use of android.support.test.annotation.UiThreadTest in project RxBinding by JakeWharton.
the class RxSearchBarTest method searchQueryChangeEventsKeyboardDismissed.
@Test
@UiThreadTest
public void searchQueryChangeEventsKeyboardDismissed() {
RecordingObserver<SearchBarSearchQueryEvent> o = new RecordingObserver<>();
RxSearchBar.searchQueryChangeEvents(searchBar).subscribe(o);
o.assertNoMoreEvents();
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
searchBar.setSearchQuery("q");
searchEditText.onKeyPreIme(KeyEvent.KEYCODE_BACK, keyEvent);
assertEquals(SearchBarSearchQueryChangedEvent.create(searchBar, "q"), o.takeNext());
assertEquals(SearchBarSearchQueryKeyboardDismissedEvent.create(searchBar, "q"), o.takeNext());
o.dispose();
searchEditText.onKeyPreIme(KeyEvent.KEYCODE_BACK, keyEvent);
o.assertNoMoreEvents();
}
use of android.support.test.annotation.UiThreadTest in project RxBinding by JakeWharton.
the class RxToolbarTest 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<>();
RxToolbar.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();
}
use of android.support.test.annotation.UiThreadTest in project material-components-android by material-components.
the class TextInputLayoutTest method testDrawableStateChanged.
/** Regression test for b/31663756. */
@UiThreadTest
@Test
public void testDrawableStateChanged() {
final Activity activity = activityTestRule.getActivity();
final TextInputLayout layout = (TextInputLayout) activity.findViewById(R.id.textinput);
// Force a drawable state change.
layout.drawableStateChanged();
}
use of android.support.test.annotation.UiThreadTest in project realm-java by realm.
the class RxJavaTests method realmList_closeInDoOnUnsubscribe.
@Test
@UiThreadTest
public void realmList_closeInDoOnUnsubscribe() {
realm.beginTransaction();
RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
realm.commitTransaction();
Observable<RealmList<Dog>> observable = list.asObservable().doOnUnsubscribe(new Action0() {
@Override
public void call() {
realm.close();
}
});
subscription = observable.subscribe(new Action1<RealmList<Dog>>() {
@Override
public void call(RealmList<Dog> dogs) {
}
});
subscription.unsubscribe();
assertTrue(realm.isClosed());
}
use of android.support.test.annotation.UiThreadTest in project realm-java by realm.
the class RxJavaTests method unsubscribe_sameThread.
@Test
@UiThreadTest
public void unsubscribe_sameThread() {
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
subscription = realm.asObservable().subscribe(new Action1<Realm>() {
@Override
public void call(Realm rxRealm) {
assertTrue(rxRealm == realm);
subscribedNotified.set(true);
}
});
assertEquals(1, realm.sharedRealm.realmNotifier.getListenersListSize());
subscription.unsubscribe();
assertEquals(0, realm.sharedRealm.realmNotifier.getListenersListSize());
}
Aggregations