Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8137101: [TEST_BUG] javax/swing/plaf/basic/BasicHTML/4251579/bug42515…
…79.java failure due to timing

Reviewed-by: azvegint
  • Loading branch information
prsadhuk committed Jul 28, 2021
1 parent a066c7b commit dcdb1b6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 33 deletions.
2 changes: 0 additions & 2 deletions test/jdk/ProblemList.txt
Expand Up @@ -745,8 +745,6 @@ javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all
javax/swing/JRootPane/4670486/bug4670486.java 8042381 macosx-all
javax/swing/JPopupMenu/4634626/bug4634626.java 8017175 macosx-all

javax/swing/plaf/basic/BasicHTML/4251579/bug4251579.java 8137101 linux-x64

sanity/client/SwingSet/src/ToolTipDemoTest.java 8225012 windows-all,macosx-all
sanity/client/SwingSet/src/ScrollPaneDemoTest.java 8225013 linux-all
sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 8265770 macosx-all
Expand Down
77 changes: 46 additions & 31 deletions test/jdk/javax/swing/plaf/basic/BasicHTML/4251579/bug4251579.java
@@ -1,6 +1,6 @@

/*
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2021, 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 @@ -27,54 +27,68 @@
* @key headful
* @bug 4251579
* @summary Tests if style sheets are working in JLabel
* @author Denis Sharypov
* @run main bug4251579
*/
import java.awt.*;
import javax.swing.*;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Robot;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class bug4251579 {

private static JLabel htmlComponent;
private static JFrame mainFrame;

public static void main(String[] args) throws Exception {
final Robot robot = new Robot();
robot.setAutoDelay(50);

SwingUtilities.invokeAndWait(new Runnable() {
try {
SwingUtilities.invokeAndWait(new Runnable() {

@Override
public void run() {
createAndShowGUI();
}
});
@Override
public void run() {
createAndShowGUI();
}
});

robot.waitForIdle();
robot.waitForIdle();
robot.delay(1000);

SwingUtilities.invokeAndWait(new Runnable() {
SwingUtilities.invokeAndWait(new Runnable() {

@Override
public void run() {
boolean passed = false;
@Override
public void run() {
boolean passed = false;

Point p = htmlComponent.getLocationOnScreen();
Dimension d = htmlComponent.getSize();
int x0 = p.x;
int y = p.y + d.height / 2;
Point p = htmlComponent.getLocationOnScreen();
Dimension d = htmlComponent.getSize();
int x0 = p.x;
int y = p.y + d.height / 2;

for (int x = x0; x < x0 + d.width; x++) {
if (robot.getPixelColor(x, y).equals(Color.blue)) {
passed = true;
break;
for (int x = x0; x < x0 + d.width; x++) {
if (robot.getPixelColor(x, y).equals(Color.blue)) {
passed = true;
break;
}
}
}

if (!passed) {
throw new RuntimeException("Test failed.");
}
if (!passed) {
throw new RuntimeException("Test failed.");
}

}
});
}
});
} finally {
SwingUtilities.invokeAndWait(() -> {
if (mainFrame != null) {
mainFrame.dispose();
}
});
}
}

private static void createAndShowGUI() {
Expand All @@ -86,12 +100,13 @@ private static void createAndShowGUI() {
+ "<P class=\"blue\"> should be rendered with BLUE class definition</P>"
+ "</body>";

JFrame mainFrame = new JFrame("bug4251579");
mainFrame = new JFrame("bug4251579");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

htmlComponent = new JLabel(htmlText);
mainFrame.getContentPane().add(htmlComponent);

mainFrame.setLocationRelativeTo(null);
mainFrame.pack();
mainFrame.setVisible(true);
}
Expand Down

3 comments on commit dcdb1b6

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on dcdb1b6 Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on dcdb1b6 Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin Could not automatically backport dcdb1b6a to Optional[openjdk/jdk17u] due to conflicts in the following files:

  • test/jdk/ProblemList.txt

To manually resolve these conflicts run the following commands in your personal fork of Optional[openjdk/jdk17u]:

$ git checkout -b GoeLin-backport-dcdb1b6a
$ git fetch --no-tags https://git.openjdk.java.net/jdk dcdb1b6aaad912669614ff52ad2b0b8804f204d1
$ git cherry-pick --no-commit dcdb1b6aaad912669614ff52ad2b0b8804f204d1
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport dcdb1b6aaad912669614ff52ad2b0b8804f204d1'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the Optional[openjdk/jdk17u] with the title Backport dcdb1b6aaad912669614ff52ad2b0b8804f204d1.

Please sign in to comment.