Search in sources :

Example 1 with UnsafeRunnable

use of com.jakewharton.rxbinding2.UnsafeRunnable in project RxBinding by JakeWharton.

the class RxSlidingPaneLayoutTest method open.

@Test
public void open() {
    final Consumer<? super Boolean> open = RxSlidingPaneLayout.open(view);
    view.setPanelSlideListener(new SlidingPaneLayout.SimplePanelSlideListener() {

        @Override
        public void onPanelOpened(View panel) {
            idler.decrement();
        }

        @Override
        public void onPanelClosed(View panel) {
            idler.decrement();
        }
    });
    idler.increment();
    instrumentation.runOnMainSync(new UnsafeRunnable() {

        @Override
        protected void unsafeRun() throws Exception {
            open.accept(true);
        }
    });
    instrumentation.waitForIdleSync();
    onView(withId(view.getId())).check(matches(isOpen()));
    idler.increment();
    instrumentation.runOnMainSync(new UnsafeRunnable() {

        @Override
        protected void unsafeRun() throws Exception {
            open.accept(false);
        }
    });
    instrumentation.waitForIdleSync();
    onView(withId(view.getId())).check(matches(isClosed()));
    view.setPanelSlideListener(null);
}
Also used : UnsafeRunnable(com.jakewharton.rxbinding2.UnsafeRunnable) SlidingPaneLayout(android.support.v4.widget.SlidingPaneLayout) View(android.view.View) Espresso.onView(android.support.test.espresso.Espresso.onView) Test(org.junit.Test)

Example 2 with UnsafeRunnable

use of com.jakewharton.rxbinding2.UnsafeRunnable in project RxBinding by JakeWharton.

the class RxDrawerLayoutTest method open.

@Test
public void open() {
    final Consumer<? super Boolean> open = RxDrawerLayout.open(view, RIGHT);
    instrumentation.runOnMainSync(new UnsafeRunnable() {

        @Override
        protected void unsafeRun() throws Exception {
            open.accept(true);
        }
    });
    onView(withId(view.getId())).check(matches(isOpen(RIGHT)));
    instrumentation.runOnMainSync(new UnsafeRunnable() {

        @Override
        protected void unsafeRun() throws Exception {
            open.accept(false);
        }
    });
    onView(withId(view.getId())).check(matches(isClosed(RIGHT)));
}
Also used : UnsafeRunnable(com.jakewharton.rxbinding2.UnsafeRunnable) Test(org.junit.Test)

Example 3 with UnsafeRunnable

use of com.jakewharton.rxbinding2.UnsafeRunnable in project RxBinding by JakeWharton.

the class RxAdapterViewTest method selection.

@Test
public void selection() {
    final Consumer<? super Integer> action = RxAdapterView.selection(spinner);
    instrumentation.runOnMainSync(new UnsafeRunnable() {

        @Override
        public void unsafeRun() throws Exception {
            action.accept(2);
        }
    });
    instrumentation.runOnMainSync(new Runnable() {

        @Override
        public void run() {
            assertEquals(2, spinner.getSelectedItemPosition());
        }
    });
    instrumentation.runOnMainSync(new UnsafeRunnable() {

        @Override
        public void unsafeRun() throws Exception {
            action.accept(1);
        }
    });
    instrumentation.runOnMainSync(new Runnable() {

        @Override
        public void run() {
            assertEquals(1, spinner.getSelectedItemPosition());
        }
    });
}
Also used : UnsafeRunnable(com.jakewharton.rxbinding2.UnsafeRunnable) UnsafeRunnable(com.jakewharton.rxbinding2.UnsafeRunnable) Test(org.junit.Test)

Aggregations

UnsafeRunnable (com.jakewharton.rxbinding2.UnsafeRunnable)3 Test (org.junit.Test)3 Espresso.onView (android.support.test.espresso.Espresso.onView)1 SlidingPaneLayout (android.support.v4.widget.SlidingPaneLayout)1 View (android.view.View)1