From: <gjo...@us...> - 2007-04-20 16:20:35
|
Revision: 2340 http://abbot.svn.sourceforge.net/abbot/?rev=2340&view=rev Author: gjohnsto Date: 2007-04-20 09:20:36 -0700 (Fri, 20 Apr 2007) Log Message: ----------- Significant refactoring, renaming & generification of Finder, Matcher hierarchies: New Old --- --- (Finder<Node>) FinderImpl<Node> WidgetFinderImpl (WidgetFinder) (WidgetFinder) WidgetFinderImpl BasicFinder FinderException WidgetSearchException NotFoundException WidgetNotFoundException MultipleFoundException MultipleWidgetsFoundException (Matcher<Node>) ClassMatcher<Node> WidgetClassMatcher ClassMatcher WidgetClassMultiMatcher ClassMultiMatcher IndexedClassMultiMatcher WidgetDataMatcher DataMatcher StringDataMatcher WidgetTextMatcher Textmatcher DecorationsMatcher ShellMatcher TextMultiMatcher IndexedTextMultiMatcher CompositeMatcher<Node> CompositeMultiMatcher<Node> CompositeWidgetMatcher CompositeWidgetMultiMatcher IdentityMatcher<Node> WidgetIdentityMatcher IdentityMatcher WidgetVisibleMatcher VisibleMatcher (MultiMatcher<Node>) CompositeMultiMatcher<Node> ... (WidgetMultiMatcher) (MultiMatcher) IndexedMultiMatcher TextMultiMatcher ... WidgetClassMultiMatcher ... (WidgetMatcher) (Matcher) StyleMatcher WidgetStyleMatcher ... Modified Paths: -------------- abbot.swt/trunk/abbot.swt.eclipse/doc/AbbotTutorial.html abbot.swt/trunk/abbot.swt.eclipse/src/abbot/swt/eclipse/utils/InvokeNewWizard.java abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/AbstractDialogTester.java abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseCancelDialogTester.java abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseFinishCancelDialogTester.java abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseOKCancelDialogTester.java Modified: abbot.swt/trunk/abbot.swt.eclipse/doc/AbbotTutorial.html =================================================================== --- abbot.swt/trunk/abbot.swt.eclipse/doc/AbbotTutorial.html 2007-04-20 16:20:29 UTC (rev 2339) +++ abbot.swt/trunk/abbot.swt.eclipse/doc/AbbotTutorial.html 2007-04-20 16:20:36 UTC (rev 2340) @@ -219,7 +219,7 @@ assertTrue("Description message incorrect. - Create a new Java class.", message.getText().trim().compareTo("Create a new Java class.") == 0); System.out.println("Description Message Correct"); - } catch (WidgetNotFoundException e) { + } catch (NotFoundException e) { e.printStackTrace(); fail("Widget not found"); } catch (MultipleWidgetsFoundException e) { @@ -248,7 +248,7 @@ // Test #7 - check that the new file exists assertTrue(project.getFile("/abbot/swt/eclipse/example/SampleJavaClass.java").exists()); System.out.println("The new Java class file exists"); - } catch (WidgetNotFoundException e) { + } catch (NotFoundException e) { e.printStackTrace(); fail("Widget not found"); } catch (MultipleWidgetsFoundException e) { Modified: abbot.swt/trunk/abbot.swt.eclipse/src/abbot/swt/eclipse/utils/InvokeNewWizard.java =================================================================== --- abbot.swt/trunk/abbot.swt.eclipse/src/abbot/swt/eclipse/utils/InvokeNewWizard.java 2007-04-20 16:20:29 UTC (rev 2339) +++ abbot.swt/trunk/abbot.swt.eclipse/src/abbot/swt/eclipse/utils/InvokeNewWizard.java 2007-04-20 16:20:36 UTC (rev 2340) @@ -7,12 +7,12 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; -import abbot.swt.finder.BasicFinder; -import abbot.swt.finder.MultipleWidgetsFoundException; +import abbot.swt.finder.WidgetFinderImpl; import abbot.swt.finder.WidgetFinder; -import abbot.swt.finder.WidgetNotFoundException; -import abbot.swt.finder.matchers.ClassMatcher; -import abbot.swt.finder.matchers.TextMatcher; +import abbot.swt.finder.generic.MultipleFoundException; +import abbot.swt.finder.generic.NotFoundException; +import abbot.swt.finder.matchers.WidgetClassMatcher; +import abbot.swt.finder.matchers.WidgetTextMatcher; import abbot.swt.tester.TreeItemTester; import abbot.swt.tester.WidgetTester; @@ -59,7 +59,7 @@ // get a BasicFinder final Display display = parentShell.getDisplay(); - final WidgetFinder finder = BasicFinder.getDefault(); + final WidgetFinder finder = WidgetFinderImpl.getDefault(); // thread to drive new wizard final Thread wizMain = new Thread() { @@ -67,15 +67,15 @@ WidgetTester.waitForShellShowing(NEW_WIZARD_TITLE); try { - Tree tree = (Tree)finder.find (new ClassMatcher(Tree.class)); - Shell newWizardShell = (Shell) finder.find(new TextMatcher(NEW_WIZARD_TITLE)); + Tree tree = (Tree)finder.find (new WidgetClassMatcher(Tree.class)); + Shell newWizardShell = (Shell) finder.find(new WidgetTextMatcher(NEW_WIZARD_TITLE)); treeItemTester.actionClickTreeItem(wizardPath, aDelim, tree, 2); //treeItemTester.actionClickTreeItem(wizardPath, tree, newWizardShell, 100, 2); - } catch (WidgetNotFoundException e) { + } catch (NotFoundException e) { e.printStackTrace(); // finder.printWidgets(); fail("widget not found"); //$NON-NLS-1$ - } catch (MultipleWidgetsFoundException e) { + } catch (MultipleFoundException e) { e.printStackTrace(); // finder.printWidgets(); fail("multiple widgets found"); //$NON-NLS-1$ Modified: abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/AbstractDialogTester.java =================================================================== --- abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/AbstractDialogTester.java 2007-04-20 16:20:29 UTC (rev 2339) +++ abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/AbstractDialogTester.java 2007-04-20 16:20:36 UTC (rev 2340) @@ -9,14 +9,14 @@ import org.eclipse.swt.widgets.Shell; import abbot.swt.Log; -import abbot.swt.finder.BasicFinder; -import abbot.swt.finder.Matcher; -import abbot.swt.finder.MultipleWidgetsFoundException; +import abbot.swt.finder.WidgetFinderImpl; import abbot.swt.finder.WidgetFinder; -import abbot.swt.finder.WidgetNotFoundException; -import abbot.swt.finder.matchers.ClassMatcher; -import abbot.swt.finder.matchers.CompositeMatcher; -import abbot.swt.finder.matchers.TextMatcher; +import abbot.swt.finder.generic.MultipleFoundException; +import abbot.swt.finder.generic.NotFoundException; +import abbot.swt.finder.matchers.CompositeWidgetMatcher; +import abbot.swt.finder.matchers.WidgetClassMatcher; +import abbot.swt.finder.matchers.WidgetMatcher; +import abbot.swt.finder.matchers.WidgetTextMatcher; import abbot.swt.script.Condition; import abbot.swt.tester.ButtonTester; import abbot.swt.tester.Robot; @@ -73,7 +73,7 @@ this.timeoutMinutes = timeoutMinutes; this.timeoutCloseSeconds = DEFAULT_TIMEOUT_CLOSE_SECONDS; this.timeoutForInvokeFailureOrShellShowingSeconds = DEFAULT_TIMEOUT_INVOKEFAILURE_OR_SHELLSHOWING_SECONDS; - this.finder = BasicFinder.getDefault(); + this.finder = WidgetFinderImpl.getDefault(); } protected Robot getRobot() { @@ -82,18 +82,17 @@ return robot; } - protected void clickButton(Composite root, String label) throws WidgetNotFoundException, - MultipleWidgetsFoundException { + protected void clickButton(Composite root, String label) throws NotFoundException, + MultipleFoundException { clickButton(root, makeClassAndTextMatcher(Button.class, label)); } - protected void clickButton(String label) throws WidgetNotFoundException, - MultipleWidgetsFoundException { + protected void clickButton(String label) throws NotFoundException, MultipleFoundException { clickButton(shell, makeClassAndTextMatcher(Button.class, label)); } - protected void clickButton(final Composite root, final Matcher m) - throws WidgetNotFoundException, MultipleWidgetsFoundException { + protected void clickButton(final Composite root, final WidgetMatcher m) + throws NotFoundException, MultipleFoundException { final Composite searchRoot = (root == null) ? shell : root; final Button btn = (Button) finder.find(searchRoot, m); @@ -114,11 +113,11 @@ tester.actionClick(btn); } - protected static Matcher makeClassAndTextMatcher(Class clazz, String text) { - TextMatcher textMatcher = new TextMatcher(text); - ClassMatcher classMatcher = new ClassMatcher(clazz); - CompositeMatcher compMatcher = new CompositeMatcher(new Matcher[] { textMatcher, - classMatcher }); + protected static WidgetMatcher makeClassAndTextMatcher(Class clazz, String text) { + WidgetTextMatcher textMatcher = new WidgetTextMatcher(text); + WidgetClassMatcher classMatcher = new WidgetClassMatcher(clazz); + CompositeWidgetMatcher compMatcher = new CompositeWidgetMatcher(new WidgetMatcher[] { + textMatcher, classMatcher }); return compMatcher; } @@ -285,8 +284,7 @@ } } - protected void waitForDialogShowing() throws WidgetNotFoundException, - MultipleWidgetsFoundException { + protected void waitForDialogShowing() throws NotFoundException, MultipleFoundException { // Displays.waitForIdle(); // @todo: can we get rid of this waitForIdle? waitForShellShowing(title, display); shell = (Shell) finder.find(makeClassAndTextMatcher(Shell.class, title)); Modified: abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseCancelDialogTester.java =================================================================== --- abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseCancelDialogTester.java 2007-04-20 16:20:29 UTC (rev 2339) +++ abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseCancelDialogTester.java 2007-04-20 16:20:36 UTC (rev 2340) @@ -4,7 +4,7 @@ import org.eclipse.swt.widgets.Display; -import abbot.swt.finder.WidgetSearchException; +import abbot.swt.finder.generic.FinderException; /** * abstract base class for testing wizard dialogs in order to close the dialog, this class clicks @@ -30,7 +30,7 @@ protected void doCloseDialog() { try { clickButton(BUTTON_CANCEL); - } catch (WidgetSearchException e) { + } catch (FinderException e) { throw new RuntimeException(e); } } Modified: abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseFinishCancelDialogTester.java =================================================================== --- abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseFinishCancelDialogTester.java 2007-04-20 16:20:29 UTC (rev 2339) +++ abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseFinishCancelDialogTester.java 2007-04-20 16:20:36 UTC (rev 2340) @@ -2,7 +2,7 @@ import org.eclipse.swt.widgets.Display; -import abbot.swt.finder.WidgetSearchException; +import abbot.swt.finder.generic.FinderException; /** * abstract base class for testing wizard dialogs @@ -31,7 +31,7 @@ // if (ok) { try { clickButton(BUTTON_FINISH); - } catch (WidgetSearchException e) { + } catch (FinderException e) { throw new RuntimeException(e); } // } else { Modified: abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseOKCancelDialogTester.java =================================================================== --- abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseOKCancelDialogTester.java 2007-04-20 16:20:29 UTC (rev 2339) +++ abbot.swt/trunk/abbot.swt.eclipse/src/abbot/tester/swt/eclipse/BaseOKCancelDialogTester.java 2007-04-20 16:20:36 UTC (rev 2340) @@ -2,7 +2,7 @@ import org.eclipse.swt.widgets.Display; -import abbot.swt.finder.WidgetSearchException; +import abbot.swt.finder.generic.FinderException; /** * abstract base class for testing dialogs in order to close the dialog, this class clicks OK if @@ -24,7 +24,7 @@ // if (ok) { try { clickButton(BUTTON_OK); - } catch (WidgetSearchException e) { + } catch (FinderException e) { throw new RuntimeException(e); } // } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |