Search in sources :

Example 1 with CountingIdlingResource

use of androidx.test.espresso.idling.CountingIdlingResource in project RxBinding by JakeWharton.

the class RxSlidingPaneLayoutTest method setUp.

@Before
public void setUp() {
    RxSlidingPaneLayoutTestActivity activity = activityRule.getActivity();
    view = activity.slidingPaneLayout;
    idler = new CountingIdlingResource("counting idler");
    idlingRegistry.register(idler);
}
Also used : CountingIdlingResource(androidx.test.espresso.idling.CountingIdlingResource) Before(org.junit.Before)

Example 2 with CountingIdlingResource

use of androidx.test.espresso.idling.CountingIdlingResource in project android-test by android.

the class IdlingTest method register.

public void register() throws Exception {
    resource = new CountingIdlingResource("counter");
    IdlingRegistry.getInstance().register(resource);
    IdlingUIActivity.listener = new IdlingUIActivity.Listener() {

        @Override
        public void onLoadStarted() {
            resource.increment();
        }

        @Override
        public void onLoadFinished() {
            resource.decrement();
        }
    };
}
Also used : CountingIdlingResource(androidx.test.espresso.idling.CountingIdlingResource)

Example 3 with CountingIdlingResource

use of androidx.test.espresso.idling.CountingIdlingResource in project whiteboard-android by netless-io.

the class RoomActivityTest method setScenePath.

@Test
public void setScenePath() {
    onIdle();
    CountingIdlingResource idlingResource = new CountingIdlingResource("getScenePath");
    idlingResource.increment();
    mActivity.mRoom.getSceneState(new Promise<SceneState>() {

        @Override
        public void then(SceneState sceneState) {
            currentSceneState = sceneState;
            idlingResource.decrement();
        }

        @Override
        public void catchEx(SDKError t) {
            idlingResource.decrement();
        }
    });
    IdlingRegistry.getInstance().register(idlingResource);
    SetScenePathResult result = new SetScenePathResult();
    result.register();
    onView(isRoot()).perform(new SimpleViewAction() {

        @Override
        public void perform(UiController uiController, View view) {
            IdlingRegistry.getInstance().unregister(idlingResource);
            if (currentSceneState == null) {
                fail();
            }
            result.start();
            mActivity.mRoom.setScenePath(getNextScenePath(currentSceneState), result);
        }

        private String getNextScenePath(SceneState currentSceneState) {
            String dir = currentSceneState.getScenePath().substring(0, currentSceneState.getScenePath().lastIndexOf('/'));
            int index = currentSceneState.getIndex();
            Scene[] scenes = currentSceneState.getScenes();
            Scene tScene = scenes[(index + 1) % scenes.length];
            return dir + '/' + tScene.getName();
        }
    });
    // wait for idling
    onIdle();
    onView(isRoot()).perform(new SimpleViewAction() {

        @Override
        public void perform(UiController uiController, View view) {
            assertEquals(true, result.success);
            result.unregister();
        }
    });
}
Also used : CountingIdlingResource(androidx.test.espresso.idling.CountingIdlingResource) SDKError(com.herewhite.sdk.domain.SDKError) SimpleViewAction(com.herewhite.demo.utils.SimpleViewAction) SceneState(com.herewhite.sdk.domain.SceneState) UiController(androidx.test.espresso.UiController) Scene(com.herewhite.sdk.domain.Scene) View(android.view.View) Espresso.onView(androidx.test.espresso.Espresso.onView) Test(org.junit.Test)

Example 4 with CountingIdlingResource

use of androidx.test.espresso.idling.CountingIdlingResource in project android-test by android.

the class AdvancedSynchronizationTest method setUp.

@Before
public void setUp() throws Exception {
    ActivityScenario<SyncActivity> activityScenario = ActivityScenario.launch(SyncActivity.class);
    activityScenario.onActivity(activity -> {
        HelloWorldServer realServer = activity.getHelloWorldServer();
        // Here, we use CountingIdlingResource - a common convenience class - to track the idle
        // state of
        // the server. You could also do this yourself, by implementing the IdlingResource
        // interface.
        countingResource = new CountingIdlingResource("HelloWorldServerCalls");
        activity.setHelloWorldServer(new DecoratedHelloWorldServer(realServer, countingResource));
        assertTrue(registerIdlingResources(countingResource));
    });
}
Also used : HelloWorldServer(androidx.test.ui.app.SyncActivity.HelloWorldServer) CountingIdlingResource(androidx.test.espresso.idling.CountingIdlingResource) Before(org.junit.Before)

Aggregations

CountingIdlingResource (androidx.test.espresso.idling.CountingIdlingResource)4 Before (org.junit.Before)2 View (android.view.View)1 Espresso.onView (androidx.test.espresso.Espresso.onView)1 UiController (androidx.test.espresso.UiController)1 HelloWorldServer (androidx.test.ui.app.SyncActivity.HelloWorldServer)1 SimpleViewAction (com.herewhite.demo.utils.SimpleViewAction)1 SDKError (com.herewhite.sdk.domain.SDKError)1 Scene (com.herewhite.sdk.domain.Scene)1 SceneState (com.herewhite.sdk.domain.SceneState)1 Test (org.junit.Test)1