ensure an icon doesn't exist has PNG and SVG
@@ -6,9 +6,12 @@ import lermitage.intellij.extra.icons.Model;
import org.junit.Assert;
import org.junit.Test;
+import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class SettingsServiceTest {
@@ -28,4 +31,24 @@ public class SettingsServiceTest {
Assert.fail("model ids are registered more than once: " + duplicatedIds);
}
}
+
+ @Test
+ public void icons_should_not_exist_as_svg_and_png() {
+ File iconsFolder = new File("resources/icons/");
+ File[] svgIcons = iconsFolder.listFiles((dir, name) -> name.endsWith(".svg"));
+ File[] pngIcons = iconsFolder.listFiles((dir, name) -> name.endsWith(".png"));
+ Set<String> pngIconNames = Stream.of(pngIcons)
+ .map(file -> file.getName().replace(".png", ""))
+ .collect(Collectors.toSet());
+ Assert.assertTrue(svgIcons.length > 0);
+ Assert.assertTrue(pngIcons.length > 0);
+
+ for (File svgIcon : svgIcons) {
+ String svgIconName = svgIcon.getName().replace(".svg", "");
+ Assert.assertFalse(svgIconName, pngIconNames.contains(svgIconName));
+ Assert.assertFalse(svgIconName, pngIconNames.contains(svgIconName + "_dark"));
+ Assert.assertFalse(svgIconName, pngIconNames.contains(svgIconName + "@2x"));
+ Assert.assertFalse(svgIconName, pngIconNames.contains(svgIconName + "@2x_dark"));
+ }
+ }
}
