summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/tests/src')
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java29
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java150
2 files changed, 177 insertions, 2 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
index eaf2f78..0addb9e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
@@ -17,9 +17,12 @@ import android.telephony.TelephonyManager;
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.internal.telephony.IccCardConstants;
+import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
import com.android.systemui.statusbar.policy.NetworkControllerImpl.Config;
+import com.android.systemui.statusbar.policy.NetworkControllerImpl.MobileSignalController;
import com.android.systemui.statusbar.policy.NetworkControllerImpl.SignalCluster;
import org.mockito.ArgumentCaptor;
@@ -41,6 +44,7 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
protected static final int DEFAULT_QS_ICON = TelephonyIcons.QS_ICON_3G;
protected NetworkControllerImpl mNetworkController;
+ protected MobileSignalController mMobileSignalController;
protected PhoneStateListener mPhoneStateListener;
protected SignalCluster mSignalCluster;
protected NetworkSignalChangedCallback mNetworkSignalChangedCallback;
@@ -84,14 +88,27 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
when(subscription.getSubscriptionId()).thenReturn(subId);
subs.add(subscription);
mNetworkController.setCurrentSubscriptions(subs);
- mPhoneStateListener =
- mNetworkController.mMobileSignalControllers.get(subId).mPhoneStateListener;
+ mMobileSignalController = mNetworkController.mMobileSignalControllers.get(subId);
+ mPhoneStateListener = mMobileSignalController.mPhoneStateListener;
mSignalCluster = mock(SignalCluster.class);
mNetworkSignalChangedCallback = mock(NetworkSignalChangedCallback.class);
mNetworkController.addSignalCluster(mSignalCluster);
mNetworkController.addNetworkSignalChangedCallback(mNetworkSignalChangedCallback);
}
+ protected NetworkControllerImpl setUpNoMobileData() {
+ when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
+ NetworkControllerImpl networkControllerNoMobile
+ = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
+ mConfig, mock(AccessPointControllerImpl.class),
+ mock(MobileDataControllerImpl.class));
+
+ setupNetworkController();
+
+ return networkControllerNoMobile;
+
+ }
+
@Override
protected void tearDown() throws Exception {
StringWriter sw = new StringWriter();
@@ -238,4 +255,12 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
assertEquals("Data icon in status bar", typeIcon, (int) typeIconArg.getValue());
assertEquals("Visibility in status bar", visible, (boolean) visibleArg.getValue());
}
+
+ protected void assertSimStateEquals(IccCardConstants.State expected) {
+ assertEquals("Sim state", expected, mMobileSignalController.getSimState());
+ }
+
+ protected void assertNetworkNameEquals(String expected) {
+ assertEquals("Network name", expected, mNetworkController.getMobileNetworkName());
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
index b5d97d9..fae4bb7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
@@ -1,12 +1,16 @@
package com.android.systemui.statusbar.policy;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import android.content.Intent;
import android.net.ConnectivityManager;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
+import com.android.internal.telephony.IccCardConstants;
+import com.android.internal.telephony.TelephonyIntents;
import com.android.systemui.R;
import org.mockito.Mockito;
@@ -127,4 +131,150 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
TelephonyManager.NETWORK_TYPE_CDMA);
setCdmaRoaming(false);
}
+
+ public void testOnReceive_updateSimState_noSim() {
+ Intent intent = new Intent();
+ intent.setAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+ intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE, IccCardConstants.INTENT_VALUE_ICC_ABSENT);
+
+ mNetworkController.onReceive(mContext, intent);
+
+ assertSimStateEquals(IccCardConstants.State.ABSENT);
+ }
+
+ public void testOnReceive_stringsUpdatedAction_spn() {
+ String expectedMNetworkName = "Test";
+ Intent intent = createStringsUpdatedIntent(true /* showSpn */,
+ expectedMNetworkName /* spn */,
+ false /* showPlmn */,
+ "NotTest" /* plmn */);
+
+ mNetworkController.onReceive(mContext, intent);
+
+ assertNetworkNameEquals(expectedMNetworkName);
+ }
+
+ public void testOnReceive_stringsUpdatedAction_plmn() {
+ String expectedMNetworkName = "Test";
+
+ Intent intent = createStringsUpdatedIntent(false /* showSpn */,
+ "NotTest" /* spn */,
+ true /* showPlmn */,
+ expectedMNetworkName /* plmn */);
+
+ mNetworkController.onReceive(mContext, intent);
+
+ assertNetworkNameEquals(expectedMNetworkName);
+ }
+
+ public void testOnReceive_stringsUpdatedAction_bothFalse() {
+ Intent intent = createStringsUpdatedIntent(false /* showSpn */,
+ "Irrelevant" /* spn */,
+ false /* showPlmn */,
+ "Irrelevant" /* plmn */);
+
+ mNetworkController.onReceive(mContext, intent);
+
+ String defaultNetworkName = mMobileSignalController
+ .getStringIfExists(
+ com.android.internal.R.string.lockscreen_carrier_default);
+ assertNetworkNameEquals(defaultNetworkName);
+ }
+
+ public void testOnReceive_stringsUpdatedAction_bothTrueAndNull() {
+ Intent intent = createStringsUpdatedIntent(true /* showSpn */,
+ null /* spn */,
+ true /* showPlmn */,
+ null /* plmn */);
+
+ mNetworkController.onReceive(mContext, intent);
+
+ String defaultNetworkName = mMobileSignalController.getStringIfExists(
+ com.android.internal.R.string.lockscreen_carrier_default);
+ assertNetworkNameEquals(defaultNetworkName);
+ }
+
+ public void testOnReceive_stringsUpdatedAction_bothTrueAndNonNull() {
+ String spn = "Test1";
+ String plmn = "Test2";
+
+ Intent intent = createStringsUpdatedIntent(true /* showSpn */,
+ spn /* spn */,
+ true /* showPlmn */,
+ plmn /* plmn */);
+
+ mNetworkController.onReceive(mContext, intent);
+
+ assertNetworkNameEquals(plmn
+ + mMobileSignalController.getStringIfExists(
+ R.string.status_bar_network_name_separator)
+ + spn);
+ }
+
+ private Intent createStringsUpdatedIntent(boolean showSpn, String spn,
+ boolean showPlmn, String plmn) {
+
+ Intent intent = new Intent();
+ intent.setAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
+
+ intent.putExtra(TelephonyIntents.EXTRA_SHOW_SPN, showSpn);
+ intent.putExtra(TelephonyIntents.EXTRA_SPN, spn);
+
+ intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn);
+ intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn);
+
+ return intent;
+ }
+
+ public void testOnUpdateDataActivity_dataIn() {
+ setupDefaultSignal();
+
+ updateDataActivity(TelephonyManager.DATA_ACTIVITY_IN);
+
+ verifyLastQsMobileDataIndicators(true /* visible */,
+ TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH[1][DEFAULT_LEVEL] /* icon */,
+ DEFAULT_QS_ICON /* typeIcon */,
+ true /* dataIn */,
+ false /* dataOut */);
+
+ }
+
+ public void testOnUpdateDataActivity_dataOut() {
+ setupDefaultSignal();
+
+ updateDataActivity(TelephonyManager.DATA_ACTIVITY_OUT);
+
+ verifyLastQsMobileDataIndicators(true /* visible */,
+ TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH[1][DEFAULT_LEVEL] /* icon */,
+ DEFAULT_QS_ICON /* typeIcon */,
+ false /* dataIn */,
+ true /* dataOut */);
+
+ }
+
+ public void testOnUpdateDataActivity_dataInOut() {
+ setupDefaultSignal();
+
+ updateDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT);
+
+ verifyLastQsMobileDataIndicators(true /* visible */,
+ TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH[1][DEFAULT_LEVEL] /* icon */,
+ DEFAULT_QS_ICON /* typeIcon */,
+ true /* dataIn */,
+ true /* dataOut */);
+
+ }
+
+ public void testOnUpdateDataActivity_dataActivityNone() {
+ setupDefaultSignal();
+
+ updateDataActivity(TelephonyManager.DATA_ACTIVITY_NONE);
+
+ verifyLastQsMobileDataIndicators(true /* visible */,
+ TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH[1][DEFAULT_LEVEL] /* icon */,
+ DEFAULT_QS_ICON /* typeIcon */,
+ false /* dataIn */,
+ false /* dataOut */);
+
+ }
}