Search in sources :

Example 56 with UiThreadTest

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

the class EnabledNetworkModePreferenceControllerTest method preferredNetworkModeNotification_preferenceUpdates.

@UiThreadTest
@Test
public void preferredNetworkModeNotification_preferenceUpdates() {
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
    mPreference.setKey(KEY);
    screen.addPreference(mPreference);
    mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
    // NETWORK_MODE_TDSCDMA_GSM_WCDMA = RAF_TD_SCDMA | GSM | WCDMA
    when(mTelephonyManager.getAllowedNetworkTypesForReason(TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER)).thenReturn((long) (RAF_TD_SCDMA | GSM | WCDMA));
    mController.displayPreference(screen);
    mController.updateState(mPreference);
    mLifecycle.handleLifecycleEvent(ON_START);
    assertThat(Integer.parseInt(mPreference.getValue())).isEqualTo(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
    assertThat(mPreference.getSummary()).isEqualTo("3G");
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 57 with UiThreadTest

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

the class EnabledNetworkModePreferenceControllerTest method setUp.

@UiThreadTest
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mCarrierConfigManager);
    when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
    doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
    doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    doReturn(mServiceState).when(mTelephonyManager).getServiceState();
    mPersistableBundle = new PersistableBundle();
    doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfig();
    doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
    mPreference = new ListPreference(mContext);
    mController = new EnabledNetworkModePreferenceController(mContext, KEY);
    mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
    mockAccessFamily(TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
    mController.init(mLifecycle, SUB_ID);
    mPreference.setKey(mController.getPreferenceKey());
}
Also used : PersistableBundle(android.os.PersistableBundle) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ListPreference(androidx.preference.ListPreference) Before(org.junit.Before) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 58 with UiThreadTest

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

the class ProviderModelSliceTest method getSlice_haveOneConnectedWifiAndTwoDisconnectedWifiAndNoCarrier_getFiveRow.

@Test
@UiThreadTest
public void getSlice_haveOneConnectedWifiAndTwoDisconnectedWifiAndNoCarrier_getFiveRow() {
    mWifiList.clear();
    mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1", WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
    mWifiList.add(mMockWifiSliceItem1);
    mockWifiItemCondition(mMockWifiSliceItem2, "wifi2", "wifi2", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
    mWifiList.add(mMockWifiSliceItem2);
    mockWifiItemCondition(mMockWifiSliceItem3, "wifi3", "wifi3", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi3_key", true);
    mWifiList.add(mMockWifiSliceItem3);
    mMockNetworkProviderWorker.updateSelfResults(mWifiList);
    mockHelperCondition(false, false, false, mWifiList.get(0));
    final Slice slice = mMockProviderModelSlice.getSlice();
    assertThat(slice).isNotNull();
    verify(mListBuilder, times(5)).addRow(any(ListBuilder.RowBuilder.class));
    assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
Also used : Slice(androidx.slice.Slice) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 59 with UiThreadTest

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

the class ProviderModelSliceTest method getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getSixRow.

@Test
@UiThreadTest
public void getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getSixRow() {
    mWifiList.clear();
    mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi1_key", true);
    mWifiList.add(mMockWifiSliceItem1);
    mockWifiItemCondition(mMockWifiSliceItem2, "wifi2", "wifi2", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
    mWifiList.add(mMockWifiSliceItem2);
    mMockNetworkProviderWorker.updateSelfResults(mWifiList);
    mockHelperCondition(false, true, true, null);
    when(mMockNetworkProviderWorker.getInternetType()).thenReturn(InternetUpdater.INTERNET_ETHERNET);
    final Slice slice = mMockProviderModelSlice.getSlice();
    assertThat(slice).isNotNull();
    assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
    verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
    verify(mListBuilder, times(6)).addRow(any(ListBuilder.RowBuilder.class));
    assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
Also used : Slice(androidx.slice.Slice) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 60 with UiThreadTest

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

the class ProviderModelSliceTest method getSlice_airplaneModeIsOn_oneWifiToggle.

@Test
@UiThreadTest
public void getSlice_airplaneModeIsOn_oneWifiToggle() {
    mWifiList.clear();
    mMockNetworkProviderWorker.updateSelfResults(null);
    mockHelperCondition(true, false, false, null);
    final Slice slice = mMockProviderModelSlice.getSlice();
    assertThat(slice).isNotNull();
    verify(mListBuilder, times(1)).addRow(any(ListBuilder.RowBuilder.class));
    final SliceItem sliceTitle = SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
    assertThat(sliceTitle.getText()).isEqualTo(ResourcesUtils.getResourcesString(mContext, "wifi_settings"));
}
Also used : Slice(androidx.slice.Slice) WifiSliceItem(com.android.settings.wifi.slice.WifiSliceItem) SliceItem(androidx.slice.SliceItem) 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