本文整理汇总了Java中android.support.test.annotation.UiThreadTest类的典型用法代码示例。如果您正苦于以下问题:Java UiThreadTest类的具体用法?Java UiThreadTest怎么用?Java UiThreadTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UiThreadTest类属于android.support.test.annotation包,在下文中一共展示了UiThreadTest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRegisterAndPost
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void testRegisterAndPost() {
// Use an activity to test real life performance
TestActivity testActivity = new TestActivity();
String event = "Hello";
long start = System.currentTimeMillis();
eventBus.register(testActivity);
long time = System.currentTimeMillis() - start;
Log.d(EventBus.TAG, "Registered in " + time + "ms");
eventBus.post(event);
assertEquals(event, testActivity.lastStringEvent);
}
示例2: realmObject_emitChangesetOnSubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void realmObject_emitChangesetOnSubscribe() {
realm.beginTransaction();
final AllTypes obj = realm.createObject(AllTypes.class);
realm.commitTransaction();
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
subscription = obj.asChangesetObservable().subscribe(new Consumer<ObjectChange<RealmObject>>() {
@Override
public void accept(ObjectChange<RealmObject> change) throws Exception {
assertTrue(change.getObject() == obj);
assertNull(change.getChangeset());
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.dispose();
}
示例3: dynamicRealmObject_emitChangesetOnSubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void dynamicRealmObject_emitChangesetOnSubscribe() {
DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
dynamicRealm.beginTransaction();
final DynamicRealmObject obj = dynamicRealm.createObject(AllTypes.CLASS_NAME);
dynamicRealm.commitTransaction();
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
subscription = obj.asChangesetObservable().subscribe(new Consumer<ObjectChange<RealmObject>>() {
@Override
public void accept(ObjectChange<RealmObject> change) throws Exception {
assertTrue(change.getObject() == obj);
assertNull(change.getChangeset());
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.dispose();
dynamicRealm.close();
}
示例4: realmResults_emittedOnSubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void realmResults_emittedOnSubscribe() {
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
final RealmResults<AllTypes> results = realm.where(AllTypes.class).findAll();
subscription = results.asFlowable().subscribe(new Consumer<RealmResults<AllTypes>>() {
@Override
@SuppressWarnings("ReferenceEquality")
public void accept(RealmResults<AllTypes> rxResults) throws Exception {
assertTrue(rxResults == results);
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.dispose();
}
示例5: realmList_emittedChangesetOnSubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void realmList_emittedChangesetOnSubscribe() {
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
realm.beginTransaction();
final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
realm.commitTransaction();
subscription = list.asChangesetObservable().subscribe(new Consumer<CollectionChange<RealmList<Dog>>>() {
@Override
public void accept(CollectionChange<RealmList<Dog>> change) throws Exception {
assertEquals(list, change.getCollection());
assertNull(change.getChangeset());
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.dispose();
}
示例6: dynamicRealmResults_emittedOnSubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void dynamicRealmResults_emittedOnSubscribe() {
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
final RealmResults<DynamicRealmObject> results = dynamicRealm.where(AllTypes.CLASS_NAME).findAll();
subscription = results.asFlowable().subscribe(new Consumer<RealmResults<DynamicRealmObject>>() {
@Override
@SuppressWarnings("ReferenceEquality")
public void accept(RealmResults<DynamicRealmObject> rxResults) throws Exception {
assertTrue(rxResults == results);
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
dynamicRealm.close();
subscription.dispose();
}
示例7: dynamicRealmResults_emittedChangesetOnSubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void dynamicRealmResults_emittedChangesetOnSubscribe() {
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
final RealmResults<DynamicRealmObject> results = dynamicRealm.where(AllTypes.CLASS_NAME).findAll();
subscription = results.asChangesetObservable().subscribe(new Consumer<CollectionChange<RealmResults<DynamicRealmObject>>>() {
@Override
public void accept(CollectionChange<RealmResults<DynamicRealmObject>> change) throws Exception {
assertEquals(results, change.getCollection());
assertNull(change.getChangeset());
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
dynamicRealm.close();
subscription.dispose();
}
示例8: findAllAsync_emittedOnSubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void findAllAsync_emittedOnSubscribe() {
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
final RealmResults<AllTypes> results = realm.where(AllTypes.class).findAllAsync();
subscription = results.asFlowable().subscribe(new Consumer<RealmResults<AllTypes>>() {
@Override
@SuppressWarnings("ReferenceEquality")
public void accept(RealmResults<AllTypes> rxResults) throws Exception {
assertTrue(rxResults == results);
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.dispose();
}
示例9: itemRangeInsertionEvents
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test @UiThreadTest public void itemRangeInsertionEvents() {
String value = "value";
ObservableArrayListItemRangeInsertionEvent<String> next;
RecordingObserver<ObservableArrayListItemRangeInsertionEvent<String>> o =
new RecordingObserver<>();
RxObservableArrayList.itemRangeInsertionEvents(observableArrayList).subscribe(o);
o.assertNoMoreEvents();
observableArrayList.add(value);
next = o.takeNext();
assertEquals(observableArrayList, next.observableArrayList());
assertEquals(0, next.positionStart());
assertEquals(1, next.itemCount());
observableArrayList.addAll(Arrays.asList(value, value, value));
next = o.takeNext();
assertEquals(observableArrayList, next.observableArrayList());
assertEquals(1, next.positionStart());
assertEquals(3, next.itemCount());
o.dispose();
observableArrayList.add(value);
o.assertNoMoreEvents();
}
示例10: dynamicRealm_emittedOnSubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void dynamicRealm_emittedOnSubscribe() {
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
subscription = dynamicRealm.asFlowable().subscribe(new Consumer<DynamicRealm>() {
@Override
public void accept(DynamicRealm rxRealm) throws Exception {
assertTrue(rxRealm == dynamicRealm);
subscribedNotified.set(true);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
fail();
}
});
assertTrue(subscribedNotified.get());
dynamicRealm.close();
subscription.dispose();
}
示例11: testSpyglassCallsMethod_attributeMissing_defaultToNullPresent
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void testSpyglassCallsMethod_attributeMissing_defaultToNullPresent() {
final AttributeSet attrs = fromXml(context, R.xml.dimension_handler_without_attr);
final DimensionHandlerTestTargetBase target = new WithDefaultToNull(context, attrs);
assertThat(target.getReceivedValue(), is(ReceivedValue.<Integer>of(null)));
}
示例12: wrongGenericClassThrows
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void wrongGenericClassThrows() {
realm.beginTransaction();
final AllTypes obj = realm.createObject(AllTypes.class);
realm.commitTransaction();
Flowable<CyclicType> obs = obj.asFlowable();
@SuppressWarnings("unused")
Disposable subscription = obs.subscribe(new Consumer<CyclicType>() {
@Override
public void accept(CyclicType cyclicType) throws Exception {
fail();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable ignored) throws Exception {
}
});
}
示例13: dynamicRealm_closeInDoOnUnsubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void dynamicRealm_closeInDoOnUnsubscribe() {
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
Flowable<DynamicRealm> observable = dynamicRealm.asFlowable()
.doOnCancel(new Action() {
@Override
public void run() throws Exception {
dynamicRealm.close();
}
});
subscription = observable.subscribe(new Consumer<DynamicRealm>() {
@Override
public void accept(DynamicRealm ignored) throws Exception {
}
});
subscription.dispose();
assertTrue(dynamicRealm.isClosed());
}
示例14: dynamicRealmObject_closeInDoOnUnsubscribe
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void dynamicRealmObject_closeInDoOnUnsubscribe() {
realm.beginTransaction();
realm.createObject(AllTypes.class);
realm.commitTransaction();
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
Flowable<DynamicRealmObject> flowable = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst().<DynamicRealmObject>asFlowable()
.doOnCancel(new Action() {
@Override
public void run() throws Exception {
dynamicRealm.close();
}
});
subscription = flowable.subscribe(new Consumer<DynamicRealmObject>() {
@Override
public void accept(DynamicRealmObject ignored) throws Exception {
}
});
subscription.dispose();
assertTrue(dynamicRealm.isClosed());
}
示例15: removeChangeListener
import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void removeChangeListener() throws InterruptedException, ExecutionException {
final AtomicInteger counter = new AtomicInteger(0);
RealmChangeListener<Realm> listener = new RealmChangeListener<Realm>() {
@Override
public void onChange(Realm object) {
counter.incrementAndGet();
}
};
realm = Realm.getInstance(realmConfig);
realm.addChangeListener(listener);
realm.removeChangeListener(listener);
realm.beginTransaction();
realm.createObject(AllTypes.class);
realm.commitTransaction();
assertEquals(0, counter.get());
}