Skip to content

Commit 211f013

Browse files
author
duke
committedApr 23, 2022
Automatic merge of jdk:master into master
2 parents a6d4d43 + 08024d9 commit 211f013

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed
 

‎test/jdk/ProblemList.txt

-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ java/awt/TrayIcon/ModalityTest/ModalityTest.java 8150540 windows-all,macosx-all
208208
java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java 8150540 windows-all
209209
java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java 8150540 windows-all
210210
java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/FunctionalityCheck.java 8150540 windows-all
211-
java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java 8193543 linux-all
212211
java/awt/TrayIcon/TrayIconEventModifiers/TrayIconEventModifiersTest.java 8150540 windows-all
213212
java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java 8150540 windows-all
214213
java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java 8150540 windows-all

‎test/jdk/java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java

+27-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,7 @@
2121
* questions.
2222
*/
2323

24-
import java.awt.*;
24+
import java.awt.SystemTray;
2525

2626
/*
2727
* @test
@@ -30,43 +30,56 @@
3030
* a proper instance is returned in supported platforms and a proper
3131
* exception is thrown in unsupported platforms
3232
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
33+
* @requires (os.family != "linux")
3334
* @run main/othervm -DSystemTraySupport=TRUE SystemTrayInstanceTest
3435
*/
3536

37+
/*
38+
* @test
39+
* @key headful
40+
* @requires (os.family == "linux")
41+
* @run main/othervm -DSystemTraySupport=MAYBE SystemTrayInstanceTest
42+
*/
43+
3644
public class SystemTrayInstanceTest {
3745

38-
private static boolean supported = false;
46+
private static boolean shouldSupport = false;
3947

4048
public static void main(String[] args) throws Exception {
4149
String sysTraySupport = System.getProperty("SystemTraySupport");
4250
if (sysTraySupport == null)
4351
throw new RuntimeException("SystemTray support status unknown!");
4452

4553
if ("TRUE".equals(sysTraySupport)) {
46-
System.out.println("System tray is supported on the platform under test");
47-
supported = true;
54+
System.out.println("System tray should be supported on this platform.");
55+
shouldSupport = true;
4856
}
4957

5058
new SystemTrayInstanceTest().doTest();
5159
}
5260

53-
private void doTest() throws Exception {
54-
boolean flag = SystemTray.isSupported();
55-
if (supported != flag)
56-
throw new RuntimeException("FAIL: isSupported did not return the correct value"+
57-
(supported ?
58-
"SystemTray is supported on the platform under test" :
59-
"SystemTray is not supported on the platform under test") +
60-
"SystemTray.isSupported() method returned " + flag);
61+
private void doTest() {
62+
boolean systemSupported = SystemTray.isSupported();
63+
if (shouldSupport && !systemSupported) {
64+
throw new RuntimeException(
65+
"FAIL: SystemTray is not supported on the platform under test, while it should."
66+
);
67+
}
6168

62-
if (supported) {
69+
if (shouldSupport || systemSupported) {
6370
SystemTray tray = SystemTray.getSystemTray();
71+
System.out.println("SystemTray instance received");
6472
} else {
73+
boolean exceptionThrown = false;
6574
try {
6675
SystemTray tray = SystemTray.getSystemTray();
6776
} catch (UnsupportedOperationException uoe) {
77+
exceptionThrown = true;
6878
System.out.println("UnsupportedOperationException thrown correctly");
6979
}
80+
if (!exceptionThrown) {
81+
throw new RuntimeException("UnsupportedOperationException is not thrown");
82+
}
7083
}
7184
}
7285
}

0 commit comments

Comments
 (0)
Please sign in to comment.