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: Fix JTree.isRowSelected() test


This test tested for the wrong method (getRowForPath() instead of the
correct getPathForRow() method) and I added an additional check to see
if isPathSelected() is called during isRowSelected().

2006-10-09  Roman Kennke <kennke@aicas.com>

	* gnu/testlet/javax/swing/JTree/isRowSelected.java
	(TestTree.isPathSelected): New overridden method for testing.
	(TestTree.getRowForPath): Removed.
	(TestTree.getPathForRow): New overridden method for testing.
	(isPathSelectedCalled): New field.
	(getPathForRowCalled): Renamed old getRowForPathCalled field.
	(test): Include new isPathSelected() test.
	(testGetRowForPath): Renamed method and check getPathForRow() instead
	of getRowForPath().
	(testCallIsRowSelected): New test method.

/Roman

Index: gnu/testlet/javax/swing/JTree/isRowSelected.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/JTree/isRowSelected.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 isRowSelected.java
--- gnu/testlet/javax/swing/JTree/isRowSelected.java	8 Oct 2006 22:15:23 -0000	1.1
+++ gnu/testlet/javax/swing/JTree/isRowSelected.java	8 Oct 2006 22:31:22 -0000
@@ -27,91 +27,118 @@
 import javax.swing.tree.DefaultTreeSelectionModel;
 import javax.swing.tree.TreePath;
 
 import gnu.testlet.TestHarness;
 import gnu.testlet.Testlet;
 
 /**
  * Tests JTree.isRowSelected().
  */
 public class isRowSelected implements Testlet
 {
 
   /**
    * Indicates if JTree.getRowForPath() is called during a test.
    */
-  boolean getRowForPathCalled;
+  boolean getPathForRowCalled;
+
+  /**
+   * Indicates if JTree.isPathSelected() is called during a test.
+   */
+  boolean isPathSelectedCalled;
 
   /**
    * Indicates if a tree's selection model isRowSelected() is called
    * during a test.
    */
   boolean modelIsRowSelectedCalled;
 
   /**
    * A subclass of JTree for testing.
    */
   private class TestTree
     extends JTree
   {
     public TestTree(Object[] data)
     {
       super(data);
     }
-    public int getRowForPath(TreePath p)
+    public TreePath getPathForRow(int r)
+    {
+      getPathForRowCalled = true;
+      return super.getPathForRow(r);
+    }
+    public boolean isPathSelected(TreePath p)
     {
-      getRowForPathCalled = true;
-      return super.getRowForPath(p);
+      isPathSelectedCalled = true;
+      return super.isPathSelected(p);
     }
   }
 
   /**
    * A subclass of DefaultTreeSelectionModel for testing.
    */
   private class TestTreeSelectionModel
     extends DefaultTreeSelectionModel
   {
     public boolean isRowSelected(int r)
     {
       modelIsRowSelectedCalled = true;
       return super.isRowSelected(r);
     }
   }
 
   /**
    * Entry point into test suite.
    */
   public void test(TestHarness harness)
   {
-    testCallGetRowForPath(harness);
+    testCallGetPathForRow(harness);
+    testCallIsPathSelected(harness);
     testCallModelIsRowSelected(harness);
   }
 
   /**
    * Tests if isRowSelected should call JTree.getRowForPath(), or if it
    * should leave the row->path mapping to the selection model.
    *
    * @param h the test harness
    */
-  private void testCallGetRowForPath(TestHarness h)
+  private void testCallGetPathForRow(TestHarness h)
   {
-    h.checkPoint("testCallGetRowForPath");
+    h.checkPoint("testCallGetPathForRow");
+    Object[] data = new Object[]{ "Hello", "World" };
+    TestTree t = new TestTree(data);
+    getPathForRowCalled = false;
+    t.isRowSelected(0);
+    h.check(getPathForRowCalled, false);
+  }
+
+  /**
+   * Tests if isRowSelected should call JTree.isPathSelected, or if it
+   * should leave the row->path mapping to the selection model.
+   *
+   * @param h the test harness
+   */
+  private void testCallIsPathSelected(TestHarness h)
+  {
+    h.checkPoint("testCallIsPathSelected");
     Object[] data = new Object[]{ "Hello", "World" };
     TestTree t = new TestTree(data);
-    getRowForPathCalled = false;
+    isPathSelectedCalled = false;
     t.isRowSelected(0);
-    h.check(getRowForPathCalled, false);
+    h.check(isPathSelectedCalled, false);
   }
 
   /**
    * Tests if JTree.isRowSelected() should call the model's isRowSelected()
    * method.
    *
    * @param h the test harness
    */
   private void testCallModelIsRowSelected(TestHarness h)
   {
     h.checkPoint("testCallGetRowForPath");
     Object[] data = new Object[]{ "Hello", "World" };
     TestTree t = new TestTree(data);
     t.setSelectionModel(new TestTreeSelectionModel());
     modelIsRowSelectedCalled = false;

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