author | hseigel |
Wed, 01 Mar 2017 08:00:02 -0500 | |
changeset 46194 | 5596e6f63072 |
parent 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
1 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
2 |
import java.awt.*; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
3 |
import java.awt.event.KeyEvent; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
4 |
import java.util.ArrayList; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
5 |
import java.util.List; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
6 |
import javax.accessibility.Accessible; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
7 |
import javax.accessibility.AccessibleContext; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
8 |
import javax.accessibility.AccessibleState; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
9 |
import javax.accessibility.AccessibleStateSet; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
10 |
import javax.swing.*; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
11 |
import javax.swing.plaf.nimbus.NimbusLookAndFeel; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
12 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
13 |
/* |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
14 |
* @test |
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
35673
diff
changeset
|
15 |
* @key headful |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
16 |
* @bug 8134116 |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
17 |
* @summary JTabbedPane$Page.getBounds throws IndexOutOfBoundsException |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
18 |
* @run main Bug8134116 |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
19 |
*/ |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
20 |
public class Bug8134116 { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
21 |
|
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
22 |
private static volatile Exception exception = null; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
23 |
|
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
24 |
public static void main(String args[]) throws Exception { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
25 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
26 |
try { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
27 |
UIManager.setLookAndFeel(new NimbusLookAndFeel()); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
28 |
} catch (Exception e) { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
29 |
throw new RuntimeException(e); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
30 |
} |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
31 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
32 |
SwingUtilities.invokeAndWait(() -> { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
33 |
JPanel panel0 = new JPanel(); |
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
34 |
JPanel panel2 = new JPanel(); |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
35 |
BadPane badPane = new BadPane(); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
36 |
badPane.add("zero", panel0); |
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
37 |
badPane.add("one", null); // no component |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
38 |
badPane.add("", panel2); // no title |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
39 |
badPane.add("", null); // no component, no title |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
40 |
// but give it that via a tabComponent |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
41 |
JPanel tabComponent = new JPanel(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
42 |
JLabel tabComponentLabel = new JLabel("three"); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
43 |
tabComponent.add(tabComponentLabel); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
44 |
badPane.setTabComponentAt(3, tabComponent); |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
45 |
JFrame frame = new JFrame(); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
46 |
frame.add(badPane); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
47 |
frame.setSize(300, 300); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
48 |
frame.setVisible(true); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
49 |
|
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
50 |
try { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
51 |
AccessibleContext ac = badPane.getAccessibleContext(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
52 |
Accessible page0 = ac.getAccessibleChild(0); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
53 |
if (page0 == null) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
54 |
// Not something being tested, but checking anyway |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
55 |
throw new RuntimeException("getAccessibleChild(0) is null"); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
56 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
57 |
Accessible page1 = ac.getAccessibleChild(1); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
58 |
if (page1 == null) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
59 |
// Not something being tested, but checking anyway |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
60 |
throw new RuntimeException("getAccessibleChild(1) is null"); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
61 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
62 |
Accessible page2 = ac.getAccessibleChild(2); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
63 |
Accessible page3 = ac.getAccessibleChild(3); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
64 |
// page0 - page3 are JTabbedPane.Page, a private inner class |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
65 |
// and is an AccessibleContext |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
66 |
// and implements Accessible and AccessibleComponent |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
67 |
AccessibleContext pac0 = page0.getAccessibleContext(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
68 |
AccessibleContext pac1 = page1.getAccessibleContext(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
69 |
AccessibleContext pac2 = page2.getAccessibleContext(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
70 |
AccessibleContext pac3 = page3.getAccessibleContext(); |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
71 |
|
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
72 |
// test Page.getBounds |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
73 |
// ensure no IndexOutOfBoundsException |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
74 |
Rectangle r0 = pac0.getAccessibleComponent().getBounds(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
75 |
// make sure second Bounds is different than first |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
76 |
Rectangle r1 = pac1.getAccessibleComponent().getBounds(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
77 |
if (r1.equals(r0)) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
78 |
String msg = "Second tab should not have same bounds as first tab"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
79 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
80 |
} |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
81 |
|
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
82 |
// test Page.getAccessibleStateSet |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
83 |
// At this point page 0 is selected |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
84 |
AccessibleStateSet accSS0 = pac0.getAccessibleStateSet(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
85 |
if (!accSS0.contains(AccessibleState.SELECTED)) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
86 |
String msg = "Empty title -> AccessibleState.SELECTED not set"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
87 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
88 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
89 |
// select second tab |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
90 |
badPane.setSelectedIndex(1); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
91 |
AccessibleStateSet accSS1 = pac1.getAccessibleStateSet(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
92 |
if (!accSS1.contains(AccessibleState.SELECTED)) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
93 |
String msg = "Second tab selected but AccessibleState.SELECTED not set"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
94 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
95 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
96 |
// select third tab |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
97 |
badPane.setSelectedIndex(2); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
98 |
AccessibleStateSet accSS2 = pac2.getAccessibleStateSet(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
99 |
if (!accSS1.contains(AccessibleState.SELECTED)) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
100 |
String msg = "Third tab selected but AccessibleState.SELECTED not set"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
101 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
102 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
103 |
// select fourth tab |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
104 |
badPane.setSelectedIndex(3); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
105 |
AccessibleStateSet accSS3 = pac3.getAccessibleStateSet(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
106 |
if (!accSS1.contains(AccessibleState.SELECTED)) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
107 |
String msg = "Fourth tab selected but AccessibleState.SELECTED not set"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
108 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
109 |
} |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
110 |
|
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
111 |
// test Page.getAccessibleIndexInParent |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
112 |
if (pac0.getAccessibleIndexInParent() == -1) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
113 |
String msg = "Empty title -> negative AccessibleIndexInParent"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
114 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
115 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
116 |
if (pac0.getAccessibleIndexInParent() != 0) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
117 |
String msg = "first tab is not at index 0 in parent"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
118 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
119 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
120 |
if (pac1.getAccessibleIndexInParent() != 1) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
121 |
String msg = "second tab (null component) is not at index 1 in parent"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
122 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
123 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
124 |
if (pac2.getAccessibleIndexInParent() != 2) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
125 |
String msg = "third tab (empty title) string is not at index 2 in parent"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
126 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
127 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
128 |
if (pac3.getAccessibleIndexInParent() != 3) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
129 |
String msg = "fourth tab (empty title, null component, has tabComponent) string is not at index 3 in parent"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
130 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
131 |
} |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
132 |
|
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
133 |
// test Page.getAccessibleName |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
134 |
String accName = pac0.getAccessibleName(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
135 |
if (!accName.equals("zero")) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
136 |
String msg = "Empty title -> empty AccessibleName"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
137 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
138 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
139 |
// test Page.getAccessibleName when component is null |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
140 |
accName = pac1.getAccessibleName(); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
141 |
if (!accName.equals("one")) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
142 |
String msg = "AccessibleName of null panel not 'one'"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
143 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
144 |
} |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
145 |
|
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
146 |
// test Page.setDisplayedMnemonicIndex |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
147 |
// Empty title -> IllegalArgumnetException |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
148 |
badPane.setDisplayedMnemonicIndexAt(0, 1); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
149 |
|
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
150 |
// test Page.updateDisplayedMnemonicIndex |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
151 |
badPane.setMnemonicAt(0, KeyEvent.VK_Z); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
152 |
if (badPane.getDisplayedMnemonicIndexAt(0) == -1) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
153 |
String msg="Empty title -> getDisplayedMnemonicIndexAt failure"; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
154 |
throw new RuntimeException(msg); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
155 |
} |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
156 |
} catch (Exception e) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
157 |
exception = e; |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
158 |
} |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
159 |
}); |
35673
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
160 |
if (exception != null) { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
161 |
System.out.println("Test failed: " + exception.getMessage()); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
162 |
throw exception; |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
163 |
} else { |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
164 |
System.out.println("Test passed."); |
61884618e67d
8145735: Tests api/javax_swing/JTabbedPane/AccessibleJTabbedPane/* are failing
ptbrunet
parents:
34393
diff
changeset
|
165 |
} |
34393
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
166 |
} |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
167 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
168 |
// The following is likely what is being done in Burp Suite |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
169 |
// https://portswigger.net/burp/ which fails in the same way, i.e. the |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
170 |
// pages List in JTabbedPane is not being managed properly and thus |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
171 |
// Page.title is "" for each page. The overridden insertTab manages titles |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
172 |
// in the subclass passing a "" title to the superclass JTabbedPane through |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
173 |
// its insertTab. Later an overridden getTitleAt returns the titles as |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
174 |
// managed by the subclass. |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
175 |
static class BadPane extends JTabbedPane { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
176 |
private List<String> titles; |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
177 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
178 |
BadPane() { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
179 |
titles = new ArrayList<String>(1); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
180 |
} |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
181 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
182 |
@Override |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
183 |
public void insertTab( String title, Icon icon, Component component, |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
184 |
String tip, int index ) { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
185 |
titles.add(index, title); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
186 |
super.insertTab("", icon, component, tip, index); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
187 |
} |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
188 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
189 |
@Override |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
190 |
public String getTitleAt(int i) { |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
191 |
return titles.get(i); |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
192 |
} |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
193 |
} |
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
194 |
|
171a07c89136
8134116: Add more comprehensive fix and regression test for JDK-8133897
ptbrunet
parents:
diff
changeset
|
195 |
} |