Merge "[Wi-Fi] Remove the files which use SettingsLib Wi-Fi objects"
This commit is contained in:
committed by
Android (Google) Code Review
commit
bc7c42621b
@@ -55,7 +55,7 @@ public class AddNetworkFragmentTest {
|
||||
|
||||
@Test
|
||||
public void getMode_shouldBeModeConnected() {
|
||||
assertThat(mAddNetworkFragment.getMode()).isEqualTo(WifiConfigUiBase.MODE_CONNECT);
|
||||
assertThat(mAddNetworkFragment.getMode()).isEqualTo(WifiConfigUiBase2.MODE_CONNECT);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -68,7 +68,7 @@ public class ConfigureWifiEntryFragmentTest {
|
||||
@Test
|
||||
public void getMode_shouldBeModeConnected() {
|
||||
assertThat(mConfigureWifiEntryFragment.getMode()).isEqualTo(
|
||||
WifiConfigUiBase.MODE_CONNECT);
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -43,7 +43,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
|
||||
import com.android.settings.wifi.details.WifiPrivacyPreferenceController;
|
||||
import com.android.settings.wifi.details2.WifiPrivacyPreferenceController2;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -249,7 +249,7 @@ public class WifiConfigController2Test {
|
||||
@Test
|
||||
public void loadCertificates_undesiredCertificates_shouldNotLoadUndesiredCertificates() {
|
||||
final Spinner spinner = new Spinner(mContext);
|
||||
when(mKeyStore.list(anyString())).thenReturn(WifiConfigController.UNDESIRED_CERTIFICATES);
|
||||
when(mKeyStore.list(anyString())).thenReturn(WifiConfigController2.UNDESIRED_CERTIFICATES);
|
||||
|
||||
mController.loadCertificates(spinner,
|
||||
"prefix",
|
||||
@@ -392,7 +392,7 @@ public class WifiConfigController2Test {
|
||||
public void loadMacRandomizedValue_shouldPersistentAsDefault() {
|
||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||
final int prefPersist =
|
||||
WifiPrivacyPreferenceController.translateMacRandomizedValueToPrefValue(
|
||||
WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
|
||||
WifiConfiguration.RANDOMIZATION_PERSISTENT);
|
||||
|
||||
assertThat(privacySetting.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
@@ -420,7 +420,7 @@ public class WifiConfigController2Test {
|
||||
|
||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||
final int expectedPrefValue =
|
||||
WifiPrivacyPreferenceController.translateMacRandomizedValueToPrefValue(
|
||||
WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
|
||||
macRandomizedValue);
|
||||
|
||||
assertThat(privacySetting.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
@@ -438,7 +438,7 @@ public class WifiConfigController2Test {
|
||||
public void saveMacRandomizedValue_ChangedToNone_shouldGetNone() {
|
||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||
final int prefMacNone =
|
||||
WifiPrivacyPreferenceController.translateMacRandomizedValueToPrefValue(
|
||||
WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
|
||||
WifiConfiguration.RANDOMIZATION_NONE);
|
||||
privacySetting.setSelection(prefMacNone);
|
||||
|
||||
|
@@ -1,57 +0,0 @@
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
|
||||
import com.android.settings.wifi.WifiDialog.WifiDialogListener;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowEntityHeaderController.class)
|
||||
public class WifiDialogTest {
|
||||
@Mock private AccessPoint mockAccessPoint;
|
||||
|
||||
private Context mContext = RuntimeEnvironment.application;
|
||||
|
||||
private WifiDialogListener mListener = new WifiDialogListener() {};
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createModal_usesDefaultTheme() {
|
||||
WifiDialog modal = WifiDialog
|
||||
.createModal(mContext, mListener, mockAccessPoint, WifiConfigUiBase.MODE_CONNECT);
|
||||
|
||||
WifiDialog wifiDialog = new WifiDialog(mContext, mListener, mockAccessPoint,
|
||||
WifiConfigUiBase.MODE_CONNECT, 0 /* style */, false /* hideSubmitButton */);
|
||||
assertThat(modal.getContext().getThemeResId())
|
||||
.isEqualTo(wifiDialog.getContext().getThemeResId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createModal_whenSetTheme_shouldBeCustomizedTheme() {
|
||||
WifiDialog modal = WifiDialog.createModal(mContext, mListener, mockAccessPoint,
|
||||
WifiConfigUiBase.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light);
|
||||
|
||||
WifiDialog wifiDialog = new WifiDialog(mContext, mListener, mockAccessPoint,
|
||||
WifiConfigUiBase.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light,
|
||||
false /* hideSubmitButton */);
|
||||
assertThat(modal.getContext().getThemeResId())
|
||||
.isEqualTo(wifiDialog.getContext().getThemeResId());
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.wifi.details;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
|
||||
import androidx.preference.DropDownPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class WifiMeteredPreferenceControllerTest {
|
||||
|
||||
private static final int METERED_OVERRIDE_NONE = 0;
|
||||
private static final int METERED_OVERRIDE_METERED = 1;
|
||||
private static final int METERED_OVERRIDE_NOT_METERED = 2;
|
||||
|
||||
@Mock
|
||||
private WifiConfiguration mWifiConfiguration;
|
||||
|
||||
private WifiMeteredPreferenceController mPreferenceController;
|
||||
private Context mContext;
|
||||
private DropDownPreference mDropDownPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
|
||||
mPreferenceController = spy(
|
||||
new WifiMeteredPreferenceController(mContext, mWifiConfiguration));
|
||||
mDropDownPreference = new DropDownPreference(mContext);
|
||||
mDropDownPreference.setEntries(R.array.wifi_metered_entries);
|
||||
mDropDownPreference.setEntryValues(R.array.wifi_metered_values);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_wifiMetered_setCorrectValue() {
|
||||
doReturn(METERED_OVERRIDE_METERED).when(mPreferenceController).getMeteredOverride();
|
||||
|
||||
mPreferenceController.updateState(mDropDownPreference);
|
||||
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo("Treat as metered");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_wifiNotMetered_setCorrectValue() {
|
||||
doReturn(METERED_OVERRIDE_NOT_METERED).when(mPreferenceController).getMeteredOverride();
|
||||
|
||||
mPreferenceController.updateState(mDropDownPreference);
|
||||
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo("Treat as unmetered");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_wifiAuto_setCorrectValue() {
|
||||
doReturn(METERED_OVERRIDE_NONE).when(mPreferenceController).getMeteredOverride();
|
||||
|
||||
mPreferenceController.updateState(mDropDownPreference);
|
||||
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo("Detect automatically");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testController_resilientToNullConfig() {
|
||||
mPreferenceController = spy(new WifiMeteredPreferenceController(mContext, null));
|
||||
|
||||
mPreferenceController.getMeteredOverride();
|
||||
mPreferenceController.onPreferenceChange(mDropDownPreference, 1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user