Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7550870
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Feb 29, 2024
54766dd
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Mar 1, 2024
12dc34e
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Mar 1, 2024
5e28d1d
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Mar 1, 2024
008dff4
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Mar 1, 2024
5b8b0b8
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Apr 1, 2024
232db3b
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Apr 18, 2024
ecd34da
Merge branch 'openjdk:master' into backport-8185500
yaqsun Apr 18, 2024
485457e
Merge branch 'openjdk:master' into backport-8185500
yaqsun May 28, 2024
8a0b148
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Jun 11, 2024
ae71cd2
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Jun 11, 2024
4c69d5c
Merge branch 'openjdk:master' into backport-8185500
yaqsun Jun 12, 2024
1fc9217
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Jun 13, 2024
11d35aa
backport 8186259: IOExceptionIfEncodedURLTest.sh versus IOExceptionIf…
yaqsun Jun 17, 2024
5ba12d7
Backport 34afeced211cd7115e2529b043c1e57dfa1291fe
yaqsun Jun 18, 2024
2ee8478
del '@(#)TestSinhalaChar.java' after '@test'
yaqsun Jun 25, 2024
330839e
add '@build Sysout'
yaqsun Jun 26, 2024
5abebe0
Merge branch 'openjdk:master' into backport-8185500
yaqsun Oct 31, 2024
906ade3
backport jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java
yaqsun Oct 31, 2024
8563895
Merge branch 'openjdk:master' into backport-8185500
yaqsun Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 116 additions & 58 deletions jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
Expand All @@ -22,11 +22,25 @@
*/

/* @test
@bug 7123767
@key headful randomness
@summary Wrong tooltip location in Multi-Monitor configurations
@author Vladislav Karnaukhov
@run main bug7123767
* @bug 7123767
*
* @summary Check if a tooltip location in Multi-Monitor
* configurations is correct.
* If the configurations number per device exceeds 5,
* then some 5 random configurations will be checked.
* Please Use -Dseed=X to set the random generator seed
* (if necessary).
*
* @author Vladislav Karnaukhov
*
* @key headful
* @key randomness
*
* @modules java.desktop/sun.awt
* @library /lib/testlibrary/
* @build jdk.testlibrary.*
*
* @run main/timeout=300 bug7123767
*/

import javax.swing.*;
Expand All @@ -35,8 +49,50 @@
import java.awt.event.MouseEvent;
import java.lang.reflect.InvocationTargetException;

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

import jdk.testlibrary.RandomFactory;


