aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Android.mk17
-rw-r--r--tests/NfcProvisioning/Android.mk33
-rw-r--r--tests/NfcProvisioning/AndroidManifest.xml32
-rw-r--r--tests/NfcProvisioning/AndroidTest.xml44
-rw-r--r--tests/NfcProvisioning/src/com/android/afwtest/nfcprovisioning/NfcProvisioningTest.java97
-rw-r--r--tests/NonSuwPoProvisioning/Android.mk33
-rw-r--r--tests/NonSuwPoProvisioning/AndroidManifest.xml32
-rw-r--r--tests/NonSuwPoProvisioning/AndroidTest.xml60
-rw-r--r--tests/NonSuwPoProvisioning/src/com/android/afwtest/nonsuwpoprovisioning/NonSuwPoProvisioningTest.java91
-rw-r--r--tests/QRCodeProvisioning/Android.mk33
-rw-r--r--tests/QRCodeProvisioning/AndroidManifest.xml32
-rw-r--r--tests/QRCodeProvisioning/AndroidTest.xml43
-rw-r--r--tests/QRCodeProvisioning/src/com/android/afwtest/qrcodeprovisioning/QRCodeProvisioningTest.java111
-rw-r--r--tests/SuwDoProvisioning/Android.mk33
-rw-r--r--tests/SuwDoProvisioning/AndroidManifest.xml32
-rw-r--r--tests/SuwDoProvisioning/AndroidTest.xml47
-rw-r--r--tests/SuwDoProvisioning/src/com/android/afwtest/suwdoprovisioning/SuwDoProvisioningTest.java78
-rw-r--r--tests/SuwPoProvisioning/Android.mk33
-rw-r--r--tests/SuwPoProvisioning/AndroidManifest.xml32
-rw-r--r--tests/SuwPoProvisioning/AndroidTest.xml57
-rw-r--r--tests/SuwPoProvisioning/src/com/android/afwtest/suwpoprovisioning/SuwPoProvisioningTest.java62
21 files changed, 1032 insertions, 0 deletions
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644
index 0000000..41a41d0
--- /dev/null
+++ b/tests/Android.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2016 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/tests/NfcProvisioning/Android.mk b/tests/NfcProvisioning/Android.mk
new file mode 100644
index 0000000..882e7d1
--- /dev/null
+++ b/tests/NfcProvisioning/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2016 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_PACKAGE_NAME := AfwTestNfcProvisioningTestCases
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator AfwThCommonLib AfwThUiAutomatorLib android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_AFW_TEST_MODULE_CONFIG := $(LOCAL_PATH)/$(AFW_TEST_MODULE_TEST_CONFIG)
+
+LOCAL_SDK_VERSION := 22
+
+include $(BUILD_AFW_TEST_PACKAGE)
diff --git a/tests/NfcProvisioning/AndroidManifest.xml b/tests/NfcProvisioning/AndroidManifest.xml
new file mode 100644
index 0000000..5ba861d
--- /dev/null
+++ b/tests/NfcProvisioning/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.afwtest.nfcprovisioning">
+
+ <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="23"/>
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.afwtest.nfcprovisioning"
+ android:label="AfW NFC Provisioning Test Package">
+ </instrumentation>
+</manifest>
diff --git a/tests/NfcProvisioning/AndroidTest.xml b/tests/NfcProvisioning/AndroidTest.xml
new file mode 100644
index 0000000..7572cf2
--- /dev/null
+++ b/tests/NfcProvisioning/AndroidTest.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<!-- This file contains configurations used to prepare a testing device for running the
+ test in in AfwTestNfcProvisioningTestCases.apk.
+-->
+<configuration description="Test configurations for AfwTestNfcProvisioningTestCases">
+
+ <include name="afw-test-factory-reset"/>
+
+ <!-- General device setup. -->
+ <include name="afw-test-common"/>
+ <!-- Turn on NFC -->
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="svc nfc enable" />
+ </target_preparer>
+
+ <!-- Dump testing environment info to android-cts/repository/logs/ -->
+ <target_preparer class="com.android.afwtest.tradefed.targetprep.AfwTestEnvDumper" >
+ <option name="file-name-prefix" value="AfwTestNfcProvisioningTestCases"/>
+ </target_preparer>
+
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+ <option name="cleanup-apks" value="true"/>
+ <option name="test-file-name" value="AfwTestNfcProvisioningTestCases.apk"/>
+ </target_preparer>
+
+ <test class="com.android.afwtest.tradefed.testtype.AfwAndroidJUnitTest">
+ <option name="package" value="com.android.afwtest.nfcprovisioning"/>
+ </test>
+</configuration>
diff --git a/tests/NfcProvisioning/src/com/android/afwtest/nfcprovisioning/NfcProvisioningTest.java b/tests/NfcProvisioning/src/com/android/afwtest/nfcprovisioning/NfcProvisioningTest.java
new file mode 100644
index 0000000..9199d79
--- /dev/null
+++ b/tests/NfcProvisioning/src/com/android/afwtest/nfcprovisioning/NfcProvisioningTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2016 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.afwtest.nfcprovisioning;
+
+import static com.android.afwtest.common.test.TestConfig.DEFAULT_TEST_CONFIG_FILE;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.nfc.NfcAdapter;
+import android.nfc.NfcManager;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Log;
+
+import com.android.afwtest.common.nfcprovisioning.Utils;
+import com.android.afwtest.common.test.TestConfig;
+import com.android.afwtest.uiautomator.provisioning.AutomationDriver;
+import com.android.afwtest.uiautomator.test.AbstractTestCase;
+import com.android.afwtest.uiautomator.test.AfwTestUiWatcher;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * NFC provisioning test.
+ */
+@RunWith(AndroidJUnit4.class)
+public class NfcProvisioningTest extends AbstractTestCase {
+
+ private static final String TAG = "afwtest.NfcProvisioningTest";
+
+ /**
+ * {@inheritDoc}
+ */
+ @Before
+ public void setUp() throws Exception {
+ AfwTestUiWatcher.register(getUiDevice());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @After
+ public void tearDown() throws Exception {
+ AfwTestUiWatcher.unregister(getUiDevice());
+ }
+
+ @Test
+ public void testNfcProvisioning() throws Exception {
+
+ // Skip the test if no nfc
+ if (!getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
+ Log.w(TAG, "Device doesn't support NFC, skipping Nfc provisioning test!");
+ return;
+ }
+
+ // Verify if NFC is available and enabled
+ NfcManager nfcManager = (NfcManager) getContext().getSystemService(Context.NFC_SERVICE);
+ assertNotNull("Failed to get NfcManager", nfcManager);
+ NfcAdapter nfcAdapter = nfcManager.getDefaultAdapter();
+ assertNotNull("No NFC adapter found!", nfcAdapter);
+ assertTrue("NFC is disabled.", nfcAdapter.isEnabled());
+
+ // Start provisioning
+ String deviceAdminPkgName = Utils.startProvisioning(getContext(), DEFAULT_TEST_CONFIG_FILE);
+ assertNotNull(deviceAdminPkgName);
+
+ // Navigate the pages.
+ AutomationDriver driver = new AutomationDriver(getUiDevice());
+ assertTrue("NFC provisioning didn't finish",
+ driver.runNfcProvisioning(TestConfig.getDefault()));
+
+ DevicePolicyManager devicePolicyManager =
+ (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
+
+ // Verify if the device is provisioned.
+ assertTrue("Provisioning failed", devicePolicyManager.isDeviceOwnerApp(deviceAdminPkgName));
+ }
+}
diff --git a/tests/NonSuwPoProvisioning/Android.mk b/tests/NonSuwPoProvisioning/Android.mk
new file mode 100644
index 0000000..69b4063
--- /dev/null
+++ b/tests/NonSuwPoProvisioning/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2016 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_PACKAGE_NAME := AfwTestNonSuwPoProvisioningTestCases
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator AfwThCommonLib AfwThUiAutomatorLib android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := 22
+
+LOCAL_AFW_TEST_MODULE_CONFIG := $(LOCAL_PATH)/$(AFW_TEST_MODULE_TEST_CONFIG)
+
+include $(BUILD_AFW_TEST_PACKAGE)
diff --git a/tests/NonSuwPoProvisioning/AndroidManifest.xml b/tests/NonSuwPoProvisioning/AndroidManifest.xml
new file mode 100644
index 0000000..3db6052
--- /dev/null
+++ b/tests/NonSuwPoProvisioning/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.afwtest.nonsuwpoprovisioning">
+
+ <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="23"/>
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.afwtest.nonsuwpoprovisioning"
+ android:label="AfW Non-SuW PO Provisioning Test Package">
+ </instrumentation>
+</manifest>
diff --git a/tests/NonSuwPoProvisioning/AndroidTest.xml b/tests/NonSuwPoProvisioning/AndroidTest.xml
new file mode 100644
index 0000000..7e0aa4c
--- /dev/null
+++ b/tests/NonSuwPoProvisioning/AndroidTest.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<!-- This file contains configurations used to prepare a testing device for running the
+ test in in AfwTestNonSuwPoProvisioningTestCases.apk.
+-->
+<configuration description="Test configurations for AfwTestNonSuwPoProvisioningTestCases">
+
+ <!-- Disable adb root option as this test is intended to be running on production build. -->
+ <target_preparer class="com.android.afwtest.tradefed.targetprep.AfwTestAdbRootOptionPreparer">
+ <option name="enable-root-option" value="false"/>
+ </target_preparer>
+
+ <!-- General device setup -->
+ <include name="afw-test-common"/>
+
+ <!-- Connect wifi -->
+ <include name="afw-test-wifi"/>
+
+ <!-- Uninstall TestDpc and reset users. -->
+ <include name="afw-test-uninstall-testdpc-and-reset-users"/>
+
+ <!-- Force-stop Google Search App after the test as it often becomes not responding. -->
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="teardown-command" value="am force-stop com.google.android.googlequicksearchbox"/>
+ </target_preparer>
+
+ <!-- Dump testing environment info to android-cts/repository/logs/ -->
+ <target_preparer class="com.android.afwtest.tradefed.targetprep.AfwTestEnvDumper" >
+ <option name="file-name-prefix" value="AfwTestNonSuwPoProvisioningTestCases"/>
+ </target_preparer>
+
+ <!-- Copy Provisioning-Stats.csv to local file -->
+ <target_preparer class="com.android.afwtest.tradefed.targetprep.AfwTestPullExternalFile" >
+ <option name="remote-file" value="Provisioning-Stats.csv"/>
+ <option name="local-file" value="/stats/NonSuwPoProvisioning/Provisioning-Stats.csv"/>
+ </target_preparer>
+
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+ <option name="cleanup-apks" value="true"/>
+ <option name="test-file-name" value="AfwTestNonSuwPoProvisioningTestCases.apk"/>
+ </target_preparer>
+
+ <test class="com.android.afwtest.tradefed.testtype.AfwAndroidJUnitTest">
+ <option name="package" value="com.android.afwtest.nonsuwpoprovisioning"/>
+ </test>
+</configuration>
diff --git a/tests/NonSuwPoProvisioning/src/com/android/afwtest/nonsuwpoprovisioning/NonSuwPoProvisioningTest.java b/tests/NonSuwPoProvisioning/src/com/android/afwtest/nonsuwpoprovisioning/NonSuwPoProvisioningTest.java
new file mode 100644
index 0000000..f2f505a
--- /dev/null
+++ b/tests/NonSuwPoProvisioning/src/com/android/afwtest/nonsuwpoprovisioning/NonSuwPoProvisioningTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2016 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.afwtest.nonsuwpoprovisioning;
+
+import static org.junit.Assert.assertTrue;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Intent;
+import android.support.test.runner.AndroidJUnit4;
+
+import com.android.afwtest.common.AccountManagerUtils;
+import com.android.afwtest.common.test.TestConfig;
+import com.android.afwtest.uiautomator.provisioning.AutomationDriver;
+import com.android.afwtest.uiautomator.test.AbstractTestCase;
+import com.android.afwtest.uiautomator.test.AfwTestUiWatcher;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test profile owner provisioning started from Settings.
+ */
+@RunWith(AndroidJUnit4.class)
+public class NonSuwPoProvisioningTest extends AbstractTestCase {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Before
+ public void setUp() throws Exception {
+ AfwTestUiWatcher.register(getUiDevice());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @After
+ public void tearDown() throws Exception {
+ AfwTestUiWatcher.unregister(getUiDevice());
+ }
+
+ /**
+ * Tests non-suw profile owner provisioning flow.
+ */
+ @Test
+ public void testNonSuwPoProvisioning() throws Exception {
+
+ // Start Add Account activity.
+ AccountManagerUtils.startAddGoogleAccountActivity(getContext(), false);
+ AutomationDriver automationDriver = new AutomationDriver(getUiDevice());
+
+ // Navigate provisioning.
+ assertTrue("Non-SuW PO provisioning didn't finish",
+ automationDriver.runNonSuwPoProvisioning(TestConfig.getDefault()));
+ }
+
+ /**
+ * Tests provisioning a non-existing package.
+ */
+ @Test
+ public void testDisallowedProvisioning() throws Exception {
+ Intent startProvisioning = new Intent(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE);
+ // We're asking ManagedProvisioning to provision a non-existing package. It should not be
+ // allowed.
+ startProvisioning.putExtra(
+ DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,
+ "package.that.does.not.exist");
+ startProvisioning.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ AutomationDriver automationDriver = new AutomationDriver(getUiDevice());
+ getContext().startActivity(startProvisioning);
+ assertTrue("Non-SuW PO provisioning disallowed didn't finish",
+ automationDriver.runNonSuwPoProvisioningDisallowed(TestConfig.getDefault()));
+ }
+}
diff --git a/tests/QRCodeProvisioning/Android.mk b/tests/QRCodeProvisioning/Android.mk
new file mode 100644
index 0000000..d75171c
--- /dev/null
+++ b/tests/QRCodeProvisioning/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2016 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_PACKAGE_NAME := AfwTestQRCodeProvisioningTestCases
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator AfwThCommonLib AfwThUiAutomatorLib android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_AFW_TEST_MODULE_CONFIG := $(LOCAL_PATH)/$(AFW_TEST_MODULE_TEST_CONFIG)
+
+LOCAL_SDK_VERSION := 24
+
+include $(BUILD_AFW_TEST_PACKAGE)
diff --git a/tests/QRCodeProvisioning/AndroidManifest.xml b/tests/QRCodeProvisioning/AndroidManifest.xml
new file mode 100644
index 0000000..4f52706
--- /dev/null
+++ b/tests/QRCodeProvisioning/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.afwtest.qrcodeprovisioning">
+
+ <uses-sdk android:minSdkVersion="24" android:targetSdkVersion="24"/>
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.afwtest.qrcodeprovisioning"
+ android:label="AfW QR Code Provisioning Test Package">
+ </instrumentation>
+</manifest>
diff --git a/tests/QRCodeProvisioning/AndroidTest.xml b/tests/QRCodeProvisioning/AndroidTest.xml
new file mode 100644
index 0000000..a90a003
--- /dev/null
+++ b/tests/QRCodeProvisioning/AndroidTest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<!-- This file contains configurations used to prepare a testing device for running the
+ test in AfwTestQRCodeProvisioningTestCases.apk.
+-->
+<configuration description="Test configurations for AfwTestQRCodeProvisioningTestCases">
+
+ <include name="afw-test-factory-reset"/>
+
+ <!-- General device setup. -->
+ <include name="afw-test-common"/>
+
+ <!-- Connect wifi -->
+ <include name="afw-test-wifi"/>
+
+ <!-- Dump testing environment info to android-cts/repository/logs/ -->
+ <target_preparer class="com.android.afwtest.tradefed.targetprep.AfwTestEnvDumper" >
+ <option name="file-name-prefix" value="AfwTestQRCodeProvisioningTestCases"/>
+ </target_preparer>
+
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+ <option name="cleanup-apks" value="true"/>
+ <option name="test-file-name" value="AfwTestQRCodeProvisioningTestCases.apk"/>
+ </target_preparer>
+
+ <test class="com.android.afwtest.tradefed.testtype.AfwAndroidJUnitTest">
+ <option name="package" value="com.android.afwtest.qrcodeprovisioning"/>
+ </test>
+</configuration>
diff --git a/tests/QRCodeProvisioning/src/com/android/afwtest/qrcodeprovisioning/QRCodeProvisioningTest.java b/tests/QRCodeProvisioning/src/com/android/afwtest/qrcodeprovisioning/QRCodeProvisioningTest.java
new file mode 100644
index 0000000..2cbe953
--- /dev/null
+++ b/tests/QRCodeProvisioning/src/com/android/afwtest/qrcodeprovisioning/QRCodeProvisioningTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2016 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.afwtest.qrcodeprovisioning;
+
+import static com.android.afwtest.common.test.TestConfig.DEFAULT_TEST_CONFIG_FILE;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.os.SystemClock;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.BySelector;
+import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.UiObjectNotFoundException;
+
+import com.android.afwtest.common.qrcodeprovisioning.Utils;
+import com.android.afwtest.common.test.TestConfig;
+import com.android.afwtest.uiautomator.provisioning.AutomationDriver;
+import com.android.afwtest.uiautomator.test.AbstractTestCase;
+import com.android.afwtest.uiautomator.test.AfwTestUiWatcher;
+import com.android.afwtest.uiautomator.utils.WidgetUtils;
+
+import java.util.regex.Pattern;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * QR code provisioning test.
+ */
+@RunWith(AndroidJUnit4.class)
+public class QRCodeProvisioningTest extends AbstractTestCase {
+
+ private static final String SUW_PACKAGE_NAME = "com.google.android.setupwizard";
+ private static final int TAP_COUNT = 6;
+ private static final int TAP_INTERVAL = 300;
+
+ private static final int QR_READER_INSTALL_TIMEOUT = 30000;
+ private static final int QR_READER_INSTALL_ATTEMPTS = 6;
+
+ private static final BySelector NEXT_BUTTON_SELECTOR =
+ By.text(Pattern.compile("next", Pattern.CASE_INSENSITIVE)).clickable(true);
+ private static final BySelector SWITCH_CAMERA_BUTTON_SELECTOR =
+ By.res(SUW_PACKAGE_NAME, "switch_camera_button");
+ private static final BySelector WELCOME_TITLE_SELECTOR =
+ By.text(Pattern.compile("welcome|hi there", Pattern.CASE_INSENSITIVE));
+
+ /**
+ * {@inheritDoc}
+ */
+ @Before
+ public void setUp() throws Exception {
+ AfwTestUiWatcher.register(getUiDevice());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @After
+ public void tearDown() throws Exception {
+ AfwTestUiWatcher.unregister(getUiDevice());
+ }
+
+ /**
+ * Test QR code provisioning flow.
+ */
+ @Test
+ public void testQRCodeProvisioning() throws Exception {
+ UiObject2 welcomeTitle = WidgetUtils.safeWait(getUiDevice(), WELCOME_TITLE_SELECTOR);
+ for (int i = 0; i < TAP_COUNT; i++) {
+ welcomeTitle.click();
+ SystemClock.sleep(TAP_INTERVAL);
+ }
+ WidgetUtils.waitAndClick(getUiDevice(), NEXT_BUTTON_SELECTOR);
+ UiObject2 frontCameraButton =
+ WidgetUtils.safeWait(getUiDevice(), SWITCH_CAMERA_BUTTON_SELECTOR,
+ QR_READER_INSTALL_TIMEOUT, QR_READER_INSTALL_ATTEMPTS);
+ if (frontCameraButton == null) {
+ throw new UiObjectNotFoundException("Cannot identify QR reader");
+ }
+
+ // Start provisioning
+ String deviceAdminPkgName = Utils.startProvisioning(getContext(), DEFAULT_TEST_CONFIG_FILE);
+ assertNotNull(deviceAdminPkgName);
+ AutomationDriver driver = new AutomationDriver(getUiDevice());
+ assertTrue("QR Code provisioning didn't finish",
+ driver.runQRCodeProvisioning(TestConfig.getDefault()));
+ DevicePolicyManager devicePolicyManager =
+ (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
+ // Verify if the device is provisioned.
+ assertTrue("Provisioning failed", devicePolicyManager.isDeviceOwnerApp(deviceAdminPkgName));
+ }
+}
diff --git a/tests/SuwDoProvisioning/Android.mk b/tests/SuwDoProvisioning/Android.mk
new file mode 100644
index 0000000..308e9c1
--- /dev/null
+++ b/tests/SuwDoProvisioning/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2016 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_PACKAGE_NAME := AfwTestSuwDoProvisioningTestCases
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator AfwThCommonLib AfwThUiAutomatorLib android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := 22
+
+LOCAL_AFW_TEST_MODULE_CONFIG := $(LOCAL_PATH)/$(AFW_TEST_MODULE_TEST_CONFIG)
+
+include $(BUILD_AFW_TEST_PACKAGE)
diff --git a/tests/SuwDoProvisioning/AndroidManifest.xml b/tests/SuwDoProvisioning/AndroidManifest.xml
new file mode 100644
index 0000000..9688e98
--- /dev/null
+++ b/tests/SuwDoProvisioning/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.afwtest.suwdoprovisioning">
+
+ <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="23"/>
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.afwtest.suwdoprovisioning"
+ android:label="AfW SUW DO Provisioning Test Package">
+ </instrumentation>
+</manifest>
diff --git a/tests/SuwDoProvisioning/AndroidTest.xml b/tests/SuwDoProvisioning/AndroidTest.xml
new file mode 100644
index 0000000..0e8b9e8
--- /dev/null
+++ b/tests/SuwDoProvisioning/AndroidTest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<!-- This file contains configurations used to prepare a testing device for running the
+ test in AfwTestSuwDoProvisioningTestCases.apk.
+-->
+<configuration description="Test configurations for AfwTestSuwDoProvisioningTestCases">
+
+ <!-- Factory Reset Device -->
+ <include name="afw-test-factory-reset"/>
+
+ <!-- General device setup -->
+ <include name="afw-test-common"/>
+
+ <!-- Encrypt Device -->
+ <include name="afw-test-encrypt-device"/>
+
+ <!-- Connect wifi -->
+ <include name="afw-test-wifi"/>
+
+ <!-- Dump testing environment info to android-cts/repository/logs/ -->
+ <target_preparer class="com.android.afwtest.tradefed.targetprep.AfwTestEnvDumper" >
+ <option name="file-name-prefix" value="AfwTestSuwDoProvisioningTestCases"/>
+ </target_preparer>
+
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+ <option name="cleanup-apks" value="true"/>
+ <option name="test-file-name" value="AfwTestSuwDoProvisioningTestCases.apk"/>
+ </target_preparer>
+
+ <test class="com.android.afwtest.tradefed.testtype.AfwAndroidJUnitTest">
+ <option name="package" value="com.android.afwtest.suwdoprovisioning"/>
+ </test>
+</configuration>
diff --git a/tests/SuwDoProvisioning/src/com/android/afwtest/suwdoprovisioning/SuwDoProvisioningTest.java b/tests/SuwDoProvisioning/src/com/android/afwtest/suwdoprovisioning/SuwDoProvisioningTest.java
new file mode 100644
index 0000000..d81eff9
--- /dev/null
+++ b/tests/SuwDoProvisioning/src/com/android/afwtest/suwdoprovisioning/SuwDoProvisioningTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2016 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.afwtest.suwdoprovisioning;
+
+import static com.android.afwtest.uiautomator.Constants.TESTDPC_PKG_NAME;
+import static org.junit.Assert.assertTrue;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.support.test.runner.AndroidJUnit4;
+
+import com.android.afwtest.common.AccountManagerUtils;
+import com.android.afwtest.common.test.TestConfig;
+import com.android.afwtest.uiautomator.provisioning.AutomationDriver;
+import com.android.afwtest.uiautomator.test.AbstractTestCase;
+import com.android.afwtest.uiautomator.test.AfwTestUiWatcher;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * SuW device owner provisioning test.
+ */
+@RunWith(AndroidJUnit4.class)
+public class SuwDoProvisioningTest extends AbstractTestCase{
+
+ /**
+ * {@inheritDoc}
+ */
+ @Before
+ public void setUp() throws Exception {
+ AfwTestUiWatcher.register(getUiDevice());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @After
+ public void tearDown() throws Exception {
+ AfwTestUiWatcher.unregister(getUiDevice());
+ }
+
+ /**
+ * Tests Device Owner provisioning flow.
+ */
+ @Test
+ public void testDoProvisioning() throws Exception {
+
+ AccountManagerUtils.startAddGoogleAccountActivity(getContext(), true);
+
+ AutomationDriver runner = new AutomationDriver(getUiDevice());
+ assertTrue("SuW DO provisioning didn't finish",
+ runner.runSuwDoProvisioning(TestConfig.getDefault()));
+
+ DevicePolicyManager devicePolicyManager =
+ (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
+
+ // Verify if the device is provisioned.
+ assertTrue("Provisioning failed",
+ devicePolicyManager.isDeviceOwnerApp(TESTDPC_PKG_NAME));
+ }
+}
diff --git a/tests/SuwPoProvisioning/Android.mk b/tests/SuwPoProvisioning/Android.mk
new file mode 100644
index 0000000..49bf2f7
--- /dev/null
+++ b/tests/SuwPoProvisioning/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2016 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_PACKAGE_NAME := AfwTestSuwPoProvisioningTestCases
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator AfwThCommonLib AfwThUiAutomatorLib android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := 22
+
+LOCAL_AFW_TEST_MODULE_CONFIG := $(LOCAL_PATH)/$(AFW_TEST_MODULE_TEST_CONFIG)
+
+include $(BUILD_AFW_TEST_PACKAGE)
diff --git a/tests/SuwPoProvisioning/AndroidManifest.xml b/tests/SuwPoProvisioning/AndroidManifest.xml
new file mode 100644
index 0000000..4e5172d
--- /dev/null
+++ b/tests/SuwPoProvisioning/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.afwtest.suwpoprovisioning">
+
+ <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="23"/>
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.afwtest.suwpoprovisioning"
+ android:label="AfW SUW PO Provisioning Test Package">
+ </instrumentation>
+</manifest>
diff --git a/tests/SuwPoProvisioning/AndroidTest.xml b/tests/SuwPoProvisioning/AndroidTest.xml
new file mode 100644
index 0000000..fe2ef05
--- /dev/null
+++ b/tests/SuwPoProvisioning/AndroidTest.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<!-- This file contains configurations used to prepare a testing device for running the
+ test in AfwTestSuwPoProvisioningTestCases.apk.
+-->
+<configuration description="Test configurations for AfwTestSuwPoProvisioningTestCases">
+
+ <!-- Factory Reset Device -->
+ <include name="afw-test-factory-reset"/>
+
+ <!-- General device setup -->
+ <include name="afw-test-common"/>
+
+ <!-- Encrypt Device -->
+ <include name="afw-test-encrypt-device"/>
+
+ <!-- Connect wifi -->
+ <include name="afw-test-wifi"/>
+
+ <!-- Remove non-primary user after the test. -->
+ <target_preparer class="com.android.afwtest.tradefed.targetprep.AfwTestUserRemover">
+ <option name="remove-users-before-test" value="false"/>
+ </target_preparer>
+
+ <!-- Force-stop Google Search App after the test as it often becomes not responding. -->
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="teardown-command" value="am force-stop com.google.android.googlequicksearchbox"/>
+ </target_preparer>
+
+ <!-- Dump testing environment info to android-cts/repository/logs/ -->
+ <target_preparer class="com.android.afwtest.tradefed.targetprep.AfwTestEnvDumper" >
+ <option name="file-name-prefix" value="AfwTestSuwPoProvisioningTestCases"/>
+ </target_preparer>
+
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+ <option name="cleanup-apks" value="true"/>
+ <option name="test-file-name" value="AfwTestSuwPoProvisioningTestCases.apk"/>
+ </target_preparer>
+
+ <test class="com.android.afwtest.tradefed.testtype.AfwAndroidJUnitTest">
+ <option name="package" value="com.android.afwtest.suwpoprovisioning"/>
+ </test>
+</configuration>
diff --git a/tests/SuwPoProvisioning/src/com/android/afwtest/suwpoprovisioning/SuwPoProvisioningTest.java b/tests/SuwPoProvisioning/src/com/android/afwtest/suwpoprovisioning/SuwPoProvisioningTest.java
new file mode 100644
index 0000000..da3b6fe
--- /dev/null
+++ b/tests/SuwPoProvisioning/src/com/android/afwtest/suwpoprovisioning/SuwPoProvisioningTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016 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.afwtest.suwpoprovisioning;
+
+import static org.junit.Assert.assertTrue;
+
+import android.support.test.runner.AndroidJUnit4;
+
+import com.android.afwtest.common.test.TestConfig;
+import com.android.afwtest.uiautomator.provisioning.AutomationDriver;
+import com.android.afwtest.uiautomator.test.AbstractTestCase;
+import com.android.afwtest.uiautomator.test.AfwTestUiWatcher;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test Profile Owner provisioning flow from Setup Wizard.
+ */
+@RunWith(AndroidJUnit4.class)
+public class SuwPoProvisioningTest extends AbstractTestCase {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Before
+ public void setUp() throws Exception {
+ AfwTestUiWatcher.register(getUiDevice());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @After
+ public void tearDown() throws Exception {
+ AfwTestUiWatcher.unregister(getUiDevice());
+ }
+
+ @Test
+ public void testPoProvisioning() throws Exception {
+
+ AutomationDriver runner = new AutomationDriver(getUiDevice());
+ assertTrue("SuW PO provisioning didn't finish",
+ runner.runSuwPoProvisioning(TestConfig.getDefault()));
+ }
+}