RFR: 8339906: Open source several AWT focus tests - series 4 [v4]

Abhishek Kumar abhiscxk at openjdk.org
Fri Sep 20 04:16:39 UTC 2024


On Fri, 20 Sep 2024 03:15:06 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Opensource few Focus tests
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   typo

test/jdk/java/awt/Focus/AltTabEventsTest.java line 61:

> 59:            2. Press Alt-tab.
> 60:            In the messqge dialog area you should see that
> 61:            WINDOW_DEACTIVATED,WINDOW_LOST_FOCUS event were generated.

Suggestion:

           WINDOW_DEACTIVATED, WINDOW_LOST_FOCUS event were generated.

test/jdk/java/awt/Focus/AltTabEventsTest.java line 80:

> 78:                 .rows((int) INSTRUCTIONS.lines().count() + 5)
> 79:                 .columns(35)
> 80:                 .testUI(AltTabEventsTest::createTestUI)

can be changed to `new Test();` and thus leading to remove the `createTestUI()` method.

test/jdk/java/awt/Focus/AltTabEventsTest.java line 104:

> 102:         WindowAdapter wa = new WindowAdapter() {
> 103:                 public void windowActivated(WindowEvent e) {
> 104:                     println(e.toString());

can be replaced with `PassFailJFrame.log` everywhere. Anyways there is a repetition of `println`.
Suggestion:

                    PassFailJFrame.log(e.toString());

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 54:

> 52: 
> 53:     public ComponentLostFocusTest() {
> 54:         try{

Suggestion:

        try {

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 56:

> 54:         try{
> 55:             r = new Robot();
> 56:         } catch(Exception e){

Suggestion:

        } catch (Exception e) {

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 69:

> 67:         });
> 68: 
> 69:         frame.setLayout (new FlowLayout ());

Suggestion:

        frame.setLayout (new FlowLayout());

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 79:

> 77:     public void doTest() {
> 78:         // Do requesting focus to the modal dialog in order to after that
> 79:         // to do requesting focus to the frame

Doesn't sound correct, can it be rephrased?

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 103:

> 101:         tf.addFocusListener(new FocusAdapter() {
> 102:             public void focusGained(FocusEvent e) {
> 103:                 System.out.println("TextField gained focus: "+e);

Suggestion:

                System.out.println("TextField gained focus: " + e);

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 111:

> 109: 
> 110:         System.out.println("Focused window: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow());
> 111:         System.out.println("Focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());

please limit it to 80 cols.

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 118:

> 116:     }
> 117: 
> 118:     private void doRequestFocusToTextField(){

Suggestion:

    private void doRequestFocusToTextField() {

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 121:

> 119:         // do activation using press title
> 120:         Point loc = frame.getLocationOnScreen();
> 121:         r.mouseMove(loc.x + frame.getWidth()/2, loc.y + frame.getInsets().top/2);

Suggestion:

        r.mouseMove(loc.x + frame.getWidth() / 2, loc.y + frame.getInsets().top / 2);

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 121:

> 119:         // do activation using press title
> 120:         Point loc = frame.getLocationOnScreen();
> 121:         r.mouseMove(loc.x + frame.getWidth()/2, loc.y + frame.getInsets().top/2);

Should it be accessed on EDT?

test/jdk/java/awt/Focus/ComponentLostFocusTest.java line 131:

> 129:     }
> 130: 
> 131:     public static final void main(String args[]){

Suggestion:

    public static final void main(String args[]) {

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767916449
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767916965
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767917411
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767919827
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767918226
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767918406
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767919134
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767919295
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767920580
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767920637
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767920840
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767921196
PR Review Comment: https://git.openjdk.org/jdk/pull/21051#discussion_r1767920918


More information about the client-libs-dev mailing list