From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5882 invoked by alias); 10 Oct 2006 20:22:57 -0000 Received: (qmail 5872 invoked by uid 22791); 10 Oct 2006 20:22:56 -0000 X-Spam-Check-By: sourceware.org Received: from kennke.org (HELO box7954.elkhouse.de) (213.9.79.54) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 10 Oct 2006 20:22:44 +0000 Received: from [89.49.114.255] (helo=[192.168.2.100]) by box7954.elkhouse.de with esmtpsa (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.50) id 1GWiD7-00072o-1b for mauve-patches@sources.redhat.com; Mon, 09 Oct 2006 01:37:33 +0200 Subject: FYI: Fix JTree.isRowSelected() test From: Roman Kennke To: mauve-patches Content-Type: multipart/mixed; boundary="=-k/DzCYtCm8bcusxImt9V" Date: Tue, 10 Oct 2006 20:22:00 -0000 Message-Id: <1160346821.10926.9.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 X-IsSubscribed: yes Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2006/txt/msg00689.txt.bz2 --=-k/DzCYtCm8bcusxImt9V Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 741 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 * 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 --=-k/DzCYtCm8bcusxImt9V Content-Disposition: attachment; filename=patch.diff Content-Type: text/x-patch; name=patch.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 3815 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; --=-k/DzCYtCm8bcusxImt9V--