Search in sources :

Example 71 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.

the class MobileNetworkSwitchControllerTest method switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledFailed.

@Test
@UiThreadTest
@Ignore
public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledFailed() {
    when(mSubscriptionManager.setSubscriptionEnabled(eq(mSubId), anyBoolean())).thenReturn(false);
    when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
    mController.displayPreference(mScreen);
    assertThat(mSwitchBar.isShowing()).isTrue();
    assertThat(mSwitchBar.isChecked()).isTrue();
    final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
    doNothing().when(mContext).startActivity(intentCaptor.capture());
    mSwitchBar.setChecked(false);
    Bundle extra = intentCaptor.getValue().getExtras();
    verify(mContext, times(1)).startActivity(any());
    assertThat(extra.getInt(ToggleSubscriptionDialogActivity.ARG_SUB_ID)).isEqualTo(mSubId);
    assertThat(extra.getBoolean(ToggleSubscriptionDialogActivity.ARG_enable)).isEqualTo(false);
    assertThat(mSwitchBar.isChecked()).isTrue();
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) Ignore(org.junit.Ignore) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 72 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.

the class NetworkProviderWorkerTest method getWifiEntry_connectedWifiKey_shouldGetConnectedWifi.

@Test
@UiThreadTest
public void getWifiEntry_connectedWifiKey_shouldGetConnectedWifi() {
    final String key = "key";
    final WifiEntry connectedWifiEntry = mock(WifiEntry.class);
    when(connectedWifiEntry.getKey()).thenReturn(key);
    when(mMockWifiPickerTracker.getConnectedWifiEntry()).thenReturn(connectedWifiEntry);
    assertThat(mMockNetworkProviderWorker.getWifiEntry(key)).isEqualTo(connectedWifiEntry);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 73 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.

the class NetworkProviderWorkerTest method getWifiEntry_reachableWifiKey_shouldGetReachableWifi.

@Test
@UiThreadTest
public void getWifiEntry_reachableWifiKey_shouldGetReachableWifi() {
    final String key = "key";
    final WifiEntry reachableWifiEntry = mock(WifiEntry.class);
    when(reachableWifiEntry.getKey()).thenReturn(key);
    when(mMockWifiPickerTracker.getWifiEntries()).thenReturn(Arrays.asList(reachableWifiEntry));
    assertThat(mMockNetworkProviderWorker.getWifiEntry(key)).isEqualTo(reachableWifiEntry);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 74 with UiThreadTest

use of androidx.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(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)

Example 75 with UiThreadTest

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

the class RxViewTest method focusChanges.

@Test
@UiThreadTest
public void focusChanges() {
    // We need a parent which can take focus from our view when it attempts to clear.
    LinearLayout parent = new LinearLayout(context);
    parent.setFocusable(true);
    parent.addView(view);
    view.setFocusable(true);
    RecordingObserver<Boolean> o = new RecordingObserver<>();
    RxView.focusChanges(view).subscribe(o);
    assertFalse(o.takeNext());
    view.requestFocus();
    assertTrue(o.takeNext());
    view.clearFocus();
    assertFalse(o.takeNext());
    o.dispose();
    view.requestFocus();
    o.assertNoMoreEvents();
}
Also used : RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) LinearLayout(android.widget.LinearLayout) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) 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