android.support.test.espresso.IdlingResource Java Examples
The following examples show how to use
android.support.test.espresso.IdlingResource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SuntimesScreenshots1.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
private void makeScreenshots0(Context context, String languageTag, String theme) { SuntimesTestConfig configuration = defaultConfig; if (config.containsKey(languageTag)) { configuration = config.get(languageTag); } configureAppForTesting(context, languageTag, configuration, theme); activityRule.getActivity().finish(); activityRule.launchActivity(activityRule.getActivity().getIntent()); onView( withId(android.R.id.content)).perform(ViewActions.swipeUp()); long waitTime = 6 * 1000; // wait a moment IdlingResource waitForResource = new ElapsedTimeIdlingResource(waitTime); IdlingPolicies.setMasterPolicyTimeout(waitTime * 2, TimeUnit.MILLISECONDS); IdlingPolicies.setIdlingResourceTimeout(waitTime * 2, TimeUnit.MILLISECONDS); registerIdlingResources(waitForResource); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "activity-alarms0-" + theme); unregisterIdlingResources(waitForResource); }
Example #2
Source File: SuntimesScreenshots.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
private void makeScreenshots0(Context context, String languageTag, String theme) { SuntimesTestConfig configuration = defaultConfig; if (config.containsKey(languageTag)) { configuration = config.get(languageTag); } configureAppForTesting(context, languageTag, configuration, theme); activityRule.launchActivity(activityRule.getActivity().getIntent()); long waitTime = 3 * 1000; // wait a moment IdlingResource waitForResource = new ElapsedTimeIdlingResource(waitTime); IdlingPolicies.setMasterPolicyTimeout(waitTime * 2, TimeUnit.MILLISECONDS); IdlingPolicies.setIdlingResourceTimeout(waitTime * 2, TimeUnit.MILLISECONDS); registerIdlingResources(waitForResource); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "activity-main0-" + theme); unregisterIdlingResources(waitForResource); }
Example #3
Source File: RegistrationIntegrationTest.java From iroha-android with Apache License 2.0 | 6 votes |
@Test public void register_existingUsername() { onView(withId(R.id.username)).perform(typeText(EXISTING_USERNAME), closeSoftKeyboard()); onView(withId(R.id.register_button)).perform(click()); IdlingPolicies.setIdlingResourceTimeout(NETWORK_TIMEOUT_SECONDS, TimeUnit.SECONDS); IdlingPolicies.setMasterPolicyTimeout(NETWORK_TIMEOUT_SECONDS * 2, TimeUnit.SECONDS); IdlingResource idlingResource = new NetworkRequestIdlingResources(rule.getActivity().registrationPresenter); IdlingRegistry.getInstance().register(idlingResource); onView(withText(R.string.error_dialog_title)) .inRoot(isDialog()) .check(matches(isDisplayed())); onView(withText(R.string.username_already_exists_error_dialog_message)) .inRoot(isDialog()) .check(matches(isDisplayed())); onView(withText(android.R.string.ok)) .inRoot(isDialog()) .check(matches(isDisplayed())); IdlingRegistry.getInstance().unregister(idlingResource); }
Example #4
Source File: LoginInstrumentedTest.java From mangosta-android with Apache License 2.0 | 6 votes |
@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); }
Example #5
Source File: OkHttp3IdlingResourceTest.java From okhttp-idling-resource with Apache License 2.0 | 6 votes |
@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); }
Example #6
Source File: OkHttpIdlingResourceRule.java From mockwebserver-demo with Apache License 2.0 | 5 votes |
@Override public Statement apply(final Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { IdlingResource idlingResource = OkHttp3IdlingResource.create( "okhttp", OkHttp.getInstance()); Espresso.registerIdlingResources(idlingResource); base.evaluate(); Espresso.unregisterIdlingResources(idlingResource); } }; }
Example #7
Source File: SuntimesActivityTest.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
private void userSwappedCard() { Matcher<View> cardFlipper = withId(R.id.info_time_flipper1); onView(cardFlipper).check(assertShown); // flipper should be visible boolean cardSetToToday = viewIsDisplayed(R.id.info_time_all_today, "Today"); // pre-click checks if (cardSetToToday) verifyTimeCard_today(); else verifyTimeCard_tomorrow(); // click the next/prev button if (cardSetToToday) swapCardNext(); else swapCardPrev(); cardSetToToday = !cardSetToToday; // post-click checks if (cardSetToToday) verifyTimeCard_today(); else verifyTimeCard_tomorrow(); // wait a minute (and check again) long waitTime = 60 * 1000; IdlingResource waitForResource = new ElapsedTimeIdlingResource(waitTime); IdlingPolicies.setMasterPolicyTimeout(waitTime * 2, TimeUnit.MILLISECONDS); IdlingPolicies.setIdlingResourceTimeout(waitTime * 2, TimeUnit.MILLISECONDS); // during that minute // the app will update the clock and note area at least once registerIdlingResources(waitForResource); // afterward... verifyTimeCard_today(); unregisterIdlingResources(waitForResource); }
Example #8
Source File: MainMenuInstrumentedTest.java From mangosta-android with Apache License 2.0 | 5 votes |
@Test public void logoutWithMenuItem() throws Exception { assumeTrue(isUserLoggedIn()); openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext()); onView(withText(R.string.action_signout)) .check(matches(isDisplayed())) .check(matches(isEnabled())) .perform(click()); IdlingResource resource = startTiming(SplashActivity.WAIT_TIME); onView(withId(R.id.loginButton)).check(matches(isDisplayed())); stopTiming(resource); }
Example #9
Source File: MainActivity.java From testing-cin with MIT License | 5 votes |
/** * Only called from test, creates and returns a new {@link SimpleIdlingResource}. */ @VisibleForTesting @NonNull public IdlingResource getIdlingResource() { if (mIdlingResource == null) { mIdlingResource = new SimpleIdlingResource(); } return mIdlingResource; }
Example #10
Source File: FeedActivityTest.java From dev-summit-architecture-demo with Apache License 2.0 | 5 votes |
@Before public void registerIdlingResource() { mIdlingResource = new IdlingResource() { ResourceCallback mResourceCallback; @Override public String getName() { return "RecyclerView"; } @Override public boolean isIdleNow() { boolean idle = !mCreatedActivity || !getActivity().mBinding.list.hasPendingAdapterUpdates(); if (idle && mResourceCallback != null) { mResourceCallback.onTransitionToIdle(); } return idle; } @Override public void registerIdleTransitionCallback(ResourceCallback callback) { mResourceCallback = callback; } }; Espresso.registerIdlingResources(mIdlingResource); }
Example #11
Source File: LoginInstrumentedTest.java From mangosta-android with Apache License 2.0 | 5 votes |
@Test public void checkXMPPServerAndServiceInLogin() throws Exception { assumeFalse(isUserLoggedIn()); IdlingResource resource = startTiming(SplashActivity.WAIT_TIME); onView(withId(R.id.loginJidCompletionEditText)) .check(matches(withText("@" + XMPPSession.SERVICE_NAME))); onView(withId(R.id.loginServerEditText)) .check(matches(withText(XMPPSession.SERVER_NAME))); stopTiming(resource); }
Example #12
Source File: RegistrationIntegrationTest.java From iroha-android with Apache License 2.0 | 5 votes |
@Test public void register_validUsername() { onView(withId(R.id.username)).perform(typeText(username), closeSoftKeyboard()); onView(withId(R.id.register_button)).perform(click()); IdlingPolicies.setIdlingResourceTimeout(NETWORK_TIMEOUT_SECONDS, TimeUnit.SECONDS); IdlingPolicies.setMasterPolicyTimeout(NETWORK_TIMEOUT_SECONDS * 2, TimeUnit.SECONDS); IdlingResource idlingResource = new NetworkRequestIdlingResources(rule.getActivity().registrationPresenter); IdlingRegistry.getInstance().register(idlingResource); intended(hasComponent(MainActivity.class.getName())); IdlingRegistry.getInstance().unregister(idlingResource); }
Example #13
Source File: AuthActivityTest.java From AndroidSchool with Apache License 2.0 | 5 votes |
@Test public void testSuccessAuth() throws Exception { onView(withId(R.id.loginEdit)).perform(typeText("login")); closeSoftKeyboard(); onView(withId(R.id.passwordEdit)).perform(typeText("pass")); closeSoftKeyboard(); onView(withId(R.id.logInButton)).perform(click()); IdlingResource idlingResource = TimeIdlingResource.timeout(4000); Intents.intended(hasComponent(RepositoriesActivity.class.getName())); Espresso.unregisterIdlingResources(idlingResource); }
Example #14
Source File: AuthActivityTest.java From AndroidSchool with Apache License 2.0 | 5 votes |
@Test public void testErrorAuth() throws Exception { RepositoryProvider.provideKeyValueStorage().saveToken(ERROR); onView(withId(R.id.loginEdit)).perform(typeText("login")); closeSoftKeyboard(); onView(withId(R.id.passwordEdit)).perform(typeText("pass")); closeSoftKeyboard(); onView(withId(R.id.logInButton)).perform(click()); IdlingResource idlingResource = TimeIdlingResource.timeout(4000); onView(withId(R.id.loginInputLayout)).check(matches(withInputError(R.string.error))); Espresso.unregisterIdlingResources(idlingResource); }
Example #15
Source File: ThreadPoolIdlingResource.java From android-agera with Apache License 2.0 | 4 votes |
public static IdlingResource newThreadPoolIdlingResource( @NonNull final ThreadPoolExecutor executor, @NonNull final String name) { return new ThreadPoolIdlingResource(executor, name); }
Example #16
Source File: EspressoIdlingResource.java From Weather2016 with MIT License | 4 votes |
public static IdlingResource getIdlingResource() { return mCountingIdlingResource; }
Example #17
Source File: RxEspressoScheduleHandler.java From incubator-taverna-mobile with Apache License 2.0 | 4 votes |
public IdlingResource getIdlingResource() { return mCountingIdlingResource; }
Example #18
Source File: NoteDetailActivity.java From androidtestdebug with MIT License | 4 votes |
@VisibleForTesting public IdlingResource getCountingIdlingResource() { return EspressoIdlingResource.getIdlingResource(); }
Example #19
Source File: SuntimesScreenshots.java From SuntimesWidget with GNU General Public License v3.0 | 4 votes |
private void makeScreenshots1(Context context, String languageTag, String theme) { SuntimesTestConfig configuration = defaultConfig; if (config.containsKey(languageTag)) { configuration = config.get(languageTag); } configureAppForTesting(context, languageTag, configuration, theme); activityRule.launchActivity(activityRule.getActivity().getIntent()); long waitTime = 3 * 1000; // wait a moment IdlingResource waitForResource = new ElapsedTimeIdlingResource(waitTime); IdlingPolicies.setMasterPolicyTimeout(waitTime * 2, TimeUnit.MILLISECONDS); IdlingPolicies.setIdlingResourceTimeout(waitTime * 2, TimeUnit.MILLISECONDS); registerIdlingResources(waitForResource); // main activity captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "activity-main0-" + theme); // dialogs DialogTest.showAboutDialog(context, false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-about-" + theme); DialogTest.cancelAboutDialog(); DialogTest.showHelpDialog(context, false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-help-" + theme); DialogTest.cancelHelpDialog(); DialogTest.showEquinoxDialog(context, false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-equinox-" + theme); DialogTest.cancelEquinoxDialog(); DialogTest.showLightmapDialog(context, false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-lightmap-" + theme); DialogTest.cancelLightmapDialog(); TimeZoneDialogTest.showTimezoneDialog(activityRule.getActivity(), false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-timezone0-" + theme); TimeZoneDialogTest.inputTimezoneDialog_mode(context, WidgetSettings.TimezoneMode.SOLAR_TIME); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-timezone1-" + theme); TimeZoneDialogTest.cancelTimezoneDialog(); AlarmDialogTest.showAlarmDialog(context, false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-alarm-" + theme); AlarmDialogTest.cancelAlarmDialog(); TimeDateDialogTest.showDateDialog(context, false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-date-" + theme); TimeDateDialogTest.cancelDateDialog(); LocationDialogTest.showLocationDialog(false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-location0-" + theme); LocationDialogTest.editLocationDialog(false); captureScreenshot(activityRule.getActivity(), version + "/" + languageTag, "dialog-location1-" + theme); LocationDialogTest.cancelLocationDialog(context); }
Example #20
Source File: AddNoteActivity.java From androidtestdebug with MIT License | 4 votes |
@VisibleForTesting public IdlingResource getCountingIdlingResource() { return EspressoIdlingResource.getIdlingResource(); }
Example #21
Source File: EspressoIdlingResource.java From androidtestdebug with MIT License | 4 votes |
public static IdlingResource getIdlingResource() { return mCountingIdlingResource; }
Example #22
Source File: NotesActivity.java From androidtestdebug with MIT License | 4 votes |
@VisibleForTesting public IdlingResource getCountingIdlingResource() { return EspressoIdlingResource.getIdlingResource(); }
Example #23
Source File: NoteDetailActivity.java From androidtestdebug with MIT License | 4 votes |
@VisibleForTesting public IdlingResource getCountingIdlingResource() { return EspressoIdlingResource.getIdlingResource(); }
Example #24
Source File: AddNoteActivity.java From androidtestdebug with MIT License | 4 votes |
@VisibleForTesting public IdlingResource getCountingIdlingResource() { return EspressoIdlingResource.getIdlingResource(); }
Example #25
Source File: EspressoIdlingResource.java From androidtestdebug with MIT License | 4 votes |
public static IdlingResource getIdlingResource() { return mCountingIdlingResource; }
Example #26
Source File: NotesActivity.java From androidtestdebug with MIT License | 4 votes |
@VisibleForTesting public IdlingResource getCountingIdlingResource() { return EspressoIdlingResource.getIdlingResource(); }
Example #27
Source File: AbstractSimpleActivity.java From Awesome-WanAndroid with Apache License 2.0 | 4 votes |
@VisibleForTesting public IdlingResource getCountingIdlingResource() { return EspressoIdlingResource.getIdlingResource(); }
Example #28
Source File: BaseInstrumentedTest.java From mangosta-android with Apache License 2.0 | 4 votes |
protected IdlingResource startTiming(long time) { IdlingResource idlingResource = new ElapsedTimeIdlingResource(time); Espresso.registerIdlingResources(idlingResource); return idlingResource; }
Example #29
Source File: EspressoIdlingResource.java From Awesome-WanAndroid with Apache License 2.0 | 4 votes |
public static IdlingResource getIdlingResource() { return mCountingIdlingResource; }
Example #30
Source File: TasksActivity.java From android-espresso-revealed with Apache License 2.0 | 4 votes |
@VisibleForTesting public IdlingResource getCountingIdlingResource() { return EspressoIdlingResource.getIdlingResource(); }