8247753: UIManager.getSytemLookAndFeelClassName() returns wrong value on Fedora 32

Reviewed-by: prr, psadhukhan
This commit is contained in:
Pankaj Bansal 2020-08-09 14:30:02 +05:30
parent 0615eac2e6
commit 79a4a019bb
2 changed files with 33 additions and 21 deletions

View file

@ -95,10 +95,19 @@ public abstract class UNIXToolkit extends SunToolkit
@Override @Override
public String getDesktop() { public String getDesktop() {
String gnome = "gnome";
String gsi = AccessController.doPrivileged( String gsi = AccessController.doPrivileged(
(PrivilegedAction<String>) () (PrivilegedAction<String>) ()
-> System.getenv("GNOME_DESKTOP_SESSION_ID")); -> System.getenv("GNOME_DESKTOP_SESSION_ID"));
return (gsi != null) ? "gnome" : null; if (gsi != null) {
return gnome;
}
String desktop = AccessController.doPrivileged(
(PrivilegedAction<String>) ()
-> System.getenv("XDG_CURRENT_DESKTOP"));
return (desktop != null && desktop.toLowerCase().contains(gnome))
? gnome : null;
} }
/** /**

View file

@ -21,9 +21,9 @@
* questions. * questions.
*/ */
/* /*
* @test * @test
* @bug 8226783 * @bug 8226783 8247753
* @key headful * @key headful
* @summary Verify System L&F * @summary Verify System L&F
*/ */
@ -52,23 +52,26 @@ public class SystemLookAndFeelTest {
} else if (os.contains("macos")) { } else if (os.contains("macos")) {
expLAF = "com.apple.laf.AquaLookAndFeel"; expLAF = "com.apple.laf.AquaLookAndFeel";
} else if (os.contains("linux")) { } else if (os.contains("linux")) {
/* /*
* The implementation keys off the following desktop setting to * The implementation keys off the following desktop setting to
* decide if GTK is an appropriate system L&F. * decide if GTK is an appropriate system L&F.
* In its absence, there probably isn't support for the GTK L&F * In its absence, there probably isn't support for the GTK L&F
* anyway. It does not tell us if the GTK libraries are available * anyway. It does not tell us if the GTK libraries are available
* but they really should be if this is a gnome session. * but they really should be if this is a gnome session.
* If it proves necessary the test can perhaps be updated to see * If it proves necessary the test can perhaps be updated to see
* if the GTK LAF is listed as installed and can be instantiated. * if the GTK LAF is listed as installed and can be instantiated.
*/ */
String gnome = System.getenv("GNOME_DESKTOP_SESSION_ID"); String gnome = System.getenv("GNOME_DESKTOP_SESSION_ID");
System.out.println("Gnome desktop session ID is " + gnome); String desktop = System.getenv("XDG_CURRENT_DESKTOP");
if (gnome != null) { System.out.println("Gnome desktop session ID is " + gnome);
expLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; System.out.println("XDG_CURRENT_DESKTOP is set to " + desktop);
} else if (os.contains("linux")) { if (gnome != null ||
expLAF = "javax.swing.plaf.metal.MetalLookAndFeel"; (desktop != null && desktop.toLowerCase().contains("gnome"))) {
} expLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
} } else {
expLAF = "javax.swing.plaf.metal.MetalLookAndFeel";
}
}
System.out.println("Expected System LAF is " + expLAF); System.out.println("Expected System LAF is " + expLAF);
if (expLAF == null) { if (expLAF == null) {
System.out.println("No match for expected LAF, unknown OS ?"); System.out.println("No match for expected LAF, unknown OS ?");
@ -77,5 +80,5 @@ public class SystemLookAndFeelTest {
if (!(laf.equals(expLAF))) { if (!(laf.equals(expLAF))) {
throw new RuntimeException("LAF not as expected"); throw new RuntimeException("LAF not as expected");
} }
} }
} }