android.support.test.espresso.IdlingRegistry Java Examples

The following examples show how to use android.support.test.espresso.IdlingRegistry. 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: CameraViewTest.java    From cameraview with Apache License 2.0 6 votes vote down vote up
@Test
public void testTakePicture() throws Exception {
    TakePictureIdlingResource resource = new TakePictureIdlingResource(
            (CameraView) rule.getActivity().findViewById(R.id.camera));
    onView(withId(R.id.camera))
            .perform(new AnythingAction("take picture") {
                @Override
                public void perform(UiController uiController, View view) {
                    CameraView cameraView = (CameraView) view;
                    cameraView.takePicture();
                }
            });
    try {
        IdlingRegistry.getInstance().register(resource);
        onView(withId(R.id.camera))
                .perform(waitFor(1000))
                .check(showingPreview());
        assertThat("Didn't receive valid JPEG data.", resource.receivedValidJpeg(), is(true));
    } finally {
        IdlingRegistry.getInstance().unregister(resource);
        resource.close();
    }
}
 
Example #2
Source File: AppNavigationTest.java    From Awesome-WanAndroid with Apache License 2.0 6 votes vote down vote up
@Test
public void clickItemShowCollectPage() {
    clickNavigationLoginShowLoginScreen();

    onView(withId(R.id.login_account_edit))
            .perform(ViewActions.typeText("2243963927"));

    onView(withId(R.id.login_password_edit))
            .perform(ViewActions.typeText("qaz123"),
                    ViewActions.closeSoftKeyboard());

    clickView(R.id.login_btn);

    //将异步请求转换为同步执行
    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    checkVisible(R.id.nav_view);

    onView(withId(R.id.nav_view))
            .perform(NavigationViewActions.navigateTo(R.id.nav_item_my_collect));

    checkVisible(R.id.collect_recycler_view);
}
 
Example #3
Source File: RegistrationIntegrationTest.java    From iroha-android with Apache License 2.0 6 votes vote down vote up
@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: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 6 votes vote down vote up
@Test
public void inputInfoAndClickSearch() {
    clickSearchPage();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    onView(withId(R.id.search_edit))
            .check(matches(isDisplayed()))
            .perform(replaceText("RxJava"))
            .check(matches(withText("RxJava")));

    onView(withId(R.id.search_tv))
            .check(matches(isDisplayed()))
            .perform(click());

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    onView(withId(R.id.search_list_refresh_layout))
            .check(matches(isDisplayed()));
}
 
Example #5
Source File: MainPagerTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void scrollListItemTagPageList() throws InterruptedException {
    clickMainPagerItemTag();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    scrollRecyclerViewToPosition(R.id.knowledge_hierarchy_list_recycler_view, 5);
}
 
Example #6
Source File: MainPagerTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void clickListItemTagPageItemLike() throws InterruptedException {
    clickMainPagerItemTag();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    clickRecyclerViewItemChildView(R.id.knowledge_hierarchy_list_recycler_view,
            0,
            R.id.item_search_pager_like_iv);
}
 
Example #7
Source File: HttpResource.java    From px-android with MIT License 5 votes vote down vote up
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            final OkHttpClient client = getClient();
            final OkHttp3IdlingResource okHttp3IdlingResource =
                OkHttp3IdlingResource.create(RES_NAME_OK_HTTP, client);
            IdlingRegistry.getInstance().register(okHttp3IdlingResource);
            base.evaluate();
            IdlingRegistry.getInstance().unregister(okHttp3IdlingResource);
        }
    };
}
 
Example #8
Source File: BaseNavigationActivityTest.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
@Before
public void beforeTest() {
  try {
    idlingResource = new OnNavigationReadyIdlingResource(rule.getActivity());
    IdlingRegistry.getInstance().register(idlingResource);
    checkViewIsDisplayed(R.id.navigationView);
    navigationView = idlingResource.getNavigationView();
  } catch (IdlingResourceTimeoutException idlingResourceTimeoutException) {
    Timber.e("Idling resource timed out. Could not validate if navigation is ready.");
    throw new RuntimeException("Could not start test for " + getActivityClass().getSimpleName() + ".\n"
      + "The ViewHierarchy doesn't contain a view with resource id = R.id.navigationView");
  }
}
 
Example #9
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void scrollListItemTagPageList() {
    clickSearchListItemTag();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    scrollRecyclerViewToPosition(R.id.knowledge_hierarchy_list_recycler_view, 5);
}
 
Example #10
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void clickListItemTagPageItemLike() {
    clickSearchListItemTag();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    clickRecyclerViewItemChildView(R.id.knowledge_hierarchy_list_recycler_view,
            0,
            R.id.item_search_pager_like_iv);
}
 
Example #11
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void clickSearchListItemTag() {
    inputInfoAndClickSearch();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    clickRecyclerViewItemChildView(R.id.normal_view,
            0,
            R.id.item_search_pager_chapterName);

    onView(withId(R.id.knowledge_hierarchy_detail_viewpager))
            .check(matches(isDisplayed()));
}
 
