Index: src/test/api/java/common/javax/swing/text/ComponentViewTest.java =================================================================== --- src/test/api/java/common/javax/swing/text/ComponentViewTest.java (revision 496381) +++ src/test/api/java/common/javax/swing/text/ComponentViewTest.java (working copy) @@ -33,7 +33,11 @@ import javax.swing.JTextArea; import javax.swing.JTextPane; import javax.swing.SwingTestCase; +import javax.swing.text.Element; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.ListView; + public class ComponentViewTest extends SwingTestCase { StyledDocument document; @@ -649,6 +653,47 @@ } } + public void testSetParent_View() { + // Regression test for HARMONY-1767 + HTMLDocument doc = new HTMLDocument(); + Element e = doc.getDefaultRootElement(); + ComponentView obj = new ComponentView(new TestElement()); + obj.setParent(new ListView(e)); + } + + private class TestElement implements Element { + public boolean isLeaf() { + return false; + } + public Element getElement(int index) { + return null; + } + public int getElementCount() { + return 0; + } + public int getElementIndex(int offset) { + return 0; + } + public int getEndOffset() { + return 0; + } + public int getStartOffset() { + return 0; + } + public AttributeSet getAttributes() { + return null; + } + public String getName() { + return "AA"; + } + public Element getParentElement() { + return null; + } + public Document getDocument() { + return null; + } + } + private void checkBounds(final int x, final int y, final int height, final Shape box) { Rectangle bounds = box.getBounds(); assertEquals(x, bounds.x);