-
Notifications
You must be signed in to change notification settings - Fork 6.2k
JDK-8340210 : Add positionTestUI() to PassFailJFrame.Builder #21023
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
Conversation
|
👋 Welcome back honkar! A progress list of the required criteria for merging this PR into |
|
@honkar-jdk 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 120 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 |
|
@honkar-jdk 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. |
|
/contributor add @aivanov-jdk |
|
@honkar-jdk |
Webrevs
|
aivanov-jdk
left a comment
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 to me.
It was previously discussed in #15665 when I added testUI. The interface and the field in the builder were defined but there was no way to pass an implementation of PositionWindows.
Since the position implementation is done in test code it allows flexibility as the user can add custom positioning code per test UI requirements.
There's an enhancement JDK-8317116: Provide layouts for multiple test UI in PassFailJFrame to provide a set of common layouts for tests to re-use. It would avoid code duplication for the most common layouts like columns or rows to the right or bottom of the instruction UI.
Update PR description with the PR link related to JDK-8317116 in case anyone wants to explore custom positioning of multiple UIs. |
| if (windowListCreator == null || testWindows == null) { | ||
| throw new IllegalStateException("Neither a windows list creator " | ||
| + "nor a list of test windows " | ||
| + "has been provided"); | ||
| } |
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.
@aivanov-jdk Running into exception when this check is added here. I believe Builder's windowListCreator and testWindows are not assigned yet at this stage.
And since this check is already in-place here: validate(), I'm removing it from positionTestUI().
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 condition should've been &&: the error message is correct, the exception was supposed to be thrown if both windowListCreator and testWindows is null. The condition with || is always true.
Yet I agree to remove this condition from here as it enforces the order of calls, which is not strictly required, even though it would common to add a window creator before setting positioning.
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 think that this can be improved by adding some predefined positionTestUI functions, like in the #15721 (we can borrow them from it).
For example, consider adding PositionWindowsLib.java(or maybe a nested public static class for PassFailJFrame to avoid extra @build clause), which has functions something like
.positionTestUI(PositionWindowsLib::positionHH) // aka TwoWindowsHH.positionTestUI
.positionTestUI(PositionWindowsLib::positionHV) // aka TwoWindowsHV.positionTestUI
...It'll be easier for a test developer to just take a ready-to-use function (which in most cases will be the same across multiple tests),
and it'll be easier for the test reviewer because there will be less code to review.
| * @throws IllegalStateException if the {@code positionWindows} field | ||
| * is already set, or if neither a windows list creator | ||
| * nor a list of test windows has been provided |
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.
| * @throws IllegalStateException if the {@code positionWindows} field | |
| * is already set, or if neither a windows list creator | |
| * nor a list of test windows has been provided | |
| * @throws IllegalStateException if the {@code positionWindows} field | |
| * is already set |
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.
Updated
I agree that we should — and we will. Yet I don't see missing default layouts as stopper from integrating this PR. Adding a library of common layouts will take more time — to add layouts and to review — and @honkar-jdk wants to use the feature right now. It's better to do it with what's currently available rather than implement tricks to position two test UI windows. @kumarabhi006 also asked about the feature. Once tests are created, or even right now, we can submit bugs to update the test and use a common layout rather than one in the test and link those bugs as blocked by JDK-8317116. There's already a test jdk/test/jdk/java/awt/event/KeyEvent/AcceleratorTest/AcceleratorTest.java Lines 157 to 161 in c6721a0
This test could be updated to use logging area instead of two test windows. Either way works.
I've thought about it. We can add the most common layout right into I think we should add convenience methods |
|
There has been no need for multiple test windows for nearly a year, it's not the most used feature. This is why I think we can add common layouts later rather than rush it right now. A few tests are also easy to update, and these tests would be a live demo for the improvement. |
aivanov-jdk
left a comment
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 wanted to request the changes instead: the description of the method needs updating as the result of removing the check for window creator or window list.
@azvegint Valid suggestion and re-usability of common layouts is better than having to repeat it in the test code. This will be added as next step to PassFailJFrame iterative improvement as @aivanov-jdk suggested. |
|
/integrate |
|
Going to push as commit f0ae90f.
Your commit was automatically rebased without conflicts. |
|
@honkar-jdk Pushed as commit f0ae90f. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
positionTestUI()option is added to PassFailJFrame (PFJ).With this change multiple UI can be positioned using the PFJ new builder pattern by providing implementation for the Functional Interface
PositionWindows.positionTestWindows(List<? extends Window> testWindows,InstructionUI instructionUI)in the test code.Since the position implementation is done in test code it allows flexibility as the user can add custom positioning code as per test UI requirements.
Usage:
where positionMultiTestUI is the implementation for positioning of multiple test windows for
PositionWindows.positionTestWindows(List<? extends Window> testWindows,InstructionUI instructionUI)@aivanov-jdk has demonstrated custom test UI positioning in this PR:
8294156: Demo positioning of multiple test windows
Progress
Issue
Reviewers
Contributors
<aivanov@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21023/head:pull/21023$ git checkout pull/21023Update a local copy of the PR:
$ git checkout pull/21023$ git pull https://git.openjdk.org/jdk.git pull/21023/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21023View PR using the GUI difftool:
$ git pr show -t 21023Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21023.diff
Webrev
Link to Webrev Comment