本文整理匯總了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);
}