changeset 10872:a78490a8d5fa

8193185: [Windows] System test failures in scene size tests with HiDPI Reviewed-by: kcr
author rkamath
date Mon, 12 Mar 2018 21:32:16 +0530
parents 69f6ef371e61
children f82a2e491b72
files tests/system/src/test/java/test/javafx/scene/NewSceneSizeTest.java tests/system/src/test/java/test/javafx/scene/RestoreSceneSizeTest.java
diffstat 2 files changed, 25 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/tests/system/src/test/java/test/javafx/scene/NewSceneSizeTest.java	Mon Mar 12 08:27:04 2018 -0700
+++ b/tests/system/src/test/java/test/javafx/scene/NewSceneSizeTest.java	Mon Mar 12 21:32:16 2018 +0530
@@ -41,12 +41,13 @@
 import org.junit.Test;
 
 import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
 
 public class NewSceneSizeTest {
     static CountDownLatch startupLatch;
     static volatile Stage stage;
 
+    private static double scaleX, scaleY;
+
     public static void main(String[] args) throws Exception {
         initFX();
         try {
@@ -65,8 +66,12 @@
         public void start(Stage primaryStage) throws Exception {
             primaryStage.setScene(new Scene(new VBox()));
             stage = primaryStage;
-            stage.addEventHandler(WindowEvent.WINDOW_SHOWN, e ->
-                    Platform.runLater(startupLatch::countDown));
+            stage.addEventHandler(WindowEvent.WINDOW_SHOWN, e -> {
+                scaleX = stage.getOutputScaleX();
+                scaleY = stage.getOutputScaleY();
+
+                Platform.runLater(startupLatch::countDown);
+            });
             stage.show();
         }
     }
@@ -86,7 +91,6 @@
 
     @Test
     public void testNewSceneSize() throws Exception {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8193185
         Thread.sleep(200);
         final int nTries = 100;
         Stage childStage[] = new Stage[nTries];
@@ -106,8 +110,8 @@
                     stage.setResizable(fI % 2 == 0);
                     Scene scene = new Scene(new VBox(), 300 - fI, 200 - fI);
                     stage.setScene(scene);
-                    w[fI] = stage.getScene().getWidth();
-                    h[fI] = stage.getScene().getHeight();
+                    w[fI] = (Math.ceil((300 - fI) * scaleX)) / scaleX;
+                    h[fI] = (Math.ceil((200 - fI) * scaleY)) / scaleY;
                     Assert.assertTrue(w[fI] > 1);
                     Assert.assertTrue(h[fI] > 1);
                     stage.widthProperty().addListener(listenerW = (v, o, n) -> {
@@ -130,9 +134,9 @@
         Thread.sleep(200);
         for (int i = 0; i < nTries; i++) {
             Assert.assertEquals("Wrong scene " + i + " width", w[i],
-                                           childStage[i].getScene().getWidth());
+                                    childStage[i].getScene().getWidth(), 0.1);
             Assert.assertEquals("Wrong scene " + i + " height", h[i],
-                                          childStage[i].getScene().getHeight());
+                                    childStage[i].getScene().getHeight(), 0.1);
         }
     }
 
--- a/tests/system/src/test/java/test/javafx/scene/RestoreSceneSizeTest.java	Mon Mar 12 08:27:04 2018 -0700
+++ b/tests/system/src/test/java/test/javafx/scene/RestoreSceneSizeTest.java	Mon Mar 12 21:32:16 2018 +0530
@@ -46,8 +46,10 @@
 public class RestoreSceneSizeTest {
     static CountDownLatch startupLatch;
     static Stage stage;
-    static double w;
-    static double h;
+
+    private static final int WIDTH = 234;
+    private static final int HEIGHT = 255;
+    private static double scaleX, scaleY;
 
     public static void main(String[] args) throws Exception {
         initFX();
@@ -65,13 +67,15 @@
 
         @Override
         public void start(Stage primaryStage) throws Exception {
-            primaryStage.setScene(new Scene(new VBox(), 234, 255));
+            primaryStage.setScene(new Scene(new VBox(), WIDTH, HEIGHT));
             stage = primaryStage;
-            w = stage.getScene().getWidth();
-            h = stage.getScene().getHeight();
             stage.setFullScreen(true);
-            stage.addEventHandler(WindowEvent.WINDOW_SHOWN, e ->
-                    Platform.runLater(startupLatch::countDown));
+            stage.addEventHandler(WindowEvent.WINDOW_SHOWN, e -> {
+                scaleX = stage.getOutputScaleX();
+                scaleY = stage.getOutputScaleY();
+
+                Platform.runLater(startupLatch::countDown);
+            });
             stage.show();
         }
     }
@@ -91,11 +95,12 @@
 
     @Test
     public void testUnfullscreenSize() throws Exception {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8193185
         // Disable on Mac until JDK-8176813 is fixed
         assumeTrue(!PlatformUtil.isMac());
 
         Thread.sleep(200);
+        final double w = (Math.ceil(WIDTH * scaleX)) / scaleX;
+        final double h = (Math.ceil(HEIGHT * scaleY)) / scaleY;
         Assert.assertTrue(stage.isShowing());
         Assert.assertTrue(stage.isFullScreen());