8193543: Regression automated test '/open/test/jdk/java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java' fails

Reviewed-by: serb
This commit is contained in:
Alexander Zvegintsev 2022-04-23 20:41:55 +00:00
parent a1efb95536
commit 08024d9583
2 changed files with 27 additions and 15 deletions
test/jdk
ProblemList.txt
java/awt/TrayIcon/SystemTrayInstance

@ -208,7 +208,6 @@ java/awt/TrayIcon/ModalityTest/ModalityTest.java 8150540 windows-all,macosx-all
java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java 8150540 windows-all
java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java 8150540 windows-all
java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/FunctionalityCheck.java 8150540 windows-all
java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java 8193543 linux-all
java/awt/TrayIcon/TrayIconEventModifiers/TrayIconEventModifiersTest.java 8150540 windows-all
java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java 8150540 windows-all
java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java 8150540 windows-all

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, 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
@ -21,7 +21,7 @@
* questions.
*/
import java.awt.*;
import java.awt.SystemTray;
/*
* @test
@ -30,12 +30,20 @@ import java.awt.*;
* a proper instance is returned in supported platforms and a proper
* exception is thrown in unsupported platforms
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
* @requires (os.family != "linux")
* @run main/othervm -DSystemTraySupport=TRUE SystemTrayInstanceTest
*/
/*
* @test
* @key headful
* @requires (os.family == "linux")
* @run main/othervm -DSystemTraySupport=MAYBE SystemTrayInstanceTest
*/
public class SystemTrayInstanceTest {
private static boolean supported = false;
private static boolean shouldSupport = false;
public static void main(String[] args) throws Exception {
String sysTraySupport = System.getProperty("SystemTraySupport");
@ -43,30 +51,35 @@ public class SystemTrayInstanceTest {
throw new RuntimeException("SystemTray support status unknown!");
if ("TRUE".equals(sysTraySupport)) {
System.out.println("System tray is supported on the platform under test");
supported = true;
System.out.println("System tray should be supported on this platform.");
shouldSupport = true;
}
new SystemTrayInstanceTest().doTest();
}
private void doTest() throws Exception {
boolean flag = SystemTray.isSupported();
if (supported != flag)
throw new RuntimeException("FAIL: isSupported did not return the correct value"+
(supported ?
"SystemTray is supported on the platform under test" :
"SystemTray is not supported on the platform under test") +
"SystemTray.isSupported() method returned " + flag);
private void doTest() {
boolean systemSupported = SystemTray.isSupported();
if (shouldSupport && !systemSupported) {
throw new RuntimeException(
"FAIL: SystemTray is not supported on the platform under test, while it should."
);
}
if (supported) {
if (shouldSupport || systemSupported) {
SystemTray tray = SystemTray.getSystemTray();
System.out.println("SystemTray instance received");
} else {
boolean exceptionThrown = false;
try {
SystemTray tray = SystemTray.getSystemTray();
} catch (UnsupportedOperationException uoe) {
exceptionThrown = true;
System.out.println("UnsupportedOperationException thrown correctly");
}
if (!exceptionThrown) {
throw new RuntimeException("UnsupportedOperationException is not thrown");
}
}
}
}