Search in sources :

Example 1 with AbstractElement

use of javax.swing.text.AbstractDocument.AbstractElement in project jdk8u_jdk by JetBrains.

the class bug7165725 method execute.

public void execute(final String urlStr, final GoldenElement goldenElement) throws Exception {
    System.out.println();
    System.out.println("***** TEST: " + urlStr + " *****");
    System.out.println();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            try {
                editorPane = new JEditorPane();
                editorPane.setEditorKit(new HTMLEditorKit() {

                    public Document createDefaultDocument() {
                        AbstractDocument doc = (AbstractDocument) super.createDefaultDocument();
                        doc.setAsynchronousLoadPriority(-1);
                        return doc;
                    }
                });
                editorPane.setPage(new URL(urlStr));
            } catch (IOException ex) {
                throw new RuntimeException("Test failed", ex);
            }
            editorPane.setEditable(false);
            JScrollPane scroller = new JScrollPane();
            JViewport vp = scroller.getViewport();
            vp.add(editorPane);
            add(scroller, BorderLayout.CENTER);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setSize(400, 400);
            setLocationRelativeTo(null);
            setVisible(true);
        }
    });
    ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            HTMLDocument doc = (HTMLDocument) editorPane.getDocument();
            doc.dump(System.out);
            goldenElement.checkStructureEquivalence((AbstractElement) doc.getDefaultRootElement());
            dispose();
        }
    });
    System.out.println();
    System.out.println("*********************************");
    System.out.println();
}
Also used : AbstractDocument(javax.swing.text.AbstractDocument) AbstractElement(javax.swing.text.AbstractDocument.AbstractElement) HTMLDocument(javax.swing.text.html.HTMLDocument) SunToolkit(sun.awt.SunToolkit) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

IOException (java.io.IOException)1 URL (java.net.URL)1 AbstractDocument (javax.swing.text.AbstractDocument)1 AbstractElement (javax.swing.text.AbstractDocument.AbstractElement)1 HTMLDocument (javax.swing.text.html.HTMLDocument)1 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)1 SunToolkit (sun.awt.SunToolkit)1