-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8353000: Open source several swing tests batch2 #24560
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c51406a
Initial commit for backout
DamonGuy a98fb87
Merge branch 'master' of github.com:DamonGuy/jdk
DamonGuy 947f73d
Merge branch 'master' of github.com:DamonGuy/jdk
DamonGuy b17e483
Merge branch 'master' of github.com:DamonGuy/jdk
DamonGuy 240863f
Initial move
DamonGuy 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
83 changes: 83 additions & 0 deletions
83
test/jdk/javax/swing/plaf/metal/MenuItemUI/JavaLAFMenuAcceleratorDelimiter.java
This file contains hidden or 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,83 @@ | ||
| /* | ||
| * Copyright (c) 1999, 2025, 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. | ||
| */ | ||
|
|
||
| /* | ||
| * @test | ||
| * @bug 4210461 | ||
| * @summary Confirm Metal Look & Feel's MenuItem Accelerator Delimiter | ||
| * @library /java/awt/regtesthelpers | ||
| * @build PassFailJFrame | ||
| * @run main/manual JavaLAFMenuAcceleratorDelimiter | ||
| */ | ||
|
|
||
| import java.awt.BorderLayout; | ||
| import java.awt.event.ActionEvent; | ||
| import java.awt.event.KeyEvent; | ||
|
|
||
| import javax.swing.JFrame; | ||
| import javax.swing.JMenu; | ||
| import javax.swing.JMenuBar; | ||
| import javax.swing.JMenuItem; | ||
| import javax.swing.JPanel; | ||
| import javax.swing.KeyStroke; | ||
| import javax.swing.UIManager; | ||
|
|
||
| public class JavaLAFMenuAcceleratorDelimiter { | ||
| static final String INSTRUCTIONS = """ | ||
| A simple check. The visual design specification for JLF/Metal asks for | ||
| a "-" to delimit the other two entities in a menu item's accelerator. | ||
| The test passes if the delimiter for the accelerator is correct when | ||
| opening the example menu. Otherwise, the test fails. | ||
| """; | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| // Set Metal L&F | ||
| UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); | ||
| PassFailJFrame.builder() | ||
| .title("JavaLAFMenuAcceleratorDelimiter Test Instructions") | ||
| .instructions(INSTRUCTIONS) | ||
| .columns(40) | ||
| .testUI(JavaLAFMenuAcceleratorDelimiter::createUI) | ||
| .build() | ||
| .awaitAndCheck(); | ||
| } | ||
|
|
||
| static JFrame createUI() { | ||
| JFrame frame = new JFrame("Metal L&F Accelerator Delimiter Test"); | ||
| JPanel menuPanel = new JPanel(); | ||
| JMenuBar menuBar = new JMenuBar(); | ||
| menuBar.setOpaque(true); | ||
| JMenu exampleMenu = new JMenu("Example"); | ||
| JMenuItem hiMenuItem = new JMenuItem("Hi There!"); | ||
| hiMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, | ||
| ActionEvent.CTRL_MASK)); | ||
| exampleMenu.add(hiMenuItem); | ||
| menuBar.add(exampleMenu); | ||
| menuPanel.add(menuBar); | ||
|
|
||
| frame.getContentPane().setLayout(new BorderLayout()); | ||
| frame.getContentPane().add(menuPanel, BorderLayout.CENTER); | ||
| frame.setSize(250, 150); | ||
| return frame; | ||
| } | ||
| } |
98 changes: 98 additions & 0 deletions
98
test/jdk/javax/swing/plaf/metal/MetalIconFactory/bug4952462.java
This file contains hidden or 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,98 @@ | ||
| /* | ||
| * Copyright (c) 2004, 2025, 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. | ||
| */ | ||
|
|
||
| /* | ||
| * @test | ||
| * @bug 4952462 | ||
| * @summary Ocean: Tests that disabled selected JRadioButton dot is NOT | ||
| * painted with the foreground color | ||
| * @modules java.desktop/sun.awt | ||
| * @library /test/lib | ||
| * @key headful | ||
| * @run main bug4952462 | ||
| */ | ||
|
|
||
| import java.awt.Color; | ||
| import java.awt.FlowLayout; | ||
| import java.awt.Point; | ||
| import java.awt.Robot; | ||
|
|
||
| import javax.swing.JFrame; | ||
| import javax.swing.JRadioButton; | ||
| import javax.swing.SwingUtilities; | ||
| import javax.swing.UIManager; | ||
| import javax.swing.plaf.metal.MetalTheme; | ||
|
|
||
| import jtreg.SkippedException; | ||
| import sun.awt.AppContext; | ||
|
|
||
| public class bug4952462 { | ||
| private static JFrame frame; | ||
| private static JRadioButton rb; | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| try { | ||
| UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); | ||
|
|
||
| MetalTheme theme = (MetalTheme) AppContext.getAppContext().get("currentMetalTheme"); | ||
| if (theme == null || !"Ocean".equals(theme.getName())) { | ||
| throw new SkippedException("Current theme is not Ocean. Test is " + | ||
| "only for Metal's Ocean theme. Skipping test."); | ||
| } else { | ||
| Robot r = new Robot(); | ||
| SwingUtilities.invokeAndWait(() -> { | ||
| frame = new JFrame("Metal JRadioButton Foreground Color Test"); | ||
| frame.getContentPane().setLayout(new FlowLayout()); | ||
| rb = new JRadioButton("RadioButton", true); | ||
| rb.setEnabled(false); | ||
| rb.setForeground(Color.RED); | ||
| frame.getContentPane().add(rb); | ||
| frame.setSize(250, 100); | ||
| frame.setLocationRelativeTo(null); | ||
| frame.setVisible(true); | ||
| }); | ||
|
|
||
| r.waitForIdle(); | ||
| r.delay(500); | ||
|
|
||
| SwingUtilities.invokeAndWait(() -> { | ||
| Point p = rb.getLocationOnScreen(); | ||
| for (int i = 0; i < 50; i++) { | ||
| Color c = r.getPixelColor(p.x + 10 + i, p.y + (rb.getHeight() / 2)); | ||
| System.out.println(c); | ||
| if (c.getRed() > 200 && c.getBlue() < 200 && c.getGreen() < 200) { | ||
| throw new RuntimeException("Test failed. Radiobutton is red " + | ||
| "and not grey."); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| } finally { | ||
| SwingUtilities.invokeAndWait(() -> { | ||
| if (frame != null) { | ||
| frame.dispose(); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| } | ||
74 changes: 74 additions & 0 deletions
74
test/jdk/javax/swing/plaf/metal/MetalSliderUI/4186347/bug4186347.java
This file contains hidden or 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,74 @@ | ||
| /* | ||
| * Copyright (c) 2001, 2025, 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. | ||
| */ | ||
|
|
||
| /* | ||
| * @test | ||
| * @bug 4186347 | ||
| * @summary Tests changing Slider.horizontalThumbIcon UIResource | ||
| * @library /java/awt/regtesthelpers | ||
| * @build PassFailJFrame | ||
| * @run main/manual bug4186347 | ||
| */ | ||
|
|
||
| import javax.swing.Icon; | ||
| import javax.swing.ImageIcon; | ||
| import javax.swing.JFrame; | ||
| import javax.swing.JSlider; | ||
| import javax.swing.UIDefaults; | ||
| import javax.swing.UIManager; | ||
| import javax.swing.plaf.IconUIResource; | ||
|
|
||
| public class bug4186347 { | ||
| static final String INSTRUCTIONS = """ | ||
| If the slider's thumb icon is painted correctly | ||
| (that is centered vertically relative to slider | ||
| channel) then test passed, otherwise it failed. | ||
| """; | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| // Set Metal L&F | ||
| UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); | ||
| PassFailJFrame.builder() | ||
| .title("bug4186347 Test Instructions") | ||
| .instructions(INSTRUCTIONS) | ||
| .columns(40) | ||
| .testUI(bug4186347::createUI) | ||
| .build() | ||
| .awaitAndCheck(); | ||
| } | ||
|
|
||
| static JFrame createUI() { | ||
| JFrame frame = new JFrame("Metal JSlider Icon Test"); | ||
| String a = System.getProperty("test.src", ".") | ||
| + System.getProperty("file.separator") | ||
| + "duke.gif"; | ||
| Icon icon = new ImageIcon(a); | ||
| IconUIResource iconResource = new IconUIResource(icon); | ||
| UIDefaults defaults = UIManager.getDefaults(); | ||
| defaults.put("Slider.horizontalThumbIcon", iconResource); | ||
| JSlider s = new JSlider(); | ||
| frame.getContentPane().add(s); | ||
| frame.setSize(250, 150); | ||
| return frame; | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
The usage of AppContext can be dropped, and replaced by some other public api.