summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun <jjunwangg@google.com>2021-09-02 10:59:07 -0700
committerJun <jjunwangg@google.com>2021-09-02 11:10:43 -0700
commita16bf000acfe4590e4fb9d3109b6aecf3183c28d (patch)
tree13b612b21a6dea20d855fd6538c22b5243177edf
parent270825feda527c18b210b468fcc519ae6d4e4fb3 (diff)
downloadplatform_testing-a16bf000acfe4590e4fb9d3109b6aecf3183c28d.tar.gz
remove AccountSettingTest from AOSP
move to vendor repo Test: locally bug: 196497323 Change-Id: I00f7d1d4dd24dcd752377214296e6b9f85f0902b
-rw-r--r--libraries/automotive-helpers/settings-app-helper/src/android/platform/helpers/SettingAccountsHelperImpl.java181
-rw-r--r--tests/automotive/functional/settings/src/android/platform/tests/AccountSettingTest.java80
2 files changed, 0 insertions, 261 deletions
diff --git a/libraries/automotive-helpers/settings-app-helper/src/android/platform/helpers/SettingAccountsHelperImpl.java b/libraries/automotive-helpers/settings-app-helper/src/android/platform/helpers/SettingAccountsHelperImpl.java
deleted file mode 100644
index 2f938078d..000000000
--- a/libraries/automotive-helpers/settings-app-helper/src/android/platform/helpers/SettingAccountsHelperImpl.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2021 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 android.platform.helpers;
-
-import android.app.Instrumentation;
-import android.os.SystemClock;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.UiObject2;
-
-/** Implementation of {@link IAutoAccountsHelper} to support tests of account settings */
-public class SettingAccountsHelperImpl extends AbstractAutoStandardAppHelper
- implements IAutoAccountsHelper {
-
- // Wait Time
- private static final int UI_RESPONSE_WAIT_MS = 5000;
-
- public SettingAccountsHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /** {@inheritDoc} */
- @Override
- public String getPackage() {
- return getApplicationConfig(AutoConfigConstants.SETTINGS_PACKAGE);
- }
-
- /** {@inheritDoc} */
- @Override
- public void addAccount(String email, String password) {
- if (!doesEmailExist(email)) {
- goToSignInPage();
- inputAccount(email);
- inputPassowrd(password);
- UiObject2 doneButtonObject =
- scrollAndFindUiObject(
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.DONE_BUTTON));
- if (doneButtonObject == null) {
- throw new RuntimeException("Unable to find Done button.");
- }
- clickAndWaitForIdleScreen(doneButtonObject);
- }
- }
-
- private void goToSignInPage() {
- UiObject2 addAccountObject =
- scrollAndFindUiObject(
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.ADD_ACCOUNT));
- if (addAccountObject == null) {
- throw new RuntimeException("Unable to find Add Account button.");
- }
- clickAndWaitForIdleScreen(addAccountObject);
- UiObject2 signInOnCarScreen =
- scrollAndFindUiObject(
- By.clickable(true)
- .hasDescendant(
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.SIGN_IN_ON_CAR_SCREEN)));
- if (signInOnCarScreen == null) {
- throw new RuntimeException("Unable to find Sign In on Car Screen button.");
- }
- clickAndWaitForIdleScreen(signInOnCarScreen);
- scrollAndFindUiObject(
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.GOOGLE_SIGN_IN_SCREEN));
- }
-
- /** {@inheritDoc} */
- @Override
- public void removeAccount(String email) {
- if (doesEmailExist(email)) {
- BySelector accountSelector = By.text(email);
- UiObject2 accountObject =
- scrollAndFindUiObject(accountSelector, getScrollScreenIndex())
- .getParent()
- .getParent();
- clickAndWaitForIdleScreen(accountObject);
- UiObject2 removeButtonObject =
- scrollAndFindUiObject(
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.REMOVE_BUTTON));
- if (removeButtonObject == null) {
- throw new RuntimeException("Unable to find Remove button.");
- }
- clickAndWaitForIdleScreen(removeButtonObject);
- UiObject2 confirmObject =
- scrollAndFindUiObject(
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.REMOVE_ACCOUNT_BUTTON));
- if (removeButtonObject == null) {
- throw new RuntimeException("Unable to find Remove Account button.");
- }
- clickAndWaitForIdleScreen(confirmObject);
- waitForGone(accountSelector);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean doesEmailExist(String email) {
- UiObject2 accountObject = scrollAndFindUiObject(By.text(email), getScrollScreenIndex());
- return accountObject != null;
- }
-
- private int getScrollScreenIndex() {
- int scrollScreenIndex = 0;
- if (hasSplitScreenSettingsUI()) {
- scrollScreenIndex = 1;
- }
- return scrollScreenIndex;
- }
-
- private void inputAccount(String account) {
- inputText(account, false);
- }
-
- private void inputPassowrd(String password) {
- inputText(password, true);
- }
-
- private void inputText(String text, boolean isPassword) {
- BySelector selector =
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.ENTER_EMAIL);
- if (isPassword) {
- selector =
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.ENTER_PASSWORD);
- }
- UiObject2 input = scrollAndFindUiObject(selector);
- if (input == null) {
- throw new RuntimeException(
- String.format("%s input is not present", selector.toString()));
- }
- input.setText(text);
- scrollAndFindUiObject(By.text(text).focused(false));
- UiObject2 nextButtonObject =
- scrollAndFindUiObject(
- getResourceFromConfig(
- AutoConfigConstants.SETTINGS,
- AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS,
- AutoConfigConstants.NEXT_BUTTON));
- if (nextButtonObject == null) {
- throw new RuntimeException("Unable to find Next button.");
- }
- clickAndWaitForGone(nextButtonObject, By.text(text));
- SystemClock.sleep(UI_RESPONSE_WAIT_MS); // to avoid stale object error
- }
-}
diff --git a/tests/automotive/functional/settings/src/android/platform/tests/AccountSettingTest.java b/tests/automotive/functional/settings/src/android/platform/tests/AccountSettingTest.java
deleted file mode 100644
index ed0608b09..000000000
--- a/tests/automotive/functional/settings/src/android/platform/tests/AccountSettingTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2021 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 android.platform.tests;
-
-import android.platform.helpers.AutoConfigConstants;
-import android.platform.helpers.AutoUtility;
-import android.platform.helpers.HelperAccessor;
-import android.platform.helpers.IAutoAccountsHelper;
-import android.platform.helpers.IAutoSettingHelper;
-import android.platform.test.option.StringOption;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.BeforeClass;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-
-@RunWith(AndroidJUnit4.class)
-public class AccountSettingTest {
- private static final String ACCOUNT_EMAIL = "account-email";
- private static final String ACCOUNT_PASSWORD = "account-password";
-
- @ClassRule
- public static StringOption mAccountEmail = new StringOption(ACCOUNT_EMAIL).setRequired(true);
-
- @ClassRule
- public static StringOption mAccountPassword =
- new StringOption(ACCOUNT_PASSWORD).setRequired(true);
-
- private HelperAccessor<IAutoAccountsHelper> mAccountsHelper;
- private HelperAccessor<IAutoSettingHelper> mSettingHelper;
-
- public AccountSettingTest() {
- mAccountsHelper = new HelperAccessor<>(IAutoAccountsHelper.class);
- mSettingHelper = new HelperAccessor<>(IAutoSettingHelper.class);
- }
-
- @BeforeClass
- public static void exitSuw() {
- AutoUtility.exitSuw();
- }
-
- @Before
- public void openAccountsFacet() {
- mSettingHelper.get().openSetting(AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS);
- }
-
- @After
- public void goBackToHomeScreen() {
- mSettingHelper.get().goBackToSettingsScreen();
- }
-
- @Test
- public void testAddRemoveAccount() {
- mAccountsHelper.get().addAccount(mAccountEmail.get(), mAccountPassword.get());
- mSettingHelper.get().openSetting(AutoConfigConstants.PROFILE_ACCOUNT_SETTINGS);
- assertTrue(mAccountsHelper.get().doesEmailExist(mAccountEmail.get()));
- mAccountsHelper.get().removeAccount(mAccountEmail.get());
- assertFalse(mAccountsHelper.get().doesEmailExist(mAccountEmail.get()));
- }
-}