当前位置: 首页>>代码示例>>Java>>正文


Java IdlingResource类代码示例

本文整理汇总了Java中android.support.test.espresso.IdlingResource的典型用法代码示例。如果您正苦于以下问题:Java IdlingResource类的具体用法?Java IdlingResource怎么用?Java IdlingResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IdlingResource类属于android.support.test.espresso包,在下文中一共展示了IdlingResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: starting

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@Override
protected void starting(Description description) {
    Espresso.registerIdlingResources(new IdlingResource() {
        @Override
        public String getName() {
            return "architecture components idling resource";
        }

        @Override
        public boolean isIdleNow() {
            return TaskExecutorWithIdlingResourceRule.this.isIdle();
        }

        @Override
        public void registerIdleTransitionCallback(ResourceCallback callback) {
            callbacks.add(callback);
        }
    });
    super.starting(description);
}
 
开发者ID:googlesamples,项目名称:android-architecture-components,代码行数:21,代码来源:TaskExecutorWithIdlingResourceRule.java

示例2: setUp

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@Before public void setUp() {
  scheduler.registerIdleTransitionCallback(new IdlingResource.ResourceCallback() {
    @Override public void onTransitionToIdle() {
      idleCount.incrementAndGet();
    }
  });
}
 
开发者ID:square,项目名称:RxIdler,代码行数:8,代码来源:DelegatingIdlingResourceSchedulerTest.java

示例3: checkXMPPLoggedUserSaved

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@Test
public void checkXMPPLoggedUserSaved() throws Exception {
    assumeTrue(isUserLoggedIn());

    IdlingResource resource = startTiming(SplashActivity.WAIT_TIME);

    assumeNotNull(XMPPSession.getInstance().getXMPPConnection());
    assumeNotNull(XMPPSession.getInstance().getXMPPConnection().getUser());

    Jid jid = XMPPSession.getInstance().getXMPPConnection().getUser().asBareJid();
    assertTrue(XMPPUtils.isAutenticatedJid(jid));

    String userName = XMPPUtils.fromJIDToUserName(jid.toString());
    assertTrue(XMPPUtils.isAutenticatedUser(userName));

    stopTiming(resource);
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:18,代码来源:LoginInstrumentedTest.java

示例4: waitFor

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
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);
}
 
开发者ID:EthanCo,项目名称:AndroidTesting,代码行数:25,代码来源:TimingActivityTest.java

示例5: idleCallback

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@Test public void idleCallback() throws InterruptedException, IOException {
  server.enqueue(new MockResponse());

  OkHttpClient client = new OkHttpClient();
  IdlingResource idlingResource = OkHttp3IdlingResource.create("Ok!", client);

  final AtomicInteger count = new AtomicInteger();
  IdlingResource.ResourceCallback callback = new IdlingResource.ResourceCallback() {
    @Override public void onTransitionToIdle() {
      count.getAndIncrement();
    }
  };
  idlingResource.registerIdleTransitionCallback(callback);

  assertThat(count.get()).isEqualTo(0);

  // Use a synchronous call as a quick way to transition from busy to idle in a blocking way.
  client.newCall(new Request.Builder().url(server.url("/")).build()).execute().close();
  assertThat(count.get()).isEqualTo(1);
}
 
开发者ID:JakeWharton,项目名称:okhttp-idling-resource,代码行数:21,代码来源:OkHttp3IdlingResourceTest.java

示例6: checkConflict

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
public static void checkConflict() {
    //when: click on assess tab + plus button
    onView(withTagValue(Matchers.is((Object) PreferencesState.getInstance().getContext().getString(R.string.tab_tag_improve)))).perform(click());


    IdlingResource idlingResource = new ElapsedTimeIdlingResource(5 * 1000);
    Espresso.registerIdlingResources(idlingResource);
    String text=getActivityInstance().getApplicationContext().getString(R.string.feedback_info_conflict);
    text=text.toUpperCase();
    onView(withText(text)).perform(click());

    Espresso.unregisterIdlingResources(idlingResource);

    //Wait for SurveyService loads feedback
    idlingResource = new ElapsedTimeIdlingResource(5 * 1000);
    Espresso.registerIdlingResources(idlingResource);
    try {
        onView(withId(R.string.feedback_info_conflict)).perform(click());
    }catch (Exception e){
        //It can fail if the mobile resolution fill the text
    }

    Espresso.unregisterIdlingResources(idlingResource);

}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:26,代码来源:PushConflictTest.java

