mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 882191 - Wait for Settings item to be enabled before selecting; r=liuche
This commit is contained in:
parent
c8b13fc52d
commit
ff705ea969
@ -23,6 +23,7 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
@ -41,6 +42,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
|
||||
private static final int VERIFY_URL_TIMEOUT = 2000;
|
||||
private static final int MAX_LIST_ATTEMPTS = 3;
|
||||
private static final int MAX_WAIT_ENABLED_TEXT_MS = 10000;
|
||||
public static final int MAX_WAIT_MS = 3000;
|
||||
|
||||
private static Class<Activity> mLauncherActivityClass;
|
||||
@ -399,6 +401,35 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
return rc;
|
||||
}
|
||||
|
||||
public boolean waitForEnabledText(String text) {
|
||||
final String testText = text;
|
||||
boolean rc = waitForTest(new BooleanTest() {
|
||||
@Override
|
||||
public boolean test() {
|
||||
// Solo.getText() could be used here, except that it sometimes
|
||||
// hits an assertion when the requested text is not found.
|
||||
ArrayList<View> views = mSolo.getCurrentViews();
|
||||
for (View view : views) {
|
||||
if (view instanceof TextView) {
|
||||
TextView tv = (TextView)view;
|
||||
String viewText = tv.getText().toString();
|
||||
if (tv.isEnabled() && viewText != null && viewText.matches(testText)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, MAX_WAIT_ENABLED_TEXT_MS);
|
||||
if (!rc) {
|
||||
// log out failed wait for diagnostic purposes only;
|
||||
// failures are sometimes expected/normal
|
||||
mAsserter.dumpLog("waitForEnabledText timeout on "+text);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Select <item> from Menu > "Settings" > <section>
|
||||
*/
|
||||
@ -411,10 +442,10 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
section != null &&
|
||||
!section.equals("General")) {
|
||||
String sectionName = "^" + section + "$";
|
||||
waitForText(sectionName);
|
||||
waitForEnabledText(sectionName);
|
||||
mSolo.clickOnText(sectionName);
|
||||
}
|
||||
waitForText(itemName);
|
||||
waitForEnabledText(itemName);
|
||||
mSolo.clickOnText(itemName);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user