Skip to content

Commit a834b58

Browse files
committed
8269269: [macos11] SystemIconTest fails with ClassCastException
Backport-of: eab959cbfa9e781adac3bc4bc3e74af8b18a1fd5
1 parent 23326d5 commit a834b58

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

test/jdk/javax/swing/JFileChooser/FileSystemView/SystemIconTest.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,39 @@ static void negativeTests() {
7373
static void testSystemIcon(File file, boolean implComplete) {
7474
int[] sizes = new int[] {16, 32, 48, 64, 128};
7575
for (int size : sizes) {
76-
ImageIcon icon = (ImageIcon) fsv.getSystemIcon(file, size, size);
76+
Icon i = fsv.getSystemIcon(file, size, size);
7777

78+
if (i == null) {
79+
throw new RuntimeException(file.getAbsolutePath() + " icon is null");
80+
}
81+
82+
if (!(i instanceof ImageIcon)) {
83+
// Default UI resource icon returned - it is not covered
84+
// by new implementation so we can not test it
85+
continue;
86+
}
87+
88+
ImageIcon icon = (ImageIcon) i;
7889
//Enable below to see the icon
7990
//JLabel label = new JLabel(icon);
8091
//JOptionPane.showMessageDialog(null, label);
8192

82-
if (icon == null) {
83-
throw new RuntimeException("icon is null!!!");
84-
}
85-
8693
if (implComplete && icon.getIconWidth() != size) {
8794
throw new RuntimeException("Wrong icon size " +
88-
icon.getIconWidth() + " when requested " + size);
95+
icon.getIconWidth() + " when requested " + size +
96+
" for file " + file.getAbsolutePath());
8997
}
9098

9199
if (icon.getImage() instanceof MultiResolutionImage) {
92100
MultiResolutionImage mri = (MultiResolutionImage) icon.getImage();
93101
if (mri.getResolutionVariant(size, size) == null) {
94102
throw new RuntimeException("There is no suitable variant for the size "
95-
+ size + " in the multi resolution icon");
103+
+ size + " in the multi resolution icon " + file.getAbsolutePath());
96104
}
97105
} else {
98106
if (implComplete) {
99-
throw new RuntimeException("icon is supposed to be multi-resolution but it is not");
107+
throw new RuntimeException("icon is supposed to be" +
108+
" multi-resolution but it is not for " + file.getAbsolutePath());
100109
}
101110
}
102111
}

0 commit comments

Comments
 (0)