diff --git a/mobile/android/base/tests/BaseTest.java b/mobile/android/base/tests/BaseTest.java index 43c1a03d7603..6d4f018d8de7 100644 --- a/mobile/android/base/tests/BaseTest.java +++ b/mobile/android/base/tests/BaseTest.java @@ -53,6 +53,7 @@ import android.widget.TextView; import com.jayway.android.robotium.solo.Condition; import com.jayway.android.robotium.solo.Solo; +import com.jayway.android.robotium.solo.Timeout; /** * A convenient base class suitable for most Robocop tests. @@ -396,8 +397,17 @@ abstract class BaseTest extends BaseRobocopTest { return assets.open(filename); } - public boolean waitForText(String text) { - boolean rc = mSolo.waitForText(text); + public boolean waitForText(final String text) { + // false is the default value for finding only + // visible views in `Solo.waitForText(String)`. + return waitForText(text, false); + } + + public boolean waitForText(final String text, final boolean onlyVisibleViews) { + // We use the default robotium values from + // `Waiter.waitForText(String)` for unspecified arguments. + final boolean rc = + mSolo.waitForText(text, 0, Timeout.getLargeTimeout(), true, onlyVisibleViews); if (!rc) { // log out failed wait for diagnostic purposes only; // waitForText failures are sometimes expected/normal @@ -459,7 +469,7 @@ abstract class BaseTest extends BaseRobocopTest { } - /** + /** * Select from Menu > "Settings" >
. */ public void selectSettingsItem(String section, String item) { @@ -489,7 +499,7 @@ abstract class BaseTest extends BaseRobocopTest { // build the item name ready to be used String itemName = "^" + menuItemName + "$"; mActions.sendSpecialKey(Actions.SpecialKey.MENU); - if (waitForText(itemName)) { + if (waitForText(itemName, true)) { mSolo.clickOnText(itemName); } else { // Older versions of Android have additional settings under "More", @@ -948,7 +958,7 @@ abstract class BaseTest extends BaseRobocopTest { public void setPreferenceAndWaitForChange(final JSONObject jsonPref) { mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString()); - // Get the preference name from the json and store it in an array. This array + // Get the preference name from the json and store it in an array. This array // will be used later while fetching the preference data. String[] prefNames = new String[1]; try {