Skip to content
Snippets Groups Projects
Commit 19aab395 authored by Andrew Lu's avatar Andrew Lu
Browse files

8193547: Regression automated test...

8193547: Regression automated test '/open/test/jdk/java/awt/Toolkit/DesktopProperties/rfe4758438.java' fails

Backport-of: c05dbac3cbd8de3822191bcb5c34832c997bc4a9
parent 0bc3783c
Branches
Tags
No related merge requests found
...@@ -473,7 +473,6 @@ java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java 7107528 linu ...@@ -473,7 +473,6 @@ java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java 7107528 linu
java/awt/Mouse/MouseDragEvent/MouseDraggedTest.java 8080676 linux-all java/awt/Mouse/MouseDragEvent/MouseDraggedTest.java 8080676 linux-all
java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersInKeyEvent.java 8157147 linux-all,windows-all,macosx-all java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersInKeyEvent.java 8157147 linux-all,windows-all,macosx-all
java/awt/Mouse/TitleBarDoubleClick/TitleBarDoubleClick.java 8148041 linux-all java/awt/Mouse/TitleBarDoubleClick/TitleBarDoubleClick.java 8148041 linux-all
java/awt/Toolkit/DesktopProperties/rfe4758438.java 8193547 linux-all
java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java 6847163 linux-all java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java 6847163 linux-all
java/awt/xembed/server/RunTestXEmbed.java 7034201 linux-all java/awt/xembed/server/RunTestXEmbed.java 7034201 linux-all
java/awt/Modal/ModalFocusTransferTests/FocusTransferDialogsDocModalTest.java 8164473 linux-all java/awt/Modal/ModalFocusTransferTests/FocusTransferDialogsDocModalTest.java 8164473 linux-all
......
/* /*
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -30,6 +30,7 @@ import java.io.InputStream; ...@@ -30,6 +30,7 @@ import java.io.InputStream;
* @test * @test
* @key headful * @key headful
* @bug 4758438 * @bug 4758438
* @requires os.family == "linux"
* @summary Testcase to check the implementation of RFE 4758438 * @summary Testcase to check the implementation of RFE 4758438
* The RFE suggests that the GNOME desktop properties * The RFE suggests that the GNOME desktop properties
* should be made accessible through the * should be made accessible through the
...@@ -43,12 +44,14 @@ public class rfe4758438 implements PropertyChangeListener { ...@@ -43,12 +44,14 @@ public class rfe4758438 implements PropertyChangeListener {
enum PROPS { enum PROPS {
drag_threshold( drag_threshold(
"org.gnome.desktop.peripherals.mouse drag-threshold",
"org.gnome.settings-daemon.peripherals.mouse drag-threshold", "org.gnome.settings-daemon.peripherals.mouse drag-threshold",
"/desktop/gnome/peripherals/mouse/drag_threshold", "/desktop/gnome/peripherals/mouse/drag_threshold",
"gnome.Net/DndDragThreshold", "gnome.Net/DndDragThreshold",
"int", "int",
new String[]{"5", "6"}), new String[]{"5", "6"}),
double_click( double_click(
"org.gnome.desktop.peripherals.mouse double-click",
"org.gnome.settings-daemon.peripherals.mouse double-click", "org.gnome.settings-daemon.peripherals.mouse double-click",
"/desktop/gnome/peripherals/mouse/double_click", "/desktop/gnome/peripherals/mouse/double_click",
"gnome.Net/DoubleClickTime", "gnome.Net/DoubleClickTime",
...@@ -56,31 +59,43 @@ public class rfe4758438 implements PropertyChangeListener { ...@@ -56,31 +59,43 @@ public class rfe4758438 implements PropertyChangeListener {
new String[]{"200","300"}), new String[]{"200","300"}),
cursor_blink( cursor_blink(
"org.gnome.desktop.interface cursor-blink", "org.gnome.desktop.interface cursor-blink",
null,
"/desktop/gnome/interface/cursor_blink", "/desktop/gnome/interface/cursor_blink",
"gnome.Net/CursorBlink", "gnome.Net/CursorBlink",
"bool", "bool",
new String[]{"true","false"}), new String[]{"true","false"}),
cursor_blink_time( cursor_blink_time(
"org.gnome.desktop.interface cursor-blink-time", "org.gnome.desktop.interface cursor-blink-time",
null,
"/desktop/gnome/interface/cursor_blink_time", "/desktop/gnome/interface/cursor_blink_time",
"gnome.Net/CursorBlinkTime", "gnome.Net/CursorBlinkTime",
"int", "int",
new String[]{"1000","1500"}), new String[]{"1000","1500"}),
gtk_theme( gtk_theme(
"org.gnome.desktop.interface gtk-theme", "org.gnome.desktop.interface gtk-theme",
null,
"/desktop/gnome/interface/gtk_theme", "/desktop/gnome/interface/gtk_theme",
"gnome.Net/ThemeName", "gnome.Net/ThemeName",
"string", "string",
new String[]{"Crux","Simple"}); new String[]{"Crux","Simple"});
public final String gsettings; public final String gsettings;
public final String gsettingsFallback;
public final String gconftool; public final String gconftool;
public final String java; public final String java;
public final String type; public final String type;
public final String[] values; public final String[] values;
PROPS(String gsettings, String gconftool, String java, String type, String[] values){ PROPS(
String gsettings,
String gsettingsFallback,
String gconftool,
String java,
String type,
String[] values
){
this.gsettings = gsettings; this.gsettings = gsettings;
this.gsettingsFallback = gsettingsFallback;
this.gconftool = gconftool; this.gconftool = gconftool;
this.java = java; this.java = java;
this.type = type; this.type = type;
...@@ -90,10 +105,10 @@ public class rfe4758438 implements PropertyChangeListener { ...@@ -90,10 +105,10 @@ public class rfe4758438 implements PropertyChangeListener {
static boolean useGsettings; static boolean useGsettings;
static String tool; static String tool;
Toolkit toolkit = Toolkit.getDefaultToolkit(); final Toolkit toolkit = Toolkit.getDefaultToolkit();
String changedProperty; String changedProperty;
Object changedValue; Object changedValue;
Object lock = new Object(); final Object lock = new Object();
/** /**
* Implementation of PropertyChangeListener method * Implementation of PropertyChangeListener method
...@@ -105,7 +120,7 @@ public class rfe4758438 implements PropertyChangeListener { ...@@ -105,7 +120,7 @@ public class rfe4758438 implements PropertyChangeListener {
synchronized(lock) { synchronized(lock) {
try { try {
lock.notifyAll(); lock.notifyAll();
} catch (Exception e) { } catch (Exception ignored) {
} }
} }
} }
...@@ -132,6 +147,34 @@ public class rfe4758438 implements PropertyChangeListener { ...@@ -132,6 +147,34 @@ public class rfe4758438 implements PropertyChangeListener {
System.out.println("Test passed"); System.out.println("Test passed");
} }
String prepareCommand(PROPS property, boolean useMain) {
//Create the command to execute
StringBuffer sb = new StringBuffer(tool);
if (useGsettings) {
sb.append(" set ");
sb.append( useMain
? property.gsettings
: property.gsettingsFallback
);
sb.append(" ");
} else {
sb.append(" --set --type=");
sb.append(property.type);
sb.append(" ");
sb.append(property.gconftool);
sb.append(" ");
}
return sb.toString();
}
int doTestCommand(String cmd) throws Exception {
//Initialize the variables and execute the command
changedProperty = "";
changedValue = null;
return executeCommand(cmd);
}
/** /**
* Do the test for each property. Find the current value * Do the test for each property. Find the current value
* of the property, set the property to a value not equal * of the property, set the property to a value not equal
...@@ -146,10 +189,10 @@ public class rfe4758438 implements PropertyChangeListener { ...@@ -146,10 +189,10 @@ public class rfe4758438 implements PropertyChangeListener {
//For boolean type values, getDesktopProperty method returns Integer objects //For boolean type values, getDesktopProperty method returns Integer objects
if (property.type.equals("bool")) { if (property.type.equals("bool")) {
if (obj.equals(new Integer(1))) { if (obj.equals(1)) {
obj = new String("true"); obj = "true";
} else { } else {
obj = new String("false"); obj = "false";
} }
} }
Object value = property.values[0]; Object value = property.values[0];
...@@ -157,56 +200,53 @@ public class rfe4758438 implements PropertyChangeListener { ...@@ -157,56 +200,53 @@ public class rfe4758438 implements PropertyChangeListener {
value = property.values[1]; value = property.values[1];
} }
//Create the command to execute String tempCommand = prepareCommand(property, true);
StringBuffer sb = new StringBuffer(tool);
if (useGsettings) { int retVal = doTestCommand(tempCommand + value);
sb.append(" set ");
sb.append(property.gsettings); if (retVal != 0) {
sb.append(" "); if (useGsettings && property.gsettingsFallback != null) {
} else { System.out.printf("Failed:\n\t%s\nTrying fallback:\n\t", tempCommand);
sb.append(" --set --type="); tempCommand = prepareCommand(property, false);
sb.append(property.type); System.out.println(tempCommand);
sb.append(" ");
sb.append(property.gconftool); retVal = doTestCommand(tempCommand + value);
sb.append(" ");
} }
String tempCommand = sb.toString();
sb.append(value.toString());
//Initialize the variables and execute the command if (retVal != 0) {
changedProperty = "";
changedValue = null;
if (executeCommand(sb.toString()) != 0)
throw new RuntimeException("Could not execute the command"); throw new RuntimeException("Could not execute the command");
}
}
synchronized(lock) { synchronized(lock) {
try { try {
lock.wait(5000); lock.wait(5000);
} catch (Exception e) { } catch (Exception ignored) {
} }
} }
if (property.type.equals("bool")) { if (property.type.equals("bool")) {
if (changedValue.equals(new Integer(1))) { if (changedValue.equals(1)) {
changedValue = new String("true"); changedValue = "true";
} else { } else {
changedValue = new String("false"); changedValue = "false";
} }
} }
//Check if the event got triggered //Check if the event got triggered
if (!changedProperty.equals(property.java)) { if (!changedProperty.equals(property.java)) {
//Reset the property //Reset the property
executeCommand(tempCommand + obj.toString()); executeCommand(tempCommand + obj);
throw new RuntimeException("PropertyChangedEvent did not occur for " + property.java); throw new RuntimeException("PropertyChangedEvent did not occur for " + property.java);
} else if (!changedValue.toString().equals(value.toString())) { } else if (!changedValue.toString().equals(value.toString())) {
//Reset the property //Reset the property
executeCommand(tempCommand + obj.toString()); executeCommand(tempCommand + obj);
throw new RuntimeException("New value of the property is different from " + throw new RuntimeException("New value of the property is different from " +
"the value supplied"); "the value supplied");
} }
//Reset the property //Reset the property
executeCommand(tempCommand + obj.toString()); executeCommand(tempCommand + obj);
} }
/** /**
...@@ -231,9 +271,9 @@ public class rfe4758438 implements PropertyChangeListener { ...@@ -231,9 +271,9 @@ public class rfe4758438 implements PropertyChangeListener {
stderr.append((char) es.read()); stderr.append((char) es.read());
if (stdout.length() > 0) if (stdout.length() > 0)
System.out.println(stdout.toString()); System.out.println(stdout);
if (stderr.length() > 0) if (stderr.length() > 0)
System.err.println(stderr.toString()); System.err.println(stderr);
return process.exitValue(); return process.exitValue();
} }
} }
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -28,18 +28,20 @@ OS=`uname` ...@@ -28,18 +28,20 @@ OS=`uname`
case "$OS" in case "$OS" in
Linux* ) Linux* )
GNOMESID=`pgrep gnome-session` GNOMESID=`pgrep gnome-session | head -n1`
printf "\n/* gnome-session environ\n"
cat "/proc/$GNOMESID/environ" | tr '\0' '\n'
printf "\n*/\n\n"
DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS /proc/$GNOMESID/environ | cut -d= -f2-` DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS /proc/$GNOMESID/environ | cut -d= -f2-`
export DBUS_SESSION_BUS_ADDRESS export DBUS_SESSION_BUS_ADDRESS
DISPLAY=`grep -z DISPLAY /proc/$GNOMESID/environ | cut -d= -f2-` DISPLAY=`grep -z DISPLAY /proc/$GNOMESID/environ | cut -d= -f2-`
export DISPLAY export DISPLAY
;;
Sun* ) XDG_CURRENT_DESKTOP=`grep -z XDG_CURRENT_DESKTOP /proc/$GNOMESID/environ | cut -d= -f2-`
GNOMESID=`pgrep gnome-session` export XDG_CURRENT_DESKTOP
DBUS_SESSION_BUS_ADDRESS=`pargs -e $GNOMESID | grep DBUS_SESSION_BUS_ADDRESS | cut -d= -f2-`
export DBUS_SESSION_BUS_ADDRESS
DISPLAY=`pargs -e $GNOMESID | grep DISPLAY | cut -d= -f2-`
export DISPLAY
;; ;;
* ) * )
echo "This Feature is not to be tested on $OS" echo "This Feature is not to be tested on $OS"
...@@ -47,14 +49,19 @@ case "$OS" in ...@@ -47,14 +49,19 @@ case "$OS" in
;; ;;
esac esac
if [ ${GNOME_DESKTOP_SESSION_ID:-nonset} = "nonset" ]; printf "\n/* Test env:\n\n"
then env
if [ ${GNOME_SESSION_NAME:-nonset} = "nonset" ]; printf "\n*/\n\n"
XDG_GNOME=$(echo $XDG_CURRENT_DESKTOP | grep -i gnome)
if [ -z "$XDG_GNOME" ] \
&& [ ${GNOME_DESKTOP_SESSION_ID:-nonset} = "nonset" ] \
&& [ ${GNOME_SESSION_NAME:-nonset} = "nonset" ]
then then
echo "This test should run under Gnome" echo "This test should run under Gnome"
exit 0 exit 0
fi fi
fi
SCHEMAS=`gsettings list-schemas | wc -l` SCHEMAS=`gsettings list-schemas | wc -l`
...@@ -70,7 +77,11 @@ fi ...@@ -70,7 +77,11 @@ fi
cd ${TESTSRC} cd ${TESTSRC}
echo $PWD echo $PWD
echo "${TESTJAVA}/bin/javac -d ${TESTCLASSES} rfe4758438.java" echo "${TESTJAVA}/bin/javac -d ${TESTCLASSES} rfe4758438.java"
set -e
${TESTJAVA}/bin/javac -d ${TESTCLASSES} rfe4758438.java ${TESTJAVA}/bin/javac -d ${TESTCLASSES} rfe4758438.java
set +e
cd ${TESTCLASSES} cd ${TESTCLASSES}
${TESTJAVA}/bin/java -DuseGsettings=${USE_GSETTINGS} -Dtool=${TOOL} ${TESTVMOPTS} rfe4758438 ${TESTJAVA}/bin/java -DuseGsettings=${USE_GSETTINGS} -Dtool=${TOOL} ${TESTVMOPTS} rfe4758438
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment