diff options
author | Yo Chiang <yochiang@google.com> | 2020-09-03 13:50:05 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-09-03 13:50:05 +0000 |
commit | d12a5f8680c1ef5d2f91ab0e21ab9a2b8aa8190c (patch) | |
tree | 9c900f8a269b5b79b8f0637269bf8c4adeee0325 | |
parent | b9d8e8929101a8710f801b31f9ff28b0f0a7ce0d (diff) | |
parent | 74bc0e8df723873a995ef27a451bda1c88b80fd6 (diff) | |
download | gsid-d12a5f8680c1ef5d2f91ab0e21ab9a2b8aa8190c.tar.gz |
Remove LockScreenAutomation.apk am: 331184f545 am: f465eb8c7b am: 76be6560c6 am: 74bc0e8df7
Original change: https://android-review.googlesource.com/c/platform/system/gsid/+/1418189
Change-Id: I7111f9e6f0bb538bd83e26ec1f2c0be9ee9eea82
-rw-r--r-- | tests/Android.bp | 10 | ||||
-rw-r--r-- | tests/AndroidManifest.xml | 30 | ||||
-rw-r--r-- | tests/DSUEndtoEndTest.java | 34 | ||||
-rw-r--r-- | tests/LockScreenAutomation.java | 151 |
4 files changed, 2 insertions, 223 deletions
diff --git a/tests/Android.bp b/tests/Android.bp index 034209f..70d73ee 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -58,13 +58,3 @@ java_test_host { test_config: "dsu-test.xml", test_suites: ["general-tests"], } - -android_test { - name: "LockScreenAutomation", - srcs: ["LockScreenAutomation.java"], - libs: ["junit", "android.test.base.stubs"], - static_libs: ["androidx.test.uiautomator"], - certificate: "platform", - manifest: "AndroidManifest.xml", - test_suites: ["general-tests"], -} diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml deleted file mode 100644 index 19d0c53..0000000 --- a/tests/AndroidManifest.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2019 Google Inc. - - 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.google.android.lockscreenautomation" - android:sharedUserId="android.uid.system" - > - - <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="28"/> - - <application debuggable="true"> - <uses-library android:name="android.test.runner" /> - </application> - - <instrumentation android:name="androidx.test.uiautomator.UiAutomatorInstrumentationTestRunner" - android:targetPackage="com.google.android.lockscreenautomation" - android:label="Lock Screen Automation"/> -</manifest> diff --git a/tests/DSUEndtoEndTest.java b/tests/DSUEndtoEndTest.java index 69d40ad..e717079 100644 --- a/tests/DSUEndtoEndTest.java +++ b/tests/DSUEndtoEndTest.java @@ -47,11 +47,6 @@ import java.util.concurrent.TimeUnit; @RunWith(DeviceJUnit4ClassRunner.class) public class DSUEndtoEndTest extends BaseHostJUnit4Test { private static final long kDefaultUserdataSize = 4L * 1024 * 1024 * 1024; - private static final String APK = "LockScreenAutomation.apk"; - private static final String PACKAGE = "com.google.android.lockscreenautomation"; - private static final String UI_AUTOMATOR_INSTRUMENTATION_RUNNER = - "androidx.test.uiautomator.UiAutomatorInstrumentationTestRunner"; - private static final String CLASS = "LockScreenAutomation"; private static final String LPUNPACK_PATH = "bin/lpunpack"; private static final String SIMG2IMG_PATH = "bin/simg2img"; @@ -74,7 +69,6 @@ public class DSUEndtoEndTest extends BaseHostJUnit4Test { @After public void teardown() throws Exception { - uninstallPackage(PACKAGE); if (mUnsparseSystemImage != null) { mUnsparseSystemImage.delete(); } @@ -129,13 +123,6 @@ public class DSUEndtoEndTest extends BaseHostJUnit4Test { expectGsiStatus("normal"); - installPackage(APK); - String method = "setPin"; - String testClass = PACKAGE + "." + CLASS; - String testMethod = testClass + "." + method; - Assert.assertTrue(testMethod + " failed.", - runDeviceTests(UI_AUTOMATOR_INSTRUMENTATION_RUNNER, PACKAGE, testClass, method)); - // Sleep after installing to allow time for gsi_tool to reboot. This prevents a race between // the device rebooting and waitForDeviceAvailable() returning. getDevice().executeShellV2Command("gsi_tool install --userdata-size " + mUserdataSize + @@ -145,7 +132,7 @@ public class DSUEndtoEndTest extends BaseHostJUnit4Test { expectGsiStatus("running"); - rebootAndUnlock(); + getDevice().rebootUntilOnline(); expectGsiStatus("installed"); @@ -162,16 +149,10 @@ public class DSUEndtoEndTest extends BaseHostJUnit4Test { getDevice().executeShellV2Command("gsi_tool wipe"); - rebootAndUnlock(); + getDevice().rebootUntilOnline(); expectGsiStatus("normal"); - method = "removePin"; - testClass = PACKAGE + "." + CLASS; - testMethod = testClass + "." + method; - Assert.assertTrue(testMethod + " failed.", - runDeviceTests(UI_AUTOMATOR_INSTRUMENTATION_RUNNER, PACKAGE, testClass, method)); - if (wasRoot) { getDevice().enableAdbRoot(); } @@ -182,16 +163,5 @@ public class DSUEndtoEndTest extends BaseHostJUnit4Test { String status = result.getStdout().split("\n", 2)[0].trim(); Assert.assertEquals("Device not in expected DSU state", expected, status); } - - private void rebootAndUnlock() throws Exception { - getDevice().rebootUntilOnline(); - getDevice().executeShellV2Command("input keyevent 224"); // KeyEvent.KEYCODE_WAKEUP - getDevice().executeShellV2Command("wm dismiss-keyguard"); - getDevice().executeShellV2Command("input keyevent 7"); // KeyEvent.KEYCODE_0 - getDevice().executeShellV2Command("input keyevent 7"); - getDevice().executeShellV2Command("input keyevent 7"); - getDevice().executeShellV2Command("input keyevent 7"); - getDevice().executeShellV2Command("input keyevent 66"); // KeyEvent.KEYCODE_ENTER - } } diff --git a/tests/LockScreenAutomation.java b/tests/LockScreenAutomation.java deleted file mode 100644 index afefa1c..0000000 --- a/tests/LockScreenAutomation.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2019 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.google.android.lockscreenautomation; - -import org.junit.Assert; - -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.res.Resources; -import android.provider.Settings; -import androidx.test.uiautomator.By; -import androidx.test.uiautomator.BySelector; -import androidx.test.uiautomator.UiAutomatorTestCase; -import androidx.test.uiautomator.UiDevice; -import androidx.test.uiautomator.UiObject2; -import androidx.test.uiautomator.UiObjectNotFoundException; -import androidx.test.uiautomator.UiSelector; -import androidx.test.uiautomator.Until; -import android.view.KeyEvent; - -/** - * Methods for configuring lock screen settings - */ -public class LockScreenAutomation extends UiAutomatorTestCase { - - private static final String SETTINGS_PACKAGE = "com.android.settings"; - - private static final long TIMEOUT = 2000L; - - private Context mContext; - private UiDevice mDevice; - - public void setPin() throws Exception { - mContext = getInstrumentation().getContext(); - mDevice = UiDevice.getInstance(getInstrumentation()); - - mDevice.wakeUp(); - mDevice.pressKeyCode(KeyEvent.KEYCODE_MENU); - mDevice.waitForIdle(TIMEOUT); - launchLockScreenSettings(); - - PackageManager pm = mContext.getPackageManager(); - Resources res = pm.getResourcesForApplication(SETTINGS_PACKAGE); - - int resId = res.getIdentifier("unlock_set_unlock_pin_title", "string", SETTINGS_PACKAGE); - findAndClick(By.text(res.getString(resId))); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressEnter(); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - - // Re-enter PIN - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressEnter(); - - findAndClick(By.res(SETTINGS_PACKAGE, "redact_sensitive")); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - findAndClick(By.clazz("android.widget.Button")); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - } - - public void unlock() throws Exception { - mContext = getInstrumentation().getContext(); - mDevice = UiDevice.getInstance(getInstrumentation()); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.pressKeyCode(KeyEvent.KEYCODE_ENTER); - } - - public void removePin() throws Exception { - mContext = getInstrumentation().getContext(); - mDevice = UiDevice.getInstance(getInstrumentation()); - - mDevice.wakeUp(); - mDevice.pressKeyCode(KeyEvent.KEYCODE_MENU); - mDevice.waitForIdle(TIMEOUT); - launchLockScreenSettings(); - - PackageManager pm = mContext.getPackageManager(); - Resources res = pm.getResourcesForApplication(SETTINGS_PACKAGE); - - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressKeyCode(KeyEvent.KEYCODE_0); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - mDevice.pressEnter(); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - - int resId = res.getIdentifier("unlock_set_unlock_off_title", "string", SETTINGS_PACKAGE); - findAndClick(By.text(res.getString(resId))); - mDevice.waitForWindowUpdate(SETTINGS_PACKAGE, 5); - - findAndClick(By.res("android", "button1")); - mDevice.waitForIdle(TIMEOUT); - } - - private void findAndClick(BySelector selector) - { - for (int i = 0; i < 3; i++) { - mDevice.wait(Until.findObject(selector), TIMEOUT); - UiObject2 obj = mDevice.findObject(selector); - if (obj != null) { - obj.click(); - return; - } - } - Assert.fail("Could not find and click " + selector); - } - - private void launchLockScreenSettings() { - final Intent intent = new Intent().setClassName(SETTINGS_PACKAGE, "com.android.settings.password.ChooseLockGeneric"); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); - mContext.startActivity(intent); - mDevice.wait(Until.hasObject(By.pkg(SETTINGS_PACKAGE).depth(0)), TIMEOUT); - } -} |