summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAlexander Silgidjian2013-04-01 07:19:52 (EDT)
committer Alexander Silgidjian2013-04-01 07:19:52 (EDT)
commit4974863eae06c2475e484079846d0405363e8cf7 (patch)
tree6758dec148261e0b982b8e967e8da3623466101e
parentfe6caa155c6fcce76d7c69fc3013b11206ce3c42 (diff)
downloadorg.eclipse.swtbot-4974863eae06c2475e484079846d0405363e8cf7.zip
org.eclipse.swtbot-4974863eae06c2475e484079846d0405363e8cf7.tar.gz
org.eclipse.swtbot-4974863eae06c2475e484079846d0405363e8cf7.tar.bz2
Bug 404346 - Replace usage of any() with anything()refs/changes/80/11580/1
-rw-r--r--org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotEclipseEditor.java11
-rw-r--r--org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java5
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/MenuFinderTest.java5
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/test/AbstractSWTTest.java15
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenuTest.java3
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java2
6 files changed, 23 insertions, 18 deletions
diff --git a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotEclipseEditor.java b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotEclipseEditor.java
index 014a19d..6d66d1e 100644
--- a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotEclipseEditor.java
+++ b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotEclipseEditor.java
@@ -14,7 +14,7 @@ package org.eclipse.swtbot.eclipse.finder.widgets;
import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
-import static org.hamcrest.Matchers.any;
+import static org.hamcrest.Matchers.anything;
import java.util.ArrayList;
import java.util.Arrays;
@@ -65,7 +65,8 @@ import org.hamcrest.SelfDescribing;
*/
public class SWTBotEclipseEditor extends SWTBotEditor {
- private final SWTBotStyledText styledText;
+ private final SWTBotStyledText styledText;
+ private final Matcher<SWTBotTable> anyTable = anything();
/**
* Constructs an instance of the given object.
@@ -120,7 +121,7 @@ public class SWTBotEclipseEditor extends SWTBotEditor {
* @throws WidgetNotFoundException if the quickfix could not be found.
*/
public void quickfix(int quickFixIndex) {
- WaitForObjectCondition<SWTBotTable> quickFixTableCondition = quickFixAppears(any(SWTBotTable.class));
+ WaitForObjectCondition<SWTBotTable> quickFixTableCondition = quickFixAppears(anyTable);
waitUntil(quickFixTableCondition);
SWTBotTable quickFixTable = quickFixTableCondition.get(0);
selectProposal(quickFixTable, quickFixIndex);
@@ -144,7 +145,7 @@ public class SWTBotEclipseEditor extends SWTBotEditor {
* @since 1.2
*/
public List<String> getQuickFixes() {
- WaitForObjectCondition<SWTBotTable> quickFixTableCondition = quickFixAppears(any(SWTBotTable.class));
+ WaitForObjectCondition<SWTBotTable> quickFixTableCondition = quickFixAppears(anyTable);
waitUntil(quickFixTableCondition);
SWTBotTable quickFixTable = quickFixTableCondition.get(0);
List<String> proposals = getRows(quickFixTable);
@@ -159,7 +160,7 @@ public class SWTBotEclipseEditor extends SWTBotEditor {
* @since 1.2
*/
public int getQuickfixListItemCount() {
- WaitForObjectCondition<SWTBotTable> quickFixTableCondition = quickFixAppears(any(SWTBotTable.class));
+ WaitForObjectCondition<SWTBotTable> quickFixTableCondition = quickFixAppears(anyTable);
waitUntil(quickFixTableCondition);
SWTBotTable quickFixTable = quickFixTableCondition.get(0);
return quickFixTable.rowCount();
diff --git a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java
index cba2767..bafb1c9 100644
--- a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java
+++ b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.swtbot.eclipse.finder.widgets;
-import static org.hamcrest.Matchers.any;
+import static org.hamcrest.Matchers.anything;
import java.util.ArrayList;
import java.util.List;
@@ -67,6 +67,7 @@ public abstract class SWTBotWorkbenchPart<T extends IWorkbenchPartReference> {
protected final SWTWorkbenchBot bot;
private final SelfDescribing description;
private Widget widget;
+ private final Matcher<Widget> anyWidget = anything();
/**
* Creates an instance of a workbench part.
@@ -339,7 +340,7 @@ public abstract class SWTBotWorkbenchPart<T extends IWorkbenchPartReference> {
public Widget getWidget() {
show();
if (widget == null)
- widget = findWidget(any(Widget.class));
+ widget = findWidget(anyWidget);
return widget;
}
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/MenuFinderTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/MenuFinderTest.java
index dfb1a88..289ffd6 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/MenuFinderTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/MenuFinderTest.java
@@ -12,7 +12,6 @@ package org.eclipse.swtbot.swt.finder.finders;
import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertText;
import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.pass;
-import static org.hamcrest.Matchers.any;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -32,7 +31,7 @@ public class MenuFinderTest extends AbstractMenuExampleTest {
@Test
public void clicksMenuItem() throws Exception {
- List<MenuItem> findControls = menuFinder.findMenus(any(MenuItem.class));
+ List<MenuItem> findControls = menuFinder.findMenus(anyMenuItem);
MenuItem menuItem = findControls.get(1);
try {
menuItem.notifyListeners(SWT.Selection, null);
@@ -45,7 +44,7 @@ public class MenuFinderTest extends AbstractMenuExampleTest {
@Test
public void findsAllVisibleMenus() throws Exception {
- List<MenuItem> findControls = menuFinder.findMenus(any(MenuItem.class));
+ List<MenuItem> findControls = menuFinder.findMenus(anyMenuItem);
assertEquals(25, findControls.size());
assertText("&Find...\tCtrl+F", findControls.get(21));
}
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/test/AbstractSWTTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/test/AbstractSWTTest.java
index 2c7ddfd..78c2d2f 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/test/AbstractSWTTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/test/AbstractSWTTest.java
@@ -10,13 +10,17 @@
*******************************************************************************/
package org.eclipse.swtbot.swt.finder.test;
+import static org.hamcrest.Matchers.anything;
+
import org.apache.log4j.Logger;
+import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.swt.finder.RunUIThreadRule;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.finders.ControlFinder;
import org.eclipse.swtbot.swt.finder.finders.Finder;
import org.eclipse.swtbot.swt.finder.finders.MenuFinder;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.hamcrest.Matcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.MethodRule;
@@ -36,11 +40,12 @@ public abstract class AbstractSWTTest {
java.lang.System.setProperty("org.eclipse.swt.internal.carbon.smallFonts", "");
}
- protected final Logger log = Logger.getLogger(getClass());
- protected SWTBot bot;
- protected ControlFinder controlFinder;
- protected Finder finder;
- protected MenuFinder menuFinder;
+ protected final Logger log = Logger.getLogger(getClass());
+ protected SWTBot bot;
+ protected ControlFinder controlFinder;
+ protected Finder finder;
+ protected MenuFinder menuFinder;
+ protected Matcher<MenuItem> anyMenuItem = anything();
@Rule
public MethodRule runner = new MethodRule(){
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenuTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenuTest.java
index e09dd74..d6bbdcf 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenuTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenuTest.java
@@ -11,7 +11,6 @@
package org.eclipse.swtbot.swt.finder.widgets;
import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertText;
-import static org.hamcrest.Matchers.any;
import static org.junit.Assert.assertEquals;
import java.util.List;
@@ -51,7 +50,7 @@ public class SWTBotMenuTest extends AbstractMenuExampleTest {
}
});
- List<MenuItem> findControls = menuFinder.findMenus(any(MenuItem.class));
+ List<MenuItem> findControls = menuFinder.findMenus(anyMenuItem);
MenuItem menuItem = findControls.get(14);
assertText("Last Name", menuItem);
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java
index 2ad37b7..5b28ee9 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java
@@ -55,7 +55,7 @@ public class SWTBotToolbarDropDownButtonTest extends AbstractControlExampleTest
@Test
@Ignore("Broken on cocoa")
public void getsAllMenuItems() throws Exception {
- List<? extends SWTBotMenu> menuItems = bot.toolbarDropDownButton("Drop Down").menuItems(any(MenuItem.class));
+ List<? extends SWTBotMenu> menuItems = bot.toolbarDropDownButton("Drop Down").menuItems(anyMenuItem);
menuItems.get(0).click();
assertEquals(7, menuItems.size());
}