[Wi-Fi] Fix Wi-Fi broken tests
Bug: 150910070 Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.wifi Change-Id: Ie9b9384610857e2999fe4642a93c2d31ce3315f3 Merged-In: Ie9b9384610857e2999fe4642a93c2d31ce3315f3
This commit is contained in:
@@ -21,7 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -32,6 +32,7 @@ import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkPolicyManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
|
||||
@@ -98,14 +99,21 @@ public class WifiTetherSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSwitchToggled_onlyStartsTetherWhenNeeded() {
|
||||
when(mWifiManager.isWifiApEnabled()).thenReturn(true);
|
||||
mController.onClick(mSwitchBar.getSwitch());
|
||||
public void onSwitchToggled_switchOff_noStartTethering() {
|
||||
final Switch mockSwitch = mock(Switch.class);
|
||||
when(mockSwitch.isChecked()).thenReturn(false);
|
||||
|
||||
mController.onClick(mockSwitch);
|
||||
|
||||
verify(mConnectivityManager, never()).startTethering(anyInt(), anyBoolean(), any(), any());
|
||||
}
|
||||
|
||||
doReturn(false).when(mWifiManager).isWifiApEnabled();
|
||||
mController.onClick(mSwitchBar.getSwitch());
|
||||
@Test
|
||||
public void onSwitchToggled_switchOn_startTethering() {
|
||||
final Switch mockSwitch = mock(Switch.class);
|
||||
when(mockSwitch.isChecked()).thenReturn(true);
|
||||
|
||||
mController.onClick(mockSwitch);
|
||||
|
||||
verify(mConnectivityManager, times(1))
|
||||
.startTethering(anyInt(), anyBoolean(), any(), any());
|
||||
|
||||
Reference in New Issue
Block a user