author | hseigel |
Wed, 01 Mar 2017 08:00:02 -0500 | |
changeset 46194 | 5596e6f63072 |
parent 39006 | fd8c3312d043 |
permissions | -rw-r--r-- |
36744 | 1 |
/* |
2 |
* Copyright (c) 2011, 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 |
||
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
24 |
import org.jtregext.GuiTestListener; |
36744 | 25 |
import com.sun.swingset3.demos.spinner.SpinnerDemo; |
26 |
import static com.sun.swingset3.demos.spinner.SpinnerDemo.DEMO_TITLE; |
|
27 |
import java.text.DecimalFormat; |
|
28 |
import static org.testng.AssertJUnit.*; |
|
29 |
import org.testng.annotations.Test; |
|
30 |
import org.netbeans.jemmy.ClassReference; |
|
31 |
import org.netbeans.jemmy.operators.JFrameOperator; |
|
32 |
import org.netbeans.jemmy.operators.JSpinnerOperator; |
|
33 |
import org.netbeans.jemmy.operators.JTextFieldOperator; |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
34 |
import org.testng.annotations.Listeners; |
36744 | 35 |
|
36 |
/* |
|
37 |
* @test |
|
38 |
* @key headful |
|
39 |
* @summary Verifies SwingSet3 SpinnerDemo by adjusting each spinner value via |
|
40 |
* the spinner button and checking text field value. |
|
41 |
* |
|
42 |
* @library /sanity/client/lib/jemmy/src |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
43 |
* @library /sanity/client/lib/Extensions/src |
36744 | 44 |
* @library /sanity/client/lib/SwingSet3/src |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
45 |
* @modules java.desktop |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
46 |
* java.logging |
36744 | 47 |
* @build org.jemmy2ext.JemmyExt |
48 |
* @build com.sun.swingset3.demos.spinner.SpinnerDemo |
|
49 |
* @run testng SpinnerDemoTest |
|
50 |
*/ |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
51 |
@Listeners(GuiTestListener.class) |
36744 | 52 |
public class SpinnerDemoTest { |
53 |
||
54 |
private static final int SPINNERS_COUNT = 9; |
|
55 |
private static final DecimalFormat decimalFormat = new DecimalFormat(); |
|
56 |
||
57 |
@Test |
|
58 |
public void test() throws Exception { |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
59 |
new ClassReference(SpinnerDemo.class.getCanonicalName()).startApplication(); |
36744 | 60 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
61 |
JFrameOperator frame = new JFrameOperator(DEMO_TITLE); |
36744 | 62 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
63 |
// Check changing different spinners |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
64 |
for (int i = 0; i < SPINNERS_COUNT; i++) { |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
65 |
changeValues(frame, i); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
66 |
} |
36744 | 67 |
} |
68 |
||
69 |
private void changeValues(JFrameOperator jfo, int spinnerIndex) throws Exception { |
|
70 |
JSpinnerOperator spinner = new JSpinnerOperator(jfo, spinnerIndex); |
|
71 |
JTextFieldOperator jtfo = new JTextFieldOperator(spinner); |
|
72 |
float originalFieldValue = decimalFormat.parse(jtfo.getText()).floatValue(); |
|
73 |
float finalFieldValue; |
|
74 |
||
75 |
// increment by one the value via spinner |
|
76 |
spinner.getIncreaseOperator().push(); |
|
77 |
finalFieldValue = decimalFormat.parse(jtfo.getText()).floatValue(); |
|
78 |
||
79 |
// check that the value was increased |
|
80 |
assertTrue("Increment Spinner " + spinner |
|
81 |
+ " (originalFieldValue, actual value: " + originalFieldValue + " " |
|
82 |
+ "< finalFieldValue, actual value = " + finalFieldValue + ")", |
|
83 |
originalFieldValue < finalFieldValue); |
|
84 |
||
85 |
// decrease value via spinner |
|
86 |
spinner.getDecreaseOperator().push(); |
|
87 |
finalFieldValue = decimalFormat.parse(jtfo.getText()).floatValue(); |
|
88 |
||
89 |
// check that the value was decrimented |
|
90 |
assertTrue("Decrement Spinner " + spinner |
|
91 |
+ " (originalFieldValue, actual value: " + originalFieldValue + " " |
|
92 |
+ ">= finalFieldValue, actual value = " + finalFieldValue + ")", |
|
93 |
originalFieldValue >= finalFieldValue); |
|
94 |
} |
|
95 |
||
96 |
} |