[Wi-Fi] Fix Wi-Fi broken tests
Bug: 150910070 Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.wifi Change-Id: Ie9b9384610857e2999fe4642a93c2d31ce3315f3
This commit is contained in:
@@ -1049,7 +1049,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
public void onFailure(int reason) {
|
||||
Activity activity = mFragment.getActivity();
|
||||
if (activity != null) {
|
||||
Toast.makeText(activity,
|
||||
Toast.makeText(mContext,
|
||||
R.string.wifi_failed_save_message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
final Activity activity = mFragment.getActivity();
|
||||
// error handling, connected/saved network should have mWifiConfig.
|
||||
if (mWifiConfig == null) {
|
||||
Toast.makeText(activity,
|
||||
Toast.makeText(mContext,
|
||||
R.string.wifi_failed_connect_message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
@@ -1116,7 +1116,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
if (state == STATE_ENABLE_WIFI) {
|
||||
Log.d(TAG, "Turn on Wi-Fi automatically!");
|
||||
updateConnectedButton(STATE_ENABLE_WIFI);
|
||||
Toast.makeText(activity,
|
||||
Toast.makeText(mContext,
|
||||
R.string.wifi_turned_on_message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
mWifiManager.setWifiEnabled(true);
|
||||
@@ -1137,7 +1137,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
stopTimer();
|
||||
// reset state
|
||||
state = STATE_NONE;
|
||||
Toast.makeText(activity,
|
||||
Toast.makeText(mContext,
|
||||
R.string.wifi_failed_connect_message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
updateConnectedButton(STATE_ENABLE_WIFI_FAILED);
|
||||
@@ -1159,7 +1159,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
Log.d(TAG, "connected");
|
||||
stopTimer();
|
||||
updateConnectedButton(STATE_CONNECTED);
|
||||
Toast.makeText(activity,
|
||||
Toast.makeText(mContext,
|
||||
mContext.getString(R.string.wifi_connected_to_message,
|
||||
mAccessPoint.getTitle()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
@@ -1170,7 +1170,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
stopTimer();
|
||||
// reset state
|
||||
state = STATE_NONE;
|
||||
Toast.makeText(activity,
|
||||
Toast.makeText(mContext,
|
||||
R.string.wifi_not_in_range_message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
updateConnectedButton(STATE_NOT_IN_RANGE);
|
||||
@@ -1179,7 +1179,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
stopTimer();
|
||||
// reset state
|
||||
state = STATE_NONE;
|
||||
Toast.makeText(activity,
|
||||
Toast.makeText(mContext,
|
||||
R.string.wifi_failed_connect_message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
updateConnectedButton(STATE_FAILED);
|
||||
|
@@ -94,7 +94,7 @@ public class WifiTetherSwitchBarController implements
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mSwitch.isChecked()) {
|
||||
if (((Switch) v).isChecked()) {
|
||||
startTether();
|
||||
} else {
|
||||
stopTether();
|
||||
|
@@ -41,7 +41,6 @@ import androidx.fragment.app.FragmentActivity;
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -79,7 +78,6 @@ public class WifiScanningRequiredFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void onClick_positiveButtonSetsWifiScanningOn()
|
||||
throws Settings.SettingNotFoundException {
|
||||
mFragment.onClick(null, DialogInterface.BUTTON_POSITIVE);
|
||||
|
@@ -160,11 +160,10 @@ public class WifiSettings2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void setAdditionalSettingsSummaries_wifiWakeupEnabled_displayOn() {
|
||||
final ContentResolver contentResolver = mContext.getContentResolver();
|
||||
when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
|
||||
when(mWifiManager.isScanAlwaysAvailable()).thenReturn(false);
|
||||
when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true);
|
||||
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
|
||||
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
|
||||
|
||||
|
@@ -49,6 +49,7 @@ import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.View;
|
||||
|
||||
@@ -70,7 +71,6 @@ import com.android.settingslib.wifi.WifiTracker;
|
||||
import com.android.settingslib.wifi.WifiTrackerFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -295,9 +295,12 @@ public class WifiSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Config(shadows = {ShadowDataUsageUtils.class, ShadowFragment.class})
|
||||
public void checkDataUsagePreference_perferenceInvisibleIfWifiNotSupported() {
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setUpForOnCreate();
|
||||
ShadowDataUsageUtils.IS_WIFI_SUPPORTED = false;
|
||||
|
||||
@@ -307,9 +310,12 @@ public class WifiSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Config(shadows = {ShadowDataUsageUtils.class, ShadowFragment.class})
|
||||
public void checkDataUsagePreference_perferenceVisibleIfWifiSupported() {
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setUpForOnCreate();
|
||||
ShadowDataUsageUtils.IS_WIFI_SUPPORTED = true;
|
||||
|
||||
@@ -352,9 +358,12 @@ public class WifiSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Config(shadows = {ShadowDataUsageUtils.class, ShadowFragment.class})
|
||||
public void clickOnWifiNetworkWith_shouldStartCaptivePortalApp() {
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
when(mWifiManager.getConfiguredNetworks()).thenReturn(createMockWifiConfigurations(
|
||||
NUM_NETWORKS));
|
||||
when(mWifiTracker.isConnected()).thenReturn(true);
|
||||
|
@@ -84,7 +84,6 @@ import com.android.settingslib.wifi.WifiTracker;
|
||||
import com.android.settingslib.wifi.WifiTrackerFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
@@ -1428,7 +1427,6 @@ public class WifiDetailPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConnectButton_clickConnect_displayAsSuccess() {
|
||||
setUpForDisconnectedNetwork();
|
||||
when(mockWifiManager.isWifiEnabled()).thenReturn(true);
|
||||
@@ -1461,7 +1459,6 @@ public class WifiDetailPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConnectButton_clickConnectButFailed_displayFailMessage() {
|
||||
setUpForDisconnectedNetwork();
|
||||
ArgumentCaptor<WifiManager.ActionListener> connectListenerCaptor =
|
||||
@@ -1510,7 +1507,6 @@ public class WifiDetailPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConnectButton_clickConnectButTimeout_displayFailMessage() {
|
||||
setUpForDisconnectedNetwork();
|
||||
when(mockWifiManager.isWifiEnabled()).thenReturn(true);
|
||||
@@ -1540,7 +1536,6 @@ public class WifiDetailPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConnectButton_clickConnectButTimeout_displayNotInRangeMessage() {
|
||||
setUpForNotInRangeNetwork();
|
||||
when(mockWifiManager.isWifiEnabled()).thenReturn(true);
|
||||
@@ -1570,7 +1565,6 @@ public class WifiDetailPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConnectButton_clickConnectWhenWiFiDisabled_displaySuccessMessage() {
|
||||
setUpForDisconnectedNetwork();
|
||||
when(mockWifiManager.isWifiEnabled()).thenReturn(false); // wifi disabled
|
||||
@@ -1612,7 +1606,6 @@ public class WifiDetailPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConnectButton_clickConnectWhenWiFiDisabled_failedToConnectWiFi() {
|
||||
setUpForDisconnectedNetwork();
|
||||
when(mockWifiManager.isWifiEnabled()).thenReturn(false); // wifi disabled
|
||||
@@ -1651,7 +1644,6 @@ public class WifiDetailPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void
|
||||
testConnectButton_clickConnectWhenWiFiDisabled_failedToConnectWifiBecauseNotInRange() {
|
||||
setUpForNotInRangeNetwork();
|
||||
@@ -1691,7 +1683,6 @@ public class WifiDetailPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConnectButton_clickConnectWhenWiFiDisabled_failedToEnableWifi() {
|
||||
setUpForDisconnectedNetwork();
|
||||
when(mockWifiManager.isWifiEnabled()).thenReturn(false); // wifi disabled
|
||||
|
@@ -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,11 +32,11 @@ 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;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -99,15 +99,21 @@ public class WifiTetherSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
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