コード例 #1
0
ファイル: BaseTest.java プロジェクト: jgraham/gecko-dev
 /** 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
ファイル: BaseTest.java プロジェクト: jgraham/gecko-dev
 /**
  * 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
ファイル: BaseTest.java プロジェクト: jgraham/gecko-dev
 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
ファイル: BaseTest.java プロジェクト: jgraham/gecko-dev
 /*
  * 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
ファイル: BaseTest.java プロジェクト: jgraham/gecko-dev
 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
ファイル: BaseTest.java プロジェクト: jgraham/gecko-dev
 // 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
ファイル: BaseTest.java プロジェクト: jgraham/gecko-dev
 @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
ファイル: UITest.java プロジェクト: JCROM-FxOS/b2jc_gecko
 @Override
 public void dumpLog(final String logtag, final String message, final Throwable t) {
   mAsserter.dumpLog(logtag + ": " + message, t);
 }
コード例 #9
0
ファイル: UITest.java プロジェクト: JCROM-FxOS/b2jc_gecko
 @Override
 public void dumpLog(final String logtag, final String message) {
   mAsserter.dumpLog(logtag + ": " + message);
 }