Skip to content

Conversation

@honkar-jdk
Copy link
Contributor

@honkar-jdk honkar-jdk commented Sep 16, 2024

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:

PassFailJFrame.builder()
                      .title("Test Instructions")
                      .instructions(INSTRUCTIONS)
                      .rows(int)
                      .columns(int)
                      .testUI(<TestClass::createAndShowUI>)
                      .positionTestUI(<TestClass::positionMultiTestUI>)
                      .build()
                      .awaitAndCheck();

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

  • 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-8340210: Add positionTestUI() to PassFailJFrame.Builder (Enhancement - P4)

Reviewers

Contributors

  • Alexey Ivanov <aivanov@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21023

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 16, 2024

👋 Welcome back honkar! 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
Copy link

openjdk bot commented Sep 16, 2024

@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:

8340210: Add positionTestUI() to PassFailJFrame.Builder

Co-authored-by: Alexey Ivanov <aivanov@openjdk.org>
Reviewed-by: aivanov, azvegint

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 master branch:

  • eabfc6e: 8337563: NMT: rename MEMFLAGS to MemTag
  • d588182: 8338686: App classpath mismatch if a jar from the Class-Path attribute is on the classpath
  • 5dc9723: 8340323: Test jdk/classfile/OptionsTest.java fails after JDK-8340200
  • 90e92f9: 8339790: Support Intel APX setzucc instruction
  • 28d009c: 8339934: Simplify Math.scalb(double) method
  • 3e14fb9: 8340200: Misspelled constant AttributesProcessingOption.DROP_UNSTABLE_ATRIBUTES
  • 64e3a9e: 8339574: Behavior of File.is{Directory,File,Hidden} is not documented with respect to symlinks
  • f877016: 8315273: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link (win)
  • b39e6a8: 8329816: Add SLEEF version 3.6.1
  • 80db6e7: 8339648: ZGC: Division by zero in rule_major_allocation_rate
  • ... and 110 more: https://git.openjdk.org/jdk/compare/f0e84b7617aebc421483f36bb7d0b14d0fc39616...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 rfr Pull request is ready for review label Sep 16, 2024
@openjdk
Copy link

openjdk bot commented Sep 16, 2024

@honkar-jdk 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 Sep 16, 2024
@honkar-jdk
Copy link
Contributor Author

/contributor add @aivanov-jdk

@openjdk
Copy link

openjdk bot commented Sep 16, 2024

@honkar-jdk
Contributor Alexey Ivanov <aivanov@openjdk.org> successfully added.

@mlbridge
Copy link

mlbridge bot commented Sep 16, 2024

Webrevs

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.

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.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 16, 2024
@honkar-jdk honkar-jdk changed the title JDK-8340210 : Add positionTestUI() to PassFailJFrame builder pattern JDK-8340210 : Add positionTestUI() to PassFailJFrame.Builder Sep 16, 2024
@openjdk openjdk bot added ready Pull request is ready to be integrated and removed ready Pull request is ready to be integrated labels Sep 16, 2024
@honkar-jdk
Copy link
Contributor Author

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.

Comment on lines 1273 to 1277
if (windowListCreator == null || testWindows == null) {
throw new IllegalStateException("Neither a windows list creator "
+ "nor a list of test windows "
+ "has been provided");
}
Copy link
Contributor Author

@honkar-jdk honkar-jdk Sep 16, 2024

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().

Copy link
Member

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.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 16, 2024
@honkar-jdk
Copy link
Contributor Author

honkar-jdk commented Sep 16, 2024

@azvegint You may want to review this PR, as it is related to #15721

Copy link
Member

@azvegint azvegint left a 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.

Comment on lines 1262 to 1264
* @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
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
* @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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

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

aivanov-jdk commented Sep 17, 2024

I think that this can be improved by adding some predefined positionTestUI functions, like in the #15721 (we can borrow them from it).

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 java/awt/event/KeyEvent/AcceleratorTest/AcceleratorTest.java which uses two test UI windows, yet it doesn't do anything to position them:

PassFailJFrame.positionTestWindow(jfr, PassFailJFrame.Position.HORIZONTAL);
jfr.setSize(200, 200);
PassFailJFrame.positionTestWindow(output, PassFailJFrame.Position.HORIZONTAL);
output.setSize(200, 200);

This test could be updated to use logging area instead of two test windows. Either way works.

For example, consider adding PositionWindowsLib.java(or maybe a nested public static class for PassFailJFrame to avoid extra @build clause)

I've thought about it. We can add the most common layout right into PassFailJFrame to avoid additional @build tag. It could even be in a separate class, as you suggest, if it's referenced by PassFailJFrame, it will be automatically compiled by jtreg.

I think we should add convenience methods positionTestUIRows, positionTestUIColumns, it'll make using the common layouts even simpler. If the convenience methods reference another class, it should be compiled automatically; if it doesn't work, we will put the layouts as a nested class or as methods directly into PassFailJFrame.

@aivanov-jdk
Copy link
Member

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.

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.

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.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 17, 2024
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 17, 2024
@honkar-jdk
Copy link
Contributor Author

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
...

@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.

@honkar-jdk
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 17, 2024

Going to push as commit f0ae90f.
Since your change was applied there have been 120 commits pushed to the master branch:

  • eabfc6e: 8337563: NMT: rename MEMFLAGS to MemTag
  • d588182: 8338686: App classpath mismatch if a jar from the Class-Path attribute is on the classpath
  • 5dc9723: 8340323: Test jdk/classfile/OptionsTest.java fails after JDK-8340200
  • 90e92f9: 8339790: Support Intel APX setzucc instruction
  • 28d009c: 8339934: Simplify Math.scalb(double) method
  • 3e14fb9: 8340200: Misspelled constant AttributesProcessingOption.DROP_UNSTABLE_ATRIBUTES
  • 64e3a9e: 8339574: Behavior of File.is{Directory,File,Hidden} is not documented with respect to symlinks
  • f877016: 8315273: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link (win)
  • b39e6a8: 8329816: Add SLEEF version 3.6.1
  • 80db6e7: 8339648: ZGC: Division by zero in rule_major_allocation_rate
  • ... and 110 more: https://git.openjdk.org/jdk/compare/f0e84b7617aebc421483f36bb7d0b14d0fc39616...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 17, 2024
@openjdk openjdk bot closed this Sep 17, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 17, 2024
@openjdk
Copy link

openjdk bot commented Sep 17, 2024

@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.

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 integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants