author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 31660 | 1a4e2e5c15e1 |
child 39861 | cb667c7942dd |
permissions | -rw-r--r-- |
24539 | 1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
24539 | 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 |
||
25 |
import java.awt.Color; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.GridLayout; |
|
28 |
import java.awt.Point; |
|
29 |
import java.awt.Robot; |
|
30 |
import java.awt.event.ActionEvent; |
|
31 |
import java.awt.event.ActionListener; |
|
32 |
import java.awt.event.InputEvent; |
|
33 |
import javax.swing.JButton; |
|
34 |
import javax.swing.JFrame; |
|
35 |
import javax.swing.JPanel; |
|
36 |
import javax.swing.JScrollPane; |
|
37 |
import javax.swing.JSplitPane; |
|
38 |
import javax.swing.SwingUtilities; |
|
25129
3961e8fcb668
8044157: [TEST_BUG] Improve recently submitted AWT_Mixing tests
yan
parents:
24539
diff
changeset
|
39 |
import test.java.awt.regtesthelpers.Util; |
24539 | 40 |
|
41 |
/** |
|
42 |
* AWT/Swing overlapping test for {@link javax.swing.JSplitPane } component. |
|
31660
1a4e2e5c15e1
8130125: [TEST_BUG] add @modules to the several client tests unaffected by the automated bulk update
yan
parents:
31448
diff
changeset
|
43 |
* <p>This test puts heavyweight and lightweight components into different |
1a4e2e5c15e1
8130125: [TEST_BUG] add @modules to the several client tests unaffected by the automated bulk update
yan
parents:
31448
diff
changeset
|
44 |
* panels and test if splitter image and components itself are drawn correctly. |
24539 | 45 |
* <p>See base class for test info. |
46 |
*/ |
|
47 |
/* |
|
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
48 |
* @test |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
49 |
* @key headful |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
50 |
* @bug 6986109 |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
51 |
* @summary Overlapping test for javax.swing.JSplitPane |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
52 |
* @author sergey.grinev@oracle.com: area=awt.mixing |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
53 |
* @library ../../regtesthelpers |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
54 |
* @modules java.desktop/sun.awt |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
55 |
* java.desktop/java.awt.peer |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
56 |
* @build Util |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
57 |
* @run main JSplitPaneOverlapping |
24539 | 58 |
*/ |
59 |
public class JSplitPaneOverlapping extends OverlappingTestBase { |
|
60 |
||
61 |
private boolean clicked = false; |
|
62 |
private Point splitterLoc; |
|
63 |
private JScrollPane sp1; |
|
64 |
private JScrollPane sp2; |
|
65 |
||
66 |
protected void prepareControls() { |
|
67 |
JFrame frame = new JFrame("SplitPane Mixing"); |
|
68 |
JPanel p = new JPanel(new GridLayout()); |
|
69 |
p.setPreferredSize(new Dimension(500, 500)); |
|
70 |
propagateAWTControls(p); |
|
71 |
sp1 = new JScrollPane(p); |
|
72 |
||
73 |
JButton button = new JButton("JButton"); |
|
74 |
button.setBackground(Color.RED); |
|
75 |
button.addActionListener(new ActionListener() { |
|
76 |
||
77 |
public void actionPerformed(ActionEvent e) { |
|
78 |
clicked = true; |
|
79 |
} |
|
80 |
}); |
|
81 |
sp2 = new JScrollPane(button); |
|
82 |
||
83 |
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, sp2); |
|
84 |
splitPane.setOneTouchExpandable(false); |
|
85 |
splitPane.setDividerLocation(150); |
|
86 |
||
87 |
splitPane.setPreferredSize(new Dimension(400, 200)); |
|
88 |
||
89 |
frame.getContentPane().add(splitPane); |
|
90 |
frame.pack(); |
|
91 |
frame.setVisible(true); |
|
92 |
} |
|
93 |
||
94 |
private static final boolean ignoreFail = false; |
|
95 |
||
96 |
@Override |
|
97 |
protected boolean performTest() { |
|
98 |
try { |
|
99 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
100 |
public void run() { |
|
101 |
splitterLoc = sp2.getLocationOnScreen(); |
|
102 |
Point leftLoc = sp1.getLocationOnScreen(); |
|
103 |
leftLoc.translate(sp1.getWidth(), 0); |
|
104 |
splitterLoc.translate(-(splitterLoc.x - leftLoc.x) / 2, 30); |
|
105 |
} |
|
106 |
}); |
|
107 |
} catch (Exception e) { |
|
108 |
e.printStackTrace(); |
|
25129
3961e8fcb668
8044157: [TEST_BUG] Improve recently submitted AWT_Mixing tests
yan
parents:
24539
diff
changeset
|
109 |
throw new RuntimeException("Where is splitter?"); |
24539 | 110 |
} |
111 |
// run robot |
|
112 |
Robot robot = Util.createRobot(); |
|
113 |
robot.setAutoDelay(ROBOT_DELAY); |
|
114 |
||
115 |
robot.mouseMove(splitterLoc.x, splitterLoc.y); |
|
116 |
Util.waitForIdle(robot); |
|
117 |
||
118 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
|
119 |
robot.mouseMove(splitterLoc.x - 50, splitterLoc.y); |
|
120 |
Color c = robot.getPixelColor(splitterLoc.x - 50, splitterLoc.y); |
|
121 |
System.out.println("Actual: "+c+", (not) expected: "+AWT_VERIFY_COLOR+" at "+(splitterLoc.x - 50)+", "+ splitterLoc.y); |
|
122 |
if (!ignoreFail && c.equals(AWT_VERIFY_COLOR)) { |
|
123 |
fail("The JSplitPane drag-n-drop image did not pass pixel color check and is overlapped"); |
|
124 |
} |
|
125 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
|
126 |
||
127 |
clickAndBlink(robot, splitterLoc); |
|
128 |
||
129 |
return clicked; |
|
130 |
} |
|
131 |
||
132 |
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class |
|
133 |
public static void main(String args[]) throws InterruptedException { |
|
134 |
instance = new JSplitPaneOverlapping(); |
|
135 |
OverlappingTestBase.doMain(args); |
|
136 |
} |
|
137 |
} |