diff options
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 */); + } } |