Java 类android.support.test.espresso.IdlingPolicies 实例源码

项目:AndroidTesting    文件:TimingActivityTest.java   
private static void waitFor(long waitingTime, boolean success) {
    //Start
    onView(withId(R.id.toggle_button))
            .check(matches(withText(R.string.start)))
            .perform(click());

    //Mack sure Espresso does not time out
    IdlingPolicies.setMasterPolicyTimeout(waitingTime * 2, TimeUnit.MILLISECONDS);
    IdlingPolicies.setIdlingResourceTimeout(waitingTime * 2, TimeUnit.MILLISECONDS);

    //Now we wait
    IdlingResource idlingResource = new ElapsedTimeIdlingResource(waitingTime);
    Espresso.registerIdlingResources(idlingResource);

    //Stop and verify
    onView(withId(R.id.toggle_button))
            .check(matches(withText(R.string.stop)))
            .perform(click());
    onView(withId(R.id.result))
            .check(matches(withText(success ? R.string.success : R.string.failure)));

    //Clean up
    Espresso.unregisterIdlingResources(idlingResource);
}
项目:espresso-samples    文件:MainActivityTest.java   
private static void waitFor(long waitingTime, boolean success) {
  // Start
  onView(withId(R.id.toggle_button))
      .check(matches(withText(R.string.start)))
      .perform(click());

  // Make sure Espresso does not time out
  IdlingPolicies.setMasterPolicyTimeout(waitingTime * 2, TimeUnit.MILLISECONDS);
  IdlingPolicies.setIdlingResourceTimeout(waitingTime * 2, TimeUnit.MILLISECONDS);

  // Now we wait
  IdlingResource idlingResource = new ElapsedTimeIdlingResource(waitingTime);
  IdlingRegistry.getInstance().register(idlingResource);

  // Stop and verify
  onView(withId(R.id.toggle_button))
      .check(matches(withText(R.string.stop)))
      .perform(click());
  onView(withId(R.id.result))
      .check(matches(withText(success ? R.string.success: R.string.failure)));

  // Clean up
  IdlingRegistry.getInstance().unregister(idlingResource);
}
项目:smart-lens    文件:Delay.java   
/**
 * Register idling resource to delay for given time.
 *
 * @param waitTimeMills Wait time in millisecond.
 */
public static void startDelay(long waitTimeMills) {
    // Make sure Espresso does not time out
    IdlingPolicies.setMasterPolicyTimeout(waitTimeMills * 2, TimeUnit.MILLISECONDS);
    IdlingPolicies.setIdlingResourceTimeout(waitTimeMills * 2, TimeUnit.MILLISECONDS);

    sTimeIdlingResource = new Delay(waitTimeMills);
    Espresso.registerIdlingResources(sTimeIdlingResource);
}
项目:starwarsshop    文件:StarWarsStoreBehaviorTests.java   
@Before
public void registerIntentServiceIdlingResource() {

    unlockScreen();

    // Make sure Espresso does not time out
    IdlingPolicies.setMasterPolicyTimeout(60, TimeUnit.SECONDS);
    IdlingPolicies.setIdlingResourceTimeout(30, TimeUnit.SECONDS);

    //Wait the activity to start completely
    MainActivity activity = mActivityRule.getActivity();
    idlingResource = new MainActivityIdlingResource(activity);
    Espresso.registerIdlingResources(idlingResource);
}
项目:starwarsshop    文件:ElapsedTimeIdlingResource.java   
public static IdlingResource waitFor(long waitingTime) {

        // Make sure Espresso does not time out
        IdlingPolicies.setMasterPolicyTimeout(waitingTime * 2, TimeUnit.MILLISECONDS);
        IdlingPolicies.setIdlingResourceTimeout(waitingTime * 2, TimeUnit.MILLISECONDS);

        // Now we wait
        IdlingResource idlingResource = new ElapsedTimeIdlingResource(waitingTime);
        Espresso.registerIdlingResources(idlingResource);

        return idlingResource;
    }
