* FYI: Fix JTree.isRowSelected() test
@ 2006-10-10 20:22 Roman Kennke
0 siblings, 0 replies; only message in thread
From: Roman Kennke @ 2006-10-10 20:22 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 741 bytes --]
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
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 3815 bytes --]
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-10-10 20:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-10 20:22 FYI: Fix JTree.isRowSelected() test Roman Kennke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).