Skip to content

Commit 9a94884

Browse files
author
Alisen Chung
committed
8341055: Open some TextArea awt tests 2
Reviewed-by: prr, abhiscxk
1 parent 7e98f59 commit 9a94884

File tree

4 files changed

+310
-0
lines changed

4 files changed

+310
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.awt.Frame;
25+
import java.awt.TextArea;
26+
27+
/*
28+
* @test
29+
* @bug 4648702
30+
* @summary TextArea horizontal scrollbar behavior is incorrect
31+
* @library /java/awt/regtesthelpers
32+
* @build PassFailJFrame
33+
* @run main/manual TextAreaHScrollbarTest
34+
*/
35+
36+
public class TextAreaHScrollbarTest {
37+
private static final String INSTRUCTIONS = """
38+
Please look at the frame.
39+
If the vertical and horizontal scrollbars are visible
40+
the test passed else failed.
41+
""";
42+
43+
public static void main(String[] args) throws Exception {
44+
PassFailJFrame.builder()
45+
.title("TextAreaHScrollbarTest")
46+
.instructions(INSTRUCTIONS)
47+
.columns(40)
48+
.testUI(TextAreaHScrollbarTest::createGUI)
49+
.build()
50+
.awaitAndCheck();
51+
}
52+
53+
public static Frame createGUI() {
54+
Frame test = new Frame();
55+
test.add(new TextArea("TextAreaHScrollbarTest", 5, 60,
56+
TextArea.SCROLLBARS_BOTH));
57+
test.setSize(200, 100);
58+
return test;
59+
}
60+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.awt.Frame;
25+
import java.awt.TextArea;
26+
27+
/*
28+
* @test
29+
* @bug 4776535
30+
* @summary Regression: line should not wrap around into multi lines in TextArea.
31+
* @library /java/awt/regtesthelpers
32+
* @build PassFailJFrame
33+
* @run main/manual TextAreaLineScrollWrapTest
34+
*/
35+
36+
public class TextAreaLineScrollWrapTest {
37+
private static final String INSTRUCTIONS = """
38+
You should see a frame "TextAreaLineScrollWrapTest" with
39+
a TextArea that contains a very long line.
40+
If the line is wrapped the test is failed.
41+
42+
Insert a lot of text lines and move a caret to the last one.
43+
If a caret hides and a content of the TextArea
44+
does not scroll the test is failed
45+
else the test is passed.
46+
""";
47+
48+
public static void main(String[] args) throws Exception {
49+
PassFailJFrame.builder()
50+
.title("TextAreaLineScrollWrapTest")
51+
.instructions(INSTRUCTIONS)
52+
.columns(40)
53+
.testUI(TextAreaLineScrollWrapTest::createGUI)
54+
.build()
55+
.awaitAndCheck();
56+
}
57+
58+
public static Frame createGUI() {
59+
Frame f = new Frame("TextAreaLineScrollWrapTest");
60+
f.add(new TextArea("long long long long long long long line...........",
61+
3, 4));
62+
f.setSize(100, 100);
63+
return f;
64+
}
65+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.awt.Frame;
25+
import java.awt.GridLayout;
26+
import java.awt.Label;
27+
import java.awt.TextArea;
28+
29+
/*
30+
* @test
31+
* @bug 4158997
32+
* @key headful
33+
* @summary Make sure that the TextArea has both horizontal and
34+
* vertical scrollbars when bad scrollbar arguments are passed
35+
* into the constructor.
36+
* @library /java/awt/regtesthelpers
37+
* @build PassFailJFrame
38+
* @run main/manual TextAreaScrollbarTest
39+
*/
40+
41+
public class TextAreaScrollbarTest {
42+
private static final String INSTRUCTIONS = """
43+
Check to see that each TextArea has the specified
44+
number and placement of scrollbars, i.e., both scrollbars,
45+
horizontal only, vertical only, or no scrollbars at all.
46+
""";
47+
48+
public static void main(String[] args) throws Exception {
49+
PassFailJFrame.builder()
50+
.title("TextAreaScrollbarTest")
51+
.instructions(INSTRUCTIONS)
52+
.columns(35)
53+
.testUI(TestFrame::new)
54+
.build()
55+
.awaitAndCheck();
56+
}
57+
}
58+
59+
class TestFrame extends Frame {
60+
private String both = "Both Scrollbars Both Scrollbars Both Scrollbars\n";
61+
private String horiz = "Horizontal Scrollbar Only Horizontal Scrollbar Only\n";
62+
private String vert = "Vertical Scrollbar Only Vertical Scrollbar Only\n";
63+
private String none = "No Scrollbars No Scrollbars No Scrollbars No Scrollbars\n";
64+
65+
public TestFrame() {
66+
super("Test frame");
67+
68+
// sets a GridLayout w/ 2 columns and an unspecified # of rows
69+
setLayout(new GridLayout(0, 2, 15, 5));
70+
71+
TextArea t1 = new TextArea(both + both + both + both + both + both, 3, 8, 0);
72+
add(new Label("TA should have both scrollbars: arg = 0"));
73+
add(t1);
74+
75+
TextArea t2 = new TextArea(both + both + both + both + both + both, 3, 8, -1);
76+
add(new Label("TA should have both scrollbars: arg = -1"));
77+
add(t2);
78+
79+
TextArea t3 = new TextArea(both + both + both + both + both + both, 3, 8, 4);
80+
add(new Label("TA should have both scrollbars: arg = 4"));
81+
add(t3);
82+
83+
TextArea t4 = new TextArea(horiz + horiz + horiz + horiz + horiz + horiz, 3, 8, 2);
84+
add(new Label("TA should have horizontal scrollbar: arg = 2"));
85+
add(t4);
86+
87+
TextArea t5 = new TextArea(vert + vert + vert + vert + vert + vert, 3, 8, 1);
88+
add(new Label("TA should have vertical scrollbar: arg = 1"));
89+
add(t5);
90+
91+
TextArea t6 = new TextArea(none + none + none + none + none + none, 3, 8, 3);
92+
add(new Label("TA should have no scrollbars: arg = 3"));
93+
add(t6);
94+
95+
TextArea t7 = new TextArea();
96+
t7.setText(both + both + both + both + both + both);
97+
add(new Label("Both scrollbars: TextArea()"));
98+
add(t7);
99+
100+
TextArea t8 = new TextArea(both + both + both + both + both + both);
101+
add(new Label("Both scrollbars: TextArea(String text)"));
102+
add(t8);
103+
104+
TextArea t9 = new TextArea(3, 8);
105+
t9.setText(both + both + both + both + both + both);
106+
add(new Label("Both scrollbars: TextArea(int rows, int columns)"));
107+
add(t9);
108+
109+
TextArea t10 = new TextArea(both + both + both + both + both + both, 3, 8);
110+
add(new Label("Both scrollbars: TextArea(text, rows, columns)"));
111+
add(t10);
112+
113+
setSize(600, 600);
114+
}
115+
}
116+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.awt.BorderLayout;
25+
import java.awt.Frame;
26+
import java.awt.Panel;
27+
import java.awt.TextArea;
28+
29+
/*
30+
* @test
31+
* @bug 4127272
32+
* @summary TextArea displays head of text when scrolling horizontal bar.
33+
* @library /java/awt/regtesthelpers
34+
* @build PassFailJFrame
35+
* @run main/manual TextScrollTest
36+
*/
37+
38+
public class TextScrollTest extends Frame {
39+
private static final String INSTRUCTIONS = """
40+
1. A TextArea whose content starts with the text ",
41+
'Scroll till the' will appear on the applet ",
42+
2. Use the Horizontal thumb button of the TextArea to view the entire",
43+
content of the TextArea",
44+
3. While scrolling, if the text 'Scroll till the' appears repeatedly, Click Fail ",
45+
else Click Pass"
46+
""";
47+
48+
public static void main(String[] args) throws Exception {
49+
PassFailJFrame.builder()
50+
.title("TextScrollTest")
51+
.instructions(INSTRUCTIONS)
52+
.columns(40)
53+
.testUI(TextScrollTest::new)
54+
.build()
55+
.awaitAndCheck();
56+
}
57+
58+
public TextScrollTest() {
59+
this.setLayout(new BorderLayout());
60+
61+
Panel p = new Panel();
62+
TextArea ta = new TextArea("Scroll till the right end of the " +
63+
"TextArea is reached. Action Done?\n", 10, 20);
64+
65+
p.add(ta);
66+
add("Center", p);
67+
setSize(200, 200);
68+
}
69+
}

0 commit comments

Comments
 (0)