diff options
author | Andrew Flynn <flynn@google.com> | 2015-05-04 14:43:19 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-04 14:43:20 +0000 |
commit | ae499d19eb70a46f12d6d750c608b893951a118b (patch) | |
tree | c8944ec348f7976616aa7199aceca7df5aae8471 /packages/SystemUI/tests | |
parent | 05dc201ff64f6324c2726a8841af7021e7071b97 (diff) | |
parent | 5e751478065835cf86f661cf34fa4f52f851cef5 (diff) | |
download | frameworks_base-ae499d19eb70a46f12d6d750c608b893951a118b.zip frameworks_base-ae499d19eb70a46f12d6d750c608b893951a118b.tar.gz frameworks_base-ae499d19eb70a46f12d6d750c608b893951a118b.tar.bz2 |
Merge "SystemUI Carrier Network Change unit tests" into mnc-dev
Diffstat (limited to 'packages/SystemUI/tests')
2 files changed, 79 insertions, 3 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 5d40eed..a176c98 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 @@ -234,6 +234,11 @@ public class NetworkControllerBaseTest extends SysuiTestCase { mPhoneStateListener.onDataActivity(dataActivity); } + public void setCarrierNetworkChange(boolean enable) { + Log.d(TAG, "setCarrierNetworkChange(" + enable + ")"); + mPhoneStateListener.onCarrierNetworkChange(enable); + } + protected void verifyHasNoSims(boolean hasNoSimsVisible) { ArgumentCaptor<Boolean> hasNoSimsArg = ArgumentCaptor.forClass(Boolean.class); @@ -273,19 +278,29 @@ public class NetworkControllerBaseTest extends SysuiTestCase { } protected void verifyLastMobileDataIndicators(boolean visible, int icon, int typeIcon) { - ArgumentCaptor<Integer> iconArg = ArgumentCaptor.forClass(Integer.class); + verifyLastMobileDataIndicators(visible, icon, icon, typeIcon); + } + + protected void verifyLastMobileDataIndicators(boolean visible, int strengthIcon, + int darkStrengthIcon, int typeIcon) { + ArgumentCaptor<Integer> strengthIconArg = ArgumentCaptor.forClass(Integer.class); + ArgumentCaptor<Integer> darkStrengthIconArg = ArgumentCaptor.forClass(Integer.class); ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class); ArgumentCaptor<Boolean> visibleArg = ArgumentCaptor.forClass(Boolean.class); // TODO: Verify all fields. Mockito.verify(mSignalCluster, Mockito.atLeastOnce()).setMobileDataIndicators( - visibleArg.capture(), iconArg.capture(), iconArg.capture(), typeIconArg.capture(), + visibleArg.capture(), strengthIconArg.capture(), darkStrengthIconArg.capture(), + typeIconArg.capture(), ArgumentCaptor.forClass(String.class).capture(), ArgumentCaptor.forClass(String.class).capture(), ArgumentCaptor.forClass(Boolean.class).capture(), ArgumentCaptor.forClass(Integer.class).capture()); - assertEquals("Signal icon in status bar", icon, (int) iconArg.getValue()); + assertEquals("Signal strength icon in status bar", strengthIcon, + (int) strengthIconArg.getValue()); + assertEquals("Signal strength icon (dark mode) in status bar", darkStrengthIcon, + (int) darkStrengthIconArg.getValue()); assertEquals("Data icon in status bar", typeIcon, (int) typeIconArg.getValue()); assertEquals("Visibility in status bar", visible, (boolean) visibleArg.getValue()); } 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 aefb1bb..389ad6f 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 @@ -396,4 +396,65 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest { false /* dataOut */); } + + public void testCarrierNetworkChange_carrierNetworkChangeWhileConnected() { + int strength = SignalStrength.SIGNAL_STRENGTH_GREAT; + + setupDefaultSignal(); + setLevel(strength); + + // API call is made + setCarrierNetworkChange(true /* enabled */); + + // Boolean value is set, but we still have a signal, should be showing normal + verifyLastMobileDataIndicators(true /* visible */, + TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH[1][strength] /* strengthIcon */, + DEFAULT_ICON /* typeIcon */); + + // Lose voice but still have data + setVoiceRegState(ServiceState.STATE_OUT_OF_SERVICE); + verifyLastMobileDataIndicators(true /* visible */, + TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH[1][strength] /* strengthIcon */, + DEFAULT_ICON /* typeIcon */); + + // Voice but no data + setVoiceRegState(ServiceState.STATE_IN_SERVICE); + setDataRegState(ServiceState.STATE_OUT_OF_SERVICE); + verifyLastMobileDataIndicators(true /* visible */, + TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH[1][strength] /* strengthIcon */, + DEFAULT_ICON /* typeIcon */); + } + + public void testCarrierNetworkChange_carrierNetworkChangeWhileDisconnected() { + int strength = SignalStrength.SIGNAL_STRENGTH_GREAT; + + setupDefaultSignal(); + setLevel(strength); + + // Verify baseline + verifyLastMobileDataIndicators(true /* visible */, + TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH[1][strength] /* strengthIcon */, + DEFAULT_ICON /* typeIcon */); + + // API call is made and all connectivity lost + setCarrierNetworkChange(true /* enabled */); + setVoiceRegState(ServiceState.STATE_OUT_OF_SERVICE); + setDataRegState(ServiceState.STATE_OUT_OF_SERVICE); + + // Out of service and carrier network change is true, show special indicator + verifyLastMobileDataIndicators(true /* visible */, + TelephonyIcons.TELEPHONY_CARRIER_NETWORK_CHANGE[0][0] /* strengthIcon */, + TelephonyIcons.TELEPHONY_CARRIER_NETWORK_CHANGE_DARK[0][0] /* darkStrengthIcon */, + 0 /* typeIcon */); + + // Revert back + setCarrierNetworkChange(false /* enabled */); + setVoiceRegState(ServiceState.STATE_IN_SERVICE); + setDataRegState(ServiceState.STATE_IN_SERVICE); + + // Verify back in previous state + verifyLastMobileDataIndicators(true /* visible */, + TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH[1][strength] /* strengthIcon */, + DEFAULT_ICON /* typeIcon */); + } } |