Skip to content

Commit bf24a1e

Browse files
committed
8355366: Fix the wrong usage of PassFailJFrame.forcePass() in some manual tests
Backport-of: 2785570f5620db08c0d31cd29839f92ffabd58b2
1 parent 6fac8b3 commit bf24a1e

File tree

3 files changed

+39
-36
lines changed

3 files changed

+39
-36
lines changed

test/jdk/java/awt/Desktop/BrowseTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, 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
@@ -25,8 +25,8 @@
2525
* @test
2626
* @bug 6255196
2727
* @summary Verifies the function of method browse(java.net.URI uri).
28-
* @library /java/awt/regtesthelpers
29-
* @build PassFailJFrame
28+
* @library /java/awt/regtesthelpers /test/lib
29+
* @build PassFailJFrame jtreg.SkippedException
3030
* @run main/manual BrowseTest
3131
*/
3232

@@ -36,6 +36,8 @@
3636
import java.net.URI;
3737
import javax.swing.JPanel;
3838

39+
import jtreg.SkippedException;
40+
3941
public class BrowseTest extends JPanel {
4042
static final String INSTRUCTIONS = """
4143
This test could launch default file manager to open user's home
@@ -47,12 +49,6 @@ public class BrowseTest extends JPanel {
4749
""";
4850

4951
public BrowseTest() {
50-
if (!Desktop.isDesktopSupported()) {
51-
PassFailJFrame.log("Class java.awt.Desktop is not supported on " +
52-
"current platform. Farther testing will not be performed");
53-
PassFailJFrame.forcePass();
54-
}
55-
5652
Desktop desktop = Desktop.getDesktop();
5753

5854
URI dirURI = new File(System.getProperty("user.home")).toURI();
@@ -77,6 +73,11 @@ public BrowseTest() {
7773

7874
public static void main(String[] args) throws InterruptedException,
7975
InvocationTargetException {
76+
if (!Desktop.isDesktopSupported()) {
77+
throw new SkippedException("Class java.awt.Desktop is not supported " +
78+
"on current platform. Further testing will not be performed");
79+
}
80+
8081
PassFailJFrame.builder()
8182
.title("Browser Test")
8283
.splitUI(BrowseTest::new)

test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, 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
@@ -27,8 +27,8 @@
2727
* @bug 6255196
2828
* @summary Verifies the function of methods edit(java.io.File file) and
2929
* print(java.io.File file)
30-
* @library /java/awt/regtesthelpers
31-
* @build PassFailJFrame
30+
* @library /java/awt/regtesthelpers /test/lib
31+
* @build PassFailJFrame jtreg.SkippedException
3232
* @run main/manual EditAndPrintTest
3333
*/
3434

@@ -40,6 +40,8 @@
4040
import java.lang.reflect.InvocationTargetException;
4141
import javax.swing.JPanel;
4242

43+
import jtreg.SkippedException;
44+
4345
public class EditAndPrintTest extends JPanel {
4446

4547
static final String INSTRUCTIONS = """
@@ -49,20 +51,9 @@ public class EditAndPrintTest extends JPanel {
4951
If you see any EXCEPTION messages in the output press FAIL.
5052
""";
5153

52-
public EditAndPrintTest() {
53-
if (!Desktop.isDesktopSupported()) {
54-
PassFailJFrame.log("Class java.awt.Desktop is not supported on " +
55-
"current platform. Further testing will not be performed");
56-
PassFailJFrame.forcePass();
57-
}
58-
59-
Desktop desktop = Desktop.getDesktop();
60-
61-
if (!desktop.isSupported(Action.PRINT) && !desktop.isSupported(Action.EDIT)) {
62-
PassFailJFrame.log("Neither EDIT nor PRINT actions are supported. Nothing to test.");
63-
PassFailJFrame.forcePass();
64-
}
54+
static Desktop desktop;
6555

56+
public EditAndPrintTest() {
6657
/*
6758
* Part 1: print or edit a directory, which should throw an IOException.
6859
*/
@@ -111,7 +102,7 @@ public EditAndPrintTest() {
111102
writer.write("This is a temp file used to test print() method of Desktop.");
112103
writer.flush();
113104
writer.close();
114-
} catch (java.io.IOException ioe){
105+
} catch (IOException ioe){
115106
PassFailJFrame.log("EXCEPTION: " + ioe.getMessage());
116107
PassFailJFrame.forceFail("Failed to create temp file for testing.");
117108
}
@@ -139,6 +130,16 @@ public EditAndPrintTest() {
139130

140131
public static void main(String args[]) throws InterruptedException,
141132
InvocationTargetException {
133+
if (!Desktop.isDesktopSupported()) {
134+
throw new SkippedException("Class java.awt.Desktop is not supported " +
135+
"on current platform. Further testing will not be performed");
136+
}
137+
138+
desktop = Desktop.getDesktop();
139+
if (!desktop.isSupported(Action.PRINT) && !desktop.isSupported(Action.EDIT)) {
140+
throw new SkippedException("Neither EDIT nor PRINT actions are supported. Nothing to test.");
141+
}
142+
142143
PassFailJFrame.builder()
143144
.title("Edit and Print test")
144145
.splitUI(EditAndPrintTest::new)

test/jdk/java/awt/Desktop/OpenTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, 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
@@ -25,8 +25,8 @@
2525
* @test
2626
* @bug 6255196
2727
* @summary Verifies the function of method open(java.io.File file).
28-
* @library /java/awt/regtesthelpers
29-
* @build PassFailJFrame
28+
* @library /java/awt/regtesthelpers /test/lib
29+
* @build PassFailJFrame jtreg.SkippedException
3030
* @run main/manual/othervm OpenTest
3131
*/
3232

@@ -36,6 +36,8 @@
3636
import java.lang.reflect.InvocationTargetException;
3737
import javax.swing.JPanel;
3838

39+
import jtreg.SkippedException;
40+
3941
public class OpenTest extends JPanel {
4042

4143
static final String INSTRUCTIONS = """
@@ -48,12 +50,6 @@ public class OpenTest extends JPanel {
4850
""";
4951

5052
public OpenTest() {
51-
if (!Desktop.isDesktopSupported()) {
52-
PassFailJFrame.log("Class java.awt.Desktop is not supported on " +
53-
"current platform. Further testing will not be performed");
54-
PassFailJFrame.forcePass();
55-
}
56-
5753
Desktop desktop = Desktop.getDesktop();
5854

5955
/*
@@ -85,7 +81,7 @@ public OpenTest() {
8581
testFile = File.createTempFile("JDIC-test", ".txt",
8682
new File(System.getProperty("java.io.tmpdir")));
8783
testFile.deleteOnExit();
88-
} catch (java.io.IOException ioe) {
84+
} catch (IOException ioe) {
8985
PassFailJFrame.log("EXCEPTION: " + ioe.getMessage());
9086
PassFailJFrame.log("Failed to create test file");
9187
}
@@ -101,6 +97,11 @@ public OpenTest() {
10197

10298
public static void main(String[] args) throws InterruptedException,
10399
InvocationTargetException {
100+
if (!Desktop.isDesktopSupported()) {
101+
throw new SkippedException("Class java.awt.Desktop is not supported " +
102+
"on current platform. Further testing will not be performed");
103+
}
104+
104105
PassFailJFrame.builder()
105106
.title("Mail Test")
106107
.splitUI(OpenTest::new)

0 commit comments

Comments
 (0)