Search in sources :

Example 31 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project AntennaPod by AntennaPod.

the class PlaybackServiceTaskManagerTest method testSetSleepTimer.

@Test
@UiThreadTest
public void testSetSleepTimer() throws InterruptedException {
    final Context c = InstrumentationRegistry.getInstrumentation().getTargetContext();
    final long TIME = 2000;
    final long TIMEOUT = 2 * TIME;
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    Object timerReceiver = new Object() {

        @Subscribe
        public void sleepTimerUpdate(SleepTimerUpdatedEvent event) {
            if (countDownLatch.getCount() == 0) {
                fail();
            }
            countDownLatch.countDown();
        }
    };
    EventBus.getDefault().register(timerReceiver);
    PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
    pstm.setSleepTimer(TIME);
    countDownLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
    EventBus.getDefault().unregister(timerReceiver);
    pstm.shutdown();
}
Also used : Context(android.content.Context) SleepTimerUpdatedEvent(de.danoeh.antennapod.event.playback.SleepTimerUpdatedEvent) PlaybackServiceTaskManager(de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager) CountDownLatch(java.util.concurrent.CountDownLatch) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 32 with UiThreadTest

use of androidx.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.rxbinding4.RecordingObserver) Menu(android.view.Menu) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 33 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project RxBinding by JakeWharton.

the class RxNestedScrollViewTest method scrollChangeEvents.

@Test
@UiThreadTest
public void scrollChangeEvents() {
    RecordingObserver<ViewScrollChangeEvent> o = new RecordingObserver<>();
    RxNestedScrollView.scrollChangeEvents(view).subscribe(o);
    o.assertNoMoreEvents();
    view.scrollTo(1000, 0);
    ViewScrollChangeEvent event = o.takeNext();
    assertSame(view, event.getView());
    assertEquals(1000, event.getScrollX());
    assertEquals(0, event.getScrollY());
    assertEquals(0, event.getOldScrollX());
    assertEquals(0, event.getOldScrollY());
    o.dispose();
    view.scrollTo(2000, 0);
    o.assertNoMoreEvents();
}
Also used : ViewScrollChangeEvent(com.jakewharton.rxbinding4.view.ViewScrollChangeEvent) RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 34 with UiThreadTest

use of androidx.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(new SearchBarSearchQueryChangedEvent(searchBar, "q"), o.takeNext());
    assertEquals(new SearchBarSearchQueryKeyboardDismissedEvent(searchBar, "q"), o.takeNext());
    o.dispose();
    searchEditText.onKeyPreIme(KeyEvent.KEYCODE_BACK, keyEvent);
    o.assertNoMoreEvents();
}
Also used : KeyEvent(android.view.KeyEvent) RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 35 with UiThreadTest

use of androidx.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(com.google.android.material.tabs.TabLayout) RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

UiThreadTest (androidx.test.annotation.UiThreadTest)136 Test (org.junit.Test)129 View (android.view.View)41 Unbinder (butterknife.Unbinder)31 Context (android.content.Context)23 AdapterView (android.widget.AdapterView)18 TextView (android.widget.TextView)15 RecordingObserver (com.jakewharton.rxbinding4.RecordingObserver)15 MediumTest (androidx.test.filters.MediumTest)14 Intent (android.content.Intent)10 SubscriptionInfo (android.telephony.SubscriptionInfo)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 LocalPSMP (de.danoeh.antennapod.core.service.playback.LocalPSMP)9 PlaybackServiceMediaPlayer (de.danoeh.antennapod.playback.base.PlaybackServiceMediaPlayer)9 Slice (androidx.slice.Slice)8 Playable (de.danoeh.antennapod.model.playback.Playable)8 AssertionFailedError (junit.framework.AssertionFailedError)8 Before (org.junit.Before)7 ViewGroup (android.view.ViewGroup)6 FrameLayout (android.widget.FrameLayout)6