summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/tests/overlaytests/device/Android.mk31
-rw-r--r--core/tests/overlaytests/device/AndroidManifest.xml8
-rw-r--r--core/tests/overlaytests/device/AndroidTest.xml47
-rw-r--r--core/tests/overlaytests/device/OverlayAppFiltered/Android.mk10
-rw-r--r--core/tests/overlaytests/device/OverlayAppFiltered/AndroidManifest.xml9
-rw-r--r--core/tests/overlaytests/device/OverlayAppFiltered/res/raw/lorem_ipsum.txt1
-rw-r--r--core/tests/overlaytests/device/OverlayAppFiltered/res/values/config.xml4
-rw-r--r--core/tests/overlaytests/device/OverlayAppFiltered/res/xml/integer.xml2
-rw-r--r--core/tests/overlaytests/device/OverlayAppFirst/Android.mk10
-rw-r--r--core/tests/overlaytests/device/OverlayAppFirst/AndroidManifest.xml6
-rw-r--r--core/tests/overlaytests/device/OverlayAppSecond/Android.mk10
-rw-r--r--core/tests/overlaytests/device/OverlayAppSecond/AndroidManifest.xml6
-rw-r--r--core/tests/overlaytests/device/OverlayTest/Android.mk16
-rw-r--r--core/tests/overlaytests/device/OverlayTest/AndroidManifest.xml10
-rw-r--r--core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithMultipleOverlaysTest.java7
-rw-r--r--core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java7
-rw-r--r--core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java7
-rw-r--r--core/tests/overlaytests/device/OverlayTestOverlay/Android.mk10
-rw-r--r--core/tests/overlaytests/device/OverlayTestOverlay/AndroidManifest.xml6
-rw-r--r--core/tests/overlaytests/device/res/drawable-nodpi/drawable.jpg (renamed from core/tests/overlaytests/device/OverlayTest/res/drawable-nodpi/drawable.jpg)bin414 -> 414 bytes
-rw-r--r--core/tests/overlaytests/device/res/raw/lorem_ipsum.txt (renamed from core/tests/overlaytests/device/OverlayTest/res/raw/lorem_ipsum.txt)0
-rw-r--r--core/tests/overlaytests/device/res/values-sv/config.xml (renamed from core/tests/overlaytests/device/OverlayTest/res/values-sv/config.xml)0
-rw-r--r--core/tests/overlaytests/device/res/values/config.xml (renamed from core/tests/overlaytests/device/OverlayTest/res/values/config.xml)0
-rw-r--r--core/tests/overlaytests/device/res/xml/integer.xml (renamed from core/tests/overlaytests/device/OverlayTest/res/xml/integer.xml)0
-rw-r--r--core/tests/overlaytests/device/src/com/android/overlaytest/OverlayBaseTest.java (renamed from core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java)171
-rw-r--r--core/tests/overlaytests/device/src/com/android/overlaytest/WithMultipleOverlaysTest.java36
-rw-r--r--core/tests/overlaytests/device/src/com/android/overlaytest/WithOverlayTest.java37
-rw-r--r--core/tests/overlaytests/device/src/com/android/overlaytest/WithoutOverlayTest.java36
-rw-r--r--core/tests/overlaytests/device/test-apps/Android.mk15
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayOne/Android.mk22
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayOne/AndroidManifest.xml22
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayOne/res/drawable-nodpi/drawable.jpg (renamed from core/tests/overlaytests/device/OverlayAppFirst/res/drawable-nodpi/drawable.jpg)bin399 -> 399 bytes
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayOne/res/raw/lorem_ipsum.txt (renamed from core/tests/overlaytests/device/OverlayAppFirst/res/raw/lorem_ipsum.txt)0
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayOne/res/values-sv/config.xml (renamed from core/tests/overlaytests/device/OverlayAppFirst/res/values-sv/config.xml)0
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayOne/res/values/config.xml (renamed from core/tests/overlaytests/device/OverlayAppFirst/res/values/config.xml)0
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayOne/res/xml/integer.xml (renamed from core/tests/overlaytests/device/OverlayAppFirst/res/xml/integer.xml)0
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayTwo/Android.mk22
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayTwo/AndroidManifest.xml22
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/raw/lorem_ipsum.txt (renamed from core/tests/overlaytests/device/OverlayAppSecond/res/raw/lorem_ipsum.txt)0
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/values-sv/config.xml (renamed from core/tests/overlaytests/device/OverlayAppSecond/res/values-sv/config.xml)0
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/values/config.xml (renamed from core/tests/overlaytests/device/OverlayAppSecond/res/values/config.xml)0
-rw-r--r--core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/xml/integer.xml (renamed from core/tests/overlaytests/device/OverlayAppSecond/res/xml/integer.xml)0
-rw-r--r--core/tests/overlaytests/device/test-apps/FrameworkOverlay/Android.mk22
-rw-r--r--core/tests/overlaytests/device/test-apps/FrameworkOverlay/AndroidManifest.xml22
-rw-r--r--core/tests/overlaytests/device/test-apps/FrameworkOverlay/res/values/config.xml (renamed from core/tests/overlaytests/device/OverlayTestOverlay/res/values/config.xml)0
-rw-r--r--core/tests/overlaytests/host/test-apps/SignatureOverlay/AndroidManifest.xml2
-rwxr-xr-xcore/tests/overlaytests/testrunner.py732
47 files changed, 491 insertions, 877 deletions
diff --git a/core/tests/overlaytests/device/Android.mk b/core/tests/overlaytests/device/Android.mk
new file mode 100644
index 000000000000..4ca3e4ce2389
--- /dev/null
+++ b/core/tests/overlaytests/device/Android.mk
@@ -0,0 +1,31 @@
+# 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(call all-java-files-under,src)
+LOCAL_MODULE_TAGS := tests
+LOCAL_PACKAGE_NAME := OverlayDeviceTests
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_COMPATIBILITY_SUITE := device-tests
+LOCAL_TARGET_REQUIRED_MODULES := \
+ OverlayDeviceTests_AppOverlayOne \
+ OverlayDeviceTests_AppOverlayTwo \
+ OverlayDeviceTests_FrameworkOverlay
+include $(BUILD_PACKAGE)
+
+# Include to build test-apps.
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
diff --git a/core/tests/overlaytests/device/AndroidManifest.xml b/core/tests/overlaytests/device/AndroidManifest.xml
index e01caeedd862..d14fdf5ee819 100644
--- a/core/tests/overlaytests/device/AndroidManifest.xml
+++ b/core/tests/overlaytests/device/AndroidManifest.xml
@@ -15,15 +15,15 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.server.om.test">
+ package="com.android.overlaytest">
<uses-sdk android:minSdkVersion="21" />
<application>
- <uses-library android:name="android.test.runner" />
+ <uses-library android:name="android.test.runner"/>
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.server.om.test" />
-
+ android:targetPackage="com.android.overlaytest"
+ android:label="Runtime resource overlay tests" />
</manifest>
diff --git a/core/tests/overlaytests/device/AndroidTest.xml b/core/tests/overlaytests/device/AndroidTest.xml
new file mode 100644
index 000000000000..f06983559830
--- /dev/null
+++ b/core/tests/overlaytests/device/AndroidTest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<configuration description="Test module config for OverlayDeviceTests">
+ <option name="test-tag" value="OverlayDeviceTests" />
+ <option name="test-suite-tag" value="apct" />
+
+ <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <option name="test-file-name" value="OverlayDeviceTests.apk" />
+ <option name="test-file-name" value="OverlayDeviceTests_AppOverlayOne.apk" />
+ <option name="test-file-name" value="OverlayDeviceTests_AppOverlayTwo.apk" />
+ <option name="test-file-name" value="OverlayDeviceTests_FrameworkOverlay.apk" />
+ </target_preparer>
+
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command"
+ value="cmd overlay disable com.android.overlaytest.framework" />
+ <option name="run-command"
+ value="cmd overlay disable com.android.overlaytest.app_overlay_one" />
+ <option name="run-command"
+ value="cmd overlay disable com.android.overlaytest.app_overlay_two" />
+ <option name="teardown-command"
+ value="cmd overlay disable com.android.overlaytest.framework" />
+ <option name="teardown-command"
+ value="cmd overlay disable com.android.overlaytest.app_overlay_one" />
+ <option name="teardown-command"
+ value="cmd overlay disable com.android.overlaytest.app_overlay_two" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest">
+ <option name="package" value="com.android.overlaytest" />
+ <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+ </test>
+</configuration>
diff --git a/core/tests/overlaytests/device/OverlayAppFiltered/Android.mk b/core/tests/overlaytests/device/OverlayAppFiltered/Android.mk
deleted file mode 100644
index f76de7a93b2e..000000000000
--- a/core/tests/overlaytests/device/OverlayAppFiltered/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := system_current
-
-LOCAL_PACKAGE_NAME := com.android.overlaytest.filtered_app_overlay
-
-include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/device/OverlayAppFiltered/AndroidManifest.xml b/core/tests/overlaytests/device/OverlayAppFiltered/AndroidManifest.xml
deleted file mode 100644
index 5b7950a25fbf..000000000000
--- a/core/tests/overlaytests/device/OverlayAppFiltered/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.overlaytest.filtered_app_overlay"
- android:versionCode="1"
- android:versionName="1.0">
- <overlay android:targetPackage="com.android.overlaytest"
- android:requiredSystemPropertyName="persist.oem.overlay.test"
- android:requiredSystemPropertyValue="foo"
- android:priority="3"/>
-</manifest>
diff --git a/core/tests/overlaytests/device/OverlayAppFiltered/res/raw/lorem_ipsum.txt b/core/tests/overlaytests/device/OverlayAppFiltered/res/raw/lorem_ipsum.txt
deleted file mode 100644
index 0954cedeb5d5..000000000000
--- a/core/tests/overlaytests/device/OverlayAppFiltered/res/raw/lorem_ipsum.txt
+++ /dev/null
@@ -1 +0,0 @@
-Lorem ipsum: filtered overlays.
diff --git a/core/tests/overlaytests/device/OverlayAppFiltered/res/values/config.xml b/core/tests/overlaytests/device/OverlayAppFiltered/res/values/config.xml
deleted file mode 100644
index 60b94eec5994..000000000000
--- a/core/tests/overlaytests/device/OverlayAppFiltered/res/values/config.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="str">filtered</string>
-</resources>
diff --git a/core/tests/overlaytests/device/OverlayAppFiltered/res/xml/integer.xml b/core/tests/overlaytests/device/OverlayAppFiltered/res/xml/integer.xml
deleted file mode 100644
index e2652b7e2915..000000000000
--- a/core/tests/overlaytests/device/OverlayAppFiltered/res/xml/integer.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<integer value="3"/>
diff --git a/core/tests/overlaytests/device/OverlayAppFirst/Android.mk b/core/tests/overlaytests/device/OverlayAppFirst/Android.mk
deleted file mode 100644
index bf9416c279be..000000000000
--- a/core/tests/overlaytests/device/OverlayAppFirst/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_PACKAGE_NAME := com.android.overlaytest.first_app_overlay
-
-include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/device/OverlayAppFirst/AndroidManifest.xml b/core/tests/overlaytests/device/OverlayAppFirst/AndroidManifest.xml
deleted file mode 100644
index ec10bbcf752e..000000000000
--- a/core/tests/overlaytests/device/OverlayAppFirst/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.overlaytest.first_app_overlay"
- android:versionCode="1"
- android:versionName="1.0">
- <overlay android:targetPackage="com.android.overlaytest" android:priority="1"/>
-</manifest>
diff --git a/core/tests/overlaytests/device/OverlayAppSecond/Android.mk b/core/tests/overlaytests/device/OverlayAppSecond/Android.mk
deleted file mode 100644
index bb7d142d6809..000000000000
--- a/core/tests/overlaytests/device/OverlayAppSecond/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_PACKAGE_NAME := com.android.overlaytest.second_app_overlay
-
-include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/device/OverlayAppSecond/AndroidManifest.xml b/core/tests/overlaytests/device/OverlayAppSecond/AndroidManifest.xml
deleted file mode 100644
index ed498637b454..000000000000
--- a/core/tests/overlaytests/device/OverlayAppSecond/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.overlaytest.second_app_overlay"
- android:versionCode="1"
- android:versionName="1.0">
- <overlay android:targetPackage="com.android.overlaytest" android:priority="2"/>
-</manifest>
diff --git a/core/tests/overlaytests/device/OverlayTest/Android.mk b/core/tests/overlaytests/device/OverlayTest/Android.mk
deleted file mode 100644
index 5fe7b917102e..000000000000
--- a/core/tests/overlaytests/device/OverlayTest/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_PACKAGE_NAME := OverlayTest
-
-LOCAL_DEX_PREOPT := false
-
-LOCAL_JAVA_LIBRARIES += android.test.base
-
-LOCAL_MODULE_PATH := $(TARGET_OUT)/app
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/device/OverlayTest/AndroidManifest.xml b/core/tests/overlaytests/device/OverlayTest/AndroidManifest.xml
deleted file mode 100644
index 9edba12ffa8f..000000000000
--- a/core/tests/overlaytests/device/OverlayTest/AndroidManifest.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.overlaytest">
- <uses-permission android:name="android.permission.RUN_INSTRUMENTATION"/>
- <application>
- <uses-library android:name="android.test.runner"/>
- </application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.android.overlaytest"
- android:label="Runtime resource overlay tests"/>
-</manifest>
diff --git a/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithMultipleOverlaysTest.java b/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithMultipleOverlaysTest.java
deleted file mode 100644
index e104f5a670c1..000000000000
--- a/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithMultipleOverlaysTest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.android.overlaytest;
-
-public class WithMultipleOverlaysTest extends OverlayBaseTest {
- public WithMultipleOverlaysTest() {
- mMode = MODE_MULTIPLE_OVERLAYS;
- }
-}
diff --git a/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java b/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java
deleted file mode 100644
index 816a476e28cf..000000000000
--- a/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.android.overlaytest;
-
-public class WithOverlayTest extends OverlayBaseTest {
- public WithOverlayTest() {
- mMode = MODE_SINGLE_OVERLAY;
- }
-}
diff --git a/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java b/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java
deleted file mode 100644
index 318cccc85461..000000000000
--- a/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.android.overlaytest;
-
-public class WithoutOverlayTest extends OverlayBaseTest {
- public WithoutOverlayTest() {
- mMode = MODE_NO_OVERLAY;
- }
-}
diff --git a/core/tests/overlaytests/device/OverlayTestOverlay/Android.mk b/core/tests/overlaytests/device/OverlayTestOverlay/Android.mk
deleted file mode 100644
index ed330467f68a..000000000000
--- a/core/tests/overlaytests/device/OverlayTestOverlay/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_PACKAGE_NAME := com.android.overlaytest.overlay
-
-include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/device/OverlayTestOverlay/AndroidManifest.xml b/core/tests/overlaytests/device/OverlayTestOverlay/AndroidManifest.xml
deleted file mode 100644
index f8b6c7b888b5..000000000000
--- a/core/tests/overlaytests/device/OverlayTestOverlay/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.overlaytest.overlay"
- android:versionCode="1"
- android:versionName="1.0">
- <overlay android:targetPackage="android" android:priority="1"/>
-</manifest>
diff --git a/core/tests/overlaytests/device/OverlayTest/res/drawable-nodpi/drawable.jpg b/core/tests/overlaytests/device/res/drawable-nodpi/drawable.jpg
index a3f14f325b85..a3f14f325b85 100644
--- a/core/tests/overlaytests/device/OverlayTest/res/drawable-nodpi/drawable.jpg
+++ b/core/tests/overlaytests/device/res/drawable-nodpi/drawable.jpg
Binary files differ
diff --git a/core/tests/overlaytests/device/OverlayTest/res/raw/lorem_ipsum.txt b/core/tests/overlaytests/device/res/raw/lorem_ipsum.txt
index cee7a927c5fa..cee7a927c5fa 100644
--- a/core/tests/overlaytests/device/OverlayTest/res/raw/lorem_ipsum.txt
+++ b/core/tests/overlaytests/device/res/raw/lorem_ipsum.txt
diff --git a/core/tests/overlaytests/device/OverlayTest/res/values-sv/config.xml b/core/tests/overlaytests/device/res/values-sv/config.xml
index 891853edb4c5..891853edb4c5 100644
--- a/core/tests/overlaytests/device/OverlayTest/res/values-sv/config.xml
+++ b/core/tests/overlaytests/device/res/values-sv/config.xml
diff --git a/core/tests/overlaytests/device/OverlayTest/res/values/config.xml b/core/tests/overlaytests/device/res/values/config.xml
index c692a2625199..c692a2625199 100644
--- a/core/tests/overlaytests/device/OverlayTest/res/values/config.xml
+++ b/core/tests/overlaytests/device/res/values/config.xml
diff --git a/core/tests/overlaytests/device/OverlayTest/res/xml/integer.xml b/core/tests/overlaytests/device/res/xml/integer.xml
index 9383daa20b6c..9383daa20b6c 100644
--- a/core/tests/overlaytests/device/OverlayTest/res/xml/integer.xml
+++ b/core/tests/overlaytests/device/res/xml/integer.xml
diff --git a/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java b/core/tests/overlaytests/device/src/com/android/overlaytest/OverlayBaseTest.java
index e57c55ced046..96ab977b799c 100644
--- a/core/tests/overlaytests/device/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java
+++ b/core/tests/overlaytests/device/src/com/android/overlaytest/OverlayBaseTest.java
@@ -1,45 +1,80 @@
+/*
+ * 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.overlaytest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import android.app.UiAutomation;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
-import android.test.AndroidTestCase;
+import android.os.LocaleList;
+import android.os.ParcelFileDescriptor;
+import android.support.test.InstrumentationRegistry;
import android.util.AttributeSet;
import android.util.Xml;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.util.Locale;
-public abstract class OverlayBaseTest extends AndroidTestCase {
+@Ignore
+public abstract class OverlayBaseTest {
private Resources mResources;
- protected int mMode; // will be set by subclasses
- static final protected int MODE_NO_OVERLAY = 0;
- static final protected int MODE_SINGLE_OVERLAY = 1;
- static final protected int MODE_MULTIPLE_OVERLAYS = 2;
+ private final int mMode;
+ static final int MODE_NO_OVERLAY = 0;
+ static final int MODE_SINGLE_OVERLAY = 1;
+ static final int MODE_MULTIPLE_OVERLAYS = 2;
+
+ static final String APP_OVERLAY_ONE_PKG = "com.android.overlaytest.app_overlay_one";
+ static final String APP_OVERLAY_TWO_PKG = "com.android.overlaytest.app_overlay_two";
+ static final String FRAMEWORK_OVERLAY_PKG = "com.android.overlaytest.framework";
+
+ protected OverlayBaseTest(int mode) {
+ mMode = mode;
+ }
- protected void setUp() {
- mResources = getContext().getResources();
+ @Before
+ public void setUp() {
+ mResources = InstrumentationRegistry.getContext().getResources();
}
private int calculateRawResourceChecksum(int resId) throws Throwable {
- InputStream input = null;
- try {
- input = mResources.openRawResource(resId);
+ try (InputStream input = mResources.openRawResource(resId)) {
int ch, checksum = 0;
while ((ch = input.read()) != -1) {
checksum = (checksum + ch) % 0xffddbb00;
}
return checksum;
- } finally {
- input.close();
}
}
private void setLocale(Locale locale) {
- Locale.setDefault(locale);
+ final LocaleList locales = new LocaleList(locale);
+ LocaleList.setDefault(locales);
Configuration config = new Configuration();
- config.locale = locale;
+ config.setLocales(locales);
mResources.updateConfiguration(config, mResources.getDisplayMetrics());
}
@@ -126,6 +161,7 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
}
}
+ @Test
public void testFrameworkBooleanOverlay() throws Throwable {
// config_annoy_dianne has the value:
// - true when no overlay exists (MODE_NO_OVERLAY)
@@ -135,6 +171,7 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
assertResource(resId, true, false, false);
}
+ @Test
public void testBooleanOverlay() throws Throwable {
// usually_false has the value:
// - false when no overlay exists (MODE_NO_OVERLAY)
@@ -144,12 +181,14 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
assertResource(resId, false, true, false);
}
+ @Test
public void testBoolean() throws Throwable {
// always_true has no overlay
final int resId = R.bool.always_true;
assertResource(resId, true, true, true);
}
+ @Test
public void testIntegerArrayOverlay() throws Throwable {
// fibonacci has values:
// - eight first values of Fibonacci sequence, when no overlay exists (MODE_NO_OVERLAY)
@@ -162,6 +201,7 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
new int[]{21, 13, 8, 5, 3, 2, 1, 1});
}
+ @Test
public void testIntegerArray() throws Throwable {
// prime_numbers has no overlay
final int resId = R.array.prime_numbers;
@@ -169,6 +209,7 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
assertResource(resId, expected, expected, expected);
}
+ @Test
public void testDrawable() throws Throwable {
// drawable-nodpi/drawable has overlay (default config)
final int resId = R.drawable.drawable;
@@ -188,16 +229,19 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
assertEquals(expected, actual);
}
+ @Test
public void testAppString() throws Throwable {
final int resId = R.string.str;
assertResource(resId, "none", "single", "multiple");
}
+ @Test
public void testApp2() throws Throwable {
final int resId = R.string.str2; // only in base package and first app overlay
assertResource(resId, "none", "single", "single");
}
+ @Test
public void testAppXml() throws Throwable {
int expected = getExpected(0, 1, 2);
int actual = -1;
@@ -214,6 +258,7 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
assertEquals(expected, actual);
}
+ @Test
public void testAppRaw() throws Throwable {
final int resId = R.raw.lorem_ipsum;
@@ -256,10 +301,10 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
* SLOT PACKAGE CONFIGURATION VALUE
* A target package (default) 100
* B target package -sv 200
- * C OverlayAppFirst (default) 300
- * D OverlayAppFirst -sv 400
- * E OverlayAppSecond (default) 500
- * F OverlayAppSecond -sv 600
+ * C AppOverlayOne (default) 300
+ * D AppOverlayOne -sv 400
+ * E AppOverlayTwo (default) 500
+ * F AppOverlayTwo -sv 600
*
* Example: in testMatrix101110, the base package defines the
* R.integer.matrix101110 resource for the default configuration (value
@@ -269,195 +314,283 @@ public abstract class OverlayBaseTest extends AndroidTestCase {
* are loaded, the expected value after setting the language to Swedish is
* 400.
*/
+ @Test
public void testMatrix100000() throws Throwable {
final int resId = R.integer.matrix_100000;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 100, 100);
}
+ @Test
public void testMatrix100001() throws Throwable {
final int resId = R.integer.matrix_100001;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 100, 600);
}
+ @Test
public void testMatrix100010() throws Throwable {
final int resId = R.integer.matrix_100010;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 100, 500);
}
+ @Test
public void testMatrix100011() throws Throwable {
final int resId = R.integer.matrix_100011;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 100, 600);
}
+ @Test
public void testMatrix100100() throws Throwable {
final int resId = R.integer.matrix_100100;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 400, 400);
}
+ @Test
public void testMatrix100101() throws Throwable {
final int resId = R.integer.matrix_100101;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 400, 600);
}
+ @Test
public void testMatrix100110() throws Throwable {
final int resId = R.integer.matrix_100110;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 400, 400);
}
+ @Test
public void testMatrix100111() throws Throwable {
final int resId = R.integer.matrix_100111;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 400, 600);
}
+ @Test
public void testMatrix101000() throws Throwable {
final int resId = R.integer.matrix_101000;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 300, 300);
}
+ @Test
public void testMatrix101001() throws Throwable {
final int resId = R.integer.matrix_101001;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 300, 600);
}
+ @Test
public void testMatrix101010() throws Throwable {
final int resId = R.integer.matrix_101010;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 300, 500);
}
+ @Test
public void testMatrix101011() throws Throwable {
final int resId = R.integer.matrix_101011;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 300, 600);
}
+ @Test
public void testMatrix101100() throws Throwable {
final int resId = R.integer.matrix_101100;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 400, 400);
}
+ @Test
public void testMatrix101101() throws Throwable {
final int resId = R.integer.matrix_101101;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 400, 600);
}
+ @Test
public void testMatrix101110() throws Throwable {
final int resId = R.integer.matrix_101110;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 400, 400);
}
+ @Test
public void testMatrix101111() throws Throwable {
final int resId = R.integer.matrix_101111;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 100, 400, 600);
}
+ @Test
public void testMatrix110000() throws Throwable {
final int resId = R.integer.matrix_110000;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 200, 200);
}
+ @Test
public void testMatrix110001() throws Throwable {
final int resId = R.integer.matrix_110001;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 200, 600);
}
+ @Test
public void testMatrix110010() throws Throwable {
final int resId = R.integer.matrix_110010;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 200, 200);
}
+ @Test
public void testMatrix110011() throws Throwable {
final int resId = R.integer.matrix_110011;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 200, 600);
}
+ @Test
public void testMatrix110100() throws Throwable {
final int resId = R.integer.matrix_110100;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 400, 400);
}
+ @Test
public void testMatrix110101() throws Throwable {
final int resId = R.integer.matrix_110101;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 400, 600);
}
+ @Test
public void testMatrix110110() throws Throwable {
final int resId = R.integer.matrix_110110;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 400, 400);
}
+ @Test
public void testMatrix110111() throws Throwable {
final int resId = R.integer.matrix_110111;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 400, 600);
}
+ @Test
public void testMatrix111000() throws Throwable {
final int resId = R.integer.matrix_111000;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 200, 200);
}
+ @Test
public void testMatrix111001() throws Throwable {
final int resId = R.integer.matrix_111001;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 200, 600);
}
+ @Test
public void testMatrix111010() throws Throwable {
final int resId = R.integer.matrix_111010;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 200, 200);
}
+ @Test
public void testMatrix111011() throws Throwable {
final int resId = R.integer.matrix_111011;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 200, 600);
}
+ @Test
public void testMatrix111100() throws Throwable {
final int resId = R.integer.matrix_111100;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 400, 400);
}
+ @Test
public void testMatrix111101() throws Throwable {
final int resId = R.integer.matrix_111101;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 400, 600);
}
+ @Test
public void testMatrix111110() throws Throwable {
final int resId = R.integer.matrix_111110;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 400, 400);
}
+ @Test
public void testMatrix111111() throws Throwable {
final int resId = R.integer.matrix_111111;
setLocale(new Locale("sv", "SE"));
assertResource(resId, 200, 400, 600);
}
+
+ /**
+ * Executes the shell command and reads all the output to ensure the command ran and didn't
+ * get stuck buffering on output.
+ */
+ protected static String executeShellCommand(UiAutomation automation, String command)
+ throws Exception {
+ final ParcelFileDescriptor pfd = automation.executeShellCommand(command);
+ try (InputStream in = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) {
+ final BufferedReader reader = new BufferedReader(
+ new InputStreamReader(in, StandardCharsets.UTF_8));
+ StringBuilder str = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ str.append(line);
+ }
+ return str.toString();
+ }
+ }
+
+ /**
+ * Enables overlay packages and waits for a configuration change event before
+ * returning, to guarantee that Resources are up-to-date.
+ * @param packages the list of package names to enable.
+ */
+ protected static void enableOverlayPackages(String... packages) throws Exception {
+ enableOverlayPackages(true, packages);
+ }
+
+ /**
+ * Disables overlay packages and waits for a configuration change event before
+ * returning, to guarantee that Resources are up-to-date.
+ * @param packages the list of package names to disable.
+ */
+ protected static void disableOverlayPackages(String... packages) throws Exception {
+ enableOverlayPackages(false, packages);
+ }
+
+ /**
+ * Enables/disables overlay packages and waits for a configuration change event before
+ * returning, to guarantee that Resources are up-to-date.
+ * @param enable enables the overlays when true, disables when false.
+ * @param packages the list of package names to enable/disable.
+ */
+ private static void enableOverlayPackages(boolean enable, String[] packages)
+ throws Exception {
+ final UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation()
+ .getUiAutomation();
+ for (final String pkg : packages) {
+ executeShellCommand(uiAutomation,
+ "cmd overlay " + (enable ? "enable " : "disable ") + pkg);
+ }
+
+ // Wait for the overlay change to propagate.
+ Thread.sleep(1000);
+ }
}
diff --git a/core/tests/overlaytests/device/src/com/android/overlaytest/WithMultipleOverlaysTest.java b/core/tests/overlaytests/device/src/com/android/overlaytest/WithMultipleOverlaysTest.java
new file mode 100644
index 000000000000..f35e511cdcf4
--- /dev/null
+++ b/core/tests/overlaytests/device/src/com/android/overlaytest/WithMultipleOverlaysTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.overlaytest;
+
+import android.support.test.filters.MediumTest;
+
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+@MediumTest
+public class WithMultipleOverlaysTest extends OverlayBaseTest {
+ public WithMultipleOverlaysTest() {
+ super(MODE_MULTIPLE_OVERLAYS);
+ }
+
+ @BeforeClass
+ public static void enableOverlay() throws Exception {
+ enableOverlayPackages(APP_OVERLAY_ONE_PKG, APP_OVERLAY_TWO_PKG, FRAMEWORK_OVERLAY_PKG);
+ }
+}
diff --git a/core/tests/overlaytests/device/src/com/android/overlaytest/WithOverlayTest.java b/core/tests/overlaytests/device/src/com/android/overlaytest/WithOverlayTest.java
new file mode 100644
index 000000000000..037449fc2c05
--- /dev/null
+++ b/core/tests/overlaytests/device/src/com/android/overlaytest/WithOverlayTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.overlaytest;
+
+import android.support.test.filters.MediumTest;
+
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+@MediumTest
+public class WithOverlayTest extends OverlayBaseTest {
+ public WithOverlayTest() {
+ super(MODE_SINGLE_OVERLAY);
+ }
+
+ @BeforeClass
+ public static void enableOverlay() throws Exception {
+ disableOverlayPackages(APP_OVERLAY_TWO_PKG);
+ enableOverlayPackages(APP_OVERLAY_ONE_PKG, FRAMEWORK_OVERLAY_PKG);
+ }
+}
diff --git a/core/tests/overlaytests/device/src/com/android/overlaytest/WithoutOverlayTest.java b/core/tests/overlaytests/device/src/com/android/overlaytest/WithoutOverlayTest.java
new file mode 100644
index 000000000000..f657b5cef0e5
--- /dev/null
+++ b/core/tests/overlaytests/device/src/com/android/overlaytest/WithoutOverlayTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.overlaytest;
+
+import android.support.test.filters.MediumTest;
+
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+@MediumTest
+public class WithoutOverlayTest extends OverlayBaseTest {
+ public WithoutOverlayTest() {
+ super(MODE_NO_OVERLAY);
+ }
+
+ @BeforeClass
+ public static void disableOverlays() throws Exception {
+ disableOverlayPackages(APP_OVERLAY_ONE_PKG, APP_OVERLAY_TWO_PKG, FRAMEWORK_OVERLAY_PKG);
+ }
+}
diff --git a/core/tests/overlaytests/device/test-apps/Android.mk b/core/tests/overlaytests/device/test-apps/Android.mk
new file mode 100644
index 000000000000..9af9f444ca59
--- /dev/null
+++ b/core/tests/overlaytests/device/test-apps/Android.mk
@@ -0,0 +1,15 @@
+# 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.
+
+include $(call all-subdir-makefiles)
diff --git a/core/tests/overlaytests/device/test-apps/AppOverlayOne/Android.mk b/core/tests/overlaytests/device/test-apps/AppOverlayOne/Android.mk
new file mode 100644
index 000000000000..17e20eeeda85
--- /dev/null
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayOne/Android.mk
@@ -0,0 +1,22 @@
+# 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+LOCAL_PACKAGE_NAME := OverlayDeviceTests_AppOverlayOne
+LOCAL_COMPATIBILITY_SUITE := device-tests
+LOCAL_CERTIFICATE := platform
+include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/device/test-apps/AppOverlayOne/AndroidManifest.xml b/core/tests/overlaytests/device/test-apps/AppOverlayOne/AndroidManifest.xml
new file mode 100644
index 000000000000..17191589e3f2
--- /dev/null
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayOne/AndroidManifest.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.overlaytest.app_overlay_one"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <overlay android:targetPackage="com.android.overlaytest" android:priority="1" />
+</manifest>
diff --git a/core/tests/overlaytests/device/OverlayAppFirst/res/drawable-nodpi/drawable.jpg b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/drawable-nodpi/drawable.jpg
index 0d944d02d633..0d944d02d633 100644
--- a/core/tests/overlaytests/device/OverlayAppFirst/res/drawable-nodpi/drawable.jpg
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/drawable-nodpi/drawable.jpg
Binary files differ
diff --git a/core/tests/overlaytests/device/OverlayAppFirst/res/raw/lorem_ipsum.txt b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/raw/lorem_ipsum.txt
index 756b0a3fc532..756b0a3fc532 100644
--- a/core/tests/overlaytests/device/OverlayAppFirst/res/raw/lorem_ipsum.txt
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/raw/lorem_ipsum.txt
diff --git a/core/tests/overlaytests/device/OverlayAppFirst/res/values-sv/config.xml b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/values-sv/config.xml
index 9cdc73e27ade..9cdc73e27ade 100644
--- a/core/tests/overlaytests/device/OverlayAppFirst/res/values-sv/config.xml
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/values-sv/config.xml
diff --git a/core/tests/overlaytests/device/OverlayAppFirst/res/values/config.xml b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/values/config.xml
index 972137a3d1bf..972137a3d1bf 100644
--- a/core/tests/overlaytests/device/OverlayAppFirst/res/values/config.xml
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/values/config.xml
diff --git a/core/tests/overlaytests/device/OverlayAppFirst/res/xml/integer.xml b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/xml/integer.xml
index 7f628d9125f3..7f628d9125f3 100644
--- a/core/tests/overlaytests/device/OverlayAppFirst/res/xml/integer.xml
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayOne/res/xml/integer.xml
diff --git a/core/tests/overlaytests/device/test-apps/AppOverlayTwo/Android.mk b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/Android.mk
new file mode 100644
index 000000000000..c24bea9e06e9
--- /dev/null
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/Android.mk
@@ -0,0 +1,22 @@
+# 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+LOCAL_PACKAGE_NAME := OverlayDeviceTests_AppOverlayTwo
+LOCAL_COMPATIBILITY_SUITE := device-tests
+LOCAL_CERTIFICATE := platform
+include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/device/test-apps/AppOverlayTwo/AndroidManifest.xml b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/AndroidManifest.xml
new file mode 100644
index 000000000000..ae8307c446c1
--- /dev/null
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/AndroidManifest.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.overlaytest.app_overlay_two"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <overlay android:targetPackage="com.android.overlaytest" android:priority="2" />
+</manifest>
diff --git a/core/tests/overlaytests/device/OverlayAppSecond/res/raw/lorem_ipsum.txt b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/raw/lorem_ipsum.txt
index 613f5b63c66c..613f5b63c66c 100644
--- a/core/tests/overlaytests/device/OverlayAppSecond/res/raw/lorem_ipsum.txt
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/raw/lorem_ipsum.txt
diff --git a/core/tests/overlaytests/device/OverlayAppSecond/res/values-sv/config.xml b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/values-sv/config.xml
index ec4b6c03e5ff..ec4b6c03e5ff 100644
--- a/core/tests/overlaytests/device/OverlayAppSecond/res/values-sv/config.xml
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/values-sv/config.xml
diff --git a/core/tests/overlaytests/device/OverlayAppSecond/res/values/config.xml b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/values/config.xml
index 8b072160ffba..8b072160ffba 100644
--- a/core/tests/overlaytests/device/OverlayAppSecond/res/values/config.xml
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/values/config.xml
diff --git a/core/tests/overlaytests/device/OverlayAppSecond/res/xml/integer.xml b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/xml/integer.xml
index f3370a6b8bcf..f3370a6b8bcf 100644
--- a/core/tests/overlaytests/device/OverlayAppSecond/res/xml/integer.xml
+++ b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/res/xml/integer.xml
diff --git a/core/tests/overlaytests/device/test-apps/FrameworkOverlay/Android.mk b/core/tests/overlaytests/device/test-apps/FrameworkOverlay/Android.mk
new file mode 100644
index 000000000000..dc811c51e926
--- /dev/null
+++ b/core/tests/overlaytests/device/test-apps/FrameworkOverlay/Android.mk
@@ -0,0 +1,22 @@
+# 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+LOCAL_PACKAGE_NAME := OverlayDeviceTests_FrameworkOverlay
+LOCAL_COMPATIBILITY_SUITE := device-tests
+LOCAL_CERTIFICATE := platform
+include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/device/test-apps/FrameworkOverlay/AndroidManifest.xml b/core/tests/overlaytests/device/test-apps/FrameworkOverlay/AndroidManifest.xml
new file mode 100644
index 000000000000..77ea16afff83
--- /dev/null
+++ b/core/tests/overlaytests/device/test-apps/FrameworkOverlay/AndroidManifest.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.overlaytest.framework"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <overlay android:targetPackage="android" android:priority="1" />
+</manifest>
diff --git a/core/tests/overlaytests/device/OverlayTestOverlay/res/values/config.xml b/core/tests/overlaytests/device/test-apps/FrameworkOverlay/res/values/config.xml
index c1e3de12059a..c1e3de12059a 100644
--- a/core/tests/overlaytests/device/OverlayTestOverlay/res/values/config.xml
+++ b/core/tests/overlaytests/device/test-apps/FrameworkOverlay/res/values/config.xml
diff --git a/core/tests/overlaytests/host/test-apps/SignatureOverlay/AndroidManifest.xml b/core/tests/overlaytests/host/test-apps/SignatureOverlay/AndroidManifest.xml
index 2d6843948f29..b08ac96aca68 100644
--- a/core/tests/overlaytests/host/test-apps/SignatureOverlay/AndroidManifest.xml
+++ b/core/tests/overlaytests/host/test-apps/SignatureOverlay/AndroidManifest.xml
@@ -15,6 +15,6 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.server.om.hosttest.signature_overlay">
+ package="com.android.server.om.hosttest.signature_overlay">
<overlay android:targetPackage="android" />
</manifest>
diff --git a/core/tests/overlaytests/testrunner.py b/core/tests/overlaytests/testrunner.py
deleted file mode 100755
index e88805e8cbf1..000000000000
--- a/core/tests/overlaytests/testrunner.py
+++ /dev/null
@@ -1,732 +0,0 @@
-#!/usr/bin/python
-import hashlib
-import optparse
-import os
-import re
-import shlex
-import subprocess
-import sys
-import threading
-import time
-
-TASK_COMPILATION = 'compile'
-TASK_DISABLE_OVERLAYS = 'disable overlays'
-TASK_ENABLE_MULTIPLE_OVERLAYS = 'enable multiple overlays'
-TASK_ENABLE_SINGLE_OVERLAY = 'enable single overlay'
-TASK_ENABLE_FILTERED_OVERLAYS = 'enable filtered overlays'
-TASK_FILE_EXISTS_TEST = 'test (file exists)'
-TASK_GREP_IDMAP_TEST = 'test (grep idmap)'
-TASK_MD5_TEST = 'test (md5)'
-TASK_IDMAP_PATH = 'idmap --path'
-TASK_IDMAP_SCAN = 'idmap --scan'
-TASK_INSTRUMENTATION = 'instrumentation'
-TASK_INSTRUMENTATION_TEST = 'test (instrumentation)'
-TASK_MKDIR = 'mkdir'
-TASK_PUSH = 'push'
-TASK_ROOT = 'root'
-TASK_REMOUNT = 'remount'
-TASK_RM = 'rm'
-TASK_SETPROP = 'setprop'
-TASK_SETUP_IDMAP_PATH = 'setup idmap --path'
-TASK_SETUP_IDMAP_SCAN = 'setup idmap --scan'
-TASK_START = 'start'
-TASK_STOP = 'stop'
-
-adb = 'adb'
-
-def _adb_shell(cmd):
- argv = shlex.split(adb + " shell '" + cmd + "; echo $?'")
- proc = subprocess.Popen(argv, bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- (stdout, stderr) = (stdout.replace('\r', ''), stderr.replace('\r', ''))
- tmp = stdout.rsplit('\n', 2)
- if len(tmp) == 2:
- stdout == ''
- returncode = int(tmp[0])
- else:
- stdout = tmp[0] + '\n'
- returncode = int(tmp[1])
- return returncode, stdout, stderr
-
-class VerbosePrinter:
- class Ticker(threading.Thread):
- def _print(self):
- s = '\r' + self.text + '[' + '.' * self.i + ' ' * (4 - self.i) + ']'
- sys.stdout.write(s)
- sys.stdout.flush()
- self.i = (self.i + 1) % 5
-
- def __init__(self, cond_var, text):
- threading.Thread.__init__(self)
- self.text = text
- self.setDaemon(True)
- self.cond_var = cond_var
- self.running = False
- self.i = 0
- self._print()
- self.running = True
-
- def run(self):
- self.cond_var.acquire()
- while True:
- self.cond_var.wait(0.25)
- running = self.running
- if not running:
- break
- self._print()
- self.cond_var.release()
-
- def stop(self):
- self.cond_var.acquire()
- self.running = False
- self.cond_var.notify_all()
- self.cond_var.release()
-
- def _start_ticker(self):
- self.ticker = VerbosePrinter.Ticker(self.cond_var, self.text)
- self.ticker.start()
-
- def _stop_ticker(self):
- self.ticker.stop()
- self.ticker.join()
- self.ticker = None
-
- def _format_begin(self, type, name):
- N = self.width - len(type) - len(' [ ] ')
- fmt = '%%s %%-%ds ' % N
- return fmt % (type, name)
-
- def __init__(self, use_color):
- self.cond_var = threading.Condition()
- self.ticker = None
- if use_color:
- self.color_RED = '\033[1;31m'
- self.color_red = '\033[0;31m'
- self.color_reset = '\033[0;37m'
- else:
- self.color_RED = ''
- self.color_red = ''
- self.color_reset = ''
-
- argv = shlex.split('stty size') # get terminal width
- proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- if proc.returncode == 0:
- (h, w) = stdout.split()
- self.width = int(w)
- else:
- self.width = 72 # conservative guesstimate
-
- def begin(self, type, name):
- self.text = self._format_begin(type, name)
- sys.stdout.write(self.text + '[ ]')
- sys.stdout.flush()
- self._start_ticker()
-
- def end_pass(self, type, name):
- self._stop_ticker()
- sys.stdout.write('\r' + self.text + '[ OK ]\n')
- sys.stdout.flush()
-
- def end_fail(self, type, name, msg):
- self._stop_ticker()
- sys.stdout.write('\r' + self.color_RED + self.text + '[FAIL]\n')
- sys.stdout.write(self.color_red)
- sys.stdout.write(msg)
- sys.stdout.write(self.color_reset)
- sys.stdout.flush()
-
-class QuietPrinter:
- def begin(self, type, name):
- pass
-
- def end_pass(self, type, name):
- sys.stdout.write('PASS ' + type + ' ' + name + '\n')
- sys.stdout.flush()
-
- def end_fail(self, type, name, msg):
- sys.stdout.write('FAIL ' + type + ' ' + name + '\n')
- sys.stdout.flush()
-
-class CompilationTask:
- def __init__(self, makefile):
- self.makefile = makefile
-
- def get_type(self):
- return TASK_COMPILATION
-
- def get_name(self):
- return self.makefile
-
- def execute(self):
- os.putenv('ONE_SHOT_MAKEFILE', os.getcwd() + "/" + self.makefile)
- argv = shlex.split('make -C "../../../../../" files')
- proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- return proc.returncode, stdout, stderr
-
-class InstrumentationTask:
- def __init__(self, instrumentation_class):
- self.instrumentation_class = instrumentation_class
-
- def get_type(self):
- return TASK_INSTRUMENTATION
-
- def get_name(self):
- return self.instrumentation_class
-
- def execute(self):
- return _adb_shell('am instrument -r -w -e class %s com.android.overlaytest/android.test.InstrumentationTestRunner' % self.instrumentation_class)
-
-class PushTask:
- def __init__(self, src, dest):
- self.src = src
- self.dest = dest
-
- def get_type(self):
- return TASK_PUSH
-
- def get_name(self):
- return "%s -> %s" % (self.src, self.dest)
-
- def execute(self):
- src = os.getenv('OUT')
- if (src is None):
- return 1, "", "Unable to proceed - $OUT environment var not set\n"
- src += "/" + self.src
- argv = shlex.split(adb + ' push %s %s' % (src, self.dest))
- proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- return proc.returncode, stdout, stderr
-
-class MkdirTask:
- def __init__(self, path):
- self.path = path
-
- def get_type(self):
- return TASK_MKDIR
-
- def get_name(self):
- return self.path
-
- def execute(self):
- return _adb_shell('mkdir -p %s' % self.path)
-
-class RmTask:
- def __init__(self, path):
- self.path = path
-
- def get_type(self):
- return TASK_RM
-
- def get_name(self):
- return self.path
-
- def execute(self):
- returncode, stdout, stderr = _adb_shell('ls %s' % self.path)
- if returncode != 0 and stderr.endswith(': No such file or directory\n'):
- return 0, "", ""
- return _adb_shell('rm -r %s' % self.path)
-
-class SetPropTask:
- def __init__(self, prop, value):
- self.prop = prop
- self.value = value
-
- def get_type(self):
- return TASK_SETPROP
-
- def get_name(self):
- return self.prop
-
- def execute(self):
- return _adb_shell('setprop %s %s' % (self.prop, self.value))
-
-class IdmapPathTask:
- def __init__(self, path_target_apk, path_overlay_apk, path_idmap):
- self.path_target_apk = path_target_apk
- self.path_overlay_apk = path_overlay_apk
- self.path_idmap = path_idmap
-
- def get_type(self):
- return TASK_IDMAP_PATH
-
- def get_name(self):
- return self.path_idmap
-
- def execute(self):
- return _adb_shell('su system idmap --scan "%s" "%s" "%s" "%s"' % (self.target_pkg_name, self.target_pkg, self.idmap_dir, self.overlay_dir))
-
-class IdmapScanTask:
- def __init__(self, overlay_dir, target_pkg_name, target_pkg, idmap_dir, symlink_dir):
- self.overlay_dir = overlay_dir
- self.target_pkg_name = target_pkg_name
- self.target_pkg = target_pkg
- self.idmap_dir = idmap_dir
- self.symlink_dir = symlink_dir
-
- def get_type(self):
- return TASK_IDMAP_SCAN
-
- def get_name(self):
- return self.target_pkg_name
-
- def execute(self):
- return _adb_shell('su system idmap --scan "%s" "%s" "%s" "%s"' % (self.overlay_dir, self.target_pkg_name, self.target_pkg, self.idmap_dir))
-
-class FileExistsTest:
- def __init__(self, path):
- self.path = path
-
- def get_type(self):
- return TASK_FILE_EXISTS_TEST
-
- def get_name(self):
- return self.path
-
- def execute(self):
- return _adb_shell('ls %s' % self.path)
-
-class GrepIdmapTest:
- def __init__(self, path_idmap, pattern, expected_n):
- self.path_idmap = path_idmap
- self.pattern = pattern
- self.expected_n = expected_n
-
- def get_type(self):
- return TASK_GREP_IDMAP_TEST
-
- def get_name(self):
- return self.pattern
-
- def execute(self):
- returncode, stdout, stderr = _adb_shell('idmap --inspect %s' % self.path_idmap)
- if returncode != 0:
- return returncode, stdout, stderr
- all_matches = re.findall('\s' + self.pattern + '$', stdout, flags=re.MULTILINE)
- if len(all_matches) != self.expected_n:
- return 1, 'pattern=%s idmap=%s expected=%d found=%d\n' % (self.pattern, self.path_idmap, self.expected_n, len(all_matches)), ''
- return 0, "", ""
-
-class Md5Test:
- def __init__(self, path, expected_content):
- self.path = path
- self.expected_md5 = hashlib.md5(expected_content).hexdigest()
-
- def get_type(self):
- return TASK_MD5_TEST
-
- def get_name(self):
- return self.path
-
- def execute(self):
- returncode, stdout, stderr = _adb_shell('md5sum %s' % self.path)
- if returncode != 0:
- return returncode, stdout, stderr
- actual_md5 = stdout.split()[0]
- if actual_md5 != self.expected_md5:
- return 1, 'expected %s, got %s\n' % (self.expected_md5, actual_md5), ''
- return 0, "", ""
-
-class StartTask:
- def get_type(self):
- return TASK_START
-
- def get_name(self):
- return ""
-
- def execute(self):
- (returncode, stdout, stderr) = _adb_shell('start')
- if returncode != 0:
- return returncode, stdout, stderr
-
- while True:
- (returncode, stdout, stderr) = _adb_shell('getprop dev.bootcomplete')
- if returncode != 0:
- return returncode, stdout, stderr
- if stdout.strip() == "1":
- break
- time.sleep(0.5)
-
- return 0, "", ""
-
-class StopTask:
- def get_type(self):
- return TASK_STOP
-
- def get_name(self):
- return ""
-
- def execute(self):
- (returncode, stdout, stderr) = _adb_shell('stop')
- if returncode != 0:
- return returncode, stdout, stderr
- return _adb_shell('setprop dev.bootcomplete 0')
-
-class RootTask:
- def get_type(self):
- return TASK_ROOT
-
- def get_name(self):
- return ""
-
- def execute(self):
- (returncode, stdout, stderr) = _adb_shell('getprop service.adb.root 0')
- if returncode != 0:
- return returncode, stdout, stderr
- if stdout.strip() == '1': # already root
- return 0, "", ""
-
- argv = shlex.split(adb + ' root')
- proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- if proc.returncode != 0:
- return proc.returncode, stdout, stderr
-
- argv = shlex.split(adb + ' wait-for-device')
- proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- return proc.returncode, stdout, stderr
-
-class RemountTask:
- def get_type(self):
- return TASK_REMOUNT
-
- def get_name(self):
- return ""
-
- def execute(self):
- argv = shlex.split(adb + ' remount')
- proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- # adb remount returns 0 even if the operation failed, so check stdout
- if stdout.startswith('remount failed:'):
- return 1, stdout, stderr
- return proc.returncode, stdout, stderr
-
-class CompoundTask:
- def __init__(self, type, tasks):
- self.type = type
- self.tasks = tasks
-
- def get_type(self):
- return self.type
-
- def get_name(self):
- return ""
-
- def execute(self):
- for t in self.tasks:
- (returncode, stdout, stderr) = t.execute()
- if returncode != 0:
- return returncode, stdout, stderr
- return 0, "", ""
-
-def _create_disable_overlays_task():
- tasks = [
- RmTask("/vendor/overlay/framework_a.apk"),
- RmTask("/vendor/overlay/framework_b.apk"),
- RmTask("/data/resource-cache/vendor@overlay@framework_a.apk@idmap"),
- RmTask("/data/resource-cache/vendor@overlay@framework_b.apk@idmap"),
- RmTask("/vendor/overlay/app_a.apk"),
- RmTask("/vendor/overlay/app_b.apk"),
- RmTask("/vendor/overlay/app_c.apk"),
- RmTask("/data/resource-cache/vendor@overlay@app_a.apk@idmap"),
- RmTask("/data/resource-cache/vendor@overlay@app_b.apk@idmap"),
- RmTask("/data/resource-cache/vendor@overlay@app_c.apk@idmap"),
- SetPropTask('persist.oem.overlay.test', '""'),
- RmTask("/data/property/persist.oem.overlay.test"),
- ]
- return CompoundTask(TASK_DISABLE_OVERLAYS, tasks)
-
-def _create_enable_single_overlay_task():
- tasks = [
- _create_disable_overlays_task(),
- MkdirTask('/system/vendor'),
- MkdirTask('/vendor/overlay'),
- PushTask('/data/app/com.android.overlaytest.overlay/com.android.overlaytest.overlay.apk', '/vendor/overlay/framework_a.apk'),
- PushTask('/data/app/com.android.overlaytest.first_app_overlay/com.android.overlaytest.first_app_overlay.apk', '/vendor/overlay/app_a.apk'),
- ]
- return CompoundTask(TASK_ENABLE_SINGLE_OVERLAY, tasks)
-
-def _create_enable_multiple_overlays_task():
- tasks = [
- _create_disable_overlays_task(),
- MkdirTask('/system/vendor'),
- MkdirTask('/vendor/overlay'),
-
- PushTask('/data/app/com.android.overlaytest.overlay/com.android.overlaytest.overlay.apk', '/vendor/overlay/framework_b.apk'),
- PushTask('/data/app/com.android.overlaytest.first_app_overlay/com.android.overlaytest.first_app_overlay.apk', '/vendor/overlay/app_a.apk'),
- PushTask('/data/app/com.android.overlaytest.second_app_overlay/com.android.overlaytest.second_app_overlay.apk', '/vendor/overlay/app_b.apk'),
- PushTask('/data/app/com.android.overlaytest.filtered_app_overlay/com.android.overlaytest.filtered_app_overlay.apk', '/vendor/overlay/app_c.apk'),
- ]
- return CompoundTask(TASK_ENABLE_MULTIPLE_OVERLAYS, tasks)
-
-def _create_enable_filtered_overlays_task():
- tasks = [
- _create_disable_overlays_task(),
- SetPropTask('persist.oem.overlay.test', 'foo'),
- MkdirTask('/system/vendor'),
- MkdirTask('/vendor/overlay'),
- PushTask('/data/app/com.android.overlaytest.overlay/com.android.overlaytest.overlay.apk', '/vendor/overlay/framework_b.apk'),
- PushTask('/data/app/com.android.overlaytest.first_app_overlay/com.android.overlaytest.first_app_overlay.apk', '/vendor/overlay/app_a.apk'),
- PushTask('/data/app/com.android.overlaytest.second_app_overlay/com.android.overlaytest.second_app_overlay.apk', '/vendor/overlay/app_b.apk'),
- PushTask('/data/app/com.android.overlaytest.filtered_app_overlay/com.android.overlaytest.filtered_app_overlay.apk', '/vendor/overlay/app_c.apk'),
- ]
- return CompoundTask(TASK_ENABLE_FILTERED_OVERLAYS, tasks)
-
-def _create_setup_idmap_path_task(idmaps, symlinks):
- tasks = [
- _create_enable_single_overlay_task(),
- RmTask(symlinks),
- RmTask(idmaps),
- MkdirTask(idmaps),
- MkdirTask(symlinks),
- ]
- return CompoundTask(TASK_SETUP_IDMAP_PATH, tasks)
-
-def _create_setup_idmap_scan_task(idmaps, symlinks):
- tasks = [
- _create_enable_filtered_overlays_task(),
- RmTask(symlinks),
- RmTask(idmaps),
- MkdirTask(idmaps),
- MkdirTask(symlinks),
- ]
- return CompoundTask(TASK_SETUP_IDMAP_SCAN, tasks)
-
-def _handle_instrumentation_task_output(stdout, printer):
- regex_status_code = re.compile(r'^INSTRUMENTATION_STATUS_CODE: -?(\d+)')
- regex_name = re.compile(r'^INSTRUMENTATION_STATUS: test=(.*)')
- regex_begin_stack = re.compile(r'^INSTRUMENTATION_STATUS: stack=(.*)')
- regex_end_stack = re.compile(r'^$')
-
- failed_tests = 0
- current_test = None
- current_stack = []
- mode_stack = False
- for line in stdout.split("\n"):
- line = line.rstrip() # strip \r from adb output
- m = regex_status_code.match(line)
- if m:
- c = int(m.group(1))
- if c == 1:
- printer.begin(TASK_INSTRUMENTATION_TEST, current_test)
- elif c == 0:
- printer.end_pass(TASK_INSTRUMENTATION_TEST, current_test)
- else:
- failed_tests += 1
- current_stack.append("\n")
- msg = "\n".join(current_stack)
- printer.end_fail(TASK_INSTRUMENTATION_TEST, current_test, msg.rstrip() + '\n')
- continue
-
- m = regex_name.match(line)
- if m:
- current_test = m.group(1)
- continue
-
- m = regex_begin_stack.match(line)
- if m:
- mode_stack = True
- current_stack = []
- current_stack.append(" " + m.group(1))
- continue
-
- m = regex_end_stack.match(line)
- if m:
- mode_stack = False
- continue
-
- if mode_stack:
- current_stack.append(" " + line.strip())
-
- return failed_tests
-
-def _set_adb_device(option, opt, value, parser):
- global adb
- if opt == '-d' or opt == '--device':
- adb = 'adb -d'
- if opt == '-e' or opt == '--emulator':
- adb = 'adb -e'
- if opt == '-s' or opt == '--serial':
- adb = 'adb -s ' + value
-
-def _create_opt_parser():
- parser = optparse.OptionParser()
- parser.add_option('-d', '--device', action='callback', callback=_set_adb_device,
- help='pass -d to adb')
- parser.add_option('-e', '--emulator', action='callback', callback=_set_adb_device,
- help='pass -e to adb')
- parser.add_option('-s', '--serial', type="str", action='callback', callback=_set_adb_device,
- help='pass -s <serical> to adb')
- parser.add_option('-C', '--no-color', action='store_false',
- dest='use_color', default=True,
- help='disable color escape sequences in output')
- parser.add_option('-q', '--quiet', action='store_true',
- dest='quiet_mode', default=False,
- help='quiet mode, output only results')
- parser.add_option('-b', '--no-build', action='store_false',
- dest='do_build', default=True,
- help='do not rebuild test projects')
- parser.add_option('-k', '--continue', action='store_true',
- dest='do_continue', default=False,
- help='do not rebuild test projects')
- parser.add_option('-i', '--test-idmap', action='store_true',
- dest='test_idmap', default=False,
- help='run tests for idmap')
- parser.add_option('-0', '--test-no-overlay', action='store_true',
- dest='test_no_overlay', default=False,
- help='run tests without any overlay')
- parser.add_option('-1', '--test-single-overlay', action='store_true',
- dest='test_single_overlay', default=False,
- help='run tests for single overlay')
- parser.add_option('-2', '--test-multiple-overlays', action='store_true',
- dest='test_multiple_overlays', default=False,
- help='run tests for multiple overlays')
- parser.add_option('-3', '--test-filtered-overlays', action='store_true',
- dest='test_filtered_overlays', default=False,
- help='run tests for filtered (sys prop) overlays')
- return parser
-
-if __name__ == '__main__':
- opt_parser = _create_opt_parser()
- opts, args = opt_parser.parse_args(sys.argv[1:])
- if not opts.test_idmap and not opts.test_no_overlay and not opts.test_single_overlay and not opts.test_multiple_overlays and not opts.test_filtered_overlays:
- opts.test_idmap = True
- opts.test_no_overlay = True
- opts.test_single_overlay = True
- opts.test_multiple_overlays = True
- opts.test_filtered_overlays = True
-
- if len(args) > 0:
- opt_parser.error("unexpected arguments: %s" % " ".join(args))
- # will never reach this: opt_parser.error will call sys.exit
-
- if opts.quiet_mode:
- printer = QuietPrinter()
- else:
- printer = VerbosePrinter(opts.use_color)
- tasks = []
-
- # must be in the same directory as this script for compilation tasks to work
- script = sys.argv[0]
- dirname = os.path.dirname(script)
- wd = os.path.realpath(dirname)
- os.chdir(wd)
-
- # build test cases
- if opts.do_build:
- tasks.append(CompilationTask('OverlayTest/Android.mk'))
- tasks.append(CompilationTask('OverlayTestOverlay/Android.mk'))
- tasks.append(CompilationTask('OverlayAppFirst/Android.mk'))
- tasks.append(CompilationTask('OverlayAppSecond/Android.mk'))
- tasks.append(CompilationTask('OverlayAppFiltered/Android.mk'))
-
- # remount filesystem, install test project
- tasks.append(RootTask())
- tasks.append(RemountTask())
- tasks.append(PushTask('/system/app/OverlayTest/OverlayTest.apk', '/system/app/OverlayTest.apk'))
-
- # test idmap
- if opts.test_idmap:
- idmaps='/data/local/tmp/idmaps'
- symlinks='/data/local/tmp/symlinks'
-
- # idmap --path
- tasks.append(StopTask())
- tasks.append(_create_setup_idmap_path_task(idmaps, symlinks))
- tasks.append(StartTask())
- tasks.append(IdmapPathTask('/vendor/overlay/framework_a.apk', '/system/framework/framework-res.apk', idmaps + '/a.idmap'))
- tasks.append(FileExistsTest(idmaps + '/a.idmap'))
- tasks.append(GrepIdmapTest(idmaps + '/a.idmap', 'bool/config_annoy_dianne', 1))
-
- # idmap --scan
- tasks.append(StopTask())
- tasks.append(_create_setup_idmap_scan_task(idmaps, symlinks))
- tasks.append(StartTask())
- tasks.append(IdmapScanTask('/vendor/overlay', 'android', '/system/framework/framework-res.apk', idmaps, symlinks))
- tasks.append(FileExistsTest(idmaps + '/vendor@overlay@framework_b.apk@idmap'))
- tasks.append(GrepIdmapTest(idmaps + '/vendor@overlay@framework_b.apk@idmap', 'bool/config_annoy_dianne', 1))
-
-
- # overlays.list
- overlays_list_path = idmaps + '/overlays.list'
- expected_content = '''\
-/vendor/overlay/framework_b.apk /data/local/tmp/idmaps/vendor@overlay@framework_b.apk@idmap
-'''
- tasks.append(FileExistsTest(overlays_list_path))
- tasks.append(Md5Test(overlays_list_path, expected_content))
-
- # idmap cleanup
- tasks.append(RmTask(symlinks))
- tasks.append(RmTask(idmaps))
-
- # test no overlay: all overlays cleared
- if opts.test_no_overlay:
- tasks.append(StopTask())
- tasks.append(_create_disable_overlays_task())
- tasks.append(StartTask())
- tasks.append(InstrumentationTask('com.android.overlaytest.WithoutOverlayTest'))
-
- # test single overlay: one overlay (a)
- if opts.test_single_overlay:
- tasks.append(StopTask())
- tasks.append(_create_enable_single_overlay_task())
- tasks.append(StartTask())
- tasks.append(InstrumentationTask('com.android.overlaytest.WithOverlayTest'))
-
- # test multiple overlays: all overlays - including 'disabled' filtered
- # overlay (system property unset) so expect 'b[p=2]' overrides 'a[p=1]' but
- # 'c[p=3]' should be ignored
- if opts.test_multiple_overlays:
- tasks.append(StopTask())
- tasks.append(_create_enable_multiple_overlays_task())
- tasks.append(StartTask())
- tasks.append(InstrumentationTask('com.android.overlaytest.WithMultipleOverlaysTest'))
-
- # test filtered overlays: all overlays - including 'enabled' filtered
- # overlay (system property set/matched) so expect c[p=3] to override both a
- # & b where applicable
- if opts.test_filtered_overlays:
- tasks.append(StopTask())
- tasks.append(_create_enable_filtered_overlays_task())
- tasks.append(StartTask())
- tasks.append(InstrumentationTask('com.android.overlaytest.WithFilteredOverlaysTest'))
-
- ignored_errors = 0
- for t in tasks:
- type = t.get_type()
- name = t.get_name()
- if type == TASK_INSTRUMENTATION:
- # InstrumentationTask will run several tests, but we want it
- # to appear as if each test was run individually. Calling
- # "am instrument" with a single test method is prohibitively
- # expensive, so let's instead post-process the output to
- # emulate individual calls.
- retcode, stdout, stderr = t.execute()
- if retcode != 0:
- printer.begin(TASK_INSTRUMENTATION, name)
- printer.end_fail(TASK_INSTRUMENTATION, name, stderr)
- sys.exit(retcode)
- retcode = _handle_instrumentation_task_output(stdout, printer)
- if retcode != 0:
- if not opts.do_continue:
- sys.exit(retcode)
- else:
- ignored_errors += retcode
- else:
- printer.begin(type, name)
- retcode, stdout, stderr = t.execute()
- if retcode == 0:
- printer.end_pass(type, name)
- if retcode != 0:
- if len(stderr) == 0:
- # hope for output from stdout instead (true for eg adb shell rm)
- stderr = stdout
- printer.end_fail(type, name, stderr)
- if not opts.do_continue:
- sys.exit(retcode)
- else:
- ignored_errors += retcode
- sys.exit(ignored_errors)