Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9741/src/org/rubypeople/rdt/internal/ui/search Modified Files: TS_InternalUiRubySearch.java TC_RubySearchTreeContentProvider.java Added Files: TC_GroupByScopeStrategy.java TC_Scope.java Log Message: Search result page allows grouping by file and package (scope) --- NEW FILE: TC_Scope.java --- package org.rubypeople.rdt.internal.ui.search; import junit.framework.Assert; import junit.framework.TestCase; public class TC_Scope extends TestCase { public void testNameSimple() { Assert.assertEquals("b", new Scope("b").getName()) ; } public void testNameQualified() { Assert.assertEquals("b", new Scope("a::b").getName()) ; } } Index: TC_RubySearchTreeContentProvider.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TC_RubySearchTreeContentProvider.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TC_RubySearchTreeContentProvider.java 24 Oct 2005 22:55:12 -0000 1.1 --- TC_RubySearchTreeContentProvider.java 26 Oct 2005 21:55:03 -0000 1.2 *************** *** 51,54 **** --- 51,75 ---- } + + public void testGroupByScope() { + // could be a MockSearchResult instead + RubySearchResult rubyUISearchResult = new RubySearchResult(null); + rubySearchTreeContentProvider.setGroupByScope() ; + // call initialize before the search starts + rubySearchTreeContentProvider.initialize(rubyUISearchResult) ; + // initialize does not refresh the viewer, therefore elementsChanges is called here + MethodSymbol methodSymbol = new MethodSymbol("myModule::myScope::myMethod") ; + Path path = new Path("test") ; + Location location = new Location(path,new RdtPosition(0,0,0,0)) ; + SearchResult searchResult = new SearchResult(methodSymbol, location) ; + rubyUISearchResult.addMatch(new Match(searchResult, Match.UNIT_CHARACTER, 0, 0)); + + rubySearchTreeContentProvider.elementsChanged(new Object[]{searchResult}) ; + Assert.assertTrue(mockTreeViewer.isParentAdded(new Scope("myModule::myScope"))) ; + Assert.assertTrue(mockTreeViewer.isParentAdded(new Scope("myModule"))) ; + Assert.assertEquals(new Scope("myModule::myScope"),mockTreeViewer.childFrom(new Scope("myModule"))) ; + Assert.assertEquals(searchResult,mockTreeViewer.childFrom(new Scope("myModule::myScope"))) ; + + } } --- NEW FILE: TC_GroupByScopeStrategy.java --- package org.rubypeople.rdt.internal.ui.search; import org.eclipse.core.runtime.Path; import org.rubypeople.rdt.internal.core.parser.RdtPosition; import org.rubypeople.rdt.internal.core.symbols.Location; import org.rubypeople.rdt.internal.core.symbols.MethodSymbol; import org.rubypeople.rdt.internal.core.symbols.SearchResult; import junit.framework.Assert; import junit.framework.TestCase; public class TC_GroupByScopeStrategy extends TestCase { private GroupByScopeStrategy groupByScopeStrategy ; public void setUp() { groupByScopeStrategy = new GroupByScopeStrategy() ; } public void testNoQualifiedName() { Assert.assertEquals(null, groupByScopeStrategy.getParent(new Scope("name"))) ; } public void testQualifiedName1() { Assert.assertEquals(new Scope("pckg"), groupByScopeStrategy.getParent(new Scope("pckg::name"))) ; } public void testQualifiedName2() { Assert.assertEquals(new Scope("pckg::class"), groupByScopeStrategy.getParent(new Scope("pckg::class::name"))) ; } public void testSearchResult() { MethodSymbol methodSymbol = new MethodSymbol("clazz::myMethod") ; SearchResult searchResult = new SearchResult(methodSymbol, new Location(new Path("test"), new RdtPosition(0,0,0,0))) ; Assert.assertEquals(new Scope("clazz"), groupByScopeStrategy.getParent(searchResult)) ; } public void testOtherClass() { Assert.assertEquals(null, groupByScopeStrategy.getParent(this)) ; } } Index: TS_InternalUiRubySearch.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TS_InternalUiRubySearch.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TS_InternalUiRubySearch.java 24 Oct 2005 22:55:12 -0000 1.1 --- TS_InternalUiRubySearch.java 26 Oct 2005 21:55:03 -0000 1.2 *************** *** 19,22 **** --- 19,24 ---- TestSuite suite = new TestSuite("org.rubypeople.rdt.internal.ui.search"); suite.addTestSuite(TC_RubySearchTreeContentProvider.class); + suite.addTestSuite(TC_Scope.class) ; + suite.addTestSuite(TC_GroupByScopeStrategy.class) ; return suite; } |