< prev index next >

test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java

Print this page




  76             case "TEST_FOCUS":
  77                 testFocus();
  78                 break;
  79             default:
  80                 throw new RuntimeException("Unknown test: " + test);
  81         }
  82     }
  83 
  84     static void testSplash(ImageInfo test) throws Exception {
  85         SplashScreen splashScreen = SplashScreen.getSplashScreen();
  86 
  87         if (splashScreen == null) {
  88             throw new RuntimeException("Splash screen is not shown!");
  89         }
  90 
  91         Graphics2D g = splashScreen.createGraphics();
  92         Rectangle splashBounds = splashScreen.getBounds();
  93         int screenX = (int) splashBounds.getCenterX();
  94         int screenY = (int) splashBounds.getCenterY();
  95 









  96         Robot robot = new Robot();
  97         Color splashScreenColor = robot.getPixelColor(screenX, screenY);
  98 
  99         float scaleFactor = getScaleFactor();
 100         Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;
 101 
 102         if (!compare(testColor, splashScreenColor)) {
 103             throw new RuntimeException(
 104                     "Image with wrong resolution is used for splash screen!");
 105         }
 106     }
 107 
 108     static void testFocus() throws Exception {
 109 
 110         System.out.println("Focus Test!");
 111         Robot robot = new Robot();
 112         robot.setAutoDelay(50);
 113 
 114         Frame frame = new Frame();
 115         frame.setSize(100, 100);




  76             case "TEST_FOCUS":
  77                 testFocus();
  78                 break;
  79             default:
  80                 throw new RuntimeException("Unknown test: " + test);
  81         }
  82     }
  83 
  84     static void testSplash(ImageInfo test) throws Exception {
  85         SplashScreen splashScreen = SplashScreen.getSplashScreen();
  86 
  87         if (splashScreen == null) {
  88             throw new RuntimeException("Splash screen is not shown!");
  89         }
  90 
  91         Graphics2D g = splashScreen.createGraphics();
  92         Rectangle splashBounds = splashScreen.getBounds();
  93         int screenX = (int) splashBounds.getCenterX();
  94         int screenY = (int) splashBounds.getCenterY();
  95 
  96         if(splashBounds.width != IMAGE_WIDTH){
  97             throw new RuntimeException(
  98                     "SplashScreen#getBounds has wrong width");
  99         }
 100         if(splashBounds.height != IMAGE_HEIGHT){
 101             throw new RuntimeException(
 102                     "SplashScreen#getBounds has wrong height");
 103         }
 104        
 105         Robot robot = new Robot();
 106         Color splashScreenColor = robot.getPixelColor(screenX, screenY);
 107 
 108         float scaleFactor = getScaleFactor();
 109         Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;
 110 
 111         if (!compare(testColor, splashScreenColor)) {
 112             throw new RuntimeException(
 113                     "Image with wrong resolution is used for splash screen!");
 114         }
 115     }
 116 
 117     static void testFocus() throws Exception {
 118 
 119         System.out.println("Focus Test!");
 120         Robot robot = new Robot();
 121         robot.setAutoDelay(50);
 122 
 123         Frame frame = new Frame();
 124         frame.setSize(100, 100);


< prev index next >