Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8316388: Opensource five Swing component related regression tests #18184

Closed
wants to merge 3 commits into from

Conversation

azuev-java
Copy link
Member

@azuev-java azuev-java commented Mar 11, 2024

Clean up five more tests.

test/jdk/javax/swing/JDesktopPane/4132993/bug4132993.java
test/jdk/javax/swing/JDesktopPane/4773378/bug4773378.java
test/jdk/javax/swing/JEditorPane/4325606/bug4325606.java
test/jdk/javax/swing/JEditorPane/4330998/bug4330998.java
test/jdk/javax/swing/JEditorPane/4694598/FrameContent.html
test/jdk/javax/swing/JEditorPane/4694598/bug4694598.java


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8316388: Opensource five Swing component related regression tests (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18184/head:pull/18184
$ git checkout pull/18184

Update a local copy of the PR:
$ git checkout pull/18184
$ git pull https://git.openjdk.org/jdk.git pull/18184/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18184

View PR using the GUI difftool:
$ git pr show -t 18184

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18184.diff

Webrev

Link to Webrev Comment

Clean up and move to poen five more tests.
@bridgekeeper
Copy link

bridgekeeper bot commented Mar 11, 2024

👋 Welcome back kizune! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 11, 2024
@openjdk
Copy link

openjdk bot commented Mar 11, 2024

@azuev-java The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Mar 11, 2024
@mlbridge
Copy link

mlbridge bot commented Mar 11, 2024

Webrevs

JInternalFrame jif;

Robot robot;
volatile boolean keyTyped = false;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
volatile boolean keyTyped = false;
volatile boolean keyTyped = false;

}
robo.setAutoDelay(100);
robo.delay(1000);
robo.mouseMove(100,100);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
robo.mouseMove(100,100);
robo.mouseMove(100, 100);

Copy link
Contributor

Choose a reason for hiding this comment

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

Whilst it is fine to use setLocation(int, int), I do agree that assuming it will be precisely honoured is risky.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, i will ise the actual location of the frame instead.

import javax.swing.JEditorPane;

