8340336: Open some checkbox awt tests
Reviewed-by: prr, honkar
This commit is contained in:
parent
7a64fbbb92
commit
1ea1f33f66
84
test/jdk/java/awt/Checkbox/AppearanceIfLargeFont.java
Normal file
84
test/jdk/java/awt/Checkbox/AppearanceIfLargeFont.java
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 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.Button;
|
||||
import java.awt.CheckboxMenuItem;
|
||||
import java.awt.Frame;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6401956
|
||||
* @summary The right mark of the CheckboxMenu item is broken
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual AppearanceIfLargeFont
|
||||
*/
|
||||
|
||||
public class AppearanceIfLargeFont extends Frame {
|
||||
private static final String INSTRUCTIONS = """
|
||||
1) Make sure that font-size is large.
|
||||
You could change this using 'Appearance' dialog.
|
||||
2) Press button 'Press'
|
||||
You will see a menu item with check-mark.
|
||||
3) If check-mark is correctly painted then the test passed.
|
||||
Otherwise, test failed.
|
||||
""";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
PassFailJFrame.builder()
|
||||
.title("AppearanceIfLargeFont")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(35)
|
||||
.testUI(AppearanceIfLargeFont::new)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public AppearanceIfLargeFont() {
|
||||
createComponents();
|
||||
|
||||
setSize(200, 200);
|
||||
validate();
|
||||
}
|
||||
|
||||
void createComponents() {
|
||||
final Button press = new Button("Press");
|
||||
final PopupMenu popup = new PopupMenu();
|
||||
press.add(popup);
|
||||
add(press);
|
||||
|
||||
CheckboxMenuItem item = new CheckboxMenuItem("CheckboxMenuItem", true);
|
||||
popup.add(item);
|
||||
|
||||
press.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
popup.show(press, press.getSize().width, 0);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
120
test/jdk/java/awt/Checkbox/CheckboxMenuItemEventsTest.java
Normal file
120
test/jdk/java/awt/Checkbox/CheckboxMenuItemEventsTest.java
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.CheckboxMenuItem;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Panel;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4814163 5005195
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @summary Tests events fired by CheckboxMenuItem
|
||||
* @run main/manual CheckboxMenuItemEventsTest
|
||||
*/
|
||||
|
||||
public class CheckboxMenuItemEventsTest extends Frame implements ActionListener {
|
||||
Button trigger;
|
||||
PopupMenu popup;
|
||||
TextArea ta;
|
||||
|
||||
class Listener implements ItemListener, ActionListener {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
ta.append("CORRECT: ItemEvent fired\n");
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ta.append("ERROR: ActionEvent fired\n");
|
||||
}
|
||||
}
|
||||
|
||||
Listener listener = new Listener();
|
||||
|
||||
private static final String INSTRUCTIONS = """
|
||||
Press button to invoke popup menu
|
||||
When you press checkbox menu item
|
||||
Item state should toggle (on/off).
|
||||
ItemEvent should be displayed in log below.
|
||||
And ActionEvent should not be displayed
|
||||
Press PASS if ItemEvents are generated
|
||||
and ActionEvents are not, FAIL Otherwise.
|
||||
""";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
PassFailJFrame.builder()
|
||||
.title("CheckboxMenuItemEventsTest")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(35)
|
||||
.testUI(CheckboxMenuItemEventsTest::new)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public CheckboxMenuItemEventsTest() {
|
||||
CheckboxMenuItem i1 = new CheckboxMenuItem("CheckBoxMenuItem 1");
|
||||
CheckboxMenuItem i2 = new CheckboxMenuItem("CheckBoxMenuItem 2");
|
||||
Panel p1 = new Panel();
|
||||
Panel p2 = new Panel();
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
ta = new TextArea();
|
||||
p2.add(ta);
|
||||
|
||||
trigger = new Button("menu");
|
||||
trigger.addActionListener(this);
|
||||
|
||||
popup = new PopupMenu();
|
||||
|
||||
i1.addItemListener(listener);
|
||||
i1.addActionListener(listener);
|
||||
popup.add(i1);
|
||||
i2.addItemListener(listener);
|
||||
i2.addActionListener(listener);
|
||||
popup.add(i2);
|
||||
|
||||
trigger.add(popup);
|
||||
|
||||
p1.add(trigger);
|
||||
|
||||
add(p1, BorderLayout.NORTH);
|
||||
add(p2, BorderLayout.SOUTH);
|
||||
|
||||
pack();
|
||||
validate();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == (Object) trigger) {
|
||||
popup.show(trigger, trigger.getSize().width, 0);
|
||||
}
|
||||
}
|
||||
}
|
78
test/jdk/java/awt/Container/ValidateTest.java
Normal file
78
test/jdk/java/awt/Container/ValidateTest.java
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Panel;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4136190
|
||||
* @requires (os.family == "windows")
|
||||
* @summary Recursive validation calls would cause major USER resource leakage
|
||||
* @key headful
|
||||
* @run main/timeout=30 ValidateTest
|
||||
*/
|
||||
|
||||
public class ValidateTest {
|
||||
static Frame frame;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
try {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
createGUI();
|
||||
});
|
||||
} finally {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void createGUI() {
|
||||
frame = new Frame("Test for 4136190 : JVM and win95 resource leakage issues");
|
||||
frame.setLayout(new GridLayout(1, 1));
|
||||
MyPanel panel = new MyPanel();
|
||||
frame.add(panel);
|
||||
frame.invalidate();
|
||||
frame.validate();
|
||||
frame.setSize(500, 400);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
static class MyPanel extends Panel {
|
||||
int recurseCounter = 0;
|
||||
|
||||
public void validate() {
|
||||
recurseCounter++;
|
||||
if (recurseCounter >= 100) {
|
||||
return;
|
||||
}
|
||||
getParent().validate();
|
||||
super.validate();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user