Search in sources :

Example 36 with UiThreadTest

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

the class RxJavaTests method dynamicRealmResults_closeInDoOnUnsubscribe.

@Test
@UiThreadTest
public void dynamicRealmResults_closeInDoOnUnsubscribe() {
    final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
    Observable<RealmResults<DynamicRealmObject>> observable = dynamicRealm.where(AllTypes.CLASS_NAME).findAll().asObservable().doOnUnsubscribe(new Action0() {

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

        @Override
        public void call(RealmResults<DynamicRealmObject> allTypes) {
        }
    });
    subscription.unsubscribe();
    assertTrue(dynamicRealm.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 37 with UiThreadTest

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

the class RxJavaTests method dynamicRealmObject_closeInDoOnUnsubscribe.

@Test
@UiThreadTest
public void dynamicRealmObject_closeInDoOnUnsubscribe() {
    realm.beginTransaction();
    realm.createObject(AllTypes.class);
    realm.commitTransaction();
    final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
    Observable<DynamicRealmObject> observable = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst().<DynamicRealmObject>asObservable().doOnUnsubscribe(new Action0() {

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

        @Override
        public void call(DynamicRealmObject obj) {
        }
    });
    subscription.unsubscribe();
    assertTrue(dynamicRealm.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 38 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 39 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 40 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)

Aggregations

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