public class bug7123767 extends JFrame {

// maximum number of GraphicsConfigurations checked per GraphicsDevice
private static final int MAX_N_CONFIGS = 5;
private static final List<GraphicsConfiguration> CONFIGS = getConfigs();

private static List<GraphicsConfiguration> getConfigs() {

Random rnd = RandomFactory.getRandom();

List<GraphicsConfiguration> configs = new ArrayList<>();

GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = ge.getScreenDevices();

for (GraphicsDevice device : devices) {
GraphicsConfiguration[] allConfigs = device.getConfigurations();
int nConfigs = allConfigs.length;
if (nConfigs <= MAX_N_CONFIGS) {
Collections.addAll(configs, allConfigs);
} else { // see JDK-8159454
System.out.println("check only " + MAX_N_CONFIGS +
" configurations for device " + device);
configs.add(device.getDefaultConfiguration()); // check default
for (int j = 0; j < MAX_N_CONFIGS - 1; j++) {
int k = rnd.nextInt(nConfigs);
configs.add(allConfigs[k]);
}
}
}

return configs;
}


private static class TestFactory extends PopupFactory {

private static TestFactory newFactory = new TestFactory();
Expand All @@ -60,15 +116,21 @@ public static void uninstall() {
}

// Actual test happens here
@Override
public Popup getPopup(Component owner, Component contents, int x, int y) {
GraphicsConfiguration mouseGC = testGC(MouseInfo.getPointerInfo().getLocation());

GraphicsConfiguration mouseGC =
testGC(MouseInfo.getPointerInfo().getLocation());

if (mouseGC == null) {
throw new RuntimeException("Can't find GraphicsConfiguration that mouse pointer belongs to");
throw new RuntimeException("Can't find GraphicsConfiguration "
+ "that mouse pointer belongs to");
}

GraphicsConfiguration tipGC = testGC(new Point(x, y));
if (tipGC == null) {
throw new RuntimeException("Can't find GraphicsConfiguration that tip belongs to");
throw new RuntimeException(
"Can't find GraphicsConfiguration that tip belongs to");
}

if (!mouseGC.equals(tipGC)) {
Expand All @@ -79,17 +141,14 @@ public Popup getPopup(Component owner, Component contents, int x, int y) {
}

private static GraphicsConfiguration testGC(Point pt) {
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = environment.getScreenDevices();
for (GraphicsDevice device : devices) {
GraphicsConfiguration[] configs = device.getConfigurations();
for (GraphicsConfiguration config : configs) {
Rectangle rect = config.getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
adjustInsets(rect, insets);
if (rect.contains(pt))
return config;
}

for (GraphicsConfiguration config: CONFIGS) {

Rectangle rect = config.getBounds();
Insets insets =
Toolkit.getDefaultToolkit().getScreenInsets(config);
adjustInsets(rect, insets);
if (rect.contains(pt)) { return config; }
}

return null;
Expand All @@ -101,15 +160,18 @@ private static GraphicsConfiguration testGC(Point pt) {
private static Robot robot;

public static void main(String[] args) throws Exception {

UIManager.setLookAndFeel(new MetalLookAndFeel());
setUp();
testToolTip();
TestFactory.uninstall();
if (frame != null) { frame.dispose(); }
}

// Creates a window that is stretched across all available monitors
// and adds itself as ContainerListener to track tooltips drawing
private bug7123767() {

super();

ToolTipManager.sharedInstance().setInitialDelay(0);
Expand All @@ -133,17 +195,16 @@ public Point getToolTipLocation(MouseEvent event) {
pack();

Rectangle rect = new Rectangle();
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = environment.getScreenDevices();
for (GraphicsDevice device : devices) {
GraphicsConfiguration[] configs = device.getConfigurations();
for (GraphicsConfiguration config : configs) {
Insets localInsets = Toolkit.getDefaultToolkit().getScreenInsets(config);
Rectangle localRect = config.getBounds();
adjustInsets(localRect, localInsets);
rect.add(localRect);
}

for (GraphicsConfiguration config: CONFIGS) {

Insets localInsets =
Toolkit.getDefaultToolkit().getScreenInsets(config);
Rectangle localRect = config.getBounds();
adjustInsets(localRect, localInsets);
rect.add(localRect);
}

setBounds(rect);
}

Expand All @@ -164,35 +225,32 @@ private static void testToolTip() throws AWTException {
robot.setAutoDelay(20);
robot.waitForIdle();

GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = environment.getScreenDevices();
for (GraphicsDevice device : devices) {
GraphicsConfiguration[] configs = device.getConfigurations();
for (GraphicsConfiguration config : configs) {
Rectangle rect = config.getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
adjustInsets(rect, insets);
for (GraphicsConfiguration config: CONFIGS) {

// Upper left
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + MARGIN, rect.y + MARGIN);
robot.waitForIdle();

// Lower left
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + MARGIN, rect.y + rect.height - MARGIN);
robot.waitForIdle();

// Upper right
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + rect.width - MARGIN, rect.y + MARGIN);
robot.waitForIdle();

// Lower right
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + rect.width - MARGIN, rect.y + rect.height - MARGIN);
robot.waitForIdle();
}
Rectangle rect = config.getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
adjustInsets(rect, insets);

// Upper left
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + MARGIN, rect.y + MARGIN);
robot.waitForIdle();

// Lower left
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + MARGIN, rect.y + rect.height - MARGIN);
robot.waitForIdle();

// Upper right
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + rect.width - MARGIN, rect.y + MARGIN);
robot.waitForIdle();

// Lower right
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + rect.width - MARGIN, rect.y + rect.height - MARGIN);

robot.waitForIdle();
}
}

Expand Down