示例7: fillCompulsorySurvey

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
public static void fillCompulsorySurvey(int numQuestions, String optionValue) {
    //when: answer NO to every question
    //Wait for fragment load data from SurveyService
    IdlingResource idlingResource=null;
    onView(withTagValue(Matchers.is((Object) getActivityInstance().getApplicationContext().getString(R.string.tab_tag_assess)))).perform(click());
    for (int i = 0; i < numQuestions; i++) {
        try {
            idlingResource = new ElapsedTimeIdlingResource(1 * 1000);
            Espresso.registerIdlingResources(idlingResource);
            onData(is(instanceOf(Question.class)))
                    .inAdapterView(withId(R.id.listView))
                    .atPosition(i)
                    .onChildView(withId(R.id.answer)).onChildView(withText(optionValue))
                    .perform(click());
        } catch (NoMatchingViewException e) {
            Log.e(TAG,"Exception selecting option value " + optionValue);
        }
        finally {
            Espresso.unregisterIdlingResources(idlingResource);
        }
    }
}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:23,代码来源:SDKTestUtils.java

示例8: markCompleteAndGoImprove

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
public static Long markCompleteAndGoImprove() {
    Long idSurvey = getSurveyId();

    //when: Mark as completed
    onView(withId(R.id.score)).perform(click());
    onView(withText(MARK_AS_COMPLETED)).perform(click());
    onView(withText(android.R.string.ok)).perform(click());

    IdlingResource idlingResource = new ElapsedTimeIdlingResource(5 * 1000);
    Espresso.registerIdlingResources(idlingResource);

    onView(withTagValue(Matchers.is((Object) getActivityInstance().getApplicationContext().getString(R.string.tab_tag_improve)))).perform(click());

    Espresso.unregisterIdlingResources(idlingResource);
    return idSurvey;
}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:17,代码来源:SDKTestUtils.java

示例9: waitFor

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
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);
}
 
开发者ID:chiuki,项目名称:espresso-samples,代码行数:25,代码来源:MainActivityTest.java

示例10: getIdlingResource

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
/**
 * Only called from test, creates and returns a new {@link SimpleIdlingResource}.
 */
@VisibleForTesting
@NonNull
public IdlingResource getIdlingResource() {
    if (mIdlingResource == null) {
        mIdlingResource = new SimpleIdlingResource();
    }
    return mIdlingResource;
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:12,代码来源:MainActivity.java

示例11: getIdlingResource

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@VisibleForTesting
@NonNull
public IdlingResource getIdlingResource() {
    if (idlingResource == null) {
        idlingResource = new RecipesIdlingResource();
    }
    return idlingResource;
}
 
开发者ID:derohimat,项目名称:SgPSI,代码行数:9,代码来源:PsiListActivity.java

示例12: getIdlingResource

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@NonNull
public IdlingResource getIdlingResource(){
    if(mIdlingResource == null) {
        mIdlingResource = new SimpleIdlingResource();
    }
    return mIdlingResource;
}
 
开发者ID:harrynp,项目名称:BakingApp,代码行数:8,代码来源:MainActivityFragment.java

示例13: onIdle

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@Override
protected void onIdle() {
    super.onIdle();
    for (IdlingResource.ResourceCallback callback : callbacks) {
        callback.onTransitionToIdle();
    }
}
 
开发者ID:googlesamples,项目名称:android-architecture-components,代码行数:8,代码来源:TaskExecutorWithIdlingResourceRule.java

示例14: waitFor

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
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;
    }
 
开发者ID:hernandazevedo,项目名称:starwarsshop,代码行数:13,代码来源:ElapsedTimeIdlingResource.java

示例15: testFabButtonAndList

import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@Test
public void testFabButtonAndList() {
    IdlingResource ir = new RecyclerViewScrollingIdlingResource((RecyclerView) activity.findViewById(R.id.list));
    IdlingRegistry.getInstance().register(ir);
    Matcher listMatcher = withId(R.id.list);
    onView(listMatcher).perform(smoothScrollTo(12));
    onView(withId(R.id.fab)).perform(click());
    onView(listMatcher).perform(smoothScrollTo(0));
    onView(withId(R.id.fab)).perform(click());
    IdlingRegistry.getInstance().unregister(ir);
}
 
开发者ID:DimaKoz,项目名称:meat-grinder,代码行数:12,代码来源:MainActivityTest.java


注:本文中的android.support.test.espresso.IdlingResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。