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