Bug 491472: TimeoutException thrown instead of WidgetNotFoundException
Methods that find menus or menu items specify that they throw a
WidgetNotFoundException, but sometimes throw a TimeoutException instead.
The methods are fixed to throw a WidgetNotFoundException. The Javadoc is
updated with a @throws tag where it was missing.
Change-Id: Ic4e035f74ceff867d5844f146440a8272ede5538
diff --git a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotView.java b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotView.java
index 5945e6a..f9a1f79 100644
--- a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotView.java
+++ b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotView.java
@@ -107,11 +107,12 @@
* Gets the view menu of this view.
*
* @return the view menu.
+ * @throws WidgetNotFoundException if the widget is not found.
* @since 2.4
*/
public SWTBotRootMenu viewMenu() {
WaitForObjectCondition<Menu> waitForMenu = Conditions.waitForViewMenu(partReference);
- new SWTBot().waitUntil(waitForMenu);
+ new SWTBot().waitUntilWidgetAppears(waitForMenu);
return new SWTBotRootMenu(waitForMenu.get(0));
}
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/SWTBotFactory.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/SWTBotFactory.java
index 9a0d1a7..9b185b6 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/SWTBotFactory.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/SWTBotFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 Ketan Padegaonkar and others.
+ * Copyright (c) 2008, 2016 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@
* Ketan Patel - (Bug 259860)
* Mickael Istria (Red Hat Inc.) - Bug 422458
* Lorenzo Bettini - https://bugs.eclipse.org/bugs/show_bug.cgi?id=464687
- * Patrick Tasse - Improve SWTBot menu API and implementation (Bug 479091)
+ * Patrick Tasse - Improve SWTBot menu API and implementation (Bug 479091)
*******************************************************************************/
package org.eclipse.swtbot.swt.finder;
@@ -198,6 +198,7 @@
* Gets the menu bar of the active shell.
*
* @return the menu bar.
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotRootMenu menu() {
return menu(activeShell());
@@ -208,6 +209,7 @@
*
* @param shell the shell.
* @return the menu bar.
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotRootMenu menu(SWTBotShell shell) {
WaitForObjectCondition<Menu> waitForMenu = Conditions.waitForMenuBar(shell);
@@ -225,6 +227,7 @@
* @param text
* the text on the menu.
* @return a menu item that matches the specified text.
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotMenu menu(String text) {
return menu().menu(text, true, 0);
@@ -240,6 +243,7 @@
* @param text the text on the menu.
* @param index the index of the menu item, in case there are multiple matching menu items.
* @return a menu item that matches the specified text.
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotMenu menu(String text, int index) {
return menu().menu(text, true, index);
@@ -255,6 +259,7 @@
* @param text the text on the menu.
* @param recursive if set to true, will find depth-first in sub-menus as well.
* @return a menu item that matches the specified text.
+ * @throws WidgetNotFoundException if the widget is not found.
* @since 2.3
*/
public SWTBotMenu menu(String text, boolean recursive) {
@@ -272,6 +277,7 @@
* @param value the value of the id.
* @return a wrapper around a @{link MenuItem} with the specified key/value pair for its id.
* @see SWTBotPreferences#DEFAULT_KEY
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotMenu menuWithId(String value) {
return menu().menuWithId(SWTBotPreferences.DEFAULT_KEY, value, true, 0);
@@ -289,6 +295,7 @@
* @param index the index of the menu item, in case there are multiple matching menu items.
* @return a wrapper around a @{link MenuItem} with the specified key/value pair for its id.
* @see SWTBotPreferences#DEFAULT_KEY
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotMenu menuWithId(String value, int index) {
return menu().menuWithId(SWTBotPreferences.DEFAULT_KEY, value, true, index);
@@ -304,6 +311,7 @@
* @param key the key of the id.
* @param value the value of the id.
* @return a wrapper around a @{link MenuItem} with the specified key/value pair for its id.
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotMenu menuWithId(String key, String value) {
return menu().menuWithId(key, value, true, 0);
@@ -320,6 +328,7 @@
* @param value the value of the id.
* @param index the index of the menu item, in case there are multiple matching menu items.
* @return a wrapper around a @{link Menu} with the specified key/value pair for its id.
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotMenu menuWithId(String key, String value, int index) {
return menu().menuWithId(key, value, true, index);
@@ -336,6 +345,7 @@
* @param matcher the matcher used to find the menu.
* @param index the index of the menu item, in case there are multiple matching menu items.
* @return a menu item that matches the specified matcher.
+ * @throws WidgetNotFoundException if the widget is not found.
*/
public SWTBotMenu menu(SWTBotShell shell, Matcher<MenuItem> matcher, int index) {
return menu(shell).menu(matcher, true, index);
@@ -352,6 +362,7 @@
* @param matcher the matcher used to find the menu.
* @param recursive if set to true, will find depth-first in sub-menus as well.
* @return a menu item that matches the specified matcher.
+ * @throws WidgetNotFoundException if the widget is not found.
* @since 2.2
*/
public SWTBotMenu menu(SWTBotShell shell, Matcher<MenuItem> matcher, boolean recursive) {
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/AbstractSWTBot.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/AbstractSWTBot.java
index f949ba2..ec20eb9 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/AbstractSWTBot.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/AbstractSWTBot.java
@@ -8,7 +8,7 @@
* Contributors:
* Ketan Padegaonkar - initial API and implementation
* Lorenzo Bettini - (Bug 426869) mark new methods with since annotation
- * Patrick Tasse - Improve SWTBot menu API and implementation (Bug 479091)
+ * Patrick Tasse - Improve SWTBot menu API and implementation (Bug 479091)
* Aparna Argade(Cadence Design Systems, Inc.) - Bug 489179
*******************************************************************************/
package org.eclipse.swtbot.swt.finder.widgets;
@@ -440,7 +440,7 @@
ContextMenuHelper.notifyMenuDetect(control, widget);
WaitForObjectCondition<Menu> waitForMenu = Conditions.waitForPopupMenu(control);
- new SWTBot().waitUntil(waitForMenu);
+ new SWTBot().waitUntilWidgetAppears(waitForMenu);
return new SWTBotRootMenu(waitForMenu.get(0));
}
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenu.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenu.java
index 38cc372..cca7559 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenu.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotMenu.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 Ketan Padegaonkar and others.
+ * Copyright (c) 2008, 2016 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,7 @@
* Contributors:
* Ketan Padegaonkar - initial API and implementation
* Patrick Tasse - Fix radio menu item click behavior (Bug 451126 & Bug 397649)
- * - Improve SWTBot menu API and implementation (Bug 479091)
+ * - Improve SWTBot menu API and implementation (Bug 479091)
*******************************************************************************/
package org.eclipse.swtbot.swt.finder.widgets;
@@ -256,7 +256,7 @@
*/
public SWTBotMenu menu(Matcher<MenuItem> matcher, final boolean recursive, final int index) throws WidgetNotFoundException {
WaitForObjectCondition<MenuItem> waitForMenuItem = Conditions.waitForMenuItem(this, matcher, recursive, index);
- new SWTBot().waitUntil(waitForMenuItem);
+ new SWTBot().waitUntilWidgetAppears(waitForMenuItem);
return new SWTBotMenu(waitForMenuItem.get(0), matcher);
}
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotRootMenu.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotRootMenu.java
index 06562cd..1507eab 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotRootMenu.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotRootMenu.java
@@ -119,7 +119,7 @@
*/
public SWTBotMenu menu(final Matcher<MenuItem> matcher, final boolean recursive, final int index) throws WidgetNotFoundException {
WaitForObjectCondition<MenuItem> waitForMenuItem = Conditions.waitForMenuItem(this, matcher, recursive, index);
- new SWTBot().waitUntil(waitForMenuItem);
+ new SWTBot().waitUntilWidgetAppears(waitForMenuItem);
return new SWTBotMenu(waitForMenuItem.get(0), matcher);
}