Example #12
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void clickSearchListLikeIv() {
    inputInfoAndClickSearch();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    clickRecyclerViewItemChildView(R.id.normal_view,
            0,
            R.id.item_search_pager_like_iv);
}
 
Example #13
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void scrollSearchList() {
    inputInfoAndClickSearch();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    swipeUpRecyclerViewToPosition(R.id.normal_view, 10);
}
 
Example #14
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void clickHotSearchItem() {
    clickSearchPage();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    onView(withText("RxJava"))
            .check(matches(isDisplayed()))
            .perform(click());

    onView(withId(R.id.search_list_refresh_layout))
            .check(matches(isDisplayed()));
}
 
Example #15
Source File: RegistrationIntegrationTest.java    From iroha-android with Apache License 2.0 5 votes vote down vote up
@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 #16
Source File: WaitForBusinessResult.java    From px-android with MIT License 4 votes vote down vote up
public WaitForBusinessResult() {
    register = IdlingRegistry.getInstance();
    activityIdlingResource = new ActivityIdlingResource(BusinessPaymentResultActivity.class);
}
 
Example #17
Source File: WaitForPaymentResult.java    From px-android with MIT License 4 votes vote down vote up
public WaitForPaymentResult() {
    register = IdlingRegistry.getInstance();
    activityIdlingResource = new ActivityIdlingResource(PaymentResultActivity.class);
}
 
Example #18
Source File: CameraViewTest.java    From cameraview with Apache License 2.0 4 votes vote down vote up
@Before
public void setUpIdlingResource() {
    mCameraViewIdlingResource = new CameraViewIdlingResource(
            (CameraView) rule.getActivity().findViewById(R.id.camera));
    IdlingRegistry.getInstance().register(mCameraViewIdlingResource);
}
 
Example #19
Source File: CameraViewTest.java    From cameraview with Apache License 2.0 4 votes vote down vote up
@After
public void tearDownIdlingResource() throws Exception {
    IdlingRegistry.getInstance().unregister(mCameraViewIdlingResource);
    mCameraViewIdlingResource.close();
}
 
Example #20
Source File: IdlingResources.java    From InstantAppStarter with MIT License 4 votes vote down vote up
public static void registerOkHttp(OkHttpClient client) {
    IdlingRegistry.getInstance().register(OkHttp3IdlingResource.create("okhttp", client));
}
 
Example #21
Source File: AppNavigationTest.java    From Awesome-WanAndroid with Apache License 2.0 4 votes vote down vote up
@After
public void testFinish() {
    IdlingRegistry.getInstance().unregister(mCountingIdlingResource);
}
 
Example #22
Source File: MainPagerTest.java    From Awesome-WanAndroid with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
    IdlingRegistry.getInstance().unregister(mCountingIdlingResource);
}
 
Example #23
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 4 votes vote down vote up
@After
public void testFinish() {
    IdlingRegistry.getInstance().unregister(mCountingIdlingResource);
}
 
Example #24
Source File: UsagePageTest.java    From Awesome-WanAndroid with Apache License 2.0 4 votes vote down vote up
@After
public void testFinish() {
    IdlingRegistry.getInstance().unregister(mCountingIdlingResource);
}
 
Example #25
Source File: KnowledgeHierarchyTest.java    From Awesome-WanAndroid with Apache License 2.0 4 votes vote down vote up
@After
public void finishTest() {
    IdlingRegistry.getInstance().unregister(mCountingIdlingResource);
}
 
Example #26
Source File: BaseNavigationActivityTest.java    From graphhopper-navigation-android with MIT License 4 votes vote down vote up
@After
public void afterTest() {
  IdlingRegistry.getInstance().unregister(idlingResource);
}
 
Example #27
Source File: MainPagerTest.java    From Awesome-WanAndroid with Apache License 2.0 3 votes vote down vote up
@Test
public void pullToRefreshListItemTagPageList() throws InterruptedException {
    clickMainPagerItemTag();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    pullToSmartRefresh(R.id.normal_view);

    Thread.sleep(DELAY_TIME);
}
 
Example #28
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 3 votes vote down vote up
@Test
public void pullToRefreshListItemTagPageList() throws InterruptedException {
    clickSearchListItemTag();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    pullToSmartRefresh(R.id.knowledge_hierarchy_list_recycler_view);

    Thread.sleep(DELAY_TIME);
}
 
Example #29
Source File: SearchPageTest.java    From Awesome-WanAndroid with Apache License 2.0 3 votes vote down vote up
@Test
public void pullToRefresh() throws InterruptedException {
    inputInfoAndClickSearch();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);
    
    pullToSmartRefresh(R.id.search_list_refresh_layout);
 
    Thread.sleep(DELAY_TIME);
}
 
Example #30
Source File: UsagePageTest.java    From Awesome-WanAndroid with Apache License 2.0 3 votes vote down vote up
@Test
public void clickUsageItem() {
    clickUsagePage();

    IdlingRegistry.getInstance().register(mCountingIdlingResource);

    clickView("掘金");

    checkVisible(R.id.article_detail_web_view);
}