diff options
Diffstat (limited to 'packages/SystemUI/tests/src')
-rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerEthernetTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerEthernetTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerEthernetTest.java new file mode 100644 index 0000000..82ced9f --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerEthernetTest.java @@ -0,0 +1,40 @@ +package com.android.systemui.statusbar.policy; + +import android.net.NetworkCapabilities; + +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; + +public class NetworkControllerEthernetTest extends NetworkControllerBaseTest { + + public void testEthernetIcons() { + verifyLastEthernetIcon(false, 0); + + setEthernetState(true, false); // Connected, unvalidated. + verifyLastEthernetIcon(true, EthernetIcons.ETHERNET_ICONS[0][0]); + + setEthernetState(true, true); // Connected, validated. + verifyLastEthernetIcon(true, EthernetIcons.ETHERNET_ICONS[1][0]); + + setEthernetState(true, false); // Connected, unvalidated. + verifyLastEthernetIcon(true, EthernetIcons.ETHERNET_ICONS[0][0]); + + setEthernetState(false, false); // Disconnected. + verifyLastEthernetIcon(false, 0); + } + + protected void setEthernetState(boolean connected, boolean validated) { + setConnectivity(validated ? 100 : 0, NetworkCapabilities.TRANSPORT_ETHERNET, connected); + } + + protected void verifyLastEthernetIcon(boolean visible, int icon) { + ArgumentCaptor<Boolean> visibleArg = ArgumentCaptor.forClass(Boolean.class); + ArgumentCaptor<Integer> iconArg = ArgumentCaptor.forClass(Integer.class); + + Mockito.verify(mSignalCluster, Mockito.atLeastOnce()).setEthernetIndicators( + visibleArg.capture(), iconArg.capture(), + ArgumentCaptor.forClass(String.class).capture()); + assertEquals("Ethernet visible, in status bar", visible, (boolean) visibleArg.getValue()); + assertEquals("Ethernet icon, in status bar", icon, (int) iconArg.getValue()); + } +} |