Skip to content

Commit 8194427

Browse files
author
Andrew Lu
committed
8328642: Convert applet test MouseDraggedOutCauseScrollingTest.html to main
Backport-of: ab183e437c18b445e9c022a4d74de818d4ccecbe
1 parent b79cdcd commit 8194427

File tree

2 files changed

+75
-238
lines changed

2 files changed

+75
-238
lines changed

test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.html

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 75 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2024, 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
@@ -22,29 +22,29 @@
2222
*/
2323

2424
/*
25-
test
25+
@test
2626
@bug 6243382 8006070
2727
@summary Dragging of mouse outside of a List and Choice area don't work properly on XAWT
28-
@author [email protected] area=awt.list
29-
@run applet/manual=yesno MouseDraggedOutCauseScrollingTest.html
28+
@requires (os.family == "linux")
29+
@library /java/awt/regtesthelpers
30+
@run main/manual MouseDraggedOutCauseScrollingTest
3031
*/
3132

32-
import java.applet.Applet;
33-
import java.awt.*;
33+
import java.awt.Choice;
34+
import java.awt.Frame;
35+
import java.awt.GridLayout;
36+
import java.awt.List;
37+
import java.awt.Toolkit;
3438

35-
public class MouseDraggedOutCauseScrollingTest extends Applet
36-
{
37-
Choice choice;
38-
List singleList;
39-
List multipleList;
39+
public class MouseDraggedOutCauseScrollingTest {
4040

41-
public void init()
42-
{
43-
this.setLayout (new GridLayout (1, 3));
41+
static Frame createUI() {
42+
Frame frame = new Frame("MouseDraggedOutCausesScrollingTest");
43+
frame.setLayout(new GridLayout(1, 3));
4444

45-
choice = new Choice();
46-
singleList = new List(3, false);
47-
multipleList = new List(3, true);
45+
Choice choice = new Choice();
46+
List singleList = new List(3, false);
47+
List multipleList = new List(3, true);
4848

4949
choice.add("Choice");
5050
for (int i = 1; i < 100; i++){
@@ -59,188 +59,68 @@ public void init()
5959
for (int i = 1; i < 100; i++)
6060
multipleList.add(""+i);
6161

62-
this.add(choice);
63-
this.add(singleList);
64-
this.add(multipleList);
62+
frame.add(choice);
63+
frame.add(singleList);
64+
frame.add(multipleList);
65+
frame.setSize(400, 100);
66+
return frame;
67+
}
6568

69+
public static void main(String[] args) throws Exception {
6670
String toolkitName = Toolkit.getDefaultToolkit().getClass().getName();
71+
6772
if (!toolkitName.equals("sun.awt.X11.XToolkit")) {
68-
String[] instructions =
69-
{
70-
"This test is not applicable to the current platform. Press PASS"
71-
};
72-
Sysout.createDialogWithInstructions( instructions );
73-
} else {
74-
String[] instructions =
75-
{
76-
"0) Please note, that this is only Motif/XAWT test. At first, make the applet active",
77-
"1.1) Click on the choice",
78-
"1.2) Press the left button of the mouse and keep on any item of the choice, for example 5",
79-
"1.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same",
80-
"1.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling UP of the list and selected item changes on the upper. If not, the test failed",
81-
"1.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling DOWN of the list and selected item changes on the lower. If not, the test failed",
82-
"-----------------------------------",
83-
"2.1) Click on the single list",
84-
"2.2) Press the left button of the mouse and keep on any item of the list, for example 5",
85-
"2.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same",
86-
"2.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling UP of the list and selected item changes on the upper. If not, the test failed",
87-
"2.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling DOWN of the list and selected item changes on the lower. If not, the test failed",
88-
"-----------------------------------",
89-
"3.1) Click on the multiple list",
90-
"3.2) Press the left button of the mouse and keep on any item of the list, for example 5",
91-
"3.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same",
92-
"3.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling of the list NO OCCURED and selected item NO CHANGES on the upper. If not, the test failed",
93-
"3.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling of the list NO OCCURED and selected item NO CHANGES on the lower. If not, the test failed",
94-
"4) Test passed."
95-
};
96-
Sysout.createDialogWithInstructions( instructions );
73+
System.out.println(INAPPLICABLE);
74+
return;
9775
}
9876

99-
}//End init()
100-
101-
public void start ()
102-
{
103-
setSize (400,100);
104-
setVisible(true);
105-
validate();
106-
107-
}// start()
108-
109-
}// class ManualYesNoTest
110-
111-
/****************************************************
112-
Standard Test Machinery
113-
DO NOT modify anything below -- it's a standard
114-
chunk of code whose purpose is to make user
115-
interaction uniform, and thereby make it simpler
116-
to read and understand someone else's test.
117-
****************************************************/
118-
119-
/**
120-
This is part of the standard test machinery.
121-
It creates a dialog (with the instructions), and is the interface
122-
for sending text messages to the user.
123-
To print the instructions, send an array of strings to Sysout.createDialog
124-
WithInstructions method. Put one line of instructions per array entry.
125-
To display a message for the tester to see, simply call Sysout.println
126-
with the string to be displayed.
127-
This mimics System.out.println but works within the test harness as well
128-
as standalone.
129-
*/
130-
131-
class Sysout
132-
{
133-
private static TestDialog dialog;
134-
135-
public static void createDialogWithInstructions( String[] instructions )
136-
{
137-
dialog = new TestDialog( new Frame(), "Instructions" );
138-
dialog.printInstructions( instructions );
139-
dialog.setVisible(true);
140-
println( "Any messages for the tester will display here." );
141-
}
142-
143-
public static void createDialog( )
144-
{
145-
dialog = new TestDialog( new Frame(), "Instructions" );
146-
String[] defInstr = { "Instructions will appear here. ", "" } ;
147-
dialog.printInstructions( defInstr );
148-
dialog.setVisible(true);
149-
println( "Any messages for the tester will display here." );
150-
}
151-
152-
153-
public static void printInstructions( String[] instructions )
154-
{
155-
dialog.printInstructions( instructions );
156-
}
157-
158-
159-
public static void println( String messageIn )
160-
{
161-
dialog.displayMessage( messageIn );
162-
}
163-
164-
}// Sysout class
165-
166-
/**
167-
This is part of the standard test machinery. It provides a place for the
168-
test instructions to be displayed, and a place for interactive messages
169-
to the user to be displayed.
170-
To have the test instructions displayed, see Sysout.
171-
To have a message to the user be displayed, see Sysout.
172-
Do not call anything in this dialog directly.
173-
*/
174-
class TestDialog extends Dialog
175-
{
176-
177-
TextArea instructionsText;
178-
TextArea messageText;
179-
int maxStringLength = 80;
180-
181-
//DO NOT call this directly, go through Sysout
182-
public TestDialog( Frame frame, String name )
183-
{
184-
super( frame, name );
185-
int scrollBoth = TextArea.SCROLLBARS_BOTH;
186-
instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
187-
add( "North", instructionsText );
188-
189-
messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
190-
add("Center", messageText);
191-
192-
pack();
193-
194-
setVisible(true);
195-
}// TestDialog()
196-
197-
//DO NOT call this directly, go through Sysout
198-
public void printInstructions( String[] instructions )
199-
{
200-
//Clear out any current instructions
201-
instructionsText.setText( "" );
202-
203-
//Go down array of instruction strings
204-
205-
String printStr, remainingStr;
206-
for( int i=0; i < instructions.length; i++ )
207-
{
208-
//chop up each into pieces maxSringLength long
209-
remainingStr = instructions[ i ];
210-
while( remainingStr.length() > 0 )
211-
{
212-
//if longer than max then chop off first max chars to print
213-
if( remainingStr.length() >= maxStringLength )
214-
{
215-
//Try to chop on a word boundary
216-
int posOfSpace = remainingStr.
217-
lastIndexOf( ' ', maxStringLength - 1 );
218-
219-
if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
220-
221-
printStr = remainingStr.substring( 0, posOfSpace + 1 );
222-
remainingStr = remainingStr.substring( posOfSpace + 1 );
223-
}
224-
//else just print
225-
else
226-
{
227-
printStr = remainingStr;
228-
remainingStr = "";
229-
}
230-
231-
instructionsText.append( printStr + "\n" );
232-
233-
}// while
234-
235-
}// for
236-
237-
}//printInstructions()
238-
239-
//DO NOT call this directly, go through Sysout
240-
public void displayMessage( String messageIn )
241-
{
242-
messageText.append( messageIn + "\n" );
243-
System.out.println(messageIn);
77+
PassFailJFrame
78+
.builder()
79+
.instructions(INSTRUCTIONS)
80+
.rows(40)
81+
.columns(70)
82+
.testUI(MouseDraggedOutCauseScrollingTest::createUI)
83+
.build()
84+
.awaitAndCheck();
24485
}
24586

246-
}// TestDialog class
87+
static final String INAPPLICABLE = "The test is not applicable to the current platform. Test PASSES.";
88+
static final String INSTRUCTIONS = """
89+
0) Please note, that this is an XAWT/Linux only test. First, make the test window is active.
90+
-----------------------------------
91+
1.1) Click on the Choice.
92+
1.2) Press and hold down the left button of the mouse to select (eg) item 5 in the choice.
93+
1.3) Drag the mouse vertically out of the area of the open list,
94+
keeping the X coordinate of the mouse position about the same.
95+
1.4) Check that when the Y coordinate of the mouse position is higher than the upper bound of the list
96+
then the list continues to scrolls UP and the selected item changes at the top until you reach the topmost item.
97+
If not, the test failed. Press FAIL.
98+
1.5) Check that when the Y coordinate of the mouse position is lower than the lower bound of the list
99+
then the list continues to scroll DOWN and the selected item changes at the bottom until you reach the bottommost item.
100+
If not, the test failed. Press FAIL.
101+
-----------------------------------
102+
2.1) Click on the Single List.
103+
2.2) Press and hold down the left button of the mouse to select (eg) item 5 in the list.
104+
2.3) Drag the mouse vertically out of the area of the open list,
105+
keeping the X coordinate of the mouse position about the same.
106+
2.4) Check that when the Y coordinate of the mouse position is higher than the upper bound of the list
107+
then the list continues to scrolls UP and the selected item changes at the top until you reach the topmost item.
108+
If not, the test failed. Press FAIL.
109+
2.5) Check that when the Y coordinate of the mouse position is lower than the lower bound of the list
110+
then the list continues to scroll DOWN and the selected item changes at the bottom until you reach the bottommost item.
111+
If not, the test failed. Press FAIL.
112+
-----------------------------------
113+
3.1) Click on the Multiple List.
114+
3.2) Press and hold down the left button of the mouse to select (eg) item 5 in the list.
115+
3.3) Drag the mouse vertically out of the area of the open list,
116+
keeping the X coordinate of the mouse position about the same.
117+
3.4) Check that when the Y coordinate of the mouse is higher than the upper bound of the list
118+
that scrolling of the list DOES NOT OCCUR and the selected item IS UNCHANGED at the top.
119+
If not, the test failed. Press FAIL.
120+
3.5) Check that when the Y coordinate of the mouse is below the lower bound of the list
121+
that scrolling of the list DOES NOT OCCUR and the selected item IS UNCHANGED at the bottom.
122+
If not, the test failed. Press FAIL.
123+
-----------------------------------
124+
4) The test has now passed. Press PASS.
125+
""";
126+
}

0 commit comments

Comments
 (0)