changeset 12456:ebdeb89e5dfb

8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails Reviewed-by: serb, alexsch
author aivanov
date Wed, 15 Jul 2015 15:48:32 +0300
parents 53ec4e8d1aee
children 7f6ac78c4644
files test/javax/swing/JFileChooser/8002077/bug8002077.java
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/test/javax/swing/JFileChooser/8002077/bug8002077.java	Wed Jul 15 14:05:09 2015 +0300
+++ b/test/javax/swing/JFileChooser/8002077/bug8002077.java	Wed Jul 15 15:48:32 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -22,7 +22,6 @@
  */
 
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import javax.swing.JFileChooser;
 import javax.swing.SwingUtilities;
@@ -46,6 +45,8 @@
         for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
             if ("Nimbus".equals(info.getName())) {
                 UIManager.setLookAndFeel(info.getClassName());
+                UIManager.put("FileChooser.openButtonMnemonic", KeyEvent.VK_O);
+                UIManager.put("FileChooser.saveButtonMnemonic", KeyEvent.VK_S);
                 runTest();
                 break;
             }
@@ -56,24 +57,24 @@
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
-        SwingUtilities.invokeLater(new Runnable() {
-            public void run() {
-                fileChooserState = new JFileChooser().showSaveDialog(null);
-            }
-        });
+        SwingUtilities.invokeLater(() ->
+                fileChooserState = new JFileChooser().showSaveDialog(null));
         robot.waitForIdle();
 
         Util.hitMnemonics(robot, KeyEvent.VK_N);
         robot.waitForIdle();
 
-        robot.keyPress(KeyEvent.VK_A);
-        robot.keyRelease(KeyEvent.VK_A);
+        Util.hitKeys(robot, KeyEvent.VK_A);
         robot.waitForIdle();
 
         Util.hitMnemonics(robot, KeyEvent.VK_S);
         robot.waitForIdle();
 
         if (fileChooserState != JFileChooser.APPROVE_OPTION) {
+            // Close the dialog
+            Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
+            robot.waitForIdle();
+
             throw new RuntimeException("Save button is not pressed!");
         }
     }