Search in sources :

Example 46 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project realm-java by realm.

the class RxJavaTests method realm_closeInDoOnUnsubscribe.

@Test
@UiThreadTest
public void realm_closeInDoOnUnsubscribe() {
    Observable<Realm> observable = realm.asObservable().doOnUnsubscribe(new Action0() {

        @Override
        public void call() {
            realm.close();
        }
    });
    subscription = observable.subscribe(new Action1<Realm>() {

        @Override
        public void call(Realm rxRealm) {
        }
    });
    subscription.unsubscribe();
    assertTrue(realm.isClosed());
}
Also used : Action0(rx.functions.Action0) Action1(rx.functions.Action1) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 47 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project realm-java by realm.

the class RxJavaTests method realmObject_closeInDoOnUnsubscribe.

@Test
@UiThreadTest
public void realmObject_closeInDoOnUnsubscribe() {
    realm.beginTransaction();
    realm.createObject(AllTypes.class);
    realm.commitTransaction();
    Observable<AllTypes> observable = realm.where(AllTypes.class).findFirst().<AllTypes>asObservable().doOnUnsubscribe(new Action0() {

        @Override
        public void call() {
            realm.close();
        }
    });
    subscription = observable.subscribe(new Action1<AllTypes>() {

        @Override
        public void call(AllTypes allTypes) {
        }
    });
    subscription.unsubscribe();
    assertTrue(realm.isClosed());
}
Also used : Action0(rx.functions.Action0) Action1(rx.functions.Action1) AllTypes(io.realm.entities.AllTypes) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 48 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project RxBinding by JakeWharton.

the class RxActionMenuViewTest method itemClicks.

@Test
@UiThreadTest
public void itemClicks() {
    Menu menu = view.getMenu();
    MenuItem item1 = menu.add(0, 1, 0, "Hi");
    MenuItem item2 = menu.add(0, 2, 0, "Hey");
    RecordingObserver<MenuItem> o = new RecordingObserver<>();
    RxActionMenuView.itemClicks(view).subscribe(o);
    o.assertNoMoreEvents();
    menu.performIdentifierAction(2, 0);
    assertSame(item2, o.takeNext());
    menu.performIdentifierAction(1, 0);
    assertSame(item1, o.takeNext());
    o.dispose();
    menu.performIdentifierAction(2, 0);
    o.assertNoMoreEvents();
}
Also used : MenuItem(android.view.MenuItem) RecordingObserver(com.jakewharton.rxbinding2.RecordingObserver) Menu(android.view.Menu) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 49 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project RxBinding by JakeWharton.

the class RxPopupMenuTest method itemClicks.

@Test
@UiThreadTest
public void itemClicks() {
    Menu menu = view.getMenu();
    MenuItem item1 = menu.add(0, 1, 0, "Hi");
    MenuItem item2 = menu.add(0, 2, 0, "Hey");
    RecordingObserver<MenuItem> o = new RecordingObserver<>();
    RxPopupMenu.itemClicks(view).subscribe(o);
    o.assertNoMoreEvents();
    menu.performIdentifierAction(2, 0);
    assertSame(item2, o.takeNext());
    menu.performIdentifierAction(1, 0);
    assertSame(item1, o.takeNext());
    o.dispose();
    menu.performIdentifierAction(2, 0);
    o.assertNoMoreEvents();
}
Also used : MenuItem(android.view.MenuItem) RecordingObserver(com.jakewharton.rxbinding2.RecordingObserver) PopupMenu(android.support.v7.widget.PopupMenu) Menu(android.view.Menu) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 50 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project RxBinding by JakeWharton.

the class RxTabLayoutTest method selectionEventsNoInitial.

@Test
@UiThreadTest
public void selectionEventsNoInitial() {
    TabLayout empty = new TabLayout(context);
    RecordingObserver<TabLayoutSelectionEvent> o = new RecordingObserver<>();
    RxTabLayout.selectionEvents(empty).subscribe(o);
    o.assertNoMoreEvents();
}
Also used : TabLayout(android.support.design.widget.TabLayout) RecordingObserver(com.jakewharton.rxbinding2.RecordingObserver) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest) UiThreadTest(android.support.test.annotation.UiThreadTest)

Aggregations

UiThreadTest (android.support.test.annotation.UiThreadTest)57 Test (org.junit.Test)57 Action1 (rx.functions.Action1)17 RecordingObserver (com.jakewharton.rxbinding2.RecordingObserver)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 AllTypes (io.realm.entities.AllTypes)10 SmallTest (android.support.test.filters.SmallTest)8 Action0 (rx.functions.Action0)7 Activity (android.app.Activity)6 LayoutInflater (android.view.LayoutInflater)6 Menu (android.view.Menu)6 TextInputLayoutActivity (android.support.design.testapp.TextInputLayoutActivity)5 LargeTest (android.support.test.filters.LargeTest)5 MediumTest (android.support.test.filters.MediumTest)5 MenuItem (android.view.MenuItem)5 TabLayoutActions.selectTab (android.support.design.testutils.TabLayoutActions.selectTab)4 AllJavaTypes (io.realm.entities.AllJavaTypes)4 Bundle (android.os.Bundle)3 KeyEvent (android.view.KeyEvent)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2