Search in sources :

Example 51 with UiThreadTest

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

the class SubscriptionsPreferenceControllerTest method onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat.

@Test
@UiThreadTest
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat() {
    final CharSequence expectedSummary = Html.fromHtml("LTE", Html.FROM_HTML_MODE_LEGACY);
    final String networkType = "LTE";
    final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
    final TelephonyDisplayInfo telephonyDisplayInfo = new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
    doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
    doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
    setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true, true, ServiceState.STATE_IN_SERVICE);
    doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
    doReturn(networkType).when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
    mController.onResume();
    mController.displayPreference(mPreferenceScreen);
    mController.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
    assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
}
Also used : TelephonyDisplayInfo(android.telephony.TelephonyDisplayInfo) SubscriptionInfo(android.telephony.SubscriptionInfo) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 52 with UiThreadTest

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

the class SubscriptionsPreferenceControllerTest method setIcon_greatSignal_correctLevels.

@Test
@UiThreadTest
public void setIcon_greatSignal_correctLevels() {
    final List<SubscriptionInfo> subs = setupMockSubscriptions(2, 1, true);
    setMockSubSignalStrength(subs, 0, SIGNAL_STRENGTH_GREAT);
    setMockSubSignalStrength(subs, 1, SIGNAL_STRENGTH_GREAT);
    final Preference pref = new Preference(mContext);
    final Drawable greatDrawWithoutCutOff = mock(Drawable.class);
    doReturn(greatDrawWithoutCutOff).when(sInjector).getIcon(any(), anyInt(), anyInt(), anyBoolean());
    mController.setIcon(pref, 1, true);
    assertThat(pref.getIcon()).isEqualTo(greatDrawWithoutCutOff);
    final Drawable greatDrawWithCutOff = mock(Drawable.class);
    doReturn(greatDrawWithCutOff).when(sInjector).getIcon(any(), anyInt(), anyInt(), anyBoolean());
    mController.setIcon(pref, 2, false);
    assertThat(pref.getIcon()).isEqualTo(greatDrawWithCutOff);
}
Also used : Preference(androidx.preference.Preference) Drawable(android.graphics.drawable.Drawable) SubscriptionInfo(android.telephony.SubscriptionInfo) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 53 with UiThreadTest

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

the class SubscriptionsPreferenceControllerTest method dataSubscriptionChanged_providerAndHasMultiSim_showSubId1Preference.

@Test
@UiThreadTest
public void dataSubscriptionChanged_providerAndHasMultiSim_showSubId1Preference() {
    final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
    doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
    doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
    doReturn(sub).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
    Intent intent = new Intent(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
    mController.onResume();
    mController.displayPreference(mPreferenceScreen);
    mController.mConnectionChangeReceiver.onReceive(mContext, intent);
    assertThat(mController.isAvailable()).isTrue();
    assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
    assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub1");
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) Intent(android.content.Intent) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 54 with UiThreadTest

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

the class SubscriptionsPreferenceControllerTest method getIcon_voiceInServiceAndMobileDataOff_iconIsSignalIcon.

@Test
@UiThreadTest
public void getIcon_voiceInServiceAndMobileDataOff_iconIsSignalIcon() {
    final List<SubscriptionInfo> subs = setupMockSubscriptions(1);
    final int subId = subs.get(0).getSubscriptionId();
    doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
    doReturn(subs.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
    Drawable icon = mock(Drawable.class);
    when(mTelephonyManager.isDataEnabled()).thenReturn(false);
    doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(true));
    setupGetIconConditions(subId, false, false, false, ServiceState.STATE_IN_SERVICE);
    mController.onResume();
    mController.displayPreference(mPreferenceScreen);
    Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
    ServiceState ss = mock(ServiceState.class);
    NetworkRegistrationInfo regInfo = new NetworkRegistrationInfo.Builder().setDomain(NetworkRegistrationInfo.DOMAIN_PS).setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN).setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME).setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE).build();
    doReturn(ss).when(mTelephonyManagerForSub).getServiceState();
    doReturn(regInfo).when(ss).getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
    assertThat(icon).isEqualTo(actualIcon);
}
Also used : NetworkRegistrationInfo(android.telephony.NetworkRegistrationInfo) ServiceState(android.telephony.ServiceState) Drawable(android.graphics.drawable.Drawable) SubscriptionInfo(android.telephony.SubscriptionInfo) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 55 with UiThreadTest

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

the class SubscriptionsPreferenceControllerTest method dataSubscriptionChanged_providerAndHasMultiSim_showSubId2Preference.

@Test
@UiThreadTest
public void dataSubscriptionChanged_providerAndHasMultiSim_showSubId2Preference() {
    final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
    final int subId = sub.get(0).getSubscriptionId();
    doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
    doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
    doReturn(sub).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
    Intent intent = new Intent(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
    mController.onResume();
    mController.displayPreference(mPreferenceScreen);
    assertThat(mController.isAvailable()).isTrue();
    assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
    assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub1");
    doReturn(sub.get(1)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
    mController.mConnectionChangeReceiver.onReceive(mContext, intent);
    assertThat(mController.isAvailable()).isTrue();
    assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
    assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub2");
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) Intent(android.content.Intent) 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