-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
Clean up and move to poen five more tests.
👋 Welcome back kizune! A progress list of the required criteria for merging this PR into |
@azuev-java The following label will be automatically applied to this pull request:
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. |
Webrevs
|
JInternalFrame jif; | ||
|
||
Robot robot; | ||
volatile boolean keyTyped = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
volatile boolean keyTyped = false; | |
volatile boolean keyTyped = false; |
} | ||
robo.setAutoDelay(100); | ||
robo.delay(1000); | ||
robo.mouseMove(100,100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
robo.mouseMove(100,100); | |
robo.mouseMove(100, 100); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static void main(String[] args) { | |
public static void main(String[] args) { |
There was a problem hiding this 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.
} catch (PropertyVetoException ex) { | ||
ex.printStackTrace(); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
} catch (Exception e) { | ||
throw new RuntimeException("Test interrupted by " | ||
+ e.getLocalizedMessage()); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
synchronized (bug4773378.this) { | ||
keyTyped = true; | ||
bug4773378.this.notifyAll(); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed as frameActivated
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} catch (Throwable t) { | ||
t.printStackTrace(); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
try { | ||
Thread.sleep(50); | ||
} catch (InterruptedException ex) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try { | |
Thread.sleep(50); | |
} catch (InterruptedException ex) {} | |
jRobo.delay(50); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JRobot jRobo = JRobot.getRobot(); | |
JRobot jRobo = JRobot.getRobot(); | |
jRobo.waitForIdle(); |
Let the frame appear on the screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* @library ../../regtesthelpers | ||
* @build JRobot |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JFrame frame = null; | |
JFrame frame; |
null
is the default value any way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
public static void main(String args[]) throws InterruptedException, | ||
InvocationTargetException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static void main(String args[]) throws InterruptedException, | |
InvocationTargetException { | |
public static void main(String[] args) throws Exception { |
Java-style array declaration, shortened throws
clause.
There was a problem hiding this comment.
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.
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
@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:
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
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 |
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. |
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> |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
Issue
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