项目:AndroidRTC    文件:ConnectActivityStubbedInputOutputTest.java   
@Test
public void testLoopback() throws InterruptedException {
  // The time to write down the data during closing of the program can take a while.
  IdlingPolicies.setMasterPolicyTimeout(240000, TimeUnit.MILLISECONDS);

  // During the time we sleep it will record video.
  Thread.sleep(10000);

  // Click on hang-up button.
  onView(withId(R.id.button_call_disconnect)).perform(click());
}
项目:kheera-testrunner-android    文件:LoginPageFeatureFile.java   
@OnStartTest()
public void onStartTest(String featureName, String scenarioName) {

    IdlingPolicies.setMasterPolicyTimeout(30, TimeUnit.SECONDS);

    Log.v(runnerConfig.LogTag, "Starting Test: " + featureName + " - " + scenarioName);
    Intents.init();
}
项目:AndroidArchitecture    文件:TestUtils.java   
@NonNull
public static IdlingResource waitForDialog(@NonNull FragmentManager fragmentManager, @NonNull String tag) {
    IdlingPolicies.setMasterPolicyTimeout(3, TimeUnit.SECONDS);
    IdlingPolicies.setIdlingResourceTimeout(3, TimeUnit.SECONDS);

    IdlingResource idlingResource = new DialogFragmentIdlingResource(fragmentManager, tag);
    Espresso.registerIdlingResources(idlingResource);

    return idlingResource;
}
项目:delern    文件:FirebaseOperationInProgressRule.java   
@Override
protected void before() throws Throwable {
    // Raise Idling policy timeout because emulator or network can be really slow.
    IdlingPolicies.setIdlingResourceTimeout(2, TimeUnit.MINUTES);
    IdlingPolicies.setMasterPolicyTimeout(2, TimeUnit.MINUTES);
    if (mDefaultEnabled) {
        enableForCurrentTestCase();
    }
}
项目:espresso-doppio    文件:BaseIdlingResource.java   
public BaseIdlingResource() {
    IdlingPolicies.setIdlingResourceTimeout(DEFAULT_IDLING_TIMEOUT, TimeUnit.MILLISECONDS);
}
项目:espresso-doppio    文件:BaseIdlingResource.java   
public BaseIdlingResource(long timeout) {
    IdlingPolicies.setIdlingResourceTimeout(timeout, TimeUnit.MILLISECONDS);
}
项目:AndroidTesting    文件:TimingActivityTest.java   
@Before
public void resetTimeout() {
    IdlingPolicies.setMasterPolicyTimeout(60, TimeUnit.SECONDS);
    IdlingPolicies.setIdlingResourceTimeout(26, TimeUnit.SECONDS);
}
项目:bluesnap-android-int    文件:EspressoBasedTest.java   
public void detectIfNoToken() {
    IdlingPolicies.setMasterPolicyTimeout(60, TimeUnit.SECONDS);
    IdlingPolicies.setIdlingResourceTimeout(60, TimeUnit.SECONDS);
    checkToken();

}
项目:EDSApp    文件:SDKTestUtils.java   
public static void setTestTimeoutSeconds(int seconds) {
    IdlingPolicies.setMasterPolicyTimeout(
            seconds, TimeUnit.SECONDS);
    IdlingPolicies.setIdlingResourceTimeout(
            seconds, TimeUnit.SECONDS);
}
项目:Meducated-Ninja    文件:SplashActivityTest.java   
@Before
public void setUp() {
    // ensure that espresso doesn't time out while we're intentionally idling.
    IdlingPolicies.setMasterPolicyTimeout(SplashActivity.DISPLAY_TIME * 2, TimeUnit.MILLISECONDS);
    IdlingPolicies.setIdlingResourceTimeout(SplashActivity.DISPLAY_TIME * 2, TimeUnit.MILLISECONDS);
}
项目:malariapp    文件:SDKTestUtils.java   
public static void setTestTimeoutSeconds(int seconds) {
    IdlingPolicies.setMasterPolicyTimeout(
            seconds, TimeUnit.SECONDS);
    IdlingPolicies.setIdlingResourceTimeout(
            seconds, TimeUnit.SECONDS);
}
项目:espresso-samples    文件:MainActivityTest.java   
@Before
public void resetTimeout() {
  IdlingPolicies.setMasterPolicyTimeout(60, TimeUnit.SECONDS);
  IdlingPolicies.setIdlingResourceTimeout(26, TimeUnit.SECONDS);
}
项目:breadwallet-android    文件:JUnit4StyleTests.java   
@BeforeClass
public static void beforeClass() {
    IdlingPolicies.setMasterPolicyTimeout(600, TimeUnit.SECONDS);
    IdlingPolicies.setIdlingResourceTimeout(600, TimeUnit.SECONDS);
}
项目:Man-Man    文件:ApplicationTest.java   
@Before
public void espressoPreconditions() {
    IdlingPolicies.setMasterPolicyTimeout(10, TimeUnit.MINUTES);
}