Bug 1092254 - Use Solo.waitForCondition under the hood in BaseTest.waitForTest. r=liuche, a=test-only
--- a/mobile/android/base/tests/BaseTest.java
+++ b/mobile/android/base/tests/BaseTest.java
@@ -321,35 +321,37 @@ abstract class BaseTest extends BaseRobo
if (!result) {
// Log timeout failure for diagnostic purposes only; a failed wait may
// be normal and does not necessarily warrant a test assertion/failure.
mAsserter.dumpLog("waitForCondition timeout after " + timeout + " ms.");
}
return result;
}
- // TODO: With Robotium 4.2, we should use Condition and waitForCondition instead.
- // Future boolean tests should not use this method.
- protected final boolean waitForTest(BooleanTest t, int timeout) {
- long end = SystemClock.uptimeMillis() + timeout;
- while (SystemClock.uptimeMillis() < end) {
- if (t.test()) {
- return true;
+ /**
+ * @deprecated use {@link #waitForCondition(Condition, int)} instead
+ */
+ @Deprecated
+ protected final boolean waitForTest(final BooleanTest t, final int timeout) {
+ final boolean isSatisfied = mSolo.waitForCondition(new Condition() {
+ @Override
+ public boolean isSatisfied() {
+ return t.test();
}
- mSolo.sleep(100);
+ }, timeout);
+
+ if (!isSatisfied) {
+ // log out wait failure for diagnostic purposes only;
+ // a failed wait may be normal and does not necessarily
+ // warrant a test assertion/failure
+ mAsserter.dumpLog("waitForTest timeout after " + timeout + " ms");
}
- // log out wait failure for diagnostic purposes only;
- // a failed wait may be normal and does not necessarily
- // warrant a test assertion/failure
- mAsserter.dumpLog("waitForTest timeout after "+timeout+" ms");
- return false;
+ return isSatisfied;
}
- // TODO: With Robotium 4.2, we should use Condition and waitForCondition instead.
- // Future boolean tests should not implement this interface.
protected interface BooleanTest {
public boolean test();
}
public void SqliteCompare(String dbName, String sqlCommand, ContentValues[] cvs) {
File profile = new File(mProfile);
String dbPath = new File(profile, dbName).getPath();