author | jboes |
Fri, 08 Nov 2019 11:15:16 +0000 | |
changeset 59029 | 3786a0962570 |
parent 50834 | 9cf279436b9d |
permissions | -rw-r--r-- |
1978
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
1 |
/* |
50834
9cf279436b9d
8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. |
1978
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
4 |
* |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
8 |
* |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
13 |
* accompanied this code). |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
14 |
* |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
18 |
* |
5506 | 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. |
|
1978
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
22 |
*/ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
23 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
24 |
/* |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
25 |
@test %W% %E% |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
32427
diff
changeset
|
26 |
@key headful |
1978
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
27 |
@bug 6777320 |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
28 |
@summary PIT : Canvas is not fully painted on the internal frame & internal frame goes behind the canvas |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
29 |
@author dmitry.cherepanov@...: area=awt.mixing |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
30 |
@library ../regtesthelpers |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
31 |
@build Util |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
32 |
@run main MixingOnShrinkingHWButton |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
33 |
*/ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
34 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
35 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
36 |
/** |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
37 |
* MixingOnDialog.java |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
38 |
* |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
39 |
* summary: Tests whether awt.Button and swing.JButton mix correctly |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
40 |
* when awt.Button's width got shrinked |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
41 |
*/ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
42 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
43 |
import java.awt.*; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
44 |
import java.awt.event.*; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
45 |
import javax.swing.*; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
46 |
import test.java.awt.regtesthelpers.Util; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
47 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
48 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
49 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
50 |
public class MixingOnShrinkingHWButton |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
51 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
52 |
static volatile boolean heavyClicked = false; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
53 |
static volatile boolean lightClicked = false; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
54 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
55 |
private static void init() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
56 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
57 |
// Create components |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
58 |
final Dialog d = new Dialog((Frame)null, "Button-JButton mix test"); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
59 |
final Button heavy = new Button(" Heavyweight Button "); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
60 |
final JButton light = new JButton(" LW Button "); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
61 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
62 |
// Actions for the buttons add appropriate number to the test sequence |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
63 |
heavy.addActionListener(new java.awt.event.ActionListener() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
64 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
65 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
66 |
heavyClicked = true; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
67 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
68 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
69 |
); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
70 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
71 |
light.addActionListener(new java.awt.event.ActionListener() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
72 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
73 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
74 |
lightClicked = true; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
75 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
76 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
77 |
); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
78 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
79 |
// Shrink the HW button under LW button |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
80 |
heavy.setBounds(30, 30, 100, 100); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
81 |
light.setBounds(40, 30, 100, 100); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
82 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
83 |
// Put the components into the frame |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
84 |
d.setLayout(null); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
85 |
d.add(light); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
86 |
d.add(heavy); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
87 |
d.setBounds(50, 50, 400, 400); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
88 |
d.setVisible(true); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
89 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
90 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
91 |
Robot robot = Util.createRobot(); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
92 |
robot.setAutoDelay(20); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
93 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
94 |
Util.waitForIdle(robot); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
95 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
96 |
// Move the mouse pointer to the position where both |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
97 |
// buttons overlap |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
98 |
Point heavyLoc = heavy.getLocationOnScreen(); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
99 |
robot.mouseMove(heavyLoc.x + 20, heavyLoc.y + 20); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
100 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
101 |
// Now perform the click at this point |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
102 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
103 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
104 |
Util.waitForIdle(robot); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
105 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
106 |
// If the buttons are correctly mixed, the test sequence |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
107 |
// is equal to the check sequence. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
108 |
if (lightClicked == true) { |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
109 |
MixingOnShrinkingHWButton.pass(); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
110 |
} else { |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
111 |
MixingOnShrinkingHWButton.fail("The lightweight component left behind the heavyweight one."); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
112 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
113 |
}//End init() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
114 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
115 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
116 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
117 |
/***************************************************** |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
118 |
* Standard Test Machinery Section |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
119 |
* DO NOT modify anything in this section -- it's a |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
120 |
* standard chunk of code which has all of the |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
121 |
* synchronisation necessary for the test harness. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
122 |
* By keeping it the same in all tests, it is easier |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
123 |
* to read and understand someone else's test, as |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
124 |
* well as insuring that all tests behave correctly |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
125 |
* with the test harness. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
126 |
* There is a section following this for test- |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
127 |
* classes |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
128 |
******************************************************/ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
129 |
private static boolean theTestPassed = false; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
130 |
private static boolean testGeneratedInterrupt = false; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
131 |
private static String failureMessage = ""; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
132 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
133 |
private static Thread mainThread = null; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
134 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
135 |
private static int sleepTime = 300000; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
136 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
137 |
// Not sure about what happens if multiple of this test are |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
138 |
// instantiated in the same VM. Being static (and using |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
139 |
// static vars), it aint gonna work. Not worrying about |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
140 |
// it for now. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
141 |
public static void main( String args[] ) throws InterruptedException |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
142 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
143 |
mainThread = Thread.currentThread(); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
144 |
try |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
145 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
146 |
init(); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
147 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
148 |
catch( TestPassedException e ) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
149 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
150 |
//The test passed, so just return from main and harness will |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
151 |
// interepret this return as a pass |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
152 |
return; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
153 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
154 |
//At this point, neither test pass nor test fail has been |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
155 |
// called -- either would have thrown an exception and ended the |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
156 |
// test, so we know we have multiple threads. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
157 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
158 |
//Test involves other threads, so sleep and wait for them to |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
159 |
// called pass() or fail() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
160 |
try |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
161 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
162 |
Thread.sleep( sleepTime ); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
163 |
//Timed out, so fail the test |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
164 |
throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
165 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
166 |
catch (InterruptedException e) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
167 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
168 |
//The test harness may have interrupted the test. If so, rethrow the exception |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
169 |
// so that the harness gets it and deals with it. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
170 |
if( ! testGeneratedInterrupt ) throw e; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
171 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
172 |
//reset flag in case hit this code more than once for some reason (just safety) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
173 |
testGeneratedInterrupt = false; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
174 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
175 |
if ( theTestPassed == false ) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
176 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
177 |
throw new RuntimeException( failureMessage ); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
178 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
179 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
180 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
181 |
}//main |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
182 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
183 |
public static synchronized void setTimeoutTo( int seconds ) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
184 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
185 |
sleepTime = seconds * 1000; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
186 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
187 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
188 |
public static synchronized void pass() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
189 |
{ |
50834
9cf279436b9d
8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents:
47216
diff
changeset
|
190 |
System.out.println( "The test passed." ); |
9cf279436b9d
8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents:
47216
diff
changeset
|
191 |
System.out.println( "The test is over, hit Ctl-C to stop Java VM" ); |
1978
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
192 |
//first check if this is executing in main thread |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
193 |
if ( mainThread == Thread.currentThread() ) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
194 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
195 |
//Still in the main thread, so set the flag just for kicks, |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
196 |
// and throw a test passed exception which will be caught |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
197 |
// and end the test. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
198 |
theTestPassed = true; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
199 |
throw new TestPassedException(); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
200 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
201 |
theTestPassed = true; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
202 |
testGeneratedInterrupt = true; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
203 |
mainThread.interrupt(); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
204 |
}//pass() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
205 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
206 |
public static synchronized void fail() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
207 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
208 |
//test writer didn't specify why test failed, so give generic |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
209 |
fail( "it just plain failed! :-)" ); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
210 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
211 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
212 |
public static synchronized void fail( String whyFailed ) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
213 |
{ |
50834
9cf279436b9d
8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents:
47216
diff
changeset
|
214 |
System.out.println( "The test failed: " + whyFailed ); |
9cf279436b9d
8205153: Delete "standard instructions" machinery in the open automated tests
serb
parents:
47216
diff
changeset
|
215 |
System.out.println( "The test is over, hit Ctl-C to stop Java VM" ); |
1978
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
216 |
//check if this called from main thread |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
217 |
if ( mainThread == Thread.currentThread() ) |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
218 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
219 |
//If main thread, fail now 'cause not sleeping |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
220 |
throw new RuntimeException( whyFailed ); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
221 |
} |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
222 |
theTestPassed = false; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
223 |
testGeneratedInterrupt = true; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
224 |
failureMessage = whyFailed; |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
225 |
mainThread.interrupt(); |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
226 |
}//fail() |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
227 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
228 |
}// class MixingOnDialog |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
229 |
|
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
230 |
//This exception is used to exit from any level of call nesting |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
231 |
// when it's determined that the test has passed, and immediately |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
232 |
// end the test. |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
233 |
class TestPassedException extends RuntimeException |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
234 |
{ |
8b981ce05cd0
6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents:
diff
changeset
|
235 |
} |