Merge changes I1ad45223,Id8ec6317,If393bb08,I1cf32ec4,Ia7b86a4b, ... into rvc-dev
* changes: CTS: Test WifiNl80211Manager.OemSecurityType CTS: Test PnoSettings CTS: Test NativeWifiClient CTS: Test PnoNetwork CTS: Test RadioChainInfo CTS: Test DeviceWiphyCapabilities
This commit is contained in:
@@ -20,12 +20,12 @@ import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
public class WifiFeature {
|
||||
static boolean isWifiSupported(Context context) {
|
||||
public static boolean isWifiSupported(Context context) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
return packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI);
|
||||
}
|
||||
|
||||
static boolean isP2pSupported(Context context) {
|
||||
public static boolean isP2pSupported(Context context) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
return packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 android.net.wifi.nl80211.cts;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.cts.WifiFeature;
|
||||
import android.net.wifi.nl80211.DeviceWiphyCapabilities;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** CTS tests for {@link DeviceWiphyCapabilities}. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class DeviceWiphyCapabilitiesTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
// skip tests if Wifi is not supported
|
||||
assumeTrue(WifiFeature.isWifiSupported(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a {@link DeviceWiphyCapabilities} object can be serialized and deserialized,
|
||||
* while keeping its values unchanged.
|
||||
*/
|
||||
@Test
|
||||
public void canSerializeAndDeserialize() {
|
||||
DeviceWiphyCapabilities capa = new DeviceWiphyCapabilities();
|
||||
|
||||
capa.setWifiStandardSupport(ScanResult.WIFI_STANDARD_11N, true);
|
||||
capa.setWifiStandardSupport(ScanResult.WIFI_STANDARD_11AC, true);
|
||||
capa.setWifiStandardSupport(ScanResult.WIFI_STANDARD_11AX, false);
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
capa.writeToParcel(parcel, 0);
|
||||
// Rewind the pointer to the head of the parcel.
|
||||
parcel.setDataPosition(0);
|
||||
DeviceWiphyCapabilities capaDeserialized =
|
||||
DeviceWiphyCapabilities.CREATOR.createFromParcel(parcel);
|
||||
|
||||
assertThat(capaDeserialized.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11N)).isTrue();
|
||||
assertThat(capaDeserialized.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11AC))
|
||||
.isTrue();
|
||||
assertThat(capaDeserialized.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11AX))
|
||||
.isFalse();
|
||||
assertThat(capaDeserialized).isEqualTo(capa);
|
||||
assertThat(capaDeserialized.hashCode()).isEqualTo(capa.hashCode());
|
||||
}
|
||||
|
||||
/** Test mapping wifi standard support into channel width support */
|
||||
@Test
|
||||
public void testMappingWifiStandardIntoChannelWidthSupport() {
|
||||
DeviceWiphyCapabilities capa = new DeviceWiphyCapabilities();
|
||||
|
||||
capa.setWifiStandardSupport(ScanResult.WIFI_STANDARD_11N, false);
|
||||
capa.setWifiStandardSupport(ScanResult.WIFI_STANDARD_11AC, false);
|
||||
capa.setWifiStandardSupport(ScanResult.WIFI_STANDARD_11AX, false);
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_20MHZ)).isTrue();
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_40MHZ)).isFalse();
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_80MHZ)).isFalse();
|
||||
|
||||
capa.setWifiStandardSupport(ScanResult.WIFI_STANDARD_11N, true);
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_20MHZ)).isTrue();
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_40MHZ)).isTrue();
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_80MHZ)).isFalse();
|
||||
|
||||
capa.setWifiStandardSupport(ScanResult.WIFI_STANDARD_11AC, true);
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_20MHZ)).isTrue();
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_40MHZ)).isTrue();
|
||||
assertThat(capa.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_80MHZ)).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 android.net.wifi.nl80211.cts;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.MacAddress;
|
||||
import android.net.wifi.cts.WifiFeature;
|
||||
import android.net.wifi.nl80211.NativeWifiClient;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** CTS tests for {@link NativeWifiClient}. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class NativeWifiClientTest {
|
||||
|
||||
private static final byte[] TEST_MAC = { 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
// skip tests if Wifi is not supported
|
||||
assumeTrue(WifiFeature.isWifiSupported(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetters() {
|
||||
NativeWifiClient client = new NativeWifiClient(MacAddress.fromBytes(TEST_MAC));
|
||||
|
||||
assertThat(client.getMacAddress().toByteArray()).isEqualTo(TEST_MAC);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canSerializeAndDeserialize() {
|
||||
NativeWifiClient client = new NativeWifiClient(MacAddress.fromBytes(TEST_MAC));
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
client.writeToParcel(parcel, 0);
|
||||
// Rewind the pointer to the head of the parcel.
|
||||
parcel.setDataPosition(0);
|
||||
NativeWifiClient clientDeserialized = NativeWifiClient.CREATOR.createFromParcel(parcel);
|
||||
|
||||
assertThat(clientDeserialized.getMacAddress().toByteArray()).isEqualTo(TEST_MAC);
|
||||
assertThat(clientDeserialized).isEqualTo(client);
|
||||
assertThat(clientDeserialized.hashCode()).isEqualTo(client.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
NativeWifiClient client = new NativeWifiClient(MacAddress.fromBytes(TEST_MAC));
|
||||
NativeWifiClient client2 =
|
||||
new NativeWifiClient(MacAddress.fromBytes(new byte[] { 7, 8, 9, 10, 11, 12 }));
|
||||
|
||||
assertThat(client2).isNotEqualTo(client);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 android.net.wifi.nl80211.cts;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.cts.WifiFeature;
|
||||
import android.net.wifi.nl80211.PnoNetwork;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** CTS tests for {@link PnoNetwork}. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class PnoNetworkTest {
|
||||
|
||||
private static final byte[] TEST_SSID = { 's', 's', 'i', 'd' };
|
||||
private static final int[] TEST_FREQUENCIES = { 2412, 2417, 5035 };
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
// skip tests if Wifi is not supported
|
||||
assumeTrue(WifiFeature.isWifiSupported(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetters() {
|
||||
PnoNetwork network = new PnoNetwork();
|
||||
network.setSsid(TEST_SSID);
|
||||
network.setFrequenciesMhz(TEST_FREQUENCIES);
|
||||
network.setHidden(true);
|
||||
|
||||
assertThat(network.getSsid()).isEqualTo(TEST_SSID);
|
||||
assertThat(network.getFrequenciesMhz()).isEqualTo(TEST_FREQUENCIES);
|
||||
assertThat(network.isHidden()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canSerializeAndDeserialize() {
|
||||
PnoNetwork network = new PnoNetwork();
|
||||
network.setSsid(TEST_SSID);
|
||||
network.setFrequenciesMhz(TEST_FREQUENCIES);
|
||||
network.setHidden(true);
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
network.writeToParcel(parcel, 0);
|
||||
// Rewind the pointer to the head of the parcel.
|
||||
parcel.setDataPosition(0);
|
||||
PnoNetwork networkDeserialized = PnoNetwork.CREATOR.createFromParcel(parcel);
|
||||
|
||||
assertThat(networkDeserialized.getSsid()).isEqualTo(TEST_SSID);
|
||||
assertThat(networkDeserialized.getFrequenciesMhz()).isEqualTo(TEST_FREQUENCIES);
|
||||
assertThat(networkDeserialized.isHidden()).isTrue();
|
||||
assertThat(networkDeserialized).isEqualTo(network);
|
||||
assertThat(networkDeserialized.hashCode()).isEqualTo(network.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
PnoNetwork network = new PnoNetwork();
|
||||
network.setSsid(TEST_SSID);
|
||||
network.setFrequenciesMhz(TEST_FREQUENCIES);
|
||||
network.setHidden(true);
|
||||
|
||||
PnoNetwork network2 = new PnoNetwork();
|
||||
network.setSsid(new byte[] { 'a', 's', 'd', 'f'});
|
||||
network.setFrequenciesMhz(new int[] { 1, 2, 3 });
|
||||
network.setHidden(false);
|
||||
|
||||
assertThat(network2).isNotEqualTo(network);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 android.net.wifi.nl80211.cts;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.cts.WifiFeature;
|
||||
import android.net.wifi.nl80211.PnoNetwork;
|
||||
import android.net.wifi.nl80211.PnoSettings;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/** CTS tests for {@link PnoSettings}. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class PnoSettingsTest {
|
||||
|
||||
private static List<PnoNetwork> createTestNetworks() {
|
||||
PnoNetwork network1 = new PnoNetwork();
|
||||
network1.setSsid(new byte[] { 's', 's', 'i', 'd' });
|
||||
network1.setFrequenciesMhz(new int[] { 2412, 2417, 5035 });
|
||||
network1.setHidden(true);
|
||||
|
||||
PnoNetwork network2 = new PnoNetwork();
|
||||
network2.setSsid(new byte[] { 'a', 's', 'd', 'f' });
|
||||
network2.setFrequenciesMhz(new int[] { 2422, 2427, 5040 });
|
||||
network2.setHidden(false);
|
||||
|
||||
return Arrays.asList(network1, network2);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
// skip tests if Wifi is not supported
|
||||
assumeTrue(WifiFeature.isWifiSupported(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetters() {
|
||||
PnoSettings settings = new PnoSettings();
|
||||
settings.setIntervalMillis(1000);
|
||||
settings.setMin2gRssiDbm(-70);
|
||||
settings.setMin5gRssiDbm(-60);
|
||||
settings.setMin6gRssiDbm(-50);
|
||||
settings.setPnoNetworks(createTestNetworks());
|
||||
|
||||
assertThat(settings.getIntervalMillis()).isEqualTo(1000);
|
||||
assertThat(settings.getMin2gRssiDbm()).isEqualTo(-70);
|
||||
assertThat(settings.getMin5gRssiDbm()).isEqualTo(-60);
|
||||
assertThat(settings.getMin6gRssiDbm()).isEqualTo(-50);
|
||||
assertThat(settings.getPnoNetworks()).isEqualTo(createTestNetworks());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canSerializeAndDeserialize() {
|
||||
PnoSettings settings = new PnoSettings();
|
||||
settings.setIntervalMillis(1000);
|
||||
settings.setMin2gRssiDbm(-70);
|
||||
settings.setMin5gRssiDbm(-60);
|
||||
settings.setMin6gRssiDbm(-50);
|
||||
settings.setPnoNetworks(createTestNetworks());
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
settings.writeToParcel(parcel, 0);
|
||||
// Rewind the pointer to the head of the parcel.
|
||||
parcel.setDataPosition(0);
|
||||
PnoSettings settingsDeserialized = PnoSettings.CREATOR.createFromParcel(parcel);
|
||||
|
||||
assertThat(settingsDeserialized.getIntervalMillis()).isEqualTo(1000);
|
||||
assertThat(settingsDeserialized.getMin2gRssiDbm()).isEqualTo(-70);
|
||||
assertThat(settingsDeserialized.getMin5gRssiDbm()).isEqualTo(-60);
|
||||
assertThat(settingsDeserialized.getMin6gRssiDbm()).isEqualTo(-50);
|
||||
assertThat(settingsDeserialized.getPnoNetworks()).isEqualTo(createTestNetworks());
|
||||
assertThat(settingsDeserialized).isEqualTo(settings);
|
||||
assertThat(settingsDeserialized.hashCode()).isEqualTo(settings.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
PnoSettings settings = new PnoSettings();
|
||||
settings.setIntervalMillis(1000);
|
||||
settings.setMin2gRssiDbm(-70);
|
||||
settings.setMin5gRssiDbm(-60);
|
||||
settings.setMin6gRssiDbm(-50);
|
||||
settings.setPnoNetworks(createTestNetworks());
|
||||
|
||||
PnoSettings settings2 = new PnoSettings();
|
||||
settings.setIntervalMillis(2000);
|
||||
settings.setMin2gRssiDbm(-70);
|
||||
settings.setMin5gRssiDbm(-60);
|
||||
settings.setMin6gRssiDbm(-50);
|
||||
settings.setPnoNetworks(createTestNetworks());
|
||||
|
||||
assertThat(settings2).isNotEqualTo(settings);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 android.net.wifi.nl80211.cts;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.cts.WifiFeature;
|
||||
import android.net.wifi.nl80211.RadioChainInfo;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** CTS tests for {@link RadioChainInfo}. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RadioChainInfoTest {
|
||||
|
||||
private static final int TEST_CHAIN_ID = 1;
|
||||
private static final int TEST_CHAIN_ID2 = 2;
|
||||
private static final int TEST_LEVEL_DBM = -50;
|
||||
private static final int TEST_LEVEL_DBM2 = -80;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
// skip tests if Wifi is not supported
|
||||
assumeTrue(WifiFeature.isWifiSupported(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetters() {
|
||||
RadioChainInfo info = new RadioChainInfo(TEST_CHAIN_ID, TEST_LEVEL_DBM);
|
||||
assertThat(info.getChainId()).isEqualTo(TEST_CHAIN_ID);
|
||||
assertThat(info.getLevelDbm()).isEqualTo(TEST_LEVEL_DBM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canSerializeAndDeserialize() {
|
||||
RadioChainInfo info = new RadioChainInfo(TEST_CHAIN_ID, TEST_LEVEL_DBM);
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
info.writeToParcel(parcel, 0);
|
||||
// Rewind the pointer to the head of the parcel.
|
||||
parcel.setDataPosition(0);
|
||||
RadioChainInfo infoDeserialized = RadioChainInfo.CREATOR.createFromParcel(parcel);
|
||||
|
||||
assertThat(infoDeserialized.getChainId()).isEqualTo(TEST_CHAIN_ID);
|
||||
assertThat(infoDeserialized.getLevelDbm()).isEqualTo(TEST_LEVEL_DBM);
|
||||
assertThat(infoDeserialized).isEqualTo(info);
|
||||
assertThat(infoDeserialized.hashCode()).isEqualTo(info.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
RadioChainInfo info = new RadioChainInfo(TEST_CHAIN_ID, TEST_LEVEL_DBM);
|
||||
RadioChainInfo info2 = new RadioChainInfo(TEST_CHAIN_ID2, TEST_LEVEL_DBM2);
|
||||
|
||||
assertThat(info2).isNotEqualTo(info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 android.net.wifi.nl80211.cts;
|
||||
|
||||
import static android.net.wifi.nl80211.WifiNl80211Manager.OemSecurityType;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.cts.WifiFeature;
|
||||
import android.net.wifi.nl80211.WifiNl80211Manager;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** CTS tests for {@link WifiNl80211Manager}. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class WifiNl80211ManagerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
// skip tests if Wifi is not supported
|
||||
assumeTrue(WifiFeature.isWifiSupported(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOemSecurityTypeConstructor() {
|
||||
OemSecurityType securityType = new OemSecurityType(
|
||||
ScanResult.PROTOCOL_WPA,
|
||||
Arrays.asList(ScanResult.KEY_MGMT_PSK, ScanResult.KEY_MGMT_SAE),
|
||||
Arrays.asList(ScanResult.CIPHER_NONE, ScanResult.CIPHER_TKIP),
|
||||
ScanResult.CIPHER_CCMP);
|
||||
|
||||
assertThat(securityType.protocol).isEqualTo(ScanResult.PROTOCOL_WPA);
|
||||
assertThat(securityType.keyManagement)
|
||||
.isEqualTo(Arrays.asList(ScanResult.KEY_MGMT_PSK, ScanResult.KEY_MGMT_SAE));
|
||||
assertThat(securityType.pairwiseCipher)
|
||||
.isEqualTo(Arrays.asList(ScanResult.CIPHER_NONE, ScanResult.CIPHER_TKIP));
|
||||
assertThat(securityType.groupCipher).isEqualTo(ScanResult.CIPHER_CCMP);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user