summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2020-03-18 15:34:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-18 15:34:23 +0000
commite5539573fac5594bd6df5d9ec5a4fdf33c655f94 (patch)
tree93328a53412788b7e1541160f4889fbe020c8325 /tests
parentcaf73afd677addbf0fc2172e8446562dfcc5db13 (diff)
parentd32c5600ac8a3b78cb5158f24a39d8a6ad996e7f (diff)
Merge "WifiConfigStore: Use new API's for migrating config store data" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java24
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java16
2 files changed, 27 insertions, 13 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
index 02b53f5c8..14cb6043a 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
@@ -56,6 +56,7 @@ import org.mockito.MockitoAnnotations;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -135,7 +136,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
/**
* Helper method to create and verify actions for the ApConfigStore used in the following tests.
*/
- private WifiApConfigStore createWifiApConfigStore(File legacyFile) {
+ private WifiApConfigStore createWifiApConfigStore(File legacyFile) throws Exception {
WifiApConfigStore store;
if (legacyFile == null) {
store = new WifiApConfigStore(
@@ -144,7 +145,8 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
} else {
store = new WifiApConfigStore(
mContext, mWifiInjector, mHandler, mBackupManagerProxy,
- mWifiConfigStore, mWifiConfigManager, mActiveModeWarden, legacyFile);
+ mWifiConfigStore, mWifiConfigManager, mActiveModeWarden,
+ new FileInputStream(legacyFile));
}
verify(mWifiConfigStore).registerStoreData(any());
@@ -156,7 +158,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
return store;
}
- private WifiApConfigStore createWifiApConfigStore() {
+ private WifiApConfigStore createWifiApConfigStore() throws Exception {
return createWifiApConfigStore(null);
}
@@ -337,9 +339,6 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
// a) On reading the legacy file (new config store not ready yet)
// b) When the new config store is ready.
verify(mWifiConfigManager, times(2)).saveToStore(true);
-
- // The temporary legacy AP config file should be removed after migration.
- assertFalse(mLegacyApConfigFile.exists());
}
/**
@@ -555,7 +554,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
* Verify a proper SoftApConfiguration is generate by getDefaultApConfiguration().
*/
@Test
- public void getDefaultApConfigurationIsValid() {
+ public void getDefaultApConfigurationIsValid() throws Exception {
WifiApConfigStore store = createWifiApConfigStore();
SoftApConfiguration config = store.getApConfiguration();
assertTrue(WifiApConfigStore.validateApWifiConfiguration(config));
@@ -603,7 +602,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
}
@Test
- public void randomizeBssid_randomizesWhenEnabled() {
+ public void randomizeBssid_randomizesWhenEnabled() throws Exception {
mResources.setBoolean(R.bool.config_wifi_ap_mac_randomization_supported, true);
SoftApConfiguration baseConfig = new SoftApConfiguration.Builder().build();
@@ -614,7 +613,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
}
@Test
- public void randomizeBssid_usesFactoryMacWhenRandomizationOff() {
+ public void randomizeBssid_usesFactoryMacWhenRandomizationOff() throws Exception {
mResources.setBoolean(R.bool.config_wifi_ap_mac_randomization_supported, false);
SoftApConfiguration baseConfig = new SoftApConfiguration.Builder().build();
@@ -625,7 +624,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
}
@Test
- public void randomizeBssid_forwardsCustomMac() {
+ public void randomizeBssid_forwardsCustomMac() throws Exception {
mResources.setBoolean(R.bool.config_wifi_ap_mac_randomization_supported, true);
Builder baseConfigBuilder = new SoftApConfiguration.Builder();
baseConfigBuilder.setBssid(MacAddress.fromString("11:22:33:44:55:66"));
@@ -738,7 +737,8 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
* Verify the default configuration security when SAE support.
*/
@Test
- public void testDefaultConfigurationSecurityTypeIsWpa3SaeTransitionWhenSupport() {
+ public void testDefaultConfigurationSecurityTypeIsWpa3SaeTransitionWhenSupport()
+ throws Exception {
mResources.setBoolean(R.bool.config_wifi_softap_sae_supported, true);
WifiApConfigStore store = createWifiApConfigStore();
verifyDefaultApConfig(store.getApConfiguration(), TEST_DEFAULT_AP_SSID, true);
@@ -761,7 +761,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
}
@Test
- public void testResetToDefaultForUnsupportedConfig() {
+ public void testResetToDefaultForUnsupportedConfig() throws Exception {
mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, false);
mResources.setBoolean(R.bool.config_wifi_softap_sae_supported, false);
SoftApConfiguration sae_config = new SoftApConfiguration.Builder()
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java
index 066640679..967c029ba 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java
@@ -24,12 +24,15 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.net.MacAddress;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiMigration;
import android.net.wifi.util.HexEncoding;
import android.os.Handler;
+import android.os.UserHandle;
import android.os.test.TestLooper;
import androidx.test.filters.SmallTest;
+import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.server.wifi.WifiConfigStore.StoreData;
import com.android.server.wifi.WifiConfigStore.StoreFile;
import com.android.server.wifi.util.ArrayUtils;
@@ -42,6 +45,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoSession;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
@@ -163,6 +167,7 @@ public class WifiConfigStoreTest extends WifiBaseTest {
private List<StoreFile> mUserStores = new ArrayList<StoreFile>();
private MockStoreData mSharedStoreData;
private MockStoreData mUserStoreData;
+ private MockitoSession mSession;
/**
* Test instance of WifiConfigStore.
@@ -193,6 +198,12 @@ public class WifiConfigStoreTest extends WifiBaseTest {
mSharedStoreData = new MockStoreData(WifiConfigStore.STORE_FILE_SHARED_GENERAL);
mUserStoreData = new MockStoreData(WifiConfigStore.STORE_FILE_USER_GENERAL);
+
+ mSession = ExtendedMockito.mockitoSession()
+ .mockStatic(WifiMigration.class, withSettings().lenient())
+ .startMocking();
+ when(WifiMigration.convertAndRetrieveSharedConfigStoreFile(anyInt())).thenReturn(null);
+ when(WifiMigration.convertAndRetrieveUserConfigStoreFile(anyInt(), any())).thenReturn(null);
}
/**
@@ -214,6 +225,9 @@ public class WifiConfigStoreTest extends WifiBaseTest {
@After
public void cleanup() {
validateMockitoUsage();
+ if (mSession != null) {
+ mSession.finishMocking();
+ }
}
/**
@@ -841,7 +855,7 @@ public class WifiConfigStoreTest extends WifiBaseTest {
private boolean mStoreWritten;
MockStoreFile(@WifiConfigStore.StoreFileId int fileId) {
- super(new File("MockStoreFile"), fileId, mEncryptionUtil);
+ super(new File("MockStoreFile"), fileId, UserHandle.ALL, mEncryptionUtil);
}
@Override