jdk/test/javax/swing/plaf/synth/Test6933784.java
changeset 5133 0a1777c5b601
child 5506 202f599c92aa
equal deleted inserted replaced
5132:34d52d014724 5133:0a1777c5b601
       
     1 /*
       
     2  * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    21  * have any questions.
       
    22  */
       
    23 
       
    24 /* @test
       
    25    @bug 6933784
       
    26    @summary NIMBUS: ImageView getNoImageIcon and getLoadingImageIcon returns nulls instead of an icon
       
    27    @author Pavel Porvatov
       
    28    @run main Test6933784
       
    29 */
       
    30 
       
    31 import javax.swing.*;
       
    32 import javax.swing.plaf.nimbus.NimbusLookAndFeel;
       
    33 import javax.swing.plaf.synth.SynthLookAndFeel;
       
    34 import javax.swing.text.Element;
       
    35 import javax.swing.text.html.HTMLDocument;
       
    36 import javax.swing.text.html.HTMLEditorKit;
       
    37 import javax.swing.text.html.ImageView;
       
    38 import java.io.StringReader;
       
    39 
       
    40 public class Test6933784 {
       
    41     public static void main(String[] args) throws Exception {
       
    42         UIManager.setLookAndFeel(new SynthLookAndFeel());
       
    43 
       
    44         checkImages();
       
    45 
       
    46         UIManager.setLookAndFeel(new NimbusLookAndFeel());
       
    47 
       
    48         checkImages();
       
    49     }
       
    50 
       
    51     private static void checkImages() throws Exception {
       
    52         SwingUtilities.invokeAndWait(new Runnable() {
       
    53             public void run() {
       
    54                 HTMLEditorKit c = new HTMLEditorKit();
       
    55                 HTMLDocument doc = new HTMLDocument();
       
    56 
       
    57                 try {
       
    58                     c.read(new StringReader("<HTML><TITLE>Test</TITLE><BODY><IMG id=test></BODY></HTML>"), doc, 0);
       
    59                 } catch (Exception e) {
       
    60                     throw new RuntimeException("The test failed", e);
       
    61                 }
       
    62 
       
    63                 Element elem = doc.getElement("test");
       
    64                 ImageView iv = new ImageView(elem);
       
    65 
       
    66                 if (iv.getLoadingImageIcon() == null) {
       
    67                     throw new RuntimeException("getLoadingImageIcon returns null");
       
    68                 }
       
    69 
       
    70                 if (iv.getNoImageIcon() == null) {
       
    71                     throw new RuntimeException("getNoImageIcon returns null");
       
    72                 }
       
    73             }
       
    74         });
       
    75     }
       
    76 }