RFR: 8294156: Demo positioning of multiple test windows [v2]

Alexey Ivanov aivanov at openjdk.org
Thu Sep 14 14:55:41 UTC 2023


On Wed, 13 Sep 2023 21:17:46 GMT, Alexander Zvegintsev <azvegint at openjdk.org> wrote:

>> Alexey Ivanov has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8294156: Additional layouts for vertically positioned test windows
>
> test/jdk/java/awt/Window/8294156/manyWindows/TwoWindowColumnsH.java line 96:
> 
>> 94:     private static final int COLUMNS = 3;
>> 95: 
>> 96:     public static void positionTestUI(List<? extends Window> windows,
> 
> When I thought about adding more than one window, I thought about simply placing everything in a row.
> 
> Looking at all this I have mixed feelings.
> On the one hand a person using all this for the first time will have to spend some time to understand how it works, or take the easy way out and manually arrange the windows.
> On the other hand, the result is impressive, and can make life easier if you don't have to write positionTestUI every time. 
> 
> I think if we do go this way, we should add some standard positionTestUI implementations to PassFailJFrame so that we don't have to reinvent the wheel every time.
> 
> It is also worth considering that looks like we don't have many tests with more than 2-3 windows.

Isn't it the problem? If we allow adding more than one window, there should be a way to position them… as we have a way to position one test window. Do you agree?

> When I thought about adding more than one window, I thought about simply placing everything in a row.

This is pretty easy. If you look at `TwoWindowsHH.java`  
https://github.com/openjdk/jdk/blob/4c0e4d097e3a484698bee0356ba36557ccc9e96c/test/jdk/java/awt/Window/8294156/twoWindows/TwoWindowsHH.java#L64-L69

It implements positioning of test windows in a row, either to the right of the instructions or below it.

Then `TwoWindowsHV.java` does the same for placing test windows in a column to the right or below the instructions.

This still requires refinement.

> Looking at all this I have mixed feelings.

I do too. 

When Lawrence @lawrence-andrew and I started on the manual test framework ([JDK-8283712](https://bugs.openjdk.org/browse/JDK-8283712)), I envisioned it as something light that provided a quick and easy replacement for applet-based manual Yes/No test, that also gave a unified look to manual tests. If I remember correctly, we took inspiration from your code. ;)

As new scenarios emerged, the framework grew… Yet it wasn't as easy to use, it still required manually creating test UI, registering test windows. The idea of disposing of all the frames was rejected on [the code review](https://github.com/openjdk/jdk/pull/7966#discussion_r835700911).

I truly believe Lawrence's idea of the builder pattern ([JDK-8294535](https://bugs.openjdk.org/browse/JDK-8294535)) is a *game-changer*. With the addition of the `testUI` method, the entire `main` method becomes simple, *streamlined*. I think it makes using the framework easier.

I had this idea of passing a method reference to create a test window from the start. But I never thought about supporting two test windows or more.

As you can see, handling one test window is much simpler, the internals have grown dramatically with multiple windows.

At the same time, I must **thank you** for raising this problem. Adding support for multiple windows would've been harder if I'd handled only one test window.

> On the one hand a person using all this for the first time will have to spend some time to understand how it works, or take the easy way out and manually arrange the windows.

The hardest part is making it easy to use… and flexible at the same time.

Manually arranging windows could be easier as the developer knows more about their intentions. Harshitha @honkar-jdk  positioned the test windows manually in #12447. It's always an option.

Framework methods on the other hand should handle everything you throw at them.

> On the other hand, the result is impressive, and can make life easier if you don't have to write positionTestUI every time.

I've had fun writing this code.

> I think if we do go this way, we should add some standard positionTestUI implementations to PassFailJFrame so that we don't have to reinvent the wheel every time.

I didn't even think about not providing any default implementations of `positionTestUI` — that's the idea! The framework should support simple layouts.

Implementing common layouts each time they're used would be a waste of time.

A method reference to an implementation in `PassFailJFrame` could be passed. Alternatively, we can add helper methods to builder which selects the `Position` and `positionTestUI`.

The code in `TwoWindowsHH.java` and `TwoWindowsHV.java` needs refining. Yet it's a great foundation.

I created two-column and two-row layouts for fun. At the same, they're somewhat generic, there are no assumptions that all the windows are of the same size. If there's a need, we can also include them after refining the code. I spent a couple of hours on it, the code can be improved. These layouts could be in a separate source file, one more `@build` line in the test tags.

Thus, the interface allows a pluggable flexibility.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15721#discussion_r1326082796


More information about the client-libs-dev mailing list