Skip to content

Commit 7576064

Browse files
author
Damon Nguyen
committed
8359061: Update and ProblemList manual test java/awt/Cursor/CursorDragTest/ListDragCursor.java
Reviewed-by: honkar, aivanov
1 parent 8df6b2c commit 7576064

File tree

2 files changed

+82
-19
lines changed

2 files changed

+82
-19
lines changed

test/jdk/ProblemList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ java/awt/Checkbox/CheckboxNullLabelTest.java 8340870 windows-all
832832
java/awt/dnd/WinMoveFileToShellTest.java 8341665 windows-all
833833
java/awt/Menu/MenuVisibilityTest.java 8161110 macosx-all
834834
java/awt/Modal/NativeDialogToFrontBackTest.java 7188049 windows-all,linux-all
835+
java/awt/Cursor/CursorDragTest/ListDragCursor.java 7177297 macosx-all
835836

836837
############################################################################
837838

test/jdk/java/awt/Cursor/CursorDragTest/ListDragCursor.java

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,42 +25,60 @@
2525
* @test
2626
* @bug 4313052
2727
* @summary Test cursor changes after mouse dragging ends
28-
* @library /java/awt/regtesthelpers
29-
* @build PassFailJFrame
3028
* @run main/manual ListDragCursor
3129
*/
3230

31+
import java.awt.BorderLayout;
32+
import java.awt.Button;
3333
import java.awt.Cursor;
34+
import java.awt.EventQueue;
3435
import java.awt.Frame;
3536
import java.awt.List;
3637
import java.awt.Panel;
3738
import java.awt.TextArea;
39+
import java.util.concurrent.CountDownLatch;
40+
import java.util.concurrent.TimeUnit;
3841

3942
public class ListDragCursor {
40-
public static void main(String[] args) throws Exception {
41-
String INSTRUCTIONS = """
43+
private static final String INSTRUCTIONS = """
4244
1. Move mouse to the TextArea.
4345
2. Press the left mouse button.
4446
3. Drag mouse to the list.
4547
4. Release the left mouse button.
4648
47-
If the mouse cursor starts as a Text Line Cursor and changes
48-
to a regular Pointer Cursor, then Hand Cursor when hovering
49-
the list, pass the test. This test fails if the cursor does
50-
not update at all when pointing over the different components.
49+
The mouse cursor should appear as an I-beam cursor
50+
and should stay the same while dragging across the
51+
components. Once you reach the list, release the
52+
left mouse button. As soon as you release the left
53+
mouse button, the cursor should change to a Hand
54+
cursor. If true, this test passes.
55+
56+
The test fails if the cursor updates while dragging
57+
over the components before releasing the left
58+
mouse button.
5159
""";
5260

53-
PassFailJFrame.builder()
54-
.title("Test Instructions")
55-
.instructions(INSTRUCTIONS)
56-
.rows((int) INSTRUCTIONS.lines().count() + 2)
57-
.columns(35)
58-
.testUI(ListDragCursor::createUI)
59-
.build()
60-
.awaitAndCheck();
61+
private static Frame testFrame;
62+
private static Frame instructionsFrame;
63+
64+
private static final CountDownLatch countDownLatch = new CountDownLatch(1);
65+
66+
public static void main(String[] args) throws Exception {
67+
try {
68+
EventQueue.invokeAndWait(() -> {
69+
instructionsFrame = createInstructionsFrame();
70+
testFrame = createTestFrame();
71+
});
72+
if (!countDownLatch.await(5, TimeUnit.MINUTES)) {
73+
throw new RuntimeException("Test timeout : No action was"
74+
+ " taken on the test.");
75+
}
76+
} finally {
77+
EventQueue.invokeAndWait(ListDragCursor::disposeFrames);
78+
}
6179
}
6280

63-
public static Frame createUI() {
81+
static Frame createTestFrame() {
6482
Frame frame = new Frame("Cursor change after drag");
6583
Panel panel = new Panel();
6684

@@ -78,7 +96,51 @@ public static Frame createUI() {
7896
panel.add(list);
7997

8098
frame.add(panel);
81-
frame.setBounds(300, 100, 300, 150);
99+
frame.setSize(300, 150);
100+
frame.setLocation(instructionsFrame.getX()
101+
+ instructionsFrame.getWidth(),
102+
instructionsFrame.getY());
103+
frame.setVisible(true);
104+
return frame;
105+
}
106+
107+
static Frame createInstructionsFrame() {
108+
Frame frame = new Frame("Test Instructions");
109+
Panel mainPanel = new Panel(new BorderLayout());
110+
TextArea textArea = new TextArea(INSTRUCTIONS,
111+
15, 35, TextArea.SCROLLBARS_NONE);
112+
113+
Panel btnPanel = new Panel();
114+
Button passBtn = new Button("Pass");
115+
Button failBtn = new Button("Fail");
116+
btnPanel.add(passBtn);
117+
btnPanel.add(failBtn);
118+
119+
passBtn.addActionListener(e -> {
120+
countDownLatch.countDown();
121+
System.out.println("Test passed.");
122+
});
123+
failBtn.addActionListener(e -> {
124+
countDownLatch.countDown();
125+
throw new RuntimeException("Test Failed.");
126+
});
127+
128+
mainPanel.add(textArea, BorderLayout.CENTER);
129+
mainPanel.add(btnPanel, BorderLayout.SOUTH);
130+
131+
frame.add(mainPanel);
132+
frame.pack();
133+
frame.setLocationRelativeTo(null);
134+
frame.setVisible(true);
82135
return frame;
83136
}
137+
138+
static void disposeFrames() {
139+
if (testFrame != null) {
140+
testFrame.dispose();
141+
}
142+
if (instructionsFrame != null) {
143+
instructionsFrame.dispose();
144+
}
145+
}
84146
}

0 commit comments

Comments
 (0)