-
Notifications
You must be signed in to change notification settings - Fork 517
8255337: [TestBug] Controls unit tests - ButtonTest and ComboBoxTest - log ClassCastException #337
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
8255337: [TestBug] Controls unit tests - ButtonTest and ComboBoxTest - log ClassCastException #337
Conversation
👋 Welcome back aghaisas! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
||
mouse.dispose(); | ||
} |
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.
just curious: do we have to dispose the mouseFirer? If so, that pattern isn't safe because it will not happen if the test fails.
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.
Hmm.. very good point. I believe, we should use dispose mechanism whenever available for a readable cleanup. Both classes MouseEventFirer & StageLoader provide dispose method and the user of these classes should use it.
Now, this can be handled in two ways -
- Keep a reference at test class level - it will be null by default - individual tests will create the object and update the class reference - we can dispose in cleanup method after the test
- Use Try blocks in tests that use MouseEventFirerer or StageLoader objects and dispose them in finally{} blocks.
We can use (1) if many tests in a test class use MouseEventFirerer or StageLoader objects - for example ComboBoxTest and use approach (2) if very few tests use these classes - for example ButtonTest.
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.
makes sense :)
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.
just looked at MouseEventFirer (a bit late, sry ;): all it does is to dispose the Stageloader it created (if it received a bare node) - so if we add a node to a stage and/or wrap it into our own loader, we don't really need to dispose the firer (though it doesn't hurt except a very minimal code clutter)
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.
If we use our own loader - we would need to dispose that as well :)
Also, I found approach (1) of using reference at test class level and cleaning it up in cleanup method after the test is more suitable as in ButtonTest, the assertion happens in event handler. Wrapping it in try..finally will need additional code.
I will push the changes in a moment.
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.
nit-picking: we already do dispose our own loader (or cleanup our stage), don't we :)
the change looks good
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.
Can you please mark it as Approved?
Stage stage = new Stage(); | ||
Scene scene = new Scene(comboBox); | ||
stage.setScene(scene); | ||
StageLoader sl = new StageLoader(comboBox); | ||
|
||
|
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.
good catch :) But wouldn't show the stage have the same effect? (It's just me having a personal dislike of stageloader :)
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.
stage.show() has the same effect of fixing the bug. In fact, I fixed it initially with exact this fix.
When I looked at the other tests in ComboBoxTest class, I saw that there is a pattern of creating a Stage, creating a Scene with ComboBox and then adding Scene to the Stage. What was missed was stage.show(). The StageLoader does exactly these steps (including the missed stage.show()).
StageLoader might be a misfit at some of the other places in our tests (I believe that is the reason for your dislike), but I feel using StageLoader is a better fit in ComboBoxTest.
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.
thanks!
Wondering as to when/why Stageloader might be a misfit? I completely gave up on using it a while ago, so don't really remember *cough
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 that StageLoader is bad as such. By misfit - I meant - error prone to be used in tests that already use their own Scene and Stage creation.
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.
ahh .. I see, thanks :)
sl.dispose(); | ||
} |
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.
just for completeness: same as mouse.dispose above :)
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.
fix looks good to me - approving, but probably will need a "real" reviewer :)
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 good.
@aghaisas 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 5 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
/integrate |
@aghaisas Since your change was applied there have been 5 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 690d266. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is a test fix.
Root cause:
Fix :
I have attached the logs captured before and after this fix to the JBS.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jfx pull/337/head:pull/337
$ git checkout pull/337