diff options
author | Jinhui Wang <jinhuiw@google.com> | 2017-01-18 18:41:05 -0800 |
---|---|---|
committer | Jinhui Wang <jinhuiw@google.com> | 2017-01-18 18:41:05 -0800 |
commit | 0287c9b920d085395612f8813901c14dbf123c0b (patch) | |
tree | 3654f9dbe98dadf7a490da764058b2f8e4f65038 | |
parent | d924fa195b7afa513e1ae07979f1cab3836f320f (diff) | |
download | AfwTestHarness-0287c9b920d085395612f8813901c14dbf123c0b.tar.gz |
Fix DO/PO/NFC/QR test failures on O
BUG: 34167779
Change-Id: I88a0367ae532b717d00fa063b66b60820d851126
10 files changed, 17 insertions, 170 deletions
diff --git a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/Constants.java b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/Constants.java index 35bbbe0..d4978c4 100644 --- a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/Constants.java +++ b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/Constants.java @@ -193,7 +193,7 @@ public final class Constants { * {@link BySelector} for {@link Button} in ManagedProvisioning to set up the profile/device. */ public static final BySelector MANAGED_PROVISIONING_SETUP_BUTTON_SELECTOR = By.res( - Pattern.compile(MANAGED_PROVISIONING_PKG_NAME + ":id/(suw_navbar_next|setup_button)")); + Pattern.compile(MANAGED_PROVISIONING_PKG_NAME + ":id/next_button")); /** * {@link BySelector} in ManagedProvisioning. diff --git a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/gms/GoogleServicesPage.java b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/gms/GoogleServicesPage.java index 880ca01..7400971 100644 --- a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/gms/GoogleServicesPage.java +++ b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/gms/GoogleServicesPage.java @@ -16,12 +16,9 @@ package com.android.afwtest.uiautomator.pages.gms; -import static com.android.afwtest.uiautomator.Constants.GMS_AGREE_BACKUP_SELECTOR; import static com.android.afwtest.uiautomator.Constants.GMS_BTN_WITH_TEXT_OK; -import static com.android.afwtest.uiautomator.Constants.GMS_CLOSE_BACKUP_MESSAGE_SELECTOR; import static com.android.afwtest.uiautomator.Constants.GMS_NEXT_BUTTON_RES_SELECTOR; import static com.android.afwtest.uiautomator.Constants.GMS_PKG_NAME_REGEX; -import static com.android.afwtest.uiautomator.Constants.GMS_SWITCH_SELECTOR; import android.support.test.uiautomator.By; import android.support.test.uiautomator.BySelector; @@ -91,14 +88,6 @@ public final class GoogleServicesPage extends UiPage { @Override public void navigate() throws Exception { - // Switch off auto-backup - WidgetUtils.safeWaitAndClick(getUiDevice(), GMS_AGREE_BACKUP_SELECTOR, GMS_SWITCH_SELECTOR, - DEFAULT_TIMEOUT_MS); - - // Click on CLOSE button, if exists - WidgetUtils.safeWaitAndClick(getUiDevice(), GMS_CLOSE_BACKUP_MESSAGE_SELECTOR, - DEFAULT_TIMEOUT_MS); - // Scroll up so that the Next button appears. for (int i = 0; i < 5; ++i) { Device.swipeUp(getUiDevice()); diff --git a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/NfcProvisioningPage.java b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/NfcProvisioningPage.java deleted file mode 100644 index b2c1e4f..0000000 --- a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/NfcProvisioningPage.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.uiautomator.pages.managedprovisioning; - -import static com.android.afwtest.uiautomator.Constants.MANAGED_PROVISIONING_PKG_SELECTOR; - -import android.support.test.uiautomator.BySelector; -import android.support.test.uiautomator.UiDevice; - -import com.android.afwtest.common.test.TestConfig; -import com.android.afwtest.uiautomator.pages.UiPage; - -/** - * A {@link UiPage} to manage NFC provisioning process. - */ -public final class NfcProvisioningPage extends BasePage { - - private static final String TAG = "afwtest.NfcProvisioningPage"; - - /** - * Constructor. - * - * @param uiDevice {@link UiDevice} object - * @param config {@link TestConfig} object holding test configurations - */ - public NfcProvisioningPage(UiDevice uiDevice, TestConfig config) { - super(uiDevice, config); - } - - /** - * {@inheritDoc} - */ - @Override - public BySelector uniqueElement() { - return MANAGED_PROVISIONING_PKG_SELECTOR; - } - - /** - * {@inheritDoc} - */ - @Override - public void navigate() throws Exception { - if (!waitForProvisioningToFinish()) { - throw new RuntimeException("NFC Provisioning timeout"); - } - } -} diff --git a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/QRCodeProvisioningPage.java b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/QRCodeProvisioningPage.java deleted file mode 100644 index 04af8e4..0000000 --- a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/QRCodeProvisioningPage.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.uiautomator.pages.managedprovisioning; - -import static com.android.afwtest.uiautomator.Constants.MANAGED_PROVISIONING_PKG_SELECTOR; - -import android.support.test.uiautomator.BySelector; -import android.support.test.uiautomator.UiDevice; - -import com.android.afwtest.common.test.TestConfig; -import com.android.afwtest.uiautomator.pages.UiPage; - -/** - * A {@link UiPage} to manage QR code provisioning process. - */ -public final class QRCodeProvisioningPage extends BasePage { - - /** - * Constructor. - * - * @param uiDevice {@link UiDevice} object - * @param config {@link TestConfig} object holding test configurations - */ - public QRCodeProvisioningPage(UiDevice uiDevice, TestConfig config) { - super(uiDevice, config); - } - - /** - * {@inheritDoc} - */ - @Override - public BySelector uniqueElement() { - return MANAGED_PROVISIONING_PKG_SELECTOR; - } - - /** - * {@inheritDoc} - */ - @Override - public void navigate() throws Exception { - if (!waitForProvisioningToFinish()) { - throw new RuntimeException("QR code Provisioning timeout"); - } - } -} diff --git a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/SetupYourDevicePage.java b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/SetupYourDevicePage.java index 94446af..37f4ed1 100644 --- a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/SetupYourDevicePage.java +++ b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/SetupYourDevicePage.java @@ -19,15 +19,13 @@ package com.android.afwtest.uiautomator.pages.managedprovisioning; import static com.android.afwtest.uiautomator.Constants.MANAGED_PROVISIONING_PKG_NAME; import static com.android.afwtest.uiautomator.Constants.MANAGED_PROVISIONING_SETUP_BUTTON_SELECTOR; import static com.android.afwtest.uiautomator.Constants.STAT_TESTDPC_WORK_PROFILE_CREATION_TIME; +import static java.util.regex.Pattern.CASE_INSENSITIVE; import android.support.test.uiautomator.By; import android.support.test.uiautomator.BySelector; import android.support.test.uiautomator.UiDevice; -import android.widget.CheckBox; - import com.android.afwtest.common.test.TestConfig; import com.android.afwtest.uiautomator.utils.WidgetUtils; - import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; @@ -46,16 +44,7 @@ public class SetupYourDevicePage extends BasePage { */ private static final BySelector SET_UP_YOUR_DEVICE_PAGE_SELECTOR = By.pkg(MANAGED_PROVISIONING_PKG_NAME) - .text(Pattern.compile("Set up work device")); - - /** - * {@link BySelector} for {@link CheckBox} with resource-id user_consent_checkbox on - * base ManagedProvisioning dialog. - */ - private static final BySelector MANAGED_PROVISIONING_CONSENT_CHECKBOX_SELECTOR = - By.res(MANAGED_PROVISIONING_PKG_NAME, "user_consent_checkbox") - .clazz(CheckBox.class.getName()) - .checkable(true); + .text(Pattern.compile("Set up .* device", CASE_INSENSITIVE)); /** * Constructor. @@ -82,8 +71,6 @@ public class SetupYourDevicePage extends BasePage { public void navigate() throws Exception { WidgetUtils.waitAndClick(getUiDevice(), MANAGED_PROVISIONING_SETUP_BUTTON_SELECTOR, DEFAULT_TIMEOUT_MS); - WidgetUtils.waitAndClick(getUiDevice(), MANAGED_PROVISIONING_CONSENT_CHECKBOX_SELECTOR, - DEFAULT_TIMEOUT_MS); onProvisioningStarted(); diff --git a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/SetupYourProfilePage.java b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/TermsPage.java index 7194fe2..d595499 100644 --- a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/SetupYourProfilePage.java +++ b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/pages/managedprovisioning/TermsPage.java @@ -31,26 +31,19 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; /** - * Managed Provisioning setup your profile page. + * Managed Provisioning terms and conditions page. */ -public class SetupYourProfilePage extends BasePage { +public class TermsPage extends BasePage { private static final long DEFAULT_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(20); /** - * {@link BySelector} unique to this page. - */ - private static final BySelector SET_UP_YOUR_PROFILE_PAGE_SELECTOR = - By.pkg(MANAGED_PROVISIONING_PKG_NAME) - .text(Pattern.compile("Set up .* profile")); - - /** * Constructor. * * @param uiDevice {@link UiDevice} object * @param config {@link TestConfig} object holding test configurations */ - public SetupYourProfilePage(UiDevice uiDevice, TestConfig config) { + public TermsPage(UiDevice uiDevice, TestConfig config) { super(uiDevice, config); } @@ -59,7 +52,7 @@ public class SetupYourProfilePage extends BasePage { */ @Override public BySelector uniqueElement() { - return SET_UP_YOUR_PROFILE_PAGE_SELECTOR; + return MANAGED_PROVISIONING_SETUP_BUTTON_SELECTOR; } /** diff --git a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/provisioning/AutomationDriver.java b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/provisioning/AutomationDriver.java index b99523e..53dd91b 100644 --- a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/provisioning/AutomationDriver.java +++ b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/provisioning/AutomationDriver.java @@ -27,15 +27,12 @@ import com.android.afwtest.uiautomator.pages.LandingPage; import com.android.afwtest.uiautomator.pages.PageSkipper; import com.android.afwtest.uiautomator.pages.UiPage; import com.android.afwtest.uiautomator.pages.gms.AddAccountPage; -import com.android.afwtest.uiautomator.pages.gms.BackUpToDrivePage; import com.android.afwtest.uiautomator.pages.gms.EnterPasswordPage; import com.android.afwtest.uiautomator.pages.gms.GoogleAppsDevicePolicyPage; import com.android.afwtest.uiautomator.pages.gms.GoogleServicesPage; import com.android.afwtest.uiautomator.pages.managedprovisioning.ErrorPage; -import com.android.afwtest.uiautomator.pages.managedprovisioning.NfcProvisioningPage; -import com.android.afwtest.uiautomator.pages.managedprovisioning.QRCodeProvisioningPage; import com.android.afwtest.uiautomator.pages.managedprovisioning.SetupYourDevicePage; -import com.android.afwtest.uiautomator.pages.managedprovisioning.SetupYourProfilePage; +import com.android.afwtest.uiautomator.pages.managedprovisioning.TermsPage; import com.android.afwtest.uiautomator.pages.packageinstaller.DeviceAccessPage; import com.android.afwtest.uiautomator.pages.testdpc.SetupFinishPage; import com.android.afwtest.uiautomator.pages.testdpc.SetupManagementDoPage; @@ -168,7 +165,7 @@ public class AutomationDriver { */ private List<UiPage> getNfcProvisioningPages(TestConfig testConfig) { List<UiPage> pages = new LinkedList<>(); - pages.add(new NfcProvisioningPage(mUiDevice, testConfig)); + pages.add(new SetupYourDevicePage(mUiDevice, testConfig)); // Land on the mdm page. UiPage mdmPage = @@ -195,7 +192,7 @@ public class AutomationDriver { */ private List<UiPage> getQRCodeProvisioningPages(TestConfig testConfig) { List<UiPage> pages = new LinkedList<>(); - pages.add(new QRCodeProvisioningPage(mUiDevice, testConfig)); + pages.add(new SetupYourDevicePage(mUiDevice, testConfig)); // Land on the mdm page. UiPage mdmPage = @@ -224,7 +221,6 @@ public class AutomationDriver { List<UiPage> pages = new LinkedList<>(); pages.add(new AddAccountPage(mUiDevice, testConfig)); pages.add(new EnterPasswordPage(mUiDevice, testConfig)); - pages.add(new BackUpToDrivePage(mUiDevice, testConfig)); pages.add(new GoogleServicesPage(mUiDevice, testConfig)); pages.add(new GoogleAppsDevicePolicyPage(mUiDevice, testConfig)); pages.add(new DeviceAccessPage(mUiDevice, testConfig)); @@ -256,12 +252,11 @@ public class AutomationDriver { List<UiPage> pages = new LinkedList<>(); pages.add(new AddAccountPage(mUiDevice, testConfig)); pages.add(new EnterPasswordPage(mUiDevice, testConfig)); - pages.add(new BackUpToDrivePage(mUiDevice, testConfig)); pages.add(new GoogleServicesPage(mUiDevice, testConfig)); pages.add(new GoogleAppsDevicePolicyPage(mUiDevice, testConfig)); pages.add(new DeviceAccessPage(mUiDevice, testConfig)); pages.add(new SetupManagementPoPage(mUiDevice, testConfig)); - pages.add(new SetupYourProfilePage(mUiDevice, testConfig)); + pages.add(new TermsPage(mUiDevice, testConfig)); UiPage landingPage = new SetupFinishPage(mUiDevice, testConfig); PageSkipper pageSkipper = @@ -288,12 +283,11 @@ public class AutomationDriver { List<UiPage> pages = new LinkedList<>(); pages.add(new AddAccountPage(mUiDevice, testConfig)); pages.add(new EnterPasswordPage(mUiDevice, testConfig)); - pages.add(new BackUpToDrivePage(mUiDevice, testConfig)); pages.add(new GoogleServicesPage(mUiDevice, testConfig)); pages.add(new GoogleAppsDevicePolicyPage(mUiDevice, testConfig)); pages.add(new DeviceAccessPage(mUiDevice, testConfig)); pages.add(new SetupManagementPoPage(mUiDevice, testConfig)); - pages.add(new SetupYourProfilePage(mUiDevice, testConfig)); + pages.add(new TermsPage(mUiDevice, testConfig)); pages.add(new SetupFinishPage(mUiDevice, testConfig)); return pages; } diff --git a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/test/AfwTestUiWatcher.java b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/test/AfwTestUiWatcher.java index 8d940a9..0c26972 100644 --- a/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/test/AfwTestUiWatcher.java +++ b/libs/UiAutomatorLib/src/com/android/afwtest/uiautomator/test/AfwTestUiWatcher.java @@ -76,7 +76,7 @@ public final class AfwTestUiWatcher implements UiWatcher { * Words to match for "Accept" button's text or description. */ private static final String[] ACCEPT_WORDS = { - "accept", "agree", "allow", "close", "I agree", "yes"}; + "accept", "agree", "allow", "I agree", "yes"}; /** * {@link Pattern} to match any "Accept" word in {@link #ACCEPT_WORDS}. diff --git a/tests/NfcProvisioning/AndroidManifest.xml b/tests/NfcProvisioning/AndroidManifest.xml index bf814e8..5ba861d 100644 --- a/tests/NfcProvisioning/AndroidManifest.xml +++ b/tests/NfcProvisioning/AndroidManifest.xml @@ -19,6 +19,8 @@ <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> diff --git a/tests/QRCodeProvisioning/AndroidManifest.xml b/tests/QRCodeProvisioning/AndroidManifest.xml index fd7f94d..4f52706 100644 --- a/tests/QRCodeProvisioning/AndroidManifest.xml +++ b/tests/QRCodeProvisioning/AndroidManifest.xml @@ -19,6 +19,8 @@ <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> |