public class bug4330998 {
public static void main(String[] args) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public static void main(String[] args) {
public static void main(String[] args) {

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

The copyright year should be updated to 2024.

The directory structure should be flattened, there's no need for additional folder in the path.

Comment on lines 45 to 47
} catch (PropertyVetoException ex) {
ex.printStackTrace();
}
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the test fail if an unexpected exception is thrown?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not unexpected but instead of failing i think test should just pass. Which will happen because the internal frame is not minimized so the test condition is not recreated.

Copy link
Member

Choose a reason for hiding this comment

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

I believe it's unexpected because we don't expect PropertyVetoException, in which case failure seems a better option.

If anything changes so that PropertyVetoException would be thrown all the time, the test would appear to be passing whereas it would not run at all.

Copy link
Member

Choose a reason for hiding this comment

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

This is the only point with which I disagree.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I see no reason to catch anything unless it is known to sometimes happen and not be a problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, removing the try/catch clause, this will cause this exception to cause test to fail.

Comment on lines 56 to 59
} catch (Exception e) {
throw new RuntimeException("Test interrupted by "
+ e.getLocalizedMessage());
}
Copy link
Member

Choose a reason for hiding this comment

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

You can add throws Exception clause to the main method and remove this catch block.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

Comment on lines 66 to 69
synchronized (bug4773378.this) {
keyTyped = true;
bug4773378.this.notifyAll();
}
Copy link
Member

Choose a reason for hiding this comment

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

A CountDownLatch would work great in this case.

And keyTyped is a confusing name for a flag which gets to true when the internal frame is activated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed as frameActivated

Copy link
Member

Choose a reason for hiding this comment

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

I'm still for using CountDownLatch, it looks cleaner in my opinion.


public void performTest() {
try {
jif.setSelected(true);
Copy link
Member

Choose a reason for hiding this comment

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

This should be called via SwingUtilities.invokeLater on EDT.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 100 to 102
} catch (Throwable t) {
t.printStackTrace();
}
Copy link
Member

Choose a reason for hiding this comment

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

A Throwable should fail the test, it must be propagated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 79 to 81
try {
Thread.sleep(50);
} catch (InterruptedException ex) {}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
try {
Thread.sleep(50);
} catch (InterruptedException ex) {}
jRobo.delay(50);

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.


public void performTest() throws InterruptedException,
InvocationTargetException {
JRobot jRobo = JRobot.getRobot();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
JRobot jRobo = JRobot.getRobot();
JRobot jRobo = JRobot.getRobot();
jRobo.waitForIdle();

Let the frame appear on the screen.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Comment on lines 28 to 29
* @library ../../regtesthelpers
* @build JRobot
Copy link
Member

Choose a reason for hiding this comment

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

The test doesn't seem to use any of the extended functionality provided by JRobot, so the standard java.awt.Robot can be used instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not see any harm in using JRobot, it is a Swing test after all.

Copy link
Member

Choose a reason for hiding this comment

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

No harm but a dependency on a library which isn't used.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am very much against including libraries that aren't needed.
If this test isn't using any JRobot functionality, please remove it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, removed.

import javax.swing.SwingUtilities;

public class bug4694598 {
JFrame frame = null;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
JFrame frame = null;
JFrame frame;

null is the default value any way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

Comment on lines 92 to 93
public static void main(String args[]) throws InterruptedException,
InvocationTargetException {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public static void main(String args[]) throws InterruptedException,
InvocationTargetException {
public static void main(String[] args) throws Exception {

Java-style array declaration, shortened throws clause.

Copy link
Member Author

Choose a reason for hiding this comment

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

Switched the array declaration but i would prefer to keep all the exceptions listed in the main method declaration.

@azuev-java
Copy link
Member Author

I would prefer to keep the directory structure - it does not make any difference after al and sometimes makes test logs more readable.

Minor changes based on the review comments
@openjdk
Copy link

openjdk bot commented Mar 12, 2024

@azuev-java This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8316388: Opensource five Swing component related regression tests

Reviewed-by: aivanov

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 532 new commits pushed to the master branch:

  • d5b95a0: 8327631: Update IANA Language Subtag Registry to Version 2024-03-07
  • 966a42f: 8324868: debug agent does not properly handle interrupts of a virtual thread
  • 22f10e0: 8327856: Convert applet test SpanishDiacriticsTest.java to a main program
  • 7283c8b: 8327972: Convert java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.html applet test to main
  • 30249c4: 8327838: Convert java/awt/FileDialog/MultipleMode/MultipleMode.html applet test to main
  • 94b4ed5: 8327096: (fc) java/nio/channels/FileChannel/Size.java fails on partition incapable of creating large files
  • b9c3dc3: 8327738: Remove unused internal method sun.n.w.p.h.HttpURLConnection.setDefaultAuthenticator
  • 5b41466: 8327729: Remove deprecated xxxObject methods from jdk.internal.misc.Unsafe
  • 313e814: 8324682: Remove redefinition of NULL for XLC compiler
  • 8a3bdd5: 8327995: Remove unused Unused_Variable
  • ... and 522 more: https://git.openjdk.org/jdk/compare/e999dfcb405962bc4d77b9740d36193f1ebe4a2c...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 12, 2024
@aivanov-jdk
Copy link
Member

I would prefer to keep the directory structure - it does not make any difference after al and sometimes makes test logs more readable.

At times, I find it easier to manage in IDE either. Just mark one folder as Test Sources, and it brings only one test. A folder with lots of tests often results in compilation errors because of duplicate classes and so on.

@prrace
Copy link
Contributor

prrace commented Mar 12, 2024

With the exception of bug4694598.java, there is no need for the extra level of folder for these tests

Tests moved to the components folders.
@@ -0,0 +1,3 @@
<HTML><BODY>
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you forgot to remove this file ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also a bit surprised I don't see all the rest of the original html & java files anywhere now, not as deleted, not as changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's something wrong with the latest commit. Looking at it now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, either github or skara got mad at me for pushing commit with both rename and edit changes of the same files. Tried to fix it but it only gets worse so what i'm going to do is i will clone a fresh repository, move stuff there, close this PR and create a new one tomorrow morning with the latest versions of files in correct places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

4 participants