Merge changes I8194476e,I9d21909f
* changes: [Wi-Fi] Fix some test failures of com.android.settings.wifi.details2 [Wi-Fi] Remove passpoint methods in WifiEntryShell
This commit is contained in:
committed by
Android (Google) Code Review
commit
b7f0145c02
@@ -23,7 +23,6 @@ import com.android.wifitrackerlib.WifiEntry;
|
||||
* all the unavalable {@link AccessPoint} methods & constants.
|
||||
*
|
||||
* TODO(b/143326832): Replace all methods & constants with WifiEntry version when it's available.
|
||||
* TODO(b/143326832): How about AccessPoint#getSettingsSummary(boolean convertSavedAsDisconnected)?
|
||||
*/
|
||||
public class WifiEntryShell {
|
||||
public WifiEntryShell(){};
|
||||
@@ -47,41 +46,4 @@ public class WifiEntryShell {
|
||||
* Upper bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
|
||||
*/
|
||||
public static final int HIGHER_FREQ_5GHZ = 5900;
|
||||
|
||||
// Passpoint methods
|
||||
|
||||
/**
|
||||
* Mapping of the corresponding {@link AccessPoint} method
|
||||
*/
|
||||
public static boolean isExpired(WifiEntry wifiEntry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of the corresponding {@link AccessPoint} method
|
||||
*/
|
||||
public static boolean isPasspointConfigurationR1(WifiEntry wifiEntry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of the corresponding {@link AccessPoint} method
|
||||
*/
|
||||
public static boolean isPasspointConfigurationOsuProvisioned(WifiEntry wifiEntry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of the corresponding {@link AccessPoint} method
|
||||
*/
|
||||
public static boolean isOsuProvider(WifiEntry wifiEntry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of the corresponding {@link AccessPoint} method
|
||||
*/
|
||||
public static String getPasspointFqdn(WifiEntry wifiEntry) {
|
||||
return "Fake passpoint FQDN";
|
||||
}
|
||||
}
|
||||
|
@@ -537,7 +537,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
||||
}
|
||||
|
||||
private void refreshSsid() {
|
||||
if (mWifiEntry.isSubscription() || WifiEntryShell.isOsuProvider(mWifiEntry)) {
|
||||
if (mWifiEntry.isSubscription()) {
|
||||
mSsidPref.setVisible(true);
|
||||
mSsidPref.setSummary(mWifiEntry.getTitle());
|
||||
} else {
|
||||
@@ -743,8 +743,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
||||
try {
|
||||
mWifiEntry.forget(this);
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "Failed to remove Passpoint configuration for "
|
||||
+ WifiEntryShell.getPasspointFqdn(mWifiEntry));
|
||||
Log.e(TAG, "Failed to remove Passpoint configuration: " + e);
|
||||
}
|
||||
mMetricsFeatureProvider.action(
|
||||
mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
|
||||
|
@@ -28,7 +28,6 @@ import com.android.settings.R;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -86,13 +85,4 @@ public class WifiMeteredPreferenceController2Test {
|
||||
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo("Detect automatically");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testController_resilientToNullConfig() {
|
||||
mPreferenceController = spy(new WifiMeteredPreferenceController2(mContext, null));
|
||||
|
||||
mPreferenceController.getMeteredOverride();
|
||||
mPreferenceController.onPreferenceChange(mDropDownPreference, 1);
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.wifi.details2;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -30,7 +31,6 @@ import com.android.settings.R;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -38,14 +38,12 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Ignore
|
||||
public class WifiPrivacyPreferenceController2Test {
|
||||
|
||||
private static final int PRIVACY_RANDOMIZED = WifiEntry.PRIVACY_RANDOMIZED_MAC;
|
||||
private static final int PRIVACY_TRUSTED = WifiEntry.PRIVACY_DEVICE_MAC;
|
||||
|
||||
@Mock
|
||||
private WifiEntry mWifiEntry;
|
||||
@Mock private WifiEntry mMockWifiEntry;
|
||||
|
||||
private WifiPrivacyPreferenceController2 mPreferenceController;
|
||||
private Context mContext;
|
||||
@@ -56,9 +54,10 @@ public class WifiPrivacyPreferenceController2Test {
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
|
||||
mMockWifiEntry = mock(WifiEntry.class);
|
||||
WifiPrivacyPreferenceController2 preferenceController =
|
||||
new WifiPrivacyPreferenceController2(mContext);
|
||||
preferenceController.setWifiEntry(mWifiEntry);
|
||||
preferenceController.setWifiEntry(mMockWifiEntry);
|
||||
mPreferenceController = spy(preferenceController);
|
||||
mDropDownPreference = new DropDownPreference(mContext);
|
||||
mDropDownPreference.setEntries(R.array.wifi_privacy_entries);
|
||||
@@ -89,18 +88,10 @@ public class WifiPrivacyPreferenceController2Test {
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo(mPerferenceStrings[prefValue]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testController_resilientToNullConfig() {
|
||||
mPreferenceController = spy(new WifiPrivacyPreferenceController2(mContext));
|
||||
mPreferenceController.setWifiEntry(mWifiEntry);
|
||||
|
||||
mPreferenceController.getRandomizationValue();
|
||||
mPreferenceController.onPreferenceChange(mDropDownPreference, "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_canSetPrivacy_shouldBeSelectable() {
|
||||
when(mWifiEntry.canSetPrivacy()).thenReturn(true);
|
||||
when(mMockWifiEntry.canSetPrivacy()).thenReturn(true);
|
||||
|
||||
mPreferenceController.updateState(mDropDownPreference);
|
||||
|
||||
assertThat(mDropDownPreference.isSelectable()).isTrue();
|
||||
@@ -108,7 +99,8 @@ public class WifiPrivacyPreferenceController2Test {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_canNotSetPrivacy_shouldNotSelectable() {
|
||||
when(mWifiEntry.canSetPrivacy()).thenReturn(false);
|
||||
when(mMockWifiEntry.canSetPrivacy()).thenReturn(false);
|
||||
|
||||
mPreferenceController.updateState(mDropDownPreference);
|
||||
|
||||
assertThat(mDropDownPreference.isSelectable()).isFalse();
|
||||
|
Reference in New Issue
Block a user