author | hseigel |
Wed, 01 Mar 2017 08:00:02 -0500 | |
changeset 46194 | 5596e6f63072 |
parent 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
26017
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
1 |
/* |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
2 |
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
4 |
* |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
8 |
* |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
13 |
* accompanied this code). |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
14 |
* |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
18 |
* |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
21 |
* questions. |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
22 |
*/ |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
23 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
24 |
import javax.swing.*; |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
25 |
import java.awt.*; |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
26 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
27 |
/* |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
28 |
* @test |
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
26017
diff
changeset
|
29 |
* @key headful |
26017
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
30 |
* @summary Construct a jframe with some components and zoom the frame and bring it back to normal state. |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
31 |
* @author Aruna Samji |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
32 |
* @library ../../../lib/testlibrary |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
33 |
* @build ExtendedRobot |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
34 |
* @run main TaskZoomJFrameRepaint |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
35 |
*/ |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
36 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
37 |
public class TaskZoomJFrameRepaint extends Task<GUIZoomFrame> { |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
38 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
39 |
public static void main (String[] args) throws Exception { |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
40 |
new TaskZoomJFrameRepaint(GUIZoomFrame.class, new ExtendedRobot()).task(); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
41 |
} |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
42 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
43 |
TaskZoomJFrameRepaint(Class guiClass, ExtendedRobot robot) throws Exception { |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
44 |
super(guiClass, robot); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
45 |
} |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
46 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
47 |
public void task() throws Exception { |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
48 |
SwingUtilities.invokeAndWait(() -> { |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
49 |
gui.jframe2.setVisible(true); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
50 |
gui.jframe2.getContentPane().removeAll(); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
51 |
gui.jframe2.getContentPane().add(gui.jbutton); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
52 |
gui.jframe2.getContentPane().add(gui.jtextarea); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
53 |
if (gui.jframe2.getExtendedState() != Frame.NORMAL) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
54 |
gui.jframe2.setExtendedState(Frame.NORMAL); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
55 |
}); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
56 |
robot.waitForIdle(1000); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
57 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
58 |
Point buttonOrigin, newbuttonOrigin, newbuttonCenter; |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
59 |
Point textareaOrigin, newtextareaOrigin, newtextareaCenter ; |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
60 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
61 |
//to find the lenght and width of the component originally |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
62 |
buttonOrigin = gui.jbutton.getLocationOnScreen(); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
63 |
textareaOrigin = gui.jtextarea.getLocationOnScreen(); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
64 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
65 |
if (Toolkit.getDefaultToolkit().isFrameStateSupported( |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
66 |
Frame.MAXIMIZED_BOTH)){ |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
67 |
//Maximising the Frame fully |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
68 |
SwingUtilities.invokeAndWait(() -> |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
69 |
gui.jframe2.setExtendedState(Frame.MAXIMIZED_BOTH) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
70 |
); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
71 |
robot.waitForIdle(1000); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
72 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
73 |
//To check whether the bitwise mask for MAXIMIZED_BOTH state is set |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
74 |
if (gui.jframe2.getExtendedState() != Frame.MAXIMIZED_BOTH) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
75 |
throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_BOTH " + |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
76 |
"is not set when the frame is in MAXIMIZED_BOTH state"); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
77 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
78 |
//To check whether the Frame is maximized fully |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
79 |
if (gui.maxBoth == false) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
80 |
throw new RuntimeException("Frame is not maximized fully"); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
81 |
} |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
82 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
83 |
//Normalising the Frame.... |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
84 |
SwingUtilities.invokeAndWait(() -> |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
85 |
gui.jframe2.setExtendedState(Frame.NORMAL) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
86 |
); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
87 |
robot.waitForIdle(1000); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
88 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
89 |
//To check whether the bitwise mask for NORMAL state is set |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
90 |
if (gui.jframe2.getExtendedState() != Frame.NORMAL) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
91 |
throw new RuntimeException("The bitwise mask Frame.NORMAL is not " + |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
92 |
"set when the frame is in NORMAL state"); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
93 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
94 |
//To check whether the Frame is normalised programmatically |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
95 |
if (! gui.normal) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
96 |
throw new RuntimeException("Frame is not restored to normal"); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
97 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
98 |
//to find the lenght and width of the component after zommed and back to normal |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
99 |
newbuttonOrigin = gui.jbutton.getLocationOnScreen(); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
100 |
newtextareaOrigin = gui.jtextarea.getLocationOnScreen(); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
101 |
newbuttonCenter = gui.jbutton.getLocationOnScreen(); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
102 |
newbuttonCenter.translate(gui.jbutton.getWidth()/2, gui.jbutton.getHeight()/2); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
103 |
newtextareaCenter = gui.jtextarea.getLocationOnScreen(); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
104 |
newtextareaCenter.translate(gui.jtextarea.getWidth()/2, gui.jtextarea.getHeight()/2); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
105 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
106 |
if((buttonOrigin.x != newbuttonOrigin.x) & (buttonOrigin.y != newbuttonOrigin.y)) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
107 |
throw new RuntimeException("The button is not positioned back " + |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
108 |
"to the original place on the screen after iconified"); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
109 |
|
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
110 |
if((textareaOrigin.x != newtextareaOrigin.x) & (textareaOrigin.y != newtextareaOrigin.y)) |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
111 |
throw new RuntimeException("The TextArea is not positioned back " + |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
112 |
"to the original place on the screen after iconified"); |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
113 |
} |
4d9ac57cd697
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
dermashov
parents:
diff
changeset
|
114 |
} |