Merge changes I915e0c4e,Iae187c0b
* changes: Add utility methods for creation of NetInfo, NetCaps, and LinkProps Add VcnGatewayConnection state skeleton, signals and fields
This commit is contained in:
@@ -20,6 +20,7 @@ android_test {
|
||||
"services.core",
|
||||
],
|
||||
libs: [
|
||||
"android.net.ipsec.ike.stubs.module_lib",
|
||||
"android.test.runner",
|
||||
"android.test.base",
|
||||
"android.test.mock",
|
||||
|
||||
@@ -33,12 +33,13 @@ import java.util.concurrent.TimeUnit;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class VcnGatewayConnectionConfigTest {
|
||||
private static final int[] EXPOSED_CAPS =
|
||||
// Public for use in VcnGatewayConnectionTest
|
||||
public static final int[] EXPOSED_CAPS =
|
||||
new int[] {
|
||||
NetworkCapabilities.NET_CAPABILITY_INTERNET, NetworkCapabilities.NET_CAPABILITY_MMS
|
||||
};
|
||||
private static final int[] UNDERLYING_CAPS = new int[] {NetworkCapabilities.NET_CAPABILITY_DUN};
|
||||
private static final long[] RETRY_INTERVALS_MS =
|
||||
public static final int[] UNDERLYING_CAPS = new int[] {NetworkCapabilities.NET_CAPABILITY_DUN};
|
||||
public static final long[] RETRY_INTERVALS_MS =
|
||||
new long[] {
|
||||
TimeUnit.SECONDS.toMillis(5),
|
||||
TimeUnit.SECONDS.toMillis(30),
|
||||
@@ -47,10 +48,10 @@ public class VcnGatewayConnectionConfigTest {
|
||||
TimeUnit.MINUTES.toMillis(15),
|
||||
TimeUnit.MINUTES.toMillis(30)
|
||||
};
|
||||
private static final int MAX_MTU = 1360;
|
||||
public static final int MAX_MTU = 1360;
|
||||
|
||||
// Package protected for use in VcnConfigTest
|
||||
static VcnGatewayConnectionConfig buildTestConfig() {
|
||||
// Public for use in VcnGatewayConnectionTest
|
||||
public static VcnGatewayConnectionConfig buildTestConfig() {
|
||||
final VcnGatewayConnectionConfig.Builder builder =
|
||||
new VcnGatewayConnectionConfig.Builder()
|
||||
.setRetryInterval(RETRY_INTERVALS_MS)
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 com.android.server.vcn;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.vcn.VcnGatewayConnectionConfigTest;
|
||||
import android.os.ParcelUuid;
|
||||
import android.os.test.TestLooper;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/** Tests for TelephonySubscriptionTracker */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class VcnGatewayConnectionTest {
|
||||
private static final ParcelUuid TEST_PARCEL_UUID = new ParcelUuid(UUID.randomUUID());
|
||||
private static final int TEST_SIM_SLOT_INDEX = 1;
|
||||
private static final int TEST_SUBSCRIPTION_ID_1 = 2;
|
||||
private static final SubscriptionInfo TEST_SUBINFO_1 = mock(SubscriptionInfo.class);
|
||||
private static final int TEST_SUBSCRIPTION_ID_2 = 3;
|
||||
private static final SubscriptionInfo TEST_SUBINFO_2 = mock(SubscriptionInfo.class);
|
||||
private static final Map<Integer, ParcelUuid> TEST_SUBID_TO_GROUP_MAP;
|
||||
|
||||
static {
|
||||
final Map<Integer, ParcelUuid> subIdToGroupMap = new HashMap<>();
|
||||
subIdToGroupMap.put(TEST_SUBSCRIPTION_ID_1, TEST_PARCEL_UUID);
|
||||
subIdToGroupMap.put(TEST_SUBSCRIPTION_ID_2, TEST_PARCEL_UUID);
|
||||
TEST_SUBID_TO_GROUP_MAP = Collections.unmodifiableMap(subIdToGroupMap);
|
||||
}
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
@NonNull private final TestLooper mTestLooper;
|
||||
@NonNull private final VcnNetworkProvider mVcnNetworkProvider;
|
||||
@NonNull private final VcnGatewayConnection.Dependencies mDeps;
|
||||
|
||||
public VcnGatewayConnectionTest() {
|
||||
mContext = mock(Context.class);
|
||||
mTestLooper = new TestLooper();
|
||||
mVcnNetworkProvider = mock(VcnNetworkProvider.class);
|
||||
mDeps = mock(VcnGatewayConnection.Dependencies.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildNetworkCapabilities() throws Exception {
|
||||
final NetworkCapabilities caps =
|
||||
VcnGatewayConnection.buildNetworkCapabilities(
|
||||
VcnGatewayConnectionConfigTest.buildTestConfig());
|
||||
|
||||
for (int exposedCapability : VcnGatewayConnectionConfigTest.EXPOSED_CAPS) {
|
||||
assertTrue(caps.hasCapability(exposedCapability));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user