summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Android.bp28
-rw-r--r--tests/OWNERS3
-rw-r--r--tests/TEST_MAPPING7
-rw-r--r--tests/apex-e2e-tests.xml22
-rw-r--r--tests/src/com/android/tests/apex/ApexPackageStageActivateUninstallHostTest.java93
-rw-r--r--tests/testdata/HelloActivity.apkbin0 -> 16866 bytes
6 files changed, 153 insertions, 0 deletions
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..5365156
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,28 @@
+// 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.
+
+java_test_host {
+ name: "apex_e2e_tests",
+
+ srcs: ["src/**/*.java"],
+
+ libs: ["tradefed"],
+
+ data: ["testdata/*"],
+
+ test_config: "apex-e2e-tests.xml",
+
+ test_suites: ["general-tests"],
+}
+
diff --git a/tests/OWNERS b/tests/OWNERS
new file mode 100644
index 0000000..0ffc7cf
--- /dev/null
+++ b/tests/OWNERS
@@ -0,0 +1,3 @@
+chenzhu@google.com
+jiyong@google.com
+yuwu@google.com
diff --git a/tests/TEST_MAPPING b/tests/TEST_MAPPING
new file mode 100644
index 0000000..d80cd2b
--- /dev/null
+++ b/tests/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "apex_e2e_tests"
+ }
+ ]
+}
diff --git a/tests/apex-e2e-tests.xml b/tests/apex-e2e-tests.xml
new file mode 100644
index 0000000..053c67f
--- /dev/null
+++ b/tests/apex-e2e-tests.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.
+-->
+<configuration description="Config for apex install/uninstall test cases">
+ <option name="test-suite-tag" value="apex_e2e_tests" />
+ <test class="com.android.tradefed.testtype.HostTest" >
+ <option name="jar" value="apex_e2e_tests.jar" />
+ </test>
+</configuration>
+
diff --git a/tests/src/com/android/tests/apex/ApexPackageStageActivateUninstallHostTest.java b/tests/src/com/android/tests/apex/ApexPackageStageActivateUninstallHostTest.java
new file mode 100644
index 0000000..9b1e5c9
--- /dev/null
+++ b/tests/src/com/android/tests/apex/ApexPackageStageActivateUninstallHostTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.tests.apex;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+import com.android.tradefed.build.BuildInfoKey.BuildInfoFileKey;
+import com.android.tradefed.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test to check if Apex can be staged, activated and uninstalled successfully.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class ApexPackageStageActivateUninstallHostTest extends BaseHostJUnit4Test {
+
+ private static final String TEST_APK_NAME = "HelloActivity";
+ private static final String TEST_PACKAGE_NAME = "com.example.android.helloactivity";
+
+ private ITestDevice mDevice;
+
+ @Before
+ public synchronized void setUp() throws Exception {
+ // Cleanup test apps that might be installed from previous partial test run
+ mDevice = getDevice();
+ mDevice.uninstallPackage(TEST_PACKAGE_NAME);
+ }
+
+ /**
+ * Tests that if Apex package can be staged, activated and uninstalled successfully.
+ */
+ @Test
+ public void testStageActivateUninstallApexPackage()
+ throws DeviceNotAvailableException, IOException {
+
+ // Test staging APEX module (currently we simply install a sample apk).
+ // TODO: change sample apk to test APEX package and do install using adb.
+ File testAppFile = getTestApk();
+ String installResult = mDevice.installPackage(testAppFile, false);
+ Assert.assertNull(
+ String.format("failed to install test app. Reason: %s", installResult),
+ installResult);
+ Assert.assertTrue(mDevice.getInstalledPackageNames().contains(TEST_PACKAGE_NAME));
+
+ // TODO: Reboot device after staging to test if apex can be activated successfully.
+
+ // Test uninstallation
+ // TODO: reboot device to check the Apexd activates the original module
+ // after uninstallation.
+ mDevice.uninstallPackage(TEST_PACKAGE_NAME);
+ Assert.assertFalse(mDevice.getInstalledPackageNames().contains(TEST_PACKAGE_NAME));
+ }
+
+ /**
+ * Helper method to extract the sample apk from the jar file.
+ */
+ private File getTestApk() throws IOException {
+ File hostdir = getBuild().getFile(BuildInfoFileKey.HOST_LINKED_DIR);
+ File apkFile = FileUtil.findFile(hostdir, TEST_APK_NAME + ".apk");
+ return apkFile;
+ }
+
+ @After
+ public void tearDown() throws DeviceNotAvailableException {
+ mDevice.uninstallPackage(TEST_PACKAGE_NAME);
+ mDevice.reboot();
+ }
+}
+
+
diff --git a/tests/testdata/HelloActivity.apk b/tests/testdata/HelloActivity.apk
new file mode 100644
index 0000000..741ede1
--- /dev/null
+++ b/tests/testdata/HelloActivity.apk
Binary files differ