Home | History | Annotate | Download | only in policy
      1 package com.android.systemui.statusbar.policy;
      2 
      3 import android.net.NetworkCapabilities;
      4 import android.test.suitebuilder.annotation.SmallTest;
      5 
      6 import com.android.systemui.statusbar.policy.NetworkController.IconState;
      7 
      8 import org.mockito.ArgumentCaptor;
      9 import org.mockito.Mockito;
     10 
     11 @SmallTest
     12 public class NetworkControllerEthernetTest extends NetworkControllerBaseTest {
     13 
     14     public void testEthernetIcons() {
     15         verifyLastEthernetIcon(false, 0);
     16 
     17         setEthernetState(true, false);   // Connected, unvalidated.
     18         verifyLastEthernetIcon(true, EthernetIcons.ETHERNET_ICONS[0][0]);
     19 
     20         setEthernetState(true, true);    // Connected, validated.
     21         verifyLastEthernetIcon(true, EthernetIcons.ETHERNET_ICONS[1][0]);
     22 
     23         setEthernetState(true, false);   // Connected, unvalidated.
     24         verifyLastEthernetIcon(true, EthernetIcons.ETHERNET_ICONS[0][0]);
     25 
     26         setEthernetState(false, false);  // Disconnected.
     27         verifyLastEthernetIcon(false, 0);
     28     }
     29 
     30     protected void setEthernetState(boolean connected, boolean validated) {
     31         setConnectivity(NetworkCapabilities.TRANSPORT_ETHERNET, validated, connected);
     32     }
     33 
     34     protected void verifyLastEthernetIcon(boolean visible, int icon) {
     35         ArgumentCaptor<IconState> iconArg = ArgumentCaptor.forClass(IconState.class);
     36 
     37         Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setEthernetIndicators(
     38                 iconArg.capture());
     39         IconState iconState = iconArg.getValue();
     40         assertEquals("Ethernet visible, in status bar", visible, iconState.visible);
     41         assertEquals("Ethernet icon, in status bar", icon, iconState.icon);
     42     }
     43 }
     44