Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 71748 invoked from network); 26 Nov 2006 20:18:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Nov 2006 20:18:04 -0000 Received: (qmail 20792 invoked by uid 500); 26 Nov 2006 20:18:12 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 20761 invoked by uid 500); 26 Nov 2006 20:18:12 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 20726 invoked by uid 99); 26 Nov 2006 20:18:11 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Nov 2006 12:18:11 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Nov 2006 12:17:51 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id A82421A985D; Sun, 26 Nov 2006 12:16:18 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r479418 [28/43] - in /harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common: javax/swing/ javax/swing/border/ javax/swing/colorchooser/ javax/swing/event/ javax/swing/filechooser/ javax/swing/plaf/ javax/swing/plaf/basic/ j... Date: Sun, 26 Nov 2006 20:15:55 -0000 To: commits@harmony.apache.org From: ndbeyer@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061126201618.A82421A985D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementsAndAttributesTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementsAndAttributesTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementsAndAttributesTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementsAndAttributesTest.java Sun Nov 26 12:15:43 2006 @@ -21,10 +21,8 @@ package javax.swing.text; import java.awt.Color; - import javax.swing.BasicSwingTestCase; import javax.swing.text.AbstractDocument.AbstractElement; - import junit.framework.TestCase; /** @@ -34,18 +32,26 @@ */ public class DefaultStyledDocument_ElementsAndAttributesTest extends TestCase { private DefaultStyledDocument doc; + private Element root; + private StyleContext styles; private AttributeSet plain; + private AttributeSet bold; + private AttributeSet italic; + private AttributeSet boldItalic; + private AttributeSet background; + private AttributeSet foreground; private static final class StyledText { public final String text; + public final AttributeSet attr; public StyledText(final String text, final AttributeSet attr) { @@ -54,13 +60,12 @@ } } + @Override protected void setUp() throws Exception { super.setUp(); - styles = new StyleContext(); doc = new DefaultStyledDocument(styles); root = doc.getDefaultRootElement(); - initAttributes(); initText(); } @@ -68,32 +73,23 @@ private void initAttributes() { plain = styles.getEmptySet(); bold = styles.addAttribute(plain, StyleConstants.Bold, Boolean.TRUE); - italic = styles.addAttribute(plain, - StyleConstants.Italic, Boolean.TRUE); - boldItalic = styles.addAttribute(bold, - StyleConstants.Italic, Boolean.TRUE); - + italic = styles.addAttribute(plain, StyleConstants.Italic, Boolean.TRUE); + boldItalic = styles.addAttribute(bold, StyleConstants.Italic, Boolean.TRUE); foreground = background = styles.getEmptySet(); - foreground = styles.addAttribute(foreground, - StyleConstants.Foreground, - Color.CYAN); - background = styles.addAttribute(background, - StyleConstants.Background, - Color.BLUE); + foreground = styles.addAttribute(foreground, StyleConstants.Foreground, Color.CYAN); + background = styles.addAttribute(background, StyleConstants.Background, Color.BLUE); } private void initText() throws BadLocationException { final StyledText[] styledText = new StyledText[] { - // First paragraph - new StyledText("plain", plain), - new StyledText("bold", bold), - new StyledText("italic\n", italic), - // Second and Third - new StyledText("Bold & Italic", boldItalic), - new StyledText(" & Plain\n", plain), - new StyledText("The very plain text", null) - }; - + // First paragraph + new StyledText("plain", plain), + new StyledText("bold", bold), + new StyledText("italic\n", italic), + // Second and Third + new StyledText("Bold & Italic", boldItalic), + new StyledText(" & Plain\n", plain), + new StyledText("The very plain text", null) }; int offset = 0; for (int i = 0; i < styledText.length; i++) { doc.insertString(offset, styledText[i].text, styledText[i].attr); @@ -199,13 +195,11 @@ * General checks for getLogicalStyle(). */ public void testGetLogicalStyle01() { - final StyleContext styles = (StyleContext)doc.getAttributeContext(); - assertSame(styles.getStyle(StyleContext.DEFAULT_STYLE), - doc.getLogicalStyle(5)); + final StyleContext styles = (StyleContext) doc.getAttributeContext(); + assertSame(styles.getStyle(StyleContext.DEFAULT_STYLE), doc.getLogicalStyle(5)); final Element par = doc.getParagraphElement(5); final AttributeSet parAttrs = par.getAttributes(); - assertSame(parAttrs.getAttribute(AttributeSet.ResolveAttribute), - doc.getLogicalStyle(5)); + assertSame(parAttrs.getAttribute(AttributeSet.ResolveAttribute), doc.getLogicalStyle(5)); } /** @@ -214,9 +208,7 @@ public void testGetLogicalStyle02() { final StyleContext context = new StyleContext(); final Style style = context.addStyle("aStyle", null); - - final AbstractElement par = (AbstractElement)doc.getParagraphElement(5); - + final AbstractElement par = (AbstractElement) doc.getParagraphElement(5); doc.writeLock(); try { par.addAttribute(AttributeSet.ResolveAttribute, style); @@ -231,7 +223,7 @@ * to non-Style object. */ public void testGetLogicalStyle03() { - final AbstractElement par = (AbstractElement)doc.getParagraphElement(5); + final AbstractElement par = (AbstractElement) doc.getParagraphElement(5); final MutableAttributeSet set = new SimpleAttributeSet(); StyleConstants.setForeground(set, Color.GREEN); StyleConstants.setBackground(set, Color.YELLOW); @@ -262,13 +254,11 @@ doc.setCharacterAttributes(3, 8, foreground, false); final Element par = doc.getParagraphElement(0); assertEquals(5, par.getElementCount()); - assertEquals(plain, par.getElement(0).getAttributes()); assertEquals(foreground, par.getElement(1).getAttributes()); - assertEquals(styles.addAttributes(bold, foreground), - par.getElement(2).getAttributes()); - assertEquals(styles.addAttributes(italic, foreground), - par.getElement(3).getAttributes()); + assertEquals(styles.addAttributes(bold, foreground), par.getElement(2).getAttributes()); + assertEquals(styles.addAttributes(italic, foreground), par.getElement(3) + .getAttributes()); assertEquals(italic, par.getElement(4).getAttributes()); } @@ -280,24 +270,19 @@ doc.setCharacterAttributes(3, 8, foreground, false); final Element par = doc.getParagraphElement(0); assertEquals(5, par.getElementCount()); - Element span = par.getElement(0); // Plain (no attributes) assertEquals(0, span.getStartOffset()); assertEquals(3, span.getEndOffset()); - - span = par.getElement(1); // Foreground only + span = par.getElement(1); // Foreground only assertEquals(3, span.getStartOffset()); assertEquals(5, span.getEndOffset()); - - span = par.getElement(2); // Bold + Foreground + span = par.getElement(2); // Bold + Foreground assertEquals(5, span.getStartOffset()); assertEquals(9, span.getEndOffset()); - - span = par.getElement(3); // Italic + Foreground + span = par.getElement(3); // Italic + Foreground assertEquals(9, span.getStartOffset()); assertEquals(11, span.getEndOffset()); - - span = par.getElement(4); // Italic only + span = par.getElement(4); // Italic only assertEquals(11, span.getStartOffset()); assertEquals(16, span.getEndOffset()); } @@ -311,7 +296,6 @@ doc.setCharacterAttributes(3, 8, background, true); final Element par = doc.getParagraphElement(0); assertEquals(5, par.getElementCount()); - assertEquals(plain, par.getElement(0).getAttributes()); assertEquals(background, par.getElement(1).getAttributes()); assertEquals(background, par.getElement(2).getAttributes()); @@ -327,22 +311,19 @@ doc.setCharacterAttributes(3, 8, background, true); final Element par = doc.getParagraphElement(0); assertEquals(5, par.getElementCount()); - Element span = par.getElement(0); // Plain (no attributes) assertEquals(0, span.getStartOffset()); assertEquals(3, span.getEndOffset()); - - span = par.getElement(1); // Background only + span = par.getElement(1); // Background only assertEquals(3, span.getStartOffset()); assertEquals(5, span.getEndOffset()); - span = par.getElement(2); // Background only + span = par.getElement(2); // Background only assertEquals(5, span.getStartOffset()); assertEquals(9, span.getEndOffset()); - span = par.getElement(3); // Background only + span = par.getElement(3); // Background only assertEquals(9, span.getStartOffset()); assertEquals(11, span.getEndOffset()); - - span = par.getElement(4); // Italic only + span = par.getElement(4); // Italic only assertEquals(11, span.getStartOffset()); assertEquals(16, span.getEndOffset()); } @@ -354,9 +335,9 @@ public void testSetCharacterAttributes05() { try { doc.setCharacterAttributes(3, 8, null, false); - fail("NullPointerException is expected."); - } catch (NullPointerException e) { } + } catch (NullPointerException e) { + } } /** @@ -366,9 +347,9 @@ public void testSetCharacterAttributes06() { try { doc.setCharacterAttributes(3, 8, null, true); - fail("NullPointerException is expected."); - } catch (NullPointerException e) { } + } catch (NullPointerException e) { + } } public void testSetLogicalStyle() { @@ -376,14 +357,12 @@ final Style logicalStyle = context.addStyle("aStyle", null); logicalStyle.addAttribute(StyleConstants.Foreground, Color.CYAN); logicalStyle.addAttribute(StyleConstants.Background, Color.BLUE); - doc.setLogicalStyle(16, logicalStyle); assertNotSame(logicalStyle, doc.getLogicalStyle(15)); // 1st par end - 1 - assertSame(logicalStyle, doc.getLogicalStyle(16)); // 2nd par start - assertSame(logicalStyle, doc.getLogicalStyle(37)); // 2nd par end - 1 + assertSame(logicalStyle, doc.getLogicalStyle(16)); // 2nd par start + assertSame(logicalStyle, doc.getLogicalStyle(37)); // 2nd par end - 1 assertNotSame(logicalStyle, doc.getLogicalStyle(38)); // 3rd par start - assertSame(doc.getStyle(StyleContext.DEFAULT_STYLE), - doc.getLogicalStyle(38)); + assertSame(doc.getStyle(StyleContext.DEFAULT_STYLE), doc.getLogicalStyle(38)); } public void testSetLogicalStyleInvalid() { @@ -392,11 +371,10 @@ logicalStyle.addAttribute(StyleConstants.Foreground, Color.CYAN); logicalStyle.addAttribute(StyleConstants.Background, Color.BLUE); final Style defaultStyle = doc.getStyle(StyleContext.DEFAULT_STYLE); - doc.setLogicalStyle(-2, logicalStyle); - assertSame(logicalStyle, doc.getLogicalStyle(0)); // 1st par end - 1 - assertSame(defaultStyle, doc.getLogicalStyle(16)); // 2nd par start - assertSame(defaultStyle, doc.getLogicalStyle(37)); // 2nd par end - 1 + assertSame(logicalStyle, doc.getLogicalStyle(0)); // 1st par end - 1 + assertSame(defaultStyle, doc.getLogicalStyle(16)); // 2nd par start + assertSame(defaultStyle, doc.getLogicalStyle(37)); // 2nd par end - 1 assertSame(defaultStyle, doc.getLogicalStyle(38)); doc.setLogicalStyle(doc.getLength() + 2, logicalStyle); assertSame(logicalStyle, doc.getLogicalStyle(doc.getLength())); @@ -408,14 +386,10 @@ public void testSetParagraphAttributes01() { doc.setParagraphAttributes(3, 13, foreground, false); assertFalse(doc.getLogicalStyle(3).containsAttributes(foreground)); - // The paragraph itself contains attributes, but not its resolve parent - assertTrue(root.getElement(0).getAttributes() - .containsAttributes(foreground)); - assertFalse(root.getElement(1).getAttributes() - .containsAttributes(foreground)); - assertFalse(root.getElement(2).getAttributes() - .containsAttributes(foreground)); + assertTrue(root.getElement(0).getAttributes().containsAttributes(foreground)); + assertFalse(root.getElement(1).getAttributes().containsAttributes(foreground)); + assertFalse(root.getElement(2).getAttributes().containsAttributes(foreground)); } /** @@ -425,13 +399,9 @@ doc.setParagraphAttributes(3, 14, foreground, false); assertFalse(doc.getLogicalStyle(3).containsAttributes(foreground)); assertFalse(doc.getLogicalStyle(3 + 14).containsAttributes(foreground)); - - assertTrue(root.getElement(0).getAttributes() - .containsAttributes(foreground)); - assertTrue(root.getElement(1).getAttributes() - .containsAttributes(foreground)); - assertFalse(root.getElement(2).getAttributes() - .containsAttributes(foreground)); + assertTrue(root.getElement(0).getAttributes().containsAttributes(foreground)); + assertTrue(root.getElement(1).getAttributes().containsAttributes(foreground)); + assertFalse(root.getElement(2).getAttributes().containsAttributes(foreground)); } /** @@ -444,7 +414,6 @@ // The attributes fully replaced including resolve parent assertNull(doc.getLogicalStyle(3)); assertEquals(background, root.getElement(0).getAttributes()); - final Style defaultStyle = doc.getStyle(StyleContext.DEFAULT_STYLE); assertSame(defaultStyle, doc.getLogicalStyle(16)); assertSame(defaultStyle, doc.getLogicalStyle(38)); @@ -456,54 +425,53 @@ public void testSetParagraphAttributes04() { try { doc.setParagraphAttributes(3, 1, null, false); - fail("NullPointerException is expected"); - } catch (NullPointerException e) { } + } catch (NullPointerException e) { + } } } - /* The dump of the document used in these tests (after setUp()). -
- - - [0,5][plain] - - [5,9][bold] - - [9,16][italic -] - - - [16,29][Bold & Italic] - - [29,38][ & Plain -] - - - [38,57][The very plain text] - - [57,58][ -] - - - [0,58][plainbolditalic -Bold & Italic & Plain -Th...] +
+ + + [0,5][plain] + + [5,9][bold] + + [9,16][italic + ] + + + [16,29][Bold & Italic] + + [29,38][ & Plain + ] + + + [38,57][The very plain text] + + [57,58][ + ] + + + [0,58][plainbolditalic + Bold & Italic & Plain + Th...] -*/ + */ Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_SectionElementTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_SectionElementTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_SectionElementTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_SectionElementTest.java Sun Nov 26 12:15:43 2006 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** * @author Alexey A. Ivanov * @version $Revision$ @@ -22,7 +21,6 @@ package javax.swing.text; import javax.swing.text.DefaultStyledDocument.SectionElement; - import junit.framework.TestCase; /** @@ -31,7 +29,8 @@ */ public class DefaultStyledDocument_SectionElementTest extends TestCase { private DefaultStyledDocument doc; - private SectionElement section; + + private SectionElement section; public void testGetName() { assertSame(AbstractDocument.SectionElementName, section.getName()); @@ -44,10 +43,10 @@ assertEquals(0, section.getElementCount()); } + @Override protected void setUp() throws Exception { super.setUp(); doc = new DefaultStyledDocument(); section = doc.new SectionElement(); } - } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_StylesAndStdAttrsTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_StylesAndStdAttrsTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_StylesAndStdAttrsTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_StylesAndStdAttrsTest.java Sun Nov 26 12:15:43 2006 @@ -23,11 +23,9 @@ import java.awt.Color; import java.awt.Font; import java.util.Enumeration; - import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.StyleContext.NamedStyle; - import junit.framework.TestCase; /** @@ -37,11 +35,15 @@ */ public class DefaultStyledDocument_StylesAndStdAttrsTest extends TestCase { private DefaultStyledDocument doc; + private StyleContext styles; + private AttributeSet attrSet; private boolean getBackground; + private boolean getFont; + private boolean getForeground; private static final String STYLE_NAME = "aStyle"; @@ -75,20 +77,18 @@ } public void testGetStyleNames() { - final String[] names = new String[] {"one", "two", "three"}; + final String[] names = new String[] { "one", "two", "three" }; for (int i = 0; i < names.length; i++) { styles.addStyle(names[i], null); } - boolean[] found = new boolean[names.length]; - Enumeration styleNames = doc.getStyleNames(); + Enumeration styleNames = doc.getStyleNames(); while (styleNames.hasMoreElements()) { Object name = styleNames.nextElement(); for (int i = 0; i < names.length; i++) { found[i] = found[i] || name.equals(names[i]); } } - for (int i = 0; i < found.length; i++) { assertTrue("@ " + i, found[i]); } @@ -104,69 +104,69 @@ public void testStyleChanged() { final Style[] changed = new Style[1]; doc = new DefaultStyledDocument() { + private static final long serialVersionUID = 1L; + + @Override protected void styleChanged(final Style style) { changed[0] = style; super.styleChanged(style); } }; - styles = (StyleContext)doc.getAttributeContext(); - - final NamedStyle aStyle = (NamedStyle)doc.addStyle(STYLE_NAME, null); - + styles = (StyleContext) doc.getAttributeContext(); + final NamedStyle aStyle = (NamedStyle) doc.addStyle(STYLE_NAME, null); assertEquals(0, styles.getChangeListeners().length); assertEquals(0, aStyle.listenerList.getListenerCount()); - final DocumentListener listener = new DocumentListener() { public void insertUpdate(DocumentEvent e) { } + public void removeUpdate(DocumentEvent e) { } + public void changedUpdate(DocumentEvent e) { } }; doc.addDocumentListener(listener); - assertEquals(1, styles.getChangeListeners().length); assertEquals(1, aStyle.listenerList.getListenerCount()); - - final NamedStyle anotherStyle = - (NamedStyle)styles.addStyle("otherStyle", aStyle); + final NamedStyle anotherStyle = (NamedStyle) styles.addStyle("otherStyle", aStyle); assertEquals(1, anotherStyle.listenerList.getListenerCount()); - - final NamedStyle nullStyle = (NamedStyle)styles.addStyle(null, null); + final NamedStyle nullStyle = (NamedStyle) styles.addStyle(null, null); assertEquals(0, nullStyle.listenerList.getListenerCount()); - - assertNull(changed[0]); aStyle.addAttribute("key", "value"); assertSame(aStyle, changed[0]); - doc.removeDocumentListener(listener); assertEquals(0, styles.getChangeListeners().length); assertEquals(0, aStyle.listenerList.getListenerCount()); assertEquals(0, anotherStyle.listenerList.getListenerCount()); } + @Override protected void setUp() throws Exception { super.setUp(); doc = new DefaultStyledDocument(new StyleContext() { + private static final long serialVersionUID = 1L; + + @Override public Color getBackground(AttributeSet as) { getBackground = true; return super.getBackground(as); } + @Override public Font getFont(AttributeSet as) { getFont = true; return super.getFont(as); } + @Override public Color getForeground(AttributeSet as) { getForeground = true; return super.getForeground(as); } }); - styles = (StyleContext)doc.getAttributeContext(); + styles = (StyleContext) doc.getAttributeContext(); attrSet = styles.getEmptySet(); } - } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DocumentTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DocumentTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DocumentTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DocumentTest.java Sun Nov 26 12:15:43 2006 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** * @author Alexey A. Ivanov * @version $Revision$ @@ -24,7 +23,6 @@ import junit.framework.TestCase; public class DocumentTest extends TestCase { - public static void main(final String[] args) { junit.textui.TestRunner.run(DocumentTest.class); } @@ -36,5 +34,4 @@ public void testTitleProperty() { assertEquals("title", Document.TitleProperty); } - } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/EditorKitTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/EditorKitTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/EditorKitTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/EditorKitTest.java Sun Nov 26 12:15:43 2006 @@ -27,12 +27,10 @@ import java.io.OutputStream; import java.io.Reader; import java.io.Writer; - import javax.swing.Action; import javax.swing.SwingTestCase; public class EditorKitTest extends SwingTestCase { - protected EditorKit kit = null; public static void main(final String[] args) { @@ -42,43 +40,58 @@ /* * @see TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); - kit = new EditorKit() { + private static final long serialVersionUID = 1L; + protected int i = 0; + @Override public Caret createCaret() { return null; } + @Override public Document createDefaultDocument() { return null; } + @Override public Action[] getActions() { return null; } + @Override public String getContentType() { return i + ""; } + @Override public ViewFactory getViewFactory() { i += 100; return null; } - public void read(final InputStream in, final Document doc, final int pos) throws IOException, BadLocationException { + @Override + public void read(final InputStream in, final Document doc, final int pos) + throws IOException, BadLocationException { } - public void read(final Reader in, final Document doc, final int pos) throws IOException, BadLocationException { + @Override + public void read(final Reader in, final Document doc, final int pos) + throws IOException, BadLocationException { } - public void write(final OutputStream out, final Document doc, final int pos, final int len) throws IOException, BadLocationException { + @Override + public void write(final OutputStream out, final Document doc, final int pos, + final int len) throws IOException, BadLocationException { } - public void write(final Writer out, final Document doc, final int pos, final int len) throws IOException, BadLocationException { + @Override + public void write(final Writer out, final Document doc, final int pos, final int len) + throws IOException, BadLocationException { } }; } @@ -89,7 +102,8 @@ public void testClone() { kit.getViewFactory(); assertTrue("cloned", kit.clone() != null); - assertEquals("cloned field", kit.getContentType(), ((EditorKit)kit.clone()).getContentType()); + assertEquals("cloned field", kit.getContentType(), ((EditorKit) kit.clone()) + .getContentType()); } public void testDeinstall() { @@ -97,5 +111,4 @@ public void testInstall() { } - } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ElementIteratorTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ElementIteratorTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ElementIteratorTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ElementIteratorTest.java Sun Nov 26 12:15:43 2006 @@ -15,28 +15,37 @@ * limitations under the License. */ /** -* @author Alexander T. Simbirtsev -* @version $Revision$ -*/ + * @author Alexander T. Simbirtsev + * @version $Revision$ + */ package javax.swing.text; import javax.swing.BasicSwingTestCase; public class ElementIteratorTest extends BasicSwingTestCase { - protected ElementIterator iterator; + protected AbstractDocument doc; protected Element root; + protected Element branch1; + protected Element branch2; + protected Element leaf1; + protected Element leaf2; + protected Element leaf3; + protected Element leaf4; + protected Element leaf5; + protected Element leaf6; + @Override protected void setUp() throws Exception { super.setUp(); doc = new DefaultStyledDocument(); @@ -48,7 +57,6 @@ doc.insertString(2, "XX", attr2); doc.insertString(4, "\n00", attr1); doc.insertString(7, "XX", attr2); - root = doc.getRootElements()[0]; branch1 = root.getElement(0); leaf1 = branch1.getElement(0); @@ -61,6 +69,7 @@ iterator = new ElementIterator(doc); } + @Override protected void tearDown() throws Exception { super.tearDown(); } @@ -71,7 +80,6 @@ public void testElementIteratorDocument() { assertSame(root, iterator.current()); assertNull(iterator.previous()); - iterator.next(); assertSame(root, iterator.first()); assertNull(iterator.previous()); @@ -89,12 +97,10 @@ assertSame(leaf3, iterator.next()); assertNull(iterator.next()); assertSame(branch1, iterator.first()); - iterator = new ElementIterator(leaf1); assertSame(leaf1, iterator.current()); assertNull(iterator.next()); assertNull(iterator.previous()); - iterator = new ElementIterator(leaf1); assertSame(leaf1, iterator.next()); assertNull(iterator.current()); @@ -171,7 +177,6 @@ */ public void testDepth() throws BadLocationException { assertEquals(0, iterator.depth()); - iterator.current(); assertEquals(1, iterator.depth()); iterator.next(); @@ -192,10 +197,8 @@ assertEquals(3, iterator.depth()); iterator.next(); assertEquals(0, iterator.depth()); - iterator.first(); assertEquals(1, iterator.depth()); - iterator = new ElementIterator(doc.getBidiRootElement()); assertEquals(0, iterator.depth()); iterator.next(); @@ -213,17 +216,13 @@ iterator = new ElementIterator(branch2); iterator.current(); iterator.next(); - - ElementIterator cloned = (ElementIterator)iterator.clone(); + ElementIterator cloned = (ElementIterator) iterator.clone(); assertSame(leaf4, cloned.current()); assertSame(branch2, cloned.previous()); assertSame(leaf5, cloned.next()); assertSame(leaf6, cloned.next()); assertNull(cloned.next()); - assertSame(leaf4, iterator.current()); - assertSame(branch2, cloned.first()); } - } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/EmptyAttributeSetTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/EmptyAttributeSetTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/EmptyAttributeSetTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/EmptyAttributeSetTest.java Sun Nov 26 12:15:43 2006 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** * @author Alexey A. Ivanov * @version $Revision$ @@ -23,25 +22,25 @@ import java.util.Enumeration; import java.util.NoSuchElementException; - import javax.swing.BasicSwingTestCase; - import junit.framework.TestCase; public class EmptyAttributeSetTest extends TestCase { /** * Shared instance of EmptyAttributeSet class. */ - private static final AttributeSet empty = SimpleAttributeSet.EMPTY; + private static final AttributeSet empty = SimpleAttributeSet.EMPTY; + /** * Shared instance of SimpleAttributeSet class. */ private static final SimpleAttributeSet simple = new SimpleAttributeSet(); + /** * Shared instance of StyleContext.SmallAttributeSet class. */ - private static final StyleContext.SmallAttributeSet small = - new StyleContext().new SmallAttributeSet(empty); + private static final StyleContext.SmallAttributeSet small = new StyleContext().new SmallAttributeSet( + empty); public EmptyAttributeSetTest(final String name) { super(name); @@ -82,14 +81,14 @@ } public void testGetAttributeNames() { - Enumeration names = empty.getAttributeNames(); + Enumeration names = empty.getAttributeNames(); assertNotNull(names); assertFalse(names.hasMoreElements()); try { names.nextElement(); - fail("NoSuchElementException should be thrown"); - } catch (NoSuchElementException e) { } + } catch (NoSuchElementException e) { + } } public void testGetResolveParent() { @@ -113,9 +112,8 @@ public void testToString() { final String expected; - expected = BasicSwingTestCase.isHarmony() - ? "javax.swing.text.EmptyAttributeSet@0" - : "javax.swing.text.SimpleAttributeSet$EmptyAttributeSet@0"; + expected = BasicSwingTestCase.isHarmony() ? "javax.swing.text.EmptyAttributeSet@0" + : "javax.swing.text.SimpleAttributeSet$EmptyAttributeSet@0"; assertEquals(expected, empty.toString()); } } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FieldViewTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FieldViewTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FieldViewTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FieldViewTest.java Sun Nov 26 12:15:43 2006 @@ -33,17 +33,18 @@ FieldView fv; + @Override protected void setUp() throws Exception { super.setUp(); jf = new JFrame(); jtf = new JTextField("JTextField for FieldView testing"); jf.getContentPane().add(jtf); - fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf) - .getView(0); + fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf).getView(0); jf.setSize(200, 100); jf.pack(); } + @Override protected void tearDown() throws Exception { jf.dispose(); super.tearDown(); @@ -52,14 +53,11 @@ public void testGetPreferredSpan() { FontMetrics fm = fv.getFontMetrics(); assertEquals(fm.getHeight(), (int) fv.getPreferredSpan(View.Y_AXIS)); - assertEquals(fm.stringWidth(jtf.getText()), (int) fv - .getPreferredSpan(View.X_AXIS)); + assertEquals(fm.stringWidth(jtf.getText()), (int) fv.getPreferredSpan(View.X_AXIS)); jtf.setFont(new java.awt.Font("SimSun", 0, 12)); - fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf) - .getView(0); + fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf).getView(0); fm = jtf.getFontMetrics(jtf.getFont()); - assertEquals(fm.stringWidth(jtf.getText()), (int) fv - .getPreferredSpan(View.X_AXIS)); + assertEquals(fm.stringWidth(jtf.getText()), (int) fv.getPreferredSpan(View.X_AXIS)); } public void testGetResizeWeight() { @@ -71,8 +69,7 @@ public void testGetFontMetrics() { assertEquals(jtf.getFontMetrics(jtf.getFont()), fv.getFontMetrics()); jtf.setFont(new java.awt.Font("SimSun", 0, 12)); - fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf) - .getView(0); + fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf).getView(0); assertEquals(jtf.getFontMetrics(jtf.getFont()), fv.getFontMetrics()); } } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowViewTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowViewTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowViewTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowViewTest.java Sun Nov 26 12:15:43 2006 @@ -23,7 +23,6 @@ import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; - import javax.swing.BasicSwingTestCase; import javax.swing.SizeRequirements; import javax.swing.event.DocumentEvent; @@ -37,7 +36,6 @@ * */ public class FlowViewTest extends BasicSwingTestCase { - protected static class FlowViewImpl extends FlowView { private int count = 0; @@ -45,32 +43,36 @@ super(element, axis); } + @Override protected View createRow() { - return new BoxView(getElement(), - getAxis() == Y_AXIS ? X_AXIS : Y_AXIS) { + return new BoxView(getElement(), getAxis() == Y_AXIS ? X_AXIS : Y_AXIS) { private final int id = count++; + @Override public String toString() { return "row(" + id + ")"; } + @Override protected void loadChildren(ViewFactory factory) { return; } + @Override public int getStartOffset() { - return getViewCount() > 0 ? getView(0).getStartOffset() - : super.getStartOffset(); + return getViewCount() > 0 ? getView(0).getStartOffset() : super + .getStartOffset(); } + @Override public int getEndOffset() { int count = getViewCount(); - return count > 0 ? getView(count - 1).getEndOffset() - : super.getEndOffset(); + return count > 0 ? getView(count - 1).getEndOffset() : super.getEndOffset(); } }; } + @Override public String toString() { return "flow"; } @@ -84,24 +86,29 @@ } public FlowViewImplWithFactory(final Element element, final int axis, - final ViewFactory factory) { + final ViewFactory factory) { super(element, axis); this.factory = factory; } + @Override public ViewFactory getViewFactory() { return factory; } + @Override public String toString() { return "theFlow"; } } private Document doc; + private Element root; + private FlowView view; + @Override protected void setUp() throws Exception { super.setUp(); doc = new PlainDocument(); @@ -115,10 +122,8 @@ assertNull(view.layoutPool); assertEquals(0, view.getViewCount()); assertNull(view.getViewFactory()); - final View parent = new BoxView(root, View.X_AXIS); view.setParent(parent); - assertNotNull(view.getParent()); assertEquals(0, view.getViewCount()); assertNotNull(view.layoutPool); @@ -129,15 +134,12 @@ public void testSetParentWithFactory() { view = new FlowViewImplWithFactory(root, View.Y_AXIS); - assertNull(view.getParent()); assertNull(view.layoutPool); assertEquals(0, view.getViewCount()); assertNotNull(view.getViewFactory()); - final View parent = new BoxView(root, View.X_AXIS); view.setParent(parent); - assertNotNull(view.getParent()); assertEquals(0, view.getViewCount()); assertNotNull(view.layoutPool); @@ -156,12 +158,8 @@ final Element first = root.getElement(0); final Element second = root.getElement(1); final int middle = (first.getStartOffset() + first.getEndOffset()) / 2; - View[] views = new View[] { - vf.create(first), - vf.create(second) - }; + View[] views = new View[] { vf.create(first), vf.create(second) }; view.replace(0, 0, views); - assertEquals(-1, view.getViewIndexAtPosition(-1)); assertEquals(0, view.getViewIndexAtPosition(first.getStartOffset())); assertEquals(0, view.getViewIndexAtPosition(middle)); @@ -169,9 +167,7 @@ assertEquals(1, view.getViewIndexAtPosition(second.getStartOffset())); assertEquals(1, view.getViewIndexAtPosition(second.getEndOffset() - 1)); assertEquals(-1, view.getViewIndexAtPosition(second.getEndOffset())); - assertEquals(-1, - view.getViewIndexAtPosition(second.getEndOffset() + 2)); - + assertEquals(-1, view.getViewIndexAtPosition(second.getEndOffset() + 2)); assertNull(view.layoutPool); } @@ -185,13 +181,9 @@ final Element first = root.getElement(0); final Element second = root.getElement(1); final int middle = (first.getStartOffset() + first.getEndOffset()) / 2; - View[] views = new View[] { - new ElementPartView(first, first.getStartOffset(), middle), - new ElementPartView(first, middle, first.getEndOffset()), - vf.create(second) - }; + View[] views = new View[] { new ElementPartView(first, first.getStartOffset(), middle), + new ElementPartView(first, middle, first.getEndOffset()), vf.create(second) }; view.replace(0, 0, views); - assertEquals(-1, view.getViewIndexAtPosition(-1)); assertEquals(0, view.getViewIndexAtPosition(first.getStartOffset())); assertEquals(0, view.getViewIndexAtPosition(middle - 1)); @@ -202,9 +194,7 @@ assertEquals(2, view.getViewIndexAtPosition(second.getStartOffset())); assertEquals(2, view.getViewIndexAtPosition(second.getEndOffset() - 1)); assertEquals(-1, view.getViewIndexAtPosition(second.getEndOffset())); - assertEquals(-1, - view.getViewIndexAtPosition(second.getEndOffset() + 2)); - + assertEquals(-1, view.getViewIndexAtPosition(second.getEndOffset() + 2)); assertNull(view.layoutPool); } @@ -212,7 +202,6 @@ assertNull(view.layoutPool); assertNull(view.getViewFactory()); view.loadChildren(new ChildrenFactory()); - assertNotNull(view.layoutPool); assertSame(view, view.layoutPool.getParent()); assertSame(root, view.layoutPool.getElement()); @@ -221,11 +210,9 @@ public void testLoadChildrenWithFactory() { view = new FlowViewImplWithFactory(root, View.Y_AXIS); - assertNull(view.layoutPool); assertNotNull(view.getViewFactory()); view.loadChildren(new ChildrenFactory()); - assertNotNull(view.layoutPool); assertSame(view, view.layoutPool.getParent()); assertSame(root, view.layoutPool.getElement()); @@ -234,81 +221,71 @@ public void testLoadChildrenWithFactoryEmtpyPool() { view = new FlowViewImplWithFactory(root, View.Y_AXIS); - assertNull(view.layoutPool); assertNotNull(view.getViewFactory()); view.loadChildren(null); - assertNotNull(view.layoutPool); view.layoutPool.removeAll(); - view.loadChildren(null); assertEquals(root.getElementCount(), view.layoutPool.getViewCount()); } public void testLoadChildrenEmtpyPoolNullFactory() { view = new FlowViewImplWithFactory(root, View.Y_AXIS); - assertNull(view.layoutPool); assertNotNull(view.getViewFactory()); view.loadChildren(null); - assertNotNull(view.layoutPool); view.layoutPool.removeAll(); - - ((CompositeView)view.layoutPool).loadChildren(null); + ((CompositeView) view.layoutPool).loadChildren(null); assertEquals(0, view.layoutPool.getViewCount()); } public void testLoadChildrenStrategy() { - final boolean[] called = new boolean[] {false}; - + final boolean[] called = new boolean[] { false }; view = new FlowViewImplWithFactory(root, View.Y_AXIS); view.strategy = new FlowStrategy() { - public void insertUpdate(FlowView fv, DocumentEvent event, - Rectangle alloc) { + @Override + public void insertUpdate(FlowView fv, DocumentEvent event, Rectangle alloc) { called[0] = true; - assertSame(view, fv); assertNull(event); assertNull(alloc); - super.insertUpdate(fv, event, alloc); } }; - view.loadChildren(null); assertTrue(called[0]); } public void testCalculateMinorAxisRequirements() { view.layoutPool = new PlainView(root) { + @Override public float getPreferredSpan(int axis) { return axis == X_AXIS ? -13 : 13; } + @Override public float getMinimumSpan(int axis) { return axis == X_AXIS ? -19 : 7; } + @Override public float getMaximumSpan(int axis) { return axis == X_AXIS ? -7 : 19; } + @Override public float getAlignment(int axis) { return axis == X_AXIS ? 0.312f : 0.213f; } }; - - SizeRequirements xSR = view.calculateMinorAxisRequirements(View.X_AXIS, - null); + SizeRequirements xSR = view.calculateMinorAxisRequirements(View.X_AXIS, null); assertEquals(-19, xSR.minimum); assertEquals(-13, xSR.preferred); assertEquals(Integer.MAX_VALUE, xSR.maximum); assertEquals(0.5f, xSR.alignment, 1e-5f); - - SizeRequirements ySR = view.calculateMinorAxisRequirements(View.Y_AXIS, - xSR); + SizeRequirements ySR = view.calculateMinorAxisRequirements(View.Y_AXIS, xSR); assertSame(xSR, ySR); assertEquals(7, xSR.minimum); assertEquals(13, xSR.preferred); @@ -317,16 +294,17 @@ } public void testLayout() { - final List layoutChanges = new ArrayList(); + final List layoutChanges = new ArrayList(); final Marker prefMarker = new Marker(); view = new FlowViewImplWithFactory(root, View.Y_AXIS) { + @Override public void layoutChanged(int axis) { layoutChanges.add(new Integer(axis)); super.layoutChanged(axis); } - public void preferenceChanged(View child, - boolean width, boolean height) { + @Override + public void preferenceChanged(View child, boolean width, boolean height) { assertNull(child); assertFalse(width); assertTrue(height); @@ -338,14 +316,13 @@ assertEquals(root.getElementCount(), view.layoutPool.getViewCount()); assertEquals(0, view.getViewCount()); layoutChanges.clear(); - assertFalse(view.isAllocationValid()); assertEquals(Short.MAX_VALUE, view.layoutSpan); - - final boolean[] called = new boolean[] {false}; + final boolean[] called = new boolean[] { false }; final int width = 513; final int height = 137; view.strategy = new FlowStrategy() { + @Override public void layout(FlowView fv) { assertSame(view, fv); super.layout(fv); @@ -357,46 +334,38 @@ assertEquals(1, view.getViewCount()); assertTrue(called[0]); assertTrue(view.isAllocationValid()); - assertEquals(2, layoutChanges.size()); - assertEquals(View.X_AXIS, ((Integer)layoutChanges.get(0)).intValue()); - assertEquals(View.Y_AXIS, ((Integer)layoutChanges.get(1)).intValue()); + assertEquals(View.X_AXIS, layoutChanges.get(0).intValue()); + assertEquals(View.Y_AXIS, layoutChanges.get(1).intValue()); layoutChanges.clear(); - - called[0] = false; view.layout(width, height); assertFalse(called[0]); assertEquals(0, layoutChanges.size()); - view.layoutChanged(View.X_AXIS); layoutChanges.clear(); assertFalse(view.isAllocationValid()); view.layout(width, height); assertTrue(called[0]); assertEquals(0, layoutChanges.size()); - called[0] = false; view.layout(width, height - 1); assertFalse(called[0]); assertEquals(0, layoutChanges.size()); - view.layout(width - 1, height); assertEquals(width - 1, view.layoutSpan); assertTrue(called[0]); - assertEquals(2, layoutChanges.size()); - assertEquals(View.X_AXIS, ((Integer)layoutChanges.get(0)).intValue()); - assertEquals(View.Y_AXIS, ((Integer)layoutChanges.get(1)).intValue()); + assertEquals(View.X_AXIS, layoutChanges.get(0).intValue()); + assertEquals(View.Y_AXIS, layoutChanges.get(1).intValue()); layoutChanges.clear(); - // Test if preferenceChanged() is called view.removeAll(); - int prefSpan = (int)view.getPreferredSpan(View.Y_AXIS); + int prefSpan = (int) view.getPreferredSpan(View.Y_AXIS); assertEquals(0, prefSpan); view.layout(width, height); assertTrue(view.getViewCount() != 0); - assertEquals(getSpanY(), (int)view.getPreferredSpan(View.Y_AXIS)); + assertEquals(getSpanY(), (int) view.getPreferredSpan(View.Y_AXIS)); assertEquals(isHarmony(), prefMarker.isOccurred()); } @@ -406,7 +375,6 @@ assertEquals(Short.MAX_VALUE, view.layoutSpan); assertNull(view.layoutPool); assertNotNull(view.strategy); - FlowView other = new FlowViewImpl(root, View.Y_AXIS); assertSame(view.strategy, other.strategy); } @@ -414,27 +382,22 @@ public void testGetFlowAxis() { assertEquals(View.Y_AXIS, view.getAxis()); assertEquals(View.X_AXIS, view.getFlowAxis()); - view = new FlowViewImpl(root, View.X_AXIS); assertEquals(View.X_AXIS, view.getAxis()); assertEquals(View.Y_AXIS, view.getFlowAxis()); - view = new FlowViewImpl(root, 10); assertEquals(10, view.getAxis()); assertEquals(View.Y_AXIS, view.getFlowAxis()); - view.setAxis(View.Y_AXIS); assertEquals(View.X_AXIS, view.getFlowAxis()); } public void testGetFlowStart() { assertEquals(0, view.getViewCount()); - assertEquals(0, view.getFlowStart(0)); assertEquals(0, view.getFlowStart(1)); assertEquals(0, view.getFlowStart(2)); - - view.setInsets((short)5, (short)7, (short)6, (short)3); + view.setInsets((short) 5, (short) 7, (short) 6, (short) 3); assertEquals(0, view.getFlowStart(0)); assertEquals(0, view.getFlowStart(1)); assertEquals(0, view.getFlowStart(2)); @@ -442,15 +405,12 @@ public void testGetFlowSpan() { assertEquals(0, view.getViewCount()); - assertEquals(Short.MAX_VALUE, view.layoutSpan); - view.layoutSpan = -10; assertEquals(-10, view.getFlowSpan(0)); assertEquals(-10, view.getFlowSpan(1)); assertEquals(-10, view.getFlowSpan(2)); - - view.setInsets((short)5, (short)7, (short)6, (short)3); + view.setInsets((short) 5, (short) 7, (short) 6, (short) 3); assertEquals(-10, view.getFlowSpan(0)); assertEquals(-10, view.getFlowSpan(1)); assertEquals(-10, view.getFlowSpan(2)); @@ -460,99 +420,86 @@ view = new FlowViewImplWithFactory(root, View.Y_AXIS); view.loadChildren(null); assertEquals(0, view.getViewCount()); - view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null); assertEquals(1, view.layoutPool.getViewCount()); - final View child = view.layoutPool.getView(0); - int childX = (int)child.getPreferredSpan(View.X_AXIS); - int childY = (int)child.getPreferredSpan(View.Y_AXIS); - assertEquals(childX, (int)child.getMinimumSpan(View.X_AXIS)); - assertEquals(childY, (int)child.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)child.getMaximumSpan(View.X_AXIS)); - assertEquals(childY, (int)child.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS)); - assertEquals(childY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS)); - assertEquals(childY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.getPreferredSpan(View.X_AXIS)); - assertEquals(0, (int)view.getPreferredSpan(View.Y_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS)); - assertEquals(0, (int)view.getMaximumSpan(View.Y_AXIS)); + int childX = (int) child.getPreferredSpan(View.X_AXIS); + int childY = (int) child.getPreferredSpan(View.Y_AXIS); + assertEquals(childX, (int) child.getMinimumSpan(View.X_AXIS)); + assertEquals(childY, (int) child.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) child.getMaximumSpan(View.X_AXIS)); + assertEquals(childY, (int) child.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.layoutPool.getPreferredSpan(View.X_AXIS)); + assertEquals(childY, (int) view.layoutPool.getPreferredSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.layoutPool.getMaximumSpan(View.X_AXIS)); + assertEquals(childY, (int) view.layoutPool.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.getPreferredSpan(View.X_AXIS)); + assertEquals(0, (int) view.getPreferredSpan(View.Y_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.X_AXIS)); + assertEquals(0, (int) view.getMaximumSpan(View.Y_AXIS)); } public void testGetSpanOneRowNoChildren() throws Exception { view = new FlowViewImplWithFactory(root, View.Y_AXIS); view.loadChildren(null); assertEquals(0, view.getViewCount()); - view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null); assertEquals(1, view.layoutPool.getViewCount()); final View row = view.createRow(); view.append(row); - final View child = view.layoutPool.getView(0); - int childX = (int)child.getPreferredSpan(View.X_AXIS); - int childY = (int)child.getPreferredSpan(View.Y_AXIS); - assertEquals(childX, (int)child.getMinimumSpan(View.X_AXIS)); - assertEquals(childY, (int)child.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)child.getMaximumSpan(View.X_AXIS)); - assertEquals(childY, (int)child.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS)); - assertEquals(childY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS)); - assertEquals(childY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.getPreferredSpan(View.X_AXIS)); - assertEquals(0, (int)view.getPreferredSpan(View.Y_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.Y_AXIS)); + int childX = (int) child.getPreferredSpan(View.X_AXIS); + int childY = (int) child.getPreferredSpan(View.Y_AXIS); + assertEquals(childX, (int) child.getMinimumSpan(View.X_AXIS)); + assertEquals(childY, (int) child.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) child.getMaximumSpan(View.X_AXIS)); + assertEquals(childY, (int) child.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.layoutPool.getPreferredSpan(View.X_AXIS)); + assertEquals(childY, (int) view.layoutPool.getPreferredSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.layoutPool.getMaximumSpan(View.X_AXIS)); + assertEquals(childY, (int) view.layoutPool.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.getPreferredSpan(View.X_AXIS)); + assertEquals(0, (int) view.getPreferredSpan(View.Y_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.X_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.Y_AXIS)); } public void testGetSpanOneRowOneChild() throws Exception { view = new FlowViewImplWithFactory(root, View.Y_AXIS); view.loadChildren(null); assertEquals(0, view.getViewCount()); - view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null); assertEquals(1, view.layoutPool.getViewCount()); - final View row = view.createRow(); view.append(row); final View child = view.layoutPool.getView(0); row.append(child); - - int childX = (int)child.getPreferredSpan(View.X_AXIS); - int childY = (int)child.getPreferredSpan(View.Y_AXIS); - assertEquals(childX, (int)child.getMinimumSpan(View.X_AXIS)); - assertEquals(childY, (int)child.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)child.getMaximumSpan(View.X_AXIS)); - assertEquals(childY, (int)child.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS)); - assertEquals(childY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS)); - assertEquals(childY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS)); - assertEquals(childY, (int)view.getMinimumSpan(View.Y_AXIS)); - assertEquals(childX, (int)view.getPreferredSpan(View.X_AXIS)); - assertEquals(childY, (int)view.getPreferredSpan(View.Y_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.Y_AXIS)); + int childX = (int) child.getPreferredSpan(View.X_AXIS); + int childY = (int) child.getPreferredSpan(View.Y_AXIS); + assertEquals(childX, (int) child.getMinimumSpan(View.X_AXIS)); + assertEquals(childY, (int) child.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) child.getMaximumSpan(View.X_AXIS)); + assertEquals(childY, (int) child.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.layoutPool.getPreferredSpan(View.X_AXIS)); + assertEquals(childY, (int) view.layoutPool.getPreferredSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.layoutPool.getMaximumSpan(View.X_AXIS)); + assertEquals(childY, (int) view.layoutPool.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.X_AXIS)); + assertEquals(childY, (int) view.getMinimumSpan(View.Y_AXIS)); + assertEquals(childX, (int) view.getPreferredSpan(View.X_AXIS)); + assertEquals(childY, (int) view.getPreferredSpan(View.Y_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.X_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.Y_AXIS)); } public void testGetSpanNoRowFlexible() throws Exception { @@ -561,26 +508,23 @@ view = new FlowViewImplWithFactory(root, View.Y_AXIS, factory); view.loadChildren(null); assertEquals(0, view.getViewCount()); - view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null); assertEquals(1, view.layoutPool.getViewCount()); final View child = view.layoutPool.getView(0); - int childPrefX = (int)child.getPreferredSpan(View.X_AXIS); - int childPrefY = (int)child.getPreferredSpan(View.Y_AXIS); - - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS)); - assertEquals(childPrefY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS)); - assertEquals(childPrefY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.getMinimumSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.getPreferredSpan(View.X_AXIS)); - assertEquals(0, (int)view.getPreferredSpan(View.Y_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS)); - assertEquals(0, (int)view.getMaximumSpan(View.Y_AXIS)); + int childPrefX = (int) child.getPreferredSpan(View.X_AXIS); + int childPrefY = (int) child.getPreferredSpan(View.Y_AXIS); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.layoutPool.getPreferredSpan(View.X_AXIS)); + assertEquals(childPrefY, (int) view.layoutPool.getPreferredSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.layoutPool.getMaximumSpan(View.X_AXIS)); + assertEquals(childPrefY, (int) view.layoutPool.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.getPreferredSpan(View.X_AXIS)); + assertEquals(0, (int) view.getPreferredSpan(View.Y_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.X_AXIS)); + assertEquals(0, (int) view.getMaximumSpan(View.Y_AXIS)); } public void testGetSpanOneRowNoChildrenFlexible() throws Exception { @@ -589,28 +533,25 @@ view = new FlowViewImplWithFactory(root, View.Y_AXIS, factory); view.loadChildren(null); assertEquals(0, view.getViewCount()); - view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null); assertEquals(1, view.layoutPool.getViewCount()); final View row = view.createRow(); view.append(row); final View child = view.layoutPool.getView(0); - int childPrefX = (int)child.getPreferredSpan(View.X_AXIS); - int childPrefY = (int)child.getPreferredSpan(View.Y_AXIS); - - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS)); - assertEquals(childPrefY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS)); - assertEquals(childPrefY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.getMinimumSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.getPreferredSpan(View.X_AXIS)); - assertEquals(0, (int)view.getPreferredSpan(View.Y_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.Y_AXIS)); + int childPrefX = (int) child.getPreferredSpan(View.X_AXIS); + int childPrefY = (int) child.getPreferredSpan(View.Y_AXIS); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.layoutPool.getPreferredSpan(View.X_AXIS)); + assertEquals(childPrefY, (int) view.layoutPool.getPreferredSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.layoutPool.getMaximumSpan(View.X_AXIS)); + assertEquals(childPrefY, (int) view.layoutPool.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.getPreferredSpan(View.X_AXIS)); + assertEquals(0, (int) view.getPreferredSpan(View.Y_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.X_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.Y_AXIS)); } public void testGetSpanOneRowOneChildFlexible() throws Exception { @@ -619,30 +560,27 @@ view = new FlowViewImplWithFactory(root, View.Y_AXIS, factory); view.loadChildren(null); assertEquals(0, view.getViewCount()); - view.layoutPool.replace(1, view.layoutPool.getViewCount() - 1, null); assertEquals(1, view.layoutPool.getViewCount()); final View row = view.createRow(); view.append(row); final View child = view.layoutPool.getView(0); row.append(child); - int childMinY = (int)child.getMinimumSpan(View.Y_AXIS); - int childPrefX = (int)child.getPreferredSpan(View.X_AXIS); - int childPrefY = (int)child.getPreferredSpan(View.Y_AXIS); - - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.X_AXIS)); - assertEquals(0, (int)view.layoutPool.getMinimumSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.layoutPool.getPreferredSpan(View.X_AXIS)); - assertEquals(childPrefY, (int)view.layoutPool.getPreferredSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.layoutPool.getMaximumSpan(View.X_AXIS)); - assertEquals(childPrefY, (int)view.layoutPool.getMaximumSpan(View.Y_AXIS)); - - assertEquals(0, (int)view.getMinimumSpan(View.X_AXIS)); - assertEquals(childMinY, (int)view.getMinimumSpan(View.Y_AXIS)); - assertEquals(childPrefX, (int)view.getPreferredSpan(View.X_AXIS)); - assertEquals(childPrefY, (int)view.getPreferredSpan(View.Y_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.X_AXIS)); - assertEquals(Integer.MAX_VALUE, (int)view.getMaximumSpan(View.Y_AXIS)); + int childMinY = (int) child.getMinimumSpan(View.Y_AXIS); + int childPrefX = (int) child.getPreferredSpan(View.X_AXIS); + int childPrefY = (int) child.getPreferredSpan(View.Y_AXIS); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.X_AXIS)); + assertEquals(0, (int) view.layoutPool.getMinimumSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.layoutPool.getPreferredSpan(View.X_AXIS)); + assertEquals(childPrefY, (int) view.layoutPool.getPreferredSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.layoutPool.getMaximumSpan(View.X_AXIS)); + assertEquals(childPrefY, (int) view.layoutPool.getMaximumSpan(View.Y_AXIS)); + assertEquals(0, (int) view.getMinimumSpan(View.X_AXIS)); + assertEquals(childMinY, (int) view.getMinimumSpan(View.Y_AXIS)); + assertEquals(childPrefX, (int) view.getPreferredSpan(View.X_AXIS)); + assertEquals(childPrefY, (int) view.getPreferredSpan(View.Y_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.X_AXIS)); + assertEquals(Integer.MAX_VALUE, (int) view.getMaximumSpan(View.Y_AXIS)); } public void testGetAttributesLayoutPool() { @@ -657,8 +595,7 @@ int span = 0; View row = view.getView(0); for (int i = 0; i < row.getViewCount(); i++) { - span = Math.max(span, - (int)row.getView(i).getPreferredSpan(View.Y_AXIS)); + span = Math.max(span, (int) row.getView(i).getPreferredSpan(View.Y_AXIS)); } return span; } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowView_ChangesTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowView_ChangesTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowView_ChangesTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/FlowView_ChangesTest.java Sun Nov 26 12:15:43 2006 @@ -24,13 +24,11 @@ import java.awt.Shape; import java.util.ArrayList; import java.util.List; - import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.DocumentEvent.EventType; import javax.swing.text.FlowViewTest.FlowViewImplWithFactory; import javax.swing.text.ViewTestHelpers.ChildView; - import junit.framework.TestCase; /** @@ -39,9 +37,13 @@ */ public class FlowView_ChangesTest extends TestCase implements DocumentListener { private AbstractDocument doc; + private Element root; + private FlowView view; + private DocumentEvent event; + private Rectangle alloc = new Rectangle(11, 21, 453, 217); /** @@ -49,10 +51,13 @@ */ private static class Changes { static final Object INSERT = "insert"; + static final Object REMOVE = "remove"; + static final Object CHANGE = "change"; private final View view; + private final Object method; Changes(final View view, final Object method) { @@ -72,20 +77,22 @@ */ private static class Preferences { private final View view; + private final View child; + private final boolean width; + private final boolean height; - Preferences(final View view, final View child, - final boolean width, final boolean height) { + Preferences(final View view, final View child, final boolean width, final boolean height) { this.view = view; this.child = child; this.width = width; this.height = height; } - final void check(final View view, final View child, - final boolean width, final boolean height) { + final void check(final View view, final View child, final boolean width, + final boolean height) { assertSame("Host view", this.view, view); assertSame("Child", this.child, child); assertEquals("Width", this.width, width); @@ -96,139 +103,134 @@ /** * List of views which got update event. */ - private final List changes = new ArrayList(); + private final List changes = new ArrayList(); /** * List of views which changed their preferences. */ - private final List preferences = new ArrayList(); + private final List preferences = new ArrayList(); private class FlowFactory implements ViewFactory { private int count = 0; public View create(Element element) { return new ChildView(element, count++) { - public void insertUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void insertUpdate(DocumentEvent event, Shape shape, ViewFactory factory) { changes.add(new Changes(this, Changes.INSERT)); preferenceChanged(null, true, false); } - public void removeUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void removeUpdate(DocumentEvent event, Shape shape, ViewFactory factory) { changes.add(new Changes(this, Changes.REMOVE)); preferenceChanged(null, false, true); } - public void changedUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void changedUpdate(DocumentEvent event, Shape shape, ViewFactory factory) { changes.add(new Changes(this, Changes.CHANGE)); preferenceChanged(null, true, true); } + @Override public String toString() { return "child(" + getID() + ")"; } - }; } } + @Override protected void setUp() throws Exception { super.setUp(); doc = new PlainDocument(); doc.insertString(0, "line1\nline2\nline3", null); root = doc.getDefaultRootElement(); - view = new FlowViewImplWithFactory(root, View.Y_AXIS, - new FlowFactory()) { + view = new FlowViewImplWithFactory(root, View.Y_AXIS, new FlowFactory()) { private int count = 0; + @Override protected View createRow() { return new BoxView(getElement(), X_AXIS) { private final int id = count++; - public void insertUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void insertUpdate(DocumentEvent event, Shape shape, + ViewFactory factory) { changes.add(new Changes(this, Changes.INSERT)); super.insertUpdate(event, shape, factory); } - public void removeUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void removeUpdate(DocumentEvent event, Shape shape, + ViewFactory factory) { changes.add(new Changes(this, Changes.REMOVE)); super.removeUpdate(event, shape, factory); } - public void changedUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void changedUpdate(DocumentEvent event, Shape shape, + ViewFactory factory) { changes.add(new Changes(this, Changes.CHANGE)); super.changedUpdate(event, shape, factory); } - public void preferenceChanged(View child, - boolean width, - boolean height) { - preferences.add(new Preferences(this, child, - width, height)); + @Override + public void preferenceChanged(View child, boolean width, boolean height) { + preferences.add(new Preferences(this, child, width, height)); super.preferenceChanged(child, width, height); } + @Override public String toString() { return "row(" + id + ")"; } + @Override protected void loadChildren(ViewFactory factory) { return; } }; } - public void preferenceChanged(View child, - boolean width, boolean height) { + @Override + public void preferenceChanged(View child, boolean width, boolean height) { preferences.add(new Preferences(this, child, width, height)); super.preferenceChanged(child, width, height); } + @Override public String toString() { return "flow"; } }; - view.layoutPool = new BoxView(root, View.X_AXIS) { - public void insertUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void insertUpdate(DocumentEvent event, Shape shape, ViewFactory factory) { changes.add(new Changes(this, Changes.INSERT)); super.insertUpdate(event, shape, factory); } - public void removeUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void removeUpdate(DocumentEvent event, Shape shape, ViewFactory factory) { changes.add(new Changes(this, Changes.REMOVE)); super.removeUpdate(event, shape, factory); } - public void changedUpdate(DocumentEvent event, - Shape shape, - ViewFactory factory) { + @Override + public void changedUpdate(DocumentEvent event, Shape shape, ViewFactory factory) { changes.add(new Changes(this, Changes.CHANGE)); super.changedUpdate(event, shape, factory); } - public void preferenceChanged(View child, - boolean width, - boolean height) { + @Override + public void preferenceChanged(View child, boolean width, boolean height) { preferences.add(new Preferences(this, child, width, height)); super.preferenceChanged(child, width, height); } + @Override public String toString() { return "pool"; } @@ -244,69 +246,49 @@ assertEquals(alloc.width, view.layoutSpan); assertEquals(1, view.getViewCount()); assertTrue(view.isAllocationValid()); - View row = view.getView(0); assertEquals(root.getElementCount(), row.getViewCount()); for (int i = 0; i < row.getViewCount(); i++) { assertSame(view.layoutPool.getView(i), row.getView(i)); } - doc.insertString(1, "^^^", null); - - view.insertUpdate(event, alloc , view.getViewFactory()); + view.insertUpdate(event, alloc, view.getViewFactory()); assertFalse(view.isAllocationValid()); - assertEquals(2, changes.size()); - ((Changes)changes.get(0)).check(view.layoutPool, Changes.INSERT); - ((Changes)changes.get(1)).check(view.layoutPool.getView(0), - Changes.INSERT); - + changes.get(0).check(view.layoutPool, Changes.INSERT); + changes.get(1).check(view.layoutPool.getView(0), Changes.INSERT); assertEquals(2, preferences.size()); - ((Preferences)preferences.get(0)).check(view.getView(0), - view.layoutPool.getView(0), - true, false); - ((Preferences)preferences.get(1)).check(view, view.getView(0), - true, false); + preferences.get(0).check(view.getView(0), view.layoutPool.getView(0), + true, false); + preferences.get(1).check(view, view.getView(0), true, false); } public void testRemoveUpdate() throws BadLocationException { assertTrue(view.isAllocationValid()); doc.remove(1, 1); - view.removeUpdate(event, alloc, view.getViewFactory()); assertFalse(view.isAllocationValid()); - assertEquals(2, changes.size()); - ((Changes)changes.get(0)).check(view.layoutPool, Changes.REMOVE); - ((Changes)changes.get(1)).check(view.layoutPool.getView(0), - Changes.REMOVE); - + changes.get(0).check(view.layoutPool, Changes.REMOVE); + changes.get(1).check(view.layoutPool.getView(0), Changes.REMOVE); assertEquals(2, preferences.size()); - ((Preferences)preferences.get(0)).check(view.getView(0), - view.layoutPool.getView(0), - false, true); - ((Preferences)preferences.get(1)).check(view, view.getView(0), - false, true); + preferences.get(0).check(view.getView(0), view.layoutPool.getView(0), + false, true); + preferences.get(1).check(view, view.getView(0), false, true); } public void testChangedUpdate() { assertTrue(view.isAllocationValid()); event = doc.new DefaultDocumentEvent(1, 1, EventType.CHANGE); - view.changedUpdate(event, alloc, view.getViewFactory()); assertFalse(view.isAllocationValid()); - assertEquals(2, changes.size()); - ((Changes)changes.get(0)).check(view.layoutPool, Changes.CHANGE); - ((Changes)changes.get(1)).check(view.layoutPool.getView(0), - Changes.CHANGE); - + changes.get(0).check(view.layoutPool, Changes.CHANGE); + changes.get(1).check(view.layoutPool.getView(0), Changes.CHANGE); assertEquals(2, preferences.size()); - ((Preferences)preferences.get(0)).check(view.getView(0), - view.layoutPool.getView(0), - true, true); - ((Preferences)preferences.get(1)).check(view, view.getView(0), - true, true); + preferences.get(0).check(view.getView(0), view.layoutPool.getView(0), + true, true); + preferences.get(1).check(view, view.getView(0), true, true); } public void insertUpdate(DocumentEvent e) { @@ -320,5 +302,4 @@ public void changedUpdate(DocumentEvent e) { event = e; } - }