RFR: JDK-8340210 : Add positionTestUI() to PassFailJFrame.Builder [v2]
Alexander Zvegintsev
azvegint at openjdk.org
Tue Sep 17 08:41:05 UTC 2024
On Mon, 16 Sep 2024 21:38:36 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:
>> `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](https://github.com/openjdk/jdk/pull/15721)**
>
> Harshitha Onkar has updated the pull request incrementally with one additional commit since the last revision:
>
> removed errorenous check
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.
-------------
PR Review: https://git.openjdk.org/jdk/pull/21023#pullrequestreview-2308800489
More information about the client-libs-dev
mailing list