Split CtsSignatureTestCases into two CTS packages
CtsSignatureTestCases contained two tests, one for checking the API
signature and one for verifying intents provided by the various
packages to ensure they do not infringe on the android.intent.action
namespace. This splits each test into its own package,
CtsApiSignatureTestCases and CtsIntentSignatureTestCases respectively.
This is in preparation for expanding the CtsApiSignatureTestCases to
test a number of different package configurations, e.g. packages with
and without <use-library android:name="android.test.runner"/>, packages
targeted at an earlier release or the current release, etc.
Tested using:
m -j32 CtsApiSignatureTestCases && \
cts-tradefed run cts -a arm64-v8a -m CtsApiSignatureTestCases
And:
m -j32 CtsIntentSignatureTestCases && \
cts-tradefed run cts -a arm64-v8a -m CtsIntentSignatureTestCases
Bug: 35192974
Bug: 30188076
Test: see above
Change-Id: I7504f6ddd6e2e73ec111d5b527e85c2a9c74b34d
diff --git a/tests/signature/Android.mk b/tests/signature/Android.mk
index b78fb95..b7b852b 100644
--- a/tests/signature/Android.mk
+++ b/tests/signature/Android.mk
@@ -13,6 +13,10 @@
# limitations under the License.
LOCAL_PATH:= $(call my-dir)
+
+# cts-signature-common java library
+# =================================
+
include $(CLEAR_VARS)
# don't include this package in any target
@@ -20,19 +24,11 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_PACKAGE_NAME := CtsSignatureTestCases
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts general-tests
+LOCAL_MODULE := cts-signature-common
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner \
- compatibility-device-util \
- android-support-test \
- legacy-android-test
-
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_STATIC_JAVA_LIBRARY)
# signature-hostside java library (for testing)
# ============================================================
diff --git a/tests/signature/api-check/Android.mk b/tests/signature/api-check/Android.mk
new file mode 100644
index 0000000..4c4f537
--- /dev/null
+++ b/tests/signature/api-check/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsApiSignatureTestCases
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts general-tests
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ cts-signature-common \
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/signature/AndroidManifest.xml b/tests/signature/api-check/AndroidManifest.xml
similarity index 85%
rename from tests/signature/AndroidManifest.xml
rename to tests/signature/api-check/AndroidManifest.xml
index 41a4233..88930eb 100644
--- a/tests/signature/AndroidManifest.xml
+++ b/tests/signature/api-check/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2017 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.
@@ -16,7 +16,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.signature.cts">
+ package="android.signature.cts.api">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
@@ -24,8 +24,8 @@
<uses-library android:name="android.test.runner"/>
</application>
- <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.signature.cts"
+ <instrumentation android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="android.signature.cts.api"
android:label="API Signature Test"/>
</manifest>
diff --git a/tests/signature/api-check/AndroidTest.xml b/tests/signature/api-check/AndroidTest.xml
new file mode 100644
index 0000000..7c75a7f
--- /dev/null
+++ b/tests/signature/api-check/AndroidTest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<configuration description="Config for CTS API Signature test cases">
+ <option name="config-descriptor:metadata" key="component" value="systems" />
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
+ <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="current.api->/data/local/tmp/signature-test/current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsApiSignatureTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.signature.cts.api" />
+ <option name="runner" value="android.test.InstrumentationTestRunner" />
+ <option name="runtime-hint" value="30s" />
+ </test>
+</configuration>
diff --git a/tests/signature/src/android/signature/cts/SignatureTest.java b/tests/signature/api-check/src/android/signature/cts/api/SignatureTest.java
similarity index 88%
rename from tests/signature/src/android/signature/cts/SignatureTest.java
rename to tests/signature/api-check/src/android/signature/cts/api/SignatureTest.java
index af82a46..414cdc8 100644
--- a/tests/signature/src/android/signature/cts/SignatureTest.java
+++ b/tests/signature/api-check/src/android/signature/cts/api/SignatureTest.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package android.signature.cts;
+package android.signature.cts.api;
import static android.signature.cts.CurrentApi.CURRENT_API_FILE;
-import static android.signature.cts.CurrentApi.SYSTEM_CURRENT_API_FILE;
import static android.signature.cts.CurrentApi.TAG_ROOT;
import static android.signature.cts.CurrentApi.TAG_PACKAGE;
import static android.signature.cts.CurrentApi.TAG_CLASS;
@@ -29,27 +28,16 @@
import static android.signature.cts.CurrentApi.TAG_EXCEPTION;
import static android.signature.cts.CurrentApi.TAG_FIELD;
-import static android.signature.cts.CurrentApi.MODIFIER_ABSTRACT;
-import static android.signature.cts.CurrentApi.MODIFIER_FINAL;
-import static android.signature.cts.CurrentApi.MODIFIER_NATIVE;
-import static android.signature.cts.CurrentApi.MODIFIER_PRIVATE;
-import static android.signature.cts.CurrentApi.MODIFIER_PROTECTED;
-import static android.signature.cts.CurrentApi.MODIFIER_PUBLIC;
-import static android.signature.cts.CurrentApi.MODIFIER_STATIC;
-import static android.signature.cts.CurrentApi.MODIFIER_SYNCHRONIZED;
-import static android.signature.cts.CurrentApi.MODIFIER_TRANSIENT;
-import static android.signature.cts.CurrentApi.MODIFIER_VOLATILE;
-import static android.signature.cts.CurrentApi.MODIFIER_VISIBILITY;
-
import static android.signature.cts.CurrentApi.ATTRIBUTE_NAME;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_EXTENDS;
import static android.signature.cts.CurrentApi.ATTRIBUTE_TYPE;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_RETURN;
-import android.content.res.Resources;
+import android.signature.cts.CurrentApi;
+import android.signature.cts.FailureType;
+import android.signature.cts.JDiffClassDescription;
import android.signature.cts.JDiffClassDescription.JDiffConstructor;
import android.signature.cts.JDiffClassDescription.JDiffField;
import android.signature.cts.JDiffClassDescription.JDiffMethod;
+import android.signature.cts.ResultObserver;
import android.test.AndroidTestCase;
import android.util.Log;
@@ -60,12 +48,8 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
-import java.util.Scanner;
/**
* Performs the signature check via a JUnit test.
diff --git a/tests/signature/intent-check/Android.mk b/tests/signature/intent-check/Android.mk
new file mode 100644
index 0000000..9d04980
--- /dev/null
+++ b/tests/signature/intent-check/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2017 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.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsIntentSignatureTestCases
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts general-tests
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ android-support-test \
+ cts-signature-common \
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/signature/AndroidManifest.xml b/tests/signature/intent-check/AndroidManifest.xml
similarity index 85%
copy from tests/signature/AndroidManifest.xml
copy to tests/signature/intent-check/AndroidManifest.xml
index 41a4233..a444350 100644
--- a/tests/signature/AndroidManifest.xml
+++ b/tests/signature/intent-check/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2017 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.
@@ -16,7 +16,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.signature.cts">
+ package="android.signature.cts.intent">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
@@ -25,7 +25,7 @@
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.signature.cts"
- android:label="API Signature Test"/>
+ android:targetPackage="android.signature.cts.intent"
+ android:label="Intent Signature Test"/>
</manifest>
diff --git a/tests/signature/AndroidTest.xml b/tests/signature/intent-check/AndroidTest.xml
similarity index 81%
rename from tests/signature/AndroidTest.xml
rename to tests/signature/intent-check/AndroidTest.xml
index 0ca8ce2..e53f5d8 100644
--- a/tests/signature/AndroidTest.xml
+++ b/tests/signature/intent-check/AndroidTest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
+<!-- Copyright (C) 2017 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.
@@ -13,11 +13,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="Config for CTS Signature test cases">
+<configuration description="Config for CTS Intent Signature test cases">
<option name="config-descriptor:metadata" key="component" value="systems" />
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher">
<option name="target" value="device" />
- <option name="config-filename" value="CtsSignatureTestCases" />
+ <option name="config-filename" value="CtsIntentSignatureTestCases" />
<option name="version" value="1.0" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
@@ -38,10 +38,10 @@
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="CtsSignatureTestCases.apk" />
+ <option name="test-file-name" value="CtsIntentSignatureTestCases.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
- <option name="package" value="android.signature.cts" />
- <option name="runtime-hint" value="7m11s" />
+ <option name="package" value="android.signature.cts.intent" />
+ <option name="runtime-hint" value="10s" />
</test>
</configuration>
diff --git a/tests/signature/DynamicConfig.xml b/tests/signature/intent-check/DynamicConfig.xml
similarity index 100%
rename from tests/signature/DynamicConfig.xml
rename to tests/signature/intent-check/DynamicConfig.xml
diff --git a/tests/signature/src/android/signature/cts/IntentTest.java b/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
similarity index 88%
rename from tests/signature/src/android/signature/cts/IntentTest.java
rename to tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
index 3d674ab..8d23025 100644
--- a/tests/signature/src/android/signature/cts/IntentTest.java
+++ b/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.signature.cts;
+package android.signature.cts.intent;
import static android.signature.cts.CurrentApi.CURRENT_API_FILE;
import static android.signature.cts.CurrentApi.SYSTEM_CURRENT_API_FILE;
@@ -28,29 +28,12 @@
import static android.signature.cts.CurrentApi.TAG_EXCEPTION;
import static android.signature.cts.CurrentApi.TAG_FIELD;
-import static android.signature.cts.CurrentApi.MODIFIER_ABSTRACT;
-import static android.signature.cts.CurrentApi.MODIFIER_FINAL;
-import static android.signature.cts.CurrentApi.MODIFIER_NATIVE;
-import static android.signature.cts.CurrentApi.MODIFIER_PRIVATE;
-import static android.signature.cts.CurrentApi.MODIFIER_PROTECTED;
-import static android.signature.cts.CurrentApi.MODIFIER_PUBLIC;
-import static android.signature.cts.CurrentApi.MODIFIER_STATIC;
-import static android.signature.cts.CurrentApi.MODIFIER_SYNCHRONIZED;
-import static android.signature.cts.CurrentApi.MODIFIER_TRANSIENT;
-import static android.signature.cts.CurrentApi.MODIFIER_VOLATILE;
-import static android.signature.cts.CurrentApi.MODIFIER_VISIBILITY;
-
import static android.signature.cts.CurrentApi.ATTRIBUTE_NAME;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_EXTENDS;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_TYPE;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_RETURN;
-import android.content.Context;
import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.signature.cts.JDiffClassDescription.JDiffConstructor;
+import android.signature.cts.CurrentApi;
+import android.signature.cts.JDiffClassDescription;
import android.signature.cts.JDiffClassDescription.JDiffField;
import android.signature.cts.JDiffClassDescription.JDiffMethod;
import android.support.test.InstrumentationRegistry;
@@ -71,9 +54,7 @@
import org.junit.Assert;
import org.junit.runner.RunWith;
-import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.xmlpull.v1.XmlPullParser;
@@ -92,7 +73,7 @@
new File("/data/local/tmp/signature-test-packages");
private static final String ANDROID_INTENT_PREFIX = "android.intent.action";
private static final String ACTION_LINE_PREFIX = " Action: ";
- private static final String MODULE_NAME = "CtsSignatureTestCases";
+ private static final String MODULE_NAME = "CtsIntentSignatureTestCases";
private PackageManager mPackageManager;
private Set<String> intentWhitelist;
diff --git a/tests/signature/src/android/signature/cts/CurrentApi.java b/tests/signature/src/android/signature/cts/CurrentApi.java
index 4c48f9f..3335115 100644
--- a/tests/signature/src/android/signature/cts/CurrentApi.java
+++ b/tests/signature/src/android/signature/cts/CurrentApi.java
@@ -28,25 +28,25 @@
/**
* Helper methods and constants used for parsing the current api file.
*/
-class CurrentApi {
+public class CurrentApi {
private CurrentApi() {}
- static final String CURRENT_API_FILE =
+ public static final String CURRENT_API_FILE =
"/data/local/tmp/signature-test/current.api";
- static final String SYSTEM_CURRENT_API_FILE =
+ public static final String SYSTEM_CURRENT_API_FILE =
"/data/local/tmp/signature-test/system-current.api";
- static final String TAG_ROOT = "api";
- static final String TAG_PACKAGE = "package";
- static final String TAG_CLASS = "class";
- static final String TAG_INTERFACE = "interface";
- static final String TAG_IMPLEMENTS = "implements";
- static final String TAG_CONSTRUCTOR = "constructor";
- static final String TAG_METHOD = "method";
- static final String TAG_PARAM = "parameter";
- static final String TAG_EXCEPTION = "exception";
- static final String TAG_FIELD = "field";
+ public static final String TAG_ROOT = "api";
+ public static final String TAG_PACKAGE = "package";
+ public static final String TAG_CLASS = "class";
+ public static final String TAG_INTERFACE = "interface";
+ public static final String TAG_IMPLEMENTS = "implements";
+ public static final String TAG_CONSTRUCTOR = "constructor";
+ public static final String TAG_METHOD = "method";
+ public static final String TAG_PARAM = "parameter";
+ public static final String TAG_EXCEPTION = "exception";
+ public static final String TAG_FIELD = "field";
static final String MODIFIER_ABSTRACT = "abstract";
static final String MODIFIER_FINAL = "final";
@@ -60,10 +60,10 @@
static final String MODIFIER_VOLATILE = "volatile";
static final String MODIFIER_VISIBILITY = "visibility";
- static final String ATTRIBUTE_NAME = "name";
+ public static final String ATTRIBUTE_NAME = "name";
static final String ATTRIBUTE_VALUE = "value";
static final String ATTRIBUTE_EXTENDS = "extends";
- static final String ATTRIBUTE_TYPE = "type";
+ public static final String ATTRIBUTE_TYPE = "type";
static final String ATTRIBUTE_RETURN = "return";
/**
@@ -73,7 +73,7 @@
* @param parser The XmlPullParser which carries the xml information.
* @return the new field
*/
- static JDiffField loadFieldInfo(String className, XmlPullParser parser) {
+ public static JDiffField loadFieldInfo(String className, XmlPullParser parser) {
String fieldName = parser.getAttributeValue(null, ATTRIBUTE_NAME);
String fieldType = parser.getAttributeValue(null, ATTRIBUTE_TYPE);
int modifier = jdiffModifierToReflectionFormat(className, parser);
@@ -88,7 +88,7 @@
* @param parser The XmlPullParser which carries the xml information.
* @return the newly loaded method.
*/
- static JDiffMethod loadMethodInfo(String className, XmlPullParser parser) {
+ public static JDiffMethod loadMethodInfo(String className, XmlPullParser parser) {
String methodName = parser.getAttributeValue(null, ATTRIBUTE_NAME);
String returnType = parser.getAttributeValue(null, ATTRIBUTE_RETURN);
int modifier = jdiffModifierToReflectionFormat(className, parser);
@@ -102,8 +102,8 @@
* @param currentClass the current class being loaded.
* @return the new constructor
*/
- static JDiffConstructor loadConstructorInfo(
- XmlPullParser parser, JDiffClassDescription currentClass) {
+ public static JDiffConstructor loadConstructorInfo(
+ XmlPullParser parser, JDiffClassDescription currentClass) {
String name = currentClass.getClassName();
int modifier = jdiffModifierToReflectionFormat(name, parser);
return new JDiffConstructor(name, modifier);
@@ -117,9 +117,9 @@
* @param pkg the name of the java package this class can be found in.
* @return the new class description.
*/
- static JDiffClassDescription loadClassInfo(
- XmlPullParser parser, boolean isInterface, String pkg,
- ResultObserver resultObserver) {
+ public static JDiffClassDescription loadClassInfo(
+ XmlPullParser parser, boolean isInterface, String pkg,
+ ResultObserver resultObserver) {
String className = parser.getAttributeValue(null, ATTRIBUTE_NAME);
JDiffClassDescription currentClass;
if (resultObserver != null) {