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