--- old/test/javax/swing/JFileChooser/ShellFolderQueries/ShellFolderQueriesTest.java 2017-09-22 13:53:19.237318608 -0700 +++ new/test/javax/swing/JFileChooser/ShellFolderQueries/ShellFolderQueriesTest.java 2017-09-22 13:53:19.129316213 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 8081722 + * @bug 8081722 8182043 * @summary Provide public API for file hierarchy provided by * sun.awt.shell.ShellFolder * @author Semyon Sadetsky @@ -31,6 +31,7 @@ */ +import javax.swing.*; import javax.swing.filechooser.FileSystemView; import java.io.File; import java.io.FileNotFoundException; @@ -50,9 +51,11 @@ public static void main(String[] args) throws Exception { if(System.getProperty("os.name").toLowerCase().contains("windows")) { - System.out.println("Windows detected: will run shortcut test"); + System.out.println("Windows detected: will run shortcut " + + "and sytem icons tests"); testGet(); testLink(); + testSystemIcon(); } else { testGet(); } @@ -119,4 +122,33 @@ } } } + + static void testSystemIcon() { + try { + fsv.getSystemIcon(null, FileSystemView.FILE_ICON_SMALL); + } catch (NullPointerException e) { + String windir = System.getenv("windir"); + testSystemIcon(new File(windir)); + testSystemIcon(new File(windir + "/explorer.exe")); + return; + } + throw new RuntimeException("NPE was not thrown"); + } + + static void testSystemIcon(File file) { + ImageIcon icon = fsv.getSystemIcon(file, FileSystemView.FILE_ICON_SMALL); + System.out.println("Small icon size " + icon.getIconWidth()); + + icon = fsv.getSystemIcon(file, FileSystemView.FILE_ICON_LARGE); + System.out.println("Large icon size " + icon.getIconWidth()); + + int[] sizes = new int[] {16, 24, 32, 48, 64, 128, 50}; + for (int size : sizes) { + icon = fsv.getSystemIcon(file, size); + if (icon.getIconWidth() != size) { + throw new RuntimeException("Wrong icon size " + + icon.getIconWidth() + " when requested " + size); + } + } + } }