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 import java.awt.*;
25 import java.awt.event.*;
26 import java.awt.peer.ComponentPeer;
27 import java.lang.reflect.Constructor;
28 import java.lang.reflect.InvocationTargetException;
29 import java.lang.reflect.Method;
30 import java.util.ArrayList;
31 import javax.swing.*;
32 import sun.awt.*;
33 import java.io.*;
34
35 /**
36 * <p>This class provides basis for AWT Mixing testing.
37 * <p>It provides all standard test machinery and should be used by
38 * extending and overriding next methods:
39 * <li> {@link OverlappingTestBase#prepareControls()} - setup UI components
40 * <li> {@link OverlappingTestBase#performTest()} - run particular test
41 * Those methods would be run in the loop for each AWT component.
42 * <p>Current AWT component should be added to the tested UI by {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) ()}.
43 * There AWT components are prepared to be tested as being overlayed by other (e.g. Swing) components - they are colored to
44 * {@link OverlappingTestBase#AWT_BACKGROUND_COLOR} and throws failure on catching mouse event.
45 * <p> Validation of component being overlayed should be tested by {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) }
46 * See each method javadoc for more details.
47 *
48 * <p>Due to test machinery limitations all test should be run from their own main() by calling next coe
49 * <code>
50 * public static void main(String args[]) throws InterruptedException {
51 * instance = new YourTestInstance();
52 * OverlappingTestBase.doMain(args);
53 * }
114
115 protected int frameBorderCounter() {
116 if (!isFrameBorderCalculated) {
117 try {
118 new FrameBorderCounter(); // force compilation by jtreg
119 String JAVA_HOME = System.getProperty("java.home");
120 Process p = Runtime.getRuntime().exec(JAVA_HOME + "/bin/java FrameBorderCounter");
121 try {
122 p.waitFor();
123 } catch (InterruptedException e) {
124 e.printStackTrace();
125 throw new RuntimeException(e);
126 }
127 if (p.exitValue() != 0) {
128 throw new RuntimeException("FrameBorderCounter exited with not null code!\n" + readInputStream(p.getErrorStream()));
129 }
130 borderShift = Integer.parseInt(readInputStream(p.getInputStream()).trim());
131 isFrameBorderCalculated = true;
132 } catch (IOException e) {
133 e.printStackTrace();
134 System.exit(1);
135 }
136 }
137 return borderShift;
138 }
139
140 public void getVerifyColor() {
141 try {
142 final int size = 200;
143 final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
144 final Point[] p = new Point[1];
145 SwingUtilities.invokeAndWait(new Runnable() {
146 public void run(){
147 JFrame frame = new JFrame("set back");
148 frame.getContentPane().setBackground(AWT_BACKGROUND_COLOR);
149 frame.setSize(size, size);
150 frame.setUndecorated(true);
151 frame.setVisible(true);
152 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
153 p[0] = frame.getLocation();
154 }
|
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 import java.awt.*;
25 import java.awt.event.*;
26 import java.awt.peer.ComponentPeer;
27 import java.lang.reflect.Constructor;
28 import java.lang.reflect.InvocationTargetException;
29 import java.lang.reflect.Method;
30 import java.util.ArrayList;
31 import javax.swing.*;
32 import sun.awt.*;
33 import java.io.*;
34 import test.java.awt.regtesthelpers.Util;
35
36 /**
37 * <p>This class provides basis for AWT Mixing testing.
38 * <p>It provides all standard test machinery and should be used by
39 * extending and overriding next methods:
40 * <li> {@link OverlappingTestBase#prepareControls()} - setup UI components
41 * <li> {@link OverlappingTestBase#performTest()} - run particular test
42 * Those methods would be run in the loop for each AWT component.
43 * <p>Current AWT component should be added to the tested UI by {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) ()}.
44 * There AWT components are prepared to be tested as being overlayed by other (e.g. Swing) components - they are colored to
45 * {@link OverlappingTestBase#AWT_BACKGROUND_COLOR} and throws failure on catching mouse event.
46 * <p> Validation of component being overlayed should be tested by {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) }
47 * See each method javadoc for more details.
48 *
49 * <p>Due to test machinery limitations all test should be run from their own main() by calling next coe
50 * <code>
51 * public static void main(String args[]) throws InterruptedException {
52 * instance = new YourTestInstance();
53 * OverlappingTestBase.doMain(args);
54 * }
115
116 protected int frameBorderCounter() {
117 if (!isFrameBorderCalculated) {
118 try {
119 new FrameBorderCounter(); // force compilation by jtreg
120 String JAVA_HOME = System.getProperty("java.home");
121 Process p = Runtime.getRuntime().exec(JAVA_HOME + "/bin/java FrameBorderCounter");
122 try {
123 p.waitFor();
124 } catch (InterruptedException e) {
125 e.printStackTrace();
126 throw new RuntimeException(e);
127 }
128 if (p.exitValue() != 0) {
129 throw new RuntimeException("FrameBorderCounter exited with not null code!\n" + readInputStream(p.getErrorStream()));
130 }
131 borderShift = Integer.parseInt(readInputStream(p.getInputStream()).trim());
132 isFrameBorderCalculated = true;
133 } catch (IOException e) {
134 e.printStackTrace();
135 throw new RuntimeException("Problem calculating a native border size");
136 }
137 }
138 return borderShift;
139 }
140
141 public void getVerifyColor() {
142 try {
143 final int size = 200;
144 final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
145 final Point[] p = new Point[1];
146 SwingUtilities.invokeAndWait(new Runnable() {
147 public void run(){
148 JFrame frame = new JFrame("set back");
149 frame.getContentPane().setBackground(AWT_BACKGROUND_COLOR);
150 frame.setSize(size, size);
151 frame.setUndecorated(true);
152 frame.setVisible(true);
153 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
154 p[0] = frame.getLocation();
155 }
|