Skip to content

Commit dc85a3f

Browse files
committed
8015602: [macosx] Test javax/swing/SpringLayout/4726194/bug4726194.java fails on MacOSX
Reviewed-by: psadhukhan, pbansal
1 parent 1d245c6 commit dc85a3f

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

test/jdk/javax/swing/SpringLayout/4726194/bug4726194.java

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, 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,13 +25,22 @@
2525
* @test
2626
* @bug 4726194 7124209
2727
* @summary Tests for 4726194
28-
* @author Phil Milne
2928
*/
30-
import java.awt.*;
31-
import java.lang.reflect.InvocationTargetException;
32-
import java.util.*;
29+
30+
import java.awt.Font;
31+
import java.util.ArrayList;
32+
import java.util.Arrays;
3333
import java.util.List;
34-
import javax.swing.*;
34+
35+
import javax.swing.BorderFactory;
36+
import javax.swing.JTextField;
37+
import javax.swing.Spring;
38+
import javax.swing.SpringLayout;
39+
import javax.swing.SwingUtilities;
40+
import javax.swing.UIManager;
41+
import javax.swing.UnsupportedLookAndFeelException;
42+
43+
import static javax.swing.UIManager.getInstalledLookAndFeels;
3544

3645
public class bug4726194 {
3746

@@ -40,22 +49,29 @@ public class bug4726194 {
4049
private static int[] FAIL = new int[3];
4150
private static boolean TEST_DUPLICATES = false;
4251

43-
public static void main(String[] args) {
44-
try {
45-
SwingUtilities.invokeAndWait(new Runnable() {
46-
@Override
47-
public void run() {
48-
int minLevel = 2;
49-
int maxLevel = 2;
50-
for (int i = minLevel; i <= maxLevel; i++) {
51-
test(i, true);
52-
test(i, false);
53-
}
52+
public static void main(String[] args) throws Exception {
53+
for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
54+
SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
55+
SwingUtilities.invokeAndWait(() -> {
56+
int minLevel = 2;
57+
int maxLevel = 2;
58+
for (int i = minLevel; i <= maxLevel; i++) {
59+
test(i, true);
60+
test(i, false);
5461
}
5562
});
56-
} catch (InterruptedException | InvocationTargetException ex) {
57-
ex.printStackTrace();
58-
throw new RuntimeException("FAILED: SwingUtilities.invokeAndWait method failed!");
63+
}
64+
}
65+
66+
private static void setLookAndFeel(UIManager.LookAndFeelInfo laf) {
67+
try {
68+
System.out.println("LookAndFeel: " + laf.getClassName());
69+
UIManager.setLookAndFeel(laf.getClassName());
70+
} catch (UnsupportedLookAndFeelException ignored){
71+
System.out.println("Unsupported LookAndFeel: " + laf.getClassName());
72+
} catch (ClassNotFoundException | InstantiationException |
73+
IllegalAccessException e) {
74+
throw new RuntimeException(e);
5975
}
6076
}
6177

@@ -64,6 +80,7 @@ public static void test(int level, boolean horizontal) {
6480
String[] constraints = horizontal ? hConstraints : vConstraints;
6581
test(level, constraints, result, Arrays.asList(new Object[level]));
6682
JTextField tf = new JTextField("");
83+
tf.setBorder(BorderFactory.createEmptyBorder());
6784
tf.setFont(new Font("Dialog", Font.PLAIN, 6));
6885
System.out.print("\t\t");
6986
for (int j = 0; j < constraints.length; j++) {

0 commit comments

Comments
 (0)