Bug 1079693 - When calling waitForText in testAddonManager, only look through visible views. r=bnicholson

This commit is contained in:
Michael Comella 2014-10-14 18:32:44 -07:00
Родитель 1b1bee23f5
Коммит 34afa3ed3c
1 изменённых файлов: 15 добавлений и 5 удалений

Просмотреть файл

@ -53,6 +53,7 @@ import android.widget.TextView;
import com.jayway.android.robotium.solo.Condition; import com.jayway.android.robotium.solo.Condition;
import com.jayway.android.robotium.solo.Solo; import com.jayway.android.robotium.solo.Solo;
import com.jayway.android.robotium.solo.Timeout;
/** /**
* A convenient base class suitable for most Robocop tests. * A convenient base class suitable for most Robocop tests.
@ -396,8 +397,17 @@ abstract class BaseTest extends BaseRobocopTest {
return assets.open(filename); return assets.open(filename);
} }
public boolean waitForText(String text) { public boolean waitForText(final String text) {
boolean rc = mSolo.waitForText(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) { if (!rc) {
// log out failed wait for diagnostic purposes only; // log out failed wait for diagnostic purposes only;
// waitForText failures are sometimes expected/normal // waitForText failures are sometimes expected/normal
@ -459,7 +469,7 @@ abstract class BaseTest extends BaseRobocopTest {
} }
/** /**
* Select <item> from Menu > "Settings" > <section>. * Select <item> from Menu > "Settings" > <section>.
*/ */
public void selectSettingsItem(String section, String item) { public void selectSettingsItem(String section, String item) {
@ -489,7 +499,7 @@ abstract class BaseTest extends BaseRobocopTest {
// build the item name ready to be used // build the item name ready to be used
String itemName = "^" + menuItemName + "$"; String itemName = "^" + menuItemName + "$";
mActions.sendSpecialKey(Actions.SpecialKey.MENU); mActions.sendSpecialKey(Actions.SpecialKey.MENU);
if (waitForText(itemName)) { if (waitForText(itemName, true)) {
mSolo.clickOnText(itemName); mSolo.clickOnText(itemName);
} else { } else {
// Older versions of Android have additional settings under "More", // Older versions of Android have additional settings under "More",
@ -948,7 +958,7 @@ abstract class BaseTest extends BaseRobocopTest {
public void setPreferenceAndWaitForChange(final JSONObject jsonPref) { public void setPreferenceAndWaitForChange(final JSONObject jsonPref) {
mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString()); 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. // will be used later while fetching the preference data.
String[] prefNames = new String[1]; String[] prefNames = new String[1];
try { try {