예제 #1
0
 /** Wait for <text> to be visible and also be enabled/clickable. */
 public boolean waitForEnabledText(String text) {
   final String testText = text;
   boolean rc =
       waitForCondition(
           new Condition() {
             @Override
             public boolean isSatisfied() {
               // 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;
 }
예제 #2
0
 /**
  * Load <code>url</code> using reflection and the internal <code>org.mozilla.gecko.Tabs</code>
  * API.
  *
  * <p>This method does not wait for any confirmation from Gecko before returning.
  */
 protected final void loadUrl(final String url) {
   try {
     Tabs.getInstance().loadUrl(url);
   } catch (Exception e) {
     mAsserter.dumpLog("Exception in loadUrl", e);
     throw new RuntimeException(e);
   }
 }
예제 #3
0
 public boolean waitForText(String text) {
   boolean rc = mSolo.waitForText(text);
   if (!rc) {
     // log out failed wait for diagnostic purposes only;
     // waitForText failures are sometimes expected/normal
     mAsserter.dumpLog("waitForText timeout on " + text);
   }
   return rc;
 }
예제 #4
0
 /*
  * Wrapper method for mSolo.waitForCondition with additional logging.
  */
 protected final boolean waitForCondition(Condition condition, int timeout) {
   boolean result = mSolo.waitForCondition(condition, timeout);
   if (!result) {
     // Log timeout failure for diagnostic purposes only; a failed wait may
     // be normal and does not necessarily warrant a test asssertion/failure.
     mAsserter.dumpLog("waitForCondition timeout after " + timeout + " ms.");
   }
   return result;
 }
예제 #5
0
 protected void blockForGeckoReady() {
   try {
     Actions.EventExpecter geckoReadyExpector = mActions.expectGeckoEvent("Gecko:Ready");
     if (!GeckoThread.checkLaunchState(LaunchState.GeckoRunning)) {
       geckoReadyExpector.blockForEvent(GECKO_READY_WAIT_MS, true);
     }
     geckoReadyExpector.unregisterListener();
   } catch (Exception e) {
     mAsserter.dumpLog("Exception in blockForGeckoReady", e);
   }
 }
예제 #6
0
 // 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;
     }
     mSolo.sleep(100);
   }
   // 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;
 }
예제 #7
0
 @Override
 protected void runTest() throws Throwable {
   try {
     super.runTest();
   } catch (Throwable t) {
     // save screenshot -- written to /mnt/sdcard/Robotium-Screenshots
     // as <filename>.jpg
     mSolo.takeScreenshot("robocop-screenshot");
     if (mAsserter != null) {
       mAsserter.dumpLog("Exception caught during test!", t);
       mAsserter.ok(false, "Exception caught", t.toString());
     }
     // re-throw to continue bail-out
     throw t;
   }
 }
예제 #8
0
 @Override
 public void dumpLog(final String logtag, final String message, final Throwable t) {
   mAsserter.dumpLog(logtag + ": " + message, t);
 }
예제 #9
0
 @Override
 public void dumpLog(final String logtag, final String message) {
   mAsserter.dumpLog(logtag + ": " + message);
 }