mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-04 23:48:33 +00:00
8299052: ViewportOverlapping test fails intermittently on Win10 & Win11
Reviewed-by: aivanov
This commit is contained in:
parent
3028295fdd
commit
2dca5ae4fd
@ -667,7 +667,6 @@ javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java 8274106 macosx-aarch64
|
||||
java/awt/Mouse/EnterExitEvents/DragWindowTest.java 8298823 macosx-all
|
||||
java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java 8280392 windows-x64
|
||||
java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java 8294264 windows-x64
|
||||
java/awt/Mixing/AWT_Mixing/ViewportOverlapping.java 8253184,8295813 windows-x64
|
||||
|
||||
javax/swing/JColorChooser/Test6827032.java 8224968 windows-x64
|
||||
java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java 8288839 windows-x64
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -21,18 +21,39 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
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.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.*;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.EmbeddedFrame;
|
||||
import java.io.*;
|
||||
import sun.awt.OSInfo;
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
@ -401,16 +422,16 @@ public abstract class OverlappingTestBase {
|
||||
Util.waitForIdle(robot);
|
||||
try{
|
||||
Thread.sleep(500);
|
||||
}catch(Exception exx){
|
||||
} catch (Exception exx) {
|
||||
exx.printStackTrace();
|
||||
}
|
||||
|
||||
if (defaultShift) {
|
||||
loc.translate(shift.x, shift.y);
|
||||
}
|
||||
if (!(System.getProperty("os.name").toLowerCase().contains("os x"))) {
|
||||
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);
|
||||
System.out.println("C&B. color: " + c + " compare with " + AWT_VERIFY_COLOR);
|
||||
if (c.equals(AWT_VERIFY_COLOR)) {
|
||||
fail(failMessageColorCheck);
|
||||
passed = false;
|
||||
@ -422,8 +443,8 @@ public abstract class OverlappingTestBase {
|
||||
|
||||
robot.mouseMove(loc.x, loc.y);
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
Util.waitForIdle(robot);
|
||||
}
|
||||
|
||||
@ -454,36 +475,32 @@ public abstract class OverlappingTestBase {
|
||||
*/
|
||||
protected Component currentAwtControl;
|
||||
|
||||
private void testComponent(Component component) throws InterruptedException, InvocationTargetException {
|
||||
private void testComponent(Component component) throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
Robot robot = null;
|
||||
try {
|
||||
robot = new Robot();
|
||||
}catch(Exception ignorex) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
currentAwtControl = component;
|
||||
System.out.println("Testing " + currentAwtControl.getClass().getSimpleName());
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
prepareControls();
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> prepareControls());
|
||||
|
||||
if (component != null) {
|
||||
Util.waitTillShown(component);
|
||||
}
|
||||
Util.waitForIdle(robot);
|
||||
try {
|
||||
Thread.sleep(500); // wait for graphic effects on systems like Win7
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
|
||||
// wait for graphic effects on systems like Win7
|
||||
robot.delay(500);
|
||||
|
||||
if (!instance.performTest()) {
|
||||
fail(failMessage);
|
||||
passed = false;
|
||||
}
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> cleanup());
|
||||
}
|
||||
|
||||
private void testEmbeddedFrame() throws InvocationTargetException, InterruptedException {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -26,10 +26,15 @@ 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;
|
||||
@ -37,7 +42,6 @@ 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 viewport
|
||||
@ -65,6 +69,7 @@ public class ViewportOverlapping extends OverlappingTestBase {
|
||||
private Point vLoc;
|
||||
private Point testLoc;
|
||||
private Point resizeLoc;
|
||||
private static Robot robot;
|
||||
|
||||
private JFrame f;
|
||||
private JPanel p;
|
||||
@ -81,7 +86,6 @@ public class ViewportOverlapping extends OverlappingTestBase {
|
||||
|
||||
f = new JFrame();
|
||||
f.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
frameClicked++;
|
||||
@ -99,60 +103,75 @@ public class ViewportOverlapping extends OverlappingTestBase {
|
||||
@Override
|
||||
protected boolean performTest() {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
// prepare test data
|
||||
frameClicked = 0;
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
// prepare test data
|
||||
frameClicked = 0;
|
||||
|
||||
b.requestFocus();
|
||||
b.requestFocus();
|
||||
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(40);
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(40);
|
||||
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);
|
||||
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);
|
||||
testLoc = p.getLocationOnScreen();
|
||||
testLoc.translate(-3, -3);
|
||||
|
||||
resizeLoc = f.getLocationOnScreen();
|
||||
resizeLoc.translate(f.getWidth() - 1, f.getHeight() - 1);
|
||||
}
|
||||
resizeLoc = f.getLocationOnScreen();
|
||||
resizeLoc.translate(f.getWidth() - 1, f.getHeight() - 1);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Problem preparing test GUI.");
|
||||
}
|
||||
// run robot
|
||||
Robot robot = Util.createRobot();
|
||||
robot.setAutoDelay(ROBOT_DELAY);
|
||||
|
||||
robot.mouseMove(hLoc.x, hLoc.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
Util.waitForIdle(robot);
|
||||
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_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
Util.waitForIdle(robot);
|
||||
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_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseMove(resizeLoc.x + 5, resizeLoc.y + 5);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
Util.waitForIdle(robot);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
captureScreen("Img_3");
|
||||
|
||||
clickAndBlink(robot, testLoc, false);
|
||||
return frameClicked == 2;
|
||||
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 InterruptedException {
|
||||
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…
x
Reference in New Issue
Block a user