author | akolarkunnu |
Thu, 11 Oct 2018 07:22:53 -0700 | |
changeset 52128 | 1e0cdaf980f3 |
parent 47216 | 71c04702a3d5 |
child 52521 | 7335ac58f32b |
permissions | -rw-r--r-- |
36744 | 1 |
/* |
2 |
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
|
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; |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
30 |
|
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
31 |
import static org.jemmy2ext.JemmyExt.*; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
32 |
|
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
33 |
import org.jtregext.GuiTestListener; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
34 |
|
36744 | 35 |
import org.netbeans.jemmy.ClassReference; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
36 |
import org.netbeans.jemmy.ComponentChooser; |
36744 | 37 |
import org.netbeans.jemmy.operators.JButtonOperator; |
38 |
import org.netbeans.jemmy.operators.JCheckBoxOperator; |
|
39 |
import org.netbeans.jemmy.operators.JFrameOperator; |
|
40 |
import org.netbeans.jemmy.operators.JRadioButtonOperator; |
|
41 |
import org.netbeans.jemmy.operators.JSplitPaneOperator; |
|
42 |
import org.netbeans.jemmy.operators.JTextFieldOperator; |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
43 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
44 |
import org.testng.annotations.Listeners; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
45 |
import org.testng.annotations.Test; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
46 |
import static org.testng.AssertJUnit.*; |
36744 | 47 |
|
48 |
/* |
|
49 |
* @test |
|
50 |
* @key headful |
|
51 |
* @summary Verifies SwingSet3 SplitPaneDemo by performing OneClick expansion, |
|
52 |
* changing size of the divier, moving the divider to different positions |
|
53 |
* and changing the divider orientation. |
|
54 |
* |
|
55 |
* @library /sanity/client/lib/jemmy/src |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
56 |
* @library /sanity/client/lib/Extensions/src |
36744 | 57 |
* @library /sanity/client/lib/SwingSet3/src |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
58 |
* @modules java.desktop |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
59 |
* java.logging |
36744 | 60 |
* @build org.jemmy2ext.JemmyExt |
61 |
* @build com.sun.swingset3.demos.splitpane.SplitPaneDemo |
|
62 |
* @run testng SplitPaneDemoTest |
|
63 |
*/ |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
64 |
@Listeners(GuiTestListener.class) |
36744 | 65 |
public class SplitPaneDemoTest { |
66 |
||
67 |
@Test |
|
68 |
public void test() throws Exception { |
|
69 |
||
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
70 |
new ClassReference(SplitPaneDemo.class.getCanonicalName()).startApplication(); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
71 |
|
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
72 |
JFrameOperator frame = new JFrameOperator(DEMO_TITLE); |
36744 | 73 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
74 |
JSplitPaneOperator splitPane = new JSplitPaneOperator(frame); |
36744 | 75 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
76 |
// Toggle OneTouch Expandable |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
77 |
checkOneTouch(frame, splitPane, true); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
78 |
checkOneTouch(frame, splitPane, false); |
36744 | 79 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
80 |
// Check changing divider size to minimum and maximum values |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
81 |
changeDividerSize(frame, splitPane, 50); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
82 |
changeDividerSize(frame, splitPane, 6); |
36744 | 83 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
84 |
// Check moving the divider |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
85 |
checkDividerMoves(frame, splitPane, false); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
86 |
checkDividerMoves(frame, splitPane, true); |
36744 | 87 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
88 |
// Check different minumum Day/Night sizes |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
89 |
changeMinimumSizes(frame, splitPane, 100); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
90 |
changeMinimumSizes(frame, splitPane, 0); |
36744 | 91 |
} |
92 |
||
93 |
// Check for different day and night minimum size |
|
94 |
public void changeMinimumSizes(JFrameOperator frame, JSplitPaneOperator splitPane, int amount) throws Exception { |
|
95 |
for (String label : new String[]{FIRST_COMPONENT_MIN_SIZE, SECOND_COMPONENT_MIN_SIZE}) { |
|
96 |
JTextFieldOperator size = new JTextFieldOperator(getLabeledContainerOperator(frame, label)); |
|
97 |
size.enterText(Integer.toString(amount)); |
|
98 |
size.pressKey(KeyEvent.VK_ENTER); |
|
99 |
} |
|
100 |
checkDividerMoves(frame, splitPane, false); |
|
101 |
checkDividerMoves(frame, splitPane, true); |
|
102 |
} |
|
103 |
||
104 |
// Check moving of divider |
|
105 |
public void checkDividerMoves(JFrameOperator frame, JSplitPaneOperator splitPane, boolean isVertical) throws Exception { |
|
106 |
if (isVertical) { |
|
107 |
new JRadioButtonOperator(frame, VERTICAL_SPLIT).doClick(); |
|
108 |
} else { |
|
109 |
new JRadioButtonOperator(frame, HORIZONTAL_SPLIT).doClick(); |
|
110 |
} |
|
111 |
||
112 |
splitPane.moveDivider(0.0); |
|
113 |
assertEquals("Move Minimum, dividerLocation is at minimumDividerLocation", |
|
114 |
splitPane.getMinimumDividerLocation(), splitPane.getDividerLocation()); |
|
115 |
||
116 |
// use getMaximumDividerLocation() to move divider to here because using proportion 1.0 does not work |
|
117 |
splitPane.moveDivider(1.0); |
|
118 |
||
119 |
assertEquals("Move Maximum, dividerLocation is at maximumDividerLocation", |
|
120 |
splitPane.getMaximumDividerLocation(), splitPane.getDividerLocation()); |
|
121 |
||
122 |
splitPane.moveDivider(0.5); |
|
123 |
assertEquals("Move Middle, dividerLocation is at the artithmetic average of minimum and maximum DividerLocations", |
|
124 |
(splitPane.getMaximumDividerLocation() + splitPane.getMinimumDividerLocation()) / 2, splitPane.getDividerLocation()); |
|
125 |
} |
|
126 |
||
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
127 |
private void waitDividerSize(JSplitPaneOperator splitPane, int size) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
128 |
splitPane.waitState(new ComponentChooser() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
129 |
public boolean checkComponent(Component c) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
130 |
return splitPane.getDividerSize() == size; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
131 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
132 |
public String getDescription() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
133 |
return "Divider size to be " + size; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
134 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
135 |
}); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
136 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
137 |
|
36744 | 138 |
// Check changing the size of the divider |
139 |
public void changeDividerSize(JFrameOperator frame, JSplitPaneOperator splitPane, int amount) throws Exception { |
|
140 |
JTextFieldOperator size = new JTextFieldOperator(getLabeledContainerOperator(frame, DIVIDER_SIZE)); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
141 |
size.enterText(Integer.toString(amount)); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
142 |
waitDividerSize(splitPane, amount); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
143 |
} |
36744 | 144 |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
145 |
private void waitDividerLocation(JSplitPaneOperator splitPane, int location) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
146 |
splitPane.waitState(new ComponentChooser() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
147 |
public boolean checkComponent(Component c) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
148 |
return splitPane.getDividerLocation() == location; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
149 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
150 |
public String getDescription() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
151 |
return "Divider location to be " + location; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
152 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
153 |
}); |
36744 | 154 |
} |
155 |
||
156 |
public void checkOneTouch(JFrameOperator frame, JSplitPaneOperator splitPane, boolean oneTouch) throws Exception { |
|
157 |
JCheckBoxOperator checkBox = new JCheckBoxOperator(frame, ONE_TOUCH_EXPANDABLE); |
|
158 |
JButtonOperator buttonLeft = new JButtonOperator(splitPane.getDivider(), 0); |
|
159 |
JButtonOperator buttonRight = new JButtonOperator(splitPane.getDivider(), 1); |
|
160 |
int initDividerLocation = splitPane.getDividerLocation(); |
|
161 |
||
162 |
if (oneTouch) { |
|
163 |
if (!checkBox.isSelected()) { |
|
164 |
// uncheck |
|
165 |
checkBox.doClick(); |
|
166 |
} |
|
167 |
||
168 |
int left = getUIValue(splitPane, (JSplitPane sp) -> sp.getInsets().left); |
|
169 |
System.out.println("left = " + left); |
|
170 |
int right = getUIValue(splitPane, (JSplitPane sp) -> sp.getInsets().right); |
|
171 |
System.out.println("right = " + right); |
|
172 |
||
173 |
// expand full left |
|
174 |
buttonLeft.push(); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
175 |
waitDividerLocation(splitPane, left); |
36744 | 176 |
|
177 |
// expand back from full left |
|
178 |
buttonRight.push(); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
179 |
waitDividerLocation(splitPane, initDividerLocation); |
36744 | 180 |
|
181 |
// expand all the way right |
|
182 |
buttonRight.push(); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
183 |
waitDividerLocation(splitPane, splitPane.getWidth() - splitPane.getDividerSize() - right); |
36744 | 184 |
|
185 |
// Click to move back from right expansion |
|
186 |
buttonLeft.push(); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
187 |
waitDividerLocation(splitPane, initDividerLocation); |
36744 | 188 |
} |
189 |
||
190 |
// Test for case where one touch expandable is disabled |
|
191 |
if (!oneTouch) { |
|
192 |
if (checkBox.isSelected()) { |
|
193 |
// uncheck |
|
194 |
checkBox.doClick(); |
|
195 |
} |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
196 |
splitPane.waitState(new ComponentChooser() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
197 |
public boolean checkComponent(Component c) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
198 |
return !splitPane.isOneTouchExpandable(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
199 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
200 |
public String getDescription() { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
201 |
return "Split pane not to be one touch expandable"; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
202 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
203 |
}); |
36744 | 204 |
} |
205 |
} |
|
206 |
||
207 |
} |