From 4af3f8a7d4954d4141fbb9046af3f7f516942edc Mon Sep 17 00:00:00 2001 From: aivanov Date: Mon, 20 Jul 2015 13:22:58 +0300 Subject: [PATCH] 8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails Reviewed-by: serb, alexsch --- .../swing/JFileChooser/8002077/bug8002077.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/javax/swing/JFileChooser/8002077/bug8002077.java b/test/javax/swing/JFileChooser/8002077/bug8002077.java index ea1470d4e..c6d49a1ae 100644 --- a/test/javax/swing/JFileChooser/8002077/bug8002077.java +++ b/test/javax/swing/JFileChooser/8002077/bug8002077.java @@ -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 @@ -47,6 +47,8 @@ public class bug8002077 { 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; } @@ -58,24 +60,24 @@ public class bug8002077 { 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)); toolkit.realSync(); Util.hitMnemonics(robot, KeyEvent.VK_N); toolkit.realSync(); - robot.keyPress(KeyEvent.VK_A); - robot.keyRelease(KeyEvent.VK_A); + Util.hitKeys(robot, KeyEvent.VK_A); toolkit.realSync(); Util.hitMnemonics(robot, KeyEvent.VK_S); toolkit.realSync(); if (fileChooserState != JFileChooser.APPROVE_OPTION) { + // Close the dialog + Util.hitKeys(robot, KeyEvent.VK_ESCAPE); + toolkit.realSync(); + throw new RuntimeException("Save button is not pressed!"); } } -- GitLab