Switch CtsIntentSignatureTestCases to Android.bp
Bug: 131312181
Test: atest -p cts/tests/signature
Change-Id: I065b8946754bac42208567c018fdace639e5f84d
diff --git a/tests/signature/api/Android.bp b/tests/signature/api/Android.bp
index ea39759..8c3e12a 100644
--- a/tests/signature/api/Android.bp
+++ b/tests/signature/api/Android.bp
@@ -14,6 +14,7 @@
default_visibility = [
"//cts/tests/signature/api-check:__subpackages__",
+ "//cts/tests/signature/intent-check",
]
genrule {
diff --git a/tests/signature/api/Android.mk b/tests/signature/api/Android.mk
index 9863798..96afc10 100644
--- a/tests/signature/api/Android.mk
+++ b/tests/signature/api/Android.mk
@@ -30,11 +30,6 @@
$$(copy-file-to-target)
endef
-# Kept for CtsIntentSignatureTestCases
-$(eval $(call copy_api_txt_file,current.txt,frameworks/base/api/current.txt))
-$(eval $(call copy_api_txt_file,system-current.txt,frameworks/base/api/system-current.txt))
-$(eval $(call copy_api_txt_file,system-removed.txt,frameworks/base/api/system-removed.txt))
-
$(foreach ver,$(PLATFORM_SYSTEMSDK_VERSIONS),\
$(if $(call math_is_number,$(ver)),\
$(eval $(call copy_api_txt_file,system-$(ver).txt,prebuilts/sdk/$(ver)/system/api/android.txt))\
diff --git a/tests/signature/intent-check/Android.bp b/tests/signature/intent-check/Android.bp
new file mode 100644
index 0000000..299e2b7
--- /dev/null
+++ b/tests/signature/intent-check/Android.bp
@@ -0,0 +1,42 @@
+// 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.
+
+android_test {
+ name: "CtsIntentSignatureTestCases",
+ defaults: ["cts_defaults"],
+
+ srcs: ["src/**/*.java"],
+ java_resources: [
+ ":cts-current-txt",
+ ":cts-system-current-txt",
+ ":cts-system-removed-txt",
+ ],
+
+ // Tag this module as a cts test artifact
+ test_suites: [
+ "cts",
+ "vts",
+ "general-tests",
+ ],
+
+ sdk_version: "test_current",
+
+ static_libs: [
+ "compatibility-device-util-axt",
+ "androidx.test.rules",
+ "cts-signature-common",
+ ],
+
+ host_required: ["cts-dynamic-config"],
+}
diff --git a/tests/signature/intent-check/Android.mk b/tests/signature/intent-check/Android.mk
deleted file mode 100644
index 98e19ff..0000000
--- a/tests/signature/intent-check/Android.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-# 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 vts general-tests
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- compatibility-device-util-axt \
- androidx.test.rules \
- cts-signature-common \
-
-LOCAL_HOST_REQUIRED_MODULES := cts-dynamic-config
-
-LOCAL_REQUIRED_MODULES := \
- cts-current-txt \
- cts-system-current-txt \
- cts-system-removed-txt
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/signature/intent-check/AndroidTest.xml b/tests/signature/intent-check/AndroidTest.xml
index ff4250a..40968ec 100644
--- a/tests/signature/intent-check/AndroidTest.xml
+++ b/tests/signature/intent-check/AndroidTest.xml
@@ -34,15 +34,6 @@
<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.txt->/data/local/tmp/signature-test/current.txt" />
- </target_preparer>
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="push" value="system-current.txt->/data/local/tmp/signature-test/system-current.txt" />
- </target_preparer>
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="push" value="system-removed.txt->/data/local/tmp/signature-test/system-removed.txt" />
- </target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsIntentSignatureTestCases.apk" />
diff --git a/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java b/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
index 6ee8434..0195dc4 100644
--- a/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
+++ b/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
@@ -18,7 +18,6 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.signature.cts.ApiDocumentParser;
-import android.signature.cts.CurrentApi;
import android.signature.cts.JDiffClassDescription.JDiffField;
import android.signature.cts.VirtualPath;
import android.util.Log;
@@ -28,6 +27,7 @@
import com.android.compatibility.common.util.DynamicConfigDeviceSide;
+import java.io.IOException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -48,18 +48,15 @@
@RunWith(AndroidJUnit4.class)
public class IntentTest {
- private static final String CURRENT_API_FILE =
- CurrentApi.API_FILE_DIRECTORY + "/current.txt";
+ private static final String CURRENT_API_RESOURCE = "current.txt";
- private static final String SYSTEM_CURRENT_API_FILE =
- CurrentApi.API_FILE_DIRECTORY + "/system-current.txt";
+ private static final String SYSTEM_CURRENT_API_RESOURCE = "system-current.txt";
- private static final String SYSTEM_REMOVED_API_FILE =
- CurrentApi.API_FILE_DIRECTORY + "/system-removed.txt";
+ private static final String SYSTEM_REMOVED_API_RESOURCE = "system-removed.txt";
private static final String TAG = IntentTest.class.getSimpleName();
- private static final File SIGNATURE_TEST_PACKGES =
+ private static final File SIGNATURE_TEST_PACKAGES =
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: ";
@@ -116,21 +113,23 @@
Assert.assertTrue(errors.toString(), errors.isEmpty());
}
- private Set<String> lookupPlatformIntents() {
+ private Set<String> lookupPlatformIntents() throws IOException {
Set<String> intents = new HashSet<>();
- intents.addAll(parse(CURRENT_API_FILE));
- intents.addAll(parse(SYSTEM_CURRENT_API_FILE));
- intents.addAll(parse(SYSTEM_REMOVED_API_FILE));
+ intents.addAll(parse(CURRENT_API_RESOURCE));
+ intents.addAll(parse(SYSTEM_CURRENT_API_RESOURCE));
+ intents.addAll(parse(SYSTEM_REMOVED_API_RESOURCE));
return intents;
}
- private static Set<String> parse(String apiFileName) {
+ private static Set<String> parse(String apiResourceName) throws IOException {
Set<String> androidIntents = new HashSet<>();
ApiDocumentParser apiDocumentParser = new ApiDocumentParser(TAG);
- apiDocumentParser.parseAsStream(VirtualPath.get(apiFileName)).forEach(
+ VirtualPath.ResourcePath virtualPath =
+ VirtualPath.get(IntentTest.class.getClassLoader(), apiResourceName);
+ apiDocumentParser.parseAsStream(virtualPath).forEach(
classDescription -> {
for (JDiffField diffField : classDescription.getFieldList()) {
String fieldValue = diffField.getValueString();
@@ -156,7 +155,7 @@
private static Set<String> lookupActiveIntents(String packageName) {
HashSet<String> activeIntents = new HashSet<>();
- File dumpsysPackage = new File(SIGNATURE_TEST_PACKGES, packageName + ".txt");
+ File dumpsysPackage = new File(SIGNATURE_TEST_PACKAGES, packageName + ".txt");
if (!dumpsysPackage.exists() || dumpsysPackage.length() == 0) {
throw new RuntimeException("Missing package info: " + dumpsysPackage.getAbsolutePath());
}