changeset 59116:5602e016309b

8233696: [TESTBUG]Some jtreg tests fail when CAPS_LOCK is ON Reviewed-by: serb, prr
author jdv
date Fri, 22 Nov 2019 11:35:26 +0530
parents 0b1c61e76d60
children b256c7afe8cc
files test/jdk/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java test/jdk/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java test/jdk/java/awt/Toolkit/LockingKeyStateTest/LockingKeyStateTest.java test/jdk/java/awt/Toolkit/RealSync/Test.java test/jdk/javax/swing/JFileChooser/8041694/bug8041694.java
diffstat 5 files changed, 33 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java	Thu Nov 21 14:43:47 2019 +0530
+++ b/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java	Fri Nov 22 11:35:26 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -140,7 +140,8 @@
         frame.dispose();
 
         if (!textField.getText().equals("ab")) {
-            throw new RuntimeException("Focus is lost!");
+            throw new RuntimeException("Focus is lost! " +
+                "Expected 'ab' got " + "'" + textField.getText() + "'.");
         }
     }
 
--- a/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java	Thu Nov 21 14:43:47 2019 +0530
+++ b/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java	Fri Nov 22 11:35:26 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -164,7 +164,8 @@
 
         frame.dispose();
         if (!textField.getText().equals("ab")) {
-            throw new RuntimeException("Focus is lost!");
+            throw new RuntimeException("Focus is lost! " +
+                "Expected 'ab' got " + "'" + textField.getText() + "'.");
         }
     }
 
--- a/test/jdk/java/awt/Toolkit/LockingKeyStateTest/LockingKeyStateTest.java	Thu Nov 21 14:43:47 2019 +0530
+++ b/test/jdk/java/awt/Toolkit/LockingKeyStateTest/LockingKeyStateTest.java	Fri Nov 22 11:35:26 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,21 +103,24 @@
     }
 
     void doTest() throws Exception{
-        robot.waitForIdle();
-        robot.mouseMove(frame.getLocationOnScreen().x + frame.getWidth() / 2,
-                frame.getLocationOnScreen().y + frame.getHeight() / 2);
-        robot.click();
+        try {
+            robot.waitForIdle();
+            robot.mouseMove(frame.getLocationOnScreen().x + frame.getWidth() / 2,
+                    frame.getLocationOnScreen().y + frame.getHeight() / 2);
+            robot.click();
 
-        EventQueue.invokeAndWait( this::toggleAllTrue );
-        robot.waitForIdle(2000);
-        EventQueue.invokeAndWait( this::checkAllTrue );
-        EventQueue.invokeAndWait( this::toggleAllFalse );
-        robot.waitForIdle(2000);
-        EventQueue.invokeAndWait( this::checkAllFalse );
-        EventQueue.invokeAndWait( this::restoreAll );
-        robot.waitForIdle();
+            EventQueue.invokeAndWait( this::toggleAllTrue );
+            robot.waitForIdle(2000);
+            EventQueue.invokeAndWait( this::checkAllTrue );
+            EventQueue.invokeAndWait( this::toggleAllFalse );
+            robot.waitForIdle(2000);
+            EventQueue.invokeAndWait( this::checkAllFalse );
+        } finally {
+            EventQueue.invokeAndWait( this::restoreAll );
+            robot.waitForIdle();
 
-        frame.dispose();
+            frame.dispose();
+        }
     }
 
     public static void main(String argv[]) throws Exception {
--- a/test/jdk/java/awt/Toolkit/RealSync/Test.java	Thu Nov 21 14:43:47 2019 +0530
+++ b/test/jdk/java/awt/Toolkit/RealSync/Test.java	Fri Nov 22 11:35:26 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -219,7 +219,8 @@
         robot.keyPress(KeyEvent.VK_A);
         robot.keyRelease(KeyEvent.VK_A);
         realSync(f);
-        asser("a".equals(b.getText()), "Wrong text: " + b.getText());
+        asser("a".equals(b.getText()), "Expected 'a' got " + "'" +
+            b.getText() + "'.");
         f.dispose();
     }
 
@@ -242,7 +243,8 @@
         robot.keyPress(KeyEvent.VK_A);
         robot.keyRelease(KeyEvent.VK_A);
         realSync(f);
-        asser("a".equals(b.getText()), "Wrong text: " + b.getText());
+        asser("a".equals(b.getText()), "Expected 'a' got " + "'" +
+            b.getText() + "'.");
         f.dispose();
     }
 
--- a/test/jdk/javax/swing/JFileChooser/8041694/bug8041694.java	Thu Nov 21 14:43:47 2019 +0530
+++ b/test/jdk/javax/swing/JFileChooser/8041694/bug8041694.java	Fri Nov 22 11:35:26 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -101,9 +101,11 @@
                 "The selected directory is '%s'.", selectedDir.getAbsolutePath()));
             if (selectedDir.getName().equals("d")) {
                 throw new RuntimeException(
-                    "JFileChooser removed trailing spaces in the selected directory name.");
+                    "JFileChooser removed trailing spaces in the selected directory name. " +
+                    "Expected 'd ' got '" + selectedDir.getName() + "'.");
             } else if (!selectedDir.getName().equals("d ")) {
-                throw new RuntimeException("The selected directory name is not the expected 'd '.");
+                throw new RuntimeException("The selected directory name is not "
+                    + "the expected 'd ' but '" + selectedDir.getName() + "'.");
             }
         } catch (UnsupportedLookAndFeelException | AWTException | IOException | InterruptedException e) {
             throw new RuntimeException(e);