diff options
author | Andrew Flynn <flynn@google.com> | 2015-05-01 11:50:07 -0400 |
---|---|---|
committer | Andrew Flynn <flynn@google.com> | 2015-05-04 10:25:09 -0400 |
commit | 5e751478065835cf86f661cf34fa4f52f851cef5 (patch) | |
tree | 4983be8e2863ace1aa25ff99a6fad40473bbadf4 /packages/SystemUI/tests | |
parent | a78240ba5f891c3fd0acb62a1b13b6dc1bbe9705 (diff) | |
download | frameworks_base-5e751478065835cf86f661cf34fa4f52f851cef5.zip frameworks_base-5e751478065835cf86f661cf34fa4f52f851cef5.tar.gz frameworks_base-5e751478065835cf86f661cf34fa4f52f851cef5.tar.bz2 |
SystemUI Carrier Network Change unit tests
- Includes unit tests for verifying mobile data indicators.
- Found one bug where dark mode icon wasn't showing properly when
different from light mode icon.
- Comment out failing test
NetworkControllerSignalTest#testSetCurrentSubscriptions
Bug: 20288155
Change-Id: Ib3c9ba224c4187cab35d6bfa68f6bd4c489cf98e
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 */); + } } |