author | hseigel |
Wed, 01 Mar 2017 08:00:02 -0500 | |
changeset 46194 | 5596e6f63072 |
parent 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
1 |
/* |
31890
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
4 |
* |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
8 |
* |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
13 |
* accompanied this code). |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
14 |
* |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
18 |
* |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
21 |
* questions. |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
22 |
*/ |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
23 |
|
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
24 |
import java.awt.Robot; |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
25 |
import java.awt.event.KeyEvent; |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
26 |
import javax.swing.JFileChooser; |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
27 |
import javax.swing.SwingUtilities; |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
28 |
import javax.swing.UIManager; |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
29 |
import javax.swing.UIManager.LookAndFeelInfo; |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
30 |
|
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
31 |
/** |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
32 |
* @test |
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
31890
diff
changeset
|
33 |
* @key headful |
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
34 |
* @bug 8002077 |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
35 |
* @author Alexander Scherbatiy |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
36 |
* @summary Possible mnemonic issue on JFileChooser Save button on nimbus L&F |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
37 |
* @library ../../regtesthelpers/ |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
38 |
* @build Util |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
39 |
* @run main bug8002077 |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
40 |
*/ |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
41 |
public class bug8002077 { |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
42 |
|
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
43 |
private static volatile int fileChooserState = JFileChooser.ERROR_OPTION; |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
44 |
|
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws Exception { |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
46 |
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
47 |
if ("Nimbus".equals(info.getName())) { |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
48 |
UIManager.setLookAndFeel(info.getClassName()); |
31890
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
49 |
UIManager.put("FileChooser.openButtonMnemonic", KeyEvent.VK_O); |
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
50 |
UIManager.put("FileChooser.saveButtonMnemonic", KeyEvent.VK_S); |
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
51 |
runTest(); |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
52 |
break; |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
53 |
} |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
54 |
} |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
55 |
} |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
56 |
|
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
57 |
private static void runTest() throws Exception { |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
58 |
Robot robot = new Robot(); |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
59 |
robot.setAutoDelay(50); |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
60 |
|
31890
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
61 |
SwingUtilities.invokeLater(() -> |
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
62 |
fileChooserState = new JFileChooser().showSaveDialog(null)); |
28071
3acb75b8df45
8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
20115
diff
changeset
|
63 |
robot.waitForIdle(); |
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
64 |
|
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
65 |
Util.hitMnemonics(robot, KeyEvent.VK_N); |
28071
3acb75b8df45
8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
20115
diff
changeset
|
66 |
robot.waitForIdle(); |
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
67 |
|
31890
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
68 |
Util.hitKeys(robot, KeyEvent.VK_A); |
28071
3acb75b8df45
8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
20115
diff
changeset
|
69 |
robot.waitForIdle(); |
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
70 |
|
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
71 |
Util.hitMnemonics(robot, KeyEvent.VK_S); |
28071
3acb75b8df45
8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
20115
diff
changeset
|
72 |
robot.waitForIdle(); |
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
73 |
|
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
74 |
if (fileChooserState != JFileChooser.APPROVE_OPTION) { |
31890
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
75 |
// Close the dialog |
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
76 |
Util.hitKeys(robot, KeyEvent.VK_ESCAPE); |
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
77 |
robot.waitForIdle(); |
5e3c32fdaffb
8087110: [TESTBUG] Test javax/swing/JFileChooser/8002077/bug8002077.java fails
aivanov
parents:
28071
diff
changeset
|
78 |
|
20115
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
79 |
throw new RuntimeException("Save button is not pressed!"); |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
80 |
} |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
81 |
} |
b17c025c01bf
8024413: Add tests for issues JDK-8002077 and JDK-7199708
alexsch
parents:
diff
changeset
|
82 |
} |