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 @test
26 @bug 6518753
27 @summary Tests the functionality of modal Swing internal frames
28 @author artem.ananiev: area=awt.modal
29 @run main/timeout=30 ModalInternalFrameTest
30 */
31
32 import java.awt.*;
33 import java.awt.event.*;
34
35 import javax.swing.*;
36
37 import sun.awt.*;
38
39 public class ModalInternalFrameTest
40 {
41 private boolean passed = true;
42
43 private JDesktopPane pane1;
44 private JDesktopPane pane2;
45
46 private JFrame frame1;
47 private JFrame frame2;
48
49 private JButton bn1;
50 private JButton bs1;
51 private JButton bn2;
52 private JButton bs2;
53
54 private Point bn1Loc;
55 private Point bs1Loc;
56 private Point bn2Loc;
57 private Point bs2Loc;
58
59 private volatile boolean unblocked1 = true;
60 private volatile boolean unblocked2 = true;
61
122 {
123 bn1Loc = bn1.getLocationOnScreen();
124 bn1Loc.translate(bn1.getWidth() / 2, bn1.getHeight() / 2);
125
126 bn2Loc = bn2.getLocationOnScreen();
127 bn2Loc.translate(bn2.getWidth() / 2, bn2.getHeight() / 2);
128
129 bs1Loc = bs1.getLocationOnScreen();
130 bs1Loc.translate(bs1.getWidth() / 2, bs1.getHeight() / 2);
131
132 bs2Loc = bs2.getLocationOnScreen();
133 bs2Loc.translate(bs2.getWidth() / 2, bs2.getHeight() / 2);
134 }
135
136 private void mouseClick(Robot r, Point p)
137 throws Exception
138 {
139 r.mouseMove(p.x, p.y);
140 r.mousePress(InputEvent.BUTTON1_MASK);
141 r.mouseRelease(InputEvent.BUTTON1_MASK);
142 ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
143 }
144
145 private void start()
146 throws Exception
147 {
148 Robot r = new Robot();
149 r.setAutoDelay(200);
150
151 unblocked1 = false;
152 mouseClick(r, bn1Loc);
153 if (!unblocked1)
154 {
155 throw new RuntimeException("Test FAILED: frame1 must be unblocked, if no modal internal frames are shown");
156 }
157
158 unblocked2 = false;
159 mouseClick(r, bn2Loc);
160 if (!unblocked2)
161 {
162 throw new RuntimeException("Test FAILED: frame2 must be unblocked, if no modal internal frame is shown in it");
163 }
164
165 mouseClick(r, bs1Loc);
166
167 unblocked1 = false;
168 mouseClick(r, bn1Loc);
176 if (!unblocked2)
177 {
178 throw new RuntimeException("Test FAILED: frame2 must be unblocked, if no modal internal frame is shown in it");
179 }
180
181 mouseClick(r, bs2Loc);
182
183 unblocked2 = false;
184 mouseClick(r, bn2Loc);
185 if (unblocked2)
186 {
187 throw new RuntimeException("Test FAILED: frame2 must be blocked, if a modal internal frame is shown in it");
188 }
189 }
190
191 private static ModalInternalFrameTest test;
192
193 public static void main(String[] args)
194 throws Exception
195 {
196 test = new ModalInternalFrameTest();
197 SwingUtilities.invokeAndWait(new Runnable()
198 {
199 public void run()
200 {
201 test.init();
202 }
203 });
204 ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
205 SwingUtilities.invokeAndWait(new Runnable()
206 {
207 public void run()
208 {
209 test.getLocations();
210 }
211 });
212 test.start();
213 }
214 }
|
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 @test
26 @bug 6518753
27 @summary Tests the functionality of modal Swing internal frames
28 @author artem.ananiev: area=awt.modal
29 @run main/timeout=30 ModalInternalFrameTest
30 */
31
32 import java.awt.*;
33 import java.awt.event.*;
34
35 import javax.swing.*;
36
37 public class ModalInternalFrameTest
38 {
39 private boolean passed = true;
40 private static Robot r;
41
42 private JDesktopPane pane1;
43 private JDesktopPane pane2;
44
45 private JFrame frame1;
46 private JFrame frame2;
47
48 private JButton bn1;
49 private JButton bs1;
50 private JButton bn2;
51 private JButton bs2;
52
53 private Point bn1Loc;
54 private Point bs1Loc;
55 private Point bn2Loc;
56 private Point bs2Loc;
57
58 private volatile boolean unblocked1 = true;
59 private volatile boolean unblocked2 = true;
60
121 {
122 bn1Loc = bn1.getLocationOnScreen();
123 bn1Loc.translate(bn1.getWidth() / 2, bn1.getHeight() / 2);
124
125 bn2Loc = bn2.getLocationOnScreen();
126 bn2Loc.translate(bn2.getWidth() / 2, bn2.getHeight() / 2);
127
128 bs1Loc = bs1.getLocationOnScreen();
129 bs1Loc.translate(bs1.getWidth() / 2, bs1.getHeight() / 2);
130
131 bs2Loc = bs2.getLocationOnScreen();
132 bs2Loc.translate(bs2.getWidth() / 2, bs2.getHeight() / 2);
133 }
134
135 private void mouseClick(Robot r, Point p)
136 throws Exception
137 {
138 r.mouseMove(p.x, p.y);
139 r.mousePress(InputEvent.BUTTON1_MASK);
140 r.mouseRelease(InputEvent.BUTTON1_MASK);
141 r.waitForIdle();
142 }
143
144 private void start()
145 throws Exception
146 {
147 r.setAutoDelay(200);
148
149 unblocked1 = false;
150 mouseClick(r, bn1Loc);
151 if (!unblocked1)
152 {
153 throw new RuntimeException("Test FAILED: frame1 must be unblocked, if no modal internal frames are shown");
154 }
155
156 unblocked2 = false;
157 mouseClick(r, bn2Loc);
158 if (!unblocked2)
159 {
160 throw new RuntimeException("Test FAILED: frame2 must be unblocked, if no modal internal frame is shown in it");
161 }
162
163 mouseClick(r, bs1Loc);
164
165 unblocked1 = false;
166 mouseClick(r, bn1Loc);
174 if (!unblocked2)
175 {
176 throw new RuntimeException("Test FAILED: frame2 must be unblocked, if no modal internal frame is shown in it");
177 }
178
179 mouseClick(r, bs2Loc);
180
181 unblocked2 = false;
182 mouseClick(r, bn2Loc);
183 if (unblocked2)
184 {
185 throw new RuntimeException("Test FAILED: frame2 must be blocked, if a modal internal frame is shown in it");
186 }
187 }
188
189 private static ModalInternalFrameTest test;
190
191 public static void main(String[] args)
192 throws Exception
193 {
194 r = new Robot();
195 test = new ModalInternalFrameTest();
196 SwingUtilities.invokeAndWait(new Runnable()
197 {
198 public void run()
199 {
200 test.init();
201 }
202 });
203 r.waitForIdle();
204 SwingUtilities.invokeAndWait(new Runnable()
205 {
206 public void run()
207 {
208 test.getLocations();
209 }
210 });
211 test.start();
212 }
213 }
|