From 236c71cad9fa269518456c11edcfb353bbfc084d Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Thu, 17 Oct 2024 15:10:38 +0000 Subject: [PATCH] 8341376: Open some TextArea awt tests 4 Reviewed-by: prr, abhiscxk --- .../TextArea/ScrollBarArrowScrollTest.java | 65 ++++++++++++++++++ .../java/awt/TextArea/WordWrappingTest.java | 66 +++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 test/jdk/java/awt/TextArea/ScrollBarArrowScrollTest.java create mode 100644 test/jdk/java/awt/TextArea/WordWrappingTest.java diff --git a/test/jdk/java/awt/TextArea/ScrollBarArrowScrollTest.java b/test/jdk/java/awt/TextArea/ScrollBarArrowScrollTest.java new file mode 100644 index 00000000000..cf54bd57585 --- /dev/null +++ b/test/jdk/java/awt/TextArea/ScrollBarArrowScrollTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.TextArea; + +/* + * @test + * @bug 6175401 + * @summary Keeping the left arrow pressedon horiz scrollbar + * does not scroll the text in TextArea, XToolkit + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollBarArrowScrollTest +*/ + + +public class ScrollBarArrowScrollTest extends Frame { + private static final String INSTRUCTIONS = """ + 1) Make sure, that the TextArea component has focus. + 2) Press 'END' key in order to keep cursor at the end + of the text of the TextArea component. + 3) Click on the left arrow on the horizontal scrollbar + of the TextArea component and keep it pressed. + 4) If the text just scrolls once and stops, the test failed. + Otherwise, the test passed. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ScrollBarArrowScrollTest") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(ScrollBarArrowScrollTest::new) + .build() + .awaitAndCheck(); + } + + public ScrollBarArrowScrollTest() { + TextArea textarea = new TextArea("Very very very long string !!!! ", 10, 3); + add(textarea); + pack(); + + } +} diff --git a/test/jdk/java/awt/TextArea/WordWrappingTest.java b/test/jdk/java/awt/TextArea/WordWrappingTest.java new file mode 100644 index 00000000000..7309bc51008 --- /dev/null +++ b/test/jdk/java/awt/TextArea/WordWrappingTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.TextArea; + +/* + * @test + * @bug 4992455 + * @summary REGRESSION: TextArea does not wrap text in JDK 1.5 as JDK 1.4.x + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WordWrappingTest +*/ + +public class WordWrappingTest { + private static final String INSTRUCTIONS = """ + Please look at the frame 'WordWrappingTest' + It contains two TextAreas that have text 'This text should be wrapped.' + One of them has a vertical scrollbar only. Another has no + scrollbars at all. + If their text is not wrapped at word boundaries and you partially see + mentioned text, the test failed. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("WordWrappingTest") + .instructions(INSTRUCTIONS) + .testUI(WordWrappingTest::createGUI) + .build() + .awaitAndCheck(); + } + + public static Frame createGUI() { + Frame f = new Frame("WordWrappingTest"); + f.setLayout(new FlowLayout()); + f.add(new TextArea("This text should be wrapped.", 5, 10, + TextArea.SCROLLBARS_VERTICAL_ONLY)); + f.add(new TextArea("This text should be wrapped.", 5, 10, + TextArea.SCROLLBARS_NONE)); + f.pack(); + return f; + } +}