Merge "Replace ConnectivityManager hidden symbols on Settings" am: cbcea32087
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1597453 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I5fe3e26c5bdda32edf656b4d7e94d2dc17c14e06
This commit is contained in:
@@ -33,6 +33,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -74,6 +75,8 @@ public class AllInOneTetherSettingsTest {
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
@Mock
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private WifiTetherSecurityPreferenceController mSecurityPreferenceController;
|
||||
@@ -89,10 +92,12 @@ public class AllInOneTetherSettingsTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
doReturn(mConnectivityManager)
|
||||
.when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
doReturn(WIFI_REGEXS).when(mConnectivityManager).getTetherableWifiRegexs();
|
||||
doReturn(USB_REGEXS).when(mConnectivityManager).getTetherableUsbRegexs();
|
||||
doReturn(BT_REGEXS).when(mConnectivityManager).getTetherableBluetoothRegexs();
|
||||
doReturn(ETHERNET_REGEXS).when(mConnectivityManager).getTetherableIfaces();
|
||||
doReturn(mTetheringManager)
|
||||
.when(mContext).getSystemService(Context.TETHERING_SERVICE);
|
||||
doReturn(WIFI_REGEXS).when(mTetheringManager).getTetherableWifiRegexs();
|
||||
doReturn(USB_REGEXS).when(mTetheringManager).getTetherableUsbRegexs();
|
||||
doReturn(BT_REGEXS).when(mTetheringManager).getTetherableBluetoothRegexs();
|
||||
doReturn(ETHERNET_REGEXS).when(mTetheringManager).getTetherableIfaces();
|
||||
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
|
||||
// Assume the feature is enabled for most test cases.
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE, true);
|
||||
|
@@ -33,6 +33,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -65,6 +66,8 @@ public class TetherSettingsTest {
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private TetheringManager mTetheringManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -75,11 +78,13 @@ public class TetherSettingsTest {
|
||||
.when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
doReturn(mUserManager)
|
||||
.when(mContext).getSystemService(Context.USER_SERVICE);
|
||||
doReturn(mTetheringManager)
|
||||
.when(mContext).getSystemService(Context.TETHERING_SERVICE);
|
||||
|
||||
setupIsTetherAvailable(true);
|
||||
|
||||
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,7 +114,7 @@ public class TetherSettingsTest {
|
||||
|
||||
@Test
|
||||
public void testTetherNonIndexableKeys_usbNotAvailable_usbKeyReturned() {
|
||||
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||
|
||||
final List<String> niks =
|
||||
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
||||
@@ -122,7 +127,7 @@ public class TetherSettingsTest {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE, false);
|
||||
// We can ignore the condition of Utils.isMonkeyRunning()
|
||||
// In normal case, monkey and robotest should not execute at the same time
|
||||
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[]{"dummyRegex"});
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{"dummyRegex"});
|
||||
|
||||
final List<String> niks =
|
||||
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
||||
@@ -132,7 +137,7 @@ public class TetherSettingsTest {
|
||||
|
||||
@Test
|
||||
public void testTetherNonIndexableKeys_bluetoothNotAvailable_bluetoothKeyReturned() {
|
||||
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
|
||||
|
||||
final List<String> niks =
|
||||
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
||||
@@ -143,7 +148,7 @@ public class TetherSettingsTest {
|
||||
@Test
|
||||
public void testTetherNonIndexableKeys_bluetoothAvailable_bluetoothKeyNotReturned() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE, false);
|
||||
when(mConnectivityManager.getTetherableBluetoothRegexs())
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs())
|
||||
.thenReturn(new String[]{"dummyRegex"});
|
||||
|
||||
final List<String> niks =
|
||||
@@ -232,11 +237,11 @@ public class TetherSettingsTest {
|
||||
}
|
||||
|
||||
private void updateOnlyBluetoothState(TetherSettings tetherSettings) {
|
||||
doReturn(mConnectivityManager).when(tetherSettings)
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
when(mConnectivityManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||
when(mConnectivityManager.getTetheredIfaces()).thenReturn(new String[0]);
|
||||
when(mConnectivityManager.getTetheringErroredIfaces()).thenReturn(new String[0]);
|
||||
doReturn(mTetheringManager).when(tetherSettings)
|
||||
.getSystemService(Context.TETHERING_SERVICE);
|
||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetheringErroredIfaces()).thenReturn(new String[0]);
|
||||
doNothing().when(tetherSettings).updateUsbState(any(String[].class), any(String[].class),
|
||||
any(String[].class));
|
||||
doNothing().when(tetherSettings).updateEthernetState(any(String[].class),
|
||||
|
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
@@ -44,7 +43,7 @@ import org.robolectric.util.ReflectionHelpers;
|
||||
public class BluetoothTetherPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private TetherEnabler mTetherEnabler;
|
||||
|
||||
@@ -58,9 +57,8 @@ public class BluetoothTetherPreferenceControllerTest {
|
||||
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
mSwitchPreference = spy(SwitchPreference.class);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
|
||||
mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
|
||||
mController = new BluetoothTetherPreferenceController(mContext, "BLUETOOTH");
|
||||
mController.setTetherEnabler(mTetherEnabler);
|
||||
ReflectionHelpers.setField(mController, "mPreference", mSwitchPreference);
|
||||
@@ -98,7 +96,7 @@ public class BluetoothTetherPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void shouldShow_noBluetoothTetherable() {
|
||||
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.EthernetManager;
|
||||
import android.net.TetheringManager;
|
||||
|
||||
@@ -49,7 +48,7 @@ public class EthernetTetherPreferenceControllerTest {
|
||||
public MockitoRule mocks = MockitoJUnit.rule();
|
||||
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private EthernetManager mEthernetManager;
|
||||
@Mock
|
||||
@@ -64,9 +63,8 @@ public class EthernetTetherPreferenceControllerTest {
|
||||
public void setUp() {
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
mPreference = spy(SwitchPreference.class);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
||||
.thenReturn(mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableIfaces()).thenReturn(new String[]{ETHERNET_REGEX});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[]{ETHERNET_REGEX});
|
||||
when(mContext.getSystemService(Context.ETHERNET_SERVICE)).thenReturn(mEthernetManager);
|
||||
mController = new EthernetTetherPreferenceController(mContext, "ethernet");
|
||||
mController.setTetherEnabler(mTetherEnabler);
|
||||
@@ -105,7 +103,7 @@ public class EthernetTetherPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void shouldEnable_noTetherable() {
|
||||
when(mConnectivityManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||
assertThat(mController.shouldEnable()).isFalse();
|
||||
}
|
||||
|
||||
|
@@ -101,9 +101,9 @@ public class TetherEnablerTest {
|
||||
when(context.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(context.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(
|
||||
mNetworkPolicyManager);
|
||||
when(mConnectivityManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||
when(mConnectivityManager.getTetheredIfaces()).thenReturn(new String[0]);
|
||||
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||
panReference.set(mBluetoothPan);
|
||||
mEnabler = spy(new TetherEnabler(context, mSwitchWidgetController, panReference));
|
||||
ReflectionHelpers.setField(mEnabler, "mBluetoothAdapter", mBluetoothAdapter);
|
||||
@@ -111,8 +111,8 @@ public class TetherEnablerTest {
|
||||
|
||||
@Test
|
||||
public void lifecycle_onStart_setCheckedCorrectly() {
|
||||
when(mConnectivityManager.getTetheredIfaces()).thenReturn(USB_TETHERED);
|
||||
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(USB_TETHERED);
|
||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(USB_TETHERED);
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(USB_TETHERED);
|
||||
|
||||
mEnabler.onStart();
|
||||
assertThat(mSwitchBar.isChecked()).isTrue();
|
||||
@@ -150,7 +150,7 @@ public class TetherEnablerTest {
|
||||
mEnabler.onStart();
|
||||
mEnabler.startTethering(TetheringManager.TETHERING_WIFI);
|
||||
|
||||
when(mConnectivityManager.getTetheredIfaces()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(new String[0]);
|
||||
mEnabler.mOnStartTetheringCallback.onTetheringFailed();
|
||||
|
||||
assertThat(mSwitchBar.isChecked()).isFalse();
|
||||
@@ -255,8 +255,8 @@ public class TetherEnablerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_shouldEnableSwitchBarTethering() {
|
||||
when(mConnectivityManager.getTetheredIfaces()).thenReturn(USB_TETHERED);
|
||||
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(USB_TETHERED);
|
||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(USB_TETHERED);
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(USB_TETHERED);
|
||||
|
||||
mSwitchWidgetController.setListener(mEnabler);
|
||||
mSwitchWidgetController.startListening();
|
||||
|
@@ -33,6 +33,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
@@ -56,7 +57,7 @@ public class TetherPreferenceControllerTest {
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
@Mock
|
||||
@@ -69,7 +70,7 @@ public class TetherPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mController = spy(TetherPreferenceController.class);
|
||||
ReflectionHelpers.setField(mController, "mContext", mContext);
|
||||
ReflectionHelpers.setField(mController, "mConnectivityManager", mConnectivityManager);
|
||||
ReflectionHelpers.setField(mController, "mTetheringManager", mTetheringManager);
|
||||
ReflectionHelpers.setField(mController, "mBluetoothAdapter", mBluetoothAdapter);
|
||||
ReflectionHelpers.setField(mController, "mPreference", mPreference);
|
||||
}
|
||||
@@ -106,16 +107,16 @@ public class TetherPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateSummary_noPreference_noInteractionWithConnectivityManager() {
|
||||
public void updateSummary_noPreference_noInteractionWithTetheringManager() {
|
||||
ReflectionHelpers.setField(mController, "mPreference", null);
|
||||
mController.updateSummary();
|
||||
verifyNoMoreInteractions(mConnectivityManager);
|
||||
verifyNoMoreInteractions(mTetheringManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateSummary_wifiTethered_shouldShowHotspotMessage() {
|
||||
when(mConnectivityManager.getTetheredIfaces()).thenReturn(new String[]{"123"});
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"123"});
|
||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(new String[]{"123"});
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"123"});
|
||||
|
||||
mController.updateSummary();
|
||||
verify(mPreference).setSummary(R.string.tether_settings_summary_hotspot_on_tether_off);
|
||||
@@ -123,8 +124,8 @@ public class TetherPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateSummary_btThetherOn_shouldShowTetherMessage() {
|
||||
when(mConnectivityManager.getTetheredIfaces()).thenReturn(new String[]{"123"});
|
||||
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[]{"123"});
|
||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(new String[]{"123"});
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[]{"123"});
|
||||
|
||||
mController.updateSummary();
|
||||
verify(mPreference).setSummary(R.string.tether_settings_summary_hotspot_off_tether_on);
|
||||
@@ -132,8 +133,8 @@ public class TetherPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateSummary_tetherOff_shouldShowTetherOffMessage() {
|
||||
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[]{"123"});
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"456"});
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[]{"123"});
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"456"});
|
||||
|
||||
mController.updateSummary();
|
||||
verify(mPreference).setSummary(R.string.switch_off_text);
|
||||
@@ -141,9 +142,9 @@ public class TetherPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateSummary_wifiBtTetherOn_shouldShowHotspotAndTetherMessage() {
|
||||
when(mConnectivityManager.getTetheredIfaces()).thenReturn(new String[]{"123", "456"});
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"456"});
|
||||
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[]{"23"});
|
||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(new String[]{"123", "456"});
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"456"});
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[]{"23"});
|
||||
|
||||
mController.updateSummary();
|
||||
verify(mPreference).setSummary(R.string.tether_settings_summary_hotspot_on_tether_on);
|
||||
|
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
@@ -43,7 +42,7 @@ import org.robolectric.util.ReflectionHelpers;
|
||||
public class UsbTetherPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private TetherEnabler mTetherEnabler;
|
||||
|
||||
@@ -56,9 +55,8 @@ public class UsbTetherPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
|
||||
mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
|
||||
mController = new UsbTetherPreferenceController(mContext, "USB");
|
||||
mController.setTetherEnabler(mTetherEnabler);
|
||||
mSwitchPreference = spy(SwitchPreference.class);
|
||||
@@ -94,7 +92,7 @@ public class UsbTetherPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void shouldShow_noTetherableUsb() {
|
||||
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||
assertThat(mController.shouldShow()).isFalse();
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
@@ -77,7 +77,7 @@ public class WifiTetherDisablePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
@Mock
|
||||
@@ -100,9 +100,8 @@ public class WifiTetherDisablePreferenceControllerTest {
|
||||
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
mPreference = spy(SwitchPreference.class);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
|
||||
mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
|
||||
mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
|
||||
mController.setTetherEnabler(mTetherEnabler);
|
||||
ReflectionHelpers.setField(mController, "mScreen", mPreferenceScreen);
|
||||
@@ -112,7 +111,7 @@ public class WifiTetherDisablePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void shouldShow_noTetherableWifi() {
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[0]);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[0]);
|
||||
assertThat(mController.shouldShow()).isFalse();
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
@@ -74,9 +74,8 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mPreference = new ListPreference(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
||||
.thenReturn(mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(
|
||||
|
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -43,7 +43,7 @@ public class WifiTetherFooterPreferenceControllerTest {
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
@@ -58,9 +58,8 @@ public class WifiTetherFooterPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
||||
.thenReturn(mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
mController = new WifiTetherFooterPreferenceController(mContext);
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class WifiTetherPasswordPreferenceControllerTest {
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
@@ -77,9 +77,8 @@ public class WifiTetherPasswordPreferenceControllerTest {
|
||||
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
||||
.thenReturn(mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||
|
||||
|
@@ -23,7 +23,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class WifiTetherPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
@@ -77,14 +77,13 @@ public class WifiTetherPreferenceControllerTest {
|
||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||
FakeFeatureFactory.setupForTest();
|
||||
mPreference = new MasterSwitchPreference(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
||||
.thenReturn(mConnectivityManager);
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||
mSoftApConfiguration = new SoftApConfiguration.Builder().setSsid(SSID).build();
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(mSoftApConfiguration);
|
||||
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
mController = new WifiTetherPreferenceController(mContext, mLifecycle,
|
||||
false /* initSoftApManager */);
|
||||
mController.displayPreference(mScreen);
|
||||
@@ -92,7 +91,7 @@ public class WifiTetherPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isAvailable_noTetherRegex_shouldReturnFalse() {
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{});
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{});
|
||||
mController = new WifiTetherPreferenceController(mContext, mLifecycle,
|
||||
false /* initSoftApManager */);
|
||||
|
||||
|
@@ -26,7 +26,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class WifiTetherSSIDPreferenceControllerTest {
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
@@ -68,9 +68,8 @@ public class WifiTetherSSIDPreferenceControllerTest {
|
||||
mPreference = new WifiTetherSsidPreference(RuntimeEnvironment.application);
|
||||
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
||||
.thenReturn(mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||
mController = new WifiTetherSSIDPreferenceController(mContext, mListener,
|
||||
|
@@ -7,7 +7,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
private WifiTetherBasePreferenceController.OnTetherConfigUpdateListener mListener;
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private TetheringManager mTetheringManager;
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
@@ -51,9 +51,8 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
||||
.thenReturn(mConnectivityManager);
|
||||
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||
|
||||
mController = new WifiTetherSecurityPreferenceController(mContext, mListener);
|
||||
|
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -69,6 +70,8 @@ public class WifiTetherSettingsTest {
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private TetheringManager mTetheringManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -77,7 +80,8 @@ public class WifiTetherSettingsTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
doReturn(mConnectivityManager)
|
||||
.when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
doReturn(WIFI_REGEXS).when(mConnectivityManager).getTetherableWifiRegexs();
|
||||
doReturn(mTetheringManager).when(mContext).getSystemService(Context.TETHERING_SERVICE);
|
||||
doReturn(WIFI_REGEXS).when(mTetheringManager).getTetherableWifiRegexs();
|
||||
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
|
||||
|
||||
mWifiTetherSettings = new WifiTetherSettings();
|
||||
|
Reference in New Issue
Block a user