-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8340077: Open source few Checkbox tests - Set2
Reviewed-by: prr, azvegint, psadhukhan
- Loading branch information
Harshitha Onkar
committed
Oct 3, 2024
1 parent
b6e72ff
commit 6f459af
Showing
5 changed files
with
404 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2001, 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.Checkbox; | ||
import java.awt.FlowLayout; | ||
import java.awt.Frame; | ||
import java.awt.Panel; | ||
|
||
/* | ||
* @test | ||
* @bug 4410522 | ||
* @requires (os.family == "windows") | ||
* @summary The box size of the Checkbox control should be the same as | ||
* in Windows native applications. | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual CheckboxBoxSizeTest | ||
*/ | ||
|
||
public class CheckboxBoxSizeTest { | ||
private static final String INSTRUCTIONS = """ | ||
This test must be run at UI Scale of 100% AND | ||
150% or greater. | ||
Compare the size of box to any of native apps on Windows | ||
(Eg. Font Dialog Settings on Word). | ||
They should be the same. | ||
If the sizes are same Press PASS, else Press FAIL. | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
PassFailJFrame.builder() | ||
.title("CheckboxBoxSizeTest Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 2) | ||
.columns(35) | ||
.testUI(CheckboxBoxSizeTest::createTestUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
private static Frame createTestUI() { | ||
Frame frame = new Frame("CheckboxBoxSizeTest"); | ||
Panel panel = new Panel(new FlowLayout()); | ||
Checkbox checkbox = new Checkbox("Compare the box size"); | ||
panel.add(checkbox); | ||
frame.add(panel); | ||
frame.pack(); | ||
return frame; | ||
} | ||
} |
168 changes: 168 additions & 0 deletions
168
test/jdk/java/awt/Checkbox/CheckboxIndicatorSizeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/* | ||
* Copyright (c) 1999, 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.Checkbox; | ||
import java.awt.CheckboxGroup; | ||
import java.awt.Color; | ||
import java.awt.Font; | ||
import java.awt.Frame; | ||
import java.awt.GridLayout; | ||
import java.awt.Label; | ||
import java.awt.Menu; | ||
import java.awt.MenuBar; | ||
import java.awt.MenuItem; | ||
import java.awt.Panel; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
|
||
/* | ||
* @test | ||
* @bug 4090493 | ||
* @summary Test for Checkbox indicator size | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual CheckboxIndicatorSizeTest | ||
*/ | ||
|
||
public class CheckboxIndicatorSizeTest implements ActionListener { | ||
private static final String INSTRUCTIONS = """ | ||
Indicator size of Checkbox depends | ||
on the platform font used to render the label. | ||
In the frame you can see a group of checkboxes | ||
and radio buttons. | ||
Verify that all checkboxes and radio buttons have | ||
indicators of the same size and proportional to | ||
the uiScale and/or font-size. | ||
Use menu to change the font size and the indicators | ||
should scale proportionally. | ||
If there is a bug, the checkbox/radiobutton with | ||
dingbats label will have a smaller indicator. | ||
Press PASS if the above conditions are true else Press FAIL. | ||
"""; | ||
private static Frame frame; | ||
private static Panel testPanel; | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
CheckboxIndicatorSizeTest obj = new CheckboxIndicatorSizeTest(); | ||
PassFailJFrame.builder() | ||
.title("Test Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 3) | ||
.columns(60) | ||
.testUI(obj::createAndShowUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
private Frame createAndShowUI() { | ||
frame = new Frame("CheckboxIndicatorSizeTest"); | ||
|
||
testPanel = new Panel(new GridLayout(0, 1)); | ||
testPanel.setFont(new Font("Dialog", Font.PLAIN, 12)); | ||
frame.add(testPanel); | ||
|
||
MenuBar menuBar = new MenuBar(); | ||
Menu fontSizeMenu = new Menu("FontSize"); | ||
|
||
MenuItem size10 = new MenuItem("10"); | ||
size10.addActionListener(this); | ||
fontSizeMenu.add(size10); | ||
|
||
MenuItem size12 = new MenuItem("12"); | ||
size12.addActionListener(this); | ||
fontSizeMenu.add(size12); | ||
|
||
MenuItem size14 = new MenuItem("14"); | ||
size14.addActionListener(this); | ||
fontSizeMenu.add(size14); | ||
|
||
MenuItem size18 = new MenuItem("18"); | ||
size18.addActionListener(this); | ||
fontSizeMenu.add(size18); | ||
|
||
MenuItem size24 = new MenuItem("24"); | ||
size24.addActionListener(this); | ||
fontSizeMenu.add(size24); | ||
|
||
MenuItem size36 = new MenuItem("36"); | ||
size36.addActionListener(this); | ||
fontSizeMenu.add(size36); | ||
|
||
menuBar.add(fontSizeMenu); | ||
frame.setMenuBar(menuBar); | ||
|
||
Checkbox cbEnglishOnly | ||
= new Checkbox("Toggle", true); | ||
Checkbox cbDingbatsOnly | ||
= new Checkbox("\u274a\u274b\u274c\u274d", true); | ||
Checkbox cbEnglishDingbats | ||
= new Checkbox("Toggle \u274a\u274d", true); | ||
Checkbox cbDingbatsEnglish | ||
= new Checkbox("\u274a\u274d toggle", true); | ||
|
||
CheckboxGroup radioGroup = new CheckboxGroup(); | ||
Checkbox rbEnglishOnly | ||
= new Checkbox("Radio", true, radioGroup); | ||
Checkbox rbDingbatsOnly | ||
= new Checkbox("\u274a\u274b\u274c\u274d", false, radioGroup); | ||
Checkbox rbEnglishDingbats | ||
= new Checkbox("Radio \u274a\u274d", false, radioGroup); | ||
Checkbox rbDingbatsEnglish | ||
= new Checkbox("\u274a\u274d radio", false, radioGroup); | ||
|
||
Label cbLabel = new Label("Checkboxes"); | ||
cbLabel.setBackground(Color.YELLOW); | ||
testPanel.add(cbLabel); | ||
testPanel.add(cbEnglishOnly); | ||
testPanel.add(cbDingbatsOnly); | ||
testPanel.add(cbEnglishDingbats); | ||
testPanel.add(cbDingbatsEnglish); | ||
|
||
Label rbLabel = new Label("Radio buttons"); | ||
rbLabel.setBackground(Color.YELLOW); | ||
testPanel.add(rbLabel); | ||
testPanel.add(rbEnglishOnly); | ||
testPanel.add(rbDingbatsOnly); | ||
testPanel.add(rbEnglishDingbats); | ||
testPanel.add(rbDingbatsEnglish); | ||
|
||
frame.pack(); | ||
return frame; | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
String sizeStr = e.getActionCommand(); | ||
int size = Integer.parseInt(sizeStr); | ||
Font oldFont = testPanel.getFont(); | ||
Font newFont = new Font(oldFont.getName(), oldFont.getStyle(), size); | ||
testPanel.setFont(newFont); | ||
frame.pack(); | ||
frame.setVisible(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright (c) 2012, 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.Checkbox; | ||
import java.awt.CheckboxGroup; | ||
import java.awt.Color; | ||
import java.awt.Font; | ||
import java.awt.Frame; | ||
import java.awt.Panel; | ||
|
||
/* | ||
* @test | ||
* @bug 4383735 | ||
* @summary Checkbox buttons are too small with java 1.3 and 1.4 | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual CheckboxNullLabelTest | ||
*/ | ||
|
||
public class CheckboxNullLabelTest { | ||
private static final String INSTRUCTIONS = """ | ||
Please look at the frame titled 'CheckboxNullLabelTest'. | ||
Check if all the check boxes in each group | ||
(of 3 check boxes) have the same size. | ||
If the size of labeled check box is NOT the same as | ||
the size of non-labeled Press FAIL otherwise Press PASS. | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
PassFailJFrame.builder() | ||
.title("Test Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 1) | ||
.columns(35) | ||
.testUI(CheckboxNullLabelTest::createAndShowUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
private static Frame createAndShowUI() { | ||
Frame f = new Frame("CheckboxNullLabelTest"); | ||
f.setLayout(new BorderLayout()); | ||
f.add(new CheckboxTest(Color.gray, new Font(null, 0, 12)), "North"); | ||
f.add(new CheckboxTest(Color.green, new Font(null, 0, 18)), "South"); | ||
f.add(new CheckboxTest(Color.red, new Font(null, 0, 24)), "East"); | ||
f.add(new CheckboxTest(Color.white, new Font(null, 0, 30)), "West"); | ||
f.add(new CheckboxTest(f.getBackground(), new Font(null, 0, 36)), "Center"); | ||
f.setSize(600, 450); | ||
return f; | ||
} | ||
|
||
private static class CheckboxTest extends Panel { | ||
Checkbox cb1, cb2, cb3; | ||
|
||
CheckboxTest(Color background, Font font) { | ||
setBackground(background); | ||
CheckboxGroup cbg = new CheckboxGroup(); | ||
|
||
cb1 = new Checkbox(null, cbg, true); | ||
cb1.setFont(font); | ||
|
||
cb2 = new Checkbox("", cbg, true); | ||
cb2.setFont(font); | ||
|
||
cb3 = new Checkbox("Label", cbg, false); | ||
cb3.setFont(font); | ||
|
||
add(cb1); | ||
add(cb2); | ||
add(cb3); | ||
} | ||
} | ||
} |
Oops, something went wrong.
6f459af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues