author | mgronlun |
Sun, 22 Sep 2019 17:31:57 +0200 | |
branch | JEP-349-branch |
changeset 58259 | b6efcf2217f1 |
parent 54241 | 3c369ad8c4ac |
permissions | -rw-r--r-- |
36744 | 1 |
/* |
54241
3c369ad8c4ac
8216353: Use utility APIs introduced in org/netbeans/jemmy/util/LookAndFeel class in client sanity test cases
vagarwal
parents:
52521
diff
changeset
|
2 |
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. |
36744 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
import com.sun.swingset3.demos.splitpane.SplitPaneDemo; |
|
25 |
import static com.sun.swingset3.demos.splitpane.SplitPaneDemo.*; |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
26 |
|
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
27 |
import java.awt.Component; |
36744 | 28 |
import java.awt.event.KeyEvent; |
29 |
import javax.swing.JSplitPane; |
|
52521
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
30 |
import javax.swing.UIManager; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
31 |
|
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
32 |
import static org.jemmy2ext.JemmyExt.*; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
33 |
|
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
34 |
import org.jtregext.GuiTestListener; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
35 |
|
36744 | 36 |
import org.netbeans.jemmy.ClassReference; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
37 |
import org.netbeans.jemmy.ComponentChooser; |
36744 | 38 |
import org.netbeans.jemmy.operators.JButtonOperator; |
39 |
import org.netbeans.jemmy.operators.JCheckBoxOperator; |
|
40 |
import org.netbeans.jemmy.operators.JFrameOperator; |
|
41 |
import org.netbeans.jemmy.operators.JRadioButtonOperator; |
|
42 |
import org.netbeans.jemmy.operators.JSplitPaneOperator; |
|
43 |
import org.netbeans.jemmy.operators.JTextFieldOperator; |
|
54241
3c369ad8c4ac
8216353: Use utility APIs introduced in org/netbeans/jemmy/util/LookAndFeel class in client sanity test cases
vagarwal
parents:
52521
diff
changeset
|
44 |
import org.netbeans.jemmy.util.LookAndFeel; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
45 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
46 |
import org.testng.annotations.Listeners; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
47 |
import org.testng.annotations.Test; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
48 |
import static org.testng.AssertJUnit.*; |
36744 | 49 |
|
50 |
/* |
|
51 |
* @test |
|
52 |
* @key headful |
|
53 |
* @summary Verifies SwingSet3 SplitPaneDemo by performing OneClick expansion, |
|
54 |
* changing size of the divier, moving the divider to different positions |
|
55 |
* and changing the divider orientation. |
|
56 |
* |
|
57 |
* @library /sanity/client/lib/jemmy/src |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
58 |
* @library /sanity/client/lib/Extensions/src |
36744 | 59 |
* @library /sanity/client/lib/SwingSet3/src |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
60 |
* @modules java.desktop |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
61 |
* java.logging |
36744 | 62 |
* @build org.jemmy2ext.JemmyExt |
63 |
* @build com.sun.swingset3.demos.splitpane.SplitPaneDemo |
|
52521
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
64 |
* @run testng/timeout=600 SplitPaneDemoTest |
36744 | 65 |
*/ |
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
66 |
@Listeners(GuiTestListener.class) |
36744 | 67 |
public class SplitPaneDemoTest { |
68 |
||
52521
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
69 |
@Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class) |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
70 |
public void test(String lookAndFeel) throws Exception { |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
71 |
UIManager.setLookAndFeel(lookAndFeel); |
36744 | 72 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
73 |
new ClassReference(SplitPaneDemo.class.getCanonicalName()).startApplication(); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
74 |
|
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
75 |
JFrameOperator frame = new JFrameOperator(DEMO_TITLE); |
36744 | 76 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
77 |
JSplitPaneOperator splitPane = new JSplitPaneOperator(frame); |
36744 | 78 |
|
52521
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
79 |
// OneTouch feature is not available in GTK L&F |
54241
3c369ad8c4ac
8216353: Use utility APIs introduced in org/netbeans/jemmy/util/LookAndFeel class in client sanity test cases
vagarwal
parents:
52521
diff
changeset
|
80 |
if(!LookAndFeel.isGTK()) { |
52521
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
81 |
// Toggle OneTouch Expandable |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
82 |
checkOneTouch(frame, splitPane, true); |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
83 |
checkOneTouch(frame, splitPane, false); |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
84 |
} |
36744 | 85 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
86 |
// Check changing divider size to minimum and maximum values |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
87 |
changeDividerSize(frame, splitPane, 50); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
88 |
changeDividerSize(frame, splitPane, 6); |
36744 | 89 |
|
90 |
||
52521
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
91 |
// TODO Skipping this code for Motif L&F as the fix for "CODETOOLS-7902324" |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
92 |
// is deferred now |
54241
3c369ad8c4ac
8216353: Use utility APIs introduced in org/netbeans/jemmy/util/LookAndFeel class in client sanity test cases
vagarwal
parents:
52521
diff
changeset
|
93 |
if(!LookAndFeel.isMotif()) { |
52521
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
94 |
// Check moving the divider |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
95 |
checkDividerMoves(frame, splitPane, false); |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
96 |
checkDividerMoves(frame, splitPane, true); |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
97 |
|
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
98 |
// Check different minumum Day/Night sizes |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
99 |
changeMinimumSizes(frame, splitPane, 100); |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
100 |
changeMinimumSizes(frame, splitPane, 0); |
7335ac58f32b
8211443: Enable different look and feels in SwingSet3 demo test SplitPaneDemoTest
sveerabhadra
parents:
47216
diff
changeset
|
101 |
} |
36744 | 102 |
} |
103 |
||
104 |
// Check for different day and night minimum size |
|
105 |
public void changeMinimumSizes(JFrameOperator frame, JSplitPaneOperator splitPane, int amount) throws Exception { |
|
106 |
for (String label : new String[]{FIRST_COMPONENT_MIN_SIZE, SECOND_COMPONENT_MIN_SIZE}) { |
|
107 |
JTextFieldOperator size = new JTextFieldOperator(getLabeledContainerOperator(frame, label)); |
|
108 |
size.enterText(Integer.toString(amount)); |
|
109 |
size.pressKey(KeyEvent.VK_ENTER); |
|
110 |
} |
|
111 |
checkDividerMoves(frame, splitPane, false); |
|
112 |
checkDividerMoves(frame, splitPane, true); |
|
113 |
} |
|
114 |
||
115 |
// Check moving of divider |
|
116 |
public void checkDividerMoves(JFrameOperator frame, JSplitPaneOperator splitPane, boolean isVertical) throws Exception { |
|
117 |
if (isVertical) { |
|
118 |
new JRadioButtonOperator(frame, VERTICAL_SPLIT).doClick(); |
|
119 |
} else { |
|
120 |
new JRadioButtonOperator(frame, HORIZONTAL_SPLIT).doClick(); |
|
121 |
} |
|
122 |
||
123 |
splitPane.moveDivider(0.0); |
|
124 |
assertEquals("Move Minimum, dividerLocation is at minimumDividerLocation", |
|
125 |
splitPane.getMinimumDividerLocation(), splitPane.getDividerLocation()); |
|
126 |
||
127 |
// use getMaximumDividerLocation() to move divider to here because using proportion 1.0 does not work |
|
128 |
splitPane.moveDivider(1.0); |
|
129 |
||
130 |
assertEquals("Move Maximum, dividerLocation is at maximumDividerLocation", |
|
131 |
splitPane.getMaximumDividerLocation(), splitPane.getDividerLocation()); |
|
132 |
||
133 |
splitPane.moveDivider(0.5); |
|
134 |
assertEquals("Move Middle, dividerLocation is at the artithmetic average of minimum and maximum DividerLocations", |
|
135 |
(splitPane.getMaximumDividerLocation() + splitPane.getMinimumDividerLocation()) / 2, splitPane.getDividerLocation()); |
|
136 |
} |
|
137 |
||
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
138 |
private void waitDividerSize(JSplitPaneOperator splitPane, int size) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
139 |
splitPane.waitState(new ComponentChooser() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
140 |
public boolean checkComponent(Component c) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
141 |
return splitPane.getDividerSize() == size; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
142 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
143 |
public String getDescription() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
144 |
return "Divider size to be " + size; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
145 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
146 |
}); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
147 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
148 |
|
36744 | 149 |
// Check changing the size of the divider |
150 |
public void changeDividerSize(JFrameOperator frame, JSplitPaneOperator splitPane, int amount) throws Exception { |
|
151 |
JTextFieldOperator size = new JTextFieldOperator(getLabeledContainerOperator(frame, DIVIDER_SIZE)); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
152 |
size.enterText(Integer.toString(amount)); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
153 |
waitDividerSize(splitPane, amount); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
154 |
} |
36744 | 155 |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
156 |
private void waitDividerLocation(JSplitPaneOperator splitPane, int location) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
157 |
splitPane.waitState(new ComponentChooser() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
158 |
public boolean checkComponent(Component c) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
159 |
return splitPane.getDividerLocation() == location; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
160 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
161 |
public String getDescription() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
162 |
return "Divider location to be " + location; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
163 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
164 |
}); |
36744 | 165 |
} |
166 |
||
167 |
public void checkOneTouch(JFrameOperator frame, JSplitPaneOperator splitPane, boolean oneTouch) throws Exception { |
|
168 |
JCheckBoxOperator checkBox = new JCheckBoxOperator(frame, ONE_TOUCH_EXPANDABLE); |
|
169 |
JButtonOperator buttonLeft = new JButtonOperator(splitPane.getDivider(), 0); |
|
170 |
JButtonOperator buttonRight = new JButtonOperator(splitPane.getDivider(), 1); |
|
171 |
int initDividerLocation = splitPane.getDividerLocation(); |
|
172 |
||
173 |
if (oneTouch) { |
|
174 |
if (!checkBox.isSelected()) { |
|
175 |
// uncheck |
|
176 |
checkBox.doClick(); |
|
177 |
} |
|
178 |
||
179 |
int left = getUIValue(splitPane, (JSplitPane sp) -> sp.getInsets().left); |
|
180 |
System.out.println("left = " + left); |
|
181 |
int right = getUIValue(splitPane, (JSplitPane sp) -> sp.getInsets().right); |
|
182 |
System.out.println("right = " + right); |
|
183 |
||
184 |
// expand full left |
|
185 |
buttonLeft.push(); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
186 |
waitDividerLocation(splitPane, left); |
36744 | 187 |
|
188 |
// expand back from full left |
|
189 |
buttonRight.push(); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
190 |
waitDividerLocation(splitPane, initDividerLocation); |
36744 | 191 |
|
192 |
// expand all the way right |
|
193 |
buttonRight.push(); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
194 |
waitDividerLocation(splitPane, splitPane.getWidth() - splitPane.getDividerSize() - right); |
36744 | 195 |
|
196 |
// Click to move back from right expansion |
|
197 |
buttonLeft.push(); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
198 |
waitDividerLocation(splitPane, initDividerLocation); |
36744 | 199 |
} |
200 |
||
201 |
// Test for case where one touch expandable is disabled |
|
202 |
if (!oneTouch) { |
|
203 |
if (checkBox.isSelected()) { |
|
204 |
// uncheck |
|
205 |
checkBox.doClick(); |
|
206 |
} |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
207 |
splitPane.waitState(new ComponentChooser() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
208 |
public boolean checkComponent(Component c) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
209 |
return !splitPane.isOneTouchExpandable(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
210 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
211 |
public String getDescription() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
212 |
return "Split pane not to be one touch expandable"; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
213 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
214 |
}); |
36744 | 215 |
} |
216 |
} |
|
217 |
||
218 |
} |