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.
|
* 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
|
||||||
@ -21,76 +21,78 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.awt.AWTException;
|
||||||
/*
|
import java.awt.BorderLayout;
|
||||||
test
|
import java.awt.Color;
|
||||||
@bug 6299866
|
import java.awt.Graphics;
|
||||||
@summary Tests that no NPE is thrown when the tray icon is disposed from the
|
import java.awt.SystemTray;
|
||||||
handler of action event caused by clicking on this icon.
|
import java.awt.TrayIcon;
|
||||||
@library ../../regtesthelpers
|
import java.awt.image.BufferedImage;
|
||||||
@build Sysout
|
import javax.swing.JFrame;
|
||||||
@author artem.ananiev: area=awt.tray
|
import javax.swing.JScrollPane;
|
||||||
@run applet/manual=yesno DisposeInActionEventTest.html
|
import javax.swing.JTextArea;
|
||||||
*/
|
|
||||||
|
|
||||||
import java.applet.*;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.*;
|
|
||||||
|
|
||||||
import jdk.test.lib.Platform;
|
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;
|
public class DisposeInActionEventTest {
|
||||||
private TrayIcon trayIcon;
|
private static JTextArea textArea;
|
||||||
|
private static SystemTray systemTray;
|
||||||
|
private static TrayIcon trayIcon;
|
||||||
|
|
||||||
public void init() {
|
public static void main(String[] args) throws Exception {
|
||||||
this.setLayout(new BorderLayout());
|
if (!SystemTray.isSupported()) {
|
||||||
|
throw new jtreg.SkippedException("The test cannot be run because " +
|
||||||
String[] instructions;
|
"SystemTray is not supported.");
|
||||||
traySupported = SystemTray.isSupported();
|
}
|
||||||
if (!traySupported) {
|
String clickInstruction =
|
||||||
instructions = new String[]{
|
(Platform.isOSX()) ? "Right-click" : "Double click (left mouse button)";
|
||||||
"The test cannot be run because SystemTray is not supported.",
|
|
||||||
"Simply press PASS 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" +
|
||||||
} else {
|
" (also called Taskbar Status Area on MS Windows, Notification\n" +
|
||||||
String clickInstruction;
|
" Area on Gnome or System Tray on KDE) is visible.\n\n" +
|
||||||
if (Platform.isOSX()) {
|
clickInstruction + " the tray icon to trigger the\n" +
|
||||||
clickInstruction = "right";
|
" action event. Brief information about action events is printed\n" +
|
||||||
} else {
|
" in the frame. After each action event, the tray icon is removed from\n" +
|
||||||
clickInstruction = "left";
|
" 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
|
private static JFrame showFrameAndIcon() {
|
||||||
public void start() {
|
JFrame frame = new JFrame("Event Message Display");
|
||||||
setSize(200, 200);
|
frame.setLayout(new BorderLayout());
|
||||||
setVisible(true);
|
|
||||||
validate();
|
|
||||||
|
|
||||||
if (!traySupported) return;
|
textArea = new JTextArea();
|
||||||
|
frame.getContentPane().add(new JScrollPane(textArea));
|
||||||
System.setProperty("sun.awt.exception.handler", "DisposeInActionEventTest$EDTExceptionHandler");
|
frame.setSize(400, 200);
|
||||||
|
|
||||||
BufferedImage img = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
|
BufferedImage img = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
|
||||||
Graphics g = img.createGraphics();
|
Graphics g = img.createGraphics();
|
||||||
@ -104,26 +106,26 @@ public class DisposeInActionEventTest extends Applet {
|
|||||||
trayIcon = new TrayIcon(img);
|
trayIcon = new TrayIcon(img);
|
||||||
trayIcon.setImageAutoSize(true);
|
trayIcon.setImageAutoSize(true);
|
||||||
trayIcon.addActionListener(ev -> {
|
trayIcon.addActionListener(ev -> {
|
||||||
Sysout.println(ev.toString());
|
textArea.append(ev + "\n");
|
||||||
systemTray.remove(trayIcon);
|
systemTray.remove(trayIcon);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
systemTray.add(trayIcon);
|
systemTray.add(trayIcon);
|
||||||
} catch (AWTException | InterruptedException e) {
|
} catch (AWTException | InterruptedException e) {
|
||||||
Sysout.println(e.toString());
|
e.printStackTrace();
|
||||||
Sysout.println("!!! The test coudn't be performed !!!");
|
PassFailJFrame.forceFail("Exception caught: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}).start();
|
||||||
).start();
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
systemTray.add(trayIcon);
|
systemTray.add(trayIcon);
|
||||||
} catch (AWTException e) {
|
} catch (AWTException e) {
|
||||||
Sysout.println(e.toString());
|
e.printStackTrace();
|
||||||
Sysout.println("!!! The test coudn't be performed !!!");
|
PassFailJFrame.forceFail("Exception caught: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return frame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,6 @@
|
|||||||
* questions.
|
* 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.AWTException;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@ -42,7 +33,18 @@ import java.awt.image.BufferedImage;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.SwingUtilities;
|
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 {
|
public class ShowAfterDisposeTest {
|
||||||
|
private static SystemTray tray;
|
||||||
|
private static TrayIcon icon;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (!SystemTray.isSupported()) {
|
if (!SystemTray.isSupported()) {
|
||||||
throw new jtreg.SkippedException("The test cannot be run because SystemTray is not supported.");
|
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" +
|
"3) If the bug is reproducible then the test will fail without assistance.\n" +
|
||||||
"4) Just press the 'pass' button.";
|
"4) Just press the 'pass' button.";
|
||||||
|
|
||||||
|
try {
|
||||||
PassFailJFrame.builder()
|
PassFailJFrame.builder()
|
||||||
.title("Test Instructions Frame")
|
.title("Test Instructions Frame")
|
||||||
.instructions(instructions)
|
.instructions(instructions)
|
||||||
@ -73,6 +76,11 @@ public class ShowAfterDisposeTest {
|
|||||||
.testUI(ShowAfterDisposeTest::showFrameAndIcon)
|
.testUI(ShowAfterDisposeTest::showFrameAndIcon)
|
||||||
.build()
|
.build()
|
||||||
.awaitAndCheck();
|
.awaitAndCheck();
|
||||||
|
} finally {
|
||||||
|
if (tray != null) {
|
||||||
|
tray.remove(icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JFrame showFrameAndIcon() {
|
private static JFrame showFrameAndIcon() {
|
||||||
@ -87,8 +95,8 @@ public class ShowAfterDisposeTest {
|
|||||||
g.fillRect(6, 6, 20, 20);
|
g.fillRect(6, 6, 20, 20);
|
||||||
g.dispose();
|
g.dispose();
|
||||||
|
|
||||||
final SystemTray tray = SystemTray.getSystemTray();
|
tray = SystemTray.getSystemTray();
|
||||||
final TrayIcon icon = new TrayIcon(img);
|
icon = new TrayIcon(img);
|
||||||
icon.setImageAutoSize(true);
|
icon.setImageAutoSize(true);
|
||||||
icon.addActionListener(new ActionListener() {
|
icon.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent ev) {
|
public void actionPerformed(ActionEvent ev) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user