This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: New ViewportLayout test


Here comes a new test for ViewportLayout.layoutContainer() that checks a
problem with the ViewportLayout.

2006-01-28  Roman Kennke  <kennke@aicas.com>

        * gnu/testlet/javax/swing/ViewportLayout/layoutContainer.java
        (testMinimumViewSize): New test.

/Roman
Index: gnu/testlet/javax/swing/ViewportLayout/layoutContainer.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/ViewportLayout/layoutContainer.java,v
retrieving revision 1.2
diff -u -r1.2 layoutContainer.java
--- gnu/testlet/javax/swing/ViewportLayout/layoutContainer.java	15 Dec 2005 17:54:02 -0000	1.2
+++ gnu/testlet/javax/swing/ViewportLayout/layoutContainer.java	28 Jan 2006 21:38:46 -0000
@@ -22,6 +22,7 @@
 package gnu.testlet.javax.swing.ViewportLayout;
 
 import java.awt.Dimension;
+import java.awt.Point;
 
 import javax.swing.JPanel;
 import javax.swing.JViewport;
@@ -48,6 +49,7 @@
     test1(harness);
     test2(harness);
     test3(harness);
+    testMinimumViewSize(harness);
   }
 
   /**
@@ -106,4 +108,26 @@
     layout.layoutContainer(vp);
     h.check(view.getSize(), new Dimension(50, 50));
   }
+
+  /**
+   * There was a strange rule in Classpath's implementation that said that if
+   * the viewport is larger than the view's minimumSize, the view's location
+   * must be set to (0,0). This test proves that this is wrong.
+   *
+   * @param h the test harness to use
+   */
+  private void testMinimumViewSize(TestHarness h)
+  {
+    JViewport vp = new JViewport();
+    ViewportLayout l = (ViewportLayout) vp.getLayout();
+    JPanel view = new JPanel();
+    view.setMinimumSize(new Dimension(100, 100));
+    view.setPreferredSize(new Dimension(200, 200));
+    view.setMaximumSize(new Dimension(300, 300));
+    vp.setSize(150, 150);
+    vp.setView(view);
+    view.setBounds(50, 50, 100, 100);
+    l.layoutContainer(vp);
+    h.check(view.getLocation(), new Point(50, 50));
+  }
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]