• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UiThreadTest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.support.test.annotation.UiThreadTest的典型用法代码示例。如果您正苦于以下问题:Java UiThreadTest类的具体用法?Java UiThreadTest怎么用?Java UiThreadTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UiThreadTest类属于android.support.test.annotation包,在下文中一共展示了UiThreadTest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:EventBusBasicTest.java


示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:RxJavaTests.java


示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RxJavaTests.java


示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:RxJavaTests.java


示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:RxJavaTests.java


示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:RxJavaTests.java


示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:RxJavaTests.java


示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:RxJavaTests.java


示例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();
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:27,代码来源:RxObservableArrayListTest.java


示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:RxJavaTests.java


示例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)));
}
 
开发者ID:MatthewTamlin,项目名称:Spyglass,代码行数:10,代码来源:TestDimensionHandlerCombinations.java


示例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 {
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:RxJavaTests.java


示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RxJavaTests.java


示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RxJavaTests.java


示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:NotificationsTest.java


示例16: useCase_simpleIterator_modifyQueryResult_innerTransaction_looperThread

import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void useCase_simpleIterator_modifyQueryResult_innerTransaction_looperThread() {
    if (skipTest(CollectionClass.MANAGED_REALMLIST, CollectionClass.UNMANAGED_REALMLIST,
            CollectionClass.REALMRESULTS)) {
        return;
    }

    assertEquals(TEST_SIZE, collection.size());
    for (int i = 0; i < collection.size(); i++) {
        realm.beginTransaction();
        AllJavaTypes obj = collection.get(i);
        obj.setFieldLong(obj.getFieldLong() + TEST_SIZE);
        realm.commitTransaction();
    }

    // Verifies that all elements were modified.
    assertEquals(0, realm.where(AllJavaTypes.class).lessThan(AllJavaTypes.FIELD_LONG, TEST_SIZE).count());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:OrderedRealmCollectionIteratorTests.java


示例17: useCase_simpleIterator_modifyQueryResult_outerTransaction_looperThread

import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test
@UiThreadTest
public void useCase_simpleIterator_modifyQueryResult_outerTransaction_looperThread() {
    if (skipTest(CollectionClass.MANAGED_REALMLIST, CollectionClass.UNMANAGED_REALMLIST,
            CollectionClass.REALMRESULTS)) {
        return;
    }

    assertEquals(TEST_SIZE, collection.size());
    realm.beginTransaction();
    for (int i = 0; i < collection.size(); i++) {
        AllJavaTypes obj = collection.get(i);
        obj.setFieldLong(obj.getFieldLong() + TEST_SIZE);
    }
    realm.commitTransaction();

    // Verifies that all elements were modified.
    assertEquals(0, realm.where(AllJavaTypes.class).lessThan(AllJavaTypes.FIELD_LONG, TEST_SIZE).count());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:OrderedRealmCollectionIteratorTests.java


示例18: propertyChangeEvents

import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test @UiThreadTest public void propertyChangeEvents() {
  short value = -1;

  RecordingObserver<Short> o = new RecordingObserver<>();
  RxObservableShort.propertyChanges(observableShort).subscribe(o);
  o.assertNoMoreEvents();

  observableShort.set(value);
  assertEquals(value, o.takeNext().shortValue());

  value = 2;
  observableShort.set(value);
  assertEquals(value, o.takeNext().shortValue());

  o.dispose();

  value = -3;
  observableShort.set(value);
  o.assertNoMoreEvents();
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:21,代码来源:RxObservableShortTest.java


示例19: propertyChangeEvents_Object

import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test @UiThreadTest public void propertyChangeEvents_Object() {
  final ObservableField<Object> observableField = new ObservableField<>();
  Object value;

  RecordingObserver<Object> o = new RecordingObserver<>();
  RxObservableField.propertyChanges(observableField).subscribe(o);
  o.assertNoMoreEvents();

  value = new Object();
  observableField.set(value);
  assertEquals(value, o.takeNext());

  value = new Object();
  observableField.set(value);
  assertEquals(value, o.takeNext());

  o.dispose();

  value = new Object();
  observableField.set(value);
  o.assertNoMoreEvents();
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:23,代码来源:RxObservableFieldTest.java


示例20: propertyChangeEvents

import android.support.test.annotation.UiThreadTest; //导入依赖的package包/类
@Test @UiThreadTest public void propertyChangeEvents() {
  final ObservableParcelable<MyParcelable> observableField = new ObservableParcelable<>();
  MyParcelable value;

  RecordingObserver<MyParcelable> o = new RecordingObserver<>();
  RxObservableParcelable.propertyChanges(observableField).subscribe(o);
  o.assertNoMoreEvents();

  value = new MyParcelable(1, "a");
  observableField.set(value);
  assertEquals(value, o.takeNext());

  value = new MyParcelable(2, "b");
  observableField.set(value);
  assertEquals(value, o.takeNext());

  o.dispose();

  value = new MyParcelable(3, "c");
  observableField.set(value);
  o.assertNoMoreEvents();
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:23,代码来源:RxObservableParcelableTest.java



注:本文中的android.support.test.annotation.UiThreadTest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PEMDecryptorProvider类代码示例发布时间:2022-05-21
下一篇:
Java DescriptorException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap