-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8340393: Open source closed choice tests #2 #21081
Open
azvegint
wants to merge
3
commits into
openjdk:master
Choose a base branch
from
azvegint:testsprint_2024_09/8340393_batch2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+322
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* 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.BorderLayout; | ||
import java.awt.Choice; | ||
import java.awt.Frame; | ||
import javax.swing.JComponent; | ||
import javax.swing.JPanel; | ||
import javax.swing.SwingUtilities; | ||
|
||
/* | ||
* @test | ||
* @bug 4151949 | ||
* @summary Verifies that Components are reshaped to their preferred size | ||
* when their Container is packed. | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual CheckChoiceTest | ||
*/ | ||
|
||
public class CheckChoiceTest { | ||
|
||
private static JComponent componentToFocus; | ||
|
||
private static final String INSTRUCTIONS = """ | ||
Verify that the widths of the Choice components are all the same | ||
and that none is the minimum possible size. | ||
(The Choices should be at least as wide as the Frame.) | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
PassFailJFrame passFailJFrame = PassFailJFrame.builder() | ||
.title("CheckChoiceTest Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 3) | ||
.columns(45) | ||
.testUI(CheckChoiceTest::createAndShowUI) | ||
.splitUIBottom(CheckChoiceTest::createComponentToFocus) | ||
.build(); | ||
|
||
// focus away from the window with choices | ||
Thread.sleep(300); | ||
SwingUtilities.invokeAndWait(() -> componentToFocus.requestFocus()); | ||
|
||
passFailJFrame.awaitAndCheck(); | ||
} | ||
|
||
private static JComponent createComponentToFocus() { | ||
componentToFocus = new JPanel(); | ||
return componentToFocus; | ||
} | ||
|
||
private static Frame createAndShowUI() { | ||
Frame f = new Frame("Check Choice"); | ||
f.setLayout(new BorderLayout()); | ||
|
||
Choice choice1 = new Choice(); | ||
Choice choice2 = new Choice(); | ||
Choice choice3 = new Choice(); | ||
|
||
f.add(choice1, BorderLayout.NORTH); | ||
f.add(choice3, BorderLayout.CENTER); | ||
f.add(choice2, BorderLayout.SOUTH); | ||
f.pack(); | ||
|
||
choice1.add("I am Choice, yes I am : 0"); | ||
choice2.add("I am the same, yes I am : 0"); | ||
choice3.add("I am the same, yes I am : 0"); | ||
|
||
return f; | ||
} | ||
} |
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,70 @@ | ||
/* | ||
* 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.Choice; | ||
import java.awt.Frame; | ||
import java.awt.FlowLayout; | ||
import java.awt.Window; | ||
|
||
/* | ||
* @test | ||
* @bug 4288285 | ||
* @summary Verifies choice works with many items | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual ChoiceBigTest | ||
*/ | ||
|
||
public class ChoiceBigTest { | ||
private static final String INSTRUCTIONS = """ | ||
Click the Choice button, press Pass if: | ||
|
||
- all looks good. | ||
- if you can select the item 1000 | ||
|
||
Otherwise press Fail. | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
PassFailJFrame.builder() | ||
.title("ChoiceBigTest Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 3) | ||
.columns(45) | ||
.testUI(ChoiceBigTest::createAndShowUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
private static Window createAndShowUI() { | ||
Frame frame = new Frame("Check Choice"); | ||
frame.setLayout(new FlowLayout()); | ||
Choice choice = new Choice(); | ||
frame.setSize(400, 200); | ||
for (int i = 1; i < 1001; ++i) { | ||
choice.add("I am Choice, yes I am : " + i); | ||
} | ||
frame.add(choice); | ||
return frame; | ||
} | ||
} |
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,81 @@ | ||
/* | ||
* 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.Button; | ||
import java.awt.Choice; | ||
import java.awt.Frame; | ||
import java.awt.Panel; | ||
import java.awt.Window; | ||
|
||
/* | ||
* @test | ||
* @bug 4927930 | ||
* @summary Verify that the focus is set to the selected item after calling the java.awt.Choice.select() method | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual ChoiceFocusTest | ||
*/ | ||
|
||
public class ChoiceFocusTest { | ||
|
||
private static final String INSTRUCTIONS = """ | ||
1. Use the mouse to select Item 5 in the Choice list. | ||
2. Click on the Choice. Item5 is now selected and highlighted. This is the correct behavior. | ||
3. Select Item 1 in the Choice list. | ||
4. Click the "choice.select(5)" button. This causes a call to Choice.select(5). Item 5 is now selected. | ||
5. Click on the Choice. | ||
6. If the cursor and focus are on item 5, the test passes. Otherwise, it fails. | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
PassFailJFrame.builder() | ||
.title("ChoiceFocusTest Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 3) | ||
.columns(50) | ||
.testUI(ChoiceFocusTest::createAndShowUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
private static Window createAndShowUI() { | ||
Panel panel = new Panel(); | ||
Choice choice = new Choice(); | ||
Button button = new Button("choice.select(5);"); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
choice.add(String.valueOf(i)); | ||
} | ||
|
||
button.addActionListener(e -> choice.select(5)); | ||
|
||
panel.add(button); | ||
panel.add(choice); | ||
|
||
Frame frame = new Frame("ChoiceFocusTest"); | ||
frame.add(panel); | ||
frame.pack(); | ||
|
||
return frame; | ||
} | ||
} |
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,79 @@ | ||
/* | ||
* Copyright (c) 2011, 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.Choice; | ||
import java.awt.Frame; | ||
import java.awt.Window; | ||
import java.awt.event.ItemEvent; | ||
|
||
/* | ||
* @test | ||
* @bug 6476183 | ||
* @summary Drop down of a Choice changed to enabled state has a disabled like appearance | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual DisabledList | ||
*/ | ||
|
||
public class DisabledList { | ||
|
||
private static final String INSTRUCTIONS = """ | ||
1) Select the checkbox | ||
2) Open Choice | ||
3) Drag mouse over the scrollbar or drag out it the choice | ||
4) If choice's items become disabled press fail, otherwise pass | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
PassFailJFrame.builder() | ||
.title("DisabledList Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 3) | ||
.columns(45) | ||
.testUI(DisabledList::createAndShowUI) | ||
.logArea(4) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
private static Window createAndShowUI() { | ||
Frame frame = new Frame("DisabledList"); | ||
frame.setSize(200, 200); | ||
frame.validate(); | ||
Checkbox checkbox = new Checkbox("checkbox"); | ||
final Choice choice = new Choice(); | ||
choice.setEnabled(false); | ||
for (int i = 0; i < 15; i++) { | ||
choice.addItem("Item" + i); | ||
} | ||
checkbox.addItemListener(event -> { | ||
PassFailJFrame.log("CheckBox.itemStateChanged occurred"); | ||
choice.setEnabled(event.getStateChange() == ItemEvent.SELECTED); | ||
}); | ||
frame.add(BorderLayout.NORTH, checkbox); | ||
frame.add(BorderLayout.CENTER, choice); | ||
return frame; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I guess it was decided that java.awt will come before javax.swing...
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.
updated.