Index: modules/swing/src/test/api/java/common/javax/swing/text/ComponentViewTest.java =================================================================== --- modules/swing/src/test/api/java/common/javax/swing/text/ComponentViewTest.java (revision 499345) +++ modules/swing/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.PlainDocument; +import javax.swing.text.PlainView; + public class ComponentViewTest extends SwingTestCase { StyledDocument document; @@ -649,6 +653,47 @@ } } + public void testSetParent_View() { + // Regression test for HARMONY-1767 + PlainDocument doc = new PlainDocument(); + Element e = doc.getDefaultRootElement(); + ComponentView obj = new ComponentView(new TestElement()); + obj.setParent(new PlainView(e)); + } + + private static 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); @@ -688,4 +733,4 @@ assertEquals(position, componentElement.getStartOffset()); } } -} \ No newline at end of file +}