You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/11/26 01:04:16 UTC
svn commit: r479240 [25/28] -
/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java Sat Nov 25 16:04:10 2006
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
* @author Anton Avtamonov
* @version $Revision$
@@ -31,7 +30,6 @@
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.InvocationEvent;
-
import org.apache.harmony.awt.ComponentInternals;
public class RepaintManagerTest extends BasicSwingTestCase {
@@ -41,12 +39,14 @@
super(name);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
timeoutDelay = 10 * DEFAULT_TIMEOUT_DELAY;
dbMaxSize = RepaintManager.currentManager(null).getDoubleBufferMaximumSize();
}
+ @Override
protected void tearDown() throws Exception {
RepaintManager.currentManager(null).setDoubleBufferMaximumSize(dbMaxSize);
super.tearDown();
@@ -59,7 +59,6 @@
assertNotNull(inst2);
RepaintManager inst3 = RepaintManager.currentManager(null);
assertNotNull(inst3);
-
assertTrue(inst1 == inst2);
assertTrue(inst2 == inst3);
}
@@ -77,14 +76,19 @@
if (!isHarmony()) {
return;
}
-
JPanel root = new JPanel() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public boolean isValidateRoot() {
return true;
}
};
final Marker marker = new Marker();
JPanel inner = new JPanel() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public void validate() {
super.validate();
marker.setOccurred();
@@ -94,7 +98,6 @@
f.getContentPane().add(root);
root.add(inner);
f.setVisible(true);
-
RepaintManager.currentManager(null).addInvalidComponent(inner);
waitForIdle();
assertTrue(marker.isOccurred());
@@ -104,14 +107,19 @@
if (!isHarmony()) {
return;
}
-
JPanel root = new JPanel() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public boolean isValidateRoot() {
return true;
}
};
final Marker marker = new Marker();
JPanel inner = new JPanel() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public void validate() {
super.validate();
marker.setOccurred();
@@ -121,11 +129,9 @@
f.getContentPane().add(root);
root.add(inner);
f.setVisible(true);
-
RepaintManager.currentManager(null).addInvalidComponent(inner);
RepaintManager.currentManager(null).validateInvalidComponents();
assertTrue(marker.isOccurred());
-
f.dispose();
}
@@ -136,7 +142,6 @@
f.setSize(100, 100);
f.setVisible(true);
waitForNativePaint(f);
-
final Marker marker = new Marker();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -145,7 +150,6 @@
}
});
assertEquals(new Rectangle(10, 10, 40, 40), marker.getAuxiliary());
-
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -154,7 +158,6 @@
}
});
assertEquals(new Rectangle(10, 10, 200, 200), marker.getAuxiliary());
-
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -164,7 +167,6 @@
}
});
assertEquals(new Rectangle(10, 5, 50, 45), marker.getAuxiliary());
-
f.dispose();
}
@@ -175,7 +177,6 @@
f.setSize(100, 100);
f.setVisible(true);
waitForNativePaint(f);
-
final Marker marker = new Marker();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -184,9 +185,8 @@
marker.setAuxiliary(RepaintManager.currentManager(null).getDirtyRegion(root));
}
});
- Rectangle dirtyRect = (Rectangle)marker.getAuxiliary();
+ Rectangle dirtyRect = (Rectangle) marker.getAuxiliary();
assertEquals(new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE), dirtyRect);
-
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -195,19 +195,18 @@
marker.setAuxiliary(RepaintManager.currentManager(null).getDirtyRegion(root));
}
});
- Rectangle dirtyRect2 = (Rectangle)marker.getAuxiliary();
+ Rectangle dirtyRect2 = (Rectangle) marker.getAuxiliary();
assertEquals(new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE), dirtyRect2);
assertNotSame(dirtyRect, dirtyRect2);
-
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- RepaintManager.currentManager(null).addDirtyRegion(root, 10, 20, Integer.MAX_VALUE, Integer.MAX_VALUE);
+ RepaintManager.currentManager(null).addDirtyRegion(root, 10, 20,
+ Integer.MAX_VALUE, Integer.MAX_VALUE);
marker.setOccurred(RepaintManager.currentManager(null).isCompletelyDirty(root));
}
});
assertTrue(marker.isOccurred());
-
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -226,7 +225,6 @@
f.setSize(100, 100);
f.setVisible(true);
waitForNativePaint(f);
-
final Marker marker = new Marker();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -235,7 +233,6 @@
}
});
assertFalse(marker.isOccurred());
-
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -244,16 +241,15 @@
}
});
assertFalse(marker.isOccurred());
-
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- RepaintManager.currentManager(null).addDirtyRegion(root, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
+ RepaintManager.currentManager(null).addDirtyRegion(root, 0, 0,
+ Integer.MAX_VALUE, Integer.MAX_VALUE);
marker.setOccurred(RepaintManager.currentManager(null).isCompletelyDirty(root));
}
});
assertTrue(marker.isOccurred());
-
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -271,20 +267,18 @@
f.setSize(100, 100);
f.setVisible(true);
waitForNativePaint(f);
-
final Marker marker = new Marker();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Rectangle r1 = RepaintManager.currentManager(null).getDirtyRegion(root);
Rectangle r2 = RepaintManager.currentManager(null).getDirtyRegion(root);
- marker.setAuxiliary(new Rectangle[] {r1, r2});
+ marker.setAuxiliary(new Rectangle[] { r1, r2 });
}
});
-
- assertEquals(new Rectangle(), ((Rectangle[])marker.getAuxiliary())[0]);
- assertEquals(new Rectangle(), ((Rectangle[])marker.getAuxiliary())[1]);
- assertNotSame(((Rectangle[])marker.getAuxiliary())[0], ((Rectangle[])marker.getAuxiliary())[1]);
-
+ assertEquals(new Rectangle(), ((Rectangle[]) marker.getAuxiliary())[0]);
+ assertEquals(new Rectangle(), ((Rectangle[]) marker.getAuxiliary())[1]);
+ assertNotSame(((Rectangle[]) marker.getAuxiliary())[0], ((Rectangle[]) marker
+ .getAuxiliary())[1]);
marker.setAuxiliary(null);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -299,18 +293,25 @@
final Marker rootPaintMarker = new Marker();
final Marker rootPaintImmediatelyMarker = new Marker();
final JPanel root = new JPanel(null) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public void paint(final Graphics g) {
if (checkRepaintEvent()) {
rootPaintMarker.setAuxiliary(g.getClipBounds());
}
super.paint(g);
}
+
+ @Override
public void paintImmediately(final int x, final int y, final int w, final int h) {
if (checkRepaintEvent()) {
rootPaintImmediatelyMarker.setAuxiliary(new Rectangle(x, y, w, h));
}
super.paintImmediately(x, y, w, h);
}
+
+ @Override
public void paintImmediately(final Rectangle r) {
if (checkRepaintEvent()) {
rootPaintImmediatelyMarker.setAuxiliary(r);
@@ -318,22 +319,28 @@
super.paintImmediately(r);
}
};
-
final Marker inner1PaintMarker = new Marker();
final Marker inner1PaintImmediatelyMarker = new Marker();
final JPanel inner1 = new JPanel() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public void paint(final Graphics g) {
if (checkRepaintEvent()) {
inner1PaintMarker.setAuxiliary(g.getClipBounds());
}
super.paint(g);
}
+
+ @Override
public void paintImmediately(final int x, final int y, final int w, final int h) {
if (checkRepaintEvent()) {
inner1PaintImmediatelyMarker.setAuxiliary(new Rectangle(x, y, w, h));
}
super.paintImmediately(x, y, w, h);
}
+
+ @Override
public void paintImmediately(final Rectangle r) {
if (checkRepaintEvent()) {
inner1PaintImmediatelyMarker.setAuxiliary(r);
@@ -342,22 +349,28 @@
}
};
inner1.setBounds(20, 20, 40, 40);
-
final Marker inner2PaintMarker = new Marker();
final Marker inner2PaintImmediatelyMarker = new Marker();
final JPanel inner2 = new JPanel() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public void paint(final Graphics g) {
if (checkRepaintEvent()) {
inner2PaintMarker.setAuxiliary(g.getClipBounds());
}
super.paint(g);
}
+
+ @Override
public void paintImmediately(final int x, final int y, final int w, final int h) {
if (checkRepaintEvent()) {
inner2PaintImmediatelyMarker.setAuxiliary(new Rectangle(x, y, w, h));
}
super.paintImmediately(x, y, w, h);
}
+
+ @Override
public void paintImmediately(final Rectangle r) {
if (checkRepaintEvent()) {
inner2PaintImmediatelyMarker.setAuxiliary(r);
@@ -366,7 +379,6 @@
}
};
inner2.setBounds(10, 70, 20, 20);
-
final JFrame f = new JFrame();
f.getContentPane().add(root);
root.add(inner1);
@@ -374,7 +386,6 @@
f.setSize(150, 150);
f.setVisible(true);
waitForNativePaint(f);
-
final Marker marker = new Marker();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -387,7 +398,6 @@
f.setVisible(false);
f.setVisible(true);
waitForNativePaint(f);
-
rootPaintMarker.setAuxiliary(null);
inner1PaintMarker.setAuxiliary(null);
inner2PaintMarker.setAuxiliary(null);
@@ -409,7 +419,6 @@
f.setVisible(false);
f.setVisible(true);
waitForNativePaint(f);
-
rootPaintMarker.setAuxiliary(null);
inner1PaintMarker.setAuxiliary(null);
inner2PaintMarker.setAuxiliary(null);
@@ -431,7 +440,6 @@
f.setVisible(false);
f.setVisible(true);
waitForNativePaint(f);
-
rootPaintMarker.setAuxiliary(null);
inner1PaintMarker.setAuxiliary(null);
inner2PaintMarker.setAuxiliary(null);
@@ -454,7 +462,6 @@
f.setVisible(false);
f.setVisible(true);
waitForNativePaint(f);
-
rootPaintMarker.setAuxiliary(null);
inner1PaintMarker.setAuxiliary(null);
inner2PaintMarker.setAuxiliary(null);
@@ -476,7 +483,6 @@
f.setVisible(false);
f.setVisible(true);
waitForNativePaint(f);
-
rootPaintMarker.setAuxiliary(null);
inner1PaintMarker.setAuxiliary(null);
inner2PaintMarker.setAuxiliary(null);
@@ -496,7 +502,6 @@
assertNull(rootPaintImmediatelyMarker.getAuxiliary());
assertEquals(new Rectangle(10, 10, 20, 20), inner1PaintImmediatelyMarker.getAuxiliary());
assertEquals(new Rectangle(5, 5, 10, 10), inner2PaintImmediatelyMarker.getAuxiliary());
-
f.dispose();
}
@@ -507,115 +512,131 @@
}
public void testGetDoubleBufferMaximumSize() throws Exception {
- assertEquals(Toolkit.getDefaultToolkit().getScreenSize(), RepaintManager.currentManager(null).getDoubleBufferMaximumSize());
+ assertEquals(Toolkit.getDefaultToolkit().getScreenSize(), RepaintManager
+ .currentManager(null).getDoubleBufferMaximumSize());
Dimension bufferSize = new Dimension(100, 100);
RepaintManager.currentManager(null).setDoubleBufferMaximumSize(bufferSize);
- assertEquals(bufferSize, RepaintManager.currentManager(null).getDoubleBufferMaximumSize());
+ assertEquals(bufferSize, RepaintManager.currentManager(null)
+ .getDoubleBufferMaximumSize());
}
public void testGetOffscreenBuffer() throws Exception {
JPanel root = new JPanel();
JFrame f = new JFrame();
f.getContentPane().add(root);
-
assertNull(RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
-
f.pack();
-
- Image offscreenImage = RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10);
+ Image offscreenImage = RepaintManager.currentManager(null).getOffscreenBuffer(root, 10,
+ 10);
assertNotNull(offscreenImage);
assertEquals(10, offscreenImage.getWidth(f));
assertEquals(10, offscreenImage.getHeight(f));
-
- assertEquals(RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10), RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
- assertEquals(RepaintManager.currentManager(null).getOffscreenBuffer(f.getRootPane(), 10, 10), RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
- assertEquals(RepaintManager.currentManager(null).getOffscreenBuffer(f, 10, 10), RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
-
+ assertEquals(RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10),
+ RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
+ assertEquals(RepaintManager.currentManager(null).getOffscreenBuffer(f.getRootPane(),
+ 10, 10), RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
+ assertEquals(RepaintManager.currentManager(null).getOffscreenBuffer(f, 10, 10),
+ RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
Image im10x10 = RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10);
Image im10x20 = RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 20);
Image im20x10 = RepaintManager.currentManager(null).getOffscreenBuffer(root, 20, 10);
Image im20x20 = RepaintManager.currentManager(null).getOffscreenBuffer(root, 20, 20);
-
assertNotSame(im10x10, im10x20);
assertNotSame(im10x20, im20x10);
assertNotSame(im10x10, im20x10);
assertNotSame(im10x20, im20x20);
-
- assertNotSame(im10x10, RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
- assertSame(im20x20, RepaintManager.currentManager(null).getOffscreenBuffer(root, 10, 10));
- assertSame(im20x20, RepaintManager.currentManager(null).getOffscreenBuffer(root, 20, 20));
+ assertNotSame(im10x10, RepaintManager.currentManager(null).getOffscreenBuffer(root, 10,
+ 10));
+ assertSame(im20x20, RepaintManager.currentManager(null)
+ .getOffscreenBuffer(root, 10, 10));
+ assertSame(im20x20, RepaintManager.currentManager(null)
+ .getOffscreenBuffer(root, 20, 20));
assertSame(im20x20, RepaintManager.currentManager(null).getOffscreenBuffer(f, 20, 20));
- assertSame(im20x20, RepaintManager.currentManager(null).getOffscreenBuffer(new JButton(), 20, 20));
-
+ assertSame(im20x20, RepaintManager.currentManager(null).getOffscreenBuffer(
+ new JButton(), 20, 20));
Image im30x20 = RepaintManager.currentManager(null).getOffscreenBuffer(root, 30, 20);
assertNotSame(im20x20, im30x20);
- assertSame(im30x20, RepaintManager.currentManager(null).getOffscreenBuffer(root, 20, 20));
-
- assertNull(RepaintManager.currentManager(null).getOffscreenBuffer(new JButton(), 50, 20));
- assertNotSame(im30x20, RepaintManager.currentManager(null).getOffscreenBuffer(root, 20, 20));
-
-
- offscreenImage = RepaintManager.currentManager(null).getOffscreenBuffer(root, 10000, 10000);
+ assertSame(im30x20, RepaintManager.currentManager(null)
+ .getOffscreenBuffer(root, 20, 20));
+ assertNull(RepaintManager.currentManager(null)
+ .getOffscreenBuffer(new JButton(), 50, 20));
+ assertNotSame(im30x20, RepaintManager.currentManager(null).getOffscreenBuffer(root, 20,
+ 20));
+ offscreenImage = RepaintManager.currentManager(null).getOffscreenBuffer(root, 10000,
+ 10000);
assertNotNull(offscreenImage);
- assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().width, offscreenImage.getWidth(f));
- assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().height, offscreenImage.getHeight(f));
-
- offscreenImage = RepaintManager.currentManager(null).getOffscreenBuffer(root, 10000, 10000);
+ assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().width,
+ offscreenImage.getWidth(f));
+ assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().height,
+ offscreenImage.getHeight(f));
+ offscreenImage = RepaintManager.currentManager(null).getOffscreenBuffer(root, 10000,
+ 10000);
assertNotNull(offscreenImage);
- assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().width, offscreenImage.getWidth(f));
- assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().height, offscreenImage.getHeight(f));
-
+ assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().width,
+ offscreenImage.getWidth(f));
+ assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().height,
+ offscreenImage.getHeight(f));
f.dispose();
}
-
public void testGetVolatileOffscreenBuffer() throws Exception {
JPanel root = new JPanel();
JFrame f = new JFrame();
f.getContentPane().add(root);
-
f.pack();
-
- Image offscreenImage = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 400);
+ Image offscreenImage = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(
+ root, 400, 400);
assertNotNull(offscreenImage);
assertEquals(400, offscreenImage.getWidth(f));
assertEquals(400, offscreenImage.getHeight(f));
-
- assertEquals(RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 400), RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 400));
- assertEquals(RepaintManager.currentManager(null).getVolatileOffscreenBuffer(f.getRootPane(), 400, 400), RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 400));
- assertEquals(RepaintManager.currentManager(null).getVolatileOffscreenBuffer(f, 400, 400), RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 400));
-
- Image im400x400 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 400);
- Image im400x420 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 420);
- Image im420x400 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 420, 400);
- Image im420x420 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 420, 420);
-
+ assertEquals(RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400,
+ 400), RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400,
+ 400));
+ assertEquals(RepaintManager.currentManager(null).getVolatileOffscreenBuffer(
+ f.getRootPane(), 400, 400), RepaintManager.currentManager(null)
+ .getVolatileOffscreenBuffer(root, 400, 400));
+ assertEquals(RepaintManager.currentManager(null)
+ .getVolatileOffscreenBuffer(f, 400, 400), RepaintManager.currentManager(null)
+ .getVolatileOffscreenBuffer(root, 400, 400));
+ Image im400x400 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root,
+ 400, 400);
+ Image im400x420 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root,
+ 400, 420);
+ Image im420x400 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root,
+ 420, 400);
+ Image im420x420 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root,
+ 420, 420);
assertNotSame(im400x400, im400x420);
assertNotSame(im400x420, im420x400);
assertNotSame(im400x420, im420x400);
assertNotSame(im400x420, im420x420);
-
- assertNotSame(im400x400, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 400));
- assertSame(im420x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 400, 400));
- assertSame(im420x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 420, 420));
- assertSame(im420x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(f, 420, 420));
- assertSame(im420x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(new JButton(), 420, 420));
-
- Image im430x420 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 430, 420);
+ assertNotSame(im400x400, RepaintManager.currentManager(null)
+ .getVolatileOffscreenBuffer(root, 400, 400));
+ assertSame(im420x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(
+ root, 400, 400));
+ assertSame(im420x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(
+ root, 420, 420));
+ assertSame(im420x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(f,
+ 420, 420));
+ assertSame(im420x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(
+ new JButton(), 420, 420));
+ Image im430x420 = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root,
+ 430, 420);
assertNotSame(im420x420, im430x420);
- assertSame(im430x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 420, 420));
-
- assertSame(im430x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 420, 420));
-
- offscreenImage = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root, 10000, 10000);
+ assertSame(im430x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(
+ root, 420, 420));
+ assertSame(im430x420, RepaintManager.currentManager(null).getVolatileOffscreenBuffer(
+ root, 420, 420));
+ offscreenImage = RepaintManager.currentManager(null).getVolatileOffscreenBuffer(root,
+ 10000, 10000);
assertNotNull(offscreenImage);
- assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().width, offscreenImage.getWidth(f));
- assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().height, offscreenImage.getHeight(f));
-
+ assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().width,
+ offscreenImage.getWidth(f));
+ assertEquals(RepaintManager.currentManager(null).getDoubleBufferMaximumSize().height,
+ offscreenImage.getHeight(f));
f.dispose();
}
-
private boolean checkRepaintEvent() {
return EventQueue.getCurrentEvent() instanceof InvocationEvent;
}
@@ -624,7 +645,6 @@
if (!isHarmony()) {
return;
}
-
int counter = 0;
while (!wasPainted(w) && counter++ < 50) {
try {
@@ -642,7 +662,6 @@
result.setOccurred(ComponentInternals.getComponentInternals().wasPainted(w));
}
});
-
return result.isOccurred();
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RobotTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RobotTestCase.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RobotTestCase.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RobotTestCase.java Sat Nov 25 16:04:10 2006
@@ -24,11 +24,9 @@
import java.awt.EventQueue;
import java.awt.Robot;
import java.lang.reflect.Method;
-
import junit.framework.TestCase;
public abstract class RobotTestCase extends TestCase {
-
/**
* Framework for running JUnit tests that consist of sequence of assertions &
* actions. The only visible method in it is static run(Object o, String[]
@@ -58,10 +56,11 @@
* "assertion0002", "action0002"});
*/
public static class RobotRunner {
-
private static class RunnableMethod implements Runnable {
private final Object target;
+
private final Method method;
+
private Object result;
public Object getResult() {
@@ -75,7 +74,7 @@
public void run() {
try {
- result = (Boolean) method.invoke(target, null);
+ result = method.invoke(target, null);
} catch (Throwable e) {
e.printStackTrace();
result = null;
@@ -107,14 +106,12 @@
for (int i = 0; i < sequence.length; i++) {
Method m = testCase.getClass().getMethod(sequence[i], new Class[] {});
if ((m.getReturnType() != boolean.class)
- && (m.getReturnType() != void.class)) { // assertion
- System.err.println("unknown return type: "
- + m.getReturnType() + " for method '" + sequence[i]
- + "' in test sequence");
+ && (m.getReturnType() != void.class)) { // assertion
+ System.err.println("unknown return type: " + m.getReturnType()
+ + " for method '" + sequence[i] + "' in test sequence");
return false;
}
}
-
//ok then - all methods are correct, we can start
for (int i = 0; i < sequence.length; i++) {
Method m = testCase.getClass().getMethod(sequence[i], new Class[] {});
@@ -163,9 +160,9 @@
}
}
+ @Override
public void setUp() throws Exception {
super.setUp();
-
RobotRunner.setTestCase(this);
}
@@ -180,5 +177,4 @@
public static void setNumberOfAssertionRetries(final int numRetries) {
RobotRunner.numAssertionRetries = numRetries;
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java Sat Nov 25 16:04:10 2006
@@ -14,28 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
* @author Sergey Burlak
* @version $Revision$
*/
-
package javax.swing;
import java.awt.Dimension;
public class ScrollPaneLayoutTest extends SwingTestCase {
private ScrollPaneLayout layout;
+
private JScrollPane pane;
+
private JLabel label;
+ @Override
protected void setUp() throws Exception {
label = new JLabel();
label.setPreferredSize(new Dimension(500, 500));
pane = new JScrollPane(label);
- layout = (ScrollPaneLayout)pane.getLayout();
+ layout = (ScrollPaneLayout) pane.getLayout();
}
+ @Override
protected void tearDown() throws Exception {
layout = null;
pane = null;
@@ -47,27 +49,20 @@
layout.colHead.setPreferredSize(new Dimension(100, 30));
layout.rowHead = new JViewport();
layout.rowHead.setPreferredSize(new Dimension(50, 20));
-
pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
-
pane.setBorder(BorderFactory.createEmptyBorder(51, 101, 151, 202));
pane.setViewportBorder(BorderFactory.createEmptyBorder(51, 101, 151, 202));
-
int width = layout.viewport.getPreferredSize().width
- + layout.rowHead.getPreferredSize().width
- + (layout.vsb == null ? 0 : layout.vsb.getBounds().width)
- + pane.getInsets().right + pane.getInsets().left
- + 101 + 202;
+ + layout.rowHead.getPreferredSize().width
+ + (layout.vsb == null ? 0 : layout.vsb.getBounds().width)
+ + pane.getInsets().right + pane.getInsets().left + 101 + 202;
int height = layout.viewport.getPreferredSize().height
- + layout.colHead.getPreferredSize().height
- + (layout.hsb == null ? 0 : layout.hsb.getBounds().height)
- + pane.getInsets().top + pane.getInsets().bottom
- + 51 + 151;
-
+ + layout.colHead.getPreferredSize().height
+ + (layout.hsb == null ? 0 : layout.hsb.getBounds().height)
+ + pane.getInsets().top + pane.getInsets().bottom + 51 + 151;
assertEquals(width, layout.preferredLayoutSize(pane).width);
assertEquals(height, layout.preferredLayoutSize(pane).height);
-
try {
layout.preferredLayoutSize(new JButton());
fail("Class cast exception shall be thrown");
@@ -77,35 +72,37 @@
public void testDefaultLayout() throws Exception {
ScrollPaneLayout l = new ScrollPaneLayout();
-
assertNull(l.colHead);
assertNull(l.lowerLeft);
assertNull(l.lowerRight);
assertNull(l.upperLeft);
assertNull(l.upperRight);
-
assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, l.vsbPolicy);
assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED, l.hsbPolicy);
}
public void testSetHorizontalPolicy() throws Exception {
- assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED, layout.getHorizontalScrollBarPolicy());
+ assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED, layout
+ .getHorizontalScrollBarPolicy());
pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
layout.syncWithScrollPane(pane);
- assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS, layout.getHorizontalScrollBarPolicy());
-
+ assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS, layout
+ .getHorizontalScrollBarPolicy());
layout.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, layout.getHorizontalScrollBarPolicy());
+ assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, layout
+ .getHorizontalScrollBarPolicy());
}
public void testSetVerticalPolicy() throws Exception {
- assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, layout.getVerticalScrollBarPolicy());
+ assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, layout
+ .getVerticalScrollBarPolicy());
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
layout.syncWithScrollPane(pane);
- assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, layout.getVerticalScrollBarPolicy());
-
+ assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, layout
+ .getVerticalScrollBarPolicy());
layout.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
- assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, layout.getVerticalScrollBarPolicy());
+ assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, layout
+ .getVerticalScrollBarPolicy());
}
public void testGetViewport() throws Exception {
@@ -131,17 +128,14 @@
JButton upperLeftButton = new JButton();
JButton lowerRightButton = new JButton();
JButton upperRightButton = new JButton();
-
layout.lowerLeft = lowerLeftButton;
layout.upperLeft = upperLeftButton;
layout.lowerRight = lowerRightButton;
layout.upperRight = upperRightButton;
-
assertEquals(lowerLeftButton, layout.getCorner(ScrollPaneConstants.LOWER_LEFT_CORNER));
assertEquals(upperLeftButton, layout.getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER));
assertEquals(lowerRightButton, layout.getCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER));
assertEquals(upperRightButton, layout.getCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER));
-
assertNull(layout.getCorner("something"));
}
@@ -159,7 +153,6 @@
public void testSyncWithScrollPane() throws Exception {
ScrollPaneLayout l = new ScrollPaneLayout();
-
assertNull(l.viewport);
assertNull(l.rowHead);
assertNull(l.colHead);
@@ -169,9 +162,7 @@
assertNull(l.upperRight);
assertNull(l.hsb);
assertNull(l.vsb);
-
l.syncWithScrollPane(pane);
-
assertEquals(pane.getViewport(), l.viewport);
assertEquals(pane.getRowHeader(), l.rowHead);
assertEquals(pane.getColumnHeader(), l.colHead);
@@ -183,7 +174,6 @@
assertEquals(pane.getCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER), l.upperRight);
assertEquals(pane.getHorizontalScrollBarPolicy(), l.getHorizontalScrollBarPolicy());
assertEquals(pane.getVerticalScrollBarPolicy(), l.getVerticalScrollBarPolicy());
-
try {
layout.syncWithScrollPane(null);
fail("NPE shall be thrown");
@@ -199,40 +189,32 @@
assertNotNull(layout.viewport);
layout.removeLayoutComponent(layout.viewport);
assertNull(layout.viewport);
-
assertNotNull(layout.vsb);
layout.removeLayoutComponent(layout.vsb);
assertNull(layout.vsb);
-
assertNotNull(layout.hsb);
layout.removeLayoutComponent(layout.hsb);
assertNull(layout.hsb);
-
layout.rowHead = new JViewport();
assertNotNull(layout.rowHead);
layout.removeLayoutComponent(layout.rowHead);
assertNull(layout.rowHead);
-
layout.colHead = new JViewport();
assertNotNull(layout.colHead);
layout.removeLayoutComponent(layout.colHead);
assertNull(layout.colHead);
-
layout.lowerLeft = new JButton();
assertNotNull(layout.lowerLeft);
layout.removeLayoutComponent(layout.lowerLeft);
assertNull(layout.lowerLeft);
-
layout.lowerRight = new JButton();
assertNotNull(layout.lowerRight);
layout.removeLayoutComponent(layout.lowerRight);
assertNull(layout.lowerRight);
-
layout.upperLeft = new JButton();
assertNotNull(layout.upperLeft);
layout.removeLayoutComponent(layout.upperLeft);
assertNull(layout.upperLeft);
-
layout.upperRight = new JButton();
assertNotNull(layout.upperRight);
layout.removeLayoutComponent(layout.upperRight);
@@ -242,13 +224,10 @@
public void testAddSingletonLayoutComponent() throws Exception {
JButton newButton = new JButton();
JButton button = new JButton();
-
-
pane.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, button);
int componentCount = pane.getComponentCount();
assertEquals(newButton, layout.addSingletonComponent(button, newButton));
assertEquals(componentCount - 1, pane.getComponentCount());
-
pane.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, button);
componentCount = pane.getComponentCount();
assertNull(layout.addSingletonComponent(button, null));
@@ -260,25 +239,18 @@
layout.colHead.setPreferredSize(new Dimension(100, 30));
layout.rowHead = new JViewport();
layout.rowHead.setPreferredSize(new Dimension(50, 20));
-
pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
-
pane.setBorder(BorderFactory.createEmptyBorder(51, 101, 151, 202));
pane.setViewportBorder(BorderFactory.createEmptyBorder(51, 101, 151, 202));
-
int width = layout.viewport.getMinimumSize().width
- + layout.rowHead.getMinimumSize().width
- + pane.getVerticalScrollBar().getMinimumSize().width
- + pane.getInsets().right + pane.getInsets().left
- + 101 + 202;
-
+ + layout.rowHead.getMinimumSize().width
+ + pane.getVerticalScrollBar().getMinimumSize().width + pane.getInsets().right
+ + pane.getInsets().left + 101 + 202;
int height = layout.viewport.getMinimumSize().height
- + layout.colHead.getMinimumSize().height
- + pane.getHorizontalScrollBar().getMinimumSize().height
- + pane.getInsets().top + pane.getInsets().bottom
- + 51 + 151;
-
+ + layout.colHead.getMinimumSize().height
+ + pane.getHorizontalScrollBar().getMinimumSize().height + pane.getInsets().top
+ + pane.getInsets().bottom + 51 + 151;
assertEquals(new Dimension(width, height), layout.minimumLayoutSize(pane));
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SerializableTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SerializableTestCase.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SerializableTestCase.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SerializableTestCase.java Sat Nov 25 16:04:10 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$
@@ -32,11 +31,11 @@
*
*/
public abstract class SerializableTestCase extends TestCase {
-
/**
* Object under test which will be serialized.
*/
protected Object toSave;
+
/**
* This is where deserialized object will be stored.
*/
@@ -45,9 +44,9 @@
/**
* Initialize toSave object here.
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
toLoad = BasicSwingTestCase.serializeObject(toSave);
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeRequirementsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeRequirementsTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeRequirementsTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeRequirementsTest.java Sat Nov 25 16:04:10 2006
@@ -26,7 +26,6 @@
import java.io.IOException;
public class SizeRequirementsTest extends SwingTestCase {
-
/*
* Class under test for void SizeRequirements(int, int, int, float)
*/
@@ -35,7 +34,6 @@
int pref = 10;
int max = 1;
float align = 0.3f;
-
SizeRequirements requirements = new SizeRequirements(min, pref, max, align);
assertEquals("Minimum ", min, requirements.minimum);
assertEquals("Preferred ", pref, requirements.preferred);
@@ -54,7 +52,6 @@
int pref = 0;
int max = 0;
float align = 0.3f;
-
SizeRequirements requirements = new SizeRequirements(0, 0, 0, align);
assertEquals("Minimum ", min, requirements.minimum);
assertEquals("Preferred ", pref, requirements.preferred);
@@ -70,7 +67,6 @@
int pref = 0;
int max = 0;
float align = 0.5f;
-
SizeRequirements requirements = new SizeRequirements();
assertEquals("Minimum ", min, requirements.minimum);
assertEquals("Preferred ", pref, requirements.preferred);
@@ -85,46 +81,37 @@
SizeRequirements requirements1 = new SizeRequirements(10, 20, 30, 0.1f);
SizeRequirements requirements2 = new SizeRequirements(110, 240, 530, 0.9f);
SizeRequirements requirements3 = new SizeRequirements();
-
assertNotNull(requirements1.toString());
assertNotNull(requirements2.toString());
assertNotNull(requirements3.toString());
}
public void testGetTiledSizeRequirements() {
- SizeRequirements[] reqs = new SizeRequirements[]{
- new SizeRequirements(10, 20, 30, 1f),
- new SizeRequirements(20, 30, 40, 1f)
- };
+ SizeRequirements[] reqs = new SizeRequirements[] {
+ new SizeRequirements(10, 20, 30, 1f), new SizeRequirements(20, 30, 40, 1f) };
SizeRequirements res = SizeRequirements.getTiledSizeRequirements(reqs);
assertEquals("Minimum ", 30, res.minimum);
assertEquals("Preferred ", 50, res.preferred);
assertEquals("Maximum ", 70, res.maximum);
assertEquals("Alignmnent ", 0.5f, res.alignment, 1e-5);
-
- reqs = new SizeRequirements[]{
- new SizeRequirements(10, 20, 30, 2f),
- new SizeRequirements(20, 30, 40, 3f),
- new SizeRequirements(30, 40, 50, -100f)
- };
+ reqs = new SizeRequirements[] { new SizeRequirements(10, 20, 30, 2f),
+ new SizeRequirements(20, 30, 40, 3f), new SizeRequirements(30, 40, 50, -100f) };
res = SizeRequirements.getTiledSizeRequirements(reqs);
assertEquals("Minimum ", 60, res.minimum);
assertEquals("Preferred ", 90, res.preferred);
assertEquals("Maximum ", 120, res.maximum);
assertEquals("Alignmnent ", 0.5f, res.alignment, 1e-5);
-
reqs = new SizeRequirements[0];
res = SizeRequirements.getTiledSizeRequirements(reqs);
assertEquals("Minimum ", 0, res.minimum);
assertEquals("Preferred ", 0, res.preferred);
assertEquals("Maximum ", 0, res.maximum);
assertEquals("Alignmnent ", 0.5f, res.alignment, 1e-5);
-
- reqs = new SizeRequirements[]{
- new SizeRequirements(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, 0f),
- new SizeRequirements(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, 1f),
- new SizeRequirements(30, 20, 10, 1f)
- };
+ reqs = new SizeRequirements[] {
+ new SizeRequirements(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
+ 0f),
+ new SizeRequirements(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
+ 1f), new SizeRequirements(30, 20, 10, 1f) };
res = SizeRequirements.getTiledSizeRequirements(reqs);
assertEquals("Minimum ", Integer.MAX_VALUE, res.minimum);
assertEquals("Preferred ", Integer.MAX_VALUE, res.preferred);
@@ -133,10 +120,8 @@
}
public void testGetAlignedSizeRequirements() {
- SizeRequirements[] reqs = new SizeRequirements[]{
- new SizeRequirements(10, 20, 30, 0.2f),
- new SizeRequirements(20, 30, 40, .7f)
- };
+ SizeRequirements[] reqs = new SizeRequirements[] {
+ new SizeRequirements(10, 20, 30, 0.2f), new SizeRequirements(20, 30, 40, .7f) };
SizeRequirements res = SizeRequirements.getAlignedSizeRequirements(reqs);
if (isHarmony()) {
assertEquals("Minimum ", 22, res.minimum);
@@ -144,30 +129,24 @@
assertEquals("Maximum ", 52, res.maximum);
assertEquals("Alignmnent ", 0.6363636f, res.alignment, 1e-5);
}
-
- reqs = new SizeRequirements[]{
- new SizeRequirements(10, 20, 30, 0f),
- new SizeRequirements(20, 30, 40, 0.2f),
- new SizeRequirements(30, 20, 10, 1f)
- };
+ reqs = new SizeRequirements[] { new SizeRequirements(10, 20, 30, 0f),
+ new SizeRequirements(20, 30, 40, 0.2f), new SizeRequirements(30, 20, 10, 1f) };
res = SizeRequirements.getAlignedSizeRequirements(reqs);
assertEquals("Minimum ", 46, res.minimum);
assertEquals("Preferred ", 44, res.preferred);
assertEquals("Maximum ", 42, res.maximum);
assertEquals("Alignmnent ", 0.65217394f, res.alignment, 1e-5);
-
reqs = new SizeRequirements[0];
res = SizeRequirements.getAlignedSizeRequirements(reqs);
assertEquals("Minimum ", 0, res.minimum);
assertEquals("Preferred ", 0, res.preferred);
assertEquals("Maximum ", 0, res.maximum);
assertEquals("Alignmnent ", 0.0f, res.alignment, 1e-5);
-
- reqs = new SizeRequirements[]{
- new SizeRequirements(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, 0f),
- new SizeRequirements(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, 0.2f),
- new SizeRequirements(30, 20, 10, 1f)
- };
+ reqs = new SizeRequirements[] {
+ new SizeRequirements(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
+ 0f),
+ new SizeRequirements(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
+ 0.2f), new SizeRequirements(30, 20, 10, 1f) };
res = SizeRequirements.getAlignedSizeRequirements(reqs);
assertEquals("Minimum ", Integer.MAX_VALUE, res.minimum);
assertEquals("Preferred ", Integer.MAX_VALUE, res.preferred);
@@ -180,14 +159,11 @@
*/
public void testCalculateTiledPositionsintSizeRequirementsSizeRequirementsArrayintArrayintArrayboolean() {
SizeRequirements total = null;
- SizeRequirements[] children = new SizeRequirements[]{
+ SizeRequirements[] children = new SizeRequirements[] {
new SizeRequirements(10, 40, 10, 0.9f),
- new SizeRequirements(20, 80, 100, 0.3f),
- new SizeRequirements(80, 70, 20, 0.6f)
- };
- int[] offsets = new int [3];
- int[] spans = new int [3];
-
+ new SizeRequirements(20, 80, 100, 0.3f), new SizeRequirements(80, 70, 20, 0.6f) };
+ int[] offsets = new int[3];
+ int[] spans = new int[3];
SizeRequirements.calculateTiledPositions(50, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 0, offsets[0]);
assertEquals("Offsets coinside ", 10, offsets[1]);
@@ -195,7 +171,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 20, spans[1]);
assertEquals("Spans coinside ", 80, spans[2]);
-
SizeRequirements.calculateTiledPositions(100, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 0, offsets[0]);
assertEquals("Offsets coinside ", 10, offsets[1]);
@@ -203,7 +178,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 20, spans[1]);
assertEquals("Spans coinside ", 80, spans[2]);
-
SizeRequirements.calculateTiledPositions(250, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 0, offsets[0]);
assertEquals("Offsets coinside ", 10, offsets[1]);
@@ -211,7 +185,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 100, spans[1]);
assertEquals("Spans coinside ", 20, spans[2]);
-
SizeRequirements.calculateTiledPositions(250, total, children, offsets, spans, false);
assertEquals("Offsets coinside ", 240, offsets[0]);
assertEquals("Offsets coinside ", 140, offsets[1]);
@@ -219,7 +192,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 100, spans[1]);
assertEquals("Spans coinside ", 20, spans[2]);
-
SizeRequirements.calculateTiledPositions(100, total, children, offsets, spans, false);
assertEquals("Offsets coinside ", 90, offsets[0]);
assertEquals("Offsets coinside ", 70, offsets[1]);
@@ -227,7 +199,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 20, spans[1]);
assertEquals("Spans coinside ", 80, spans[2]);
-
SizeRequirements.calculateTiledPositions(80, total, children, offsets, spans, false);
assertEquals("Offsets coinside ", 70, offsets[0]);
assertEquals("Offsets coinside ", 50, offsets[1]);
@@ -235,12 +206,9 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 20, spans[1]);
assertEquals("Spans coinside ", 80, spans[2]);
-
- children = new SizeRequirements[]{
- new SizeRequirements(10, 100, 1000, 0.9f),
+ children = new SizeRequirements[] { new SizeRequirements(10, 100, 1000, 0.9f),
new SizeRequirements(20, 200, 2000, 0.3f),
- new SizeRequirements(30, 300, 3000, 0.6f)
- };
+ new SizeRequirements(30, 300, 3000, 0.6f) };
SizeRequirements.calculateTiledPositions(1000, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 0, offsets[0]);
assertEquals("Offsets coinside ", 166, offsets[1]);
@@ -248,37 +216,31 @@
assertEquals("Spans coinside ", 166, spans[0]);
assertEquals("Spans coinside ", 333, spans[1]);
assertEquals("Spans coinside ", 500, spans[2]);
-
- offsets = new int [1];
- spans = new int [1];
- children = new SizeRequirements[]{
- new SizeRequirements(30, 300, Integer.MAX_VALUE, 0.6f)
- };
+ offsets = new int[1];
+ spans = new int[1];
+ children = new SizeRequirements[] { new SizeRequirements(30, 300, Integer.MAX_VALUE,
+ 0.6f) };
SizeRequirements.calculateTiledPositions(350, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 0, offsets[0]);
assertEquals("Spans coinside ", 350, spans[0]);
-
-
- offsets = new int [2];
- spans = new int [2];
- children = new SizeRequirements[]{
- new SizeRequirements(30, 50, Integer.MAX_VALUE, 0.0f),
- new SizeRequirements(30, 50, Integer.MAX_VALUE, 0.0f)
- };
+ offsets = new int[2];
+ spans = new int[2];
+ children = new SizeRequirements[] {
+ new SizeRequirements(30, 50, Integer.MAX_VALUE, 0.0f),
+ new SizeRequirements(30, 50, Integer.MAX_VALUE, 0.0f) };
SizeRequirements.calculateTiledPositions(300, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 0, offsets[0]);
assertEquals("Offsets coinside ", 150, offsets[1]);
assertEquals("Spans coinside ", 150, spans[0]);
assertEquals("Spans coinside ", 150, spans[1]);
-
if (isHarmony()) {
- offsets = new int [2];
- spans = new int [2];
- children = new SizeRequirements[]{
- new SizeRequirements(100, Integer.MAX_VALUE, Integer.MAX_VALUE, 0.0f),
- new SizeRequirements(100, Integer.MAX_VALUE, Integer.MAX_VALUE, 0.0f)
- };
- SizeRequirements.calculateTiledPositions(300, total, children, offsets, spans, true);
+ offsets = new int[2];
+ spans = new int[2];
+ children = new SizeRequirements[] {
+ new SizeRequirements(100, Integer.MAX_VALUE, Integer.MAX_VALUE, 0.0f),
+ new SizeRequirements(100, Integer.MAX_VALUE, Integer.MAX_VALUE, 0.0f) };
+ SizeRequirements
+ .calculateTiledPositions(300, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 0, offsets[0]);
assertEquals("Offsets coinside ", 150, offsets[1]);
assertEquals("Spans coinside ", 150, spans[0]);
@@ -298,14 +260,11 @@
*/
public void testCalculateAlignedPositionsintSizeRequirementsSizeRequirementsArrayintArrayintArrayboolean() {
SizeRequirements total = new SizeRequirements(0, 0, 0, 0.4f);
- SizeRequirements[] children = new SizeRequirements[]{
+ SizeRequirements[] children = new SizeRequirements[] {
new SizeRequirements(10, 40, 10, 0.1f),
- new SizeRequirements(40, 80, 100, 0.2f),
- new SizeRequirements(60, 70, 20, 1f)
- };
- int[] offsets = new int [3];
- int[] spans = new int [3];
-
+ new SizeRequirements(40, 80, 100, 0.2f), new SizeRequirements(60, 70, 20, 1f) };
+ int[] offsets = new int[3];
+ int[] spans = new int[3];
SizeRequirements.calculateAlignedPositions(50, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 19, offsets[0]);
assertEquals("Offsets coinside ", 0, offsets[1]);
@@ -313,7 +272,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 50, spans[1]);
assertEquals("Spans coinside ", 20, spans[2]);
-
SizeRequirements.calculateAlignedPositions(100, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 39, offsets[0]);
assertEquals("Offsets coinside ", 20, offsets[1]);
@@ -321,7 +279,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 80, spans[1]);
assertEquals("Spans coinside ", 20, spans[2]);
-
SizeRequirements.calculateAlignedPositions(200, total, children, offsets, spans, true);
assertEquals("Offsets coinside ", 79, offsets[0]);
assertEquals("Offsets coinside ", 60, offsets[1]);
@@ -329,7 +286,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 100, spans[1]);
assertEquals("Spans coinside ", 20, spans[2]);
-
total = new SizeRequirements(0, 0, 0, 0.1f);
SizeRequirements.calculateAlignedPositions(200, total, children, offsets, spans, false);
assertEquals("Offsets coinside ", 171, offsets[0], 1);
@@ -338,7 +294,6 @@
assertEquals("Spans coinside ", 10, spans[0]);
assertEquals("Spans coinside ", 100, spans[1]);
assertEquals("Spans coinside ", 20, spans[2]);
-
SizeRequirements.calculateAlignedPositions(80, total, children, offsets, spans, false);
assertEquals("Offsets coinside ", 63, offsets[0], 1);
assertEquals("Offsets coinside ", 0, offsets[1], 1);
@@ -356,67 +311,65 @@
}
public void testAdjustSizes() {
- SizeRequirements[] reqs = new SizeRequirements[]{
- new SizeRequirements(10, 20, 30, 0.2f),
- new SizeRequirements(20, 30, 40, .7f)
- };
+ SizeRequirements[] reqs = new SizeRequirements[] {
+ new SizeRequirements(10, 20, 30, 0.2f), new SizeRequirements(20, 30, 40, .7f) };
int[] res = SizeRequirements.adjustSizes(1, reqs);
assertTrue(res.length == 0);
}
public void testWriteObject() throws Exception {
-// SizeRequirements requirements1 = new SizeRequirements(10, 20, 30, 0.1f);
-// SizeRequirements requirements2 = new SizeRequirements(40, 50, 60, 0.2f);
-// ByteArrayOutputStream fo = new ByteArrayOutputStream();
-// ObjectOutputStream so = new ObjectOutputStream(fo);
-// so.writeObject(requirements1);
-// so.flush();
-// so.writeObject(requirements2);
-// so.flush();
+ // SizeRequirements requirements1 = new SizeRequirements(10, 20, 30, 0.1f);
+ // SizeRequirements requirements2 = new SizeRequirements(40, 50, 60, 0.2f);
+ // ByteArrayOutputStream fo = new ByteArrayOutputStream();
+ // ObjectOutputStream so = new ObjectOutputStream(fo);
+ // so.writeObject(requirements1);
+ // so.flush();
+ // so.writeObject(requirements2);
+ // so.flush();
}
public void testReadObject() throws IOException, ClassNotFoundException {
-// SizeRequirements requirements1 = new SizeRequirements(10, 20, 30, 0.1f);
-// SizeRequirements requirements2 = new SizeRequirements(40, 50, 60, 0.2f);
-// ByteArrayOutputStream fo = new ByteArrayOutputStream();
-// ObjectOutputStream so = new ObjectOutputStream(fo);
-// so.writeObject(requirements1);
-// so.flush();
-// InputStream fi = new ByteArrayInputStream(fo.toByteArray());
-// ObjectInputStream si = new ObjectInputStream(fi);
-// SizeRequirements resurrectedRequirements = (SizeRequirements)si
-// .readObject();
-//
-// assertEquals("Deserialized minimum",
-// requirements1.minimum, resurrectedRequirements.minimum);
-//
-// assertEquals("Deserialized preferred",
-// requirements1.preferred, resurrectedRequirements.preferred);
-//
-// assertEquals("Deserialized maximum",
-// requirements1.maximum, resurrectedRequirements.maximum);
-//
-// assertEquals("Deserialized alignment",
-// requirements1.alignment, resurrectedRequirements.alignment, 1e-5);
-//
-// fo = new ByteArrayOutputStream();
-// so = new ObjectOutputStream(fo);
-// so.writeObject(requirements2);
-// so.flush();
-//
-// fi = new ByteArrayInputStream(fo.toByteArray());
-// si = new ObjectInputStream(fi);
-// resurrectedRequirements = (SizeRequirements)si.readObject();
-// assertEquals("Deserialized minimum",
-// requirements2.minimum, resurrectedRequirements.minimum);
-//
-// assertEquals("Deserialized preferred",
-// requirements2.preferred, resurrectedRequirements.preferred);
-//
-// assertEquals("Deserialized maximum",
-// requirements2.maximum, resurrectedRequirements.maximum);
-//
-// assertEquals("Deserialized alignment",
-// requirements2.alignment, resurrectedRequirements.alignment, 1e-5);
+ // SizeRequirements requirements1 = new SizeRequirements(10, 20, 30, 0.1f);
+ // SizeRequirements requirements2 = new SizeRequirements(40, 50, 60, 0.2f);
+ // ByteArrayOutputStream fo = new ByteArrayOutputStream();
+ // ObjectOutputStream so = new ObjectOutputStream(fo);
+ // so.writeObject(requirements1);
+ // so.flush();
+ // InputStream fi = new ByteArrayInputStream(fo.toByteArray());
+ // ObjectInputStream si = new ObjectInputStream(fi);
+ // SizeRequirements resurrectedRequirements = (SizeRequirements)si
+ // .readObject();
+ //
+ // assertEquals("Deserialized minimum",
+ // requirements1.minimum, resurrectedRequirements.minimum);
+ //
+ // assertEquals("Deserialized preferred",
+ // requirements1.preferred, resurrectedRequirements.preferred);
+ //
+ // assertEquals("Deserialized maximum",
+ // requirements1.maximum, resurrectedRequirements.maximum);
+ //
+ // assertEquals("Deserialized alignment",
+ // requirements1.alignment, resurrectedRequirements.alignment, 1e-5);
+ //
+ // fo = new ByteArrayOutputStream();
+ // so = new ObjectOutputStream(fo);
+ // so.writeObject(requirements2);
+ // so.flush();
+ //
+ // fi = new ByteArrayInputStream(fo.toByteArray());
+ // si = new ObjectInputStream(fi);
+ // resurrectedRequirements = (SizeRequirements)si.readObject();
+ // assertEquals("Deserialized minimum",
+ // requirements2.minimum, resurrectedRequirements.minimum);
+ //
+ // assertEquals("Deserialized preferred",
+ // requirements2.preferred, resurrectedRequirements.preferred);
+ //
+ // assertEquals("Deserialized maximum",
+ // requirements2.maximum, resurrectedRequirements.maximum);
+ //
+ // assertEquals("Deserialized alignment",
+ // requirements2.alignment, resurrectedRequirements.alignment, 1e-5);
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeSequenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeSequenceTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeSequenceTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SizeSequenceTest.java Sat Nov 25 16:04:10 2006
@@ -14,55 +14,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
* @author Dennis Ushakov
* @version $Revision$
*/
package javax.swing;
-import java.util.Arrays;
-
-
public class SizeSequenceTest extends BasicSwingTestCase {
private SizeSequence sizeSequence;
+
private int[] sizes;
-
+
+ @Override
protected void setUp() throws Exception {
super.setUp();
- sizes = new int[]{1, 2, 3, 4, 5};
+ sizes = new int[] { 1, 2, 3, 4, 5 };
sizeSequence = new SizeSequence(sizes);
}
-
+
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
sizeSequence = null;
sizes = null;
}
-
- public void testSizeSequence() throws Exception {
+
+ public void testSizeSequence() throws Exception {
sizeSequence = new SizeSequence();
- assertEquals(0, sizeSequence.getSizes().length);
-
+ assertEquals(0, sizeSequence.getSizes().length);
sizeSequence = new SizeSequence(10);
assertEquals(10, sizeSequence.getSizes().length);
assertEquals(10, sizeSequence.getIndex(0));
for (int i = 0; i < 10; i++) {
assertEquals(0, sizeSequence.getSizes()[i]);
}
-
sizeSequence = new SizeSequence(10, 13);
assertEquals(10, sizeSequence.getSizes().length);
for (int i = 0; i < 10; i++) {
assertEquals(13, sizeSequence.getSizes()[i]);
}
-
- int[] sizes = new int[]{1, 2, 3, 4, 5};
+ int[] sizes = new int[] { 1, 2, 3, 4, 5 };
sizeSequence = new SizeSequence(sizes);
assertEquals(5, sizeSequence.getSizes().length);
- assertNotSame(sizes, sizeSequence.getSizes());
+ assertNotSame(sizes, sizeSequence.getSizes());
}
-
+
public void testGetIndex() {
assertEquals(2, sizeSequence.getIndex(3));
assertEquals(3, sizeSequence.getIndex(6));
@@ -70,23 +66,21 @@
assertEquals(5, sizeSequence.getIndex(100));
assertEquals(0, sizeSequence.getIndex(-100));
}
-
+
public void testGetPosition() {
assertEquals(0, sizeSequence.getPosition(0));
assertEquals(1, sizeSequence.getPosition(1));
assertEquals(3, sizeSequence.getPosition(2));
assertEquals(6, sizeSequence.getPosition(3));
- assertEquals(10, sizeSequence.getPosition(4));
+ assertEquals(10, sizeSequence.getPosition(4));
assertEquals(15, sizeSequence.getPosition(100));
assertEquals(0, sizeSequence.getPosition(-100));
-
sizeSequence = new SizeSequence();
assertEquals(0, sizeSequence.getPosition(5));
}
-
+
public void testGetSetSize() {
assertEquals(1, sizeSequence.getSize(0));
-
sizeSequence.setSize(0, 10);
assertEquals(10, sizeSequence.getSize(0));
assertEquals(10, sizeSequence.getPosition(1));
@@ -94,23 +88,19 @@
assertEquals(24, sizeSequence.getPosition(5));
assertEquals(1, sizeSequence.getIndex(11));
assertEquals(3, sizeSequence.getIndex(15));
-
sizeSequence.setSize(0, -10);
assertEquals(-10, sizeSequence.getSize(0));
assertEquals(-10, sizeSequence.getPosition(1));
-
sizeSequence.setSize(10, 1);
assertEquals(0, sizeSequence.getSize(10));
}
-
+
public void testGetSetSizes() {
int[] first = sizeSequence.getSizes();
assertNotSame(first, sizeSequence.getSizes());
-
sizes[0] = 5;
assertEquals(1, sizeSequence.getSizes()[0]);
-
- sizes = new int[]{1, 2, 3, 4, 5, 6};
+ sizes = new int[] { 1, 2, 3, 4, 5, 6 };
sizeSequence.setSizes(sizes);
assertEquals(sizes.length, sizeSequence.getSizes().length);
assertNotSame(sizes, sizeSequence.getSizes());
@@ -119,51 +109,60 @@
assertEquals(sizes[i], sizeSequence.getSize(i));
}
}
-
+
public void testInsertRemoveEntries() {
sizeSequence.removeEntries(0, 3);
assertEquals(2, sizeSequence.getSizes().length);
assertEquals(5, sizeSequence.getSize(1));
-
testExceptionalCase(new ExceptionalCase() {
+ @Override
public void exceptionalAction() throws Exception {
sizeSequence.removeEntries(10, 11);
}
+
+ @Override
public Class expectedExceptionClass() {
return NegativeArraySizeException.class;
}
- });
+ });
testExceptionalCase(new ExceptionalCase() {
+ @Override
public void exceptionalAction() throws Exception {
sizeSequence.removeEntries(10, -1);
}
+
+ @Override
public Class expectedExceptionClass() {
return ArrayIndexOutOfBoundsException.class;
}
- });
-
- sizeSequence = new SizeSequence(sizes);
+ });
+ sizeSequence = new SizeSequence(sizes);
sizeSequence.insertEntries(2, 3, 2);
- assertEquals(3 + sizes.length, sizeSequence.getSizes().length);
+ assertEquals(3 + sizes.length, sizeSequence.getSizes().length);
assertEquals(2, sizeSequence.getSize(2));
assertEquals(2, sizeSequence.getIndex(3));
assertEquals(5, sizeSequence.getSize(7));
-
testExceptionalCase(new ExceptionalCase() {
+ @Override
public void exceptionalAction() throws Exception {
sizeSequence.insertEntries(10, 11, 0);
}
+
+ @Override
public Class expectedExceptionClass() {
return ArrayIndexOutOfBoundsException.class;
}
- });
+ });
testExceptionalCase(new ExceptionalCase() {
+ @Override
public void exceptionalAction() throws Exception {
sizeSequence.insertEntries(0, -1, 0);
}
+
+ @Override
public Class expectedExceptionClass() {
return ArrayIndexOutOfBoundsException.class;
}
- });
+ });
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SortingFocusTraversalPolicyRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SortingFocusTraversalPolicyRTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SortingFocusTraversalPolicyRTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SortingFocusTraversalPolicyRTest.java Sat Nov 25 16:04:10 2006
@@ -25,32 +25,35 @@
public class SortingFocusTraversalPolicyRTest extends BasicSwingTestCase {
private SortingFocusTraversalPolicy policy;
+
private JButton button1;
+
private JButton button2;
+
private JButton button3;
+
private JButton button4;
+
private JFrame frame;
+ @Override
protected void setUp() throws Exception {
super.setUp();
policy = new SortingFocusTraversalPolicy(new TestComparator());
-
button1 = createButton("1");
button2 = createButton("2");
button3 = createButton("3");
button4 = createButton("4");
-
frame = new JFrame();
}
+ @Override
protected void tearDown() throws Exception {
policy = null;
-
button1 = null;
button2 = null;
button3 = null;
button4 = null;
-
frame.dispose();
frame = null;
super.tearDown();
@@ -60,78 +63,62 @@
JFrame f = new JFrame();
f.setVisible(true);
SwingWaitTestCase.isRealized(f);
-
JPanel cycleRoot = createPanelWithButtons();
f.getContentPane().add(cycleRoot);
cycleRoot.setFocusCycleRoot(true);
cycleRoot.setFocusable(false);
-
assertEquals(button2, policy.getComponentAfter(cycleRoot, button1));
assertEquals(button3, policy.getComponentAfter(cycleRoot, button2));
assertEquals(button4, policy.getComponentAfter(cycleRoot, button3));
assertEquals(button1, policy.getComponentAfter(cycleRoot, button4));
-
f.setVisible(false);
assertNull(policy.getComponentAfter(cycleRoot, button1));
-
f.setVisible(true);
assertEquals(button2, policy.getComponentAfter(cycleRoot, button1));
-
f.getContentPane().remove(cycleRoot);
assertNull(policy.getComponentAfter(cycleRoot, button1));
}
-
public void testGetComponentBeforeAfterNotAcceptable() throws Exception {
JFrame f = new JFrame();
f.setVisible(true);
SwingWaitTestCase.isRealized(f);
-
JPanel cycleRoot = createPanelWithButtons();
f.getContentPane().add(cycleRoot);
cycleRoot.setFocusCycleRoot(true);
cycleRoot.setFocusable(false);
-
button2.setEnabled(false);
f.setVisible(true);
-
assertEquals(button3, policy.getComponentAfter(cycleRoot, button1));
assertEquals(button3, policy.getComponentAfter(cycleRoot, button2));
assertEquals(button4, policy.getComponentAfter(cycleRoot, button3));
assertEquals(button1, policy.getComponentAfter(cycleRoot, button4));
-
assertEquals(button4, policy.getComponentBefore(cycleRoot, button1));
assertEquals(button1, policy.getComponentBefore(cycleRoot, button2));
assertEquals(button1, policy.getComponentBefore(cycleRoot, button3));
assertEquals(button3, policy.getComponentBefore(cycleRoot, button4));
-
}
-
private JPanel createPanelWithButtons() {
JPanel result = new JPanel();
result.setFocusTraversalPolicy(policy);
-
result.add(button3);
result.add(button4);
result.add(button1);
result.add(button2);
-
return result;
}
private JButton createButton(final String name) {
JButton result = new JButton(name);
result.setName(name);
-
return result;
}
private class TestComparator implements Comparator {
public int compare(final Object o1, final Object o2) {
- Component c1 = (Component)o1;
- Component c2 = (Component)o2;
-
+ Component c1 = (Component) o1;
+ Component c2 = (Component) o2;
if (c1.getName() == null) {
return -1;
} else if (c2.getName() == null) {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SortingFocusTraversalPolicyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SortingFocusTraversalPolicyTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SortingFocusTraversalPolicyTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/SortingFocusTraversalPolicyTest.java Sat Nov 25 16:04:10 2006
@@ -25,36 +25,39 @@
public class SortingFocusTraversalPolicyTest extends BasicSwingTestCase {
private SortingFocusTraversalPolicy policy;
+
private JButton button1;
+
private JButton button2;
+
private JButton button3;
+
private JButton button4;
+
private JFrame frame;
public SortingFocusTraversalPolicyTest(final String name) {
super(name);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
policy = new SortingFocusTraversalPolicy(new TestComparator());
-
button1 = createButton("1");
button2 = createButton("2");
button3 = createButton("3");
button4 = createButton("4");
-
frame = new JFrame();
}
+ @Override
protected void tearDown() throws Exception {
policy = null;
-
button1 = null;
button2 = null;
button3 = null;
button4 = null;
-
frame.dispose();
frame = null;
super.tearDown();
@@ -63,39 +66,32 @@
public void testSortingFocusTraversalPolicy() throws Exception {
Comparator cmp = new TestComparator();
policy = new SortingFocusTraversalPolicy(cmp);
-
assertEquals(cmp, policy.getComparator());
}
public void testSetComparator() throws Exception {
Comparator cmp = new TestComparator();
policy.setComparator(cmp);
-
assertEquals(cmp, policy.getComparator());
}
public void testAccept() throws Exception {
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
Component invisible = new JPanel();
frame.getContentPane().add(invisible);
invisible.setVisible(false);
assertFalse(policy.accept(invisible));
-
Component undisplayable = new JPanel();
assertFalse(policy.accept(undisplayable));
-
Component disabled = new JPanel();
frame.getContentPane().add(disabled);
disabled.setEnabled(false);
assertFalse(policy.accept(disabled));
-
Component unfocusable = new JPanel();
frame.getContentPane().add(unfocusable);
unfocusable.setFocusable(false);
assertFalse(policy.accept(unfocusable));
-
Component acceptable = new JPanel();
frame.getContentPane().add(acceptable);
assertTrue(policy.accept(acceptable));
@@ -108,7 +104,6 @@
cycleRoot.setFocusable(false);
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
assertEquals(button4, policy.getComponentBefore(cycleRoot, button1));
assertEquals(button1, policy.getComponentBefore(cycleRoot, button2));
assertEquals(button2, policy.getComponentBefore(cycleRoot, button3));
@@ -117,6 +112,7 @@
public void testGetComponentBeforeForNotCycleRoot() throws Exception {
testExceptionalCase(new IllegalArgumentCase() {
+ @Override
public void exceptionalAction() throws Exception {
policy.getComponentBefore(createNotCycleRootPanel(), button1);
}
@@ -125,6 +121,7 @@
public void testGetComponentBeforeForNullCycleRoot() throws Exception {
testExceptionalCase(new IllegalArgumentCase() {
+ @Override
public void exceptionalAction() throws Exception {
policy.getComponentBefore(null, button1);
}
@@ -138,8 +135,8 @@
cycleRoot.setFocusable(false);
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
testExceptionalCase(new IllegalArgumentCase() {
+ @Override
public void exceptionalAction() throws Exception {
policy.getComponentBefore(cycleRoot, null);
}
@@ -150,12 +147,10 @@
JFrame f = new JFrame();
f.setVisible(true);
SwingWaitTestCase.isRealized(f);
-
JPanel cycleRoot = createPanelWithButtons();
f.getContentPane().add(cycleRoot);
cycleRoot.setFocusCycleRoot(true);
cycleRoot.setFocusable(false);
-
assertEquals(button2, policy.getComponentAfter(cycleRoot, button1));
assertEquals(button3, policy.getComponentAfter(cycleRoot, button2));
assertEquals(button4, policy.getComponentAfter(cycleRoot, button3));
@@ -164,6 +159,7 @@
public void testGetComponentAfterForNotCycleRoot() throws Exception {
testExceptionalCase(new IllegalArgumentCase() {
+ @Override
public void exceptionalAction() throws Exception {
policy.getComponentAfter(createNotCycleRootPanel(), button1);
}
@@ -172,6 +168,7 @@
public void testGetComponentAfterForNullCycleRoot() throws Exception {
testExceptionalCase(new IllegalArgumentCase() {
+ @Override
public void exceptionalAction() throws Exception {
policy.getComponentAfter(null, button1);
}
@@ -181,13 +178,12 @@
public void testGetComponentAfterForNullComponent() throws Exception {
JFrame f = new JFrame();
f.setVisible(true);
-
final JPanel cycleRoot = createPanelWithButtons();
f.getContentPane().add(cycleRoot);
cycleRoot.setFocusCycleRoot(true);
cycleRoot.setFocusable(false);
-
testExceptionalCase(new IllegalArgumentCase() {
+ @Override
public void exceptionalAction() throws Exception {
policy.getComponentAfter(cycleRoot, null);
}
@@ -201,12 +197,12 @@
cycleRoot.setFocusable(false);
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
assertEquals(button4, policy.getLastComponent(cycleRoot));
}
public void testGetLastComponentForNotCycleRoot() throws Exception {
testExceptionalCase(new IllegalArgumentCase() {
+ @Override
public void exceptionalAction() throws Exception {
policy.getLastComponent(null);
}
@@ -220,7 +216,6 @@
cycleRoot.setFocusable(false);
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
assertEquals(button1, policy.getFirstComponent(cycleRoot));
}
@@ -231,27 +226,24 @@
cycleRoot.setFocusable(false);
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
assertEquals(policy.getFirstComponent(cycleRoot), policy.getDefaultComponent(cycleRoot));
}
public void testComponentIsInACycleRoot() throws Exception {
final JPanel cycleRoot = createPanelWithButtons();
-
JPanel innerCycleRoot = new JPanel();
innerCycleRoot.setName("9 - the latest");
innerCycleRoot.setFocusCycleRoot(true);
final JButton innerButton1 = createButton("1");
innerCycleRoot.add(innerButton1);
cycleRoot.add(innerCycleRoot);
-
frame.getContentPane().add(cycleRoot);
cycleRoot.setFocusCycleRoot(true);
cycleRoot.setFocusable(false);
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
testExceptionalCase(new IllegalArgumentCase() {
+ @Override
public void exceptionalAction() throws Exception {
policy.getComponentAfter(cycleRoot, innerButton1);
}
@@ -260,7 +252,6 @@
public void testInnerCycleRootsProcessingWithImplicitTraversal() throws Exception {
JPanel cycleRoot = createPanelWithButtons();
-
JPanel innerCycleRoot = new JPanel();
innerCycleRoot.setName("9 - the latest");
innerCycleRoot.setFocusCycleRoot(true);
@@ -272,13 +263,11 @@
innerCycleRoot.add(innerButton3);
innerCycleRoot.add(innerButton1);
cycleRoot.add(innerCycleRoot);
-
frame.getContentPane().add(cycleRoot);
cycleRoot.setFocusCycleRoot(true);
cycleRoot.setFocusable(false);
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
assertEquals(innerCycleRoot, policy.getComponentAfter(cycleRoot, button4));
assertEquals(innerButton1, policy.getComponentAfter(cycleRoot, innerCycleRoot));
assertEquals(innerButton1, policy.getComponentAfter(innerCycleRoot, innerCycleRoot));
@@ -289,7 +278,6 @@
assertEquals(innerCycleRoot, policy.getComponentBefore(innerCycleRoot, innerButton1));
assertEquals(innerButton3, policy.getComponentBefore(innerCycleRoot, innerCycleRoot));
assertEquals(button4, policy.getComponentBefore(cycleRoot, innerCycleRoot));
-
policy.setImplicitDownCycleTraversal(false);
assertEquals(innerCycleRoot, policy.getComponentAfter(cycleRoot, button4));
assertEquals(button1, policy.getComponentAfter(cycleRoot, innerCycleRoot));
@@ -300,12 +288,10 @@
private JPanel createPanelWithButtons() {
JPanel result = new JPanel();
result.setFocusTraversalPolicy(policy);
-
result.add(button3);
result.add(button4);
result.add(button1);
result.add(button2);
-
return result;
}
@@ -316,23 +302,19 @@
result.setFocusable(false);
frame.setVisible(true);
SwingWaitTestCase.isRealized(frame);
-
return result;
}
private JButton createButton(final String name) {
JButton result = new JButton(name);
result.setName(name);
-
return result;
}
-
private class TestComparator implements Comparator {
public int compare(final Object o1, final Object o2) {
- Component c1 = (Component)o1;
- Component c2 = (Component)o2;
-
+ Component c1 = (Component) o1;
+ Component c2 = (Component) o2;
if (c1.getName() == null) {
return -1;
} else if (c2.getName() == null) {