Search in sources :

Example 41 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 42 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)

Example 43 with UiThreadTest

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

the class RxTabLayoutTest method selectionsNoInitial.

@Test
@UiThreadTest
public void selectionsNoInitial() {
    TabLayout empty = new TabLayout(context);
    RecordingObserver<TabLayout.Tab> o = new RecordingObserver<>();
    RxTabLayout.selections(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)

Example 44 with UiThreadTest

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();
}
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 45 with UiThreadTest

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

the class RxViewTest method keys.

@Test
@UiThreadTest
public void keys() {
    RecordingObserver<KeyEvent> o = new RecordingObserver<>();
    RxView.keys(view).subscribe(o);
    o.assertNoMoreEvents();
    view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_R));
    KeyEvent event1 = o.takeNext();
    assertEquals(KeyEvent.ACTION_DOWN, event1.getAction());
    view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_H));
    KeyEvent event2 = o.takeNext();
    assertEquals(KeyEvent.KEYCODE_H, event2.getKeyCode());
    o.dispose();
    view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_S));
    o.assertNoMoreEvents();
}
Also used : KeyEvent(android.view.KeyEvent) RecordingObserver(com.jakewharton.rxbinding2.RecordingObserver) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) 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