public static boolean canRunTest(@NotNull Class testCaseClass) {
   if (GraphicsEnvironment.isHeadless()) {
     for (Class<?> clazz = testCaseClass; clazz != null; clazz = clazz.getSuperclass()) {
       if (clazz.getAnnotation(SkipInHeadlessEnvironment.class) != null) {
         System.out.println(
             "Class '"
                 + testCaseClass.getName()
                 + "' is skipped because it requires working UI environment");
         return false;
       }
     }
   }
   return true;
 }
Esempio n. 2
0
 private static Icon createColoredIcon(Color color) {
   Icon icon = icons_cache.get(color);
   if (icon != null) return icon;
   final BufferedImage image =
       GraphicsEnvironment.getLocalGraphicsEnvironment()
           .getDefaultScreenDevice()
           .getDefaultConfiguration()
           .createCompatibleImage(16, 16, Color.TRANSLUCENT);
   final Graphics g = image.getGraphics();
   g.setColor(color);
   g.fillRect(0, 0, 16, 16);
   g.dispose();
   icon = new ImageIcon(image);
   icons_cache.put(color, icon);
   return icon;
 }
Esempio n. 3
0
  public static boolean isHeadlessEnv() {
    Application app = ApplicationManager.getApplication();
    if (app == null) return GraphicsEnvironment.isHeadless();

    return app.isUnitTestMode() || app.isHeadlessEnvironment();
  }