forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8340354: Open source AWT desktop properties and print related tests
Reviewed-by: prr
- Loading branch information
Abhishek Kumar
committed
Oct 1, 2024
1 parent
b11066b
commit 988f13a
Showing
5 changed files
with
1,227 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* 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.Frame; | ||
import java.awt.Toolkit; | ||
import java.beans.PropertyChangeEvent; | ||
import java.beans.PropertyChangeListener; | ||
|
||
/* | ||
* @test | ||
* @bug 4808569 | ||
* @requires (os.family == "windows") | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @summary add desktop property for the Windows XP or later font smoothing settings | ||
* @run main/manual FontSmoothing | ||
*/ | ||
|
||
public class FontSmoothing { | ||
|
||
private static final String PROP_NAME = "win.text.fontSmoothingType"; | ||
|
||
public static void main(String[] args) throws Exception { | ||
String INSTRUCTIONS = """ | ||
This test should be run on Windows XP or later. | ||
On Windows 11: | ||
1. Open Run dialog by typing 'run' in search bar. | ||
2. Type 'cttune' and press Ok. | ||
3. Uncheck the "Turn On ClearType" checkbox and follow next instructions on screen. | ||
4. Repeat Step 1-2. | ||
5. Check the "Turn On ClearType" checkbox and follow next instructions on screen. | ||
6. Take a look at the output window to determine if the test passed or failed. | ||
"""; | ||
|
||
PassFailJFrame.builder() | ||
.title("FontSmoothing Test Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 2) | ||
.columns(40) | ||
.testTimeOut(5) | ||
.testUI(FontSmoothing::createUI) | ||
.logArea(8) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
private static Frame createUI() { | ||
Frame f = new Frame("FontSmoothing Test"); | ||
f.setSize(50, 50); | ||
|
||
Object value = Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); | ||
PassFailJFrame.log("toolkit.getDesktopProperty: " + PROP_NAME + " = " + value + "\n"); | ||
|
||
Toolkit.getDefaultToolkit().addPropertyChangeListener(PROP_NAME, new PropertyChangeListener() { | ||
public void propertyChange(PropertyChangeEvent e) { | ||
PassFailJFrame.log("PropertyChangeEvent: " + e.getPropertyName() + | ||
"\n old value=" + e.getOldValue() + | ||
"\n new value=" + e.getNewValue()); | ||
|
||
Integer value = (Integer) Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); | ||
PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); | ||
|
||
if (value.equals((Integer) e.getNewValue())) { | ||
PassFailJFrame.log("test PASSED"); | ||
} else { | ||
PassFailJFrame.log("test FAILED"); | ||
} | ||
} | ||
}); | ||
return f; | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.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,100 @@ | ||
/* | ||
* Copyright (c) 2000, 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.Color; | ||
import java.awt.Frame; | ||
import java.awt.Toolkit; | ||
import java.beans.PropertyChangeEvent; | ||
import java.beans.PropertyChangeListener; | ||
|
||
/* | ||
* @test | ||
* @bug 4368193 | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @requires (os.family == "windows") | ||
* @summary Toolkit's getDesktopProperty returns stale values on Microsoft Windows | ||
* @run main/manual ThreeDBackgroundColor | ||
*/ | ||
|
||
public class ThreeDBackgroundColor { | ||
|
||
private static final String PROP_NAME = "win.3d.backgroundColor"; | ||
|
||
public static void main(String[] args) throws Exception { | ||
String INSTRUCTIONS = """ | ||
On Windows 10: | ||
1. Open Windows Settings, in the search bar type | ||
'high contrast', in the list of suggestions choose option | ||
'Turn high contrast on or off' | ||
2. In the High contrast control panel click on the on/off switch | ||
to initialize High contrast mode | ||
3. Wait for the High contrast mode to finish initialization | ||
4. Click on the same switch again to turn off High contrast mode | ||
On Windows 11: | ||
1. Open Windows settings, in the search bar type | ||
'Contrast Theme'. | ||
2. Select any value from 'Contrast themes' dropdown menu and press 'Apply'. | ||
3. Wait for the High contrast mode to finish initialization | ||
4. Select 'None' from 'Contrast themes' dropdown menu to revert the changes. | ||
Take a look at the output window to determine if the test passed or failed."""; | ||
|
||
PassFailJFrame.builder() | ||
.title("ThreeDBackgroundColor Test Instructions") | ||
.instructions(INSTRUCTIONS) | ||
.rows((int) INSTRUCTIONS.lines().count() + 2) | ||
.columns(40) | ||
.testTimeOut(5) | ||
.testUI(ThreeDBackgroundColor::createUI) | ||
.logArea(8) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
private static Frame createUI() { | ||
Frame f = new Frame("ThreeDBackgroundColor Test"); | ||
f.setSize(50, 50); | ||
|
||
Object value = Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); | ||
PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); | ||
|
||
Toolkit.getDefaultToolkit().addPropertyChangeListener(PROP_NAME, new PropertyChangeListener() { | ||
public void propertyChange(PropertyChangeEvent e) { | ||
PassFailJFrame.log("PropertyChangeEvent: " + e.getPropertyName() + | ||
"\n old value=" + e.getOldValue() + | ||
"\n new value=" + e.getNewValue()); | ||
|
||
Color value = (Color) Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); | ||
PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); | ||
if (value.equals((Color) e.getNewValue())) { | ||
PassFailJFrame.log("test PASSED"); | ||
} else { | ||
PassFailJFrame.log("test FAILED"); | ||
} | ||
} | ||
}); | ||
return f; | ||
} | ||
} |
Oops, something went wrong.