undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com Patches, unit tests, benchmarks, whitepaper, and outreach briefs. Public domain — no copyright claimed. Use freely.
This commit is contained in:
commit
0a580b313d
70422 changed files with 17213626 additions and 0 deletions
90
test/jdk/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java
Normal file
90
test/jdk/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class FrameBorderCounter {
|
||||
|
||||
private static Frame frame;
|
||||
private static Frame background;
|
||||
private static Dimension size;
|
||||
private static Point location;
|
||||
private static Point entered;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final Robot robot = new Robot();
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
robot.mouseMove(0, 0);
|
||||
}
|
||||
});
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
background = new Frame();
|
||||
background.setBounds(100, 100, 300, 300);
|
||||
background.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
entered = e.getLocationOnScreen();
|
||||
System.err.println("[ENTERED] : " + entered);
|
||||
}
|
||||
});
|
||||
background.setVisible(true);
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame = new Frame("Frame");
|
||||
frame.setBounds(200, 200, 100, 100);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
Thread.sleep(1000);
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
location = frame.getLocationOnScreen();
|
||||
size = frame.getSize();
|
||||
}
|
||||
});
|
||||
int out = 20;
|
||||
for (int x = location.x + size.width - out; x <= location.x + size.width + out; ++x) {
|
||||
robot.mouseMove(x, location.y + size.height / 2);
|
||||
Thread.sleep(50);
|
||||
}
|
||||
System.err.println("[LOCATION] : " + location);
|
||||
System.err.println("[SIZE] : " + size);
|
||||
Thread.sleep(250);
|
||||
int shift = entered.x - location.x - size.width - 1;
|
||||
System.err.println("Done");
|
||||
System.out.println(shift);
|
||||
frame.dispose();
|
||||
background.dispose();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* Base class for testing overlapping of Swing and AWT component put into GlassPane.
|
||||
* Validates drawing and event delivery at the components intersection.
|
||||
* <p> See {@link OverlappingTestBase} for usage
|
||||
*
|
||||
* @author Sergey Grinev
|
||||
*/
|
||||
public abstract class GlassPaneOverlappingTestBase extends SimpleOverlappingTestBase {
|
||||
|
||||
/**
|
||||
* If true components is additionally tested to be correctly drawn after resize.
|
||||
*/
|
||||
protected boolean testResize = true;
|
||||
private JFrame f = null;
|
||||
|
||||
/**
|
||||
* Setups GlassPane with lightweight component returned by {@link SimpleOverlappingTestBase#getSwingComponent() }
|
||||
* Called by base class.
|
||||
*/
|
||||
@Override
|
||||
protected void prepareControls() {
|
||||
wasLWClicked = false;
|
||||
|
||||
if(f != null) {
|
||||
f.setVisible(false);
|
||||
}
|
||||
f = new JFrame("Mixing : GlassPane Overlapping test");
|
||||
f.setLayout(new SpringLayout());
|
||||
f.setSize(200, 200);
|
||||
|
||||
propagateAWTControls(f);
|
||||
|
||||
f.getGlassPane().setVisible(true);
|
||||
Container glassPane = (Container) f.getGlassPane();
|
||||
glassPane.setLayout(null);
|
||||
|
||||
testedComponent = getSwingComponent();
|
||||
if (useDefaultClickValidation) {
|
||||
testedComponent.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
//System.err.println("lw mouse clicked");
|
||||
wasLWClicked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
testedComponent.setBounds(0, 0, testedComponent.getPreferredSize().width, testedComponent.getPreferredSize().height);
|
||||
glassPane.add(testedComponent);
|
||||
|
||||
f.setLocationRelativeTo(null);
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
public GlassPaneOverlappingTestBase() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GlassPaneOverlappingTestBase(boolean defaultClickValidation) {
|
||||
super(defaultClickValidation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean isMultiFramesTest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run test by {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) } validation for current lightweight component.
|
||||
* <p>Also resize component and repeat validation in the resized area.
|
||||
* <p>Called by base class.
|
||||
* @return true if test passed
|
||||
* @see GlassPaneOverlappingTestBase#testResize
|
||||
*/
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
if (!super.performTest()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!testResize) {
|
||||
return true;
|
||||
}
|
||||
|
||||
wasLWClicked = false;
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
testedComponent.setBounds(0, 0,
|
||||
testedComponent.getPreferredSize().width,
|
||||
testedComponent.getPreferredSize().height + 20);
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException | InvocationTargetException ex) {
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
Point lLoc = testedComponent.getLocationOnScreen();
|
||||
lLoc.translate(1, testedComponent.getPreferredSize().height + 1);
|
||||
clickAndBlink(robot, lLoc);
|
||||
|
||||
return wasLWClicked;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup() {
|
||||
f.dispose();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,563 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Label;
|
||||
import java.awt.List;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Scrollbar;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.TextField;
|
||||
import java.awt.event.HierarchyBoundsListener;
|
||||
import java.awt.event.HierarchyEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
|
||||
/**
|
||||
* AWT Mixing test for HierarchyBoundsListener ancestors.
|
||||
* <p>See <a href="https://bugs.openjdk.org/browse/JDK-6768230">CR6768230</a> for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6768230 8221823
|
||||
* @summary Mixing test for HierarchyBoundsListener ancestors
|
||||
* @library /test/lib
|
||||
* @build FrameBorderCounter jdk.test.lib.Platform
|
||||
* @run main HierarchyBoundsListenerMixingTest
|
||||
*/
|
||||
public class HierarchyBoundsListenerMixingTest {
|
||||
|
||||
protected void prepareControls() {
|
||||
dummy = new Frame();
|
||||
dummy.setSize(100, 100);
|
||||
dummy.setLocation(0, 350);
|
||||
dummy.setVisible(true);
|
||||
|
||||
frame = new Frame("Test Frame");
|
||||
frame.setLayout(new FlowLayout());
|
||||
|
||||
panel = new Panel();
|
||||
button = new Button("Button");
|
||||
label = new Label("Label");
|
||||
list = new List();
|
||||
list.add("One");
|
||||
list.add("Two");
|
||||
list.add("Three");
|
||||
choice = new Choice();
|
||||
choice.add("Red");
|
||||
choice.add("Orange");
|
||||
choice.add("Yellow");
|
||||
checkbox = new Checkbox("Checkbox");
|
||||
scrollbar = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 255);
|
||||
textfield = new TextField(15);
|
||||
textarea = new TextArea(5, 15);
|
||||
|
||||
components = new Component[] {
|
||||
panel, button, label, list, choice, checkbox, scrollbar, textfield, textarea
|
||||
};
|
||||
ancestorResized = new boolean[components.length];
|
||||
ancestorMoved = new boolean[components.length];
|
||||
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent event) {
|
||||
System.err.println("User closed the window");
|
||||
}
|
||||
});
|
||||
|
||||
HierarchyBoundsListener listener = new HierarchyBoundsListenerImpl();
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
components[i].addHierarchyBoundsListener(listener);
|
||||
frame.add(components[i]);
|
||||
}
|
||||
frame.setBounds(100, 100, 300, 300);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private int frameBorderCounter() {
|
||||
String JAVA_HOME = System.getProperty("java.home");
|
||||
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(JAVA_HOME + "/bin/java FrameBorderCounter");
|
||||
try {
|
||||
p.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (p.exitValue() != 0) {
|
||||
throw new RuntimeException("FrameBorderCounter exited with not null code!\n" + readInputStream(p.getErrorStream()));
|
||||
}
|
||||
return Integer.parseInt(readInputStream(p.getInputStream()).trim());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String readInputStream(InputStream is) throws IOException {
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (InputStreamReader isr = new InputStreamReader(is)) {
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
sb.append(new String(buffer, 0, len));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected boolean performTest() {
|
||||
int BORDER_SHIFT = frameBorderCounter();
|
||||
BORDER_SHIFT = Math.abs(BORDER_SHIFT) == 1 ? BORDER_SHIFT : BORDER_SHIFT / 2;
|
||||
Robot robot = null;
|
||||
try {
|
||||
robot = new Robot();
|
||||
Thread.sleep(delay * 10);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Robot creation exception.");
|
||||
}
|
||||
|
||||
robot.mouseMove((int) components[0].getLocationOnScreen().x + components[0].getSize().width / 2,
|
||||
(int) components[0].getLocationOnScreen().y + components[0].getSize().height / 2);
|
||||
robot.delay(delay);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(delay);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(delay);
|
||||
|
||||
resetValues();
|
||||
try {
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame.setSize(new Dimension(frame.getSize().width + 10, frame.getSize().height + 10));
|
||||
frame.invalidate();
|
||||
frame.validate();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
passed = false;
|
||||
}
|
||||
if (! resizeTriggered) {
|
||||
synchronized (resizeLock) {
|
||||
try {
|
||||
resizeLock.wait(delay * 10);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (! ancestorResized[i]) {
|
||||
System.err.println("FAIL: Frame resized using API call. " +
|
||||
"Ancestor resized event did not occur for " + components[i].getClass());
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
if (moveCount > 0) {
|
||||
System.err.println("FAIL: Ancestor moved event occured when Frame resized using API");
|
||||
passed = false;
|
||||
}
|
||||
robot.delay(delay * 5);
|
||||
|
||||
resetValues();
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
if (!Platform.isOnWayland()) {
|
||||
x = frame.getLocationOnScreen().x;
|
||||
y = frame.getLocationOnScreen().y;
|
||||
w = frame.getSize().width;
|
||||
h = frame.getSize().height;
|
||||
|
||||
robot.mouseMove(x + w + BORDER_SHIFT, y + h / 2);
|
||||
robot.delay(delay);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(delay);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
robot.mouseMove(x + w + i + BORDER_SHIFT, y + h / 2);
|
||||
robot.delay(50);
|
||||
}
|
||||
robot.delay(delay);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
|
||||
if (!resizeTriggered) {
|
||||
synchronized (resizeLock) {
|
||||
try {
|
||||
resizeLock.wait(delay * 10);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (!ancestorResized[i]) {
|
||||
System.err.println("FAIL: Frame resized using mouse action. " +
|
||||
"Ancestor resized event did not occur for " +
|
||||
components[i].getClass());
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
if (moveCount > 0) {
|
||||
System.err.println("FAIL: Ancestor moved event occurred when Frame resized using mouse");
|
||||
passed = false;
|
||||
}
|
||||
|
||||
resetValues();
|
||||
}
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame.setLocation(frame.getLocation().x + 20, frame.getLocation().y + 20);
|
||||
frame.invalidate();
|
||||
frame.validate();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
passed = false;
|
||||
}
|
||||
if (! moveTriggered) {
|
||||
synchronized (moveLock) {
|
||||
try {
|
||||
moveLock.wait(delay * 10);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (! ancestorMoved[i]) {
|
||||
System.err.println("FAIL: Frame moved using API call. " +
|
||||
"Ancestor moved event did not occur for " + components[i].getClass());
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
if (resizeCount > 0) {
|
||||
System.err.println("FAIL: Ancestor resized event occured when Frame moved using API");
|
||||
passed = false;
|
||||
}
|
||||
robot.delay(delay * 10);
|
||||
|
||||
resetValues();
|
||||
|
||||
if (!Platform.isOnWayland()) {
|
||||
x = frame.getLocationOnScreen().x;
|
||||
y = frame.getLocationOnScreen().y;
|
||||
w = frame.getSize().width;
|
||||
h = frame.getSize().height;
|
||||
|
||||
//Click on the dummy frame so that the test frame loses focus. This is to workaround
|
||||
//a bug in Linux AS.
|
||||
robot.mouseMove((int) dummy.getLocationOnScreen().x + dummy.getSize().width / 2,
|
||||
(int) dummy.getLocationOnScreen().y + dummy.getSize().height / 2);
|
||||
robot.delay(delay);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(delay);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(delay);
|
||||
|
||||
robot.mouseMove(x + w / 2, y + 10);
|
||||
robot.delay(delay);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(delay);
|
||||
for (int i = 1; i <= 20; i++) {
|
||||
robot.mouseMove(x + w / 2 + i, y + 10);
|
||||
robot.delay(50);
|
||||
}
|
||||
robot.delay(delay);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
|
||||
if (! moveTriggered) {
|
||||
synchronized (moveLock) {
|
||||
try {
|
||||
moveLock.wait(delay * 10);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (! ancestorMoved[i]) {
|
||||
System.err.println("FAIL: Frame moved using mouse action. " +
|
||||
"Ancestor moved event did not occur for " + components[i].getClass());
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
if (resizeCount > 0) {
|
||||
System.err.println("FAIL: Ancestor resized event occured when Frame moved using mouse");
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
private void resetValues() {
|
||||
moveTriggered = false;
|
||||
resizeTriggered = false;
|
||||
moveCount = 0;
|
||||
resizeCount = 0;
|
||||
for (int i = 0; i < ancestorResized.length; i++) {
|
||||
ancestorResized[i] = false;
|
||||
ancestorMoved[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void keyType(int key, Robot robot) throws Exception {
|
||||
robot.keyPress(key);
|
||||
robot.delay(keyDelay);
|
||||
robot.keyRelease(key);
|
||||
robot.delay(keyDelay);
|
||||
}
|
||||
|
||||
class HierarchyBoundsListenerImpl implements HierarchyBoundsListener {
|
||||
// checks for Ancestor_Moved events
|
||||
public void ancestorMoved(HierarchyEvent ce) {
|
||||
if (check) {
|
||||
System.out.println("Moved " + ce.getComponent());
|
||||
}
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (components[i].equals(ce.getComponent())) {
|
||||
//setting this array for purpose of checking ancestor_moved.
|
||||
ancestorMoved[i] = true;
|
||||
moveCount++;
|
||||
if (moveCount == components.length) {
|
||||
moveTriggered = true;
|
||||
synchronized (moveLock) {
|
||||
try {
|
||||
moveLock.notifyAll();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// checks for Ancestor_Moved events
|
||||
public void ancestorResized(HierarchyEvent ce) {
|
||||
if (check) {
|
||||
System.out.println("Resized " + ce.getComponent());
|
||||
}
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (components[i].equals(ce.getComponent())) {
|
||||
if (! frame.equals(ce.getChanged()) || ce.getChangedParent() != null) {
|
||||
System.err.println("FAIL: Invalid value of HierarchyEvent.getXXX");
|
||||
System.err.println("ce.getChanged() : " + ce.getChanged());
|
||||
System.err.println("ce.getChangedParent() : " + ce.getChangedParent());
|
||||
passed = false;
|
||||
}
|
||||
//setting this array for purpose of checking ancestor_resized
|
||||
ancestorResized[i] = true;
|
||||
resizeCount++;
|
||||
if (resizeCount == components.length) {
|
||||
resizeTriggered = true;
|
||||
synchronized (resizeLock) {
|
||||
try {
|
||||
resizeLock.notifyAll();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Frame frame, dummy;
|
||||
private Panel panel;
|
||||
private Button button;
|
||||
private Label label;
|
||||
private List list;
|
||||
private Choice choice;
|
||||
private Checkbox checkbox;
|
||||
private Scrollbar scrollbar;
|
||||
private TextField textfield;
|
||||
private TextArea textarea;
|
||||
private Component[] components;
|
||||
private boolean[] ancestorResized;
|
||||
private boolean[] ancestorMoved;
|
||||
|
||||
private int delay = 500;
|
||||
private int keyDelay = 50;
|
||||
private int moveCount = 0;
|
||||
private int resizeCount = 0;
|
||||
|
||||
private boolean passed = true;
|
||||
private volatile boolean moveTriggered = false;
|
||||
private volatile boolean resizeTriggered = false;
|
||||
private final Object moveLock = new Object();
|
||||
private final Object resizeLock = new Object();
|
||||
|
||||
private boolean check = false;
|
||||
|
||||
private void invoke() throws InterruptedException {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
prepareControls();
|
||||
}
|
||||
});
|
||||
try {
|
||||
Thread.sleep(1000); // wait for graphic effects on systems like Win7
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
if (!performTest()) {
|
||||
fail("Test failed");
|
||||
}
|
||||
} catch (InvocationTargetException ex) {
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
* Standard Test Machinery Section
|
||||
* DO NOT modify anything in this section -- it's a
|
||||
* standard chunk of code which has all of the
|
||||
* synchronisation necessary for the test harness.
|
||||
* By keeping it the same in all tests, it is easier
|
||||
* to read and understand someone else's test, as
|
||||
* well as insuring that all tests behave correctly
|
||||
* with the test harness.
|
||||
* There is a section following this for test-
|
||||
* classes
|
||||
******************************************************/
|
||||
private static void init() throws InterruptedException {
|
||||
//*** Create instructions for the user here ***
|
||||
//System.setProperty("sun.awt.disableMixing", "true");
|
||||
|
||||
HierarchyBoundsListenerMixingTest instance = new HierarchyBoundsListenerMixingTest();
|
||||
|
||||
instance.invoke();
|
||||
|
||||
pass();
|
||||
}//End init()
|
||||
private static boolean theTestPassed = false;
|
||||
private static boolean testGeneratedInterrupt = false;
|
||||
private static String failureMessage = "";
|
||||
private static Thread mainThread = null;
|
||||
private static int sleepTime = 300000;
|
||||
|
||||
// Not sure about what happens if multiple of this test are
|
||||
// instantiated in the same VM. Being static (and using
|
||||
// static vars), it aint gonna work. Not worrying about
|
||||
// it for now.
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
mainThread = Thread.currentThread();
|
||||
try {
|
||||
init();
|
||||
} catch (TestPassedException e) {
|
||||
//The test passed, so just return from main and harness will
|
||||
// interepret this return as a pass
|
||||
return;
|
||||
}
|
||||
//At this point, neither test pass nor test fail has been
|
||||
// called -- either would have thrown an exception and ended the
|
||||
// test, so we know we have multiple threads.
|
||||
|
||||
//Test involves other threads, so sleep and wait for them to
|
||||
// called pass() or fail()
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
//Timed out, so fail the test
|
||||
throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds");
|
||||
} catch (InterruptedException e) {
|
||||
//The test harness may have interrupted the test. If so, rethrow the exception
|
||||
// so that the harness gets it and deals with it.
|
||||
if (!testGeneratedInterrupt) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
//reset flag in case hit this code more than once for some reason (just safety)
|
||||
testGeneratedInterrupt = false;
|
||||
|
||||
if (theTestPassed == false) {
|
||||
throw new RuntimeException(failureMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}//main
|
||||
|
||||
public static synchronized void setTimeoutTo(int seconds) {
|
||||
sleepTime = seconds * 1000;
|
||||
}
|
||||
|
||||
public static synchronized void pass() {
|
||||
System.out.println("The test passed.");
|
||||
System.out.println("The test is over, hit Ctl-C to stop Java VM");
|
||||
//first check if this is executing in main thread
|
||||
if (mainThread == Thread.currentThread()) {
|
||||
//Still in the main thread, so set the flag just for kicks,
|
||||
// and throw a test passed exception which will be caught
|
||||
// and end the test.
|
||||
theTestPassed = true;
|
||||
throw new TestPassedException();
|
||||
}
|
||||
theTestPassed = true;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}//pass()
|
||||
|
||||
public static synchronized void fail() {
|
||||
//test writer didn't specify why test failed, so give generic
|
||||
fail("it just plain failed! :-)");
|
||||
}
|
||||
|
||||
public static synchronized void fail(String whyFailed) {
|
||||
System.out.println("The test failed: " + whyFailed);
|
||||
System.out.println("The test is over, hit Ctl-C to stop Java VM");
|
||||
//check if this called from main thread
|
||||
if (mainThread == Thread.currentThread()) {
|
||||
//If main thread, fail now 'cause not sleeping
|
||||
throw new RuntimeException(whyFailed);
|
||||
}
|
||||
theTestPassed = false;
|
||||
testGeneratedInterrupt = true;
|
||||
failureMessage = whyFailed;
|
||||
mainThread.interrupt();
|
||||
}//fail()
|
||||
}// class LWComboBox
|
||||
class TestPassedException extends RuntimeException {
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JButton } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JButton
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JButtonInGlassPaneOverlapping
|
||||
*/
|
||||
public class JButtonInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JButton ch = new JButton();
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JButtonInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
57
test/jdk/java/awt/Mixing/AWT_Mixing/JButtonOverlapping.java
Normal file
57
test/jdk/java/awt/Mixing/AWT_Mixing/JButtonOverlapping.java
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JButton } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JButton
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JButtonOverlapping
|
||||
*/
|
||||
public class JButtonOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JButton ch = new JButton();
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JButtonOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JColorChooser } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JColorChooser
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JColorChooserOverlapping
|
||||
*/
|
||||
public class JColorChooserOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
public JColorChooserOverlapping() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
wasLWClicked = true;
|
||||
JColorChooser ch = new JColorChooser();
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JColorChooserOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
117
test/jdk/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java
Normal file
117
test/jdk/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JCombobox } component.
|
||||
* <p>This test creates combobox and test if heavyweight component is drawn correctly then dropdown is shown.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Overlapping test for javax.swing.JScrollPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JComboBoxOverlapping
|
||||
*/
|
||||
public class JComboBoxOverlapping extends OverlappingTestBase {
|
||||
|
||||
private boolean lwClicked = false;
|
||||
private Point loc;
|
||||
private Point loc2;
|
||||
private JComboBox cb;
|
||||
private JFrame frame;
|
||||
|
||||
{testEmbeddedFrame = true;}
|
||||
|
||||
protected void prepareControls() {
|
||||
frame = new JFrame("Mixing : Dropdown Overlapping test");
|
||||
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
|
||||
frame.setSize(200, 200);
|
||||
|
||||
cb = new JComboBox(petStrings);
|
||||
cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20));
|
||||
cb.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == cb) {
|
||||
lwClicked = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
frame.add(cb);
|
||||
propagateAWTControls(frame);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
robot.waitForIdle();
|
||||
robot.delay(200);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
loc = cb.getLocationOnScreen();
|
||||
loc2 = frame.getContentPane().getLocationOnScreen();
|
||||
});
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
loc2.translate(75, 75);
|
||||
pixelPreCheck(robot, loc2, currentAwtControl);
|
||||
|
||||
loc.translate(3, 3);
|
||||
clickAndBlink(robot, loc, false);
|
||||
|
||||
clickAndBlink(robot, loc2, false);
|
||||
|
||||
return lwClicked;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JComboBoxOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Point;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JBEditorPane } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JLabel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JEditorPaneInGlassPaneOverlapping
|
||||
*/
|
||||
public class JEditorPaneInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JEditorPane ch = new JEditorPane();
|
||||
ch.setText("<b>Swing component</b>");
|
||||
OverlappingTestBase.shift = new Point(12, 12);
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JEditorPaneInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JEditorPane } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JLabel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JEditorPaneOverlapping
|
||||
*/
|
||||
public class JEditorPaneOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JEditorPane ch = new JEditorPane();
|
||||
ch.setText("<b>Swing component</b>");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JEditorPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test with JInternalFrame being put in GlassPane.
|
||||
* See <a href="https://bugs.openjdk.org/browse/JDK-6637655">JDK-6637655</a> and
|
||||
* <a href="https://bugs.openjdk.org/browse/JDK-6985776">JDK-6985776</a>.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6637655 6985776
|
||||
* @summary Overlapping test for javax.swing.JScrollPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JGlassPaneInternalFrameOverlapping
|
||||
*/
|
||||
public class JGlassPaneInternalFrameOverlapping extends OverlappingTestBase {
|
||||
|
||||
private boolean lwClicked = true;
|
||||
private Point lLoc;
|
||||
private Point lLoc2;
|
||||
private JInternalFrame internalFrame;
|
||||
|
||||
protected boolean performTest() {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
lLoc = internalFrame.getContentPane().getLocationOnScreen();
|
||||
lLoc2 = lLoc.getLocation();
|
||||
lLoc2.translate(0, internalFrame.getContentPane().getHeight() + 10);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Where is internal frame?");
|
||||
}
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
clickAndBlink(robot, lLoc);
|
||||
|
||||
Color c = robot.getPixelColor(lLoc2.x, lLoc2.y);
|
||||
robot.mouseMove(lLoc2.x, lLoc2.y);
|
||||
if (!c.equals(AWT_BACKGROUND_COLOR) &&
|
||||
currentAwtControl.getClass() != java.awt.Scrollbar.class &&
|
||||
currentAwtControl.getClass() != java.awt.Choice.class) {
|
||||
fail("The HW component did not pass pixel color check and is not drawn correctly");
|
||||
}
|
||||
|
||||
return lwClicked;
|
||||
}
|
||||
|
||||
// {debugClassName = "Choice";}
|
||||
|
||||
@Override
|
||||
protected void prepareControls() {
|
||||
JFrame frame = new JFrame("Glass Pane children test");
|
||||
frame.setLayout(null);
|
||||
|
||||
Container contentPane = frame.getContentPane();
|
||||
contentPane.setLayout(new BorderLayout());
|
||||
super.propagateAWTControls(contentPane);
|
||||
|
||||
Container glassPane = (Container) frame.getRootPane().getGlassPane();
|
||||
glassPane.setVisible(true);
|
||||
glassPane.setLayout(null);
|
||||
|
||||
internalFrame = new JInternalFrame("Internal Frame", true);
|
||||
internalFrame.setBounds(50, 0, 200, 100);
|
||||
internalFrame.setVisible(true);
|
||||
glassPane.add(internalFrame);
|
||||
|
||||
internalFrame.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
lwClicked = true;
|
||||
}
|
||||
});
|
||||
|
||||
frame.setSize(300, 180);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("os x")) {
|
||||
System.out.println("Aqua L&F ignores setting color to component. Test passes on Mac OS X.");
|
||||
return;
|
||||
}
|
||||
instance = new JGlassPaneInternalFrameOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test with JInternalFrame being moved in GlassPane.
|
||||
* See <a href="https://bugs.openjdk.org/browse/JDK-6637655">JDK-6637655</a> and
|
||||
* <a href="https://bugs.openjdk.org/browse/JDK-6981919">JDK-6981919</a>.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6637655 6981919
|
||||
* @summary Overlapping test for javax.swing.JScrollPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JGlassPaneMoveOverlapping
|
||||
*/
|
||||
public class JGlassPaneMoveOverlapping extends OverlappingTestBase {
|
||||
|
||||
private boolean lwClicked = true;
|
||||
private volatile Point lLoc;
|
||||
private volatile Point lLoc2;
|
||||
|
||||
private JInternalFrame internalFrame;
|
||||
private JFrame frame = null;
|
||||
private volatile Point frameLoc;
|
||||
|
||||
protected boolean performTest() {
|
||||
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
lLoc = internalFrame.getContentPane().getLocationOnScreen();
|
||||
lLoc2 = lLoc.getLocation();
|
||||
lLoc2.translate(0, internalFrame.getHeight());
|
||||
frameLoc = frame.getLocationOnScreen();
|
||||
frameLoc.translate(frame.getWidth()/2, 3);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Where is internal frame?");
|
||||
}
|
||||
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
// force focus on JFrame (jtreg workaround)
|
||||
robot.mouseMove(frameLoc.x, frameLoc.y);
|
||||
Util.waitForIdle(robot);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.delay(50);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
Util.waitForIdle(robot);
|
||||
|
||||
|
||||
//slow move
|
||||
robot.mouseMove(lLoc.x + 25, lLoc.y - 5);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.delay(100);
|
||||
robot.mouseMove(lLoc.x + 45, lLoc.y - 5);
|
||||
robot.delay(100);
|
||||
robot.mouseMove(lLoc.x + internalWidth - 75, lLoc.y - 5);
|
||||
robot.delay(100);
|
||||
robot.mouseMove(lLoc.x + internalWidth - 55, lLoc.y - 5);
|
||||
robot.delay(100);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
Color c2 = robot.getPixelColor(lLoc.x + internalWidth + 15, lLoc.y - 5);
|
||||
if (c2.equals(AWT_BACKGROUND_COLOR)) {
|
||||
error("Foreground frame is not drawn properly");
|
||||
}
|
||||
Color c = robot.getPixelColor(lLoc.x + internalWidth - 95, lLoc.y + 5);
|
||||
robot.mouseMove(lLoc.x + internalWidth - 95, lLoc.y + 5);
|
||||
System.out.println("color: " + c + " " + AWT_BACKGROUND_COLOR);
|
||||
if (!c.equals(AWT_BACKGROUND_COLOR) && currentAwtControl.getClass() != java.awt.Scrollbar.class) {
|
||||
error("Background AWT component is not drawn properly");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// {debugClassName = "Choice";}
|
||||
|
||||
private static void error(String st) {
|
||||
//System.out.println(st);
|
||||
fail(st);
|
||||
}
|
||||
|
||||
private static final int internalWidth = 200;
|
||||
|
||||
@Override
|
||||
protected void prepareControls() {
|
||||
if(frame != null) {
|
||||
frame.setVisible(false);
|
||||
}
|
||||
frame = new JFrame("Glass Pane children test");
|
||||
frame.setLayout(null);
|
||||
|
||||
Container contentPane = frame.getContentPane();
|
||||
contentPane.setLayout(new BorderLayout());
|
||||
super.propagateAWTControls(contentPane);
|
||||
|
||||
Container glassPane = (Container) frame.getRootPane().getGlassPane();
|
||||
glassPane.setVisible(true);
|
||||
glassPane.setLayout(null);
|
||||
|
||||
internalFrame = new JInternalFrame("Internal Frame", true);
|
||||
internalFrame.setBounds(50, 0, internalWidth, 100);
|
||||
internalFrame.setVisible(true);
|
||||
glassPane.add(internalFrame);
|
||||
|
||||
internalFrame.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
lwClicked = true;
|
||||
}
|
||||
});
|
||||
|
||||
frame.setSize(400, 180);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("os x")) {
|
||||
System.out.println("Aqua L&F ignores setting color to component. Test passes on Mac OS X.");
|
||||
return;
|
||||
}
|
||||
instance = new JGlassPaneMoveOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JInternalFrame;
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JInternalFrame } component during move.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6985399
|
||||
* @summary Overlapping test for javax.swing.JScrollPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JInternalFrameMoveOverlapping
|
||||
*/
|
||||
public class JInternalFrameMoveOverlapping extends OverlappingTestBase {
|
||||
|
||||
private boolean lwClicked = true;
|
||||
private Point locTopFrame;
|
||||
private Point locTarget;
|
||||
|
||||
protected boolean performTest() {
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
robot.mouseMove(locTopFrame.x + 25, locTopFrame.y + 25);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
robot.mouseMove(locTopFrame.x + (locTarget.x - locTopFrame.x)/2, locTopFrame.y + (locTarget.y - locTopFrame.y)/2);
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
robot.mouseMove(locTarget.x, locTarget.y);
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
clickAndBlink(robot, locTarget);
|
||||
|
||||
return lwClicked;
|
||||
}
|
||||
|
||||
//static {debugClassName = "Choice";}
|
||||
|
||||
@Override
|
||||
protected void prepareControls() {
|
||||
|
||||
|
||||
JDesktopPane desktopPane = new JDesktopPane();
|
||||
|
||||
JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
|
||||
bottomFrame.setSize(220, 220);
|
||||
super.propagateAWTControls(bottomFrame);
|
||||
desktopPane.add(bottomFrame);
|
||||
bottomFrame.setVisible(true);
|
||||
|
||||
JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
|
||||
topFrame.setSize(200, 200);
|
||||
topFrame.add(new JButton("LW Button") {
|
||||
|
||||
{
|
||||
addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
lwClicked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
desktopPane.add(topFrame);
|
||||
topFrame.setVisible(true);
|
||||
|
||||
JFrame frame = new JFrame("Test Window");
|
||||
frame.setSize(300, 300);
|
||||
frame.setContentPane(desktopPane);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
|
||||
locTopFrame = topFrame.getLocationOnScreen();
|
||||
locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2);
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JInternalFrameMoveOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JInternalFrame;
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JInternalFrame } component.
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Overlapping test for javax.swing.JScrollPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JInternalFrameOverlapping
|
||||
*/
|
||||
public class JInternalFrameOverlapping extends OverlappingTestBase {
|
||||
|
||||
private boolean lwClicked = true;
|
||||
private Point lLoc;
|
||||
|
||||
protected boolean performTest() {
|
||||
|
||||
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
clickAndBlink(robot, lLoc);
|
||||
|
||||
return lwClicked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating two JInternalFrames in JDesktopPanes. Put lightweight component into one frame and heavyweight into another.
|
||||
*/
|
||||
@Override
|
||||
protected void prepareControls() {
|
||||
JDesktopPane desktopPane = new JDesktopPane();
|
||||
|
||||
JFrame frame = new JFrame("Test Window");
|
||||
frame.setSize(300, 300);
|
||||
frame.setContentPane(desktopPane);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
|
||||
bottomFrame.setSize(220, 220);
|
||||
desktopPane.add(bottomFrame);
|
||||
bottomFrame.setVisible(true);
|
||||
|
||||
super.propagateAWTControls(bottomFrame);
|
||||
JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
|
||||
topFrame.setSize(200, 200);
|
||||
JButton jbutton = new JButton("LW Button") {{
|
||||
addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
lwClicked = true;
|
||||
}
|
||||
});
|
||||
}};
|
||||
topFrame.add(jbutton);
|
||||
desktopPane.add(topFrame);
|
||||
topFrame.setVisible(true);
|
||||
lLoc = jbutton.getLocationOnScreen();
|
||||
lLoc.translate(jbutton.getWidth()/2, jbutton.getWidth()/2); //click at middle of the button
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JInternalFrameOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JLabel } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JLabel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JLabelInGlassPaneOverlapping
|
||||
*/
|
||||
public class JLabelInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JLabel ch = new JLabel();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JLabelInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
58
test/jdk/java/awt/Mixing/AWT_Mixing/JLabelOverlapping.java
Normal file
58
test/jdk/java/awt/Mixing/AWT_Mixing/JLabelOverlapping.java
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JLabel } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JLabel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JLabelOverlapping
|
||||
*/
|
||||
public class JLabelOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JLabel ch = new JLabel();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JLabelOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JList } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JList
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JListInGlassPaneOverlapping
|
||||
*/
|
||||
public class JListInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JList ch = new JList(new String[] {"one", "two", "three"});
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JListInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
55
test/jdk/java/awt/Mixing/AWT_Mixing/JListOverlapping.java
Normal file
55
test/jdk/java/awt/Mixing/AWT_Mixing/JListOverlapping.java
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JList } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JList
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JListOverlapping
|
||||
*/
|
||||
public class JListOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JList ch = new JList(new String[] {"one", "two", "three", "four"});
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JListOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
157
test/jdk/java/awt/Mixing/AWT_Mixing/JMenuBarOverlapping.java
Normal file
157
test/jdk/java/awt/Mixing/AWT_Mixing/JMenuBarOverlapping.java
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JMenuBar } and {@link javax.swing.JSeparator} components.
|
||||
* <p>This test creates menu bar and test if heavyweight component is drawn correctly then menu dropdown is shown.
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Overlapping test for javax.swing.JScrollPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JMenuBarOverlapping
|
||||
*/
|
||||
public class JMenuBarOverlapping extends OverlappingTestBase {
|
||||
|
||||
{testEmbeddedFrame = true;}
|
||||
|
||||
private boolean lwClicked = false;
|
||||
private boolean spClicked = false;
|
||||
private Point loc;
|
||||
private Point loc2;
|
||||
private Point sepLoc;
|
||||
private JFrame frame;
|
||||
private JMenuBar menuBar;
|
||||
JSeparator separator;
|
||||
|
||||
protected void prepareControls() {
|
||||
frame = new JFrame("Mixing : Dropdown Overlapping test");
|
||||
frame.setLayout(new GridLayout(0,1));
|
||||
frame.setSize(200, 200);
|
||||
|
||||
menuBar = new JMenuBar();
|
||||
JMenu menu = new JMenu("Test Menu");
|
||||
ActionListener menuListener = new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
lwClicked = true;
|
||||
}
|
||||
};
|
||||
|
||||
JMenuItem item;
|
||||
menu.add(item = new JMenuItem("first"));
|
||||
item.addActionListener(menuListener);
|
||||
separator = new JSeparator();
|
||||
separator.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
spClicked = true;
|
||||
}
|
||||
});
|
||||
menu.add(separator);
|
||||
|
||||
for (int i = 0; i < petStrings.length; i++) {
|
||||
menu.add(item = new JMenuItem(petStrings[i]));
|
||||
item.addActionListener(menuListener);
|
||||
}
|
||||
menuBar.add(menu);
|
||||
frame.setJMenuBar(menuBar);
|
||||
|
||||
propagateAWTControls(frame);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
loc = menuBar.getLocationOnScreen();
|
||||
loc2 = frame.getContentPane().getLocationOnScreen();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
}
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
loc2.translate(75, 75);
|
||||
pixelPreCheck(robot, loc2, currentAwtControl);
|
||||
|
||||
loc.translate(3, 3);
|
||||
clickAndBlink(robot, loc, false);
|
||||
|
||||
clickAndBlink(robot, loc2, false);
|
||||
|
||||
clickAndBlink(robot, loc, false);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
sepLoc = separator.getLocationOnScreen();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Where is separator?");
|
||||
}
|
||||
sepLoc.translate(20, 1);
|
||||
clickAndBlink(robot, sepLoc, false);
|
||||
|
||||
clickAndBlink(robot, loc, false); // close menu before running next step
|
||||
return lwClicked && spClicked;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JMenuBarOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JPanel } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JPanel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JPanelInGlassPaneOverlapping
|
||||
*/
|
||||
public class JPanelInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JPanel ch = new JPanel();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setBorder(BorderFactory.createTitledBorder("Swing Component"));
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JPanelInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
58
test/jdk/java/awt/Mixing/AWT_Mixing/JPanelOverlapping.java
Normal file
58
test/jdk/java/awt/Mixing/AWT_Mixing/JPanelOverlapping.java
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JPanel } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JPanel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JPanelOverlapping
|
||||
*/
|
||||
public class JPanelOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JPanel ch = new JPanel();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setBorder(BorderFactory.createTitledBorder("Swing Component"));
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JPanelOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
133
test/jdk/java/awt/Mixing/AWT_Mixing/JPopupMenuOverlapping.java
Normal file
133
test/jdk/java/awt/Mixing/AWT_Mixing/JPopupMenuOverlapping.java
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JPopupMenu } component.
|
||||
* <p>This test creates menu and test if heavyweight component is drawn correctly then menu dropdown is shown.
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Overlapping test for javax.swing.JScrollPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JPopupMenuOverlapping
|
||||
*/
|
||||
public class JPopupMenuOverlapping extends OverlappingTestBase {
|
||||
|
||||
{testEmbeddedFrame = true;}
|
||||
|
||||
private boolean lwClicked = false;
|
||||
private Point loc;
|
||||
private JPopupMenu popup;
|
||||
private JFrame frame=null;
|
||||
|
||||
protected void prepareControls() {
|
||||
if(frame != null) {
|
||||
frame.setVisible(false);
|
||||
}
|
||||
frame = new JFrame("Mixing : Dropdown Overlapping test");
|
||||
frame.setLayout(new SpringLayout());
|
||||
frame.setSize(200, 200);
|
||||
|
||||
popup = new JPopupMenu();
|
||||
ActionListener menuListener = new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
lwClicked = true;
|
||||
}
|
||||
};
|
||||
JMenuItem item;
|
||||
for (int i = 0; i < petStrings.length; i++) {
|
||||
popup.add(item = new JMenuItem(petStrings[i]));
|
||||
item.addActionListener(menuListener);
|
||||
}
|
||||
propagateAWTControls(frame);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
loc = frame.getContentPane().getLocationOnScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
loc.translate(75, 75);
|
||||
|
||||
pixelPreCheck(robot, loc, currentAwtControl);
|
||||
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
popup.show(frame.getContentPane(), 15, 15);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
clickAndBlink(robot, loc, false);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
popup.setVisible(false);
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException ex) {
|
||||
fail(ex.getMessage());
|
||||
} catch (InvocationTargetException ex) {
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
|
||||
return lwClicked;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JPopupMenuOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JProgressBar } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JProgressBar
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JProgressBarInGlassPaneOverlapping
|
||||
*/
|
||||
public class JProgressBarInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JProgressBar ch = new JProgressBar();
|
||||
ch.setValue(50);
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JProgressBarInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JProgressBar } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JProgressBar
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JProgressBarOverlapping
|
||||
*/
|
||||
public class JProgressBarOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JProgressBar ch = new JProgressBar();
|
||||
ch.setValue(50);
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JProgressBarOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.AdjustmentListener;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JScrollBar } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JScrollBar
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JScrollBarInGlassPaneOverlapping
|
||||
*/
|
||||
public class JScrollBarInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
public JScrollBarInGlassPaneOverlapping() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JScrollBar ch = new JScrollBar(JScrollBar.VERTICAL);
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setValue(50);
|
||||
ch.addAdjustmentListener(new AdjustmentListener() {
|
||||
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
wasLWClicked = true;
|
||||
}
|
||||
});
|
||||
OverlappingTestBase.shift = new Point(20, 16);
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JScrollBarInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.AdjustmentListener;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JScrollBar } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JScrollBar
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JScrollBarOverlapping
|
||||
*/
|
||||
public class JScrollBarOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
public JScrollBarOverlapping() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JScrollBar ch = new JScrollBar(JScrollBar.VERTICAL);
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setValue(50);
|
||||
ch.addAdjustmentListener(new AdjustmentListener() {
|
||||
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
wasLWClicked = true;
|
||||
}
|
||||
});
|
||||
OverlappingTestBase.shift = new Point(20, 16);
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JScrollBarOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
137
test/jdk/java/awt/Mixing/AWT_Mixing/JScrollPaneOverlapping.java
Normal file
137
test/jdk/java/awt/Mixing/AWT_Mixing/JScrollPaneOverlapping.java
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.AdjustmentListener;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JScrollPane } component.
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Overlapping test for javax.swing.JScrollPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JScrollPaneOverlapping
|
||||
*/
|
||||
public class JScrollPaneOverlapping extends OverlappingTestBase {
|
||||
|
||||
// {testEmbeddedFrame = true;}
|
||||
|
||||
private boolean horizontalClicked = false;
|
||||
private boolean verticalClicked = false;
|
||||
private Point hLoc;
|
||||
private Point vLoc;
|
||||
|
||||
private JFrame f;
|
||||
private JPanel p;
|
||||
private JScrollPane scrollPane;
|
||||
|
||||
protected void prepareControls() {
|
||||
|
||||
f = new JFrame("JScrollPane");
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setSize(120, 120);
|
||||
|
||||
p = new JPanel(new GridLayout(0, 1));
|
||||
|
||||
scrollPane = new JScrollPane(p);
|
||||
scrollPane.setPreferredSize(new Dimension(300,300));
|
||||
scrollPane.setHorizontalScrollBarPolicy(
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setVerticalScrollBarPolicy(
|
||||
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
|
||||
scrollPane.getHorizontalScrollBar().setValue(1);
|
||||
scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() {
|
||||
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
horizontalClicked = true;
|
||||
}
|
||||
});
|
||||
|
||||
scrollPane.getVerticalScrollBar().setValue(1);
|
||||
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
|
||||
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
verticalClicked = true;
|
||||
}
|
||||
});
|
||||
|
||||
f.getContentPane().add(scrollPane);
|
||||
f.setLocationRelativeTo(null);
|
||||
f.setVisible(true);
|
||||
propagateAWTControls(p);
|
||||
// JButton b = new JButton("Space extender");
|
||||
// b.setPreferredSize(new Dimension(150,150));
|
||||
// p.add( b );
|
||||
|
||||
//b.requestFocus(); // to change the look of AWT component, especially Choice
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
hLoc = scrollPane.getHorizontalScrollBar().getLocationOnScreen();
|
||||
vLoc = scrollPane.getVerticalScrollBar().getLocationOnScreen();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
}
|
||||
hLoc.translate(2, 2);
|
||||
vLoc.translate(2, 2);
|
||||
|
||||
clickAndBlink(robot, hLoc, false);
|
||||
clickAndBlink(robot, vLoc, false);
|
||||
|
||||
return horizontalClicked && verticalClicked;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JScrollPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JSlider } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JSlider
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JSliderInGlassPaneOverlapping
|
||||
*/
|
||||
public class JSliderInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JSlider ch = new JSlider();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JSliderInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
57
test/jdk/java/awt/Mixing/AWT_Mixing/JSliderOverlapping.java
Normal file
57
test/jdk/java/awt/Mixing/AWT_Mixing/JSliderOverlapping.java
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JSlider } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JSlider
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JSliderOverlapping
|
||||
*/
|
||||
public class JSliderOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JSlider ch = new JSlider();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JSliderOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JSpinner } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JSpinner
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JSpinnerInGlassPaneOverlapping
|
||||
*/
|
||||
public class JSpinnerInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
{testResize = false;}
|
||||
|
||||
public JSpinnerInGlassPaneOverlapping() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
// static {debugClassName = "Choice";}
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JSpinner ch = new JSpinner();
|
||||
ch.setPreferredSize(new Dimension(30, 50));
|
||||
ch.addChangeListener(new ChangeListener() {
|
||||
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
wasLWClicked = true;
|
||||
}
|
||||
});
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JSpinnerInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
70
test/jdk/java/awt/Mixing/AWT_Mixing/JSpinnerOverlapping.java
Normal file
70
test/jdk/java/awt/Mixing/AWT_Mixing/JSpinnerOverlapping.java
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JSpinner } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JSpinner
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JSpinnerOverlapping
|
||||
*/
|
||||
public class JSpinnerOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
public JSpinnerOverlapping() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
// static {debugClassName = "Choice";}
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JSpinner ch = new JSpinner();
|
||||
ch.setPreferredSize(new Dimension(30, 50));
|
||||
ch.addChangeListener(new ChangeListener() {
|
||||
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
wasLWClicked = true;
|
||||
}
|
||||
});
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JSpinnerOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
139
test/jdk/java/awt/Mixing/AWT_Mixing/JSplitPaneOverlapping.java
Normal file
139
test/jdk/java/awt/Mixing/AWT_Mixing/JSplitPaneOverlapping.java
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JSplitPane } component.
|
||||
* <p>This test puts heavyweight and lightweight components into different
|
||||
* panels and test if splitter image and components itself are drawn correctly.
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6986109
|
||||
* @summary Overlapping test for javax.swing.JSplitPane
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JSplitPaneOverlapping
|
||||
*/
|
||||
public class JSplitPaneOverlapping extends OverlappingTestBase {
|
||||
|
||||
private boolean clicked = false;
|
||||
private Point splitterLoc;
|
||||
private JScrollPane sp1;
|
||||
private JScrollPane sp2;
|
||||
|
||||
protected void prepareControls() {
|
||||
JFrame frame = new JFrame("SplitPane Mixing");
|
||||
JPanel p = new JPanel(new GridLayout());
|
||||
p.setPreferredSize(new Dimension(500, 500));
|
||||
propagateAWTControls(p);
|
||||
sp1 = new JScrollPane(p);
|
||||
|
||||
JButton button = new JButton("JButton");
|
||||
button.setBackground(Color.RED);
|
||||
button.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
clicked = true;
|
||||
}
|
||||
});
|
||||
sp2 = new JScrollPane(button);
|
||||
|
||||
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, sp2);
|
||||
splitPane.setOneTouchExpandable(false);
|
||||
splitPane.setDividerLocation(150);
|
||||
|
||||
splitPane.setPreferredSize(new Dimension(400, 200));
|
||||
|
||||
frame.getContentPane().add(splitPane);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static final boolean ignoreFail = false;
|
||||
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
splitterLoc = sp2.getLocationOnScreen();
|
||||
Point leftLoc = sp1.getLocationOnScreen();
|
||||
leftLoc.translate(sp1.getWidth(), 0);
|
||||
splitterLoc.translate(-(splitterLoc.x - leftLoc.x) / 2, 30);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Where is splitter?");
|
||||
}
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
robot.mouseMove(splitterLoc.x, splitterLoc.y);
|
||||
Util.waitForIdle(robot);
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseMove(splitterLoc.x - 50, splitterLoc.y);
|
||||
Color c = robot.getPixelColor(splitterLoc.x - 50, splitterLoc.y);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
System.out.println("Actual: "+c+", (not) expected: "+AWT_VERIFY_COLOR+" at "+(splitterLoc.x - 50)+", "+ splitterLoc.y);
|
||||
if (!ignoreFail && c.equals(AWT_VERIFY_COLOR)) {
|
||||
fail("The JSplitPane drag-n-drop image did not pass pixel color check and is overlapped");
|
||||
}
|
||||
clickAndBlink(robot, splitterLoc);
|
||||
|
||||
return clicked;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JSplitPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JTable } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for JTable
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JTableInGlassPaneOverlapping
|
||||
*/
|
||||
public class JTableInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
{
|
||||
testResize = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
// Create columns names
|
||||
String columnNames[] = {"Column 1", "Column 2", "Column 3"};
|
||||
|
||||
// Create some data
|
||||
String dataValues[][] = {
|
||||
{"12", "234", "67"},
|
||||
{"-123", "43", "853"},
|
||||
{"93", "89.2", "109"},
|
||||
{"279", "9033", "3092"},
|
||||
{"12", "234", "67"},
|
||||
{"-123", "43", "853"},
|
||||
{"93", "89.2", "109"},
|
||||
{"279", "9033", "3092"},
|
||||
{"12", "234", "67"},
|
||||
{"-123", "43", "853"},
|
||||
{"93", "89.2", "109"},
|
||||
{"279", "9033", "3092"},
|
||||
{"12", "234", "67"},
|
||||
{"-123", "43", "853"},
|
||||
{"93", "89.2", "109"},
|
||||
{"279", "9033", "3092"}
|
||||
};
|
||||
|
||||
// Create a new table instance
|
||||
JTable jt = new JTable(dataValues, columnNames);
|
||||
jt.getModel().addTableModelListener(new TableModelListener() {
|
||||
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
System.err.println("table changed");
|
||||
}
|
||||
});
|
||||
return jt;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JTableInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
79
test/jdk/java/awt/Mixing/AWT_Mixing/JTableOverlapping.java
Normal file
79
test/jdk/java/awt/Mixing/AWT_Mixing/JTableOverlapping.java
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JTable } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for JTable
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JTableOverlapping
|
||||
*/
|
||||
public class JTableOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
// Create columns names
|
||||
String columnNames[] = { "Column 1", "Column 2", "Column 3" };
|
||||
|
||||
// Create some data
|
||||
String dataValues[][] =
|
||||
{
|
||||
{ "12", "234", "67" },
|
||||
{ "-123", "43", "853" },
|
||||
{ "93", "89.2", "109" },
|
||||
{ "279", "9033", "3092" },
|
||||
{ "12", "234", "67" },
|
||||
{ "-123", "43", "853" },
|
||||
{ "93", "89.2", "109" },
|
||||
{ "279", "9033", "3092" },
|
||||
{ "12", "234", "67" },
|
||||
{ "-123", "43", "853" },
|
||||
{ "93", "89.2", "109" },
|
||||
{ "279", "9033", "3092" },
|
||||
{ "12", "234", "67" },
|
||||
{ "-123", "43", "853" },
|
||||
{ "93", "89.2", "109" },
|
||||
{ "279", "9033", "3092" }
|
||||
};
|
||||
|
||||
// Create a new table instance
|
||||
return new JTable( dataValues, columnNames );
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JTableOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JTextArea } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JLabel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JTextAreaInGlassPaneOverlapping
|
||||
*/
|
||||
public class JTextAreaInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JTextArea ch = new JTextArea();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JTextAreaInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JTextArea } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JLabel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JTextAreaOverlapping
|
||||
*/
|
||||
public class JTextAreaOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JTextArea ch = new JTextArea();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JTextAreaOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JTextField } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JLabel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JTextFieldInGlassPaneOverlapping
|
||||
*/
|
||||
public class JTextFieldInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JTextField ch = new JTextField();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JTextFieldInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JTextField } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JLabel
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JTextFieldOverlapping
|
||||
*/
|
||||
public class JTextFieldOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JTextField ch = new JTextField();
|
||||
ch.setPreferredSize(new Dimension(50, 50));
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JTextFieldOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JToggleButton } component in GlassPane.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JToggleButton
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JToggleButtonInGlassPaneOverlapping
|
||||
*/
|
||||
public class JToggleButtonInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JToggleButton ch = new JToggleButton();
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JToggleButtonInGlassPaneOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JToggleButton } component.
|
||||
* <p>See base class for details.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Simple Overlapping test for javax.swing.JToggleButton
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main JToggleButtonOverlapping
|
||||
*/
|
||||
public class JToggleButtonOverlapping extends SimpleOverlappingTestBase {
|
||||
|
||||
@Override
|
||||
protected JComponent getSwingComponent() {
|
||||
JToggleButton ch = new JToggleButton();
|
||||
ch.setText("Swing component");
|
||||
return ch;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new JToggleButtonOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
137
test/jdk/java/awt/Mixing/AWT_Mixing/MixingFrameResizing.java
Normal file
137
test/jdk/java/awt/Mixing/AWT_Mixing/MixingFrameResizing.java
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test.
|
||||
* <p>This test puts heavyweight component into JFrame and verifies that it's being drawn correctly after resizing the frame.
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6777370 8221823
|
||||
* @summary Issues when resizing the JFrame with HW components
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main MixingFrameResizing
|
||||
*/
|
||||
public class MixingFrameResizing extends OverlappingTestBase {
|
||||
|
||||
{testEmbeddedFrame = true;}
|
||||
|
||||
private JFrame frame = null;
|
||||
private Point lLoc;
|
||||
private Point lLoc2;
|
||||
private Dimension size;
|
||||
|
||||
protected void prepareControls() {
|
||||
if(frame != null) {
|
||||
frame.setVisible(false);
|
||||
}
|
||||
frame = new JFrame("Mixing : Frame Resizing test");
|
||||
frame.setLayout(new SpringLayout());
|
||||
frame.setSize(50, 50);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
propagateAWTControls(frame);
|
||||
Util.waitTillShown(frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
int BORDER_SHIFT = frameBorderCounter();
|
||||
BORDER_SHIFT = Math.abs(BORDER_SHIFT) == 1 ? BORDER_SHIFT : (BORDER_SHIFT / 2);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
lLoc = frame.getLocationOnScreen();
|
||||
size = frame.getSize();
|
||||
lLoc2 = frame.getContentPane().getLocationOnScreen();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Where is frame?");
|
||||
}
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY/2);
|
||||
|
||||
// resize window
|
||||
robot.mouseMove(lLoc.x + size.width / 2 + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT);
|
||||
Util.waitForIdle(robot);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
robot.mouseMove(lLoc.x + size.width / 2 + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT + 20 * i);
|
||||
}
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
robot.mouseMove(lLoc.x + size.width + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT);
|
||||
Util.waitForIdle(robot);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
robot.mouseMove(lLoc.x + size.width + BORDER_SHIFT + 20 * i, lLoc.y + size.height + BORDER_SHIFT);
|
||||
}
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
Util.waitForIdle(robot);
|
||||
// check if component is visible on the opened space
|
||||
try {
|
||||
Thread.sleep(300); //some more wait for Solaris (for some reason)
|
||||
}catch(Exception ex) {}
|
||||
lLoc2.translate(75, 75);
|
||||
Color c = robot.getPixelColor(lLoc2.x, lLoc2.y);
|
||||
System.out.println("Actual: "+c+", expected: "+AWT_VERIFY_COLOR);
|
||||
|
||||
if (!c.equals(AWT_VERIFY_COLOR)) {
|
||||
fail("HW component is not visible after resizing");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("os x")) {
|
||||
System.out.println("Aqua L&F ignores setting color to component. Test passes on Mac OS X.");
|
||||
return;
|
||||
}
|
||||
instance = new MixingFrameResizing();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
318
test/jdk/java/awt/Mixing/AWT_Mixing/MixingPanelsResizing.java
Normal file
318
test/jdk/java/awt/Mixing/AWT_Mixing/MixingPanelsResizing.java
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.Color;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for Panel and JPanel behavior during resizing.
|
||||
* <p>See <a href="https://bugs.openjdk.org/browse/JDK-6786219">JDK-6786219</a> for details
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6786219 8221823
|
||||
* @summary Issues when resizing the frame after mixing of heavy weight & light weight components
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @build FrameBorderCounter
|
||||
* @run main MixingPanelsResizing
|
||||
*/
|
||||
public class MixingPanelsResizing {
|
||||
|
||||
static volatile boolean failed = false;
|
||||
|
||||
private static JFrame frame;
|
||||
private static JButton jbutton;
|
||||
private static Button awtButton;
|
||||
private static JButton jbutton2;
|
||||
private static Button awtButton2;
|
||||
private static final Color jbColor = Color.RED;
|
||||
private static final Color awtColor = Color.ORANGE;
|
||||
private static final Color jb2Color = Color.BLUE;
|
||||
private static final Color awt2Color = Color.CYAN;
|
||||
private static final int ROBOT_DELAY = 500;
|
||||
|
||||
private static Point lLoc;
|
||||
private static int borderShift;
|
||||
|
||||
private static int frameBorderCounter() {
|
||||
String JAVA_HOME = System.getProperty("java.home");
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(JAVA_HOME + "/bin/java FrameBorderCounter");
|
||||
try {
|
||||
p.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (p.exitValue() != 0) {
|
||||
throw new RuntimeException("FrameBorderCounter exited with not null code!\n" + readInputStream(p.getErrorStream()));
|
||||
}
|
||||
return Integer.parseInt(readInputStream(p.getInputStream()).trim());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String readInputStream(InputStream is) throws IOException {
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (InputStreamReader isr = new InputStreamReader(is)) {
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
sb.append(new String(buffer, 0, len));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void init() throws Exception {
|
||||
//*** Create instructions for the user here ***
|
||||
|
||||
borderShift = frameBorderCounter();
|
||||
borderShift = Math.abs(borderShift) == 1 ? borderShift : (borderShift / 2);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
// prepare controls
|
||||
|
||||
frame = new JFrame();
|
||||
|
||||
Panel awtPanel = new Panel();
|
||||
awtPanel.setBackground(Color.GREEN);
|
||||
awtButton = new Button("AWTButton");
|
||||
awtPanel.add(awtButton);
|
||||
awtButton.setForeground(awtColor);
|
||||
awtButton.setBackground(awtColor);
|
||||
jbutton = new JButton("SwingButton");
|
||||
awtPanel.add(jbutton);
|
||||
jbutton.setForeground(jbColor);
|
||||
jbutton.setBackground(jbColor);
|
||||
|
||||
JPanel jPanel = new JPanel();
|
||||
jbutton2 = new JButton("SwingButton2");
|
||||
jPanel.add(jbutton2);
|
||||
jbutton2.setForeground(jb2Color);
|
||||
jbutton2.setBackground(jb2Color);
|
||||
awtButton2 = new Button("AWT Button2");
|
||||
jPanel.add(awtButton2);
|
||||
awtButton2.setForeground(awt2Color);
|
||||
awtButton2.setBackground(awt2Color);
|
||||
jPanel.setBackground(Color.YELLOW);
|
||||
|
||||
frame.add(awtPanel, BorderLayout.SOUTH);
|
||||
frame.add(jPanel, BorderLayout.NORTH);
|
||||
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
/////////////////////////
|
||||
|
||||
final Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
Util.waitForIdle(robot);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
lLoc = frame.getLocationOnScreen();
|
||||
lLoc.translate(frame.getWidth() + borderShift, frame.getHeight() + borderShift);
|
||||
}
|
||||
});
|
||||
|
||||
//grow
|
||||
robot.mouseMove(lLoc.x, lLoc.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
|
||||
Runnable test = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
Point btnLoc = jbutton.getLocationOnScreen();
|
||||
Color c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
|
||||
if (!c.equals(jbColor)) {
|
||||
fail("JButton was not redrawn properly on AWT Panel during move");
|
||||
}
|
||||
|
||||
btnLoc = awtButton.getLocationOnScreen();
|
||||
c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
|
||||
if (!c.equals(awtColor)) {
|
||||
fail("AWT Button was not redrawn properly on AWT Panel during move");
|
||||
}
|
||||
|
||||
btnLoc = jbutton2.getLocationOnScreen();
|
||||
c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
|
||||
if (!c.equals(jb2Color)) {
|
||||
fail("JButton was not redrawn properly on JPanel during move");
|
||||
}
|
||||
|
||||
btnLoc = awtButton2.getLocationOnScreen();
|
||||
c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
|
||||
if (!c.equals(awt2Color)) {
|
||||
fail("ATW Button was not redrawn properly on JPanel during move");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
test.run();
|
||||
robot.mouseMove(lLoc.x + 20 * i, lLoc.y + 10 * i);
|
||||
}
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
//back
|
||||
System.out.println("fast back");
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
for (int i = 5; i >= 0; i--) {
|
||||
test.run();
|
||||
robot.mouseMove(lLoc.x + 120 * i, lLoc.y + 60 * i);
|
||||
}
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
pass();
|
||||
}//End init()
|
||||
/*****************************************************
|
||||
* Standard Test Machinery Section
|
||||
* DO NOT modify anything in this section -- it's a
|
||||
* standard chunk of code which has all of the
|
||||
* synchronisation necessary for the test harness.
|
||||
* By keeping it the same in all tests, it is easier
|
||||
* to read and understand someone else's test, as
|
||||
* well as insuring that all tests behave correctly
|
||||
* with the test harness.
|
||||
* There is a section following this for test-
|
||||
* classes
|
||||
******************************************************/
|
||||
private static boolean theTestPassed = false;
|
||||
private static boolean testGeneratedInterrupt = false;
|
||||
private static String failureMessage = "";
|
||||
private static Thread mainThread = null;
|
||||
private static int sleepTime = 300000;
|
||||
|
||||
// Not sure about what happens if multiple of this test are
|
||||
// instantiated in the same VM. Being static (and using
|
||||
// static vars), it aint gonna work. Not worrying about
|
||||
// it for now.
|
||||
public static void main(String args[]) throws Exception {
|
||||
if (!Toolkit.getDefaultToolkit().isDynamicLayoutActive()) {
|
||||
System.out.println("Dynamic layout is not active. Test passes.");
|
||||
return;
|
||||
}
|
||||
mainThread = Thread.currentThread();
|
||||
try {
|
||||
init();
|
||||
} catch (TestPassedException e) {
|
||||
//The test passed, so just return from main and harness will
|
||||
// interepret this return as a pass
|
||||
return;
|
||||
}
|
||||
//At this point, neither test pass nor test fail has been
|
||||
// called -- either would have thrown an exception and ended the
|
||||
// test, so we know we have multiple threads.
|
||||
|
||||
//Test involves other threads, so sleep and wait for them to
|
||||
// called pass() or fail()
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
//Timed out, so fail the test
|
||||
throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds");
|
||||
} catch (InterruptedException e) {
|
||||
//The test harness may have interrupted the test. If so, rethrow the exception
|
||||
// so that the harness gets it and deals with it.
|
||||
if (!testGeneratedInterrupt) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
//reset flag in case hit this code more than once for some reason (just safety)
|
||||
testGeneratedInterrupt = false;
|
||||
|
||||
if (theTestPassed == false) {
|
||||
throw new RuntimeException(failureMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}//main
|
||||
|
||||
public static synchronized void setTimeoutTo(int seconds) {
|
||||
sleepTime = seconds * 1000;
|
||||
}
|
||||
|
||||
public static synchronized void pass() {
|
||||
System.out.println("The test passed.");
|
||||
System.out.println("The test is over, hit Ctl-C to stop Java VM");
|
||||
//first check if this is executing in main thread
|
||||
if (mainThread == Thread.currentThread()) {
|
||||
//Still in the main thread, so set the flag just for kicks,
|
||||
// and throw a test passed exception which will be caught
|
||||
// and end the test.
|
||||
theTestPassed = true;
|
||||
throw new TestPassedException();
|
||||
}
|
||||
theTestPassed = true;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}//pass()
|
||||
|
||||
public static synchronized void fail() {
|
||||
//test writer didn't specify why test failed, so give generic
|
||||
fail("it just plain failed! :-)");
|
||||
}
|
||||
|
||||
public static synchronized void fail(String whyFailed) {
|
||||
System.out.println("The test failed: " + whyFailed);
|
||||
System.out.println("The test is over, hit Ctl-C to stop Java VM");
|
||||
//check if this called from main thread
|
||||
if (mainThread == Thread.currentThread()) {
|
||||
//If main thread, fail now 'cause not sleeping
|
||||
throw new RuntimeException(whyFailed);
|
||||
}
|
||||
theTestPassed = false;
|
||||
testGeneratedInterrupt = true;
|
||||
failureMessage = whyFailed;
|
||||
mainThread.interrupt();
|
||||
}//fail()
|
||||
|
||||
static class TestPassedException extends RuntimeException {
|
||||
}
|
||||
}// class JButtonInGlassPane
|
||||
169
test/jdk/java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java
Normal file
169
test/jdk/java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.SwingUtilities;
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for opaque Swing components.
|
||||
* <p>This test verify if AWT components are drawn correctly under opaque components.
|
||||
* <p>See <a href="https://bugs.openjdk.org/browse/JDK-6776743">JDK-6776743</a> for details
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6776743 8173409
|
||||
* @summary Opaque overlapping test for each AWT component
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/java.awt.peer
|
||||
* java.desktop/sun.awt
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main OpaqueOverlapping
|
||||
*/
|
||||
public class OpaqueOverlapping extends OverlappingTestBase {
|
||||
|
||||
{
|
||||
useClickValidation = false;
|
||||
failMessage = "Opacity test mismatches";
|
||||
|
||||
// CR 6994264 (Choice autohides dropdown on Solaris 10)
|
||||
skipClassNames = new String[] { "Choice" };
|
||||
}
|
||||
private String testSeq;
|
||||
private static final String checkSeq = "010000101";
|
||||
private Point heavyLoc;
|
||||
private JButton light;
|
||||
private Frame frame = null;
|
||||
|
||||
protected void prepareControls() {
|
||||
testSeq = "";
|
||||
// Create components
|
||||
if(frame != null) {
|
||||
frame.setVisible(false);
|
||||
}
|
||||
frame = new Frame("OpaqueOverlapping mixing test");
|
||||
final Panel panel = new Panel();
|
||||
panel.setLayout(null);
|
||||
|
||||
propagateAWTControls(panel);
|
||||
|
||||
// Overlap the buttons
|
||||
currentAwtControl.setBounds(30, 30, 200, 200);
|
||||
|
||||
light = new JButton(" LW Button ");
|
||||
light.setBounds(10, 10, 50, 50);
|
||||
|
||||
// Put the components into the frame
|
||||
panel.add(light);
|
||||
frame.add(panel);
|
||||
frame.setBounds(50, 50, 400, 400);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
|
||||
currentAwtControl.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
panel.setComponentZOrder(light, 0);
|
||||
frame.validate();
|
||||
testSeq = testSeq + "0";
|
||||
}
|
||||
});
|
||||
light.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
panel.setComponentZOrder(currentAwtControl, 0);
|
||||
frame.validate();
|
||||
testSeq = testSeq + "1";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
heavyLoc = currentAwtControl.getLocationOnScreen();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
}
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
Util.waitForIdle(robot);
|
||||
|
||||
// Move the mouse pointer to the position where both
|
||||
// components overlap
|
||||
robot.mouseMove(heavyLoc.x + 5, heavyLoc.y + 5);
|
||||
|
||||
// Now perform the click at this point for 9 times
|
||||
// In the middle of the process toggle the opaque
|
||||
// flag value.
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
if (i == 3) {
|
||||
light.setMixingCutoutShape(new Rectangle());
|
||||
}
|
||||
if (i == 6) {
|
||||
light.setMixingCutoutShape(null);
|
||||
}
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
Util.waitForIdle(robot);
|
||||
|
||||
if (currentAwtControl.getClass() == java.awt.Choice.class && i != 1 && i != 6 && i != 8) {
|
||||
// due to the fact that Choice doesn't get mouseClicked event if its dropdown is shown
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
Util.waitForIdle(robot);
|
||||
}
|
||||
}
|
||||
|
||||
Util.waitForIdle(robot);
|
||||
|
||||
boolean result = testSeq.equals(checkSeq);
|
||||
if (!result) {
|
||||
System.err.println("Expected: " + checkSeq);
|
||||
System.err.println("Observed: " + testSeq);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new OpaqueOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for opaque Choice.
|
||||
*
|
||||
* This test case was separated from {@link OpaqueOverlapping} due to CR 6994264 (Choice autohides dropdown on Solaris 10)
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6994264
|
||||
* @summary Opaque overlapping test for Choice AWT component
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/java.awt.peer
|
||||
* java.desktop/sun.awt
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main OpaqueOverlappingChoice
|
||||
*/
|
||||
public class OpaqueOverlappingChoice extends OpaqueOverlapping {
|
||||
{
|
||||
onlyClassName = "Choice";
|
||||
skipClassNames = null;
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
instance = new OpaqueOverlappingChoice();
|
||||
OverlappingTestBase.doMain(args);
|
||||
}
|
||||
}
|
||||
|
||||
694
test/jdk/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java
Normal file
694
test/jdk/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java
Normal file
|
|
@ -0,0 +1,694 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.List;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Scrollbar;
|
||||
import java.awt.TextField;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.EmbeddedFrame;
|
||||
import sun.awt.OSInfo;
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* <p>This class provides basis for AWT Mixing testing.
|
||||
* <p>It provides all standard test machinery and should be used by
|
||||
* extending and overriding next methods:
|
||||
* <li> {@link OverlappingTestBase#prepareControls()} - setup UI components
|
||||
* <li> {@link OverlappingTestBase#performTest()} - run particular test
|
||||
* Those methods would be run in the loop for each AWT component.
|
||||
* <p>Current AWT component should be added to the tested UI by {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) ()}.
|
||||
* There AWT components are prepared to be tested as being overlayed by other (e.g. Swing) components - they are colored to
|
||||
* {@link OverlappingTestBase#AWT_BACKGROUND_COLOR} and throws failure on catching mouse event.
|
||||
* <p> Validation of component being overlayed should be tested by {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) }
|
||||
* See each method javadoc for more details.
|
||||
*
|
||||
* <p>Due to test machinery limitations all test should be run from their own main() by calling next coe
|
||||
* <code>
|
||||
* public static void main(String args[]) throws InterruptedException {
|
||||
* instance = new YourTestInstance();
|
||||
* OverlappingTestBase.doMain(args);
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @author Sergey Grinev
|
||||
*/
|
||||
public abstract class OverlappingTestBase {
|
||||
// working variables
|
||||
private static volatile boolean wasHWClicked = false;
|
||||
private static volatile boolean passed = true;
|
||||
// constants
|
||||
/**
|
||||
* Default color for AWT component used for validate correct drawing of overlapping. <b>Never</b> use it for lightweight components.
|
||||
*/
|
||||
protected static final Color AWT_BACKGROUND_COLOR = new Color(21, 244, 54);
|
||||
protected static Color AWT_VERIFY_COLOR = AWT_BACKGROUND_COLOR;
|
||||
protected static final int ROBOT_DELAY = 500;
|
||||
private static final String[] simpleAwtControls = {"Button", "Checkbox", "Label", "TextArea"};
|
||||
/**
|
||||
* Generic strings array. To be used for population of List based controls.
|
||||
*/
|
||||
protected static final String[] petStrings = {"Bird", "Cat", "Dog", "Rabbit", "Rhynocephalia Granda", "Bear", "Tiger", "Mustang"};
|
||||
// "properties"
|
||||
/**
|
||||
* Tests customization. Set this variable to test only control from java.awt
|
||||
* <p>Usage of this variable should be marked with CR being the reason.
|
||||
* <p>Do not use this variable simultaneously with {@link OverlappingTestBase#skipClassNames}
|
||||
*/
|
||||
protected String onlyClassName = null;
|
||||
/**
|
||||
* For customizing tests. List classes' simple names to skip them from testings.
|
||||
* <p>Usage of this variable should be marked with CR being the reason.
|
||||
*/
|
||||
protected String[] skipClassNames = null;
|
||||
/**
|
||||
* Set to false to avoid event delivery validation
|
||||
* @see OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point, boolean)
|
||||
*/
|
||||
protected boolean useClickValidation = true;
|
||||
/**
|
||||
* Set to false if test doesn't supposed to verify EmbeddedFrame
|
||||
*/
|
||||
protected boolean testEmbeddedFrame = false;
|
||||
/**
|
||||
* Set this variable to true if testing embedded frame is impossible (on Mac, for instance, for now).
|
||||
* The testEmbeddedFrame is explicitly set to true in dozen places.
|
||||
*/
|
||||
protected boolean skipTestingEmbeddedFrame = false;
|
||||
|
||||
public static final boolean isMac = System.getProperty("os.name").toLowerCase().contains("os x");
|
||||
private boolean isFrameBorderCalculated;
|
||||
private int borderShift;
|
||||
|
||||
{ if (Toolkit.getDefaultToolkit().getClass().getName().matches(".*L.*Toolkit")) {
|
||||
// No EmbeddedFrame in LWToolkit/LWCToolkit, yet
|
||||
// And it should be programmed some other way, too, in any case
|
||||
//System.err.println("skipTestingEmbeddedFrame");
|
||||
//skipTestingEmbeddedFrame = true;
|
||||
}else {
|
||||
System.err.println("do not skipTestingEmbeddedFrame");
|
||||
}
|
||||
}
|
||||
|
||||
protected int frameBorderCounter() {
|
||||
if (!isFrameBorderCalculated) {
|
||||
try {
|
||||
new FrameBorderCounter(); // force compilation by jtreg
|
||||
String JAVA_HOME = System.getProperty("java.home");
|
||||
Process p = Runtime.getRuntime().exec(JAVA_HOME + "/bin/java FrameBorderCounter");
|
||||
try {
|
||||
p.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (p.exitValue() != 0) {
|
||||
throw new RuntimeException("FrameBorderCounter exited with not null code!\n" + readInputStream(p.getErrorStream()));
|
||||
}
|
||||
borderShift = Integer.parseInt(readInputStream(p.getInputStream()).trim());
|
||||
isFrameBorderCalculated = true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Problem calculating a native border size");
|
||||
}
|
||||
}
|
||||
return borderShift;
|
||||
}
|
||||
|
||||
public void getVerifyColor() {
|
||||
try {
|
||||
final int size = 200;
|
||||
final Point[] p = new Point[1];
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run(){
|
||||
JFrame frame = new JFrame("set back");
|
||||
frame.getContentPane().setBackground(AWT_BACKGROUND_COLOR);
|
||||
frame.setSize(size, size);
|
||||
frame.setUndecorated(true);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
p[0] = frame.getLocation();
|
||||
}
|
||||
});
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(ROBOT_DELAY);
|
||||
AWT_VERIFY_COLOR = robot.getPixelColor(p[0].x+size/2, p[0].y+size/2);
|
||||
System.out.println("Color will be compared with " + AWT_VERIFY_COLOR + " instead of " + AWT_BACKGROUND_COLOR);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Cannot get verify color: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String readInputStream(InputStream is) throws IOException {
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (InputStreamReader isr = new InputStreamReader(is)) {
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
sb.append(new String(buffer, 0, len));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void setupControl(final Component control) {
|
||||
if (useClickValidation) {
|
||||
control.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
System.err.println("ERROR: " + control.getClass() + " received mouse click.");
|
||||
wasHWClicked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
control.setBackground(AWT_BACKGROUND_COLOR);
|
||||
control.setForeground(AWT_BACKGROUND_COLOR);
|
||||
control.setPreferredSize(new Dimension(150, 150));
|
||||
control.setFocusable(false);
|
||||
}
|
||||
|
||||
private void addAwtControl(java.util.List<Component> container, final Component control) {
|
||||
String simpleName = control.getClass().getSimpleName();
|
||||
if (onlyClassName != null && !simpleName.equals(onlyClassName)) {
|
||||
return;
|
||||
}
|
||||
if (skipClassNames != null) {
|
||||
for (String skipMe : skipClassNames) {
|
||||
if (simpleName.equals(skipMe)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
setupControl(control);
|
||||
container.add(control);
|
||||
}
|
||||
|
||||
private void addSimpleAwtControl(java.util.List<Component> container, String className) {
|
||||
try {
|
||||
Class definition = Class.forName("java.awt." + className);
|
||||
Constructor constructor = definition.getConstructor(new Class[]{String.class});
|
||||
java.awt.Component component = (java.awt.Component) constructor.newInstance(new Object[]{"AWT Component " + className});
|
||||
addAwtControl(container, component);
|
||||
} catch (Exception ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
fail("Setup error, this jdk doesn't have awt conrol " + className);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds current AWT control to container
|
||||
* <p>N.B.: if testEmbeddedFrame == true this method will also add EmbeddedFrame over Canvas
|
||||
* and it should be called <b>after</b> Frame.setVisible(true) call
|
||||
* @param container container to hold AWT component
|
||||
*/
|
||||
protected final void propagateAWTControls(Container container) {
|
||||
if (currentAwtControl != null) {
|
||||
container.add(currentAwtControl);
|
||||
} else { // embedded frame
|
||||
try {
|
||||
|
||||
//create embedder
|
||||
Canvas embedder = new Canvas();
|
||||
embedder.setBackground(Color.RED);
|
||||
embedder.setPreferredSize(new Dimension(150, 150));
|
||||
container.add(embedder);
|
||||
if (container instanceof Window) {
|
||||
((Window) container).setLocationRelativeTo(null);
|
||||
}
|
||||
container.setVisible(true); // create peer
|
||||
|
||||
long frameWindow = 0;
|
||||
String getWindowMethodName = null;
|
||||
String eframeClassName = null;
|
||||
if (Toolkit.getDefaultToolkit().getClass().getName().contains("XToolkit")) {
|
||||
java.awt.Helper.addExports("sun.awt.X11", OverlappingTestBase.class.getModule());
|
||||
getWindowMethodName = "getWindow";
|
||||
eframeClassName = "sun.awt.X11.XEmbeddedFrame";
|
||||
}else if (Toolkit.getDefaultToolkit().getClass().getName().contains(".WToolkit")) {
|
||||
java.awt.Helper.addExports("sun.awt.windows", OverlappingTestBase.class.getModule());
|
||||
getWindowMethodName = "getHWnd";
|
||||
eframeClassName = "sun.awt.windows.WEmbeddedFrame";
|
||||
}else if (isMac) {
|
||||
java.awt.Helper.addExports("sun.lwawt", OverlappingTestBase.class.getModule());
|
||||
java.awt.Helper.addExports("sun.lwawt.macosx", OverlappingTestBase.class.getModule());
|
||||
eframeClassName = "sun.lwawt.macosx.CViewEmbeddedFrame";
|
||||
}
|
||||
|
||||
ComponentPeer peer = AWTAccessor.getComponentAccessor()
|
||||
.getPeer(embedder);
|
||||
if (!isMac) {
|
||||
Method getWindowMethod = peer.getClass().getMethod(getWindowMethodName);
|
||||
frameWindow = (Long) getWindowMethod.invoke(peer);
|
||||
} else {
|
||||
Method m_getPlatformWindowMethod = peer.getClass().getMethod("getPlatformWindow");
|
||||
Object platformWindow = m_getPlatformWindowMethod.invoke(peer);
|
||||
Class classPlatformWindow = Class.forName("sun.lwawt.macosx.CPlatformWindow");
|
||||
|
||||
Method m_getContentView = classPlatformWindow.getMethod("getContentView");
|
||||
Object contentView = m_getContentView.invoke(platformWindow);
|
||||
Class classContentView = Class.forName("sun.lwawt.macosx.CPlatformView");
|
||||
|
||||
Method m_getAWTView = classContentView.getMethod("getAWTView");
|
||||
frameWindow = (Long) m_getAWTView.invoke(contentView);
|
||||
}
|
||||
|
||||
Class eframeClass = Class.forName(eframeClassName);
|
||||
Constructor eframeCtor = eframeClass.getConstructor(long.class);
|
||||
EmbeddedFrame eframe = (EmbeddedFrame) eframeCtor.newInstance(frameWindow);
|
||||
setupControl(eframe);
|
||||
eframe.setSize(new Dimension(150, 150));
|
||||
eframe.setLocationRelativeTo(null);
|
||||
eframe.setVisible(true);
|
||||
// System.err.println(eframe.getSize());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Failed to instantiate EmbeddedFrame: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
private static final Font hugeFont = new Font("Arial", Font.BOLD, 70);
|
||||
|
||||
private java.util.List<Component> getAWTControls() {
|
||||
java.util.List<Component> components = new ArrayList<Component>();
|
||||
|
||||
for (String clazz : simpleAwtControls) {
|
||||
addSimpleAwtControl(components, clazz);
|
||||
}
|
||||
|
||||
TextField tf = new TextField();
|
||||
tf.setFont(hugeFont);
|
||||
addAwtControl(components, tf);
|
||||
|
||||
// more complex controls
|
||||
Choice c = new Choice();
|
||||
for (int i = 0; i < petStrings.length; i++) {
|
||||
c.add(petStrings[i]);
|
||||
}
|
||||
addAwtControl(components, c);
|
||||
c.setPreferredSize(null);
|
||||
c.setFont(hugeFont); // to make control bigger as setPrefferedSize don't do his job here
|
||||
|
||||
List l = new List(petStrings.length);
|
||||
for (int i = 0; i < petStrings.length; i++) {
|
||||
l.add(petStrings[i]);
|
||||
}
|
||||
addAwtControl(components, l);
|
||||
|
||||
Canvas canvas = new Canvas();
|
||||
canvas.setSize(100, 200);
|
||||
addAwtControl(components, canvas);
|
||||
|
||||
Scrollbar sb = new Scrollbar(Scrollbar.VERTICAL, 500, 1, 0, 500);
|
||||
addAwtControl(components, sb);
|
||||
|
||||
Scrollbar sb2 = new Scrollbar(Scrollbar.HORIZONTAL, 500, 1, 0, 500);
|
||||
addAwtControl(components, sb2);
|
||||
|
||||
return components;
|
||||
}
|
||||
/**
|
||||
* Default shift for {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) }
|
||||
*/
|
||||
protected static Point shift = new Point(16, 16);
|
||||
|
||||
/**
|
||||
* Verifies point using specified AWT Robot. Supposes <code>defaultShift == true</code> for {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point, boolean) }.
|
||||
* This method is used to verify controls by providing just their plain screen coordinates.
|
||||
* @param robot AWT Robot. Usually created by {@link Util#createRobot() }
|
||||
* @param lLoc point to verify
|
||||
* @see OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point, boolean)
|
||||
*/
|
||||
protected void clickAndBlink(Robot robot, Point lLoc) {
|
||||
clickAndBlink(robot, lLoc, true);
|
||||
}
|
||||
/**
|
||||
* Default failure message for color check
|
||||
* @see OverlappingTestBase#performTest()
|
||||
*/
|
||||
protected String failMessageColorCheck = "The LW component did not pass pixel color check and is overlapped";
|
||||
/**
|
||||
* Default failure message event check
|
||||
* @see OverlappingTestBase#performTest()
|
||||
*/
|
||||
protected String failMessage = "The LW component did not received the click.";
|
||||
|
||||
private static boolean isValidForPixelCheck(Component component) {
|
||||
if ((component instanceof java.awt.Scrollbar) || isMac && (component instanceof java.awt.Button)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preliminary validation - should be run <b>before</b> overlapping happens to ensure test is correct.
|
||||
* @param robot AWT Robot. Usually created by {@link Util#createRobot() }
|
||||
* @param lLoc point to validate to be <b>of</b> {@link OverlappingTestBase#AWT_BACKGROUND_COLOR}
|
||||
* @param component tested component, should be pointed out as not all components are valid for pixel check.
|
||||
*/
|
||||
protected void pixelPreCheck(Robot robot, Point lLoc, Component component) {
|
||||
if (isValidForPixelCheck(component)) {
|
||||
int tries = 10;
|
||||
Color c = null;
|
||||
while (tries-- > 0) {
|
||||
c = robot.getPixelColor(lLoc.x, lLoc.y);
|
||||
System.out.println("Precheck. color: "+c+" compare with "+AWT_VERIFY_COLOR);
|
||||
if (c.equals(AWT_VERIFY_COLOR)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
System.err.println(lLoc + ": " + c);
|
||||
fail("Dropdown test setup failure, colored part of AWT component is not located at click area");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies point using specified AWT Robot.
|
||||
* <p>Firstly, verifies point by color pixel check
|
||||
* <p>Secondly, verifies event delivery by mouse click
|
||||
* @param robot AWT Robot. Usually created by {@link Util#createRobot() }
|
||||
* @param lLoc point to verify
|
||||
* @param defaultShift if true verified position will be shifted by {@link OverlappingTestBase#shift }.
|
||||
*/
|
||||
protected void clickAndBlink(Robot robot, Point lLoc, boolean defaultShift) {
|
||||
Point loc = lLoc.getLocation();
|
||||
//check color
|
||||
Util.waitForIdle(robot);
|
||||
try{
|
||||
Thread.sleep(500);
|
||||
} catch (Exception exx) {
|
||||
exx.printStackTrace();
|
||||
}
|
||||
|
||||
if (defaultShift) {
|
||||
loc.translate(shift.x, shift.y);
|
||||
}
|
||||
if (!(OSInfo.getOSType() == OSInfo.OSType.MACOSX)) {
|
||||
Color c = robot.getPixelColor(loc.x, loc.y);
|
||||
System.out.println("C&B. color: " + c + " compare with " + AWT_VERIFY_COLOR);
|
||||
if (c.equals(AWT_VERIFY_COLOR)) {
|
||||
fail(failMessageColorCheck);
|
||||
passed = false;
|
||||
}
|
||||
|
||||
// perform click
|
||||
Util.waitForIdle(robot);
|
||||
}
|
||||
|
||||
robot.mouseMove(loc.x, loc.y);
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
Util.waitForIdle(robot);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be overriden with code which setups UI for testing.
|
||||
* Code in this method <b>will</b> be called only from AWT thread so Swing operations can be called directly.
|
||||
*
|
||||
* @see {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) } for instructions about adding tested AWT control to UI
|
||||
*/
|
||||
protected abstract void prepareControls();
|
||||
|
||||
/**
|
||||
* This method should be overriden with test execution. It will <b>not</b> be called from AWT thread so all Swing operations should be treated accordingly.
|
||||
* @return true if test passed. Otherwise fail with default fail message.
|
||||
* @see {@link OverlappingTestBase#failMessage} default fail message
|
||||
*/
|
||||
protected abstract boolean performTest();
|
||||
/**
|
||||
* This method can be overriden with cleanup routines. It will be called from AWT thread so all Swing operations should be treated accordingly.
|
||||
*/
|
||||
protected void cleanup() {
|
||||
// intentionally do nothing
|
||||
}
|
||||
/**
|
||||
* Currect tested AWT Control. Usually shouldn't be accessed directly.
|
||||
*
|
||||
* @see {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) } for instructions about adding tested AWT control to UI
|
||||
*/
|
||||
protected Component currentAwtControl;
|
||||
|
||||
private void testComponent(Component component) throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
Robot robot = null;
|
||||
try {
|
||||
robot = new Robot();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
currentAwtControl = component;
|
||||
System.out.println("Testing " + currentAwtControl.getClass().getSimpleName());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> prepareControls());
|
||||
|
||||
if (component != null) {
|
||||
Util.waitTillShown(component);
|
||||
}
|
||||
Util.waitForIdle(robot);
|
||||
|
||||
// wait for graphic effects on systems like Win7
|
||||
robot.delay(500);
|
||||
|
||||
if (!instance.performTest()) {
|
||||
fail(failMessage);
|
||||
passed = false;
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> cleanup());
|
||||
}
|
||||
|
||||
private void testEmbeddedFrame() throws InvocationTargetException, InterruptedException {
|
||||
Robot robot = null;
|
||||
try {
|
||||
robot = new Robot();
|
||||
}catch(Exception ignorex) {
|
||||
}
|
||||
System.out.println("Testing EmbeddedFrame");
|
||||
currentAwtControl = null;
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
prepareControls();
|
||||
}
|
||||
});
|
||||
Util.waitForIdle(robot);
|
||||
try {
|
||||
Thread.sleep(500); // wait for graphic effects on systems like Win7
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
if (!instance.performTest()) {
|
||||
fail(failMessage);
|
||||
passed = false;
|
||||
}
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void testAwtControls() throws InterruptedException {
|
||||
try {
|
||||
for (Component component : getAWTControls()) {
|
||||
testComponent(component);
|
||||
}
|
||||
if (testEmbeddedFrame && !skipTestingEmbeddedFrame) {
|
||||
testEmbeddedFrame();
|
||||
}
|
||||
} catch (InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Used by standard test machinery. See usage at {@link OverlappingTestBase }
|
||||
*/
|
||||
protected static OverlappingTestBase instance;
|
||||
|
||||
protected OverlappingTestBase() {
|
||||
getVerifyColor();
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
* Standard Test Machinery Section
|
||||
* DO NOT modify anything in this section -- it's a
|
||||
* standard chunk of code which has all of the
|
||||
* synchronisation necessary for the test harness.
|
||||
* By keeping it the same in all tests, it is easier
|
||||
* to read and understand someone else's test, as
|
||||
* well as insuring that all tests behave correctly
|
||||
* with the test harness.
|
||||
* There is a section following this for test-
|
||||
* classes
|
||||
******************************************************/
|
||||
private static void init() throws InterruptedException {
|
||||
//System.setProperty("sun.awt.disableMixing", "true");
|
||||
|
||||
instance.testAwtControls();
|
||||
|
||||
if (wasHWClicked) {
|
||||
fail("HW component received the click.");
|
||||
passed = false;
|
||||
}
|
||||
if (passed) {
|
||||
pass();
|
||||
}
|
||||
}//End init()
|
||||
private static boolean theTestPassed = false;
|
||||
private static boolean testGeneratedInterrupt = false;
|
||||
private static String failureMessage = "";
|
||||
private static Thread mainThread = null;
|
||||
private static int sleepTime = 300000;
|
||||
|
||||
// Not sure about what happens if multiple of this test are
|
||||
// instantiated in the same VM. Being static (and using
|
||||
// static vars), it aint gonna work. Not worrying about
|
||||
// it for now.
|
||||
/**
|
||||
* Starting point for test runs. See usage at {@link OverlappingTestBase }
|
||||
* @param args regular main args, not used.
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public static void doMain(String args[]) throws InterruptedException {
|
||||
mainThread = Thread.currentThread();
|
||||
try {
|
||||
init();
|
||||
} catch (TestPassedException e) {
|
||||
//The test passed, so just return from main and harness will
|
||||
// interepret this return as a pass
|
||||
return;
|
||||
}
|
||||
//At this point, neither test pass nor test fail has been
|
||||
// called -- either would have thrown an exception and ended the
|
||||
// test, so we know we have multiple threads.
|
||||
|
||||
//Test involves other threads, so sleep and wait for them to
|
||||
// called pass() or fail()
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
//Timed out, so fail the test
|
||||
throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds");
|
||||
} catch (InterruptedException e) {
|
||||
//The test harness may have interrupted the test. If so, rethrow the exception
|
||||
// so that the harness gets it and deals with it.
|
||||
if (!testGeneratedInterrupt) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
//reset flag in case hit this code more than once for some reason (just safety)
|
||||
testGeneratedInterrupt = false;
|
||||
|
||||
if (theTestPassed == false) {
|
||||
throw new RuntimeException(failureMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}//main
|
||||
|
||||
/**
|
||||
* Test will fail if not passed after this timeout. Default timeout is 300 seconds.
|
||||
* @param seconds timeout in seconds
|
||||
*/
|
||||
public static synchronized void setTimeoutTo(int seconds) {
|
||||
sleepTime = seconds * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set test as passed. Usually shoudn't be called directly.
|
||||
*/
|
||||
public static synchronized void pass() {
|
||||
System.out.println("The test passed.");
|
||||
System.out.println("The test is over, hit Ctl-C to stop Java VM");
|
||||
//first check if this is executing in main thread
|
||||
if (mainThread == Thread.currentThread()) {
|
||||
//Still in the main thread, so set the flag just for kicks,
|
||||
// and throw a test passed exception which will be caught
|
||||
// and end the test.
|
||||
theTestPassed = true;
|
||||
throw new TestPassedException();
|
||||
}
|
||||
theTestPassed = true;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}//pass()
|
||||
|
||||
/**
|
||||
* Fail test generic message.
|
||||
*/
|
||||
public static synchronized void fail() {
|
||||
//test writer didn't specify why test failed, so give generic
|
||||
fail("it just plain failed! :-)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fail test providing specific reason.
|
||||
* @param whyFailed reason
|
||||
*/
|
||||
public static synchronized void fail(String whyFailed) {
|
||||
System.out.println("The test failed: " + whyFailed);
|
||||
System.out.println("The test is over, hit Ctl-C to stop Java VM");
|
||||
//check if this called from main thread
|
||||
if (mainThread == Thread.currentThread()) {
|
||||
//If main thread, fail now 'cause not sleeping
|
||||
throw new RuntimeException(whyFailed);
|
||||
}
|
||||
theTestPassed = false;
|
||||
testGeneratedInterrupt = true;
|
||||
failureMessage = whyFailed;
|
||||
mainThread.interrupt();
|
||||
}//fail()
|
||||
|
||||
static class TestPassedException extends RuntimeException {
|
||||
}
|
||||
}// class LWComboBox
|
||||
|
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* Base class for testing overlapping of Swing and AWT component put into one frame.
|
||||
* Validates drawing and event delivery at the components intersection.
|
||||
* <p> See base class for usage
|
||||
*
|
||||
* @author Sergey Grinev
|
||||
*/
|
||||
public abstract class SimpleOverlappingTestBase extends OverlappingTestBase {
|
||||
|
||||
{
|
||||
testEmbeddedFrame = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event delivery validation. If set to true (default) tested lightweight component will be provided
|
||||
* with mouse listener which should be called in order for test to pass.
|
||||
*/
|
||||
protected final boolean useDefaultClickValidation;
|
||||
|
||||
/**
|
||||
* Constructor which sets {@link SimpleOverlappingTestBase#useDefaultClickValidation }
|
||||
* @param defaultClickValidation
|
||||
*/
|
||||
protected SimpleOverlappingTestBase(boolean defaultClickValidation) {
|
||||
super();
|
||||
this.useDefaultClickValidation = defaultClickValidation;
|
||||
}
|
||||
|
||||
protected boolean isMultiFramesTest(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public SimpleOverlappingTestBase() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
//overridables
|
||||
/**
|
||||
* Successors override this method providing swing component for testing
|
||||
* @return swing component to test
|
||||
*/
|
||||
protected abstract JComponent getSwingComponent();
|
||||
|
||||
/**
|
||||
* For tests debugging. Please, ignore.
|
||||
*/
|
||||
protected static final boolean debug = false;
|
||||
|
||||
/**
|
||||
* Should be set to true if test isn't using {@link SimpleOverlappingTestBase#useDefaultClickValidation }
|
||||
*/
|
||||
protected volatile boolean wasLWClicked = false;
|
||||
|
||||
/**
|
||||
* Current tested lightweight component
|
||||
* @see SimpleOverlappingTestBase#getSwingComponent()
|
||||
*/
|
||||
protected JComponent testedComponent;
|
||||
|
||||
/**
|
||||
* Setups simple frame with lightweight component returned by {@link SimpleOverlappingTestBase#getSwingComponent() }
|
||||
* Called by base class.
|
||||
*/
|
||||
protected void prepareControls() {
|
||||
wasLWClicked = false;
|
||||
|
||||
final JFrame f = new JFrame("Mixing : Simple Overlapping test");
|
||||
f.setLayout(new SpringLayout());
|
||||
f.setSize(200, 200);
|
||||
|
||||
testedComponent = getSwingComponent();
|
||||
|
||||
if (useDefaultClickValidation) {
|
||||
testedComponent.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
wasLWClicked = true;
|
||||
f.setVisible(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!debug) {
|
||||
f.add(testedComponent);
|
||||
} else {
|
||||
System.err.println("Warning: DEBUG MODE");
|
||||
}
|
||||
|
||||
propagateAWTControls(f);
|
||||
|
||||
f.setLocationRelativeTo(null);
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* AWT Robot instance. Shouldn't be used in most cases.
|
||||
*/
|
||||
protected Robot robot;
|
||||
|
||||
/**
|
||||
* Run test by {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) } validation for current lightweight component.
|
||||
* <p>Called by base class.
|
||||
* @return true if test passed
|
||||
*/
|
||||
protected boolean performTest() {
|
||||
testedComponent.requestFocus();
|
||||
|
||||
// run robot
|
||||
robot = Util.createRobot();
|
||||
robot.setAutoDelay(20);
|
||||
|
||||
// get coord
|
||||
Point lLoc = !debug ? testedComponent.getLocationOnScreen() : new Point(70, 30);
|
||||
Util.waitForIdle(robot);
|
||||
/* this is a workaround for certain jtreg(?) focus issue:
|
||||
tests fail starting after failing mixing tests but always pass alone.
|
||||
*/
|
||||
JFrame ancestor = (JFrame) (testedComponent.getTopLevelAncestor());
|
||||
if (ancestor != null) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
ancestor.addFocusListener(new FocusAdapter() {
|
||||
@Override public void focusGained(FocusEvent e) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
ancestor.requestFocus();
|
||||
try {
|
||||
if (!latch.await(1L, TimeUnit.SECONDS)) {
|
||||
throw new RuntimeException(
|
||||
"Ancestor frame didn't receive focus");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
clickAndBlink(robot, lLoc);
|
||||
if (ancestor != null && isMultiFramesTest()) {
|
||||
ancestor.dispose();
|
||||
}
|
||||
|
||||
return wasLWClicked;
|
||||
}
|
||||
|
||||
public boolean isOel7orLater() {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("linux") &&
|
||||
System.getProperty("os.version").toLowerCase().contains("el")) {
|
||||
Pattern p = Pattern.compile("el(\\d+)");
|
||||
Matcher m = p.matcher(System.getProperty("os.version"));
|
||||
if (m.find()) {
|
||||
try {
|
||||
return Integer.parseInt(m.group(1)) >= 7;
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
177
test/jdk/java/awt/Mixing/AWT_Mixing/ViewportOverlapping.java
Normal file
177
test/jdk/java/awt/Mixing/AWT_Mixing/ViewportOverlapping.java
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for viewport
|
||||
* <p>This test verify if AWT components are drawn correctly being partially shown through viewport
|
||||
* <p>See <a href="http://monaco.sfbay.sun.com/detail.jsf?cr=6778882">CR6778882</a> for details
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6778882
|
||||
* @summary Viewport overlapping test for each AWT component
|
||||
* @author sergey.grinev@oracle.com: area=awt.mixing
|
||||
* @library /java/awt/patchlib ../../regtesthelpers
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build Util
|
||||
* @run main ViewportOverlapping
|
||||
*/
|
||||
public class ViewportOverlapping extends OverlappingTestBase {
|
||||
|
||||
private volatile int frameClicked;
|
||||
private Point hLoc;
|
||||
private Point vLoc;
|
||||
private Point testLoc;
|
||||
private Point resizeLoc;
|
||||
private static Robot robot;
|
||||
|
||||
private JFrame f;
|
||||
private JPanel p;
|
||||
private JButton b;
|
||||
private JScrollPane scrollPane;
|
||||
|
||||
protected void prepareControls() {
|
||||
p = new JPanel(new GridLayout(0, 1));
|
||||
propagateAWTControls(p);
|
||||
b = new JButton("Space extender");
|
||||
p.add(b);
|
||||
p.setPreferredSize(new Dimension(500, 500));
|
||||
scrollPane = new JScrollPane(p);
|
||||
|
||||
f = new JFrame();
|
||||
f.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
frameClicked++;
|
||||
}
|
||||
});
|
||||
f.getContentPane().add(scrollPane, BorderLayout.CENTER);
|
||||
((JComponent) f.getContentPane()).setBorder(
|
||||
BorderFactory.createEmptyBorder(50, 50, 50, 50));
|
||||
f.setSize(400, 400);
|
||||
f.setLocationRelativeTo(null);
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
// prepare test data
|
||||
frameClicked = 0;
|
||||
|
||||
b.requestFocus();
|
||||
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(40);
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(40);
|
||||
|
||||
hLoc = scrollPane.getHorizontalScrollBar().getLocationOnScreen();
|
||||
hLoc.translate(scrollPane.getHorizontalScrollBar().getWidth() - 3, 3);
|
||||
vLoc = scrollPane.getVerticalScrollBar().getLocationOnScreen();
|
||||
vLoc.translate(3, scrollPane.getVerticalScrollBar().getHeight() - 3);
|
||||
|
||||
testLoc = p.getLocationOnScreen();
|
||||
testLoc.translate(-3, -3);
|
||||
|
||||
resizeLoc = f.getLocationOnScreen();
|
||||
resizeLoc.translate(f.getWidth() - 1, f.getHeight() - 1);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Problem preparing test GUI.");
|
||||
}
|
||||
|
||||
robot.mouseMove(hLoc.x, hLoc.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
captureScreen("Img_1");
|
||||
|
||||
robot.mouseMove(vLoc.x, vLoc.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
captureScreen("Img_2");
|
||||
|
||||
clickAndBlink(robot, testLoc, false);
|
||||
robot.mouseMove(resizeLoc.x, resizeLoc.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseMove(resizeLoc.x + 5, resizeLoc.y + 5);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
captureScreen("Img_3");
|
||||
|
||||
clickAndBlink(robot, testLoc, false);
|
||||
captureScreen("Img_4");
|
||||
return (frameClicked == 2);
|
||||
}
|
||||
|
||||
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
instance = new ViewportOverlapping();
|
||||
OverlappingTestBase.doMain(args);
|
||||
captureScreen("Img_5");
|
||||
}
|
||||
|
||||
private static void captureScreen(String filename) {
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
try {
|
||||
ImageIO.write(
|
||||
robot.createScreenCapture(new Rectangle(0, 0, screenSize.width, screenSize.height)),
|
||||
"png",
|
||||
new File(filename + ".png")
|
||||
);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue