summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ActivityManagerPerfTests/README.txt4
-rw-r--r--tests/CoreTests/android/Android.mk10
-rw-r--r--tests/CoreTests/android/core/JniLibTest.java59
-rw-r--r--tests/CoreTests/android/core/MiscRegressionTest.java37
-rw-r--r--tests/CoreTests/android/core/RequestAPITest.java13
-rw-r--r--tests/CoreTests/android/core/Sha1Test.java69
-rw-r--r--tests/UsbTests/res/raw/readme.txt35
-rw-r--r--tests/UsbTests/res/raw/usbdescriptors_headphones.binbin0 -> 180 bytes
-rw-r--r--tests/UsbTests/res/raw/usbdescriptors_headset.binbin0 -> 305 bytes
-rw-r--r--tests/UsbTests/res/raw/usbdescriptors_lineout.binbin0 -> 180 bytes
-rw-r--r--tests/UsbTests/res/raw/usbdescriptors_nothing.binbin0 -> 52 bytes
-rw-r--r--tests/UsbTests/src/com/android/server/usb/UsbDescriptorParserTests.java115
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java34
-rw-r--r--tests/net/java/android/net/NetworkCapabilitiesTest.java14
-rw-r--r--tests/net/java/com/android/server/IpSecServiceParameterizedTest.java1
15 files changed, 203 insertions, 188 deletions
diff --git a/tests/ActivityManagerPerfTests/README.txt b/tests/ActivityManagerPerfTests/README.txt
index 26862906a7f2..15602623e7d5 100644
--- a/tests/ActivityManagerPerfTests/README.txt
+++ b/tests/ActivityManagerPerfTests/README.txt
@@ -49,5 +49,7 @@ Adding tests
can be reported in an iteration
* If the target package should be running before your test logic starts, add startTargetPackage();
at the beginning of the iteration
+
* Reporting
- * Look at go/am-perf for how to add new tests to dashboards and receive notification on regression
+ * Look at internal documentation for how to add new tests to dashboards and receive notification
+ on regressions
diff --git a/tests/CoreTests/android/Android.mk b/tests/CoreTests/android/Android.mk
index 56d7918aa01e..04f6739a6ced 100644
--- a/tests/CoreTests/android/Android.mk
+++ b/tests/CoreTests/android/Android.mk
@@ -7,14 +7,14 @@ LOCAL_SRC_FILES := \
$(call all-subdir-java-files)
LOCAL_JAVA_LIBRARIES := \
- android.test.runner \
- bouncycastle \
- conscrypt \
+ android.test.runner.stubs \
org.apache.http.legacy \
- android.test.base \
+ android.test.base.stubs \
+
+LOCAL_SDK_VERSION := current
LOCAL_STATIC_JAVA_LIBRARIES := junit
-LOCAL_PACKAGE_NAME := CoreTests
+LOCAL_PACKAGE_NAME := LegacyCoreTests
include $(BUILD_PACKAGE)
diff --git a/tests/CoreTests/android/core/JniLibTest.java b/tests/CoreTests/android/core/JniLibTest.java
deleted file mode 100644
index d4760720f818..000000000000
--- a/tests/CoreTests/android/core/JniLibTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2006 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.core;
-
-import android.test.suitebuilder.annotation.Suppress;
-import android.util.Log;
-import junit.framework.TestCase;
-
-
-@Suppress
-public class JniLibTest extends TestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- /*
- * This causes the native shared library to be loaded when the
- * class is first used. The library is only loaded once, even if
- * multiple classes include this line.
- *
- * The library must be in java.library.path, which is derived from
- * LD_LIBRARY_PATH. The actual library name searched for will be
- * "libjni_lib_test.so" under Linux, but may be different on other
- * platforms.
- */
- try {
- System.loadLibrary("jni_lib_test");
- } catch (UnsatisfiedLinkError ule) {
- Log.e("JniLibTest", "WARNING: Could not load jni_lib_test natives");
- }
- }
-
- private static native int nativeStaticThing(float f);
- private native void nativeThing(int val);
-
- public void testNativeCall() {
- Log.i("JniLibTest", "JNI search path is "
- + System.getProperty("java.library.path"));
- Log.i("JniLibTest", "'jni_lib_test' becomes '"
- + System.mapLibraryName("jni_lib_test") + "'");
-
- int result = nativeStaticThing(1234.5f);
- nativeThing(result);
- }
-}
diff --git a/tests/CoreTests/android/core/MiscRegressionTest.java b/tests/CoreTests/android/core/MiscRegressionTest.java
deleted file mode 100644
index 32995b574e59..000000000000
--- a/tests/CoreTests/android/core/MiscRegressionTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2008 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.core;
-
-import android.test.suitebuilder.annotation.MediumTest;
-import java.util.logging.Logger;
-import junit.framework.TestCase;
-
-public class MiscRegressionTest extends TestCase {
-
- // Regression test for #951285: Suitable LogHandler should be chosen
- // depending on the environment.
- @MediumTest
- public void testAndroidLogHandler() throws Exception {
- Logger.global.severe("This has logging Level.SEVERE, should become ERROR");
- Logger.global.warning("This has logging Level.WARNING, should become WARN");
- Logger.global.info("This has logging Level.INFO, should become INFO");
- Logger.global.config("This has logging Level.CONFIG, should become DEBUG");
- Logger.global.fine("This has logging Level.FINE, should become VERBOSE");
- Logger.global.finer("This has logging Level.FINER, should become VERBOSE");
- Logger.global.finest("This has logging Level.FINEST, should become VERBOSE");
- }
-}
diff --git a/tests/CoreTests/android/core/RequestAPITest.java b/tests/CoreTests/android/core/RequestAPITest.java
index 94eb23e1b5dc..206f228c3804 100644
--- a/tests/CoreTests/android/core/RequestAPITest.java
+++ b/tests/CoreTests/android/core/RequestAPITest.java
@@ -22,7 +22,6 @@ import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.Suppress;
import android.util.Log;
import android.webkit.CookieSyncManager;
-import com.google.android.collect.Maps;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -87,7 +86,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants {
* header is attempted to be set
*/
Log.d(LOGTAG, "testRequestAddNullHeader start ");
- Map<String, String> headers = Maps.newHashMap();
+ Map<String, String> headers = new HashMap<>();
headers.put(null, null);
verifyFailure(headers);
Log.d(LOGTAG, "testRequestAddNullHeader - returning");
@@ -99,7 +98,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants {
* value is attempted to be set
*/
Log.d(LOGTAG, "testRequestAddNullValue start ");
- Map<String, String> headers = Maps.newHashMap();
+ Map<String, String> headers = new HashMap<>();
headers.put("TestHeader", null);
verifyFailure(headers);
Log.d(LOGTAG, "testRequestAddNullValue - returning");
@@ -111,7 +110,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants {
* header is attempted to be set
*/
Log.d(LOGTAG, "testRequestAddEmptyValue start ");
- Map<String, String> headers = Maps.newHashMap();
+ Map<String, String> headers = new HashMap<>();
headers.put("TestHeader", "");
verifyFailure(headers);
Log.d(LOGTAG, "testRequestAddEmptyValue - returning");
@@ -131,7 +130,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants {
* generating and exception
*/
Log.d(LOGTAG, "testRequestAddHeader start ");
- Map<String, String> headers = Maps.newHashMap();
+ Map<String, String> headers = new HashMap<>();
headers.put("TestHeader", "RequestAddHeader");
verifySuccess(headers);
Log.d(LOGTAG, "testRequestAddHeader - returning");
@@ -143,7 +142,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants {
* can be set without generating and exception
*/
Log.d(LOGTAG, "testRequestAddMultiHeader start ");
- Map<String, String> headers = Maps.newHashMap();
+ Map<String, String> headers = new HashMap<>();
headers.put("TestHeader", "RequestAddMultiHeader");
headers.put("TestHeader2", "RequestAddMultiHeader");
headers.put("TestHeader3", "RequestAddMultiHeader");
@@ -157,7 +156,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants {
* and values can be set without generating and exception
*/
Log.d(LOGTAG, "testRequestAddSameHeader start ");
- Map<String, String> headers = Maps.newHashMap();
+ Map<String, String> headers = new HashMap<>();
headers.put("TestHeader", "RequestAddSameHeader");
headers.put("TestHeader", "RequestAddSameHeader");
headers.put("TestHeader", "RequestAddSameHeader");
diff --git a/tests/CoreTests/android/core/Sha1Test.java b/tests/CoreTests/android/core/Sha1Test.java
deleted file mode 100644
index 8ed120542a44..000000000000
--- a/tests/CoreTests/android/core/Sha1Test.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2008 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.core;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import java.security.MessageDigest;
-import junit.framework.TestCase;
-
-/**
- * Tests SHA1 message digest algorithm.
- */
-public class Sha1Test extends TestCase {
- class TestData {
- private String input;
- private String result;
-
- public TestData(String i, String r) {
- input = i;
- result = r;
- }
- }
-
- TestData[] mTestData = new TestData[]{
- new TestData("abc", "a9993e364706816aba3e25717850c26c9cd0d89d"),
- new TestData("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "84983e441c3bd26ebaae4aa1f95129e5e54670f1")
- };
-
- @SmallTest
- public void testSha1() throws Exception {
- MessageDigest digest = MessageDigest.getInstance("SHA-1");
-
- int numTests = mTestData.length;
- for (int i = 0; i < numTests; i++) {
- digest.update(mTestData[i].input.getBytes());
- byte[] hash = digest.digest();
- String encodedHash = encodeHex(hash);
- assertEquals(encodedHash, mTestData[i].result);
- }
- }
-
- private static String encodeHex(byte[] bytes) {
- StringBuffer hex = new StringBuffer(bytes.length * 2);
-
- for (int i = 0; i < bytes.length; i++) {
- if (((int) bytes[i] & 0xff) < 0x10) {
- hex.append("0");
- }
- hex.append(Integer.toString((int) bytes[i] & 0xff, 16));
- }
-
- return hex.toString();
- }
-}
-
diff --git a/tests/UsbTests/res/raw/readme.txt b/tests/UsbTests/res/raw/readme.txt
new file mode 100644
index 000000000000..62b673c2f079
--- /dev/null
+++ b/tests/UsbTests/res/raw/readme.txt
@@ -0,0 +1,35 @@
+The usbdescriptors_ files contain raw USB descriptors from the Google
+USB-C to 3.5mm adapter, with different loads connected to the 3.5mm
+jack.
+
+usbdescriptors_nothing.bin:
+ - The descriptors when the jack is disconnected.
+
+usbdescriptors_headphones.bin:
+ - The descriptors when the jack is connected to 32-ohm headphones,
+ no microphone.
+ The relevant output terminal is:
+ bDescriptorSubtype 3 (OUTPUT_TERMINAL)
+ bTerminalID 15
+ wTerminalType 0x0302 Headphones
+
+usbdescriptors_lineout.bin:
+ - The descriptors when the jack is connected to a PC line-in jack.
+ The relevant output terminal is:
+ bDescriptorSubtype 3 (OUTPUT_TERMINAL)
+ bTerminalID 15
+ wTerminalType 0x0603 Line Connector
+
+usbdescriptors_headset.bin:
+ - The descriptors when a headset with microphone and low-impedance
+ headphones are connected.
+ The relevant input terminal is:
+ bDescriptorSubtype 2 (INPUT_TERMINAL)
+ bTerminalID 1
+ wTerminalType 0x0201 Microphone
+ The relevant output terminal is:
+ bDescriptorSubtype 3 (OUTPUT_TERMINAL)
+ bTerminalID 15
+ wTerminalType 0x0302 Headphones
+
+
diff --git a/tests/UsbTests/res/raw/usbdescriptors_headphones.bin b/tests/UsbTests/res/raw/usbdescriptors_headphones.bin
new file mode 100644
index 000000000000..e8f2932d7b5b
--- /dev/null
+++ b/tests/UsbTests/res/raw/usbdescriptors_headphones.bin
Binary files differ
diff --git a/tests/UsbTests/res/raw/usbdescriptors_headset.bin b/tests/UsbTests/res/raw/usbdescriptors_headset.bin
new file mode 100644
index 000000000000..30eef2aae787
--- /dev/null
+++ b/tests/UsbTests/res/raw/usbdescriptors_headset.bin
Binary files differ
diff --git a/tests/UsbTests/res/raw/usbdescriptors_lineout.bin b/tests/UsbTests/res/raw/usbdescriptors_lineout.bin
new file mode 100644
index 000000000000..d540d33d15f3
--- /dev/null
+++ b/tests/UsbTests/res/raw/usbdescriptors_lineout.bin
Binary files differ
diff --git a/tests/UsbTests/res/raw/usbdescriptors_nothing.bin b/tests/UsbTests/res/raw/usbdescriptors_nothing.bin
new file mode 100644
index 000000000000..c318abf93afb
--- /dev/null
+++ b/tests/UsbTests/res/raw/usbdescriptors_nothing.bin
Binary files differ
diff --git a/tests/UsbTests/src/com/android/server/usb/UsbDescriptorParserTests.java b/tests/UsbTests/src/com/android/server/usb/UsbDescriptorParserTests.java
new file mode 100644
index 000000000000..f32395226f4a
--- /dev/null
+++ b/tests/UsbTests/src/com/android/server/usb/UsbDescriptorParserTests.java
@@ -0,0 +1,115 @@
+/*
+ * 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.server.usb;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.Resources.NotFoundException;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+
+import com.android.server.usb.descriptors.UsbDescriptorParser;
+import com.google.common.io.ByteStreams;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.lang.Exception;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for {@link com.android.server.usb.descriptors.UsbDescriptorParser}
+ */
+@RunWith(AndroidJUnit4.class)
+public class UsbDescriptorParserTests {
+
+ public UsbDescriptorParser loadParser(int resource) {
+ Context c = InstrumentationRegistry.getContext();
+ Resources res = c.getResources();
+ InputStream is = null;
+ try {
+ is = res.openRawResource(resource);
+ } catch (NotFoundException e) {
+ fail("Failed to load resource.");
+ }
+
+ byte[] descriptors = null;
+ try {
+ descriptors = ByteStreams.toByteArray(is);
+ } catch (IOException e) {
+ fail("Failed to convert descriptor strema to bytearray.");
+ }
+
+ // Testing same codepath as UsbHostManager.java:usbDeviceAdded
+ UsbDescriptorParser parser = new UsbDescriptorParser("test-usb-addr");
+ if (!parser.parseDescriptors(descriptors)) {
+ fail("failed to parse descriptors.");
+ }
+ return parser;
+ }
+
+ // A Headset has a microphone and a speaker and is a headset.
+ @Test
+ @SmallTest
+ public void testHeadsetDescriptorParser() {
+ UsbDescriptorParser parser = loadParser(R.raw.usbdescriptors_headset);
+ assertTrue(parser.hasInput());
+ assertTrue(parser.hasOutput());
+ assertTrue(parser.isInputHeadset());
+ assertTrue(parser.isOutputHeadset());
+ }
+
+ // Headphones have no microphones but are considered a headset.
+ @Test
+ @SmallTest
+ public void testHeadphoneDescriptorParser() {
+ UsbDescriptorParser parser = loadParser(R.raw.usbdescriptors_headphones);
+ assertFalse(parser.hasInput());
+ assertTrue(parser.hasOutput());
+ assertFalse(parser.isInputHeadset());
+ assertTrue(parser.isOutputHeadset());
+ }
+
+ // Line out has no microphones and aren't considered a headset.
+ @Test
+ @SmallTest
+ public void testLineoutDescriptorParser() {
+ UsbDescriptorParser parser = loadParser(R.raw.usbdescriptors_lineout);
+ assertFalse(parser.hasInput());
+ assertTrue(parser.hasOutput());
+ assertFalse(parser.isInputHeadset());
+ assertFalse(parser.isOutputHeadset());
+ }
+
+ // An HID-only device shouldn't be considered anything at all.
+ @Test
+ @SmallTest
+ public void testNothingDescriptorParser() {
+ UsbDescriptorParser parser = loadParser(R.raw.usbdescriptors_nothing);
+ assertFalse(parser.hasInput());
+ assertFalse(parser.hasOutput());
+ assertFalse(parser.isInputHeadset());
+ assertFalse(parser.isOutputHeadset());
+ }
+
+}
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
index 040173792406..db4898492ac5 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
@@ -57,7 +57,9 @@ public class MainInteractionSession extends VoiceInteractionSession
Button mCompleteButton;
Button mAbortButton;
+ Bundle mAssistData;
AssistStructure mAssistStructure;
+ AssistContent mAssistContent;
static final int STATE_IDLE = 0;
static final int STATE_LAUNCHING = 1;
@@ -169,19 +171,15 @@ public class MainInteractionSession extends VoiceInteractionSession
public void onHandleAssist(Bundle assistBundle) {
}
- @Override
- public void onHandleAssist(Bundle data, AssistStructure structure, AssistContent content) {
- mAssistStructure = structure;
- if (mAssistVisualizer != null) {
- if (mAssistStructure != null) {
- mAssistVisualizer.setAssistStructure(mAssistStructure);
- } else {
- mAssistVisualizer.clearAssistData();
- }
- }
+ private void logAssistContentAndData(AssistContent content, Bundle data) {
if (content != null) {
Log.i(TAG, "Assist intent: " + content.getIntent());
+ Log.i(TAG, "Assist intent from app: " + content.isAppProvidedIntent());
Log.i(TAG, "Assist clipdata: " + content.getClipData());
+ Log.i(TAG, "Assist structured data: " + content.getStructuredData());
+ Log.i(TAG, "Assist web uri: " + content.getWebUri());
+ Log.i(TAG, "Assist web uri from app: " + content.isAppProvidedWebUri());
+ Log.i(TAG, "Assist extras: " + content.getExtras());
}
if (data != null) {
Uri referrer = data.getParcelable(Intent.EXTRA_REFERRER);
@@ -192,6 +190,21 @@ public class MainInteractionSession extends VoiceInteractionSession
}
@Override
+ public void onHandleAssist(Bundle data, AssistStructure structure, AssistContent content) {
+ mAssistData = data;
+ mAssistStructure = structure;
+ mAssistContent = content;
+ if (mAssistVisualizer != null) {
+ if (mAssistStructure != null) {
+ mAssistVisualizer.setAssistStructure(mAssistStructure);
+ } else {
+ mAssistVisualizer.clearAssistData();
+ }
+ }
+ logAssistContentAndData(content, data);
+ }
+
+ @Override
public void onHandleAssistSecondary(final Bundle data, final AssistStructure structure,
final AssistContent content, int index, int count) {
Log.i(TAG, "Got secondary activity assist data " + index + " of " + count);
@@ -246,6 +259,7 @@ public class MainInteractionSession extends VoiceInteractionSession
public void onClick(View v) {
if (v == mTreeButton) {
if (mAssistVisualizer != null) {
+ logAssistContentAndData(mAssistContent, mAssistData);
mAssistVisualizer.logTree();
}
} else if (v == mTextButton) {
diff --git a/tests/net/java/android/net/NetworkCapabilitiesTest.java b/tests/net/java/android/net/NetworkCapabilitiesTest.java
index 2e1519b8717b..4227da6c4780 100644
--- a/tests/net/java/android/net/NetworkCapabilitiesTest.java
+++ b/tests/net/java/android/net/NetworkCapabilitiesTest.java
@@ -22,6 +22,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_EIMS;
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED;
+import static android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PAID;
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
import static android.net.NetworkCapabilities.RESTRICTED_CAPABILITIES;
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
@@ -252,6 +253,19 @@ public class NetworkCapabilitiesTest {
assertEqualsThroughMarshalling(netCap);
}
+ @Test
+ public void testOemPaid() {
+ NetworkCapabilities nc = new NetworkCapabilities();
+ nc.maybeMarkCapabilitiesRestricted();
+ assertFalse(nc.hasCapability(NET_CAPABILITY_OEM_PAID));
+ assertTrue(nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
+
+ nc.addCapability(NET_CAPABILITY_OEM_PAID);
+ nc.maybeMarkCapabilitiesRestricted();
+ assertTrue(nc.hasCapability(NET_CAPABILITY_OEM_PAID));
+ assertFalse(nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
+ }
+
private void assertEqualsThroughMarshalling(NetworkCapabilities netCap) {
Parcel p = Parcel.obtain();
netCap.writeToParcel(p, /* flags */ 0);
diff --git a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
index 66e0955b04c3..3e1ff6dd5f32 100644
--- a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
+++ b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
@@ -281,6 +281,7 @@ public class IpSecServiceParameterizedTest {
anyInt());
}
+ @Test
public void testCreateTwoTransformsWithSameSpis() throws Exception {
IpSecConfig ipSecConfig = new IpSecConfig();
addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);