-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checking Width and Height from the CLI
- Loading branch information
Showing
10 changed files
with
204 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.sterl.svg2png; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Collection; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.apache.commons.io.filefilter.TrueFileFilter; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
public class AbstractFileTest { | ||
protected static final File tmpDir = new File("./tmp1"); | ||
|
||
@BeforeEach | ||
public void before() throws IOException { | ||
tmpDir.mkdirs(); | ||
tmpDir.deleteOnExit(); | ||
Collection<File> files = FileUtils.listFiles(tmpDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); | ||
for (File file : files) { | ||
file.delete(); | ||
} | ||
} | ||
|
||
@AfterAll | ||
public static void after() throws Exception { | ||
clean(); | ||
} | ||
|
||
protected static void clean() { | ||
try { | ||
FileUtils.deleteDirectory(tmpDir); | ||
} catch (Exception e) { | ||
System.err.println("TEST: Failed to clean " + tmpDir + " -> " + e.getCause().getMessage()); | ||
Collection<File> files = FileUtils.listFiles(tmpDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); | ||
for (File file : files) { | ||
file.delete(); | ||
file.deleteOnExit(); | ||
} | ||
tmpDir.deleteOnExit(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.sterl.svg2png; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
import static org.sterl.svg2png.TestUtil.svgPath; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.sterl.svg2png.config.FileOutput; | ||
import org.sterl.svg2png.config.OutputConfig; | ||
|
||
class MainTest extends AbstractFileTest { | ||
|
||
/** | ||
* https://github.com/sterlp/svg2png/issues/21 | ||
*/ | ||
@Test | ||
public void testBug21() throws Exception { | ||
// WHEN | ||
final OutputConfig config = Main.buildOutputConfig(new String[] { | ||
"-f", | ||
svgPath("sample.svg"), | ||
"-c", | ||
getClass().getResource("/Bug21-config.json").toURI().toString(), | ||
"-o", "./" | ||
}); | ||
|
||
// THEN | ||
for (FileOutput f : config.getFiles()) { | ||
assertNotEquals(f.getWidth(), -1); | ||
assertNotEquals(f.getHeight(), -1); | ||
} | ||
assertEquals(config.getFiles().get(0).getWidth(), 16); | ||
assertEquals(config.getFiles().get(0).getHeight(), 16); | ||
|
||
assertEquals(config.getFiles().get(1).getWidth(), 38); | ||
assertEquals(config.getFiles().get(1).getHeight(), 32); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"files": [ | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_16x16", | ||
"height": 16, | ||
"width": 16 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_16x16@2x", | ||
"height": 32, | ||
"width": 38 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_32x32", | ||
"height": 32, | ||
"width": 32 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_32x32@2x", | ||
"height": 64, | ||
"width": 64 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_128x128", | ||
"height": 128, | ||
"width": 128 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_128x128@2x", | ||
"height": 256, | ||
"width": 256 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_256x256", | ||
"height": 256, | ||
"width": 256 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_256x256@2x", | ||
"height": 512, | ||
"width": 512 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_512x512", | ||
"height": 512, | ||
"width": 512 | ||
}, | ||
{ | ||
"directory": "icon.iconset", | ||
"nameSuffix": "_512x512@2x", | ||
"height": 1024, | ||
"width": 1024 | ||
} | ||
] | ||
} |