本文整理汇总了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();
}
});
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例11: getIdlingResource
import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@VisibleForTesting
@NonNull
public IdlingResource getIdlingResource() {
if (idlingResource == null) {
idlingResource = new RecipesIdlingResource();
}
return idlingResource;
}
示例12: getIdlingResource
import android.support.test.espresso.IdlingResource; //导入依赖的package包/类
@NonNull
public IdlingResource getIdlingResource(){
if(mIdlingResource == null) {
mIdlingResource = new SimpleIdlingResource();
}
return mIdlingResource;
}
示例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;
}
示例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);
}