8327492: Remove applet usage and update DisposeInActionEventTest.html
Reviewed-by: dnguyen, tr, abhiscxk, honkar, aivanov
This commit is contained in:
parent
2627470946
commit
53628f2ea9
@ -1,49 +0,0 @@
|
||||
<html>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2014, 2018, 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.
|
||||
-->
|
||||
|
||||
<!--
|
||||
@test
|
||||
@bug 6299866
|
||||
@summary Tests that no NPE is thrown when the tray icon is disposed from the
|
||||
handler of action event caused by clicking on this icon.
|
||||
@library ../../regtesthelpers
|
||||
@library /test/lib
|
||||
@build Sysout
|
||||
@build jdk.test.lib.Platform
|
||||
@author artem.ananiev: area=awt.tray
|
||||
@run applet/manual=yesno DisposeInActionEventTest.html
|
||||
-->
|
||||
<head>
|
||||
<title> DisposeInActionEventTest </title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>DisposeInActionEventTest<br>Bug ID: 6299866</h1>
|
||||
|
||||
<p> See the dialog box (usually in upper left corner) for instructions</p>
|
||||
|
||||
<APPLET CODE="DisposeInActionEventTest.class" WIDTH=200 HEIGHT=200></APPLET>
|
||||
</body>
|
||||
</html>
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 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
|
||||
@ -21,76 +21,78 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
test
|
||||
@bug 6299866
|
||||
@summary Tests that no NPE is thrown when the tray icon is disposed from the
|
||||
handler of action event caused by clicking on this icon.
|
||||
@library ../../regtesthelpers
|
||||
@build Sysout
|
||||
@author artem.ananiev: area=awt.tray
|
||||
@run applet/manual=yesno DisposeInActionEventTest.html
|
||||
*/
|
||||
|
||||
import java.applet.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import test.java.awt.regtesthelpers.Sysout;
|
||||
|
||||
public class DisposeInActionEventTest extends Applet {
|
||||
private boolean traySupported;
|
||||
/*
|
||||
* @test
|
||||
* @bug 6299866 8316931
|
||||
* @summary Tests that no NPE is thrown when the tray icon is disposed from the
|
||||
* handler of action event caused by clicking on this icon.
|
||||
* @library ../../regtesthelpers /test/lib
|
||||
* @build PassFailJFrame jtreg.SkippedException
|
||||
* @run main/manual DisposeInActionEventTest
|
||||
*/
|
||||
|
||||
private SystemTray systemTray;
|
||||
private TrayIcon trayIcon;
|
||||
public class DisposeInActionEventTest {
|
||||
private static JTextArea textArea;
|
||||
private static SystemTray systemTray;
|
||||
private static TrayIcon trayIcon;
|
||||
|
||||
public void init() {
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
String[] instructions;
|
||||
traySupported = SystemTray.isSupported();
|
||||
if (!traySupported) {
|
||||
instructions = new String[]{
|
||||
"The test cannot be run because SystemTray is not supported.",
|
||||
"Simply press PASS button."
|
||||
};
|
||||
} else {
|
||||
String clickInstruction;
|
||||
if (Platform.isOSX()) {
|
||||
clickInstruction = "right";
|
||||
} else {
|
||||
clickInstruction = "left";
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!SystemTray.isSupported()) {
|
||||
throw new jtreg.SkippedException("The test cannot be run because " +
|
||||
"SystemTray is not supported.");
|
||||
}
|
||||
String clickInstruction =
|
||||
(Platform.isOSX()) ? "Right-click" : "Double click (left mouse button)";
|
||||
|
||||
String instructions = "When the test starts, it adds the icon to the tray area. If you\n" +
|
||||
" don't see a tray icon, please, make sure that the tray area\n" +
|
||||
" (also called Taskbar Status Area on MS Windows, Notification\n" +
|
||||
" Area on Gnome or System Tray on KDE) is visible.\n\n" +
|
||||
clickInstruction + " the tray icon to trigger the\n" +
|
||||
" action event. Brief information about action events is printed\n" +
|
||||
" in the frame. After each action event, the tray icon is removed from\n" +
|
||||
" the tray and then added back in a second.\n\n" +
|
||||
"The test checks if any exceptions are thrown when removing and\n" +
|
||||
" re-adding the icon. If something is wrong, the test will automatically fail.\n" +
|
||||
" Repeat clicks several times Then press PASS button.";
|
||||
|
||||
try {
|
||||
PassFailJFrame.builder()
|
||||
.title("DisposeInActionEventTest")
|
||||
.instructions(instructions)
|
||||
.testTimeOut(10)
|
||||
.rows(15)
|
||||
.columns(45)
|
||||
.testUI(DisposeInActionEventTest::showFrameAndIcon)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
} finally {
|
||||
if (systemTray != null) {
|
||||
systemTray.remove(trayIcon);
|
||||
}
|
||||
instructions = new String[]{
|
||||
"When the test starts, it adds the icon to the tray aread. If you",
|
||||
" don't see a tray icon, please, make sure that the tray area",
|
||||
" (also called Taskbar Status Area on MS Windows, Notification",
|
||||
" Area on Gnome or System Tray on KDE) is visible.",
|
||||
"Double-click with " + clickInstruction + " button on the tray icon to trigger the",
|
||||
" action event. Brief information about action events is printed",
|
||||
" below. After each action event the tray icon is removed from",
|
||||
" the tray and then added back in a second.",
|
||||
"The test performs some automatic checks when removing the icon. If",
|
||||
" something is wrong the corresponding message is displayed below.",
|
||||
" Repeat double-clicks several times. If no 'Test FAILED' messages",
|
||||
" are printed, press PASS button else FAIL button."
|
||||
};
|
||||
}
|
||||
Sysout.createDialogWithInstructions(instructions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
setSize(200, 200);
|
||||
setVisible(true);
|
||||
validate();
|
||||
private static JFrame showFrameAndIcon() {
|
||||
JFrame frame = new JFrame("Event Message Display");
|
||||
frame.setLayout(new BorderLayout());
|
||||
|
||||
if (!traySupported) return;
|
||||
|
||||
System.setProperty("sun.awt.exception.handler", "DisposeInActionEventTest$EDTExceptionHandler");
|
||||
textArea = new JTextArea();
|
||||
frame.getContentPane().add(new JScrollPane(textArea));
|
||||
frame.setSize(400, 200);
|
||||
|
||||
BufferedImage img = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = img.createGraphics();
|
||||
@ -104,26 +106,26 @@ public class DisposeInActionEventTest extends Applet {
|
||||
trayIcon = new TrayIcon(img);
|
||||
trayIcon.setImageAutoSize(true);
|
||||
trayIcon.addActionListener(ev -> {
|
||||
Sysout.println(ev.toString());
|
||||
textArea.append(ev + "\n");
|
||||
systemTray.remove(trayIcon);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
systemTray.add(trayIcon);
|
||||
} catch (AWTException | InterruptedException e) {
|
||||
Sysout.println(e.toString());
|
||||
Sysout.println("!!! The test coudn't be performed !!!");
|
||||
e.printStackTrace();
|
||||
PassFailJFrame.forceFail("Exception caught: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
).start();
|
||||
}
|
||||
);
|
||||
}).start();
|
||||
});
|
||||
|
||||
try {
|
||||
systemTray.add(trayIcon);
|
||||
} catch (AWTException e) {
|
||||
Sysout.println(e.toString());
|
||||
Sysout.println("!!! The test coudn't be performed !!!");
|
||||
e.printStackTrace();
|
||||
PassFailJFrame.forceFail("Exception caught: " + e.getMessage());
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
@ -21,15 +21,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6384984 8004032
|
||||
* @library ../../regtesthelpers /test/lib
|
||||
* @build PassFailJFrame jtreg.SkippedException
|
||||
* @summary TrayIcon try to dispay a tooltip when is not visible
|
||||
* @run main/manual ShowAfterDisposeTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@ -42,7 +33,18 @@ import java.awt.image.BufferedImage;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6384984 8004032 8316931
|
||||
* @library ../../regtesthelpers /test/lib
|
||||
* @build PassFailJFrame jtreg.SkippedException
|
||||
* @summary TrayIcon try to dispay a tooltip when is not visible
|
||||
* @run main/manual ShowAfterDisposeTest
|
||||
*/
|
||||
public class ShowAfterDisposeTest {
|
||||
private static SystemTray tray;
|
||||
private static TrayIcon icon;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!SystemTray.isSupported()) {
|
||||
throw new jtreg.SkippedException("The test cannot be run because SystemTray is not supported.");
|
||||
@ -64,6 +66,7 @@ public class ShowAfterDisposeTest {
|
||||
"3) If the bug is reproducible then the test will fail without assistance.\n" +
|
||||
"4) Just press the 'pass' button.";
|
||||
|
||||
try {
|
||||
PassFailJFrame.builder()
|
||||
.title("Test Instructions Frame")
|
||||
.instructions(instructions)
|
||||
@ -73,6 +76,11 @@ public class ShowAfterDisposeTest {
|
||||
.testUI(ShowAfterDisposeTest::showFrameAndIcon)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
} finally {
|
||||
if (tray != null) {
|
||||
tray.remove(icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static JFrame showFrameAndIcon() {
|
||||
@ -87,8 +95,8 @@ public class ShowAfterDisposeTest {
|
||||
g.fillRect(6, 6, 20, 20);
|
||||
g.dispose();
|
||||
|
||||
final SystemTray tray = SystemTray.getSystemTray();
|
||||
final TrayIcon icon = new TrayIcon(img);
|
||||
tray = SystemTray.getSystemTray();
|
||||
icon = new TrayIcon(img);
|
||||
icon.setImageAutoSize(true);
|
||||
icon.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent ev) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user