summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/tests
diff options
context:
space:
mode:
authorLeigh Anne <lwarner@google.com>2014-11-13 14:27:10 -0800
committerJason Monk <jmonk@google.com>2014-12-02 11:21:53 -0500
commitd0a6279af69184621bf6384c5435d3eb6f62ac03 (patch)
tree8557189c41d71711a5896004168eef66df283046 /packages/SystemUI/tests
parent311aa004c0214e80383a998ae7e9869181d47eb6 (diff)
downloadframeworks_base-d0a6279af69184621bf6384c5435d3eb6f62ac03.zip
frameworks_base-d0a6279af69184621bf6384c5435d3eb6f62ac03.tar.gz
frameworks_base-d0a6279af69184621bf6384c5435d3eb6f62ac03.tar.bz2
SysUI Tests: Added some tests for mobile icon.
Testing to verify correct mobile icon in edge cases such as no sim, or no mobile data feature. Tests for updating the network name. Change-Id: I0e4114d0c1e4109d4b2aae761181bedb841fe8b6
Diffstat (limited to 'packages/SystemUI/tests')
-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 */);
+
+ }
}