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);
}
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();
}
};
}
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();
}
});
}
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));
});
}
Aggregations