summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Rosenfeld <mrosenfeld@google.com>2016-09-07 14:30:25 -0700
committerMichael Rosenfeld <mrosenfeld@google.com>2016-09-07 16:41:12 -0700
commit9e583abfa69ce2c5756d51f160dd541662d6807d (patch)
treec16e03cccfc295bc96d3b57a0730498bd5d2d1a5
parent1dd7bb7a1422eab46b23b30e74ef14ab1d8d3e00 (diff)
downloadplatform_testing-9e583abfa69ce2c5756d51f160dd541662d6807d.tar.gz
Remove items now in vendor/google_testing/integration
Change-Id: I59a1e26c529f39fd33a0b718c04de7424113e41e
-rw-r--r--libraries/first-party-app-helpers/handheld/Android.mk31
-rw-r--r--libraries/first-party-app-helpers/handheld/chrome-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/chrome-app-helper/src/android/platform/test/helpers/ChromeHelperImpl.java307
-rw-r--r--libraries/first-party-app-helpers/handheld/gmail-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/gmail-app-helper/src/android/platform/test/helpers/GmailHelperImpl.java654
-rw-r--r--libraries/first-party-app-helpers/handheld/google-app-camera-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/google-app-camera-helper/src/android/platform/test/helpers/GoogleCameraHelperImpl.java1380
-rw-r--r--libraries/first-party-app-helpers/handheld/google-docs-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/google-docs-app-helper/src/android/platform/test/helpers/GoogleDocsHelperImpl.java178
-rw-r--r--libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/src/android/platform/test/helpers/GoogleKeyboardHelperImpl.java366
-rw-r--r--libraries/first-party-app-helpers/handheld/google-messenger-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/google-messenger-app-helper/src/android/platform/test/helpers/GoogleMessengerHelperImpl.java275
-rw-r--r--libraries/first-party-app-helpers/handheld/maps-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/maps-app-helper/src/android/platform/test/helpers/MapsHelperImpl.java369
-rw-r--r--libraries/first-party-app-helpers/handheld/photos-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/photos-app-helper/src/android/platform/test/helpers/PhotosHelperImpl.java509
-rw-r--r--libraries/first-party-app-helpers/handheld/play-books-app-helper/Android.mk24
-rw-r--r--libraries/first-party-app-helpers/handheld/play-books-app-helper/src/android/platform/test/helpers/PlayBooksHelperImpl.java280
-rw-r--r--libraries/first-party-app-helpers/handheld/play-movies-app-helper/Android.mk24
-rw-r--r--libraries/first-party-app-helpers/handheld/play-movies-app-helper/src/android/platform/test/helpers/PlayMoviesHelperImpl.java215
-rw-r--r--libraries/first-party-app-helpers/handheld/play-music-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/play-music-app-helper/src/android/platform/test/helpers/PlayMusicHelperImpl.java360
-rw-r--r--libraries/first-party-app-helpers/handheld/play-store-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/play-store-app-helper/src/android/platform/test/helpers/PlayStoreHelperImpl.java229
-rw-r--r--libraries/first-party-app-helpers/handheld/recents-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/recents-app-helper/src/android/platform/test/helpers/RecentsHelperImpl.java102
-rw-r--r--libraries/first-party-app-helpers/handheld/settings-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/settings-app-helper/src/android/platform/test/helpers/SettingsHelperImpl.java218
-rw-r--r--libraries/first-party-app-helpers/handheld/youtube-app-helper/Android.mk23
-rw-r--r--libraries/first-party-app-helpers/handheld/youtube-app-helper/src/android/platform/test/helpers/YouTubeHelperImpl.java493
-rw-r--r--libraries/first-party-app-helpers/tv/Android.mk29
-rw-r--r--libraries/first-party-app-helpers/tv/leanback-demo-app-helper/Android.mk24
-rw-r--r--libraries/first-party-app-helpers/tv/leanback-demo-app-helper/src/android/platform/test/helpers/tv/LeanbackDemoHelperImpl.java212
-rw-r--r--libraries/first-party-app-helpers/tv/play-movies-app-helper/Android.mk24
-rw-r--r--libraries/first-party-app-helpers/tv/play-movies-app-helper/src/android/platform/test/helpers/tv/PlayMoviesHelperImpl.java318
-rw-r--r--libraries/first-party-app-helpers/tv/search-app-helper/Android.mk24
-rw-r--r--libraries/first-party-app-helpers/tv/search-app-helper/src/android/platform/test/helpers/tv/SearchHelperImpl.java110
-rw-r--r--libraries/first-party-app-helpers/tv/sysui-app-helper/Android.mk24
-rw-r--r--libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/NoTouchAuthHelperImpl.java184
-rw-r--r--libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiPipHelperImpl.java297
-rw-r--r--libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiRecentsHelperImpl.java273
-rw-r--r--libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiSettingsHelperImpl.java486
-rw-r--r--libraries/first-party-app-helpers/tv/youtube-app-helper/Android.mk24
-rw-r--r--libraries/first-party-app-helpers/tv/youtube-app-helper/src/android/platform/test/helpers/tv/YouTubeHelperImpl.java389
-rw-r--r--libraries/third-party-app-helpers/Android.mk27
-rw-r--r--libraries/third-party-app-helpers/facebook-app-helper/Android.mk23
-rw-r--r--libraries/third-party-app-helpers/facebook-app-helper/src/android/platform/test/helpers/FacebookHelperImpl.java285
-rw-r--r--libraries/third-party-app-helpers/flightdemo-app-helper/Android.mk23
-rw-r--r--libraries/third-party-app-helpers/flightdemo-app-helper/src/android/platform/test/helpers/FlightDemoHelperImpl.java123
-rw-r--r--libraries/third-party-app-helpers/reddit-app-helper/Android.mk23
-rw-r--r--libraries/third-party-app-helpers/reddit-app-helper/src/android/platform/test/helpers/RedditHelperImpl.java143
-rw-r--r--libraries/third-party-app-helpers/tunein-app-helper/Android.mk23
-rw-r--r--libraries/third-party-app-helpers/tunein-app-helper/src/android/platform/test/helpers/TuneInHelperImpl.java191
-rw-r--r--tests/androidbvt/Android.mk39
-rw-r--r--tests/androidbvt/AndroidManifest.xml69
-rw-r--r--tests/androidbvt/apps/Android.mk31
-rw-r--r--tests/androidbvt/apps/AndroidManifest.xml50
-rw-r--r--tests/androidbvt/apps/src/com/android/androidbvt/apps/GmailTest.java76
-rw-r--r--tests/androidbvt/apps/src/com/android/androidbvt/apps/MediaCaptureTests.java132
-rw-r--r--tests/androidbvt/hermetic/Android.mk28
-rw-r--r--tests/androidbvt/hermetic/AndroidManifest.xml46
-rw-r--r--tests/androidbvt/res/drawable-xhdpi/stat_notify_email.pngbin1055 -> 0 bytes
-rw-r--r--tests/androidbvt/res/layout/surface_view.xml46
-rw-r--r--tests/androidbvt/res/raw/bbb.mkvbin1968745 -> 0 bytes
-rw-r--r--tests/androidbvt/sim/Android.mk33
-rw-r--r--tests/androidbvt/sim/AndroidManifest.xml37
-rw-r--r--tests/androidbvt/sim/src/com/android/androidbvt/sim/ConnectivityWithSimTests.java210
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/AndroidBvtHelper.java505
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/ConnectivityWifiTests.java166
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/FrameworkBackupRestoreTests.java155
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/FrameworkDownloadTests.java209
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/FrameworkIMETests.java135
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/MediaPlaybackTests.java109
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/PackageAddedBroadcastReceiver.java53
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/PlayStoreDownloadTests.java105
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysBugReportTests.java128
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysMediaTests.java55
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysPowerTests.java79
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysSettingTests.java454
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysUIGSATests.java219
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysUILauncherTests.java267
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysUILockScreenTests.java457
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysUIMultiUserTests.java127
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysUIMultiWindowTests.java188
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/SysUINotificationShadeTests.java280
-rw-r--r--tests/androidbvt/src/com/android/androidbvt/app/MediaPlaybackTestApp.java40
-rw-r--r--tests/functional/app-helper/Android.mk26
-rw-r--r--tests/functional/app-helper/AndroidManifest.xml33
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/BaseHelperTest.java71
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/ChromeHelperTest.java94
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/GmailHelperTest.java137
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleCameraHelperTest.java117
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleKeyboardHelperTest.java91
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/MapsHelperTest.java88
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayMoviesHelperTest.java67
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayMusicHelperTest.java67
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayStoreHelperTest.java93
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/RecentsHelperTest.java72
-rw-r--r--tests/functional/app-helper/src/android/platform/test/helpers/tests/YouTubeHelperTest.java67
-rw-r--r--tests/functional/externalstorage/Android.mk15
-rw-r--r--tests/functional/externalstorage/AndroidManifest.xml31
-rw-r--r--tests/functional/externalstorage/src/com/android/functional/externalstoragetests/AdoptableStorageTests.java215
-rw-r--r--tests/functional/externalstorage/src/com/android/functional/externalstoragetests/ExternalStorageHelper.java288
-rw-r--r--tests/functional/externalstorage/src/com/android/functional/externalstoragetests/PortableStorageTests.java258
-rw-r--r--tests/functional/settingstests/Android.mk31
-rw-r--r--tests/functional/settingstests/AndroidManifest.xml36
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/AboutPhoneSettingsTests.java217
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/AccessibilitySettingsTests.java247
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/BluetoothNetworkSettingsTests.java160
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/DataUsageSettingsTests.java84
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/DisplaySettingsTest.java267
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/LocationSettingsTests.java217
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/MainSettingsLargeTests.java114
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/MainSettingsTests.java158
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/MoreWirelessSettingsTests.java147
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/QuickSettingsTest.java332
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/SettingsHelper.java140
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/SoundSettingsTest.java314
-rw-r--r--tests/functional/settingstests/src/com/android/settings/functional/WirelessNetworkSettingsTests.java757
-rw-r--r--tests/functional/tv/TvSysUiTests/Android.mk28
-rw-r--r--tests/functional/tv/TvSysUiTests/AndroidManifest.xml36
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/SysUiTestBase.java149
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/TestSetupInstrumentation.java126
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/UiWatchers.java112
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/AccessibilitySettingsTests.java170
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/AccountTests.java351
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MainSettingsTests.java140
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MultiUserInRestrictedProfileTests.java229
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MultiUserTests.java158
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/TestAll.java33
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/HomeScreenTests.java66
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/PipActivityTests.java406
-rw-r--r--tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/RecentActivityTests.java187
-rw-r--r--tests/functional/tv/YouTubeTests/Android.mk27
-rw-r--r--tests/functional/tv/YouTubeTests/AndroidManifest.xml34
-rw-r--r--tests/functional/tv/YouTubeTests/src/android/test/functional/tv/youtube/YouTubeTests.java146
-rw-r--r--tests/jank/sysapp/Android.mk27
-rw-r--r--tests/jank/sysapp/AndroidManifest.xml33
-rw-r--r--tests/jank/sysapp/src/com/android/sysapp/janktests/BooksJankTests.java163
-rw-r--r--tests/jank/sysapp/src/com/android/sysapp/janktests/CalendarJankTests.java158
-rw-r--r--tests/jank/sysapp/src/com/android/sysapp/janktests/ChromeJankTests.java121
-rw-r--r--tests/jank/sysapp/src/com/android/sysapp/janktests/ContactsJankTests.java124
-rw-r--r--tests/jank/sysapp/src/com/android/sysapp/janktests/GMailJankTests.java218
-rw-r--r--tests/jank/sysapp/src/com/android/sysapp/janktests/YouTubeJankTests.java146
-rw-r--r--utils/dialogs/Android.mk27
-rw-r--r--utils/dialogs/AndroidManifest.xml33
-rw-r--r--utils/dialogs/src/com/android/dialogutils/DismissDialogsInstrumentation.java273
148 files changed, 0 insertions, 22892 deletions
diff --git a/libraries/first-party-app-helpers/handheld/Android.mk b/libraries/first-party-app-helpers/handheld/Android.mk
deleted file mode 100644
index feee8ea3e..000000000
--- a/libraries/first-party-app-helpers/handheld/Android.mk
+++ /dev/null
@@ -1,31 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := first-party-app-helpers
-LOCAL_STATIC_JAVA_LIBRARIES := launcher-helper-lib base-app-helpers google-camera-app-helper \
- youtube-app-helper photos-app-helper play-music-app-helper \
- chrome-app-helper play-store-app-helper play-movies-app-helper \
- gmail-app-helper maps-app-helper recents-app-helper \
- google-keyboard-app-helper google-messenger-app-helper \
- play-books-app-helper google-docs-app-helper settings-app-helper
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-######################################
-
-include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/libraries/first-party-app-helpers/handheld/chrome-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/chrome-app-helper/Android.mk
deleted file mode 100644
index 7f0c1d046..000000000
--- a/libraries/first-party-app-helpers/handheld/chrome-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := chrome-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/chrome-app-helper/src/android/platform/test/helpers/ChromeHelperImpl.java b/libraries/first-party-app-helpers/handheld/chrome-app-helper/src/android/platform/test/helpers/ChromeHelperImpl.java
deleted file mode 100644
index 25d87559b..000000000
--- a/libraries/first-party-app-helpers/handheld/chrome-app-helper/src/android/platform/test/helpers/ChromeHelperImpl.java
+++ /dev/null
@@ -1,307 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.os.SystemClock;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-import android.webkit.WebView;
-import android.widget.ListView;
-
-import java.io.IOException;
-
-public class ChromeHelperImpl extends AbstractChromeHelper {
- private static final String LOG_TAG = ChromeHelperImpl.class.getSimpleName();
-
- private static final String UI_MENU_BUTTON_ID = "menu_button";
- private static final String UI_SEARCH_BOX_ID = "search_box_text";
- private static final String UI_URL_BAR_ID = "url_bar";
- private static final String UI_VIEW_HOLDER_ID = "compositor_view_holder";
- private static final String UI_POSITIVE_BUTTON_ID = "positive_button";
- private static final String UI_NEGATIVE_BUTTON_ID = "negative_button";
-
- private static final long APP_INIT_WAIT = 10000;
- private static final long MAX_DIALOG_TRANSITION = 5000;
- private static final long PAGE_LOAD_TIMEOUT = 30 * 1000;
- private static final long ANIMATION_TIMEOUT = 3000;
-
- private String mPackageName;
- private String mLauncherName;
-
- public ChromeHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- if (mPackageName == null) {
- String prop = null;
- try {
- mDevice.executeShellCommand("getprop dev.chrome.package");
- } catch (IOException ioe) {
- // log but ignore
- Log.e(LOG_TAG, "IOException while getprop", ioe);
- }
- if (prop == null || prop.isEmpty()) {
- prop = "com.android.chrome";
- }
- mPackageName = prop;
- }
- return mPackageName;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- if (mLauncherName == null) {
- String prop = null;
- try {
- mDevice.executeShellCommand("getprop dev.chrome.name");
- } catch (IOException ioe) {
- // log but ignore
- Log.e(LOG_TAG, "IOException while getprop", ioe);
- }
- if (prop == null || prop.isEmpty()) {
- prop = "Chrome";
- }
- mLauncherName = prop;
- }
- return mLauncherName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- // Terms of Service
- UiObject2 tos = mDevice.wait(Until.findObject(By.res(getPackage(), "terms_accept")),
- APP_INIT_WAIT);
- if (tos != null) {
- tos.click();
- }
-
- if (!hasAccountRegistered()) {
- // Device has no accounts registered that Chrome recognizes
- // Select negative button to skip setup wizard sign in
- UiObject2 negative = mDevice.wait(Until.findObject(
- By.res(getPackage(), UI_NEGATIVE_BUTTON_ID)), MAX_DIALOG_TRANSITION);
-
- if (negative != null) {
- negative.click();
- }
- } else {
- // Device has an account registered that Chrome recognizes
- // Press positive buttons until through setup wizard
- for (int i = 0; i < 4; i++) {
- if (!isInSetupWizard()) {
- break;
- }
-
- UiObject2 positive = mDevice.wait(Until.findObject(
- By.res(getPackage(), UI_POSITIVE_BUTTON_ID)), MAX_DIALOG_TRANSITION);
- if (positive != null) {
- positive.click();
- }
- }
- }
-
- mDevice.wait(Until.findObject(By.res(getPackage(), UI_SEARCH_BOX_ID)),
- MAX_DIALOG_TRANSITION);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openUrl(String url) {
- UiObject2 urlBar = getUrlBar();
- if (urlBar == null) {
- throw new IllegalStateException("Failed to detect a URL bar");
- }
-
- mDevice.waitForIdle();
- urlBar.setText(url);
- mDevice.pressEnter();
- waitForPageLoad();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void flingPage(Direction dir) {
- UiObject2 page = getWebPage();
- if (page != null) {
- int minDim = Math.min(
- page.getVisibleBounds().width(), page.getVisibleBounds().height());
- page.setGestureMargin((int)Math.floor(minDim * 0.25));
- page.fling(dir);
- } else {
- Log.e(LOG_TAG, String.format("Failed to fling page %s", dir.toString()));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openMenu() {
- UiObject2 menuButton = null;
- for (int retries = 2; retries > 0; retries--) {
- menuButton = mDevice.findObject(By.desc("More options"));
- if (menuButton == null) {
- flingPage(Direction.UP);
- } else {
- break;
- }
- }
-
- if (menuButton == null) {
- throw new IllegalStateException("Unable to find menu button.");
- }
- menuButton.clickAndWait(Until.newWindow(), 5000);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void mergeTabs() {
- openSettings();
- mDevice.findObject(By.text("Merge tabs and apps")).click();
- if (mDevice.findObject(By.text("On")) != null) {
- // Merge tabs is already on
- mDevice.pressBack();
- mDevice.pressBack();
- } else {
- mDevice.findObject(By.res(getPackage(), "switch_widget")).click();
- mDevice.findObject(By.text("OK")).click();
- }
- SystemClock.sleep(5000);
- waitForPageLoad();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void unmergeTabs() {
- openSettings();
- mDevice.findObject(By.text("Merge tabs and apps")).click();
- if (mDevice.findObject(By.text("Off")) != null) {
- // Merge tabs is already off
- mDevice.pressBack();
- mDevice.pressBack();
- } else {
- mDevice.findObject(By.res(getPackage(), "switch_widget")).click();
- mDevice.findObject(By.text("OK")).click();
- }
- SystemClock.sleep(5000);
- waitForPageLoad();
- }
-
- private void openSettings() {
- openMenu();
- UiObject2 menu = getMenu();
- // TODO: Change this to be non-constant
- menu.setGestureMargin(500);
- menu.scroll(Direction.DOWN, 1.0f);
- // Open the Settings menu
- mDevice.findObject(By.desc("Settings")).clickAndWait(Until.newWindow(), 3000);
- }
-
- private UiObject2 getWebPage() {
- mDevice.waitForIdle();
-
- UiObject2 webView = mDevice.findObject(By.clazz(WebView.class));
- if (webView != null) {
- return webView;
- }
-
- UiObject2 viewHolder = mDevice.findObject(
- By.res(getPackage(), UI_VIEW_HOLDER_ID));
- return viewHolder;
- }
-
- private UiObject2 getUrlBar() {
- // First time, URL bar is has id SEARCH_BOX_ID
- UiObject2 urlLoc = mDevice.findObject(By.res(getPackage(), UI_SEARCH_BOX_ID));
- if (urlLoc != null) {
- urlLoc.click();
- // Waits for the animation to complete.
- mDevice.wait(Until.findObject(By.res(getPackage(), UI_URL_BAR_ID)), ANIMATION_TIMEOUT);
- }
-
- // Afterwards, URL bar has id URL_BAR_ID; must re-select
- for (int retries = 2; retries > 0; retries--) {
- urlLoc = mDevice.findObject(By.res(getPackage(), UI_URL_BAR_ID));
- if (urlLoc == null) {
- flingPage(Direction.UP);
- } else {
- break;
- }
- }
-
- if (urlLoc != null) {
- urlLoc.click();
- } else {
- throw new IllegalStateException("Failed to find a URL bar.");
- }
-
- return urlLoc;
- }
-
- private UiObject2 getMenu() {
- return mDevice.findObject(By.clazz(ListView.class).pkg(getPackage()));
- }
-
- private void waitForPageLoad() {
- mDevice.waitForIdle();
- if (mDevice.hasObject(By.desc("Stop page loading"))) {
- mDevice.wait(Until.gone(By.desc("Stop page loading")), PAGE_LOAD_TIMEOUT);
- } else if (mDevice.hasObject(By.res(getPackage(), "progress"))) {
- mDevice.wait(Until.gone(By.res(getPackage(), "progress")), PAGE_LOAD_TIMEOUT);
- }
- }
-
- private boolean isInSetupWizard() {
- return mDevice.hasObject(By.res(getPackage(), "fre_pager"));
- }
-
- private boolean hasAccountRegistered() {
- boolean addAcountTextPresent = mDevice.wait(Until.hasObject(By.textStartsWith("Add an " +
- "account")), MAX_DIALOG_TRANSITION);
-
- UiObject2 next = mDevice.wait(Until.findObject(
- By.res(getPackage(), UI_POSITIVE_BUTTON_ID)), MAX_DIALOG_TRANSITION);
- boolean signInButtonPresent = next != null && "SIGN IN".equals(next.getText());
-
- // If any of theese elements is present, then there is no account registered.
- return !addAcountTextPresent && !signInButtonPresent;
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/gmail-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/gmail-app-helper/Android.mk
deleted file mode 100644
index d9db92c72..000000000
--- a/libraries/first-party-app-helpers/handheld/gmail-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := gmail-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/gmail-app-helper/src/android/platform/test/helpers/GmailHelperImpl.java b/libraries/first-party-app-helpers/handheld/gmail-app-helper/src/android/platform/test/helpers/GmailHelperImpl.java
deleted file mode 100644
index 98482c282..000000000
--- a/libraries/first-party-app-helpers/handheld/gmail-app-helper/src/android/platform/test/helpers/GmailHelperImpl.java
+++ /dev/null
@@ -1,654 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.Configuration;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-import android.webkit.WebView;
-import android.widget.ListView;
-import android.widget.ImageButton;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.regex.Pattern;
-
-public class GmailHelperImpl extends AbstractGmailHelper {
- private static final String LOG_TAG = GmailHelperImpl.class.getSimpleName();
-
- private static final long APP_INIT_WAIT = 10000;
- private static final long DIALOG_TIMEOUT = 5000;
- private static final long POPUP_TIMEOUT = 7500;
- private static final long COMPOSE_TIMEOUT = 10000;
- private static final long SEND_TIMEOUT = 10000;
- private static final long LOADING_TIMEOUT = 25000;
- private static final long LOAD_EMAIL_TIMEOUT = 20000;
- private static final long WIFI_TIMEOUT = 60 * 1000;
- private static final long RELOAD_INBOX_TIMEOUT = 10 * 1000;
- private static final long COMPOSE_EMAIL_TIMEOUT = 10 * 1000;
-
- private static final String UI_ATTACHMENT_TILE_SAVE_ID = "attachment_tile_save";
- private static final String UI_NAME_ID = "name";
- private static final String UI_PACKAGE_NAME = "com.google.android.gm";
- private static final String UI_PROMO_ACTION_NEG_RES = "promo_action_negative_single_line";
- private static final String UI_CONVERSATIONS_LIST_ID = "conversation_list_view";
- private static final String UI_CONVERSATION_LIST_LOADING_VIEW_ID =
- "conversation_list_loading_view";
- private static final String UI_CONVERSATION_PAGER = "conversation_pager";
- private static final String UI_MULTI_PANE_CONTAINER_ID = "two_pane_activity";
- private static final BySelector PRIMARY_SELECTOR =
- By.res(UI_PACKAGE_NAME, "name").text("Primary");
- private static final BySelector INBOX_SELECTOR =
- By.res(UI_PACKAGE_NAME, "name").text("Inbox");
- private static final BySelector NAV_DRAWER_SELECTOR = By.res("android", "list").focused(true);
-
- public GmailHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.gm";
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Gmail";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- // Check for the first, option dialog dismissal screen
- if (mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, "welcome_tour_pager")),
- APP_INIT_WAIT)) {
- // Dismiss "New in Gmail" with GOT IT button or "Wecome to Gmail" with > button
- BySelector gotItSelector = By.res(UI_PACKAGE_NAME, "welcome_tour_got_it");
- BySelector skipSelector = By.res(UI_PACKAGE_NAME, "welcome_tour_skip");
- if (mDevice.hasObject(gotItSelector)) {
- mDevice.findObject(gotItSelector).clickAndWait(Until.newWindow(), DIALOG_TIMEOUT);
- } else if (mDevice.hasObject(skipSelector)) {
- mDevice.findObject(skipSelector).clickAndWait(Until.newWindow(), DIALOG_TIMEOUT);
- }
- } else {
- Log.e(LOG_TAG, "Unable to find initial screen. Continuing anyway.");
- }
- // Dismiss "Add another email address" with TAKE ME TO GMAIL button
- UiObject2 tutorialDone = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, "action_done")), DIALOG_TIMEOUT);
- if (tutorialDone != null) {
- tutorialDone.clickAndWait(Until.newWindow(), DIALOG_TIMEOUT);
- }
- // Dismiss dogfood confidentiality dialog with OK, GOT IT button
- Pattern gotItWord = Pattern.compile("OK, GOT IT", Pattern.CASE_INSENSITIVE);
- UiObject2 splash = mDevice.wait(Until.findObject(By.text(gotItWord)), DIALOG_TIMEOUT);
- if (splash != null) {
- splash.clickAndWait(Until.newWindow(), DIALOG_TIMEOUT);
- }
- // Wait for "Getting your messages" to disappear
- if (mDevice.findObject(By.textContains("Getting your messages")) != null) {
- if (!mDevice.wait(Until.gone(By.text("Getting your messages")), WIFI_TIMEOUT)) {
- throw new UnknownUiException(
- "Timed out waiting for 'Getting your messages' to disappear");
- }
- }
- if (!mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_CONVERSATIONS_LIST_ID)), WIFI_TIMEOUT)) {
- throw new UnknownUiException("Timed out waiting for conversation list to appear");
- }
- // Dismiss "Tap a sender image" dialog
- UiObject2 senderImageDismissButton =
- mDevice.findObject(By.res(UI_PACKAGE_NAME, "dismiss_icon"));
- if (senderImageDismissButton != null) {
- senderImageDismissButton.click();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToInbox() {
- // Check if already in Inbox or Primary
- if (isInPrimaryOrInbox()) {
- return;
- }
-
- if (isMultiPaneActivity()) {
- // Select for the closed Primary icon
- UiObject2 primaryClosed = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, "image_view").text("Primary"));
- if (primaryClosed != null) {
- primaryClosed.click();
- mDevice.waitForIdle();
- return;
- }
-
- // Select for the closed Inbox icon
- UiObject2 inboxClosed = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, "image_view").text("Inbox"));
- if (inboxClosed != null) {
- inboxClosed.click();
- mDevice.waitForIdle();
- return;
- }
-
- scrollNavigationDrawer(Direction.UP);
-
- // Select for the open Primary icon
- UiObject2 primaryOpen = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, "name").text("Primary"));
- if (primaryOpen != null) {
- primaryOpen.click();
- mDevice.waitForIdle();
- return;
- }
-
- // Select for the open Inbox icon
- UiObject2 inboxOpen = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, "name").text("Inbox"));
- if (inboxOpen != null) {
- inboxOpen.click();
- mDevice.waitForIdle();
- return;
- }
-
- // Currently unhandled case; throw Exception.
- throw new RuntimeException("Unable to find method to get to Primary/Inbox");
- } else {
- // Simply press back if in a conversation
- if (isInConversation()) {
- mDevice.pressBack();
- waitForConversationsList();
- }
-
- // If in another e-mail sub-folder, go to Primary or Inbox
- if (!isInPrimaryOrInbox()) {
- // Search with the navigation drawer
- openNavigationDrawer();
-
- // Select for "Primary" and for "Inbox"
- UiObject2 primaryInboxSelector = mDevice.findObject(PRIMARY_SELECTOR);
- if (primaryInboxSelector == null) {
- primaryInboxSelector = mDevice.findObject(INBOX_SELECTOR);
- }
-
- primaryInboxSelector.click();
- waitForConversationsList();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToComposeEmail() {
- if (!isInPrimaryOrInbox()) {
- throw new IllegalStateException("Gmail is not on the Inbox or Primary page");
- }
- UiObject2 compose = mDevice.findObject(By.desc("Compose"));
- if (compose == null) {
- throw new UnknownUiException("Compose button not found");
- }
- compose.clickAndWait(Until.newWindow(), COMPOSE_TIMEOUT);
- waitForCompose();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openEmailByIndex(int index) {
- if (!isInMailbox()) {
- throw new IllegalStateException("Must be in a mailbox to open an email by index");
- }
-
- if (index >= getVisibleEmailCount()) {
- throw new IllegalArgumentException(String.format("Cannot select %s'th message of %s",
- (index + 1), getVisibleEmailCount()));
- }
-
- // Select an e-mail by index
- UiObject2 conversationList = getConversationList();
- List<UiObject2> emails = conversationList.findObjects(
- By.clazz(android.widget.FrameLayout.class));
- if (conversationList == null) {
- throw new UnknownUiException("No e-mails found.");
- }
- emails.get(index).click();
-
- // Wait until the e-mail is open
- UiObject2 loadMsg = mDevice.findObject(By.res(UI_PACKAGE_NAME, "loading_progress"));
- if (loadMsg != null) {
- if (!mDevice.wait(Until.gone(
- By.res(UI_PACKAGE_NAME, "loading_progress")), LOADING_TIMEOUT)) {
- throw new RuntimeException("Loading message timed out after 20s");
- }
- }
-
- waitForConversation();
- }
- /**
- * {@inheritDoc}
- */
- @Override
- public int getVisibleEmailCount() {
- if (!isInMailbox()) {
- throw new IllegalStateException("Must be in a mailbox to open an email by index");
- }
-
- return getConversationList().getChildCount();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void sendReplyEmail(String address, String body) {
- if (!isInConversation()) {
- throw new IllegalStateException("Must have an e-mail open to send a reply.");
- }
-
- UiObject2 convScroll = getConversationPager();
- while(convScroll.scroll(Direction.DOWN, 1.0f));
-
- UiObject2 replyButton = mDevice.findObject(By.text("Reply"));
- if (replyButton != null) {
- replyButton.clickAndWait(Until.newWindow(), COMPOSE_TIMEOUT);
- waitForCompose();
- } else {
- throw new UnknownUiException("Failed to find a 'Reply' button.");
- }
-
- // Set the necessary fields (address and body)
- setEmailToAddress(address);
- setEmailBody(body);
-
- // Send the reply e-mail and wait for original e-mail
- clickSendButton();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEmailToAddress(String address) {
- UiObject2 convScroll = getComposeScrollContainer();
- while (convScroll.scroll(Direction.UP, 1.0f));
-
- UiObject2 toField = getToField();
- for (int retries = 5; retries > 0 && toField == null; retries--) {
- convScroll.scroll(Direction.DOWN, 1.0f);
- toField = getToField();
- }
-
- if (toField != null) {
- toField.setText(address);
- } else {
- throw new UnknownUiException("Failed to find a 'To' field.");
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEmailSubject(String subject) {
- UiObject2 convScroll = getComposeScrollContainer();
- while (convScroll.scroll(Direction.UP, 1.0f));
-
- UiObject2 subjectField = getSubjectField();
- for (int retries = 5; retries > 0 && subjectField == null; retries--) {
- convScroll.scroll(Direction.DOWN, 1.0f);
- subjectField = getSubjectField();
- }
-
- if (subjectField != null) {
- subjectField.setText(subject);
- } else {
- throw new UnknownUiException("Failed to find a 'Subject' field.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEmailBody(String body) {
- UiObject2 convScroll = getComposeScrollContainer();
- while (convScroll.scroll(Direction.UP, 1.0f));
-
- UiObject2 bodyField = getBodyField();
- for (int retries = 5; retries > 0 && bodyField == null; retries--) {
- convScroll.scroll(Direction.DOWN, 1.0f);
- bodyField = getBodyField();
- }
-
- if (bodyField != null) {
- // Ensure the focus is left in the body field.
- bodyField.click();
- bodyField.setText(body);
- } else {
- throw new UnknownUiException("Failed to find a 'Body' field.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void clickSendButton() {
- UiObject2 convScroll = getComposeScrollContainer();
- while (convScroll.scroll(Direction.UP, 1.0f));
-
- UiObject2 sendButton = getSendButton();
- if (sendButton != null) {
- sendButton.clickAndWait(Until.newWindow(), SEND_TIMEOUT);
- waitForConversation();
- } else {
- throw new UnknownUiException("Failed to find a 'Send' button.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getComposeEmailBody(){
- UiObject2 bodyField = getBodyField();
- return bodyField.getText();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openNavigationDrawer() {
- for (int retries = 3; retries > 0; retries--) {
- if (isNavDrawerOpen()) {
- return;
- }
-
- UiObject2 nav = mDevice.findObject(By.desc(Pattern.compile(
- "(Open navigation drawer)|(Navigate up)")));
-
- if (nav == null) {
- throw new IllegalStateException("Could not find navigation drawer");
- }
- nav.click();
- mDevice.waitForIdle();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollNavigationDrawer(Direction dir) {
- if (dir == Direction.RIGHT || dir == Direction.LEFT) {
- throw new IllegalArgumentException("Can only scroll navigation drawer up and down.");
- }
-
- UiObject2 scroll = getNavDrawerContainer();
- if (scroll == null) {
- throw new UnknownUiException("No navigation drawer found to scroll");
- }
- scroll.scroll(dir, 1.0f);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean closeNavigationDrawer() {
- UiObject2 navDrawer = mDevice.wait(Until.findObject(
- By.clazz(ImageButton.class).desc("Close navigation drawer")), 1000);
- if (navDrawer != null) {
- navDrawer.click();
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isInComposeEmail(){
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, "compose")) != null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isInPrimaryOrInbox() {
- if (isMultiPaneActivity()) {
- return (mDevice.hasObject(By.res(UI_PACKAGE_NAME, "actionbar_title").text("Primary")) ||
- mDevice.hasObject(By.res(UI_PACKAGE_NAME, "actionbar_title").text("Inbox")));
- } else {
- return getConversationList() != null &&
- (mDevice.hasObject(By.text("Primary")) ||
- mDevice.hasObject(By.text("Inbox")));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollMailbox(Direction direction, float amount, boolean scrollToEnd) {
- if (!isInMailbox()) {
- throw new IllegalStateException("Not in mailbox");
- }
-
- if (!(Direction.UP.equals(direction) || Direction.DOWN.equals(direction))) {
- throw new IllegalArgumentException("Scroll direction must be UP or DOWN");
- }
-
- UiObject2 scrollContainer = getConversationList();
- if (scrollContainer == null) {
- throw new IllegalStateException("Could not find scroll container");
- }
-
- scroll(scrollContainer, direction, amount, scrollToEnd);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollEmail(Direction direction, float amount, boolean scrollToEnd) {
- if (!(Direction.UP.equals(direction) || Direction.DOWN.equals(direction))) {
- throw new IllegalArgumentException("Scroll direction must be UP or DOWN");
- }
-
- UiObject2 scrollContainer = getConversationPager();
- if (scrollContainer == null) {
- throw new IllegalStateException("Could not find email scroll container");
- }
-
- scroll(scrollContainer, direction, amount, scrollToEnd);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openMailbox(String mailboxName) {
- if (!isNavDrawerOpen()) {
- throw new IllegalStateException("Navigation drawer is not open");
- }
-
- UiObject2 mailbox = null;
- for (int scrollsRemaining = 5; scrollsRemaining > 0; --scrollsRemaining) {
- mailbox = mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_NAME_ID).text(
- Pattern.compile(mailboxName, Pattern.CASE_INSENSITIVE)));
- if (mailbox != null) {
- break;
- } else {
- scrollNavigationDrawer(Direction.DOWN);
- }
- }
- if (mailbox == null) {
- throw new IllegalArgumentException(
- String.format("Could not find mailbox '%s'", mailboxName));
- }
- mailbox.click();
- mDevice.waitForIdle();
- mDevice.wait(Until.gone(
- By.res(UI_PACKAGE_NAME, UI_CONVERSATION_LIST_LOADING_VIEW_ID)), WIFI_TIMEOUT);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void returnToMailbox() {
- for (int retriesRemaining = 5; retriesRemaining > 0; --retriesRemaining) {
- if (isInMailbox()) {
- break;
- } else {
- mDevice.pressBack();
- mDevice.waitForIdle();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void downloadAttachment(int index) {
- if (!isInConversation()) {
- throw new IllegalStateException("Email is not open");
- }
-
- List<UiObject2> downloadButtons =
- mDevice.findObjects(By.res(UI_PACKAGE_NAME, UI_ATTACHMENT_TILE_SAVE_ID));
- if (downloadButtons != null && index >= 0 && index < downloadButtons.size()) {
- downloadButtons.get(index).click();
- } else {
- throw new IndexOutOfBoundsException("attachment index out of bounds");
- }
- }
-
- private UiObject2 getToField() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, "to"));
- }
-
- private UiObject2 getSubjectField() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, "subject"));
- }
-
- private UiObject2 getBodyField() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, "body"));
- }
-
- private UiObject2 getSendButton() {
- return mDevice.findObject(By.desc("Send"));
- }
-
- private UiObject2 getComposeScrollContainer() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, "compose"));
- }
-
- private UiObject2 getNavDrawerContainer() {
- return mDevice.findObject(NAV_DRAWER_SELECTOR);
- }
-
- private UiObject2 getConversationList() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_CONVERSATIONS_LIST_ID));
- }
-
- private UiObject2 getConversationPager() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_CONVERSATION_PAGER));
- }
-
- private boolean isInConversation() {
- return mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_CONVERSATION_PAGER));
- }
-
- private boolean isNavDrawerOpen() {
- if (isMultiPaneActivity()) {
- return mDevice.hasObject(By.res("android", "list"));
- } else {
- return mDevice.hasObject(NAV_DRAWER_SELECTOR);
- }
- }
-
- private void waitForConversationsList() {
- mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_CONVERSATIONS_LIST_ID)), RELOAD_INBOX_TIMEOUT);
- }
-
- private void waitForConversation() {
- mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_CONVERSATION_PAGER)), LOAD_EMAIL_TIMEOUT);
- }
-
- private void waitForCompose() {
- mDevice.wait(Until.findObject(By.res(UI_PACKAGE_NAME, "compose")), COMPOSE_EMAIL_TIMEOUT);
- }
-
- private boolean isMultiPaneActivity() {
- return mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_MULTI_PANE_CONTAINER_ID));
- }
-
- private boolean isInMailbox() {
- if (isMultiPaneActivity()) {
- return mDevice.hasObject(By.desc("Search"));
- } else {
- return mDevice.hasObject(By.desc("Search")) && getNavDrawerContainer() == null;
- }
- }
-
- private void scroll(UiObject2 scrollContainer, Direction direction,
- float amount, boolean scrollToEnd) {
- if (amount < 0.0f) {
- throw new IllegalArgumentException("Scroll amount cannot be negative");
- }
-
- if (scrollToEnd) {
- while (scrollContainer.scroll(direction, 1.0f)) {
- // empty
- }
- } else {
- scrollContainer.scroll(direction, (float) amount);
- }
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/google-app-camera-helper/Android.mk b/libraries/first-party-app-helpers/handheld/google-app-camera-helper/Android.mk
deleted file mode 100644
index 2aa862e6d..000000000
--- a/libraries/first-party-app-helpers/handheld/google-app-camera-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := google-camera-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers launcher-helper-lib
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/google-app-camera-helper/src/android/platform/test/helpers/GoogleCameraHelperImpl.java b/libraries/first-party-app-helpers/handheld/google-app-camera-helper/src/android/platform/test/helpers/GoogleCameraHelperImpl.java
deleted file mode 100644
index e7e60f6d9..000000000
--- a/libraries/first-party-app-helpers/handheld/google-app-camera-helper/src/android/platform/test/helpers/GoogleCameraHelperImpl.java
+++ /dev/null
@@ -1,1380 +0,0 @@
-/*
- * Copyright (C) 2015 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.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.launcherhelper.ILauncherStrategy;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Configurator;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiWatcher;
-import android.util.Log;
-
-import java.text.SimpleDateFormat;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.regex.Pattern;
-
-public class GoogleCameraHelperImpl extends AbstractGoogleCameraHelper {
- private static final String LOG_TAG = GoogleCameraHelperImpl.class.getSimpleName();
- private static final String UI_ACTIVITY_VIEW_ID = "activity_root_view";
- private static final String UI_ALBUM_FILMSTRIP_VIEW_ID = "filmstrip_view";
- private static final String UI_PACKAGE_NAME = "com.android.camera2";
- private static final String UI_RECORDING_TIME_ID = "recording_time";
- private static final String UI_SHUTTER_DESC_CAM_3X = "Capture photo";
- private static final String UI_SHUTTER_DESC_CAM_2X = "Shutter";
- private static final String UI_SHUTTER_DESC_VID_3X = "Capture video";
- private static final String UI_SHUTTER_DESC_VID_2X = "Shutter";
- private static final String UI_THUMBNAIL_ALBUM_BUTTON_ID = "rounded_thumbnail_view";
- private static final String UI_TOGGLE_BUTTON_ID = "photo_video_paginator";
- private static final String UI_BACK_FRONT_TOGGLE_BUTTON_ID = "camera_toggle_button";
- private static final String UI_MODE_OPTION_TOGGLE_BUTTON_ID = "mode_options_toggle";
- private static final String UI_SHUTTER_BUTTON_ID_3X = "photo_video_button";
- private static final String UI_SHUTTER_BUTTON_ID_2X = "shutter_button";
- private static final String UI_SETTINGS_BUTTON_ID = "settings_button";
- private static final String UI_SETTINGS_SCROLLABLE_ID = "settings_activity_content";
- private static final String UI_MENU_BUTTON_ID_3X = "menuButton";
- private static final String UI_MENU_BUTTON_ID_4X = "toybox_menu_button";
- private static final String UI_SPECIAL_MODE_CLOSE = "closeButton";
- private static final String UI_SWITCH_WIDGET = "switch_widget";
- private static final String UI_HDR_BUTTON_ID_2X = "hdr_plus_toggle_button";
- private static final String UI_HDR_BUTTON_ID_3X = "hdr_plus_toggle_button";
- private static final String UI_HDR_BUTTON_ID_4X = "hdr_button";
- private static final String UI_HDR_AUTO_ID_4X = "hdr_auto";
- private static final String UI_HDR_ON_ID_4X = "hdr_on";
- private static final String UI_HDR_OFF_ID_4X = "hdr_off";
- private static final String UI_SELECTED_OPTION_ID = "selected_option_label";
- private static final String UI_HFR_TOGGLE_ID_J = "hfr_button";
- private static final String UI_HFR_TOGGLE_ID_I = "hfr_mode_toggle_button";
- private static final String UI_HFR_VIDEO_BUTTON_ID = "video_hfr_shutter_button";
- private static final String UI_FPS_BUTTON_ID = "fps_button";
- private static final String UI_FPS_30_BUTTON_ID = "fps_30";
- private static final String UI_FPS_60_BUTTON_ID = "fps_60";
-
- private static final String DESC_HDR_AUTO = "HDR Plus auto";
- private static final String DESC_HDR_OFF_3X = "HDR Plus off";
- private static final String DESC_HDR_ON_3X = "HDR Plus on";
-
- private static final String DESC_HDR_OFF_2X = "HDR off";
- private static final String DESC_HDR_ON_2X = "HDR on";
-
- private static final String DESC_HFR_OFF = "Slow motion is off";
- private static final String DESC_HFR_120_FPS = "Slow motion is set to 120 fps";
- private static final String DESC_HFR_240_FPS = "Slow motion is set to 240 fps";
-
- private static final String TEXT_4K_ON = "UHD 4K";
- private static final String TEXT_HD_1080 = "HD 1080p";
- private static final String TEXT_HD_720 = "HD 720p";
- private static final String TEXT_SD_480 = "SD 480p";
- private static final String TEXT_HDR_AUTO = "HDR off";
- private static final String TEXT_HDR_ON = "HDR+ Auto";
- private static final String TEXT_HDR_OFF = "HDR on";
- private static final String TEXT_BACK_VIDEO_RESOLUTION_4X = "Back camera video resolution";
- private static final String TEXT_BACK_VIDEO_RESOLUTION_3X = "Back camera video";
- private static final String TEXT_FRONT_VIDEO_RESOLUTION_4X = "Front camera video resolution";
- private static final String TEXT_FRONT_VIDEO_RESOLUTION_3X = "Front camera video";
-
- public static final int HDR_MODE_AUTO = -1;
- public static final int HDR_MODE_OFF = 0;
- public static final int HDR_MODE_ON = 1;
-
- public static final int VIDEO_4K_MODE_ON = 1;
- public static final int VIDEO_HD_1080 = 0;
- public static final int VIDEO_HD_720 = -1;
- public static final int VIDEO_SD_480 = -2;
-
- public static final int VIDEO_30FPS = 0;
- public static final int VIDEO_60FPS = 1;
-
- public static final int HFR_MODE_OFF = 0;
- public static final int HFR_MODE_120_FPS = 1;
- public static final int HFR_MODE_240_FPS = 2;
-
- private static final long APP_INIT_WAIT = 20000;
- private static final long DIALOG_TRANSITION_WAIT = 5000;
- private static final long SHUTTER_WAIT_TIME = 20000;
- private static final long SWITCH_WAIT_TIME = 5000;
- private static final long MENU_WAIT_TIME = 5000;
-
- private boolean mIsVersionH = false;
- private boolean mIsVersionI = false;
- private boolean mIsVersionJ = false;
- private boolean mIsVersionK = false;
-
- public GoogleCameraHelperImpl(Instrumentation instr) {
- super(instr);
-
- try {
- mIsVersionH = getVersion().startsWith("2.");
- mIsVersionI = getVersion().startsWith("3.0") || getVersion().startsWith("3.1");
- mIsVersionJ = getVersion().startsWith("3.2");
- mIsVersionK = getVersion().startsWith("4");
- } catch (NameNotFoundException e) {
- Log.e(LOG_TAG, String.format("Unable to find package by name, %s", getPackage()));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.GoogleCamera";
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Camera";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- if (mIsVersionK) {
- // Dismiss dogfood confidentiality dialog
- Pattern okText = Pattern.compile("OK, GOT IT", Pattern.CASE_INSENSITIVE);
- UiObject2 dogfoodMessage = mDevice.wait(
- Until.findObject(By.text(okText)), APP_INIT_WAIT);
- if (dogfoodMessage != null) {
- dogfoodMessage.click();
- }
- } else if (mIsVersionI || mIsVersionJ) {
- // Dismiss dogfood confidentiality dialog
- Pattern okText = Pattern.compile("OK, GOT IT", Pattern.CASE_INSENSITIVE);
- UiObject2 dogfoodMessage = mDevice.wait(
- Until.findObject(By.text(okText)), APP_INIT_WAIT);
- if (dogfoodMessage != null) {
- dogfoodMessage.click();
- }
- // Swipe left to dismiss 'how to open video message'
- UiObject2 activityView = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, "activity_root_view")), DIALOG_TRANSITION_WAIT);
- if (activityView != null) {
- activityView.swipe(Direction.LEFT, 1.0f);
- }
- // Confirm 'GOT IT' for action above
- UiObject2 thanks = mDevice.wait(Until.findObject(By.text("GOT IT")),
- DIALOG_TRANSITION_WAIT);
- if (thanks != null) {
- thanks.click();
- }
- } else {
- BySelector confirm = By.res(UI_PACKAGE_NAME, "confirm_button");
- UiObject2 location = mDevice.wait(Until.findObject(
- By.copy(confirm).text("NEXT")), APP_INIT_WAIT);
- if (location != null) {
- location.click();
- }
- // Choose sensor size. It's okay to timeout. These dialog screens might not exist..
- UiObject2 sensor = mDevice.wait(Until.findObject(
- By.copy(confirm).text("OK, GOT IT")), DIALOG_TRANSITION_WAIT);
- if (sensor != null) {
- sensor.click();
- }
- // Dismiss dogfood dialog
- if (mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, "internal_release_dialog_title")), 5000)) {
- mDevice.findObject(By.res(UI_PACKAGE_NAME, "ok_button")).click();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void capturePhoto() {
- if (!isCameraMode()) {
- throw new IllegalStateException(
- "GoogleCamera must be in Camera mode to capture photos.");
- }
-
- getCameraShutter().click();
- waitForCameraShutterEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void captureVideo(long timeInMs) {
- if (!isVideoMode()) {
- throw new IllegalStateException("GoogleCamera must be in Video mode to record videos.");
- }
-
- if (isRecording()) {
- return;
- }
-
- // Temporary hack #1: Make UI code responsive by shortening the UiAutomator idle timeout.
- // The pulsing record button broadcasts unnecessary events of TYPE_WINDOW_CONTENT_CHANGED,
- // but we intend to have a fix and remove this hack with Kenai (GC 3.0).
- long original = Configurator.getInstance().getWaitForIdleTimeout();
- Configurator.getInstance().setWaitForIdleTimeout(1000);
-
- try {
- getVideoShutter().click();
- SystemClock.sleep(timeInMs);
- getVideoShutter().click();
- waitForVideoShutterEnabled();
- } finally {
- Configurator.getInstance().setWaitForIdleTimeout(original);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void snapshotVideo(long videoTimeInMs, long snapshotStartTimeInMs) {
- if (!isVideoMode()) {
- throw new IllegalStateException("GoogleCamera must be in Video mode to record videos.");
- } else if (videoTimeInMs <= snapshotStartTimeInMs) {
- throw new IllegalArgumentException(
- "video recording time length must be larger than snapshot start time");
- }
-
- // Temporary hack #2: Make UI code responsive by shortening the UiAutomator idle timeout.
- // The pulsing record button broadcasts unnecessary events of TYPE_WINDOW_CONTENT_CHANGED,
- // but we intend to have a fix and remove this hack with Kenai (GC 3.0).
- long original = Configurator.getInstance().getWaitForIdleTimeout();
- Configurator.getInstance().setWaitForIdleTimeout(1000);
-
- if (isRecording()) {
- return;
- }
-
- try {
- getVideoShutter().click();
- SystemClock.sleep(snapshotStartTimeInMs);
-
- boolean snapshot_success = false;
-
- // Take a snapshot
- if (mIsVersionJ || mIsVersionK) {
- UiObject2 snapshotButton = mDevice.findObject(By.res(UI_PACKAGE_NAME, "snapshot_button"));
- if (snapshotButton != null) {
- snapshotButton.click();
- snapshot_success = true;
- }
- } else if (mIsVersionI) {
- // Ivvavik Version of GCA doesn't support snapshot
- snapshot_success = false;
- } else {
- UiObject2 snapshotButton = mDevice.findObject(By.res(UI_PACKAGE_NAME, "recording_time"));
- if (snapshotButton != null) {
- snapshotButton.click();
- snapshot_success = true;
- }
- }
-
- if (!snapshot_success) {
- getVideoShutter().click();
- waitForVideoShutterEnabled();
- throw new UnknownUiException("snapshot button not found!");
- }
-
- SystemClock.sleep(videoTimeInMs - snapshotStartTimeInMs);
- getVideoShutter().click();
- waitForVideoShutterEnabled();
- } finally {
- Configurator.getInstance().setWaitForIdleTimeout(original);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToCameraMode() {
- if (isCameraMode()) {
- return;
- }
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- UiObject2 toggle = getCameraVideoToggleButton();
- if (toggle != null) {
- toggle.click();
- }
- } else {
- openMenu();
- selectMenuItem("Camera");
- }
-
- mDevice.waitForIdle();
- waitForCameraShutterEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToVideoMode() {
- if (isVideoMode()) {
- return;
- }
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- UiObject2 toggle = getCameraVideoToggleButton();
- if (toggle != null) {
- toggle.click();
- }
- } else {
- openMenu();
- selectMenuItem("Video");
- }
-
- mDevice.waitForIdle();
- waitForVideoShutterEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToBackCamera() {
- if (isBackCamera()) {
- return;
- }
-
- // Close menu if open
- closeMenu();
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- pressBackFrontToggleButton();
- } else {
- // Open mode options if not open.
- // Note: the mode option button only appear if mode option menu not open
- UiObject2 modeoptions = getModeOptionsMenuButton();
- if (modeoptions != null) {
- modeoptions.click();
- }
- pressBackFrontToggleButton();
- }
-
- // Wait for ensuring back camera button enabled
- waitForBackEnabled();
-
- // Wait for ensuring shutter button enabled
- waitForCurrentShutterEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToFrontCamera() {
- if (isFrontCamera()) {
- return;
- }
-
- // Close menu if open
- closeMenu();
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- pressBackFrontToggleButton();
- } else {
- // Open mode options if not open.
- // Note: the mode option button only appear if mode option menu not open
- UiObject2 modeoptions = getModeOptionsMenuButton();
- if (modeoptions != null) {
- modeoptions.click();
- }
- pressBackFrontToggleButton();
- }
-
- // Wait for ensuring front camera button enabled
- waitForFrontEnabled();
-
- // Wait for ensuring shutter button enabled
- waitForCurrentShutterEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setHdrMode(int mode) {
- if (!isCameraMode()) {
- throw new IllegalStateException("Cannot set HDR unless in camera mode.");
- }
-
- if (mIsVersionK) {
- if (getHdrToggleButton() == null) {
- if (mode == HDR_MODE_OFF) {
- return;
- } else {
- throw new UnsupportedOperationException(
- "Cannot set HDR on this device as requested.");
- }
- }
-
- getHdrToggleButton().click();
- // After clicking the HDR auto button should be visible.
- mDevice.wait(Until.findObject(By.res(UI_PACKAGE_NAME, UI_HDR_AUTO_ID_4X)),
- DIALOG_TRANSITION_WAIT);
-
- switch (mode) {
- case HDR_MODE_AUTO:
- mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HDR_AUTO_ID_4X)).click();
- break;
- case HDR_MODE_ON:
- mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HDR_ON_ID_4X)).click();
- break;
- case HDR_MODE_OFF:
- mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HDR_OFF_ID_4X)).click();
- break;
- default:
- throw new UnknownUiException("Failing setting HDR+ mode!");
- }
- mDevice.waitForIdle();
- } else if (mIsVersionI || mIsVersionJ) {
- if (getHdrToggleButton() == null) {
- if (mode == HDR_MODE_OFF) {
- return;
- } else {
- throw new UnsupportedOperationException(
- "Cannot set HDR on this device as requested.");
- }
- }
-
- for (int retries = 0; retries < 3; retries++) {
- if (!isHdrMode(mode)) {
- getHdrToggleButton().click();
- mDevice.waitForIdle();
- } else {
- Log.e(LOG_TAG, "Successfully set HDR mode!");
- mDevice.waitForIdle();
- return;
- }
- }
- } else {
- // Open mode options before checking Hdr status
- openModeOptions2X();
- if (getHdrToggleButton() == null) {
- if (mode == HDR_MODE_OFF) {
- return;
- } else {
- throw new UnsupportedOperationException(
- "Cannot set HDR on this device as requested.");
- }
- }
-
- for (int retries = 0; retries < 3; retries++) {
- if (!isHdrMode(mode)) {
- getHdrToggleButton().click();
- mDevice.waitForIdle();
- } else {
- Log.e(LOG_TAG, "Successfully set HDR mode!");
- mDevice.waitForIdle();
- return;
- }
- }
- }
- }
-
- private boolean isHdrMode(int mode) {
- if (mIsVersionK) {
- getHdrToggleButton().click();
- mDevice.waitForIdle();
- UiObject2 selectedOption = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_SELECTED_OPTION_ID)), MENU_WAIT_TIME);
- String currentHdrModeText = selectedOption.getText();
- int currentMode = 0;
- switch (currentHdrModeText) {
- case TEXT_HDR_AUTO:
- currentMode = HDR_MODE_AUTO;
- break;
- case TEXT_HDR_ON:
- currentMode = HDR_MODE_ON;
- break;
- case TEXT_HDR_OFF:
- currentMode = HDR_MODE_OFF;
- break;
- default:
- throw new UnknownUiException("Failed to identify the HDR+ settings!");
- }
- selectedOption.click();
- mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_HDR_BUTTON_ID_4X)), MENU_WAIT_TIME);
- return mode == currentMode;
- } else if (mIsVersionI || mIsVersionJ) {
- String modeDesc = getHdrToggleButton().getContentDescription();
- if (DESC_HDR_AUTO.equals(modeDesc)) {
- return HDR_MODE_AUTO == mode;
- } else if (DESC_HDR_OFF_3X.equals(modeDesc)) {
- return HDR_MODE_OFF == mode;
- } else if (DESC_HDR_ON_3X.equals(modeDesc)) {
- return HDR_MODE_ON == mode;
- } else {
- throw new UnknownUiException("Unexpected failure.");
- }
- } else {
- // Open mode options before checking Hdr status
- openModeOptions2X();
- // Check the HDR mode
- String modeDesc = getHdrToggleButton().getContentDescription();
- if (DESC_HDR_OFF_2X.equals(modeDesc)) {
- return HDR_MODE_OFF == mode;
- } else if (DESC_HDR_ON_2X.equals(modeDesc)) {
- return HDR_MODE_ON == mode;
- } else {
- throw new UnknownUiException("Unexpected failure.");
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void set4KMode(int mode) {
- // If the menu is not open, open it
- if (!isMenuOpen()) {
- openMenu();
- }
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- // Select Menu Item "Settings"
- selectMenuItem("Settings");
- } else {
- // Select Menu Item "Settings"
- selectSetting2X();
- }
-
- if (mIsVersionI || mIsVersionJ) {
- // Select Item "Resolution & Quality"
- selectSettingItem("Resolution & quality");
- }
-
- // Select Item "Back camera video", which is the only mode supports 4k
- String textBackVideoResolution =
- (mIsVersionK)? TEXT_BACK_VIDEO_RESOLUTION_4X:TEXT_BACK_VIDEO_RESOLUTION_3X;
- selectVideoResolution(mode, textBackVideoResolution);
-
- if (mIsVersionI || mIsVersionJ) {
- // Quit Menu "Resolution & Quality"
- closeSettingItem();
- }
-
- // Close Main Menu
- closeMenuItem();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setHFRMode(int mode) {
- if (!isVideoMode()) {
- throw new IllegalStateException("Must be in video mode to set HFR mode.");
- }
-
- // Haleakala doesn't support slow motion, so throw exception
- if (mIsVersionH) {
- throw new UnsupportedOperationException(
- "HFR not supported on this version of Google Camera.");
- } else if (mIsVersionI) {
- waitForHFRToggleEnabled();
- for (int retries = 0; retries < 3; retries++) {
- if (!isHfrMode(mode)) {
- getHfrToggleButton().click();
- mDevice.waitForIdle();
- } else {
- Log.e(LOG_TAG, "Successfully set HFR mode!");
- mDevice.waitForIdle();
- waitForVideoShutterEnabled();
- return;
- }
- }
- //If none of the 3 options match expected option, throw an exception
- if (mode == HFR_MODE_OFF) {
- throw new UnknownUiException("Failed to turn off the HFR mode");
- } else {
- throw new UnknownUiException(String.format("Failed to select HFR mode to FPS %d",
- (int) Math.floor(mode * 120)));
- }
- } else if (mIsVersionJ || mIsVersionK) {
- String uiMenuButton = (mIsVersionK)? UI_MENU_BUTTON_ID_4X:UI_MENU_BUTTON_ID_3X;
- if (mode == HFR_MODE_OFF) {
- // This close button ui only appeared in hfr mode
- UiObject2 hfrmodeclose = mDevice.findObject(By.res(UI_PACKAGE_NAME,
- UI_SPECIAL_MODE_CLOSE));
- if (hfrmodeclose != null) {
- hfrmodeclose.click();
- mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, uiMenuButton)),
- MENU_WAIT_TIME);
- } else {
- throw new UnknownUiException(
- "Fail to find hfr mode close button when trying to turn off HFR mode");
- }
- return;
- }
-
- // When not in HFR interface, select menu to open HFR interface
- if (mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_SPECIAL_MODE_CLOSE))
- && !isVideoMode()) {
- UiObject2 specialmodeclose = mDevice.findObject(By.res(UI_PACKAGE_NAME,
- UI_SPECIAL_MODE_CLOSE));
- if (specialmodeclose != null) {
- specialmodeclose.click();
- mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, uiMenuButton)),
- MENU_WAIT_TIME);
- } else {
- throw new UnknownUiException(
- "Fail to close other special mode before setting hfr mode");
- }
- }
-
- if (!mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_SPECIAL_MODE_CLOSE))) {
- // If the menu is not open, open it
- if (!isMenuOpen()) {
- openMenu();
- }
- // Select Item "Slow Motion"
- selectSettingItem("Slow Motion");
- // Change Slow Motion mode to 120FPS or 240FPS
- }
-
- mDevice.waitForIdle();
- // Detect if hfr toggle exists in the interface
- if (!mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_HFR_TOGGLE_ID_J))) {
- if (mode == HFR_MODE_240_FPS) {
- throw new UnknownUiException(
- "The 240 fps HFR mode is not supported on the device.");
- }
- return;
- }
-
- for (int retries = 0; retries < 2; retries++) {
- if (!isHfrMode(mode)) {
- getHfrToggleButton().click();
- mDevice.waitForIdle();
- } else {
- Log.e(LOG_TAG, "Successfully set HFR mode!");
- mDevice.waitForIdle();
- waitForVideoShutterEnabled();
- return;
- }
- }
- //If neither of the 2 options match expected option, throw an exception
- throw new UnknownUiException(String.format("Failed to select HFR mode to FPS %d",
- (int) Math.floor(mode * 120)));
- } else {
- throw new UnknownUiException("The Google Camera version is not supported.");
- }
- }
-
- private boolean isHfrMode(int mode) {
- if (mIsVersionI) {
- String modeDesc = getHfrToggleButton().getContentDescription();
- if (DESC_HFR_120_FPS.equals(modeDesc)) {
- return HFR_MODE_120_FPS == mode;
- } else if (DESC_HFR_240_FPS.equals(modeDesc)) {
- return HFR_MODE_240_FPS == mode;
- } else if (DESC_HFR_OFF.equals(modeDesc)) {
- return HFR_MODE_OFF == mode;
- } else {
- throw new UnknownUiException("Fail to identify HFR toggle description.");
- }
- } else if (mIsVersionJ || mIsVersionK) {
- if (getHfrToggleButton() == null) {
- return HFR_MODE_OFF == mode;
- }
- String modeDesc = getHfrToggleButton().getContentDescription();
- if (DESC_HFR_120_FPS.equals(modeDesc)) {
- return HFR_MODE_120_FPS == mode;
- } else if (DESC_HFR_240_FPS.equals(modeDesc)) {
- return HFR_MODE_240_FPS == mode;
- } else {
- throw new UnknownUiException("Fail to identify HFR toggle description.");
- }
- }
- return HFR_MODE_OFF == mode;
- }
-
- private void openModeOptions2X() {
- // If the mode option is already open, return as it is
- if (mDevice.hasObject(By.res(UI_PACKAGE_NAME, "mode_options_buttons"))) {
- return;
- }
- // Before openning the mode option, close the menu if the menu is open
- closeMenu();
- waitForVideoShutterEnabled();
- // Open the mode options to check HDR mode
- UiObject2 modeoptions = getModeOptionsMenuButton();
- if (modeoptions != null) {
- modeoptions.click();
- // If succeeded, the hdr toggle button should be visible.
- mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, "hdr_plus_toggle_button")),
- DIALOG_TRANSITION_WAIT);
- } else {
- throw new UnknownUiException(
- "Fail to find modeoption button when trying to check HDR mode");
- }
- }
-
- private void openMenu() {
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- String uiMenuButton = (mIsVersionK)? UI_MENU_BUTTON_ID_4X:UI_MENU_BUTTON_ID_3X;
- UiObject2 menu = mDevice.findObject(By.res(UI_PACKAGE_NAME, uiMenuButton));
- menu.click();
- } else {
- UiObject2 activityView = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_ACTIVITY_VIEW_ID)), MENU_WAIT_TIME);
- activityView.swipe(Direction.RIGHT, 1.0f);
- }
-
- mDevice.wait(Until.hasObject(By.text("Photo Sphere")), MENU_WAIT_TIME);
-
- mDevice.waitForIdle();
- }
-
- private void selectMenuItem(String mode) {
- UiObject2 menuItem = mDevice.findObject(By.text(mode));
- if (menuItem != null) {
- menuItem.click();
- } else {
- throw new UnknownUiException(
- String.format("Menu item button was not enabled with %d seconds",
- (int)Math.floor(MENU_WAIT_TIME / 1000)));
- }
- mDevice.wait(Until.gone(By.text("Photo Sphere")), MENU_WAIT_TIME);
-
- mDevice.waitForIdle();
- }
-
- private void closeMenuItem() {
- UiObject2 navUp = mDevice.findObject(By.desc("Navigate up"));
- if (navUp != null) {
- navUp.click();
- } else {
- throw new UnknownUiException(String.format(
- "Navigation up button was not enabled with %d seconds",
- (int)Math.floor(MENU_WAIT_TIME / 1000)));
- }
- mDevice.wait(Until.gone(By.text("Help & feedback")), MENU_WAIT_TIME);
-
- mDevice.waitForIdle();
- }
-
- private UiObject2 findSettingItem(String mode) {
-
- UiObject2 container = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_SETTINGS_SCROLLABLE_ID));
- if (container == null) {
- throw new IllegalStateException("Cannot find scrollable Setting menu item");
- }
-
- UiObject2 settingItem = mDevice.wait(Until.findObject(By.text(mode)), MENU_WAIT_TIME);
- boolean scrollable = true;
- while (scrollable && (settingItem == null)) {
- scrollable = container.scroll(Direction.DOWN, 1.0f);
- settingItem = mDevice.wait(Until.findObject(By.text(mode)), MENU_WAIT_TIME);
- }
-
- return settingItem;
- }
-
- private void selectSettingItem(String mode) {
- UiObject2 settingItem = mDevice.findObject(By.text(mode));
- if (settingItem != null) {
- settingItem.click();
- } else {
- throw new UnknownUiException(
- String.format("Setting item button was not enabled with %d seconds",
- (int)Math.floor(MENU_WAIT_TIME / 1000)));
- }
- mDevice.wait(Until.gone(By.text("Help & feedback")), MENU_WAIT_TIME);
-
- mDevice.waitForIdle();
- }
-
- private void selectSetting2X() {
- UiObject2 settingItem = mDevice.findObject(By.desc("Settings"));
- if (settingItem != null) {
- settingItem.click();
- } else {
- throw new UnknownUiException(
- String.format("Setting item button was not enabled with %d seconds",
- (int)Math.floor(MENU_WAIT_TIME / 1000)));
- }
- mDevice.wait(Until.gone(By.text("Help & feedback")), MENU_WAIT_TIME);
-
- mDevice.waitForIdle();
- }
-
- private void closeSettingItem() {
- UiObject2 navUp = mDevice.findObject(By.desc("Navigate up"));
- if (navUp != null) {
- navUp.click();
- } else {
- throw new UnknownUiException(
- String.format("Navigation up button was not enabled with %d seconds",
- (int)Math.floor(MENU_WAIT_TIME / 1000)));
- }
- mDevice.wait(Until.findObject(By.text("Help & feedback")), MENU_WAIT_TIME);
-
- mDevice.waitForIdle();
- }
-
- private void selectVideoResolution(int mode, String textVideoResolution) {
- UiObject2 menuItem = mDevice.findObject(By.text(textVideoResolution));
- if (menuItem != null) {
- menuItem.click();
- } else {
- throw new UnknownUiException(
- String.format("Back camera button was not enabled with %d seconds",
- (int)Math.floor(MENU_WAIT_TIME / 1000)));
- }
- mDevice.wait(Until.findObject(By.text("CANCEL")), MENU_WAIT_TIME);
- mDevice.waitForIdle();
-
- if (mode == VIDEO_4K_MODE_ON) {
- mDevice.wait(Until.findObject(By.text(TEXT_4K_ON)), MENU_WAIT_TIME).click();
- } else if (mode == VIDEO_HD_1080) {
- mDevice.wait(Until.findObject(By.text(TEXT_HD_1080)), MENU_WAIT_TIME).click();
- } else if (mode == VIDEO_HD_720){
- mDevice.wait(Until.findObject(By.text(TEXT_HD_720)), MENU_WAIT_TIME).click();
- } else if (mode == VIDEO_SD_480){
- mDevice.wait(Until.findObject(By.text(TEXT_SD_480)), MENU_WAIT_TIME).click();
- } else {
- throw new UnknownUiException("Failed to set video resolution");
- }
-
- mDevice.wait(Until.gone(By.text("CANCEL")), MENU_WAIT_TIME);
-
- mDevice.waitForIdle();
- }
-
- private void closeMenu() {
- // Should only call this function when menu is open, do nothing if menu is not open
- if (!isMenuOpen()) {
- return;
- }
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- // Click menu button to close menu (this is NOT for taking pictures)
- String uiMenuButton = (mIsVersionK)? UI_MENU_BUTTON_ID_4X:UI_MENU_BUTTON_ID_3X;
- UiObject2 backButton = mDevice.findObject(By.res(UI_PACKAGE_NAME, uiMenuButton));
- if (backButton != null) {
- backButton.click();
- }
- } else {
- // Click shutter button to close menu (this is NOT for taking pictures)
- UiObject2 shutter = mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_SHUTTER_BUTTON_ID_2X));
- if (shutter != null) {
- shutter.click();
- }
- }
- }
-
- private boolean isCameraMode() {
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- return (mDevice.hasObject(By.desc(UI_SHUTTER_DESC_CAM_3X)));
- } else {
- // TODO: identify a Haleakala UiObject2 unique Camera mode
- return !isVideoMode();
- }
- }
-
- private boolean isVideoMode() {
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- return (mDevice.hasObject(By.desc(UI_SHUTTER_DESC_VID_3X)));
- } else {
- return (mDevice.hasObject(By.res(UI_PACKAGE_NAME, "recording_time_rect")));
- }
- }
-
- private boolean isRecording() {
- return mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_RECORDING_TIME_ID));
- }
-
- private boolean isFrontCamera() {
- // Close menu if open
- closeMenu();
-
- if (mIsVersionJ || mIsVersionK) {
- return (mDevice.hasObject(By.desc("Switch to back camera")));
- } else if (mIsVersionI) {
- return (mDevice.hasObject(By.desc("Front camera")));
- } else {
- // Open mode options if not open
- UiObject2 modeoptions = getModeOptionsMenuButton();
- if (modeoptions != null) {
- modeoptions.click();
- }
- return (mDevice.hasObject(By.desc("Front camera")));
- }
- }
-
- private boolean isBackCamera() {
- // Close menu if open
- closeMenu();
-
- if (mIsVersionJ || mIsVersionK) {
- return (mDevice.hasObject(By.desc("Switch to front camera")));
- } else if (mIsVersionI) {
- return (mDevice.hasObject(By.desc("Back camera")));
- } else {
- // Open mode options if not open
- UiObject2 modeoptions = getModeOptionsMenuButton();
- if (modeoptions != null) {
- modeoptions.click();
- }
- return (mDevice.hasObject(By.desc("Back camera")));
- }
- }
-
- private boolean isMenuOpen() {
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- if (mDevice.hasObject(By.desc("Open settings"))) {
- return true;
- }
- } else {
- if (mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_SETTINGS_BUTTON_ID))) {
- return true;
- }
- }
- return false;
- }
-
- private void pressBackFrontToggleButton() {
- UiObject2 toggle = getBackFrontToggleButton();
- if (toggle != null) {
- toggle.click();
- } else {
- throw new UnknownUiException("Failed to detect a back-front toggle button");
- }
- }
-
- private UiObject2 getCameraVideoToggleButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_TOGGLE_BUTTON_ID));
- }
-
- private UiObject2 getBackFrontToggleButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_BACK_FRONT_TOGGLE_BUTTON_ID));
- }
-
- private UiObject2 getHdrToggleButton() {
- if (mIsVersionK) {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HDR_BUTTON_ID_4X));
- } else if (mIsVersionI || mIsVersionJ) {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HDR_BUTTON_ID_3X));
- } else {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HDR_BUTTON_ID_2X));
- }
- }
-
- private UiObject2 getHfrToggleButton() {
- if (mIsVersionI) {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HFR_TOGGLE_ID_I));
- } else if (mIsVersionJ || mIsVersionK) {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HFR_TOGGLE_ID_J));
- } else {
- throw new UnsupportedOperationException(
- "HFR not supported on this version of Google Camera.");
- }
- }
-
- private UiObject2 getModeOptionsMenuButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_MODE_OPTION_TOGGLE_BUTTON_ID));
- }
-
- private UiObject2 getCameraShutter() {
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- return mDevice.findObject(By.desc(UI_SHUTTER_DESC_CAM_3X).enabled(true));
- } else {
- return mDevice.findObject(By.desc(UI_SHUTTER_DESC_CAM_2X).enabled(true));
- }
- }
-
- private UiObject2 getVideoShutter() {
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- return mDevice.findObject(By.desc(UI_SHUTTER_DESC_VID_3X).enabled(true));
- } else {
- return mDevice.findObject(By.desc(UI_SHUTTER_DESC_VID_2X).enabled(true));
- }
- }
-
- private UiObject2 getThumbnailAlbumButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_THUMBNAIL_ALBUM_BUTTON_ID));
- }
-
- private UiObject2 getAlbumFilmstripView() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_ALBUM_FILMSTRIP_VIEW_ID));
- }
-
- /**
- * {@inheritDoc}
- */
- public void setEIS(boolean mode) {
- // If the menu is not open, open it
- if (!isMenuOpen()) {
- openMenu();
- }
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- // Select Menu Item "Settings"
- selectMenuItem("Settings");
- } else {
- // Select Menu Item "Settings"
- selectSetting2X();
- }
-
- UiObject2 settingItem = findSettingItem("Video stabilization");
- if (settingItem != null) {
- UiObject2 itemParent = settingItem.getParent();
- if (itemParent != null) {
- UiObject2 itemGrandparent = itemParent.getParent();
- if (itemGrandparent != null) {
- // We need the LinearLayout object to grab the toggle widget.
- // It is the grandparent of the TextView object returned from findSettingItem()
- UiObject2 toggle = itemGrandparent.findObject(By.res("android", UI_SWITCH_WIDGET));
- if (toggle != null) {
- String currentState = toggle.getText();
-
- if (mode && currentState.equals("OFF")) {
- toggle.click();
- }
- else if (!mode && currentState.equals("ON")) {
- toggle.click();
- }
-
- closeMenuItem();
- }
- else {
- throw new UnknownUiException("Cannot find video stabilization toggle widget");
- }
- }
- else {
- throw new UnknownUiException("Cannot find LinearLayout object for Video stabilization");
- }
- }
- else {
- throw new UnknownUiException("Cannot find RelativeLayout object for Video stabilization");
- }
- }
- else {
- throw new UnknownUiException("Cannot find video stabilization setting item");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectFrontVideoResolution(int mode) {
- // If the menu is not open, open it
- if (!isMenuOpen()) {
- openMenu();
- }
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- // Select Menu Item "Settings"
- selectMenuItem("Settings");
- } else {
- // Select Menu Item "Settings"
- selectSetting2X();
- }
-
- String textFrontVideoResolution =
- (mIsVersionK)? TEXT_FRONT_VIDEO_RESOLUTION_4X:TEXT_FRONT_VIDEO_RESOLUTION_3X;
- UiObject2 settingItem = findSettingItem(textFrontVideoResolution);
- if (settingItem != null) {
- selectVideoResolution(mode, textFrontVideoResolution);
- closeMenuItem();
- }
- else {
- throw new UnknownUiException("Cannot find front camera video resolution setting item");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectBackVideoResolution(int mode) {
- // If the menu is not open, open it
- if (!isMenuOpen()) {
- openMenu();
- }
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- // Select Menu Item "Settings"
- selectMenuItem("Settings");
- } else {
- // Select Menu Item "Settings"
- selectSetting2X();
- }
-
- String textBackVideoResolution =
- (mIsVersionK)? TEXT_BACK_VIDEO_RESOLUTION_4X:TEXT_BACK_VIDEO_RESOLUTION_3X;
- UiObject2 settingItem = findSettingItem(textBackVideoResolution);
- if (settingItem != null) {
- selectVideoResolution(mode, textBackVideoResolution);
- closeMenuItem();
- }
- else {
- throw new UnknownUiException("Cannot find back camera video resolution setting item");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void setFrameRate(int mode) {
- if (!isVideoMode()) {
- throw new IllegalStateException("GoogleCamera must be in video mode to set frame rate.");
- }
-
- UiObject2 fpsButton = mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_FPS_BUTTON_ID));
- if (fpsButton != null) {
- fpsButton.click();
- UiObject2 fpsRateButton = null;
- if (mode == VIDEO_30FPS) {
- fpsRateButton = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_FPS_30_BUTTON_ID)), DIALOG_TRANSITION_WAIT);
- }
- else if (mode == VIDEO_60FPS) {
- fpsRateButton = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_FPS_60_BUTTON_ID)), DIALOG_TRANSITION_WAIT);
- }
-
- if (fpsRateButton != null) {
- fpsRateButton.click();
- }
- else {
- throw new UnknownUiException("Cannot find set frame rate button");
- }
- }
- else {
- throw new UnknownUiException("Cannot find framerate button.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void waitForCameraShutterEnabled() {
- boolean uiSuccess = false;
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- uiSuccess = mDevice.wait(Until.hasObject(
- By.desc(UI_SHUTTER_DESC_CAM_3X).enabled(true)), SHUTTER_WAIT_TIME);
- } else {
- uiSuccess = mDevice.wait(Until.hasObject(
- By.desc(UI_SHUTTER_DESC_CAM_2X).enabled(true)), SHUTTER_WAIT_TIME);
- }
-
- if (!uiSuccess) {
- throw new UnknownUiException(
- String.format("Camera shutter was not enabled with %d seconds",
- (int)Math.floor(SHUTTER_WAIT_TIME / 1000)));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void waitForVideoShutterEnabled() {
- boolean uiSuccess = false;
-
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- uiSuccess = mDevice.wait(Until.hasObject(
- By.desc(UI_SHUTTER_DESC_VID_3X).enabled(true)), SHUTTER_WAIT_TIME);
- } else {
- uiSuccess = mDevice.wait(Until.hasObject(
- By.desc(UI_SHUTTER_DESC_VID_2X).enabled(true)), SHUTTER_WAIT_TIME);
- }
-
- if (!uiSuccess) {
- throw new UnknownUiException(
- String.format("Video shutter was not enabled with %d seconds",
- (int)Math.floor(SHUTTER_WAIT_TIME / 1000)));
- }
- }
-
- private void waitForCurrentShutterEnabled() {
- // This function is called to wait for shutter button enabled in either camera or video mode
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, UI_SHUTTER_BUTTON_ID_3X).enabled(true)),
- SHUTTER_WAIT_TIME);
- } else {
- mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, UI_SHUTTER_BUTTON_ID_2X).enabled(true)),
- SHUTTER_WAIT_TIME);
- }
- }
-
- private void waitForBackEnabled() {
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- mDevice.wait(Until.hasObject(By.desc("Switch to front camera").enabled(true)),
- SWITCH_WAIT_TIME);
- } else {
- mDevice.wait(Until.hasObject(By.desc("Back camera").enabled(true)),
- SWITCH_WAIT_TIME);
- }
- }
-
- private void waitForFrontEnabled() {
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- mDevice.wait(Until.hasObject(By.desc("Switch to back camera").enabled(true)),
- SWITCH_WAIT_TIME);
- } else {
- mDevice.wait(Until.hasObject(By.desc("Front camera").enabled(true)),
- SWITCH_WAIT_TIME);
- }
- }
-
- private void waitForHFRToggleEnabled() {
- if (mIsVersionJ || mIsVersionK) {
- mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, UI_HFR_TOGGLE_ID_J).enabled(true)),
- SWITCH_WAIT_TIME);
- } else if (mIsVersionI) {
- mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, UI_HFR_TOGGLE_ID_I).enabled(true)),
- SWITCH_WAIT_TIME);
- } else {
- throw new UnknownUiException("HFR is not supported on this version of Google Camera");
- }
- }
-
- private void waitForAppInit() {
- boolean initalized = false;
- if (mIsVersionI || mIsVersionJ || mIsVersionK) {
- String uiMenuButton = (mIsVersionK)? UI_MENU_BUTTON_ID_4X:UI_MENU_BUTTON_ID_3X;
- initalized = mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, uiMenuButton)),
- APP_INIT_WAIT);
- } else {
- initalized = mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, UI_MODE_OPTION_TOGGLE_BUTTON_ID)),
- APP_INIT_WAIT);
- }
-
- waitForCurrentShutterEnabled();
-
- mDevice.waitForIdle();
-
- if (initalized) {
- Log.e(LOG_TAG, "Successfully initialized.");
- } else {
- Log.e(LOG_TAG, "Failed to find initialization indicator.");
- }
- }
-
- /**
- * TODO: Temporary. Create long-term solution for registering watchers.
- */
- public void registerCrashWatcher() {
- final UiDevice fDevice = mDevice;
-
- mDevice.registerWatcher("GoogleCamera-crash-watcher", new UiWatcher() {
- @Override
- public boolean checkForCondition() {
- Pattern dismissWords =
- Pattern.compile("DISMISS", Pattern.CASE_INSENSITIVE);
- UiObject2 buttonDismiss = fDevice.findObject(By.text(dismissWords).enabled(true));
- if (buttonDismiss != null) {
- buttonDismiss.click();
- throw new UnknownUiException("Camera crash dialog encountered. Failing test.");
- }
-
- return false;
- }
- });
- }
-
- /**
- * TODO: Temporary. Create long-term solution for registering watchers.
- */
- public void unregisterCrashWatcher() {
- mDevice.removeWatcher("GoogleCamera-crash-watcher");
- }
-
- /**
- * TODO: Should only be temporary
- * {@inheritDoc}
- */
- public String openWithShutterTimeString() {
- String pkg = getPackage();
- String id = getLauncherName();
-
- long launchStart = ILauncherStrategy.LAUNCH_FAILED_TIMESTAMP;
- if (!mDevice.hasObject(By.pkg(pkg).depth(0))) {
- launchStart = mLauncherStrategy.launch(id, pkg);
- }
-
- if (launchStart == ILauncherStrategy.LAUNCH_FAILED_TIMESTAMP) {
- throw new UnknownUiException("Failed to launch GoogleCamera.");
- }
-
- waitForAppInit();
- waitForCurrentShutterEnabled();
- long launchDuration = SystemClock.uptimeMillis() - launchStart;
-
- Date dateNow = new Date();
- DateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
- String dateString = dateFormat.format(dateNow);
-
- if (isCameraMode()) {
- return String.format("%s %s %d\n", dateString, "camera", launchDuration);
- } else if (isVideoMode()) {
- return String.format("%s %s %d\n", dateString, "video", launchDuration);
- } else {
- return String.format("%s %s %d\n", dateString, "wtf", launchDuration);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void goToAlbum() {
- UiObject2 thumbnailAlbumButton = getThumbnailAlbumButton();
- if (thumbnailAlbumButton == null) {
- throw new UnknownUiException("Could not find thumbnail album button");
- }
-
- thumbnailAlbumButton.click();
- if (!mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_ALBUM_FILMSTRIP_VIEW_ID)), DIALOG_TRANSITION_WAIT)) {
- throw new UnknownUiException("Could not find album filmstrip");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void scrollAlbum(Direction direction) {
- if (!(Direction.LEFT.equals(direction) || Direction.RIGHT.equals(direction))) {
- throw new IllegalArgumentException("direction must be LEFT or RIGHT");
- }
-
- UiObject2 albumFilmstripView = getAlbumFilmstripView();
- if (albumFilmstripView == null) {
- throw new UnknownUiException("Could not find album filmstrip view");
- }
-
- albumFilmstripView.scroll(direction, 5.0f);
- mDevice.waitForIdle();
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/google-docs-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/google-docs-app-helper/Android.mk
deleted file mode 100644
index 44ee3c39e..000000000
--- a/libraries/first-party-app-helpers/handheld/google-docs-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := google-docs-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/google-docs-app-helper/src/android/platform/test/helpers/GoogleDocsHelperImpl.java b/libraries/first-party-app-helpers/handheld/google-docs-app-helper/src/android/platform/test/helpers/GoogleDocsHelperImpl.java
deleted file mode 100644
index d9a31f805..000000000
--- a/libraries/first-party-app-helpers/handheld/google-docs-app-helper/src/android/platform/test/helpers/GoogleDocsHelperImpl.java
+++ /dev/null
@@ -1,178 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.os.SystemClock;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiObject2;
-
-import junit.framework.Assert;
-
-import java.lang.IllegalArgumentException;
-import java.lang.IllegalStateException;
-
-/**
- * UI test helper for Google Docs (package: com.google.android.apps.docs.editors.docs).
- * Implementation based on app version: 1.6.152
- */
-
-public class GoogleDocsHelperImpl extends AbstractGoogleDocsHelper {
-
- private static final String LOG_TAG = GoogleDocsHelperImpl.class.getSimpleName();
-
- private static final String UI_PACKAGE_NAME = "com.google.android.apps.docs.editors.docs";
- private static final String UI_DOCS_LIST_TITLE = "title";
- private static final String UI_DOCS_LIST_VIEW = "doc_list_view";
- private static final String UI_EDITOR_VIEW = "kix_editor_view";
- private static final String UI_TOOLBAR = "toolbar";
- private static final String UI_TEXT_DOCS = "Docs";
- private static final String UI_TEXT_SKIP = "SKIP";
-
- private static final long HACKY_DELAY = 1000; // 1 sec
- private static final long LOAD_DOCUMENT_TIMEOUT = 60000; // 60 secs
- private static final int BACK_TO_RECENT_DOCS_MAX_RETRY = 5;
- private static final int SEARCHING_DOC_MAX_SCROLL_DOWN = 10;
-
- public GoogleDocsHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.apps.docs.editors.docs";
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Docs";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- UiObject2 skipButton = getSkipButton();
- if (skipButton != null) {
- skipButton.click();
- mDevice.waitForIdle();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToRecentDocsTab() {
- for (int retryCnt = 0; retryCnt < BACK_TO_RECENT_DOCS_MAX_RETRY; retryCnt++) {
- if (isOnRecentDocsTab()) {
- return;
- }
- mDevice.pressBack();
-
- // TODO Hacky workaround
- // Bug: 28675538
- // mDevice.waitForIdle() is insufficient when a short (unscrollable)
- // document is scrolled by scrollDownDocument() before goToRecentDocsTab()
- // is called. isOnRecentDocsTab() fails to recognize the Recent Docs tab
- // even if the tab is indeed shown.
- SystemClock.sleep(HACKY_DELAY);
- }
- Assert.assertTrue("Failed to go to Recent Docs Tab", isOnRecentDocsTab());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openDoc(String title) {
- if (!isOnRecentDocsTab()) {
- throw new IllegalStateException("Not on the Recent Docs tab");
- }
- UiObject2 recentDocsList = getRecentDocsList();
-
- // TODO: Hacky workaround
- // Bug: 28675621
- // while (recentDocsList.scroll(Direction.UP, 1.0f));
- // The above while loop doesn't work as scroll doesn't return true
- // while there's more to scroll.
- recentDocsList.fling(Direction.UP);
-
- for (int cnt = 0; cnt < SEARCHING_DOC_MAX_SCROLL_DOWN; cnt++) {
- UiObject2 documentTitle = recentDocsList.findObject(
- By.res(UI_PACKAGE_NAME, UI_DOCS_LIST_TITLE).text(title));
- if (documentTitle != null) {
- // document is found, click to download
- documentTitle.click();
- boolean editorLoaded = mDevice.wait(
- Until.hasObject(By.res(UI_PACKAGE_NAME, UI_EDITOR_VIEW)),
- LOAD_DOCUMENT_TIMEOUT);
- Assert.assertTrue(String.format("Failed to finish downloading %s", title),
- editorLoaded);
- return;
- }
- recentDocsList.scroll(Direction.DOWN, 0.5f);
- }
- Assert.fail(String.format("Can't find the document: %s", title));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollDownDocument() {
- UiObject2 docsEditorPage = getDocsEditorPage();
- if (docsEditorPage == null) {
- throw new IllegalStateException("Not on a document page");
- }
- docsEditorPage.scroll(Direction.DOWN, 1.0f);
- }
-
- private boolean isOnRecentDocsTab() {
- UiObject2 toolbar = getToolbar();
- if (toolbar == null) {
- return false;
- }
- return toolbar.hasObject(By.text(UI_TEXT_DOCS));
- }
-
- private UiObject2 getToolbar() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_TOOLBAR));
- }
-
- private UiObject2 getRecentDocsList() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_DOCS_LIST_VIEW));
- }
-
- private UiObject2 getDocsEditorPage() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_EDITOR_VIEW));
- }
-
- private UiObject2 getSkipButton() {
- return mDevice.findObject(By.text(UI_TEXT_SKIP));
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/Android.mk
deleted file mode 100644
index 26d952c82..000000000
--- a/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := google-keyboard-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/src/android/platform/test/helpers/GoogleKeyboardHelperImpl.java b/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/src/android/platform/test/helpers/GoogleKeyboardHelperImpl.java
deleted file mode 100644
index 3e5b5e105..000000000
--- a/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/src/android/platform/test/helpers/GoogleKeyboardHelperImpl.java
+++ /dev/null
@@ -1,366 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.regex.Pattern;
-import java.util.Set;
-
-public class GoogleKeyboardHelperImpl extends AbstractGoogleKeyboardHelper {
- private static final String TAG = GoogleKeyboardHelperImpl.class.getCanonicalName();
-
- private static final Map<Character, String> SPECIAL_KEY_CONTENT_DESCRIPTIONS;
-
- private static final Set<Character> ALWAYS_VISIBLE_CHARACTERS;
- private static final Set<Character> KEYBOARD_NUMBER_SCREEN_SYMBOLS;
- private static final Set<Character> KEYBOARD_OTHER_SYMBOLS;
-
- private static final String UI_ANDROID_VIEW_CLASS = "android.view.View";
- private static final String UI_DECLINE_BUTTON_ID = "decline_button";
- private static final String UI_KEYBOARD_KEY_CLASS = "com.android.inputmethod.keyboard.Key";
- private static final String UI_KEYBOARD_LETTER_KEY_DESC = "Letters";
- private static final String UI_KEYBOARD_NUMBER_KEY_DESC = "Symbols";
- private static final String UI_KEYBOARD_SHIFT_KEY_DESC = "Shift";
- private static final String UI_KEYBOARD_SYMBOL_KEY_DESC = "More symbols";
- private static final String UI_KEYBOARD_VIEW_ID = "keyboard_view";
- private static final String UI_RESOURCE_NAME = "com.android.inputmethod.latin";
- private static final String UI_PACKAGE_NAME = "com.google.android.inputmethod.latin";
- private static final String UI_QUICK_SEARCH_BOX_PACKAGE_NAME =
- "com.google.android.googlequicksearchbox";
-
- private static final char KEYBOARD_TEST_LOWER_CASE_LETTER = 'a';
- private static final char KEYBOARD_TEST_NUMBER = '1';
- private static final char KEYBOARD_TEST_SYMBOL = '~';
- private static final char KEYBOARD_TEST_UPPER_CASE_LETTER = 'A';
-
- private static final long KEYBOARD_MODE_CHANGE_TIMEOUT = 5000; // 5 secs
-
- static {
- Map<Character, String> specialKeyContentDescriptions = new HashMap<>();
- specialKeyContentDescriptions.put(' ', "Space");
- specialKeyContentDescriptions.put('I', "Capital I");
- specialKeyContentDescriptions.put('Δ', "Increment");
- specialKeyContentDescriptions.put('©', "Copyright sign");
- specialKeyContentDescriptions.put('®', "Registered sign");
- specialKeyContentDescriptions.put('â„¢', "Trade mark sign");
- specialKeyContentDescriptions.put('â„…', "Care of");
- SPECIAL_KEY_CONTENT_DESCRIPTIONS =
- Collections.unmodifiableMap(specialKeyContentDescriptions);
-
- String alwaysVisibleCharacters = ".,";
- ALWAYS_VISIBLE_CHARACTERS = createImmutableSet(alwaysVisibleCharacters);
-
- String keyboardNumberScreenSymbols = "@#$%&-+()*\"':;!?_/";
- KEYBOARD_NUMBER_SCREEN_SYMBOLS = createImmutableSet(keyboardNumberScreenSymbols);
-
- String keyboardOtherSymbols = "~`|•√π÷×¶Δ£¢€¥^°={}\\©®™℅[]<>";
- KEYBOARD_OTHER_SYMBOLS = createImmutableSet(keyboardOtherSymbols);
- }
-
- public GoogleKeyboardHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- throw new UnsupportedOperationException(
- "There is no explicit open method for the Google Keyboard");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void exit() {
- throw new UnsupportedOperationException(
- "There is no explicit close method for the Google Keyboard");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.inputmethod.latin";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Google Keyboard";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- mDevice.pressHome();
- UiObject2 searchPlate = mDevice.findObject(
- By.res(UI_QUICK_SEARCH_BOX_PACKAGE_NAME, "search_plate"));
- if (searchPlate != null) {
- searchPlate.click();
- UiObject2 skipGoogleNowButton = mDevice.wait(Until.findObject(
- By.res(UI_QUICK_SEARCH_BOX_PACKAGE_NAME, UI_DECLINE_BUTTON_ID)), 20000);
- if (skipGoogleNowButton != null) {
- skipGoogleNowButton.click();
- }
- BySelector closeSelector = By.text(Pattern.compile("CLOSE", Pattern.CASE_INSENSITIVE));
- UiObject2 closeButton = mDevice.wait(Until.findObject(closeSelector), 5000);
- if (closeButton == null) {
- throw new UnknownUiException("Could not find close button to dismiss the" +
- "Google Keyboard dialog.");
- }
- closeButton.click();
- mDevice.wait(Until.gone(closeSelector), 5000);
- }
-
- }
-
- private static Set<Character> createImmutableSet(String setCharacters) {
- if (setCharacters == null) {
- throw new IllegalArgumentException("setCharacters cannot be null.");
- }
- Set<Character> tempSet = new HashSet<>();
- for (int i = 0; i < setCharacters.length(); ++i) {
- tempSet.add(setCharacters.charAt(i));
- }
- return Collections.unmodifiableSet(tempSet);
- }
-
- private UiObject2 getKeyboardView() {
- return mDevice.findObject(By.clazz(UI_ANDROID_VIEW_CLASS).res(
- UI_RESOURCE_NAME, UI_KEYBOARD_VIEW_ID));
- }
-
- private UiObject2 getShiftKey() {
- return mDevice.findObject(
- By.clazz(UI_KEYBOARD_KEY_CLASS).desc(UI_KEYBOARD_SHIFT_KEY_DESC));
- }
-
- private UiObject2 getNumberKey() {
- return mDevice.findObject(
- By.clazz(UI_KEYBOARD_KEY_CLASS).desc(UI_KEYBOARD_NUMBER_KEY_DESC));
- }
-
- private UiObject2 getLetterKey() {
- return mDevice.findObject(
- By.clazz(UI_KEYBOARD_KEY_CLASS).desc(UI_KEYBOARD_LETTER_KEY_DESC));
- }
-
- private UiObject2 getSymbolKey() {
- return mDevice.findObject(
- By.clazz(UI_KEYBOARD_KEY_CLASS).desc(UI_KEYBOARD_SYMBOL_KEY_DESC));
- }
-
- private String getKeyDesc(char key) {
- String specialKeyDesc = SPECIAL_KEY_CONTENT_DESCRIPTIONS.get(key);
- if (specialKeyDesc != null) {
- return specialKeyDesc;
- } else {
- return String.valueOf(key);
- }
- }
-
- private UiObject2 getKeyboardKey(char key) {
- String keyDesc = getKeyDesc(key);
-
- return mDevice.findObject(By.clazz(UI_KEYBOARD_KEY_CLASS).desc(keyDesc));
- }
-
- private boolean isLowerCaseLetter(char c) {
- return (c >= 'a' && c <= 'z');
- }
-
- private boolean isUpperCaseLetter(char c) {
- return (c >= 'A' && c <= 'Z');
- }
-
- private boolean isDigit(char c) {
- return (c >= '0' && c <= '9');
- }
-
- private boolean isKeyboardOpen() {
- return (getKeyboardView() != null);
- }
-
- private boolean isOnLowerCaseMode() {
- return (getKeyboardKey(KEYBOARD_TEST_LOWER_CASE_LETTER) != null);
- }
-
- private boolean isOnUpperCaseMode() {
- return (getKeyboardKey(KEYBOARD_TEST_UPPER_CASE_LETTER) != null);
- }
-
- private boolean isOnNumberMode() {
- return (getKeyboardKey(KEYBOARD_TEST_NUMBER) != null);
- }
-
- private boolean isOnSymbolMode() {
- return (getKeyboardKey(KEYBOARD_TEST_SYMBOL) != null);
- }
-
- private void toggleShiftMode() {
- UiObject2 shiftKey = getShiftKey();
- if (shiftKey == null) {
- throw new UnknownUiException("Could not find the Shift key.");
- }
- shiftKey.click();
- }
-
- private void switchToLetterMode() {
- UiObject2 letterKey = getLetterKey();
- if (letterKey == null) {
- throw new UnknownUiException("Could not find the letter key.");
- }
- letterKey.click();
- }
-
- private void switchToLowerCaseMode() {
- if (isOnNumberMode() || isOnSymbolMode()) {
- switchToLetterMode();
- }
-
- if (isOnUpperCaseMode()) {
- toggleShiftMode();
- }
-
- boolean success = mDevice.wait(Until.hasObject(By.clazz(UI_KEYBOARD_KEY_CLASS).desc(
- String.valueOf(KEYBOARD_TEST_LOWER_CASE_LETTER))), KEYBOARD_MODE_CHANGE_TIMEOUT);
- if (!success) {
- throw new UnknownUiException("Could not switch to lower case letters mode.");
- }
- }
-
- private void switchToUpperCaseMode() {
- if (isOnNumberMode() || isOnSymbolMode()) {
- switchToLetterMode();
- }
-
- if (isOnLowerCaseMode()) {
- toggleShiftMode();
- }
-
- boolean success = mDevice.wait(Until.hasObject(By.clazz(UI_KEYBOARD_KEY_CLASS).desc(
- String.valueOf(KEYBOARD_TEST_UPPER_CASE_LETTER))), KEYBOARD_MODE_CHANGE_TIMEOUT);
- if (!success) {
- throw new UnknownUiException("Could not switch to upper case letters mode.");
- }
- }
-
- private void switchToNumberMode() {
- if (!isOnNumberMode()) {
- UiObject2 numberKey = getNumberKey();
- if (numberKey == null) {
- throw new UnknownUiException("Could not find Number key.");
- }
- numberKey.click();
- }
-
- boolean success = mDevice.wait(Until.hasObject(By.clazz(UI_KEYBOARD_KEY_CLASS).desc(
- String.valueOf(KEYBOARD_TEST_NUMBER))), KEYBOARD_MODE_CHANGE_TIMEOUT);
- if (!success) {
- throw new UnknownUiException("Could not switch to number mode on Google Keyboard.");
- }
- }
-
- private void switchToSymbolMode() {
- if (isOnLowerCaseMode() || isOnUpperCaseMode()) {
- switchToNumberMode();
- }
-
- if (isOnNumberMode()) {
- UiObject2 symbolKey = getSymbolKey();
- if (symbolKey == null) {
- throw new UnknownUiException("Could not find the Symbol key.");
- }
-
- symbolKey.click();
- }
-
- boolean success = mDevice.wait(Until.hasObject(By.clazz(UI_KEYBOARD_KEY_CLASS).desc(
- String.valueOf(KEYBOARD_TEST_SYMBOL))), KEYBOARD_MODE_CHANGE_TIMEOUT);
- if (!success) {
- throw new UnknownUiException("Could not switch to Symbol mode.");
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public boolean waitForKeyboard(long timeout) {
- return mDevice.wait(Until.hasObject(By.clazz(UI_ANDROID_VIEW_CLASS).res(
- UI_RESOURCE_NAME, UI_KEYBOARD_VIEW_ID)), timeout);
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void typeText(String text, long delayBetweenKeyPresses) {
- if (!isKeyboardOpen()) {
- throw new IllegalStateException("Google Keyboard is not open.");
- }
- for (int i = 0; i < text.length(); ++i) {
- char c = text.charAt(i);
-
- if (ALWAYS_VISIBLE_CHARACTERS.contains(c)) {
- // Period and comma are visible on all keyboard modes so no need to switch modes
- } else if (isLowerCaseLetter(c)) {
- switchToLowerCaseMode();
- } else if (isUpperCaseLetter(c)) {
- switchToUpperCaseMode();
- } else if (isDigit(c) ||
- KEYBOARD_NUMBER_SCREEN_SYMBOLS.contains(c)) {
- switchToNumberMode();
- } else if (KEYBOARD_OTHER_SYMBOLS.contains(c)) {
- switchToSymbolMode();
- } else {
- throw new IllegalArgumentException(
- String.format("Unrecognized character '%c'", c));
- }
- UiObject2 keyboardKey = getKeyboardKey(c);
- if (keyboardKey == null) {
- throw new UnknownUiException(
- String.format("Could not find key '%c' on Google Keyboard", c));
- }
-
- keyboardKey.click();
- SystemClock.sleep(delayBetweenKeyPresses);
- }
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/google-messenger-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/google-messenger-app-helper/Android.mk
deleted file mode 100644
index cf548b0d6..000000000
--- a/libraries/first-party-app-helpers/handheld/google-messenger-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := google-messenger-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/google-messenger-app-helper/src/android/platform/test/helpers/GoogleMessengerHelperImpl.java b/libraries/first-party-app-helpers/handheld/google-messenger-app-helper/src/android/platform/test/helpers/GoogleMessengerHelperImpl.java
deleted file mode 100644
index d7b08c03f..000000000
--- a/libraries/first-party-app-helpers/handheld/google-messenger-app-helper/src/android/platform/test/helpers/GoogleMessengerHelperImpl.java
+++ /dev/null
@@ -1,275 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-
-import java.util.List;
-
-public class GoogleMessengerHelperImpl extends AbstractGoogleMessengerHelper {
- private static final String TAG = GoogleMessengerHelperImpl.class.getSimpleName();
-
- private static final String UI_ATTACH_MEDIA_BUTTON_ID = "attach_media_button";
- private static final String UI_CHOOSE_PHOTO_TEXT = "Choose photo";
- private static final String UI_COMPOSE_MESSAGE_TEXT_ID = "compose_message_text";
- private static final String UI_CONTACT_NAME_ID = "contact_name";
- private static final String UI_MEDIA_FROM_DEVICE_DESC = "Choose images from this device";
- private static final String UI_MEDIA_GALLERY_GRID_VIEW_ID = "gallery_grid_view";
- private static final String UI_MEDIA_PICKER_TABSTRIP_ID = "mediapicker_tabstrip";
- private static final String UI_PACKAGE_NAME = "com.google.android.apps.messaging";
- private static final String UI_RECIPIENT_TEXT_VIEW_ID = "recipient_text_view";
- private static final String UI_SEND_MESSAGE_BUTTON_ID = "send_message_button";
- private static final String UI_START_NEW_CONVERSATION_BUTTON_ID =
- "start_new_conversation_button";
-
- private static final long UI_DIALOG_WAIT = 5000; // 5 sec
-
- public GoogleMessengerHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE_NAME;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Messenger";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
-
- }
-
- private UiObject2 getStartNewConversationButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_START_NEW_CONVERSATION_BUTTON_ID));
- }
-
- private UiObject2 getRecipientTextView() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_RECIPIENT_TEXT_VIEW_ID));
- }
-
- private UiObject2 getComposeMessageEditText() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_COMPOSE_MESSAGE_TEXT_ID));
- }
-
- private UiObject2 getSendMessageButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_SEND_MESSAGE_BUTTON_ID));
- }
-
- private UiObject2 getMessageRecyclerView() {
- return mDevice.findObject(By.pkg(UI_PACKAGE_NAME)
- .clazz("android.support.v7.widget.RecyclerView").res("android", "list"));
- }
-
- private UiObject2 getAttachMediaButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_ATTACH_MEDIA_BUTTON_ID));
- }
-
- private UiObject2 getMediaFromDeviceTab() {
- return mDevice.findObject(By.pkg(UI_PACKAGE_NAME).desc(UI_MEDIA_FROM_DEVICE_DESC));
- }
-
- private UiObject2 getMediaGalleryGridView() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_MEDIA_GALLERY_GRID_VIEW_ID));
- }
-
- private boolean isOnHomePage() {
- return (getStartNewConversationButton() != null);
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void goToHomePage() {
- for (int retriesRemaining = 5; retriesRemaining > 0 && !isOnHomePage();
- --retriesRemaining) {
- mDevice.pressBack();
- mDevice.waitForIdle();
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void goToNewConversationPage() {
- UiObject2 startNewConversationButton = getStartNewConversationButton();
- if (startNewConversationButton == null) {
- throw new IllegalStateException("Could not find start new conversation button");
- }
-
- startNewConversationButton.click();
- if (!mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_RECIPIENT_TEXT_VIEW_ID)), UI_DIALOG_WAIT)) {
- throw new UnknownUiException("Could not find recipient text view");
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void goToMessagesPage() {
- UiObject2 contact = mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_CONTACT_NAME_ID));
- if (contact == null) {
- throw new IllegalStateException("Could not find first contact drop down menu item");
- }
-
- contact.click();
- if (!mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_COMPOSE_MESSAGE_TEXT_ID)), UI_DIALOG_WAIT)) {
- throw new UnknownUiException("Could not find compose message edit text");
- }
- }
-
- private void goToFullscreenChooseMediaPage() {
- UiObject2 mediaGalleryGridView = getMediaGalleryGridView();
- if (mediaGalleryGridView == null) {
- throw new IllegalStateException("Could not find media gallery grid view");
- }
-
- mediaGalleryGridView.scroll(Direction.DOWN, 5.0f);
- if (!mDevice.wait(Until.hasObject(By.pkg(UI_PACKAGE_NAME).text(UI_CHOOSE_PHOTO_TEXT)),
- UI_DIALOG_WAIT)) {
- throw new UnknownUiException("Could not find full screen media gallery grid view");
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void scrollMessages(Direction direction) {
- if (!(Direction.UP.equals(direction) || Direction.DOWN.equals(direction))) {
- throw new IllegalArgumentException("Direction must be UP or DOWN");
- }
-
- UiObject2 messageRecyclerView = getMessageRecyclerView();
- if (messageRecyclerView == null) {
- throw new UnknownUiException("Could not find message recycler view");
- }
-
- messageRecyclerView.scroll(direction, 10.0f);
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void clickComposeMessageText() {
- UiObject2 composeMessageEditText = getComposeMessageEditText();
- if (composeMessageEditText == null) {
- throw new IllegalStateException("Could not find compose message edit text");
- }
-
- composeMessageEditText.click();
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void clickSendMessageButton() {
- UiObject2 sendMessageButton = getSendMessageButton();
- if (sendMessageButton == null) {
- throw new IllegalStateException("Could not find send message button");
- }
-
- sendMessageButton.click();
- }
-
- private void clickAttachMediaButton() {
- UiObject2 attachMediaButton = getAttachMediaButton();
- if (attachMediaButton == null) {
- throw new IllegalStateException("Could not find attach media button");
- }
-
- attachMediaButton.click();
- if (!mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_MEDIA_PICKER_TABSTRIP_ID)), UI_DIALOG_WAIT)) {
- throw new UnknownUiException("Could not find media picker tabstrip");
- }
- }
-
- private void clickMediaFromDeviceTab() {
- UiObject2 mediaFromDeviceTab = getMediaFromDeviceTab();
- if (mediaFromDeviceTab == null) {
- throw new IllegalStateException("Could not find media from device tab");
- }
-
- if (!mediaFromDeviceTab.isSelected()) {
- mediaFromDeviceTab.click();
- if (!mDevice.wait(Until.hasObject(By.pkg(UI_PACKAGE_NAME).desc(
- UI_MEDIA_FROM_DEVICE_DESC).selected(true)), UI_DIALOG_WAIT)) {
- throw new UnknownUiException("Media from device tab not selected");
- }
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void attachMediaFromDevice(int index) {
- clickAttachMediaButton();
- clickMediaFromDeviceTab();
- goToFullscreenChooseMediaPage();
-
- UiObject2 mediaGalleryGridView = getMediaGalleryGridView();
- if (mediaGalleryGridView == null) {
- throw new UnknownUiException("Could not find media gallery grid view");
- }
-
- List<UiObject2> mediaGalleryChildren = mediaGalleryGridView.getChildren();
- if (index < 0 || index >= mediaGalleryChildren.size()) {
- throw new IndexOutOfBoundsException(String.format("index %d >= size %d",
- index, mediaGalleryChildren.size()));
- }
-
- int imageChildIndex = 1;
- UiObject2 imageView = mediaGalleryChildren.get(index).
- getChildren().get(imageChildIndex);
- while (getMediaGalleryGridView() != null) {
- imageView.click();
- // Needed to prevent StaleObjectException
- SystemClock.sleep(2000);
- }
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/maps-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/maps-app-helper/Android.mk
deleted file mode 100644
index 74259a368..000000000
--- a/libraries/first-party-app-helpers/handheld/maps-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := maps-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/maps-app-helper/src/android/platform/test/helpers/MapsHelperImpl.java b/libraries/first-party-app-helpers/handheld/maps-app-helper/src/android/platform/test/helpers/MapsHelperImpl.java
deleted file mode 100644
index ed9e20e87..000000000
--- a/libraries/first-party-app-helpers/handheld/maps-app-helper/src/android/platform/test/helpers/MapsHelperImpl.java
+++ /dev/null
@@ -1,369 +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 android.platform.test.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.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-
-import java.util.regex.Pattern;
-
-
-public class MapsHelperImpl extends AbstractMapsHelper {
- private static final String LOG_TAG = MapsHelperImpl.class.getSimpleName();
-
- private static final String UI_CLOSE_NAVIGATION_DESC = "Close navigation";
- private static final String UI_DIRECTIONS_BUTTON_ID = "placepage_directions_button";
- private static final String UI_START_NAVIGATION_BUTTON_ID = "start_button";
- private static final String UI_TEXTVIEW_CLASS = "android.widget.TextView";
- private static final String UI_PROGRESSBAR_CLASS = "android.widget.ProgressBar";
- private static final String UI_PACKAGE = "com.google.android.apps.maps";
- private static final String UI_SIDE_MENU_ID = "layers_menu_container";
- private static final String UI_SELECTABLE_SEARCHBAR_ID = "search_omnibox_text_box";
- private static final String UI_EDITABLE_SEARCHBAR_ID = "search_omnibox_edit_text";
-
- private static final int UI_RESPONSE_WAIT = 5000;
- private static final int SEARCH_RESPONSE_WAIT = 25000;
- private static final int MAP_SERVER_CONNECT_WAIT = 120000;
-
- private static final int MAX_CONNECT_TO_SERVER_RETRY = 5;
- private static final int MAX_START_NAV_RETRY = 5;
- private static final int MAX_DISMISS_INITIAL_DIALOG_RETRY = 2;
-
- public MapsHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.apps.maps";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Maps";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- Log.v(LOG_TAG, "Maps dismissing initial welcome screen.");
-
- // ToS welcome dialog
- boolean successTosDismiss = hasSearchBar(0);
-
- String text = "ACCEPT & CONTINUE";
- Pattern pattern = Pattern.compile(text, Pattern.CASE_INSENSITIVE);
-
- UiObject2 terms = mDevice.wait(Until.findObject(By.text(pattern)), 10000);
- int tryCounter = 0;
-
- while ((terms != null) && (tryCounter < MAX_DISMISS_INITIAL_DIALOG_RETRY)) {
- terms.click();
-
- mDevice.wait(Until.gone(By.pkg(UI_PACKAGE).clazz(UI_PROGRESSBAR_CLASS)),
- MAP_SERVER_CONNECT_WAIT);
-
- if (!checkServerConnectivity()) {
- throw new IllegalStateException("Unable to connect to Google Maps server");
- }
-
- terms = mDevice.wait(Until.findObject(By.text(pattern)), UI_RESPONSE_WAIT);
- tryCounter += 1;
- }
-
- if (terms != null) {
- throw new IllegalStateException("Unable to dismiss initial dialogs");
- }
-
- exit();
- open();
-
- // Location services dialog
- text = "YES, I'M IN";
- pattern = Pattern.compile(text, Pattern.CASE_INSENSITIVE);
- UiObject2 location = mDevice.wait(Until.findObject(By.text(pattern)),
- UI_RESPONSE_WAIT);
- if (location != null) {
- location.click();
- mDevice.waitForIdle();
- } else {
- Log.e(LOG_TAG, "Did not find a location services dialog.");
- }
-
- // 'Side menu' dialog
- text = "GOT IT";
- pattern = Pattern.compile(text, Pattern.CASE_INSENSITIVE);
- BySelector gotIt = By.text(Pattern.compile("GOT IT", Pattern.CASE_INSENSITIVE));
- UiObject2 sideMenuTut = mDevice.wait(Until.findObject(gotIt), 5000);
- if (sideMenuTut != null) {
- sideMenuTut.click();
- } else {
- Log.e(LOG_TAG, "Did not find any 'side menu' dialog.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void doSearch(String query) {
- Log.v(LOG_TAG, "Maps doing an address search");
-
- if (!checkServerConnectivity()) {
- throw new IllegalStateException("Cannot connect to Google Maps servers");
- }
-
- // Navigate if necessary
- goToQueryScreen();
- // Select search bar
- UiObject2 searchSelect = getSelectableSearchBar(0);
- if (searchSelect == null) {
- throw new IllegalStateException("No selectable search bar found.");
- }
- searchSelect.click();
-
- // Edit search query
- UiObject2 searchEdit = getEditableSearchBar(UI_RESPONSE_WAIT);
- if (searchEdit == null) {
- throw new IllegalStateException("Not editable search bar found.");
- }
- searchEdit.clear();
- searchEdit.setText(query);
-
- // Search and wait for the directions option
- UiObject2 firstAddressResult = mDevice.wait(Until.findObject(By.pkg(UI_PACKAGE).clazz(
- UI_TEXTVIEW_CLASS)), SEARCH_RESPONSE_WAIT);
- if (firstAddressResult == null) {
- String err_msg = String.format("Did not detect address result after %d seconds",
- (int) Math.floor(SEARCH_RESPONSE_WAIT / 1000));
- throw new IllegalStateException(err_msg);
- }
- firstAddressResult.click();
-
- if (getDirectionsButton(SEARCH_RESPONSE_WAIT) == null) {
- throw new IllegalStateException("Could not find directions button");
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void getDirections() {
- Log.v(LOG_TAG, "Maps getting direction.");
-
- dismissPullUpDialog();
-
- UiObject2 directionsButton = getDirectionsButton(UI_RESPONSE_WAIT);
- if (directionsButton == null) {
- throw new IllegalStateException("Unable to find start direction button");
- }
- directionsButton.click();
-
- dismissGetARidePopUp();
- if (getStartNavigationButton(UI_RESPONSE_WAIT) == null) {
- throw new IllegalStateException("Unable to find start navigation button");
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void startNavigation() {
- Log.v(LOG_TAG, "starting navigation.");
-
- UiObject2 startNavigationButton = getStartNavigationButton(UI_RESPONSE_WAIT);
-
- if (startNavigationButton == null) {
- dismissGetARidePopUp();
- startNavigationButton = getStartNavigationButton(UI_RESPONSE_WAIT);
-
- if (startNavigationButton == null) {
- throw new IllegalStateException("Unable to find start navigation button");
- }
- }
- startNavigationButton.click();
-
- boolean hasCloseNavigationDesc = (getCloseNavigationButton(UI_RESPONSE_WAIT) != null);
- int tryCounter = 0;
- while ((tryCounter < MAX_START_NAV_RETRY) && (!hasCloseNavigationDesc)) {
- dismissBetaUseDialog();
- dismissSearchAlongRoutePopUp();
- hasCloseNavigationDesc = (getCloseNavigationButton(UI_RESPONSE_WAIT) != null);
- tryCounter += 1;
- }
-
- if (!hasCloseNavigationDesc) {
- throw new IllegalStateException("Unable to find close navigation button");
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void stopNavigation() {
- Log.v(LOG_TAG, "stopping navigation.");
-
- dismissSearchAlongRoutePopUp();
-
- UiObject2 closeNavigationButton = getCloseNavigationButton(0);
-
- if (closeNavigationButton != null) {
- closeNavigationButton.click();
- }
-
- if (hasNavigationButton(UI_RESPONSE_WAIT)) {
- mDevice.pressBack();
- }
- }
-
- private void goToQueryScreen() {
- // First check if side menu is opened, if it is, back out.
- // Search bar may still be partially visible because side menu
- // only covers part of screen
- if (mDevice.wait(Until.hasObject(By.res(UI_PACKAGE, UI_SIDE_MENU_ID)),
- UI_RESPONSE_WAIT)) {
- Log.e(LOG_TAG, "Found side menu, backing out");
- mDevice.pressBack();
- }
-
- for (int backup = 5; backup > 0; backup--) {
- if (hasSearchBar(0)) {
- return;
- } else {
- mDevice.pressBack();
- mDevice.waitForIdle();
- }
- }
- }
-
- private UiObject2 getSelectableSearchBar(int wait_time) {
- return mDevice.wait(Until.findObject(By.res(UI_PACKAGE, UI_SELECTABLE_SEARCHBAR_ID)),
- wait_time);
- }
-
- private UiObject2 getEditableSearchBar(int wait_time) {
- return mDevice.wait(Until.findObject(By.res(UI_PACKAGE, UI_EDITABLE_SEARCHBAR_ID)),
- wait_time);
- }
-
- private UiObject2 getStartNavigationButton(int wait_time) {
- return mDevice.wait(Until.findObject(By.res(UI_PACKAGE, UI_START_NAVIGATION_BUTTON_ID)),
- wait_time);
- }
-
- private UiObject2 getCloseNavigationButton(int wait_time) {
- return mDevice.wait(Until.findObject(By.pkg(UI_PACKAGE).desc(UI_CLOSE_NAVIGATION_DESC)),
- wait_time);
- }
-
- private UiObject2 getDirectionsButton(int wait_time) {
- return mDevice.wait(Until.findObject(By.res(UI_PACKAGE, UI_DIRECTIONS_BUTTON_ID)),
- wait_time);
- }
-
- private boolean hasSearchBar(int wait_time) {
- return ((getSelectableSearchBar(wait_time) != null) ||
- (getEditableSearchBar(wait_time) != null));
- }
-
- private boolean hasNavigationButton(int wait_time) {
- return ((getStartNavigationButton(wait_time) != null) ||
- (getDirectionsButton(wait_time) != null));
- }
-
- // check connectivity issues by looking for "TRY AGAIN" pop-up dialog
- private boolean checkServerConnectivity() {
- int tryCounter = 0;
-
- UiObject2 tryAgainButton = mDevice.wait(Until.findObject(By.text("TRY AGAIN")),
- UI_RESPONSE_WAIT);
- while ((tryCounter < MAX_CONNECT_TO_SERVER_RETRY) && (tryAgainButton != null)) {
- tryAgainButton.click();
-
- tryAgainButton = mDevice.wait(Until.findObject(By.text("TRY AGAIN")),
- MAP_SERVER_CONNECT_WAIT);
- tryCounter += 1;
- }
-
- if (tryAgainButton != null) {
- return false;
- }
- else {
- return true;
- }
- }
-
- // Dismiss pop up dialog with title "Google Maps Navigation is in beta. Use caution"
- private void dismissBetaUseDialog() {
- UiObject2 acceptButton = mDevice.wait(
- Until.findObject(By.text("ACCEPT")),
- UI_RESPONSE_WAIT);
- if (acceptButton != null) {
- acceptButton.click();
- mDevice.wait(Until.gone(By.text("ACCEPT")), UI_RESPONSE_WAIT);
- }
- }
-
- // Dismiss pop-up dialog with title "Search along route"
- private void dismissSearchAlongRoutePopUp() {
- UiObject2 searchAlongRoute = mDevice.wait(
- Until.findObject(By.textContains("Search along route")),
- UI_RESPONSE_WAIT);
- if (searchAlongRoute != null) {
- mDevice.pressBack();
- }
- }
-
- // Dismiss pop-up dialog with title "Pull up"
- private void dismissPullUpDialog() {
- UiObject2 gotItButton = mDevice.wait(
- Until.findObject(By.text("GOT IT")),
- UI_RESPONSE_WAIT);
- if (gotItButton != null) {
- gotItButton.click();
- mDevice.wait(Until.gone(By.text("GOT IT")), UI_RESPONSE_WAIT);
- }
- }
-
- // Dismiss pop-up advertising for taxi-ride with title "Get a ride in minutes"
- private void dismissGetARidePopUp() {
- UiObject2 getARide = mDevice.wait(
- Until.findObject(By.textContains("Get a ride in minutes")),
- UI_RESPONSE_WAIT);
- if (getARide != null) {
- mDevice.pressBack();
- }
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/photos-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/photos-app-helper/Android.mk
deleted file mode 100644
index 6d3dcbaf2..000000000
--- a/libraries/first-party-app-helpers/handheld/photos-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := photos-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/photos-app-helper/src/android/platform/test/helpers/PhotosHelperImpl.java b/libraries/first-party-app-helpers/handheld/photos-app-helper/src/android/platform/test/helpers/PhotosHelperImpl.java
deleted file mode 100644
index 588b73f2f..000000000
--- a/libraries/first-party-app-helpers/handheld/photos-app-helper/src/android/platform/test/helpers/PhotosHelperImpl.java
+++ /dev/null
@@ -1,509 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-
-import java.util.List;
-import java.util.regex.Pattern;
-
-import junit.framework.Assert;
-
-
-import android.os.Environment;
-import java.io.File;
-import java.io.IOException;
-
-public class PhotosHelperImpl extends AbstractPhotosHelper {
- private static final String LOG_TAG = PhotosHelperImpl.class.getSimpleName();
-
- private static final long APP_LOAD_WAIT = 7500;
- private static final long HACKY_WAIT = 2500;
- private static final long PICTURE_LOAD_WAIT = 20000;
- private static final long UI_NAVIGATION_WAIT = 5000;
-
- private static final Pattern UI_PHOTO_DESC = Pattern.compile("^Photo.*");
-
- private static final String UI_DONE_BUTTON_ID = "done_button";
- private static final String UI_GET_STARTED_CONTAINER = "get_started_container";
- private static final String UI_GET_STARTED_ID = "get_started";
- private static final String UI_LOADING_ICON_ID = "list_empty_progress_bar";
- private static final String UI_NEXT_BUTTON_ID = "next_button";
- private static final String UI_PACKAGE_NAME = "com.google.android.apps.photos";
- private static final String UI_PHOTO_TAB_ID = "tab_photos";
- private static final String UI_DEVICE_FOLDER_TEXT = "Device folders";
- private static final String UI_PHOTO_VIEW_PAGER_ID = "photo_view_pager";
- private static final String UI_PHOTO_SCROLL_VIEW_ID = "recycler_view";
- private static final String UI_NAVIGATION_LIST_ID = "navigation_list";
- private static final int MAX_UI_SCROLL_COUNT = 20;
- private static final int MAX_DISMISS_INIT_DIALOG_RETRY = 20;
-
- public PhotosHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.apps.photos";
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Photos";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- // Target Photos version 1.18.0.119671374
- SystemClock.sleep(APP_LOAD_WAIT);
-
- if (isOnInitialDialogScreen()) {
- UiObject2 getStartedButton = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE_NAME, UI_GET_STARTED_ID)), APP_LOAD_WAIT);
- int retryCount = 0;
- while ((retryCount < MAX_DISMISS_INIT_DIALOG_RETRY) &&
- (getStartedButton == null)) {
- /*
- The UiAutomator sometimes cannot find GET STARTED button even though
- it is seen on the screen.
- The reason is because the initial "spinner" animation screen updates
- views too quickly for UiAutomator to catch the change.
-
- The following hack is used to reload the init dialog for UiAutomator to
- retry catching the GET STARTED button.
- */
-
- mDevice.pressBack();
- mDevice.waitForIdle();
- mDevice.pressHome();
- mDevice.waitForIdle();
- open();
-
- getStartedButton = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE_NAME, UI_GET_STARTED_ID)),
- APP_LOAD_WAIT);
- retryCount += 1;
-
- if (!isOnInitialDialogScreen()) {
- break;
- }
- }
-
- if (isOnInitialDialogScreen() && (getStartedButton == null)) {
- throw new IllegalStateException("UiAutomator cannot catch GET STARTED button");
- }
- else {
- if (getStartedButton != null) {
- getStartedButton.click();
- }
- }
- }
- else {
- Log.e(LOG_TAG, "Didn't find GET STARTED button.");
- }
-
- // Address dialogs with an account vs. without an account
- Pattern signInWords = Pattern.compile("Sign in", Pattern.CASE_INSENSITIVE);
- boolean hasAccount = !mDevice.hasObject(By.text(signInWords));
- if (!hasAccount) {
- // Select 'NO THANKS' if no account exists
- Pattern noThanksWords = Pattern.compile("No thanks", Pattern.CASE_INSENSITIVE);
- UiObject2 noThanksButton = mDevice.findObject(By.text(noThanksWords));
- if (noThanksButton != null) {
- noThanksButton.click();
- mDevice.waitForIdle();
- } else {
- Log.e(LOG_TAG, "Unable to find NO THANKS button.");
- }
- } else {
- UiObject2 doneButton = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_DONE_BUTTON_ID)), 5000);
- if (doneButton != null) {
- doneButton.click();
- mDevice.waitForIdle();
- }
- else {
- Log.e(LOG_TAG, "Didn't find DONE button.");
- }
-
- // Press the next button (arrow and check mark) four consecutive times
- for (int repeat = 0; repeat < 4; repeat++) {
- UiObject2 nextButton = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_NEXT_BUTTON_ID));
- if (nextButton != null) {
- nextButton.click();
- mDevice.waitForIdle();
- } else {
- Log.e(LOG_TAG, "Unable to find arrow or check mark buttons.");
- }
- }
-
- mDevice.wait(Until.gone(
- By.res(UI_PACKAGE_NAME, UI_LOADING_ICON_ID)), PICTURE_LOAD_WAIT);
- }
-
- mDevice.waitForIdle();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openFirstClip() {
- if (searchForVideoClip()) {
- UiObject2 clip = getFirstClip();
- if (clip != null) {
- clip.click();
- mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, "photos_videoplayer_play_button_holder")), 2000);
- }
- else {
- throw new IllegalStateException("Cannot play a video after finding video clips");
- }
- }
- else {
- throw new UnsupportedOperationException("Cannot find a video clip");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void pauseClip() {
- UiObject2 holder = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, "photos_videoplayer_play_button_holder"));
- if (holder != null) {
- holder.click();
- } else {
- throw new UnknownUiException("Unable to find pause button holder.");
- }
-
- UiObject2 pause = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, "photos_videoplayer_pause_button")), 2500);
- if (pause != null) {
- pause.click();
- mDevice.wait(Until.findObject(By.desc("Play video")), 2500);
- } else {
- throw new UnknownUiException("Unable to find pause button.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void playClip() {
- UiObject2 play = mDevice.findObject(By.desc("Play video"));
- if (play != null) {
- play.click();
- mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, "photos_videoplayer_pause_button")), 2500);
- } else {
- throw new UnknownUiException("Unable to find play button");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToMainScreen() {
- for (int retriesRemaining = 5; retriesRemaining > 0 && !isOnMainScreen();
- --retriesRemaining) {
- // check if we see the Photos tab at the bottom of the screen
- // If we do, clicking on the tab should go to home screen.
- UiObject2 photosButton = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_PHOTO_TAB_ID));
- if (photosButton != null) {
- photosButton.click();
- }
- else {
- mDevice.pressBack();
- }
- mDevice.waitForIdle();
- }
-
- if (!isOnMainScreen()) {
- throw new IllegalStateException("Cannot go to main screen");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openPicture(int index) {
-
- mDevice.waitForIdle();
- List<UiObject2> photos = mDevice.findObjects(By.pkg(UI_PACKAGE_NAME).desc(UI_PHOTO_DESC));
-
- if (photos == null) {
- throw new IllegalStateException("Cannot find photos on current view screen");
- }
-
- if ((index < 0) || (index >= photos.size())) {
- String errMsg = String.format("Photo index (%d) out of bound (0..%d)",
- index, photos.size());
- throw new IllegalArgumentException(errMsg);
- }
-
- UiObject2 photo = photos.get(index);
- photo.click();
- if (!mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, UI_PHOTO_VIEW_PAGER_ID)),
- UI_NAVIGATION_WAIT)) {
- throw new IllegalStateException("Cannot display photo on screen");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollAlbum(Direction direction) {
- if (!(Direction.LEFT.equals(direction) || Direction.RIGHT.equals(direction))) {
- throw new IllegalArgumentException("Scroll direction must be LEFT or RIGHT");
- }
-
- UiObject2 scrollContainer = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_PHOTO_VIEW_PAGER_ID));
-
- if (scrollContainer == null) {
- throw new UnknownUiException("Cannot find scroll container");
- }
-
- scrollContainer.scroll(direction, 1.0f);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToDeviceFolderScreen() {
- if (!isOnDeviceFolderScreen()) {
-
- if (!isOnMainScreen()) {
- goToMainScreen();
- }
-
- openNavigationDrawer();
-
- UiObject2 deviceFolderButton = mDevice.wait(Until.findObject(
- By.text(UI_DEVICE_FOLDER_TEXT)), UI_NAVIGATION_WAIT);
- if (deviceFolderButton != null) {
- deviceFolderButton.click();
- }
- else {
- UiObject2 photosButton = mDevice.wait(Until.findObject(By.text("Photos")),
- UI_NAVIGATION_WAIT);
- if (photosButton != null) {
- photosButton.click();
- }
- else {
- throw new IllegalStateException("No device folder in navigation drawer");
- }
- }
- }
-
- if (!isOnDeviceFolderScreen()) {
- throw new UnknownUiException("Can not go to device folder screen");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean searchForDeviceFolder(String folderName) {
- boolean foundFolder = false;
- int scrollCount = 0;
- while (!foundFolder && (scrollCount < MAX_UI_SCROLL_COUNT)) {
- foundFolder = mDevice.wait(Until.hasObject(By.text(folderName)), 2000);
- if (!foundFolder) {
- if (!scrollView(Direction.DOWN)) {
- break;
- }
- }
- scrollCount += 1;
- }
-
- if (!foundFolder) {
- foundFolder = mDevice.wait(Until.hasObject(By.text(folderName)), 2000);
- }
-
- return foundFolder;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean searchForVideoClip() {
- boolean foundVideoClip = false;
- int scrollCount = 0;
- while (!foundVideoClip && (scrollCount < MAX_UI_SCROLL_COUNT)) {
- foundVideoClip = (getFirstClip() != null);
- if (!foundVideoClip) {
- if (!scrollView(Direction.DOWN)) {
- break;
- }
- }
- scrollCount += 1;
- }
- return foundVideoClip;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean searchForPicture() {
- boolean foundPicture = false;
- int scrollCount = 0;
- while (!foundPicture && (scrollCount < MAX_UI_SCROLL_COUNT)) {
- foundPicture = mDevice.wait(Until.hasObject(By.descStartsWith("Photo")), 2000);
- if (!foundPicture) {
- if (!scrollView(Direction.DOWN)) {
- break;
- }
- }
- scrollCount += 1;
- }
- return foundPicture;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openDeviceFolder(String folderName) {
- UiObject2 deviceFolder = mDevice.wait(Until.findObject(By.text(folderName)),
- UI_NAVIGATION_WAIT);
- if (deviceFolder != null) {
- deviceFolder.click();
- }
- else {
- throw new IllegalArgumentException(String.format("Cannot open device folder %s",
- folderName));
- }
- }
-
- private UiObject2 getFirstClip() {
- return mDevice.wait(Until.findObject(By.descStartsWith("Video")), 2000);
- }
-
- /**
- * This function returns true if Photos is currently on the first-use
- * initial dialog screen, with "Get Started" button displayed on screen
- *
- * @return Returns true if app is on the initial dialog screen, false otherwise
- */
- private boolean isOnInitialDialogScreen() {
- return mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_GET_STARTED_CONTAINER));
- }
-
- private boolean isOnMainScreen() {
- return mDevice.hasObject(By.descContains("Show Navigation Drawer"));
- }
-
- /**
- * This function returns true if Photos is currently in the
- * photo-viewing screen, displaying either one photo
- * or video on the screen.
- *
- * @return Returns true if one photo or video is displayed on the screen,
- * false otherwise.
- */
- private boolean isOnPhotoViewingScreen() {
- return mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_PHOTO_VIEW_PAGER_ID));
- }
-
- private boolean isOnDeviceFolderScreen() {
-
- if (mDevice.hasObject(By.pkg(UI_PACKAGE_NAME).text(UI_DEVICE_FOLDER_TEXT))) {
- return true;
- }
-
- // sometimes the "Device Folder" tab is hidden.
- // scroll down once to make sure the tab is visible
- UiObject2 scrollContainer = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_PHOTO_SCROLL_VIEW_ID));
- if (scrollContainer != null) {
- scrollContainer.scroll(Direction.DOWN, 1.0f);
- return mDevice.hasObject(By.pkg(UI_PACKAGE_NAME).text(UI_DEVICE_FOLDER_TEXT));
- }
- else {
- return false;
- }
- }
-
- /**
- * This function performs one scroll on the current screen, in the direction
- * specified by input argument.
- *
- * @param dir The direction of the scroll
- * @return Returns whether the object can still scroll in the given direction
- */
- private boolean scrollView(Direction dir) {
- UiObject2 scrollContainer = mDevice.findObject(By.res(UI_PACKAGE_NAME,
- UI_PHOTO_SCROLL_VIEW_ID));
- if (scrollContainer == null) {
- return false;
- }
-
- return scrollContainer.scroll(dir, 1.0f);
- }
-
- private void openNavigationDrawer() {
- UiObject2 navigationDrawer = mDevice.findObject(By.desc("Show Navigation Drawer"));
- if (navigationDrawer == null) {
- mDevice.pressBack();
- navigationDrawer = mDevice.wait(Until.findObject(By.desc("Show Navigation Drawer")),
- UI_NAVIGATION_WAIT);
- }
-
- if (navigationDrawer == null) {
- throw new UnknownUiException("Cannot find navigation drawer");
- }
-
- navigationDrawer.click();
-
- if (!mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_NAVIGATION_LIST_ID))) {
- throw new UnknownUiException("Cannot open navigation drawer");
- }
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/play-books-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/play-books-app-helper/Android.mk
deleted file mode 100644
index 47da20ec1..000000000
--- a/libraries/first-party-app-helpers/handheld/play-books-app-helper/Android.mk
+++ /dev/null
@@ -1,24 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := play-books-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
diff --git a/libraries/first-party-app-helpers/handheld/play-books-app-helper/src/android/platform/test/helpers/PlayBooksHelperImpl.java b/libraries/first-party-app-helpers/handheld/play-books-app-helper/src/android/platform/test/helpers/PlayBooksHelperImpl.java
deleted file mode 100644
index e54985a3f..000000000
--- a/libraries/first-party-app-helpers/handheld/play-books-app-helper/src/android/platform/test/helpers/PlayBooksHelperImpl.java
+++ /dev/null
@@ -1,280 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.os.SystemClock;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiObject2;
-
-import junit.framework.Assert;
-
-import java.lang.IllegalStateException;
-
-/**
- * UI test helper for Play Books: The Official App (package: com.google.android.apps.books).
- * Implementation based on app version: 3.8.15
- */
-
-public class PlayBooksHelperImpl extends AbstractPlayBooksHelper {
-
- private static final String LOG_TAG = PlayBooksHelperImpl.class.getSimpleName();
-
- private static final String UI_PACKAGE_NAME = "com.google.android.apps.books";
- private static final String UI_NAVIGATE_UP_DESC = "Navigate up";
- private static final String UI_NAVIGATION_DRAWER_BUTTON_DESC = "Show navigation drawer";
- private static final String UI_EXIT_BOOK_DESC = "Exit book";
- private static final String UI_TAB_ALL_BOOKS_TEXT = "ALL BOOKS";
- private static final String UI_NAVIGATION_DRAWER_SETTING_TEXT = "Settings";
- private static final String UI_NAVIGATION_DRAWER_MYLIBRARY_TEXT = "My library";
- private static final String UI_OPTION_MENU_READ_ALOUD_TEXT = "Read aloud";
- private static final String UI_TURN_SYNC_ON_TEXT = "TURN SYNC ON";
- private static final String UI_SKIP_TEXT = "SKIP";
- private static final String UI_FULL_SCREEN_READER = "reader";
- private static final String UI_PLAY_DRAWER_ROOT = "play_drawer_root";
- private static final String UI_BOOK_THUMBNAIL = "li_thumbnail";
-
- private static final long SKIP_DELAY = 2000; // 2 secs
- private static final long UI_ANIMATION_TIMEOUT = 2500; // 2.5 secs
- private static final long OPEN_BOOK_TIMEOUT = 10000; // 10 secs
- private static final long SYNCING_BOOKS_TIMEOUT = 10000; //10 secs
-
- public PlayBooksHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.apps.books";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Play Books";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- UiObject2 skipButton = getSkipButton();
- if (skipButton != null) {
- skipButton.click();
- SystemClock.sleep(SKIP_DELAY);
- }
- UiObject2 turnSyncOnButton = getTurnSyncOnButton();
- if (turnSyncOnButton != null) {
- turnSyncOnButton.click();
- SystemClock.sleep(SYNCING_BOOKS_TIMEOUT);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToAllBooksTab() {
- closeOptionMenu();
- exitReadingMode();
- closeSettingPanel();
- openNavigationDrawer();
- UiObject2 myLibraryButton = getMyLibraryButton();
- Assert.assertNotNull("Can't find \"My Library\" button", myLibraryButton);
- myLibraryButton.click();
- UiObject2 allBooksButton = mDevice.wait(Until.findObject(
- By.text(UI_TAB_ALL_BOOKS_TEXT).clickable(true)),
- UI_ANIMATION_TIMEOUT);
- Assert.assertNotNull("Can't find \"ALL BOOKS\" tab button", allBooksButton);
- allBooksButton.click();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openBook() {
- UiObject2 bookThumbNail = getBookThumbnail();
- Assert.assertNotNull("No book in \"ALL BOOKS\" library", bookThumbNail);
- bookThumbNail.click();
- mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_FULL_SCREEN_READER)),
- OPEN_BOOK_TIMEOUT);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void exitReadingMode() {
- UiObject2 exitBookButton = null;
- UiObject2 fullScreenReader = getFullScreenReader();
- if (fullScreenReader != null) {
- fullScreenReader.click();
- exitBookButton = mDevice.wait(
- Until.findObject(By.desc(UI_EXIT_BOOK_DESC)),
- UI_ANIMATION_TIMEOUT);
- Assert.assertNotNull("Fail to exit full screen reader mode", exitBookButton);
- } else {
- exitBookButton = getExitBookButton();
- }
- if (exitBookButton != null) {
- exitBookButton.click();
- boolean hasNavButton = mDevice.wait(Until.hasObject(
- By.desc(UI_NAVIGATION_DRAWER_BUTTON_DESC)),
- UI_ANIMATION_TIMEOUT);
- Assert.assertTrue("Fail to exit reading mode", hasNavButton);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToNextPage() {
- UiObject2 fullScreenReader = getFullScreenReader();
- if (fullScreenReader == null) {
- throw new IllegalStateException("Not on a full-screen page of a book");
- }
- int displayHeight = mDevice.getDisplayHeight();
- int displayWidth = mDevice.getDisplayWidth();
- int nextPageX = displayWidth - 1;
- int nextPageY = displayHeight / 2;
- mDevice.click(nextPageX, nextPageY);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToPreviousPage() {
- UiObject2 fullScreenReader = getFullScreenReader();
- if (fullScreenReader == null) {
- throw new IllegalStateException("Not on a full-screen page of a book");
- }
- int displayHeight = mDevice.getDisplayHeight();
- int displayWidth = mDevice.getDisplayWidth();
- int previousPageX = 0;
- int previousPageY = displayHeight / 2;
- mDevice.click(previousPageX, previousPageY);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollToNextPage() {
- UiObject2 fullScreenReader = getFullScreenReader();
- if (fullScreenReader == null) {
- throw new IllegalStateException("Not on a full-screen page of a book");
- }
- fullScreenReader.scroll(Direction.RIGHT, 1.0f);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollToPreviousPage() {
- UiObject2 fullScreenReader = getFullScreenReader();
- if (fullScreenReader == null) {
- throw new IllegalStateException("Not on a full-screen page of a book");
- }
- fullScreenReader.scroll(Direction.LEFT, 1.0f);
- }
-
- private void closeOptionMenu() {
- if (isOptionMenuExpanded()) {
- mDevice.pressBack();
- }
- }
-
- private void closeSettingPanel() {
- UiObject2 backButton = getBackButton();
- if (backButton != null) {
- backButton.click();
- boolean hasNavButton = mDevice.wait(Until.hasObject(
- By.desc(UI_NAVIGATION_DRAWER_BUTTON_DESC)),
- UI_ANIMATION_TIMEOUT);
- Assert.assertNotNull("Fail to close setting panel", hasNavButton);
- }
- }
-
- private void openNavigationDrawer() {
- if (isDrawerOpen()) {
- return;
- }
- UiObject2 navButton = getNavButton();
- Assert.assertNotNull("Unable to find navigation drawer button", navButton);
- navButton.click();
- waitForNavigationDrawerOpen();
- }
-
- private boolean isOptionMenuExpanded() {
- return mDevice.hasObject(By.text(UI_OPTION_MENU_READ_ALOUD_TEXT));
- }
-
- private boolean isDrawerOpen() {
- return mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_PLAY_DRAWER_ROOT));
- }
-
- private UiObject2 getSkipButton() {
- return mDevice.findObject(By.text(UI_SKIP_TEXT));
- }
-
- private UiObject2 getTurnSyncOnButton() {
- return mDevice.findObject(By.text(UI_TURN_SYNC_ON_TEXT));
- }
-
- private UiObject2 getFullScreenReader() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_FULL_SCREEN_READER));
- }
-
- private UiObject2 getExitBookButton() {
- return mDevice.findObject(By.desc(UI_EXIT_BOOK_DESC));
- }
-
- private UiObject2 getBackButton() {
- return mDevice.findObject(By.desc(UI_NAVIGATE_UP_DESC));
- }
-
- private UiObject2 getNavButton() {
- return mDevice.findObject(By.desc(UI_NAVIGATION_DRAWER_BUTTON_DESC));
- }
-
- private UiObject2 getMyLibraryButton() {
- return mDevice.findObject(By.text(UI_NAVIGATION_DRAWER_MYLIBRARY_TEXT).clickable(true));
- }
-
- private UiObject2 getBookThumbnail() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_BOOK_THUMBNAIL));
- }
-
- private void waitForNavigationDrawerOpen() {
- mDevice.wait(Until.hasObject(
- By.text(UI_NAVIGATION_DRAWER_SETTING_TEXT).clickable(true)),
- UI_ANIMATION_TIMEOUT);
- }
-} \ No newline at end of file
diff --git a/libraries/first-party-app-helpers/handheld/play-movies-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/play-movies-app-helper/Android.mk
deleted file mode 100644
index 9c39a62c3..000000000
--- a/libraries/first-party-app-helpers/handheld/play-movies-app-helper/Android.mk
+++ /dev/null
@@ -1,24 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := play-movies-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
diff --git a/libraries/first-party-app-helpers/handheld/play-movies-app-helper/src/android/platform/test/helpers/PlayMoviesHelperImpl.java b/libraries/first-party-app-helpers/handheld/play-movies-app-helper/src/android/platform/test/helpers/PlayMoviesHelperImpl.java
deleted file mode 100644
index 99830f5f2..000000000
--- a/libraries/first-party-app-helpers/handheld/play-movies-app-helper/src/android/platform/test/helpers/PlayMoviesHelperImpl.java
+++ /dev/null
@@ -1,215 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Configurator;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-import android.widget.EditText;
-
-import java.util.regex.Pattern;
-
-public class PlayMoviesHelperImpl extends AbstractPlayMoviesHelper {
- private static final String LOG_TAG = PlayMoviesHelperImpl.class.getSimpleName();
-
- private static final String UI_PACKAGE = "com.google.android.videos";
- private static final String UI_NAV_DRAWER_ID = "play_drawer_list";
- private static final String UI_MOVIE_LIST_ID = "play_header_listview";
-
- private static final int SEARCH_MOVIES_SCROLL_RETRY = 4;
- private static final long APP_INIT_WAIT = 5000;
-
- private boolean mIsVersion3p8 = false;
-
- public PlayMoviesHelperImpl(Instrumentation instr) {
- super(instr);
-
- try {
- mIsVersion3p8 = getVersion().startsWith("3.8");
- } catch (NameNotFoundException e) {
- Log.e(LOG_TAG, String.format("Unable to find package by name, %s", getPackage()));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- long original = Configurator.getInstance().getWaitForIdleTimeout();
- Configurator.getInstance().setWaitForIdleTimeout(1500);
-
- super.open();
-
- Configurator.getInstance().setWaitForIdleTimeout(original);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Play Movies & TV";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- if (mIsVersion3p8) {
- BySelector nextButton = By.res(UI_PACKAGE, "end_button");
- int count = 0;
- while (mDevice.hasObject(nextButton) && count < 10) {
- mDevice.findObject(nextButton).click();
- mDevice.wait(Until.gone(nextButton), 1000);
- count += 1;
- }
- BySelector gotIt = By.textContains("Got It");
- count = 0;
- while (mDevice.hasObject(gotIt) && count < 3) {
- UiObject2 gotItButton = mDevice.findObject(gotIt);
- if (gotItButton != null) {
- gotItButton.click();
- mDevice.wait(Until.gone(gotIt), 1000);
- }
- count += 1;
- }
- } else {
- long original = Configurator.getInstance().getWaitForIdleTimeout();
- Configurator.getInstance().setWaitForIdleTimeout(1500);
-
- for (int retry = 0; retry < 5; retry++) {
- Pattern words = Pattern.compile("GET STARTED", Pattern.CASE_INSENSITIVE);
- UiObject2 startedButton = mDevice.wait(Until.findObject(By.text(words)), 5000);
- if (startedButton != null) {
- startedButton.click();
- }
- }
-
- Configurator.getInstance().setWaitForIdleTimeout(original);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void openMoviesTab() {
- // Navigate to the Movies tab through the Navigation drawer
- openNavigationDrawer();
- Pattern myLibraryPattern = Pattern.compile("My Library", Pattern.CASE_INSENSITIVE);
- UiObject2 libraryButton = mDevice.findObject(By.text(myLibraryPattern).clickable(true));
- libraryButton.click();
- waitForNavigationDrawerClose();
- // Select the Movies tab if necessary
- UiObject2 moviesTab = getMoviesTab();
- if (moviesTab == null) {
- throw new UnknownUiException("Unable to find the movies tab.");
- }
- if (!moviesTab.isSelected()) {
- moviesTab.click();
- mDevice.waitForIdle();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void playMovie(String name) {
- UiObject2 title = null;
- for (int retry = 0; retry < SEARCH_MOVIES_SCROLL_RETRY; retry++) {
- title = mDevice.findObject(By.textContains(name));
- if (title == null) {
- UiObject2 scroller = mDevice.findObject(By.res(UI_PACKAGE, UI_MOVIE_LIST_ID));
- if (scroller != null) {
- scroller.scroll(Direction.DOWN, 1.0f);
- }
- }
- }
- if (title == null) {
- throw new IllegalArgumentException(
- String.format("Failed to find movie by name %s", name));
- }
- title.click();
- UiObject2 play = mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "play")), 5000);
- if (play == null) {
- throw new UnknownUiException("Failed to find the play button.");
- }
- play.click();
- mDevice.waitForIdle();
- }
-
- private boolean isNavigationDrawerOpen () {
- return mDevice.hasObject(By.res(UI_PACKAGE, UI_NAV_DRAWER_ID));
- }
-
- private void openNavigationDrawer() {
- if (isNavigationDrawerOpen()) {
- return;
- }
-
- UiObject2 backButton = mDevice.findObject(By.pkg(getPackage()).desc("Navigate up"));
- if (backButton != null) {
- backButton.click();
- mDevice.wait(Until.findObject(By.desc("Show navigation drawer")), 5000);
- }
-
- UiObject2 navButton = mDevice.findObject(By.desc("Show navigation drawer"));
- if (navButton == null) {
- throw new UnknownUiException("Unable to find the navigation drawer button.");
- }
- navButton.click();
- waitForNavigationDrawerOpen();
- }
-
- private void waitForNavigationDrawerOpen() {
- mDevice.wait(Until.hasObject(By.text("Settings").clickable(true)), 2500);
- }
-
- private void waitForNavigationDrawerClose() {
- mDevice.wait(Until.gone(By.text("Settings").clickable(true)), 2500);
- }
-
- private UiObject2 getMoviesTab() {
- Pattern moviesText = Pattern.compile("MY MOVIES", Pattern.CASE_INSENSITIVE);
- UiObject2 tab = mDevice.findObject(By.text(moviesText));
- if (tab == null) {
- moviesText = Pattern.compile("MOVIES", Pattern.CASE_INSENSITIVE);
- tab = mDevice.findObject(By.text(moviesText));
- }
- return tab;
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/play-music-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/play-music-app-helper/Android.mk
deleted file mode 100644
index b17b528d4..000000000
--- a/libraries/first-party-app-helpers/handheld/play-music-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := play-music-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/play-music-app-helper/src/android/platform/test/helpers/PlayMusicHelperImpl.java b/libraries/first-party-app-helpers/handheld/play-music-app-helper/src/android/platform/test/helpers/PlayMusicHelperImpl.java
deleted file mode 100644
index 56f5c7262..000000000
--- a/libraries/first-party-app-helpers/handheld/play-music-app-helper/src/android/platform/test/helpers/PlayMusicHelperImpl.java
+++ /dev/null
@@ -1,360 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-import java.util.regex.Pattern;
-
-public class PlayMusicHelperImpl extends AbstractPlayMusicHelper {
- private static final String LOG_TAG = PlayMusicHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.google.android.music";
-
- private static final String UI_TAB_HEADER_ID = "play_header_list_tab_scroll";
- private static final String UI_PAUSE_PLAY_BUTTON_ID = "play_pause_header";
-
- private static final long APP_LOAD_WAIT = 10000;
- private static final long APP_INIT_WAIT = 10000;
- private static final long TAB_TRANSITION_WAIT = 5000;
- private static final long EXPAND_WAIT = 5000;
- private static final long NAV_BAR_WAIT = 5000;
- private static final long TOGGLE_PAUSE_PLAY_WAIT = 5000;
-
- public PlayMusicHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.music";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Play Music";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- super.open();
- // Additional wait to combat asynchronous loading
- boolean ready = mDevice.wait(Until.hasObject(
- By.res("android", "content").hasDescendant(By.focusable(true))), 5000);
- if (!ready) {
- throw new UnknownUiException("Failed to find that the app was open.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- if(!hasRegisteredGoogleAccount()) {
- UiObject2 skip = mDevice.findObject(getSkipButtonSelector());
- if (skip != null) {
- skip.clickAndWait(Until.newWindow(), APP_INIT_WAIT);
- }
- } else {
- // There are no dialogs to dismiss.
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToTab(String tabTitle) {
- if (isLibraryTabSelected(tabTitle)) {
- return;
- } else {
- navigateToDrawerItem("Music library");
-
- for (int retries = 3; retries > 0; retries--) {
- UiObject2 title = getLibraryTab(tabTitle);
- if (title != null) {
- title.click();
- boolean titleIsSelected = mDevice.wait(
- Until.hasObject(getLibraryTabSelector(tabTitle).selected(true)),
- TAB_TRANSITION_WAIT);
-
- if (!titleIsSelected) {
- String message = String.format("Tab %s was not found selected",
- tabTitle.toUpperCase());
- throw new UnknownUiException(message);
- }
- } else {
- UiObject2 headerList = mDevice.findObject(By.res(UI_PACKAGE, UI_TAB_HEADER_ID));
- if (headerList == null) {
- throw new UnknownUiException("Could not find library header to scroll.");
- }
-
- headerList.scroll(Direction.RIGHT, 1.0f);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToListenNow() {
- navigateToDrawerItem("Listen Now");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void playAnyRadioStation() {
- // Looks for a play button to click on. If not found scrolls down and looks again.
- // Repeats 10 times.
- for (int i = 0; i < 10; i++) {
- UiObject2 playButton = mDevice.findObject(By.res(UI_PACKAGE, "li_play_button"));
- if (playButton != null) {
- playButton.click();
- return;
- }
-
- Log.d(LOG_TAG, "No play button found. Scrolling down.");
-
- //TODO: use Play Music's package name instead of 'android' when the UI is fixed.
- UiObject2 scroller = mDevice.findObject(By.res("android", "list"));
- scroller.setGestureMargin(500);
- scroller.scroll(Direction.DOWN, 1.0f);
- }
-
- throw new UnknownUiException("Couldn't find play button after several tries.");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean dismissAd(){
- Pattern skipAdPattern = Pattern.compile("Skip Ad", Pattern.CASE_INSENSITIVE);
- UiObject2 skipAdButton = mDevice.findObject(By.desc(skipAdPattern));
- if (skipAdButton != null){
- skipAdButton.click();
- return true;
- }
-
- return false;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void selectSong(String album, String song) {
- UiObject2 albumItem = mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "li_title")
- .textStartsWith(album)), EXPAND_WAIT);
- if (albumItem == null) {
- throw new IllegalStateException("Unable to find album item");
- }
-
- albumItem.click();
-
- mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "title").textStartsWith(album)),
- EXPAND_WAIT);
-
- for (int retries = 5; retries > 0; retries--) {
- UiObject2 songItem = mDevice.findObject(By.res(UI_PACKAGE, "li_title").
- textStartsWith(song));
- if (songItem != null) {
- songItem.click();
- mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE, "trackname").textStartsWith(song)), EXPAND_WAIT);
-
- // Waits for the animation to complete.
- mDevice.waitForIdle();
- return;
- } else {
- UiObject2 scroller = mDevice.findObject(
- By.scrollable(true));
- scroller.setGestureMargin(500);
- scroller.scroll(Direction.DOWN, 1.0f);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void pauseSong() {
- BySelector selector1play = By.res(UI_PACKAGE, UI_PAUSE_PLAY_BUTTON_ID).desc("Play");
- BySelector selector1pause = By.res(UI_PACKAGE, UI_PAUSE_PLAY_BUTTON_ID).desc("Pause");
- BySelector selector2play = By.res(UI_PACKAGE, "pause").desc("Play");
- BySelector selector2pause = By.res(UI_PACKAGE, "pause").desc("Pause");
-
- UiObject2 button = null;
- if ((button = mDevice.findObject(selector1play)) != null) {
- return;
- } else if ((button = mDevice.findObject(selector1pause)) != null) {
- button.click();
- mDevice.wait(Until.findObject(selector1play), TOGGLE_PAUSE_PLAY_WAIT);
- } else if ((button = mDevice.findObject(selector2play)) != null) {
- return;
- } else if ((button = mDevice.findObject(selector2pause)) != null) {
- button.click();
- mDevice.wait(Until.findObject(selector2play), TOGGLE_PAUSE_PLAY_WAIT);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void playSong() {
- BySelector selector1play = By.res(UI_PACKAGE, UI_PAUSE_PLAY_BUTTON_ID).desc("Play");
- BySelector selector1pause = By.res(UI_PACKAGE, UI_PAUSE_PLAY_BUTTON_ID).desc("Pause");
- BySelector selector2play = By.res(UI_PACKAGE, "pause").desc("Play");
- BySelector selector2pause = By.res(UI_PACKAGE, "pause").desc("Pause");
-
- UiObject2 button = null;
- if ((button = mDevice.findObject(selector1pause)) != null) {
- return;
- } else if ((button = mDevice.findObject(selector1play)) != null) {
- button.click();
- mDevice.wait(Until.findObject(selector1pause), TOGGLE_PAUSE_PLAY_WAIT);
- } else if ((button = mDevice.findObject(selector2pause)) != null) {
- return;
- } else if ((button = mDevice.findObject(selector2play)) != null) {
- button.click();
- mDevice.wait(Until.findObject(selector2pause), TOGGLE_PAUSE_PLAY_WAIT);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void expandMediaControls() {
- UiObject2 header = mDevice.findObject(By.res(UI_PACKAGE, "trackname"));
- if (header == null){
- throw new IllegalStateException("Unable to find header to expand media controls.");
- }
-
- header.click();
- mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "lightsUpInterceptor")), EXPAND_WAIT);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void pressShuffleAll() {
- if (!isLibraryTabSelected("Songs")) {
- throw new IllegalStateException("The Songs tab was not selected");
- }
-
- UiObject2 shuffleAll = mDevice.findObject(By.text("SHUFFLE ALL"));
- if (shuffleAll == null) {
- throw new IllegalStateException("Could not find a 'SHUFFLE ALL' button.");
- }
-
- shuffleAll.click();
- if(!mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE, UI_PAUSE_PLAY_BUTTON_ID)), TOGGLE_PAUSE_PLAY_WAIT)){
- throw new UnknownUiException("Did not detect a song playing");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void pressRepeat() {
- UiObject2 repeatButton = mDevice.findObject(By.res(UI_PACKAGE, "repeat"));
- if (repeatButton == null){
- throw new IllegalStateException("Unable to find repeat button to press.");
- }
-
- repeatButton.click();
- mDevice.waitForIdle();
- }
-
- private void navigateToDrawerItem(String itemName) {
- Pattern pattern = Pattern.compile(itemName, Pattern.CASE_INSENSITIVE);
-
- // Select for title.
- if (mDevice.findObject(By.text(pattern).clickable(false)) != null) {
- return;
- }
-
- openNavigationBar();
-
- UiObject2 button = mDevice.findObject(By.text(pattern).clickable(true));
- if (button == null){
- String message = String.format("Couldn't find button with text: %s", itemName);
- throw new UnknownUiException(message);
- }
-
- // Select for button.
- button.click();
- mDevice.wait(Until.gone(By.res(UI_PACKAGE, "play_drawer_root")), NAV_BAR_WAIT);
- }
-
- private void openNavigationBar () {
- UiObject2 navBar = getNavigationBarButton();
- if (navBar == null) {
- throw new IllegalStateException("Did not find navigation drawer button.");
- }
-
- navBar.click();
- mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "play_drawer_root")), NAV_BAR_WAIT);
- }
-
- private UiObject2 getNavigationBarButton() {
- return mDevice.findObject(By.desc("Show navigation drawer"));
- }
-
- private boolean isLibraryTabSelected(String tabTitle) {
- return mDevice.hasObject(getLibraryTabSelector(tabTitle).selected(true));
- }
-
- private UiObject2 getLibraryTab(String tabTitle) {
- return mDevice.findObject(getLibraryTabSelector(tabTitle));
- }
-
- private BySelector getSkipButtonSelector() {
- return By.res(UI_PACKAGE, "skip_button");
- }
-
- private BySelector getLibraryTabSelector(String tabTitle) {
- return By.res(UI_PACKAGE, "title").text(tabTitle.toUpperCase());
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/play-store-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/play-store-app-helper/Android.mk
deleted file mode 100644
index 0a18e48be..000000000
--- a/libraries/first-party-app-helpers/handheld/play-store-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := play-store-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/play-store-app-helper/src/android/platform/test/helpers/PlayStoreHelperImpl.java b/libraries/first-party-app-helpers/handheld/play-store-app-helper/src/android/platform/test/helpers/PlayStoreHelperImpl.java
deleted file mode 100644
index add04b2cb..000000000
--- a/libraries/first-party-app-helpers/handheld/play-store-app-helper/src/android/platform/test/helpers/PlayStoreHelperImpl.java
+++ /dev/null
@@ -1,229 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-import android.widget.EditText;
-
-public class PlayStoreHelperImpl extends AbstractPlayStoreHelper {
- private static final String LOG_TAG = PlayStoreHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.android.vending";
-
- private static final long LONG_TOS_DIALOG_WAIT = 20000;
- private static final long LOAD_RESULT_TRANSITION = 10000;
- private static final long INSTALL_DELAY = 5000;
-
- public PlayStoreHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.android.vending";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Play Store";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- if (!isAppInForeground()) {
- throw new IllegalStateException("The Play Store app is not in the foreground.");
- }
- // Dismiss the ToS dialog by pressing accept
- if (mDevice.wait(Until.hasObject(
- By.textContains("Google Play Terms of Service")), LONG_TOS_DIALOG_WAIT)) {
- mDevice.findObject(getPositiveButtonSelector()).click();
- boolean home = mDevice.wait(Until.hasObject(getSearchBoxSelector()), 10000);
- if (!home) {
- throw new UnknownUiException("Failed to reach the home screen.");
- }
- } else {
- throw new UnknownUiException("Unable to find ToS");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void doSearch(String query) {
- if (!isAppInForeground()) {
- throw new IllegalStateException("The Play Store app is not in the foreground.");
- }
- // Scroll up or press back until searching is available, or fail
- UiObject2 search = null;
- for (int retries = 5; retries > 0; retries--) {
- // Search for the search box
- search = mDevice.findObject(getSearchBoxSelector());
- if (search != null) {
- break;
- }
- // Search for the search button
- search = mDevice.findObject(getSearchButtonSelector());
- if (search != null) {
- break;
- }
- // Scroll up or back out
- if (!scrollPage(Direction.UP, 100.0f)) {
- mDevice.pressBack();
- }
- }
- if (search == null) {
- throw new UnknownUiException("Failed to find a search method.");
- }
- search.click();
- // After pressing, the search element becomes the edit text box
- UiObject2 edit = mDevice.wait(
- Until.findObject(By.clazz(EditText.class)), 5000);
- if (edit == null) {
- throw new UnknownUiException("Failed to find an edit text.");
- }
- edit.setText(query);
- mDevice.pressEnter();
- // Validate the end criteria that the search list is visible
- if (!mDevice.wait(Until.hasObject(getSearchResultSelector()), 5000)) {
- throw new UnknownUiException("Failed to find the search results.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void selectFirstResult() {
- if (!mDevice.hasObject(getSearchResultSelector())) {
- throw new IllegalStateException("No available search result list.");
- }
- UiObject2 result = mDevice.findObject(By.res(UI_PACKAGE, "play_card"));
- if (result == null) {
- throw new UnknownUiException("Failed to find a search result card.");
- }
- result.click();
- if (!mDevice.wait(Until.hasObject(getAppTitleSelector()), LOAD_RESULT_TRANSITION)) {
- throw new UnknownUiException("Failed to find the app page open.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void installApp() {
- // #isAppInstalled also verifies that this is an app page
- if (isAppInstalled()) {
- throw new IllegalStateException("This app is already installed.");
- }
-
- UiObject2 install = mDevice.findObject(getInstallButtonSelector());
- if (install == null) {
- throw new UnknownUiException("Could not find an install button.");
- }
- install.click();
-
- // Search for the Android 6.0 permission dialog
- if (mDevice.wait(Until.hasObject(getAndroid6DialogSelector()), 2500)) {
- mDevice.findObject(getPositiveButtonSelector()).click();
- mDevice.waitForIdle();
- } else {
- // If the install button is present, then downloading failed
- if (mDevice.wait(Until.findObject(
- getInstallButtonSelector()), INSTALL_DELAY) != null) {
- throw new UnknownUiException("Did not detect that the installation started.");
- }
- }
- }
-
- private boolean scrollPage(Direction dir, float value) {
- UiObject2 scroller = mDevice.findObject(By.res(UI_PACKAGE, "recycler_view"));
- if (scroller == null) {
- scroller = mDevice.findObject(By.res(UI_PACKAGE, "viewpager"));
- }
-
- if (scroller != null) {
- return scroller.scroll(dir, value);
- } else {
- return false;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAppInstalled() {
- if (!isAppPage()) {
- throw new IllegalStateException("Play Store was not on the app's install page.");
- }
- return (mDevice.findObject(getInstallButtonSelector()) == null);
- }
-
- private boolean isAppPage () {
- // Warning: this can fail if the page is scrolled down
- return mDevice.hasObject(getAppTitleSelector());
- }
-
- private BySelector getPositiveButtonSelector() {
- return By.res(UI_PACKAGE, "positive_button");
- }
-
- private BySelector getSearchBoxSelector() {
- return By.res(UI_PACKAGE, "search_box_idle_text");
- }
-
- private BySelector getSearchButtonSelector() {
- return By.res(UI_PACKAGE, "search_button");
- }
-
- private BySelector getSearchResultSelector() {
- return By.res(UI_PACKAGE, "search_results_list");
- }
-
- private BySelector getAppTitleSelector() {
- return By.res(UI_PACKAGE, "title_background");
- }
-
- private BySelector getInstallButtonSelector() {
- return By.res(UI_PACKAGE, "buy_button");
- }
-
- private BySelector getAndroid6DialogSelector() {
- return By.res(UI_PACKAGE, "optional_permissions_help_screen");
- }
-}
-
diff --git a/libraries/first-party-app-helpers/handheld/recents-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/recents-app-helper/Android.mk
deleted file mode 100644
index b565ad8de..000000000
--- a/libraries/first-party-app-helpers/handheld/recents-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := recents-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/recents-app-helper/src/android/platform/test/helpers/RecentsHelperImpl.java b/libraries/first-party-app-helpers/handheld/recents-app-helper/src/android/platform/test/helpers/RecentsHelperImpl.java
deleted file mode 100644
index 3f2425b96..000000000
--- a/libraries/first-party-app-helpers/handheld/recents-app-helper/src/android/platform/test/helpers/RecentsHelperImpl.java
+++ /dev/null
@@ -1,102 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-import android.widget.EditText;
-
-public class RecentsHelperImpl extends AbstractRecentsHelper {
- private static final String LOG_TAG = RecentsHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.android.systemui";
-
- private static final long RECENTS_SELECTION_TIMEOUT = 5000;
-
- public RecentsHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- throw new UnsupportedOperationException("This method is not supported for Recents");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- throw new UnsupportedOperationException("This method is not supported for Recents");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- try {
- mDevice.pressRecentApps();
- mDevice.waitForIdle();
- } catch (RemoteException ex) {
- Log.e(LOG_TAG, ex.toString());
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void exit() {
- mDevice.pressHome();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- // Nothing to do.
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void flingRecents(Direction dir) {
- UiObject2 container = getRecentsContainer();
- if (container == null) {
- throw new IllegalStateException("The recent apps screen is not open.");
- }
- container.setGestureMargin(container.getVisibleBounds().height() / 4);
- container.fling(dir);
- }
-
- private UiObject2 getRecentsContainer() {
- return mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "recents_view")),
- RECENTS_SELECTION_TIMEOUT);
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/settings-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/settings-app-helper/Android.mk
deleted file mode 100644
index 462e592a0..000000000
--- a/libraries/first-party-app-helpers/handheld/settings-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := settings-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/settings-app-helper/src/android/platform/test/helpers/SettingsHelperImpl.java b/libraries/first-party-app-helpers/handheld/settings-app-helper/src/android/platform/test/helpers/SettingsHelperImpl.java
deleted file mode 100644
index 206c9103e..000000000
--- a/libraries/first-party-app-helpers/handheld/settings-app-helper/src/android/platform/test/helpers/SettingsHelperImpl.java
+++ /dev/null
@@ -1,218 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.provider.Settings;
-import android.provider.Settings.SettingNotFoundException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.platform.test.helpers.AbstractSettingsHelper;
-import android.util.Log;
-
-import junit.framework.Assert;
-
-import java.util.regex.Pattern;
-
-public class SettingsHelperImpl extends AbstractSettingsHelper {
-
- private static final int SETTINGS_DASH_TIMEOUT = 3000;
- private static final String UI_PACKAGE_NAME = "com.android.settings";
- private static final BySelector SETTINGS_DASHBOARD = By.res(UI_PACKAGE_NAME,
- "dashboard_container");
- private static final int TIMEOUT = 2000;
- private static final String LOG_TAG = SettingsHelperImpl.class.getSimpleName();
-
- private ContentResolver mResolver;
-
- public static enum SettingsType {
- SYSTEM,
- SECURE,
- GLOBAL
- }
-
- public SettingsHelperImpl(Instrumentation instr) {
- super(instr);
- mResolver = instr.getContext().getContentResolver();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.android.settings";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Settings";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollThroughSettings(int numberOfFlings) throws Exception {
- UiObject2 settingsList = loadAllSettings();
- int count = 0;
- while (count <= numberOfFlings && settingsList.fling(Direction.DOWN)) {
- count++;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void flingSettingsToStart() throws Exception {
- UiObject2 settingsList = loadAllSettings();
- while (settingsList.fling(Direction.UP));
- }
-
- public static void launchSettingsPage(Context ctx, String pageName) throws Exception {
- Intent intent = new Intent(pageName);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- ctx.startActivity(intent);
- Thread.sleep(TIMEOUT * 2);
- }
-
- public void scrollVert(boolean isUp) {
- int w = mDevice.getDisplayWidth();
- int h = mDevice.getDisplayHeight();
- mDevice.swipe(w / 2, h / 2, w / 2, isUp ? h : 0, 2);
- }
-
- /**
- * On N, the settingsDashboard is initially collapsed, and the user can see the "See all"
- * element. On hitting "See all", the same settings dashboard element is now scrollable. For
- * pre-N, the settings Dashboard is always scrollable, hence the check in the while loop. All
- * this method does is expand the Settings list if needed, before returning the element.
- */
- private UiObject2 loadAllSettings() throws Exception {
- UiObject2 settingsDashboard = mDevice.wait(Until.findObject(SETTINGS_DASHBOARD),
- SETTINGS_DASH_TIMEOUT);
- Assert.assertNotNull("Could not find the settings dashboard object.", settingsDashboard);
- int count = 0;
- while (!settingsDashboard.isScrollable() && count <= 2) {
- mDevice.wait(Until.findObject(By.text("SEE ALL")), SETTINGS_DASH_TIMEOUT).click();
- settingsDashboard = mDevice.wait(Until.findObject(SETTINGS_DASHBOARD),
- SETTINGS_DASH_TIMEOUT);
- count++;
- }
- return settingsDashboard;
- }
-
- public void clickSetting(String settingName) throws InterruptedException {
- mDevice.wait(Until.findObject(By.text(settingName)), TIMEOUT).click();
- Thread.sleep(400);
- }
-
- public void clickSetting(Pattern settingName) throws InterruptedException {
- mDevice.wait(Until.findObject(By.text(settingName)), TIMEOUT).click();
- Thread.sleep(400);
- }
-
- public boolean verifyToggleSetting(SettingsType type, String settingAction,
- String settingName, String internalName) throws Exception {
- return verifyToggleSetting(
- type, settingAction, Pattern.compile(settingName), internalName, true);
- }
-
- public boolean verifyToggleSetting(SettingsType type, String settingAction,
- Pattern settingName, String internalName) throws Exception {
- return verifyToggleSetting(type, settingAction, settingName, internalName, true);
- }
-
- public boolean verifyToggleSetting(SettingsType type, String settingAction,
- String settingName, String internalName, boolean doLaunch) throws Exception {
- return verifyToggleSetting(
- type, settingAction, Pattern.compile(settingName), internalName, doLaunch);
- }
-
- public boolean verifyToggleSetting(SettingsType type, String settingAction,
- Pattern settingName, String internalName, boolean doLaunch) throws Exception {
- String onSettingBaseVal = getStringSetting(type, internalName);
- if (onSettingBaseVal == null) {
- onSettingBaseVal = "0";
- }
- int onSetting = Integer.parseInt(onSettingBaseVal);
- Log.d(null, "On Setting value is : " + onSetting);
- if (doLaunch) {
- launchSettingsPage(mInstrumentation.getContext(), settingAction);
- }
- clickSetting(settingName);
- Log.d(null, "Clicked setting : " + settingName);
- Thread.sleep(1000);
- String changedSetting = getStringSetting(type, internalName);
- Log.d(null, "Changed Setting value is : " + changedSetting);
- if (changedSetting == null) {
- Log.d(null, "Changed Setting value is : NULL");
- changedSetting = "0";
- }
- return (1 - onSetting) == Integer.parseInt(changedSetting);
- }
-
- public boolean verifyRadioSetting(SettingsType type, String settingAction,
- String baseName, String settingName,
- String internalName, String testVal) throws Exception {
- if (baseName != null) clickSetting(baseName);
- clickSetting(settingName);
- Thread.sleep(500);
- return getStringSetting(type, internalName).equals(testVal);
- }
-
- private String getStringSetting(SettingsType type, String sName) {
- switch (type) {
- case SYSTEM:
- return Settings.System.getString(mResolver, sName);
- case GLOBAL:
- return Settings.Global.getString(mResolver, sName);
- case SECURE:
- return Settings.Secure.getString(mResolver, sName);
- }
- return "";
- }
-
- private int getIntSetting(SettingsType type, String sName) throws SettingNotFoundException {
- switch (type) {
- case SYSTEM:
- return Settings.System.getInt(mResolver, sName);
- case GLOBAL:
- return Settings.Global.getInt(mResolver, sName);
- case SECURE:
- return Settings.Secure.getInt(mResolver, sName);
- }
- return Integer.MIN_VALUE;
- }
-}
diff --git a/libraries/first-party-app-helpers/handheld/youtube-app-helper/Android.mk b/libraries/first-party-app-helpers/handheld/youtube-app-helper/Android.mk
deleted file mode 100644
index 10fb92105..000000000
--- a/libraries/first-party-app-helpers/handheld/youtube-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := youtube-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/first-party-app-helpers/handheld/youtube-app-helper/src/android/platform/test/helpers/YouTubeHelperImpl.java b/libraries/first-party-app-helpers/handheld/youtube-app-helper/src/android/platform/test/helpers/YouTubeHelperImpl.java
deleted file mode 100644
index 2750f477b..000000000
--- a/libraries/first-party-app-helpers/handheld/youtube-app-helper/src/android/platform/test/helpers/YouTubeHelperImpl.java
+++ /dev/null
@@ -1,493 +0,0 @@
-/*
- * Copyright (C) 2015 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.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.Configuration;
-import android.graphics.Point;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UiTimeoutException;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-
-import java.util.regex.Pattern;
-
-public class YouTubeHelperImpl extends AbstractYouTubeHelper {
- private static final String TAG = AbstractYouTubeHelper.class.getSimpleName();
-
- private static final String UI_ACCOUNT_BUTTON_DESC = "Account";
- private static final String UI_HOME_CONTAINER_ID = "results";
- private static final String UI_FULLSCREEN_BUTTON_DESC = "Enter fullscreen";
- private static final String UI_HELP_AND_FEEDBACK_TEXT = "Help & feedback";
- private static final String UI_HOME_BUTTON_DESC = "Home";
- private static final String UI_HOME_PAGE_VIDEO_ID = "event_item";
- private static final String UI_VIDEO_INFO_VIEW_ID = "video_info_view";
- private static final String UI_PACKAGE_NAME = "com.google.android.youtube";
- private static final String UI_PLAY_VIDEO_DESC = "Play video";
- private static final String UI_PROGRESS_ID = "load_progress";
- private static final String UI_RESULT_FILTER_ID = "menu_filter_results";
- private static final String UI_SEARCH_BUTTON_ID = "menu_search";
- private static final String UI_SEARCH_EDIT_TEXT_ID = "search_edit_text";
- private static final String UI_SELECT_DIALOG_LISTVIEW_ID = "select_dialog_listview";
- private static final String UI_TRENDING_BUTTON_DESC = "Trending";
- private static final String UI_VIDEO_PLAYER_ID = "watch_player";
- private static final String UI_VIDEO_PLAYER_OVERFLOW_BUTTON_ID = "player_overflow_button";
- private static final String UI_VIDEO_PLAYER_PLAY_PAUSE_REPLAY_BUTTON_ID =
- "player_control_play_pause_replay_button";
- private static final String UI_VIDEO_PLAYER_QUALITY_BUTTON_ID = "quality_button";
-
- private static final long MAX_HOME_LOAD_WAIT = 30 * 1000;
- private static final long MAX_VIDEO_LOAD_WAIT = 30 * 1000;
-
- private static final long APP_INIT_WAIT = 20000;
- private static final long STANDARD_DIALOG_WAIT = 5000;
- private static final long UI_NAVIGATION_WAIT = 5000;
-
- public YouTubeHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return "com.google.android.youtube";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "YouTube";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- BySelector dialog1 = By.text("OK");
- // Dismiss the splash screen that might appear on first start.
- UiObject2 splash = mDevice.wait(Until.findObject(dialog1), APP_INIT_WAIT);
- if (splash != null) {
- splash.click();
- mDevice.wait(Until.gone(dialog1), STANDARD_DIALOG_WAIT);
- }
-
- UiObject2 laterButton = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, "later_button")), STANDARD_DIALOG_WAIT);
- if (laterButton != null) {
- laterButton.clickAndWait(Until.newWindow(), STANDARD_DIALOG_WAIT);
- }
-
- UiObject2 helpAndFeedbackButton = mDevice.findObject(
- By.pkg(UI_PACKAGE_NAME).text(UI_HELP_AND_FEEDBACK_TEXT));
- if (helpAndFeedbackButton != null) {
- mDevice.pressBack();
- mDevice.wait(Until.gone(By.pkg(UI_PACKAGE_NAME).text(UI_HELP_AND_FEEDBACK_TEXT)),
- STANDARD_DIALOG_WAIT);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void playHomePageVideo() {
- if (!isOnHomePage()) {
- throw new IllegalStateException("YouTube is not on the home page.");
- }
-
- if (hasConnectionEstablishedMessage()) {
- pressGoOnline();
- }
-
- for (int i = 0; i < 3; i++) {
- UiObject2 video = getPlayableVideo();
- if (video != null) {
- video.click();
- waitForVideoToLoad(UI_NAVIGATION_WAIT);
- return;
- } else {
- scrollHomePage(Direction.DOWN);
- }
- }
-
- if (isLoading()) {
- throw new UiTimeoutException("Timed out waiting for video search results.");
- }
-
- throw new UnknownUiException("Unsuccessful attempt playing home page video.");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void playSearchResultPageVideo() {
- if (!isOnSearchResultsPage()) {
- throw new IllegalStateException("YouTube is not on the home page.");
- }
-
- for (int i = 0; i < 3; i++) {
- UiObject2 video = getPlayableVideo();
- if (video != null) {
- video.click();
- waitForVideoToLoad(UI_NAVIGATION_WAIT);
- return;
- } else {
- scrollSearchResultsPage(Direction.DOWN);
- }
- }
-
- throw new UnknownUiException("Unsuccessful attempt playing search result video.");
- }
-
- private UiObject2 getHomePageContainer() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HOME_CONTAINER_ID));
- }
-
- private UiObject2 getSearchResultsPageContainer() {
- return getHomePageContainer();
- }
-
- private UiObject2 getHomeButton() {
- return mDevice.findObject(By.pkg(UI_PACKAGE_NAME).desc(UI_HOME_BUTTON_DESC));
- }
-
- private UiObject2 getTrendingButton() {
- return mDevice.findObject(By.pkg(UI_PACKAGE_NAME).desc(UI_TRENDING_BUTTON_DESC));
- }
-
- private UiObject2 getAccountButton() {
- return mDevice.findObject(By.pkg(UI_PACKAGE_NAME).desc(UI_ACCOUNT_BUTTON_DESC));
- }
-
- private UiObject2 getSearchButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_SEARCH_BUTTON_ID));
- }
-
- private void scrollHomePage(Direction dir) {
- if (dir == Direction.RIGHT || dir == Direction.LEFT) {
- throw new IllegalArgumentException("Can only scroll up and down.");
- }
-
- UiObject2 scrollContainer = getHomePageContainer();
- if (scrollContainer != null) {
- scrollContainer.scroll(dir, 1.0f);
- mDevice.waitForIdle();
- } else {
- throw new UnknownUiException("No scrolling mechanism found.");
- }
- }
-
- private void scrollSearchResultsPage(Direction dir) {
- if (dir == Direction.RIGHT || dir == Direction.LEFT) {
- throw new IllegalArgumentException("Can only scroll up and down.");
- }
-
- UiObject2 scrollContainer = getSearchResultsPageContainer();
- if (scrollContainer != null) {
- scrollContainer.scroll(dir, 1.0f);
- mDevice.waitForIdle();
- } else {
- throw new UnknownUiException("No scrolling mechanism found.");
- }
- }
-
- private boolean isLoading() {
- // TODO: Is loading what? Requires more documentation.
- return mDevice.hasObject(By.res(UI_PACKAGE_NAME, UI_PROGRESS_ID));
- }
-
- private boolean isOnHomePage() {
- UiObject2 homeButton = getHomeButton();
- return (homeButton != null && homeButton.isSelected());
- }
-
- private boolean isOnTrendingPage() {
- UiObject2 trendingButton = getTrendingButton();
- return (trendingButton != null && trendingButton.isSelected());
- }
-
- private boolean isOnAccountPage() {
- UiObject2 accountButton = getAccountButton();
- return (accountButton != null && accountButton.isSelected());
- }
-
- private boolean isOnSearchResultsPage() {
- // Simplest way to identify search result page is the result filter button.
- UiObject2 resultFilterButton =
- mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_RESULT_FILTER_ID));
- return (resultFilterButton != null);
- }
-
- private UiObject2 getPlayableVideo() {
- UiObject2 video = mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HOME_PAGE_VIDEO_ID));
- if (video == null) {
- video = mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_VIDEO_INFO_VIEW_ID));
- }
- return video;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean waitForVideoToLoad(long timeout) {
- return mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_VIDEO_PLAYER_ID)), timeout);
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToHomePage() {
- for (int retriesRemaining = 5; retriesRemaining > 0 && getHomeButton() == null &&
- getTrendingButton() == null && getAccountButton() == null; --retriesRemaining) {
- mDevice.pressBack();
- SystemClock.sleep(3000);
- }
- // Get and press the home button
- UiObject2 homeButton = getHomeButton();
- if (homeButton == null) {
- throw new UnknownUiException("Could not find home button.");
- } else if (!homeButton.isSelected()) {
- homeButton.click();
- // Validate the home button is selected
- if (!mDevice.wait(Until.hasObject(
- By.pkg(UI_PACKAGE_NAME).desc(UI_HOME_BUTTON_DESC).selected(true)),
- UI_NAVIGATION_WAIT)) {
- throw new UnknownUiException("Not on home page after pressing home button.");
- } else {
- // Make sure the transition is complete
- mDevice.waitForIdle();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToSearchPage() {
- if (!isOnHomePage()) {
- throw new IllegalStateException("YouTube is not on the home page.");
- }
-
- UiObject2 searchButton = getSearchButton();
- if (searchButton == null) {
- throw new UnknownUiException("Could not find search button.");
- } else {
- searchButton.click();
- if (!mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_SEARCH_EDIT_TEXT_ID)), UI_NAVIGATION_WAIT)) {
- throw new UnknownUiException("Not on search page after pressing search button.");
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToFullscreenMode() {
- if (!isOnVideo()) {
- throw new IllegalStateException("YouTube is not on a video page.");
- }
-
- if (getOrientation() == Configuration.ORIENTATION_LANDSCAPE) {
- return;
- }
-
- UiObject2 fullscreenButton = null;
- for (int retriesRemaining = 5; retriesRemaining > 0; --retriesRemaining) {
- UiObject2 miniVideoPlayer = getVideoPlayer();
- if (miniVideoPlayer == null) {
- throw new UnknownUiException("Could not find mini video player.");
- }
-
- miniVideoPlayer.click();
- SystemClock.sleep(1500);
- fullscreenButton = getFullscreenButton();
- if (fullscreenButton != null) {
- fullscreenButton.click();
- // TODO: Add a valid wait for fullscreen
- break;
- }
- }
-
- if (fullscreenButton == null) {
- throw new UnknownUiException("Did not find a fullscreen button.");
- }
- }
-
- private UiObject2 getVideoPlayer() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_VIDEO_PLAYER_ID));
- }
-
- private boolean isOnVideo() {
- return (getVideoPlayer() != null);
- }
-
- private UiObject2 getVideoPlayerOverflowButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_VIDEO_PLAYER_OVERFLOW_BUTTON_ID));
- }
-
- private UiObject2 getVideoPlayerQualityButton() {
- UiObject2 videoPlayer = getVideoPlayer();
- UiObject2 qualityButton = null;
-
- if (videoPlayer != null) {
- qualityButton = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_VIDEO_PLAYER_QUALITY_BUTTON_ID));
- }
- return qualityButton;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean waitForSearchResults(long timeout) {
- return mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE_NAME, UI_VIDEO_INFO_VIEW_ID)), timeout);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setVideoQuality(VideoQuality quality) {
- if (!isOnVideo()) {
- throw new IllegalStateException("YouTube is not on a video page.");
- }
-
- UiObject2 overflowButton = getVideoPlayerOverflowButton();
- // Open the mini video player
- if (overflowButton == null) {
- UiObject2 miniVideoPlayer = getVideoPlayer();
- if (miniVideoPlayer == null) {
- throw new UnknownUiException("Could not find mini video player.");
- }
-
- miniVideoPlayer.click();
- mDevice.wait(Until.findObject(By.res(
- UI_PACKAGE_NAME, UI_VIDEO_PLAYER_OVERFLOW_BUTTON_ID)), UI_NAVIGATION_WAIT);
- overflowButton = getVideoPlayerOverflowButton();
- }
-
- if (overflowButton == null) {
- throw new UnknownUiException("Could not find overflow button.");
- }
-
- overflowButton.click();
- UiObject2 qualityButton = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_VIDEO_PLAYER_QUALITY_BUTTON_ID)), UI_NAVIGATION_WAIT);
- if (qualityButton == null) {
- throw new UnknownUiException("Could not find video quality button.");
- }
-
- qualityButton.click();
- UiObject2 quality360pLabel = mDevice.wait(Until.findObject(By.text(
- AbstractYouTubeHelper.VideoQuality.QUALITY_360p.getText())), UI_NAVIGATION_WAIT);
- if (quality360pLabel == null) {
- throw new UnknownUiException("Could not find 360p quality label.");
- }
-
- UiObject2 selectDialog = quality360pLabel.getParent();
- if (selectDialog == null) {
- throw new UnknownUiException("Could not find video quality dialog.");
- }
-
- UiObject2 qualityLabel = null;
- for (int retriesRemaining = 5; retriesRemaining > 0; --retriesRemaining) {
- qualityLabel = mDevice.findObject(By.text(quality.getText()));
- if (qualityLabel != null) {
- break;
- }
- selectDialog.scroll(Direction.DOWN, 1.0f);
- mDevice.waitForIdle();
- }
- if (qualityLabel == null) {
- throw new UnknownUiException(
- String.format("Could not find quality %s label", quality.getText()));
- }
-
- Log.v(TAG, String.format("Found quality %s label", quality.getText()));
- qualityLabel.click();
- if (!mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, UI_VIDEO_PLAYER_ID)),
- UI_NAVIGATION_WAIT)) {
- throw new UnknownUiException("Did not find video player after selecting quality.");
- }
- }
-
- private UiObject2 getFullscreenButton() {
- return mDevice.findObject(By.desc(UI_FULLSCREEN_BUTTON_DESC));
- }
-
- private UiObject2 getPlayPauseReplayButton() {
- return mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_VIDEO_PLAYER_PLAY_PAUSE_REPLAY_BUTTON_ID));
- }
-
- public void resumeVideo() {
- UiObject2 videoPlayer = getVideoPlayer();
- if (videoPlayer == null) {
- throw new UnknownUiException("Could not find video player.");
- }
-
- videoPlayer.click();
- UiObject2 playPauseReplayButton = mDevice.wait(Until.findObject(By.res(UI_PACKAGE_NAME,
- UI_VIDEO_PLAYER_PLAY_PAUSE_REPLAY_BUTTON_ID)), UI_NAVIGATION_WAIT);
- if (playPauseReplayButton == null) {
- throw new UnknownUiException("Could not find the pause/play button.");
- }
-
- if (UI_PLAY_VIDEO_DESC.equals(playPauseReplayButton.getContentDescription())) {
- playPauseReplayButton.click();
- }
- }
-
- private boolean hasConnectionEstablishedMessage() {
- Pattern establishedMsg =
- Pattern.compile("Connection established", Pattern.CASE_INSENSITIVE);
- return mDevice.hasObject(By.res(UI_PACKAGE_NAME, "message").text(establishedMsg));
- }
-
- private void pressGoOnline() {
- Pattern goOnlineMsg = Pattern.compile("Go online", Pattern.CASE_INSENSITIVE);
- UiObject2 button = mDevice.findObject(By.res(UI_PACKAGE_NAME, "action").text(goOnlineMsg));
- if (button != null) {
- button.click();
- mDevice.waitForIdle();
- } else {
- throw new UnknownUiException("Unable to find GO ONLINE button.");
- }
- }
-}
diff --git a/libraries/first-party-app-helpers/tv/Android.mk b/libraries/first-party-app-helpers/tv/Android.mk
deleted file mode 100644
index 8d641522f..000000000
--- a/libraries/first-party-app-helpers/tv/Android.mk
+++ /dev/null
@@ -1,29 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := leanback-app-helpers
-LOCAL_STATIC_JAVA_LIBRARIES := launcher-helper-lib base-app-helpers \
- tv-sysui-app-helper tv-youtube-app-helper tv-search-app-helper \
- tv-play-movies-app-helper \
- leanback-demo-app-helper
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-######################################
-
-include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/libraries/first-party-app-helpers/tv/leanback-demo-app-helper/Android.mk b/libraries/first-party-app-helpers/tv/leanback-demo-app-helper/Android.mk
deleted file mode 100644
index dfa66bdec..000000000
--- a/libraries/first-party-app-helpers/tv/leanback-demo-app-helper/Android.mk
+++ /dev/null
@@ -1,24 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := leanback-demo-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers tv-sysui-app-helper
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
diff --git a/libraries/first-party-app-helpers/tv/leanback-demo-app-helper/src/android/platform/test/helpers/tv/LeanbackDemoHelperImpl.java b/libraries/first-party-app-helpers/tv/leanback-demo-app-helper/src/android/platform/test/helpers/tv/LeanbackDemoHelperImpl.java
deleted file mode 100644
index ee73a568e..000000000
--- a/libraries/first-party-app-helpers/tv/leanback-demo-app-helper/src/android/platform/test/helpers/tv/LeanbackDemoHelperImpl.java
+++ /dev/null
@@ -1,212 +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 android.platform.test.helpers.tv;
-
-import android.app.Instrumentation;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.platform.test.helpers.AbstractLeanbackAppHelper;
-import android.platform.test.helpers.exceptions.UiTimeoutException;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-
-public class LeanbackDemoHelperImpl extends AbstractLeanbackAppHelper {
-
- private static final String TAG = LeanbackDemoHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.example.android.tvleanback";
- private static final String ACTIVITY_MAIN = "com.example.android.tvleanback.ui.MainActivity";
- private static final String RES_MAIN_ACTIVITY_ID = "main_frame";
- private static final long SHORT_SLEEP_MS = 5000; // 5 seconds
- private static final long LONG_SLEEP_MS = 30000; // 30 seconds
-
- private static final String TEXT_TOOLTIP = "Hold HOME to control PIP";
-
-
- public LeanbackDemoHelperImpl(Instrumentation instrumentation) {
- super(instrumentation);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Videos by Google";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected BySelector getMainActivitySelector() {
- return By.res(UI_PACKAGE, RES_MAIN_ACTIVITY_ID);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected BySelector getBrowseRowsSelector() {
- return By.focused(true).hasChild(By.res(UI_PACKAGE, "main_image"));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- launchActivity();
- // Wait until the main activity is open.
- mDevice.wait(Until.hasObject(getMainActivitySelector()), SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectation: None
- *
- * Launches the demo main activity with an Intent.
- */
- private void launchActivity() {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
- intent.setComponent(new ComponentName(UI_PACKAGE, ACTIVITY_MAIN));
- // Launch the activity
- mInstrumentation.getContext().startActivity(intent);
- }
-
- /**
- * Setup expectation: On the main activity.
- * <p>
- * Selects the desired video in the row content and wait for it to open the details view.
- * </p>
- * @param sectionName the name of section that includes the desired video
- * @param videoName the name of video to select
- */
- public void selectVideoInRowContent(String sectionName, String videoName) {
- returnToMainActivity();
- openHeader(sectionName);
- UiObject2 container = getRowContent(sectionName);
- BySelector target = By.focused(true).hasDescendant(
- By.res(UI_PACKAGE, "title_text").text(videoName), 3);
- UiObject2 video = select(container, target, Direction.RIGHT);
- if (video == null) {
- throw new UnknownUiException(
- String.format("The video %s not found in the %s section", videoName,
- sectionName));
- }
- mDPadHelper.pressDPadCenter();
- mDevice.waitForIdle();
- }
-
- /**
- * Setup expectation: On the details view.
- * <p>
- * Selects the button of "WATCH TRAILER FREE".
- * </p>
- */
- public void selectWatchTrailer() {
- BySelector target = By.res(UI_PACKAGE, "lb_action_button").text("WATCH TRAILER\nFREE");
- UiObject2 trailer = mDevice.wait(Until.findObject(target), SHORT_SLEEP_MS);
- if (trailer == null) {
- throw new UnknownUiException("The watch trailer button not found");
- }
- mDPadHelper.pressDPadCenter();
- mDevice.waitForIdle();
- }
-
- /**
- * Setup expectation: On the media control card.
- *
- * @return a boolean of whether the media control card has a PIP button enabled.
- */
- public boolean hasPipButton() {
- // Pressing the key up brings up the media control card
- mDPadHelper.pressDPad(Direction.UP);
- if (!mDevice.wait(Until.hasObject(By.res(UI_PACKAGE, "controls_card")), SHORT_SLEEP_MS)) {
- throw new UiTimeoutException("No media control card is found");
- }
- return mDevice.wait(Until.hasObject(
- By.res(UI_PACKAGE, "button").desc("Enter Picture In Picture Mode")),
- SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectation: PIP window is being open.
- *
- * @return a boolean of whether the tooltip text is shown.
- */
- public boolean hasTooltipShown() {
- return mDevice.wait(Until.hasObject(By.text(TEXT_TOOLTIP)), SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectation: While playing a video in fullscreen.
- * <p>
- * Clicks on the PIP button and wait for it to be gone.
- * </p>
- */
- public void openMediaControlsAndClickPipButton() {
- // Pressing the key up brings up the media control card
- mDPadHelper.pressDPad(Direction.UP);
- if (!mDevice.wait(Until.hasObject(By.res(UI_PACKAGE, "controls_card")), SHORT_SLEEP_MS)) {
- throw new UiTimeoutException("No media control card is found");
- }
- BySelector target = By.res(UI_PACKAGE, "button").desc("Enter Picture In Picture Mode");
- UiObject2 pipButton = mDevice.wait(Until.findObject(target), SHORT_SLEEP_MS);
- if (pipButton == null) {
- throw new UiTimeoutException("PIP button not found");
- }
- pipButton.click();
- mDevice.waitForIdle();
- mDPadHelper.pressDPadCenter();
- mDevice.waitForIdle();
- }
-
- /**
- * Attempts to return to main activity with getMainActivitySelector()
- * by pressing the back button repeatedly and sleeping briefly to allow for UI slowness.
- */
- public void returnToMainActivity() {
- int maxBackAttempts = 10;
- BySelector selector = getMainActivitySelector();
- if (selector == null) {
- throw new IllegalStateException("getMainActivitySelector() should be overridden.");
- }
- while (!mDevice.wait(Until.hasObject(selector), SHORT_SLEEP_MS)
- && maxBackAttempts-- > 0) {
- mDevice.pressBack();
- }
- }
-
- private UiObject2 getRowContent(String rowName) {
- return mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "row_content").desc(rowName)),
- LONG_SLEEP_MS);
- }
-}
-
diff --git a/libraries/first-party-app-helpers/tv/play-movies-app-helper/Android.mk b/libraries/first-party-app-helpers/tv/play-movies-app-helper/Android.mk
deleted file mode 100644
index 1d270f836..000000000
--- a/libraries/first-party-app-helpers/tv/play-movies-app-helper/Android.mk
+++ /dev/null
@@ -1,24 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := tv-play-movies-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
diff --git a/libraries/first-party-app-helpers/tv/play-movies-app-helper/src/android/platform/test/helpers/tv/PlayMoviesHelperImpl.java b/libraries/first-party-app-helpers/tv/play-movies-app-helper/src/android/platform/test/helpers/tv/PlayMoviesHelperImpl.java
deleted file mode 100644
index b07b4f67e..000000000
--- a/libraries/first-party-app-helpers/tv/play-movies-app-helper/src/android/platform/test/helpers/tv/PlayMoviesHelperImpl.java
+++ /dev/null
@@ -1,318 +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 android.platform.test.helpers.tv;
-
-import android.app.Instrumentation;
-import android.os.SystemClock;
-import android.platform.test.helpers.AbstractLeanbackAppHelper;
-import android.platform.test.helpers.CommandHelper;
-import android.platform.test.helpers.exceptions.UiTimeoutException;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-public class PlayMoviesHelperImpl extends AbstractLeanbackAppHelper {
-
- private static final String LOG_TAG = PlayMoviesHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.google.android.videos";
- private static final String RES_MAIN_ACTIVITY_ID = "browse_container_dock";
- private static final String RES_SEARCH_ORB_ID = "title_orb";
- private static final String RES_SEARCH_BOX_ID = "lb_search_text_editor";
-
- private static final String TEXT_MOVIES = "Movies";
- private static final String TEXT_MY_LIBRARY = "My library";
- private static final String TEXT_PLAY_TRAILER = "PLAY TRAILER";
-
- private static final long SHORT_SLEEP_MS = 5000; // 5 seconds
- private static final long LONG_SLEEP_MS = 30000; // 30 seconds
-
- private CommandHelper mCmdHelper;
-
-
- public PlayMoviesHelperImpl(Instrumentation instrumentation) {
- super(instrumentation);
- mCmdHelper = new CommandHelper(instrumentation);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Play Movies & TV";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected BySelector getMainActivitySelector() {
- return By.res(UI_PACKAGE, RES_MAIN_ACTIVITY_ID);
- }
-
- /**
- * Selects search orb. The app should be opened beforehand by calling open().
- */
- public void selectSearchOrb() {
- returnToMainActivity();
-
- // Wait until the search orb appears at runtime.
- UiObject2 searchOrb = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE, RES_SEARCH_ORB_ID).clickable(true)),
- SHORT_SLEEP_MS);
- if (searchOrb == null) {
- throw new UiTimeoutException("Failed to select search orb");
- }
- searchOrb.click();
- }
-
- /**
- * Searches for the given query and keep the search result open.
- * Play Movies app should be opened beforehand by calling open().
- *
- * @param query a search query string typed in Play Movies' search box.
- */
- public void search(String query) {
- selectSearchOrb();
- mDevice.waitForIdle();
-
- Log.v(LOG_TAG, "Searching for the movie: " + query);
- UiObject2 editText = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE, RES_SEARCH_BOX_ID)), SHORT_SLEEP_MS);
- if (editText == null) {
- throw new UnknownUiException("Search text editor not found");
- }
-
- int retries = 4;
- while(!editText.isFocused() && retries > 0) {
- mDevice.pressDPadRight();
- mDevice.waitForIdle();
- retries--;
- }
-
- // Set query and search
- editText.setText(query);
- SystemClock.sleep(SHORT_SLEEP_MS);
-
- mDevice.pressEnter();
- SystemClock.sleep(SHORT_SLEEP_MS);
- }
-
- /**
- * Finds a movie with the trailer from the search result and start playing.
- * search() should be called right before calling this method.
- */
- public UiObject2 searchForMovieWithTrailer() {
- mDevice.wait(Until.findObject(By.text(TEXT_MOVIES)), SHORT_SLEEP_MS);
- mDevice.pressDPadCenter();
- mDevice.waitForIdle();
-
- // Skip until a trailer is found from the result
- UiObject2 trailerButton = null;
- final int MAX_ATTEMPTS_SEARCH_TRAILERS = 5;
- for (long i = 0; i < MAX_ATTEMPTS_SEARCH_TRAILERS; i++) {
- trailerButton = getTrailerButton();
- if (trailerButton == null) {
- // The trailer was not found for the movie,
- // back and open the detail of the next movie
- mDevice.pressBack();
- mDevice.wait(Until.findObject(By.text(TEXT_MOVIES)), SHORT_SLEEP_MS);
-
- mDevice.pressDPadRight();
- SystemClock.sleep(SHORT_SLEEP_MS);
-
- mDevice.pressDPadCenter();
- mDevice.waitForIdle();
- } else {
- // The trailer was found for the movie
- break;
- }
-
- }
-
- SystemClock.sleep(SHORT_SLEEP_MS);
- return trailerButton;
- }
-
- public UiObject2 getTrailerButton() {
- return mDevice.wait(Until.findObject(By.text(TEXT_PLAY_TRAILER)), SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectations: Trailer is selected, and shown in details fragment.
- *
- * Play a trailer
- */
- public void playTrailerInDetails(long durationMs) {
- UiObject2 trailerButton = getTrailerButton();
- if (trailerButton == null) {
- throw new UnknownUiException("Trailer action not found");
- }
- trailerButton.click();
-
- // Using "Play trailer" to wait for the playback to start
- mDevice.wait(Until.gone(By.text(TEXT_PLAY_TRAILER)),
- SHORT_SLEEP_MS);
-
- // Using "Play trailer" button to wait until the trailer finishes
- trailerButton = mDevice.wait(
- Until.findObject(By.text(TEXT_PLAY_TRAILER)), durationMs);
- if (trailerButton == null) {
- throw new RuntimeException("Trailer too long or something went wrong");
- }
- }
-
- /**
- * Open My Library section
- */
- public void openMyLibrary() {
- returnToMainActivity();
- openHeader(TEXT_MY_LIBRARY);
- }
-
- /**
- * Setup expectations: None.
- * Open My Movies in My library section, wait for the list of movies to come.
- */
- public void openMyMoviesList() {
- openMyLibrary();
- if (getCardByNameInRowContent(TEXT_MOVIES) == null) {
- throw new UnknownUiException("Movies in My library not found");
- }
- mDevice.performActionAndWait(new Runnable() {
- @Override
- public void run() {
- mDevice.pressDPadCenter();
- }
- }, Until.newWindow(), SHORT_SLEEP_MS);
- }
-
- /**
- * Get a card with the given name in row_content
- *
- * @param title of the card
- * @return UIObject2 for the focusable button
- */
- private UiObject2 getCardByNameInRowContent(String title) {
- UiObject2 container = mDevice.findObject(
- By.res(getPackage(), "row_content").hasDescendant(By.focused(true)));
- return select(container, By.res(getPackage(), "title_text").text(title),
- Direction.RIGHT);
- }
-
- /**
- * Setup expectations: The movie(s) is listed in the Vertical grid fragment
- */
- public void selectTheFocusedMovieInVerticalGrid() {
- assertWidgetEquals(Widget.VERTICAL_GRID_FRAGMENT);
- mDevice.performActionAndWait(new Runnable() {
- @Override
- public void run() {
- mDevice.pressDPadCenter();
- }
- }, Until.newWindow(), SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectations: The movie to play is listed in the Details fragment
- *
- * Play the selected movies from beginning
- */
- public void playFromBeginning() {
- assertWidgetEquals(Widget.DETAILS_FRAGMENT);
-
- // Play from beginning
- UiObject2 actionButton = mDevice.wait(Until.findObject(By.clazz(".Button")),
- LONG_SLEEP_MS);
- if (actionButton == null) {
- throw new UnknownUiException("action button not found");
- }
- String selectedText = actionButton.getText();
- Log.v(LOG_TAG, String.format("Selected text is: %s", selectedText));
- while (!(selectedText.toLowerCase().equals("play from beginning") ||
- selectedText.toLowerCase().equals("play movie"))) {
- String prevText = selectedText;
-
- // Select the next item
- mDevice.pressDPadRight();
-
- // Make sure the text has changed
- selectedText = mDevice.findObject(By.clazz(".Button").focused(true)).getText();
- if (selectedText.equals(prevText)) {
- throw new UnknownUiException("'Play from beginning' or 'Play movie' not found");
- }
- }
- mDevice.pressDPadCenter();
-
- // Dismiss confirmation dialog if it's a rental movie
- UiObject2 yesButton = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE, "guidedactions_list")), SHORT_SLEEP_MS);
- if (yesButton != null) {
- mDevice.pressDPadCenter();
- }
- }
-
- /**
- * Get the current playback state for a given package that owns the media session.
- * @param packageName the package name of media session owner
- * @return
- * 0 = PlaybackState.STATE_NONE
- * 1 = PlaybackState.STATE_STOPPED
- * 2 = PlaybackState.STATE_PAUSED
- * 3 = PlaybackState.STATE_PLAYING
- */
- public int getPlaybackState(String packageName) {
- String output = mCmdHelper.executeDumpsysMediaSession();
- // Parse the output of dumpsys media_session.
- // Example :
- // LeanbackSampleApp com.example.android.tvleanback/LeanbackSampleApp
- // package=com.example.android.tvleanback
- // ...
- // state=PlaybackState {state=3, position=0, buffered position=0, speed=1.0, updated=...}
- int playbackState = 0;
- int index = output.indexOf(String.format("package=%s", packageName));
- if (index == -1) {
- Log.w(LOG_TAG, String.format("No media session found for the package: %s", packageName));
- return playbackState;
- }
- final Pattern PLAYBACKSTATE_REGEX = Pattern.compile(
- "\\s*state=PlaybackState \\{state=(\\d+),.*");
- Matcher matcher = PLAYBACKSTATE_REGEX.matcher(output.substring(index));
- if (matcher.find()) {
- playbackState = Integer.parseInt(matcher.group(1));
- Log.i(LOG_TAG, String.format("PlaybackState=%s package=%s", playbackState, packageName));
- }
- return playbackState;
- }
-}
-
diff --git a/libraries/first-party-app-helpers/tv/search-app-helper/Android.mk b/libraries/first-party-app-helpers/tv/search-app-helper/Android.mk
deleted file mode 100644
index 3a3898412..000000000
--- a/libraries/first-party-app-helpers/tv/search-app-helper/Android.mk
+++ /dev/null
@@ -1,24 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := tv-search-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
diff --git a/libraries/first-party-app-helpers/tv/search-app-helper/src/android/platform/test/helpers/tv/SearchHelperImpl.java b/libraries/first-party-app-helpers/tv/search-app-helper/src/android/platform/test/helpers/tv/SearchHelperImpl.java
deleted file mode 100644
index a723e51f3..000000000
--- a/libraries/first-party-app-helpers/tv/search-app-helper/src/android/platform/test/helpers/tv/SearchHelperImpl.java
+++ /dev/null
@@ -1,110 +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 android.platform.test.helpers.tv;
-
-import android.app.Instrumentation;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.platform.test.helpers.AbstractLeanbackAppHelper;
-import android.platform.test.helpers.exceptions.UiTimeoutException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-
-public class SearchHelperImpl extends AbstractLeanbackAppHelper {
-
- private static final String TAG = SearchHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.google.android.katniss";
- private static final String SEARCH_ACTIVITY_NAME =
- "com.google.android.katniss.search.SearchActivity";
- private static final long SHORT_SLEEP_MS = 3000; // 3 seconds
-
- private static Instrumentation mInstrumentation;
-
- public static final int VOICE_SEARCH = 1;
- public static final int KEYBOARD_SEARCH = 2;
-
-
- public SearchHelperImpl(Instrumentation instrumentation) {
- super(instrumentation);
- mInstrumentation = instrumentation;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return null;
- }
-
- /**
- * Setup expectations: None
- *
- * Starts the voice search activity for querying the content.
- * @param searchType Type of search request (1=voice, 2=keyboard)
- * @param searchQuery Query string
- */
- public void launchActivityAndQuery(int searchType, String searchQuery) {
- Intent intent = new Intent("android.intent.action.ASSIST");
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.addCategory("android.intent.category.DEFAULT");
- intent.setComponent(new ComponentName(UI_PACKAGE, SEARCH_ACTIVITY_NAME));
- intent.putExtra("search_type", searchType);
- intent.putExtra("query", searchQuery);
- mInstrumentation.getContext().startActivity(intent);
- Log.d(TAG, String.format("launchActivityAndQuery searchType=%d query=%s", searchType,
- searchQuery));
-
- // Ensure that the package is open
- if (isOpen(SHORT_SLEEP_MS) == false) {
- throw new UiTimeoutException("The Search activity is not launched.");
- }
- if (isInKeyboardMode()) {
- Log.i(TAG, "Search activity Is in keyboard mode. Pressing the ENTER key.");
- mDPadHelper.pressEnter();
- mDevice.waitForIdle();
- }
- }
-
- public BySelector getSearchTextEditorSelector() {
- return By.res(UI_PACKAGE, "search_text_editor");
- }
-
- public BySelector getResultContainerSelector() {
- return By.res(UI_PACKAGE, "container_list");
- }
-
- public boolean isInKeyboardMode() {
- return mDevice.hasObject(getSearchTextEditorSelector());
- }
-
- public boolean isOpen(long waitMs) {
- return mDevice.wait(Until.hasObject(By.pkg(UI_PACKAGE).depth(0)), waitMs);
- }
-}
-
diff --git a/libraries/first-party-app-helpers/tv/sysui-app-helper/Android.mk b/libraries/first-party-app-helpers/tv/sysui-app-helper/Android.mk
deleted file mode 100644
index 092690859..000000000
--- a/libraries/first-party-app-helpers/tv/sysui-app-helper/Android.mk
+++ /dev/null
@@ -1,24 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := tv-sysui-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
diff --git a/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/NoTouchAuthHelperImpl.java b/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/NoTouchAuthHelperImpl.java
deleted file mode 100644
index 1bb6d6bec..000000000
--- a/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/NoTouchAuthHelperImpl.java
+++ /dev/null
@@ -1,184 +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 android.platform.test.helpers.tv;
-
-import android.app.Instrumentation;
-import android.content.Context;
-import android.platform.test.helpers.AbstractLeanbackAppHelper;
-import android.platform.test.helpers.DPadHelper;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-
-/**
- * App helper implementation class for the NoTouchAuthDelegate UI
- * to add an account to non-touch device like TV.
- */
-public class NoTouchAuthHelperImpl extends AbstractLeanbackAppHelper {
- private static final String LOG_TAG = NoTouchAuthHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.google.android.gsf.notouch";
-
- private static final String TITLE_SIGN_IN_ONBOARDING = "Sign in to your account";
- private static final String TITLE_SIGN_IN_ACCOUNT = "Enter your account email address";
- private static final String TITLE_SIGN_IN_PASSWORD = "Enter your account password";
- private static final String TITLE_SIGN_IN_ACCOUNT_ALREADY_EXISTS =
- "This account already exists on your device";
- private static final String TEXT_SIGN_IN_SECOND_SCREEN = "Use your phone or laptop";
- private static final String TEXT_SIGN_IN_PASSWORD = "Use your password";
-
- private static final long SHORT_SLEEP_MS = 3000;
-
-
- private Context mContext;
-
-
- public NoTouchAuthHelperImpl(Instrumentation instrumentation) {
- super(instrumentation);
- mDPadHelper = DPadHelper.getInstance(instrumentation);
- mContext = instrumentation.getContext();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- throw new UnsupportedOperationException("This method is not supported for NoTouchAuth");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- throw new UnsupportedOperationException("This method is not supported for NoTouchAuth");
- }
-
- /**
- * Setup expectations: The sign-in page is open.
- * <p>
- * Attempts to login with an account.
- * </p>
- * @return true if the attempt to login is successful. However this doesn't guarantee that
- * the account is registered in AccountManager.
- */
- public boolean loginAccount(String accountName, String password) {
- selectUseYourPassword();
-
- // Enter the account name
- if (!isSignInAccountPage()) {
- throw new UnknownUiException("Failed to find the page to enter account");
- }
- setTextForSignIn(accountName);
-
- // Check if the account already exists
- if (isSignInAccountAlreadyExists()) {
- Log.w(LOG_TAG, "Failed to log in with the account already registered.");
- return false;
- }
-
- // Enter the password
- if (!isSignInPasswordPage()) {
- throw new UnknownUiException("Failed to find the page to enter password");
- }
- setTextForSignIn(password);
- return true;
- }
-
- /**
- * Setup expectations: The sign-in page is open.
- * <p>
- * Selects "Use Your Password".
- * </p>
- * @return
- */
- private void selectUseYourPassword() {
- selectSignInOptions(TEXT_SIGN_IN_PASSWORD);
- // Wait for it to open the page to enter account name
- mDevice.waitForIdle();
- if (!isSignInAccountPage()) {
- throw new UnknownUiException("Failed to find the page to enter account name");
- }
- }
-
- /**
- * Setup expectations: The sign-in page is open. Selects "Use your phone or laptop" for
- * Second Screen Setup.
- * @return
- */
- private void selectUseYourPhoneOrLaptop() {
- selectSignInOptions(TEXT_SIGN_IN_SECOND_SCREEN);
- }
-
- private boolean isSignInOnboardingPage() {
- return TITLE_SIGN_IN_ONBOARDING.equals(getTitleText());
- }
-
- private boolean isSignInAccountPage() {
- return TITLE_SIGN_IN_ACCOUNT.equals(getTitleText());
- }
-
- private boolean isSignInPasswordPage() {
- return TITLE_SIGN_IN_PASSWORD.equals(getTitleText());
- }
-
- private boolean isSignInAccountAlreadyExists() {
- return TITLE_SIGN_IN_ACCOUNT_ALREADY_EXISTS.equals(getTitleText());
- }
-
- private void selectSignInOptions(String optionString) {
- if (!isSignInOnboardingPage()) {
- throw new IllegalStateException("Should be on the sign in onboarding page");
- }
- UiObject2 action = mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "action")),
- SHORT_SLEEP_MS);
- if (action == null) {
- throw new UnknownUiException("The container 'action' for sign-in not found");
- }
- UiObject2 button = select(action,
- By.res(UI_PACKAGE, "list_item_text").text(optionString),
- Direction.DOWN);
- if (button == null) {
- throw new UnknownUiException("The button not found " + optionString);
- }
- mDPadHelper.pressDPadCenterAndWait(Until.newWindow(), SHORT_SLEEP_MS);
- }
-
- private String getTitleText() {
- return mDevice.findObject(By.res(UI_PACKAGE, "title_text")).getText();
- }
-
- private void setTextForSignIn(String text) {
- UiObject2 editText = mDevice.wait(Until.findObject(By.res(UI_PACKAGE, "text_input")),
- SHORT_SLEEP_MS);
- editText.setText(text);
- mDPadHelper.pressEnterAndWait(Until.newWindow(), SHORT_SLEEP_MS);
- }
-}
-
diff --git a/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiPipHelperImpl.java b/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiPipHelperImpl.java
deleted file mode 100644
index 60cab1a49..000000000
--- a/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiPipHelperImpl.java
+++ /dev/null
@@ -1,297 +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 android.platform.test.helpers.tv;
-
-import static android.view.KeyEvent.KEYCODE_WINDOW;
-
-import android.app.Instrumentation;
-import android.graphics.Rect;
-import android.platform.test.helpers.DPadHelper;
-import android.platform.test.helpers.CommandHelper;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-/**
- * App helper implementation class for TV's picture-in-picture in System UI
- */
-public class SysUiPipHelperImpl {
- private static final String LOG_TAG = SysUiPipHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.android.systemui";
- private static final int FULLSCREEN_WORKSPACE_STACK_ID = 1;
- private static final int PINNED_STACK_ID = 4; // ID of stack for a PIP window
-
- private static final int INVALID_TASK_ID = -1;
- private static final String ACTIVITY_PIPOVERLAY =
- "com.android.systemui.tv.pip.PipOverlayActivity";
- // Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows
- private static final Rect PIP_MENU_BOUNDS = new Rect(596, 280, 1324, 690);
- private static final Rect PIP_RECENTS_BOUNDS = new Rect(800, 54, 1120, 234);
- private static final Rect PIP_RECENTS_FOCUSED_BOUNDS = new Rect(775, 54, 1145, 262);
- private static final Rect PIP_SETTINGS_BOUNDS = new Rect(662, 54, 1142, 324);
-
- private static final long SHORT_SLEEP_MS = 3000; // 3 seconds
-
- private DPadHelper mDPadHelper;
- private CommandHelper mCmdHelper;
- private UiDevice mDevice;
-
-
- public SysUiPipHelperImpl(Instrumentation instrumentation) {
- mDPadHelper = DPadHelper.getInstance(instrumentation);
- mCmdHelper = new CommandHelper(instrumentation);
- mDevice = UiDevice.getInstance(instrumentation);
- }
-
- /**
- * @return the package name for this helper's application.
- */
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * Setup expectations: None
- * <p>
- * Checks if a PIP window is shown on screen.
- * </p>
- * @param activityName the activity of the application that implements PIP playback
- */
- public boolean isPipOnScreen(String activityName) {
- String output = mCmdHelper.executeAmStackInfo(PINNED_STACK_ID);
- Log.i(LOG_TAG, "isPipOnScreen: " + output);
- if (null == output || "null".equalsIgnoreCase(output)) {
- Log.i(LOG_TAG, "No PIP window is found");
- return false;
- }
- // Note that ACTIVITY_PIPOVERLAY would disappear in seconds, afterwards the app playback
- // overlay comes in. It's just safe to think of that whatever activity in pinned stack is
- // PIP window.
- return output.contains(activityName);
- }
-
- /**
- * Setup expectations: None
- * <p>
- * Checks if a PIP window is shown on screen.
- * </p>
- * @param activityName the activity of the application that implements PIP playback
- */
- public boolean isInFullscreen(String activityName) {
- String output = mCmdHelper.executeAmStackInfo(FULLSCREEN_WORKSPACE_STACK_ID);
- Log.i(LOG_TAG, "isInFullscreen: " + output);
- if (null == output || "null".equalsIgnoreCase(output)) {
- Log.i(LOG_TAG, "Activity is not found in full screen: " + activityName);
- return false;
- }
- return output.contains(activityName);
- }
-
- /**
- * Setup expectations: None
- * <p>
- * Returns the bounds on screen for a PIP window.
- * </p>
- */
- private Rect getPipBounds(String packageName, String activityName) {
- return getBounds(PINNED_STACK_ID, packageName, activityName);
- }
-
- private Rect getBounds(int stackId, String packageName, String activityName) {
- // Format:
- // taskId=216: com.example.android.tvleanback/com.example.android.tvleanback.ui.PlaybackOverlayActivity bounds=[775,54][1145,262] ...
- final Pattern BOUNDS_REGEX = Pattern.compile(
- String.format("taskId=\\d+: %s/%s bounds=\\[(\\d+),(\\d+)\\]\\[(\\d+),(\\d+)\\]",
- packageName, activityName));
- String output = mCmdHelper.executeAmStackInfo(stackId);
- Log.d(LOG_TAG, "getBounds output=" + output);
- Matcher matcher = BOUNDS_REGEX.matcher(output);
- if (matcher.find()) {
- int left = Integer.parseInt(matcher.group(1));
- int top = Integer.parseInt(matcher.group(2));
- int right = Integer.parseInt(matcher.group(3));
- int bottom = Integer.parseInt(matcher.group(4));
- Log.i(LOG_TAG, String.format("Bounds found: [%d,%d][%d,%d] for %s/%s",
- left, top, right, bottom, packageName, activityName));
- return new Rect(left, top, right, bottom);
- }
- Log.w(LOG_TAG, "getBounds returns null");
- return null;
- }
-
- /**
- * Setup expectations: PIP is open.
- * <p>
- * Moves the PIP window to full screen.
- * </p>
- */
- public void executeCommandPipToFullscreen(String packageName, String activityName,
- boolean throwIfFail) {
- int taskId = getTaskId(packageName, activityName);
- if (taskId != INVALID_TASK_ID) {
- mCmdHelper.executeAmStackMovetask(taskId,
- FULLSCREEN_WORKSPACE_STACK_ID);
- }
- if (throwIfFail && isPipOnScreen(activityName)) {
- throw new UnknownUiException("Failed to move a PIP window to fullscreen");
- }
- }
-
- /**
- * Get the current playback state for a given package that owns the media session.
- * @param packageName the package name of media session owner
- * @return
- * 0 = PlaybackState.STATE_NONE
- * 1 = PlaybackState.STATE_STOPPED
- * 2 = PlaybackState.STATE_PAUSED
- * 3 = PlaybackState.STATE_PLAYING
- */
- public int getPlaybackState(String packageName) {
- String output = mCmdHelper.executeDumpsysMediaSession();
- // Parse the output of dumpsys media_session.
- // Example :
- // LeanbackSampleApp com.example.android.tvleanback/LeanbackSampleApp
- // package=com.example.android.tvleanback
- // ...
- // state=PlaybackState {state=3, position=0, buffered position=0, speed=1.0, updated=...}
- int playbackState = 0;
- int index = output.indexOf(String.format("package=%s", packageName));
- if (index == -1) {
- Log.w(LOG_TAG, String.format("No media session found for the package: %s", packageName));
- return playbackState;
- }
- final Pattern PLAYBACKSTATE_REGEX = Pattern.compile(
- "\\s*state=PlaybackState \\{state=(\\d+),.*");
- Matcher matcher = PLAYBACKSTATE_REGEX.matcher(output.substring(index));
- if (matcher.find()) {
- playbackState = Integer.parseInt(matcher.group(1));
- Log.i(LOG_TAG, String.format("PlaybackState=%s package=%s", playbackState, packageName));
- }
- return playbackState;
- }
-
- /**
- * Setup expectation: None. Check if PIP overlay is shown and focused.
- */
- private boolean isPipStateOverlay() {
- // TODO
- throw new UnsupportedOperationException("This method is not yet implemented.");
- }
-
- /**
- * Setup expectation: None. Check if PIP menu is shown in center.
- */
- public boolean isPipStateMenu(String packageName, String activityName) {
- return PIP_MENU_BOUNDS.equals(getPipBounds(packageName, activityName));
- }
-
- /**
- * Setup expectation: None. Check if the PIP is shown in Recents with focus.
- */
- public boolean isPipStateRecentsFocused(String packageName, String activityName) {
- return PIP_RECENTS_FOCUSED_BOUNDS.equals(getPipBounds(packageName, activityName));
- }
-
- /**
- * Setup expectation: None. Check if the PIP is shown with Settings.
- */
- public boolean isPipStateSettings(String packageName, String activityName) {
- return PIP_SETTINGS_BOUNDS.equals(getPipBounds(packageName, activityName));
- }
-
- /**
- * Setup expectation: When the PIP is shown in Recents with focus.
- * <p>
- * Toggles the media play/pause button on screen.
- * </p>
- */
- public void togglePipMediaControls() {
- UiObject2 pause = mDevice.findObject(By.res(UI_PACKAGE, "button").desc("Pause"));
- UiObject2 play = mDevice.findObject(By.res(UI_PACKAGE, "button").desc("Play"));
- if (pause != null) {
- pause.click();
- } else if (play != null) {
- play.click();
- } else {
- throw new UnknownUiException("No Play/Pause button found in PIP in Recents");
- }
- mDevice.waitForIdle();
- mDevice.pressDPadCenter();
- }
-
- /**
- * Setup expectation: When the PIP is shown in Recents with focus.
- * <p>
- * Clicks the full screen button on screen.
- * </p>
- */
- public void selectPipToFullScreenButton() {
- UiObject2 button = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE, "button").desc("Full screen")),
- SHORT_SLEEP_MS);
- button.click();
- mDevice.waitForIdle();
- mDevice.pressDPadCenter();
- }
-
- /**
- * Setup expectation: When the PIP is shown in Recents with focus.
- * <p>
- * Clicks the Close button on screen.
- * </p>
- */
- public void selectPipCloseButton() {
- UiObject2 button = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE, "button").desc("Close PIP")),
- SHORT_SLEEP_MS);
- button.click();
- mDevice.waitForIdle();
- mDevice.pressDPadCenter();
-
- }
-
- /**
- * Setup expectation: None.
- * <p>
- * Check if the PIP is shown in Recents without focus.
- * </p>
- */
- public boolean isPipStateRecents(String packageName, String activityName) {
- return PIP_RECENTS_BOUNDS.equals(getPipBounds(packageName, activityName));
- }
-
- private int getTaskId(String packageName, String activityName) {
- int taskId = INVALID_TASK_ID;
- final Pattern TASK_REGEX = Pattern.compile(
- String.format("taskId=(\\d+): %s/%s", packageName, activityName));
- Matcher matcher = TASK_REGEX.matcher(mCmdHelper.executeAmStackList());
- if (matcher.find()) {
- taskId = Integer.parseInt(matcher.group(1));
- Log.i(LOG_TAG, String.format("TaskId found: %d for %s/%s",
- taskId, packageName, activityName));
- }
- return taskId;
- }
-}
-
diff --git a/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiRecentsHelperImpl.java b/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiRecentsHelperImpl.java
deleted file mode 100644
index 0872955b8..000000000
--- a/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiRecentsHelperImpl.java
+++ /dev/null
@@ -1,273 +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 android.platform.test.helpers.tv;
-
-import android.app.Instrumentation;
-import android.os.RemoteException;
-import android.platform.test.helpers.AbstractLeanbackAppHelper;
-import android.platform.test.helpers.DPadHelper;
-import android.platform.test.helpers.IRecentsHelper;
-import android.platform.test.helpers.exceptions.UiTimeoutException;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-/**
- * App helper implementation class for Recents activity in System UI
- */
-public class SysUiRecentsHelperImpl extends AbstractLeanbackAppHelper implements IRecentsHelper {
- private static final String LOG_TAG = SysUiRecentsHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.android.systemui";
-
- private static final long RECENTS_SELECTION_TIMEOUT = 5000;
- private static final String TEXT_NO_ITEMS = "No recent items";
-
- private DPadHelper mDPadHelper;
-
-
- public SysUiRecentsHelperImpl(Instrumentation instrumentation) {
- super(instrumentation);
- mDPadHelper = DPadHelper.getInstance(instrumentation);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- throw new UnsupportedOperationException("This method is not supported for Recents");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- try {
- mDevice.pressRecentApps();
- mDevice.waitForIdle();
- } catch (RemoteException ex) {
- Log.e(LOG_TAG, ex.toString());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void exit() {
- mDevice.pressHome();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- // Nothing to do.
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void flingRecents(Direction dir) {
- throw new UnsupportedOperationException("This method is not supported for Recents "
- + "in leanback library");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void clearAll() {
- final int MAX_ATTEMPTS = 10;
- int attempt = 0;
- while (attempt < MAX_ATTEMPTS) {
- if (dismissTask() == false) {
- break;
- }
- ++attempt;
- // Once all tasks are dismissed, it exits to Home screen
- if (!isAppInForeground()) {
- break;
- }
- }
- Log.i(LOG_TAG, String.format("%d task(s) is dismissed.", attempt));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean hasContent() {
- if (!isAppInForeground()) {
- throw new IllegalStateException("Recents is not open.");
- }
- return (getTaskCountOnScreen() > 0);
- }
-
- /**
- * @return True if there is no content and it shows the "No recent items" text on screen.
- */
- public boolean hasNoRecentItems() {
- return mDevice.hasObject(By.text(TEXT_NO_ITEMS));
- }
-
- /**
- * Setup expectations: The target application is open in Recents.
- * <p>
- * Selects a given application.
- * </p>
- * @return True if it selects a given application.
- */
- public boolean selectTask(String appName) {
- boolean found = (findTask(appName) != null);
- if (!found) {
- Log.w(LOG_TAG, String.format("The application not found in Recents: %s", appName));
- }
- return found;
- }
-
- /**
- * Setup expectations: "Recents" is open.
- * @return the name for an application currently selected in Recents
- */
- public String getFocusedTaskName() {
- UiObject2 taskView = mDevice.wait(Until.findObject(getTaskViewSelector()),
- RECENTS_SELECTION_TIMEOUT);
- if (taskView == null) {
- throw new UiTimeoutException("No task view found in Recents");
- }
- return taskView.findObject(By.focused(true)).findObject(
- By.res(UI_PACKAGE, "card_title_text")).getText();
- }
-
- /**
- * Setup expectations: "Recents" is open.
- * @return the number of tasks on the Recents screen. This may differ from the number of
- * the actual tasks.
- */
- public int getTaskCountOnScreen() {
- return mDevice.findObject(getTaskViewSelector()).getChildCount();
- }
-
- /**
- * Returns a {@link BySelector} describing the task to be dismissed in Recents
- * @return
- */
- private BySelector getTaskDismissSelector() {
- // The text "Dismiss" appears only when the card is selected to be dismissed on leanback.
- return By.pkg(UI_PACKAGE).focused(true)
- .hasChild(By.res(UI_PACKAGE, "card_dismiss_text").text("Dismiss"));
- }
-
- /**
- * Returns a {@link BySelector} describing the task view in Recents
- * @return
- */
- private BySelector getTaskViewSelector() {
- return By.res(UI_PACKAGE, "task_list");
- }
-
- /**
- * Setup expectations: "Recents" is open. This method will dismiss a focused task in Recents.
- * @return True if a task is dismissed
- */
- public boolean dismissTask() {
- if (hasNoRecentItems()) {
- Log.i(LOG_TAG, "No recent items found");
- return false;
- }
-
- if (!mDevice.wait(Until.hasObject(getTaskViewSelector()), RECENTS_SELECTION_TIMEOUT)) {
- throw new UnknownUiException("No task view found in Recents");
- }
- UiObject2 task = mDevice.findObject(getTaskDismissSelector());
- if (task == null) {
- // Select a task to be dismissed again by pressing the down key
- mDevice.pressDPadDown();
- task = mDevice.wait(Until.findObject(getTaskDismissSelector()),
- RECENTS_SELECTION_TIMEOUT);
- if (task == null) {
- throw new UnknownUiException("Dismiss button not found");
- }
- }
- mDevice.pressDPadCenter();
- // Confirm that the task is dismissed
- return mDevice.wait(Until.gone(getTaskDismissSelector()), RECENTS_SELECTION_TIMEOUT);
- }
-
- private UiObject2 findTask(String appName) {
- UiObject2 taskView = mDevice.wait(Until.findObject(getTaskViewSelector()),
- RECENTS_SELECTION_TIMEOUT);
- UiObject2 app;
- final int MAX_ATTEMPTS = 10;
- if ((app = findTask(taskView, appName, Direction.LEFT, MAX_ATTEMPTS)) != null) {
- return app;
- }
- if ((app = findTask(taskView, appName, Direction.RIGHT, MAX_ATTEMPTS)) != null) {
- return app;
- }
- return null;
- }
-
- private UiObject2 findTask(UiObject2 container, String appName, Direction direction,
- int maxAttempts) {
- UiObject2 focused = container.findObject(By.focused(true));
- if (focused == null) {
- throw new UnknownUiException("No focused item found in Recents");
- }
- String currentName = focused.findObject(By.res(UI_PACKAGE, "card_title_text")).getText();
- String nextName;
- int attempt = 0;
- boolean found = false;
- while (!(found = appName.equalsIgnoreCase(currentName)) && attempt++ < maxAttempts) {
- mDPadHelper.pressDPad(direction);
- nextName = container.findObject(By.focused(true)).findObject(
- By.res(UI_PACKAGE, "card_title_text")).getText();
- if (currentName.equals(nextName)) {
- // It reaches to the end in this direction
- Log.d(LOG_TAG, String.format("%s not found in Recents until it reaches to the end",
- appName));
- return null;
- } else {
- currentName = nextName;
- }
- }
-
- if (found) {
- return focused;
- }
- Log.d(LOG_TAG, String.format("%s not found in Recents by moving next %d times",
- appName, maxAttempts));
- return null;
- }
-}
-
diff --git a/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiSettingsHelperImpl.java b/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiSettingsHelperImpl.java
deleted file mode 100644
index b996c5e06..000000000
--- a/libraries/first-party-app-helpers/tv/sysui-app-helper/src/android/platform/test/helpers/tv/SysUiSettingsHelperImpl.java
+++ /dev/null
@@ -1,486 +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 android.platform.test.helpers.tv;
-
-import android.app.Instrumentation;
-import android.content.Context;
-import android.content.Intent;
-import android.platform.test.helpers.AbstractLeanbackAppHelper;
-import android.platform.test.helpers.DPadHelper;
-import android.platform.test.helpers.exceptions.UiTimeoutException;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.provider.Settings;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-import java.util.regex.Pattern;
-
-
-/**
- * App helper implementation class for TV Settings
- */
-public class SysUiSettingsHelperImpl extends AbstractLeanbackAppHelper {
- private static final String LOG_TAG = SysUiSettingsHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.android.tv.settings";
- private static final String ACTION_SETTINGS = Settings.ACTION_SETTINGS;
- private static final String RES_PKG_ANDROID = "android";
- private static final String RES_TITLE = "title";
- private static final String RES_SUMMARY = "summary";
- private static final long SHORT_SLEEP_MS = 3000;
-
- public static final int SETTINGS_SYSTEM = 0;
- public static final int SETTINGS_SECURE = 1;
- public static final int SETTINGS_GLOBAL = 2;
-
- private Context mContext;
-
-
- public SysUiSettingsHelperImpl(Instrumentation instrumentation) {
- super(instrumentation);
- mDPadHelper = DPadHelper.getInstance(instrumentation);
- mContext = instrumentation.getContext();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- throw new UnsupportedOperationException("This method is not supported for Settings");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- open(ACTION_SETTINGS, SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectation: On the launcher home screen.
- * <p>
- * Launches the desired application and wait for it to begin running before returning.
- * </p>
- * @param timeoutMs timeout in milliseconds to open an activity
- */
- public void open(String action, long timeoutMs) {
- launchActivity(action);
- if (timeoutMs > 0 && !waitForOpen(timeoutMs)) {
- throw new UiTimeoutException(String.format("Timed out to open a target package %s:"
- + " %d(ms)", getPackage(), timeoutMs));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void exit() {
- mDevice.pressHome();
- mDevice.waitForIdle();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- // Nothing to do.
- }
-
- /**
- * Setup expectations: The Settings is open.
- * <p>
- * Selects the main Settings item by title text.
- * </p>
- * @param title the title string of the setting to find
- * @return true if the setting that matches the name is open
- */
- public boolean clickSetting(String title) {
- UiObject2 setting = findSettingByTitle(title);
- if (setting == null) {
- return false;
- }
- mDPadHelper.pressDPadCenterAndWait(Until.newWindow(), SHORT_SLEEP_MS);
- return true;
- }
-
- /**
- * Setup expectations: The Settings is open. Selects the main Settings item by summary text.
- * @param summary the summary string of the setting to find
- * @return true if the setting that matches the name is open
- */
- public boolean clickSettingBySummary(String summary) {
- UiObject2 setting = findSettingBySummary(summary);
- if (setting == null) {
- return false;
- }
- mDPadHelper.pressDPadCenterAndWait(Until.newWindow(), SHORT_SLEEP_MS);
- return true;
- }
-
- /**
- * Setup expectations: The Settings is open.
- * @param title the title string of the setting to find
- * @return true if it finds {@link UiObject2} that has a given title text
- */
- public boolean hasSettingByTitle(String title) {
- return (findSettingByTitle(title) != null);
- }
-
- /**
- * Setup expectations: The Settings is open.
- * @param summary the summary string of the setting to find
- * @return true if it finds {@link UiObject2} that has a given summary text
- */
- public boolean hasSettingBySummary(String summary) {
- return (findSettingBySummary(summary) != null);
- }
-
- /**
- * Setup expectations: The Settings is open. Finds the setting that matches both
- * a given title and summary
- * @param title the title string of the setting to find
- * @param summary the summary string of the setting to find
- * @return true if it finds {@link UiObject2} that has both title and summary text passed.
- */
- public boolean hasSettingByTitleAndSummary(String title, String summary) {
- return (findSettingByTitleAndSummary(title, summary) != null);
- }
-
- /**
- * Setup expectations: The Settings is open.
- * @param text the name of the setting to find
- * @return true if it finds {@link UiObject2} that has a given text either in title or summary
- */
- public boolean hasSettingByTitleOrSummary(String text) {
- return (findSettingByTitleOrSummary(text) != null);
- }
-
- /**
- * Setup expectations: The Settings is open. Checks if the switch bar is turned on.
- * @param title the name of the setting to check
- * @return true if the setting is turned on
- */
- public boolean isSwitchBarOn(String title) {
- return "ON".equals(getSwitchBarText(title));
- }
-
- /**
- * Setup expectations: The Settings is open. Checks if the switch bar is turned off.
- * @param title the name of the setting to check
- * @return true if the setting is turned off
- */
- public boolean isSwitchBarOff(String title) {
- return "OFF".equals(getSwitchBarText(title));
- }
-
- /**
- * Setup expectations: The Accessibility Settings is open. Finds the preview text on screen.
- * @return true if the preview text is displayed on screen.
- */
- public boolean hasPreviewText() {
- return mDevice.hasObject(By.res(UI_PACKAGE, "preview_text"));
- }
-
- /**
- * Setup expectations: The Settings is open.
- * @return {@link UiObject2} of the current focused setting
- */
- public String getCurrentFocusedSettingTitle() {
- return mDevice.wait(Until.findObject(By.focused(true)), SHORT_SLEEP_MS)
- .findObject(By.res(RES_PKG_ANDROID, "title")).getText();
- }
-
- /**
- * Setup expectations: The Settings is open. Returns the summary text of the selected Settings.
- * @param title the name of the setting to get the summary text
- * @return String of the summary text
- */
- public String getSummaryTextByTitle(String title) {
- UiObject2 settings = findSettingByTitle(title);
- return settings.findObject(By.res(RES_PKG_ANDROID, RES_SUMMARY)).getText();
- }
-
- /**
- * Setup expectations: The Settings is open.
- *
- * Exit the guided settings by pressing BACK key a given times
- * @param maxDepth The maximum depth to exit the guided settings. Should be greater than 0
- * @return true if the Settings is closed.
- */
- public boolean goBackGuidedSettings(int maxDepth) {
- if (maxDepth < 1) {
- Log.w(LOG_TAG, "maxDepth should be greater than 0");
- maxDepth = 1;
- }
- UiObject2 focused = mDevice.wait(Until.findObject(By.focused(true)), SHORT_SLEEP_MS);
- if (focused == null) {
- throw new IllegalStateException("No focused item is found");
- }
- while (maxDepth-- > 0) {
- mDPadHelper.pressBack();
- if (!waitForOpen(SHORT_SLEEP_MS)) {
- Log.w(LOG_TAG, "Settings is closed.");
- return false;
- } else if (focused.equals(
- mDevice.wait(Until.findObject(By.focused(true)), SHORT_SLEEP_MS))) {
- Log.w(LOG_TAG, "The focused is the same. Nothing happened in Settings?");
- return false;
- }
- }
- return true;
- }
-
- /**
- * Setup expectations: On waiting for a guided setting to open.
- * @param title the title string of the guided setting
- * @param timeoutMs timeout in milliseconds to get the header title
- * @return true if the guided setting that has a given title is open in timeout
- */
- public boolean waitForOpenGuidedSetting(String title, long timeoutMs) {
- UiObject2 header = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE, "decor_title").text(title)), timeoutMs);
- return (header != null);
- }
-
- /**
- * Setup expectations: The Settings is open.
- * @return the title of the guided settings
- */
- private String getGuidedSettingTitle() {
- UiObject2 header = mDevice.findObject(By.res(UI_PACKAGE, "decor_title"));
- if (header == null) {
- throw new UnknownUiException("Header text is not found");
- }
- return header.getText();
- }
-
- public String getStringSetting(int type, String name) {
- switch (type) {
- case SETTINGS_SYSTEM:
- return Settings.System.getString(mContext.getContentResolver(), name);
- case SETTINGS_GLOBAL:
- return Settings.Global.getString(mContext.getContentResolver(), name);
- case SETTINGS_SECURE:
- return Settings.Secure.getString(mContext.getContentResolver(), name);
- }
- return "";
- }
-
- public int getIntSetting(int type, String name, int def) {
- int value = getIntSetting(type, name);
- return value != Integer.MIN_VALUE ? value : def;
- }
-
- public int getIntSetting(int type, String name) {
- try {
- switch (type) {
- case SETTINGS_SYSTEM:
- return Settings.System.getInt(mContext.getContentResolver(), name);
- case SETTINGS_GLOBAL:
- return Settings.Global.getInt(mContext.getContentResolver(), name);
- case SETTINGS_SECURE:
- return Settings.Secure.getInt(mContext.getContentResolver(), name);
- }
- } catch (Settings.SettingNotFoundException e) {
- Log.w(LOG_TAG, String.format("Settings not found name=%s, type=%d", name, type));
- }
- return Integer.MIN_VALUE;
- }
-
- public boolean isDeveloperOptionsEnabled() {
- return getIntSetting(SETTINGS_GLOBAL, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
- android.os.Build.TYPE.equals("eng") ? 1 : 0) == 1;
- }
-
- /**
- * Setup expectations: PIN code activity is open. Set a new PIN code
- * @param pinCode the PIN code of 4 digits
- * @return true if a PIN code is set
- */
- public boolean setNewPinCode(String pinCode) {
- return setPinCode("Set a new PIN", pinCode, Direction.DOWN);
- }
-
- public boolean reenterPinCode(String pinCode) {
- return setPinCode("Re-enter new PIN", pinCode, Direction.DOWN);
- }
-
- public boolean enterPinCode(String pinCode) {
- return setPinCode("Enter PIN", pinCode, Direction.DOWN);
- }
-
- protected BySelector getTitleSelector(String text) {
- return By.res(RES_PKG_ANDROID, RES_TITLE).text(text);
- }
-
- protected BySelector getSummarySelector(String text) {
- return By.res(RES_PKG_ANDROID, RES_SUMMARY).text(text);
- }
-
- /**
- * Find the focused item in Settings that has a descendant matches the criteria.
- * @param selector for a descendant of the setting to match.
- * @param direction the direction to find, only accepts UP and DOWN.
- * @return {@link UiObject2} of the focusable item that has a given descendant
- */
- private UiObject2 findSettingHasDescendant(BySelector selector, Direction direction) {
- if (!isAppInForeground()) {
- throw new IllegalStateException("Required to open the Settings ahead");
- }
- if (direction != Direction.DOWN && direction != Direction.UP) {
- throw new IllegalArgumentException("Required to go either up or down to find rows");
- }
-
- UiObject2 currentFocused = mDevice.findObject(By.focused(true));
- UiObject2 prevFocused = null;
- UiObject2 found = null;
- while (!currentFocused.equals(prevFocused)) {
- if ((found = mDevice.findObject(By.focused(true).hasDescendant(selector, 3)))
- != null) {
- return found;
- }
- if (direction == Direction.DOWN) {
- mDevice.pressDPadDown();
- } else if (direction == Direction.UP) {
- mDevice.pressDPadUp();
- }
- prevFocused = currentFocused;
- currentFocused = mDevice.findObject(By.focused(true));
- }
- Log.d(LOG_TAG, "Failed to find the item until it reaches the end.");
- return found;
- }
-
- private String getSwitchBarText(String title) {
- UiObject2 setting = findSettingByTitle(title);
- return setting.findObject(By.res(RES_PKG_ANDROID, "switch_widget")).getText();
- }
-
- private UiObject2 findSettingByTitle(String title) {
- return findSettingBySelector(getTitleSelector(title), true);
- }
-
- private UiObject2 findSettingBySummary(String summary) {
- return findSettingBySelector(getSummarySelector(summary), true);
- }
-
- private UiObject2 findSettingByTitleAndSummary(String title, String summary) {
- BySelector titleSelector = getTitleSelector(title);
- BySelector summarySelector = getSummarySelector(summary);
- UiObject2 setting;
- while ((setting = findSettingHasDescendant(titleSelector, Direction.DOWN)) != null) {
- if (setting.hasObject(summarySelector)) {
- return setting;
- }
- }
- while ((setting = findSettingHasDescendant(titleSelector, Direction.UP)) != null) {
- if (setting.hasObject(summarySelector)) {
- return setting;
- }
- }
- return null;
- }
-
- private UiObject2 findSettingByTitleOrSummary(String text) {
- final Pattern RES_REGEX = Pattern.compile(
- String.format("%s:id/(%s|%s)", RES_PKG_ANDROID, RES_TITLE, RES_SUMMARY));
- return findSettingBySelector(By.res(RES_REGEX).text(text), true);
- }
-
- private UiObject2 findSettingBySelector(BySelector selector, boolean throwIfFail) {
- UiObject2 setting;
- if ((setting = findSettingHasDescendant(selector, Direction.DOWN)) != null) {
- return setting;
- }
- if ((setting = findSettingHasDescendant(selector, Direction.UP)) != null) {
- return setting;
- }
- if (throwIfFail) {
- throw new UnknownUiException(
- String.format("No focused setting matches a given selector: %s",
- selector.toString()));
- }
- return null;
- }
-
- private boolean setPinCode(String title, String pinCode, Direction direction) {
- if (!isValidPinCode(pinCode)) {
- throw new IllegalArgumentException("4 digits PIN code is valid. pinCode=" + pinCode);
- }
- if (direction != Direction.DOWN && direction != Direction.UP) {
- throw new IllegalArgumentException("Either up or down is allowed");
- }
- if (!mDevice.wait(Until.hasObject(By.res(getPackage(), "title").text(title)),
- SHORT_SLEEP_MS)) {
- throw new IllegalStateException("The title for PIN code not found: " + title);
- }
-
- // the PIN number starts from 0 and increases by going down
- for (char c : pinCode.toCharArray()) {
- int number = c - '0';
- // Note that the resource ID for the number changes by the direction to search
- String resId = (number == 0) ? "current_number"
- : (direction == Direction.DOWN) ? "next_number" : "previous_number";
- mDPadHelper.pressDPad(direction, number);
- if (!mDevice.wait(
- Until.hasObject(By.res(getPackage(), resId).text(String.valueOf(c))),
- SHORT_SLEEP_MS)) {
- throw new UnknownUiException("Couldn't find the number:" + c);
- }
- mDPadHelper.pressDPadCenter(); // Move next
- }
- return true;
- }
-
- private boolean isValidPinCode(String pinCode) {
- final String PIN_CODE_FORMAT = "[0-9][0-9][0-9][0-9]";
- return pinCode != null && pinCode.matches(PIN_CODE_FORMAT);
- }
-
- /**
- * Setup expectations: None
- *
- * Starts the Settings activity
- */
- // TODO Move to a base or utility class that each test could access
- private void launchActivity() {
- launchActivity(ACTION_SETTINGS);
- }
-
- private void launchActivity(String action) {
- Intent intent = new Intent(action);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
- Log.d(LOG_TAG, "launchActivity intent=" + intent.toString());
- mInstrumentation.getContext().startActivity(intent);
- }
-}
diff --git a/libraries/first-party-app-helpers/tv/youtube-app-helper/Android.mk b/libraries/first-party-app-helpers/tv/youtube-app-helper/Android.mk
deleted file mode 100644
index 7c1d57208..000000000
--- a/libraries/first-party-app-helpers/tv/youtube-app-helper/Android.mk
+++ /dev/null
@@ -1,24 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := tv-youtube-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
diff --git a/libraries/first-party-app-helpers/tv/youtube-app-helper/src/android/platform/test/helpers/tv/YouTubeHelperImpl.java b/libraries/first-party-app-helpers/tv/youtube-app-helper/src/android/platform/test/helpers/tv/YouTubeHelperImpl.java
deleted file mode 100644
index 364640202..000000000
--- a/libraries/first-party-app-helpers/tv/youtube-app-helper/src/android/platform/test/helpers/tv/YouTubeHelperImpl.java
+++ /dev/null
@@ -1,389 +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 android.platform.test.helpers.tv;
-
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.os.SystemClock;
-import android.platform.test.helpers.AbstractLeanbackAppHelper;
-import android.platform.test.helpers.exceptions.UiTimeoutException;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
-
-
-public class YouTubeHelperImpl extends AbstractLeanbackAppHelper {
-
- private static final String TAG = YouTubeHelperImpl.class.getSimpleName();
- private static final String UI_PACKAGE = "com.google.android.youtube.tv";
- private static final String RES_MAIN_ACTIVITY_ID = "top_layout";
- private static final long SHORT_SLEEP_MS = 5000; // 5 seconds
- private static final long LONG_SLEEP_MS = 30000; // 30 seconds
- private static final long LOADING_CONTENT_TIMEOUT_MS = 5000;
-
-
- public YouTubeHelperImpl(Instrumentation instrumentation) {
- super(instrumentation);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "YouTube";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected BySelector getMainActivitySelector() {
- return By.res(UI_PACKAGE, RES_MAIN_ACTIVITY_ID);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected BySelector getBrowseHeadersSelector() {
- return By.res(UI_PACKAGE, "guide").hasChild(By.selected(true));
- }
-
- /**
- * Selects search orb.
- */
- public void selectSearchOrb() {
- returnToMainActivity();
- UiObject2 searchOrb = null;
-
- final int MAX_ATTEMPTS_SEARCH_ORB = 20;
- int attempt = 0;
- // Wait until the search orb appears at runtime.
- while (attempt++ < MAX_ATTEMPTS_SEARCH_ORB) {
- searchOrb = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE, "title_orb").clickable(true)), SHORT_SLEEP_MS);
- if (searchOrb == null) {
- // Search orb could be found at the top of activity
- mDPadHelper.pressDPad(Direction.UP);
- continue;
- }
- }
- if (attempt == MAX_ATTEMPTS_SEARCH_ORB) {
- throw new UnknownUiException("Failed to select search orb");
- }
- searchOrb.click();
- }
-
- /**
- * Search for a given query text in YouTube app
- */
- public void search(String query) {
- selectSearchOrb();
-
- UiObject2 editText = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE, "lb_search_text_editor")),
- 5 * 60 * 1000);
- if (editText == null) {
- throw new UnknownUiException("Search text editor not found");
- }
- if (!editText.isFocused()) {
- Log.d(TAG, "Search text editor is getting focus");
- mDevice.pressDPadRight();
- SystemClock.sleep(SHORT_SLEEP_MS);
- }
- editText.setText(query);
- mDevice.waitForIdle();
- mDevice.pressEnter();
- if (!waitForContentLoaded(SHORT_SLEEP_MS)) {
- throw new UiTimeoutException(
- String.format("Failed to find the search results in %d (ms)", SHORT_SLEEP_MS));
- }
- }
-
- /**
- * Setup expectations: YouTube search result is open and the first result is focused.
- *
- * Open the first visible search result in the list and block until the search result
- * comes in the foreground.
- */
- public void openFirstSearchResult() {
- openSearchResultByIndex(0);
- }
-
- /**
- * Setup expectations: YouTube search result is open and the first result is focused.
- *
- * Open the (index)'th visible search result in the list and block until the search result
- * comes in the foreground.
- */
- public void openSearchResultByIndex(int index) {
- if (!isInSearchPage()) {
- throw new IllegalStateException("Must be in search page to select search results");
- }
- UiObject2 rowContent = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE, "row_content")), SHORT_SLEEP_MS);
- if (rowContent == null) {
- throw new IllegalStateException("No search results found");
- }
-
- // Select a content by index
- UiObject2 focused = rowContent.findObject(By.focused(true));
- if (focused == null) {
- throw new IllegalStateException("The search result is not selected");
- }
- UiObject2 current;
- for (int i = 0; i < index; ++i) {
- mDevice.pressDPadRight();
- SystemClock.sleep(SHORT_SLEEP_MS);
- current = rowContent.findObject(By.focused(true));
- if (focused.equals(current)) {
- Log.w(TAG, "openSearchResultByIndex: the index is out of bounds.");
- break;
- } else {
- focused = current;
- }
- }
- mDevice.pressDPadCenter();
-
- // Wait until the content is open
- if (!mDevice.wait(Until.gone(By.res(UI_PACKAGE, "lb_search_bar_items")),
- LOADING_CONTENT_TIMEOUT_MS)) {
- throw new UiTimeoutException("Opening search result timed out");
- }
- }
-
- /**
- * Setup expectations: Loading content in the app
- *
- * This method blocks until the content is loaded in a content row or a search row
- *
- * @param timeout wait timeout in milliseconds
- * @return true if the content is loaded within timeout, false otherwise
- */
- public boolean waitForContentLoaded(long timeout) {
- return mDevice.wait(
- Until.hasObject(By.res(UI_PACKAGE, "row_content").hasChild(By.selected(true))),
- timeout);
- }
-
- /**
- * Setup expectations: Sign-in page is open.
- *
- * Selects the account to use if no account has been set up.
- */
- public boolean signIn(String account) {
- if (!"Sign in".equals(getGuidanceTitleText())) {
- throw new IllegalStateException("This method should be called in the Sign-in page.");
- }
- if (selectGuidedAction(account) == null) {
- Log.e(TAG, String.format("No account matches: %s", account));
- return false;
- }
- mDPadHelper.pressDPadCenter();
- return mDevice.wait(Until.hasObject(getMainActivitySelector()), SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectations: On browse fragment. Sign out
- */
- public void signOut() {
- openSettings();
- if (!hasCardInRow("Sign out")) {
- throw new UnknownUiException("Sign out is not found");
- }
- mDPadHelper.pressDPadCenter();
- mDevice.wait(Until.findObject(By.res(getPackage(), "title_text").text("Sign in")),
- SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectations: The main activity is open.
- *
- * Returns true if no user is signed in the app.
- */
- public boolean isNoUserSignedIn() {
- // Some sections "Subscriptions", "History", "Purchases" are not available
- // with no user signed in
- final String[] SECTIONS_FOR_SIGNED_IN_USER = {"Subscriptions", "History", "Purchases"};
- for (String section : SECTIONS_FOR_SIGNED_IN_USER) {
- if (mDevice.hasObject(By.res(getPackage(), "row_header").text(section))) {
- Log.d(TAG, "The section for a signed in user is found: " + section);
- return false;
- }
- }
-
- // Open Settings and confirm that the Sign-in card is shown
- openSettings();
- return hasCardInRow("Sign in");
- }
-
- /**
- * Setup expectations: On browse fragment
- *
- * Returns the name of account currently signed in
- */
- public String getSignInUserName() {
- openSettings();
- return getCardContentText("Sign out");
- }
-
- private boolean isInSearchPage() {
- return mDevice.hasObject(By.res(UI_PACKAGE, "search_fragment"));
- }
-
- /**
- * @return true if YouTube plays a video in the foreground
- */
- public boolean isInVideoPlayback() {
- return isInVideoPlayback(0);
- }
-
- private boolean isInVideoPlayback(long timeoutMs) {
- if (!isAppInForeground()) {
- Log.w(TAG, "YouTube was closed.");
- return false;
- }
- return mDevice.wait(Until.hasObject(By.res(UI_PACKAGE, "watch_player")), timeoutMs);
- }
-
- /**
- * Open the Popular on YouTube section
- */
- public void openPopularOnYouTube() {
- openHeader("Popular on YouTube");
- }
-
- public void openHome() {
- openHeader("Home");
- }
-
- public void openSettings() {
- openHeader("Settings");
- }
-
- private UiObject2 getFocusedVideoCard() {
- BySelector cardSelector = By.focused(true).hasChild(
- By.res(getPackage(), "image_card"));
- return mDevice.wait(Until.findObject(cardSelector), SHORT_SLEEP_MS);
- }
-
- /**
- * Setup expectations: YouTube is open with a focused video.
- * @return the duration in milliseconds of a focused video
- */
- public long getFocusedVideoDuration() {
- UiObject2 card = getFocusedVideoCard();
- if (card == null) {
- throw new IllegalStateException("Could not find the video card");
- }
- // Get video length
- UiObject2 length = card.findObject(By.res(getPackage(), "duration"));
- if (length == null) {
- throw new UnknownUiException("Could not find an object of video duration");
- }
- String durationText = length.getText();
- if (durationText == null || "".equals(durationText)) {
- throw new UnknownUiException("Could not find length of the selected video");
- }
-
- String formatString = (durationText.split(":").length == 3) ? "HH:mm:ss" : "mm:ss";
- SimpleDateFormat format = new SimpleDateFormat(formatString);
- format.setTimeZone(TimeZone.getTimeZone("GMT"));
- long durationMs;
- try {
- durationMs = format.parse(length.getText()).getTime();
- Log.d(TAG, String.format("Video length is %d in milliseconds", durationMs));
- } catch (ParseException e) {
- throw new RuntimeException(String.format("Failed to parse video length '%s'",
- length.getText()));
- }
- return durationMs;
- }
-
- /**
- * Setup expectations: YouTube is open with a focused video.
- * @return the title text of a focused video
- */
- public String getFocusedVideoTitleText() {
- UiObject2 card = getFocusedVideoCard();
- if (card == null) {
- throw new IllegalStateException("Could not find the video card");
- }
- return card.findObject(By.res(getPackage(), "title_text")).getText();
- }
-
- /**
- * Setup expectations: YouTube is open with a focused video.
- * @return the content text of a focused video
- */
- public String getFocusedVideoContentText() {
- UiObject2 card = getFocusedVideoCard();
- if (card == null) {
- throw new IllegalStateException("Could not find the video card");
- }
- return card.findObject(By.res(getPackage(), "content_text")).getText();
- }
-
- /**
- * Setup expectations: YouTube is open with a focused video.
- * @param timeoutMs Timeout in milliseconds to play a video. Set to 0 if it plays until the
- * end.
- * @return true if it plays without an error during a given duration.
- */
- public boolean playFocusedVideo(long timeoutMs) {
- long durationMs = getFocusedVideoDuration();
- Log.i(TAG, String.format("Playing a video for %d (ms)", timeoutMs));
-
- // Play the video
- mDevice.pressDPadCenter();
- if (!isInVideoPlayback(SHORT_SLEEP_MS)) {
- throw new IllegalStateException("Must be in video playback");
- }
-
- // Wait for the given duration
- if (timeoutMs <= 0 || timeoutMs > durationMs) {
- timeoutMs = durationMs;
- }
- SystemClock.sleep(timeoutMs);
- return true;
- }
-
- // TODO Move to a base or utility class that each test could access.
- public void launchActivity() {
- Intent intent = mInstrumentation.getContext().getPackageManager()
- .getLaunchIntentForPackage(UI_PACKAGE);
- Log.d(TAG, "launchActivity intent=" + intent.toString());
- mInstrumentation.getContext().startActivity(intent);
- }
-}
diff --git a/libraries/third-party-app-helpers/Android.mk b/libraries/third-party-app-helpers/Android.mk
deleted file mode 100644
index 91134e6b9..000000000
--- a/libraries/third-party-app-helpers/Android.mk
+++ /dev/null
@@ -1,27 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := third-party-app-helpers
-LOCAL_STATIC_JAVA_LIBRARIES := launcher-helper-lib base-app-helpers facebook-app-helper \
- reddit-app-helper flightdemo-app-helper tunein-app-helper
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-######################################
-
-include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/libraries/third-party-app-helpers/facebook-app-helper/Android.mk b/libraries/third-party-app-helpers/facebook-app-helper/Android.mk
deleted file mode 100644
index b997aea68..000000000
--- a/libraries/third-party-app-helpers/facebook-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := facebook-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/third-party-app-helpers/facebook-app-helper/src/android/platform/test/helpers/FacebookHelperImpl.java b/libraries/third-party-app-helpers/facebook-app-helper/src/android/platform/test/helpers/FacebookHelperImpl.java
deleted file mode 100644
index b7f39f62a..000000000
--- a/libraries/third-party-app-helpers/facebook-app-helper/src/android/platform/test/helpers/FacebookHelperImpl.java
+++ /dev/null
@@ -1,285 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.SystemClock;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-
-public class FacebookHelperImpl extends AbstractFacebookHelper {
- private static final String TAG = "android.platform.test.helpers.FacebookHelperImpl";
-
- private static final String UI_HOME_PAGE_CONTAINER_ID = "cs7";
- private static final String UI_LOADING_VIEW_ID = "loading_view";
- private static final String UI_LOGIN_BUTTON_ID = "bjb";
- private static final String UI_LOGIN_PASSWORD_ID = "bj_";
- private static final String UI_LOGIN_ROOT_ID = "bj6";
- private static final String UI_LOGIN_USERNAME_ID = "bj8";
- private static final String UI_NEWS_FEED_TAB_ID = "a0";
- private static final String UI_NEWS_FEED_TAB_SELECTED_DESC = "News";
- private static final String UI_PACKAGE_NAME = "com.facebook.katana";
- private static final String UI_POST_BUTTON_ID = "rk";
- private static final String UI_STATUS_TEXT_ID = "cmk";
- private static final String UI_STATUS_UPDATE_BUTTON_ID = "bmp";
- private static final String UI_LOGIN_ONE_TAP = "sc";
-
- private static final long UI_LOGIN_WAIT = 30000;
- private static final long UI_NAVIGATION_WAIT = 10000;
-
- public FacebookHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void open() {
- super.open();
- mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_HOME_PAGE_CONTAINER_ID)), UI_NAVIGATION_WAIT);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE_NAME;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Facebook";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
-
- }
-
- private UiObject2 getHomePageContainer() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_HOME_PAGE_CONTAINER_ID));
- }
-
- private boolean isOnHomePage() {
- return (getHomePageContainer() != null);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void scrollHomePage(Direction dir) {
- UiObject2 scrollContainer = getHomePageContainer();
- if (scrollContainer == null) {
- throw new IllegalStateException("No valid scrolling mechanism found.");
- }
-
- scrollContainer.scroll(dir, 5.f);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToHomePage() {
- // Try to go to the home page by repeatedly pressing the back button
- for (int retriesRemaining = 5; retriesRemaining > 0 && !isOnHomePage();
- --retriesRemaining) {
- mDevice.pressBack();
- mDevice.waitForIdle();
- }
- }
-
- private UiObject2 getNewsFeedTab() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_NEWS_FEED_TAB_ID));
- }
-
- private boolean isOnNewsFeed() {
- UiObject2 newsFeedTab = getNewsFeedTab();
- if (newsFeedTab == null) {
- return false;
- }
-
- return newsFeedTab.getContentDescription().contains(UI_NEWS_FEED_TAB_SELECTED_DESC);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToNewsFeed() {
- if (!isOnHomePage()) {
- throw new IllegalStateException("Not on home page");
- }
-
- UiObject2 newsFeedTab = getNewsFeedTab();
- if (newsFeedTab == null) {
- throw new UnknownUiException("Could not find news feed tab");
- }
-
- newsFeedTab.click();
- mDevice.wait(Until.findObject(By.res(UI_PACKAGE_NAME, UI_NEWS_FEED_TAB_ID).descContains(
- UI_NEWS_FEED_TAB_SELECTED_DESC)), UI_NAVIGATION_WAIT);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToStatusUpdate() {
- if (!isOnNewsFeed()) {
- throw new IllegalStateException("Not on News Feed");
- }
-
- UiObject2 statusUpdateButton = null;
- for (int retriesRemaining = 50; retriesRemaining > 0 && statusUpdateButton == null;
- --retriesRemaining) {
- scrollHomePage(Direction.UP);
- statusUpdateButton = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_STATUS_UPDATE_BUTTON_ID));
- }
- if (statusUpdateButton == null) {
- throw new UnknownUiException("Could not find status update button");
- }
-
- statusUpdateButton.click();
- mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_STATUS_TEXT_ID)), UI_NAVIGATION_WAIT);
-
- getStatusTextField().click();
- }
-
- private UiObject2 getStatusTextField() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_STATUS_TEXT_ID));
- }
-
- private boolean isOnStatusUpdatePage() {
- return (mDevice.hasObject(By.text("Post to Facebook")) &&
- mDevice.hasObject(By.text("What's on your mind?")));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void clickStatusUpdateTextField() {
- if (!isOnStatusUpdatePage()) {
- throw new IllegalStateException("Not on status update page");
- }
-
- UiObject2 statusTextField = getStatusTextField();
-
- if (statusTextField == null) {
- throw new UnknownUiException("Cannot find status update text field");
- }
-
- statusTextField.click();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setStatusText(String statusText) {
- UiObject2 statusTextField = getStatusTextField();
- if (statusTextField == null) {
- throw new UnknownUiException("Could not find status text field");
- }
-
- statusTextField.setText(statusText);
- }
-
- private UiObject2 getPostButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_POST_BUTTON_ID));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void postStatusUpdate() {
- UiObject2 postButton = getPostButton();
- if (postButton == null) {
- throw new UnknownUiException("Could not find post status button");
- }
-
- postButton.click();
- mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_HOME_PAGE_CONTAINER_ID)), UI_NAVIGATION_WAIT);
- }
-
- private boolean isOnLoginPage() {
- return (mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_LOGIN_ROOT_ID)) != null);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void login(String username, String password) {
- if (!isOnLoginPage()) {
- return;
- }
-
- UiObject2 usernameTextField = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_LOGIN_USERNAME_ID));
- UiObject2 passwordTextField = mDevice.findObject(
- By.res(UI_PACKAGE_NAME, UI_LOGIN_PASSWORD_ID));
- UiObject2 loginButton = mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_LOGIN_BUTTON_ID));
- if (usernameTextField == null) {
- throw new UnknownUiException("Could not find username text field");
- }
- if (passwordTextField == null) {
- throw new UnknownUiException("Could not find password text field");
- }
- if (loginButton == null) {
- throw new UnknownUiException("Could not find login button");
- }
-
- usernameTextField.setText(username);
- passwordTextField.setText(password);
- loginButton.click();
-
- // Check if one tap login screen is prompted and click on it
- UiObject2 oneTapLogin = mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_LOGIN_ONE_TAP)), UI_NAVIGATION_WAIT);
- if (oneTapLogin != null) {
- oneTapLogin.click();
- }
-
- mDevice.wait(Until.findObject(
- By.res(UI_PACKAGE_NAME, UI_HOME_PAGE_CONTAINER_ID)), UI_NAVIGATION_WAIT);
- // Wait for user content to load after logging in
- mDevice.wait(Until.gone(By.res(UI_PACKAGE_NAME, UI_LOADING_VIEW_ID)), UI_LOGIN_WAIT);
- }
-}
diff --git a/libraries/third-party-app-helpers/flightdemo-app-helper/Android.mk b/libraries/third-party-app-helpers/flightdemo-app-helper/Android.mk
deleted file mode 100644
index c6c6b848d..000000000
--- a/libraries/third-party-app-helpers/flightdemo-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := flightdemo-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/third-party-app-helpers/flightdemo-app-helper/src/android/platform/test/helpers/FlightDemoHelperImpl.java b/libraries/third-party-app-helpers/flightdemo-app-helper/src/android/platform/test/helpers/FlightDemoHelperImpl.java
deleted file mode 100644
index a8e069dd7..000000000
--- a/libraries/third-party-app-helpers/flightdemo-app-helper/src/android/platform/test/helpers/FlightDemoHelperImpl.java
+++ /dev/null
@@ -1,123 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.UiSelector;
-import android.util.Log;
-
-import java.util.regex.Pattern;
-
-public class FlightDemoHelperImpl extends AbstractFlightDemoHelper {
- private static final String LOG_TAG = FlightDemoHelperImpl.class.getCanonicalName();
- private static final String UI_PACKAGE_NAME = "leofs.android.free";
- private static final String UI_ACTIVITY_NAME = "leofs.android.free.LeofsActivity";
-
- private static final int UI_RESPONSE_WAIT = 2000; // 2 secs
- private static final int MAX_MENU_SCROLL_DOWN_COUNT = 10;
-
- public FlightDemoHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE_NAME;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Leo´s RC Simulator";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
- // Nothing to do here. There is no initial dialog in this app.
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startDemo() {
- Log.v(LOG_TAG, "Starting flight simulator demo");
- selectMenuItem("Demo");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void stopDemo() {
- Log.v(LOG_TAG, "Stopping flight simulator demo");
- selectMenuItem("Reset");
- mDevice.pressBack();
- }
-
- private void selectMenuItem(String item) {
- mDevice.pressMenu();
- UiObject2 container = mDevice.wait(Until.findObject(By.res("android", "list")),
- UI_RESPONSE_WAIT);
- if (container == null) {
- throw new IllegalStateException("Cannot find scrollable menu");
- }
-
- String err_msg = String.format("Cannot find menu item %s", item);
- int scroll_counter = 0;
- UiObject2 button = null;
- boolean reachedEnd = false;
- while (!reachedEnd) {
- final Pattern word = Pattern.compile(item, Pattern.CASE_INSENSITIVE);
- button = mDevice.wait(Until.findObject(By.text(word)), UI_RESPONSE_WAIT);
- if (button != null) {
- button.click();
- break;
- }
-
- if (!container.scroll(Direction.DOWN, 1.0f) &&
- scroll_counter >= MAX_MENU_SCROLL_DOWN_COUNT) {
- reachedEnd = true;
- }
- scroll_counter++;
- }
- if (button != null) {
- button.click();
- }
- else {
- throw new IllegalStateException(err_msg);
- }
- }
-}
diff --git a/libraries/third-party-app-helpers/reddit-app-helper/Android.mk b/libraries/third-party-app-helpers/reddit-app-helper/Android.mk
deleted file mode 100644
index 1ad7af74e..000000000
--- a/libraries/third-party-app-helpers/reddit-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := reddit-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/third-party-app-helpers/reddit-app-helper/src/android/platform/test/helpers/RedditHelperImpl.java b/libraries/third-party-app-helpers/reddit-app-helper/src/android/platform/test/helpers/RedditHelperImpl.java
deleted file mode 100644
index d6e278417..000000000
--- a/libraries/third-party-app-helpers/reddit-app-helper/src/android/platform/test/helpers/RedditHelperImpl.java
+++ /dev/null
@@ -1,143 +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 android.platform.test.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.Direction;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-
-import junit.framework.Assert;
-
-/**
- * UI test helper for Reddit: The Official App (package: com.reddit.frontpage)
- */
-
-public class RedditHelperImpl extends AbstractRedditHelper {
- private static final String TAG = RedditHelperImpl.class.getSimpleName();
-
- private static final String UI_COMMENTS_PAGE_SCROLL_CONTAINER_ID = "detail_list";
- private static final String UI_FRONT_PAGE_SCROLL_CONTAINER_ID = "link_list";
- private static final String UI_LINK_TITLE_ID = "link_title";
- private static final String UI_PACKAGE_NAME = "com.reddit.frontpage";
- private static final String UI_REDDIT_WORDMARK_ID = "reddit_wordmark";
- private static final String UI_SAVE_BUTTON_ID = "action_save";
-
- private static final long UI_NAVIGATION_WAIT = 5000; // 5 secs
-
- public RedditHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE_NAME;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "Reddit";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
-
- }
-
- private UiObject2 getRedditWordmark() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_REDDIT_WORDMARK_ID));
- }
-
- private UiObject2 getFrontPageScrollContainer() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_FRONT_PAGE_SCROLL_CONTAINER_ID));
- }
-
- private UiObject2 getFirstArticleTitle() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_LINK_TITLE_ID));
- }
-
- private UiObject2 getSaveButton() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_SAVE_BUTTON_ID));
- }
-
- private UiObject2 getCommentPageScrollContainer() {
- return mDevice.findObject(By.res(UI_PACKAGE_NAME, UI_COMMENTS_PAGE_SCROLL_CONTAINER_ID));
- }
-
- private boolean isOnFrontPage() {
- return (getRedditWordmark() != null);
- }
-
- private boolean isOnCommentsPage() {
- return (getSaveButton() != null);
- }
-
- public void goToFrontPage() {
- for (int retriesRemaining = 5; retriesRemaining > 0 && !isOnFrontPage();
- --retriesRemaining) {
- mDevice.pressBack();
- mDevice.waitForIdle();
- }
- }
-
- public void goToFirstArticleComments() {
- Assert.assertTrue("Not on front page", isOnFrontPage());
-
- UiObject2 articleTitle = getFirstArticleTitle();
- Assert.assertNotNull("Could not find first article", articleTitle);
-
- articleTitle.click();
- mDevice.wait(Until.hasObject(By.res(UI_PACKAGE_NAME, UI_SAVE_BUTTON_ID)),
- UI_NAVIGATION_WAIT);
- }
-
- public boolean scrollFrontPage(Direction direction, float percent) {
- Assert.assertTrue("Not on front page", isOnFrontPage());
- Assert.assertTrue("Scroll direction must be UP or DOWN",
- Direction.UP.equals(direction) || Direction.DOWN.equals(direction));
-
- UiObject2 scrollContainer = getFrontPageScrollContainer();
- Assert.assertNotNull("Could not find front page scroll container", scrollContainer);
-
- return scrollContainer.scroll(direction, percent);
- }
-
- public boolean scrollCommentPage(Direction direction, float percent) {
- Assert.assertTrue("Not on comment page", isOnCommentsPage());
- Assert.assertTrue("Scroll direction must be UP or DOWN",
- Direction.UP.equals(direction) || Direction.DOWN.equals(direction));
-
- UiObject2 scrollContainer = getCommentPageScrollContainer();
- Assert.assertNotNull("Could not find comment page scroll container", scrollContainer);
-
- return scrollContainer.scroll(direction, percent);
- }
-}
diff --git a/libraries/third-party-app-helpers/tunein-app-helper/Android.mk b/libraries/third-party-app-helpers/tunein-app-helper/Android.mk
deleted file mode 100644
index bf4c2a3cc..000000000
--- a/libraries/third-party-app-helpers/tunein-app-helper/Android.mk
+++ /dev/null
@@ -1,23 +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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := tunein-app-helper
-LOCAL_JAVA_LIBRARIES := ub-uiautomator base-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/libraries/third-party-app-helpers/tunein-app-helper/src/android/platform/test/helpers/TuneInHelperImpl.java b/libraries/third-party-app-helpers/tunein-app-helper/src/android/platform/test/helpers/TuneInHelperImpl.java
deleted file mode 100644
index 392d2b96b..000000000
--- a/libraries/third-party-app-helpers/tunein-app-helper/src/android/platform/test/helpers/TuneInHelperImpl.java
+++ /dev/null
@@ -1,191 +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 android.platform.test.helpers;
-
-import android.app.Instrumentation;
-import android.platform.test.helpers.exceptions.UnknownUiException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Until;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.util.Log;
-import junit.framework.Assert;
-
-public class TuneInHelperImpl extends AbstractTuneInHelper {
- private static final String TAG = TuneInHelperImpl.class.getCanonicalName();
-
- private static final String UI_PACKAGE_NAME = "tunein.player";
- private static final long UI_ACTION_TIMEOUT = 5000;
- private static final int MAX_BACK_ATTEMPTS = 5;
-
- private static final String UI_LOCAL_RADIO_TEXT = "Local Radio";
- private static final String UI_FM_LIST_ID = "view_model_list";
- private static final String UI_START_PLAY_ID = "profile_primary_button";
- private static final String UI_MINI_PLAYER_PLAY_ID = "mini_player_play";
- private static final String UI_MINI_PLAYER_STOP_ID = "mini_player_stop";
-
- public TuneInHelperImpl(Instrumentation instr) {
- super(instr);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPackage() {
- return UI_PACKAGE_NAME;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLauncherName() {
- return "TuneIn Radio";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dismissInitialDialogs() {
-
- }
-
- private boolean isOnBrowsePage() {
- return mDevice.hasObject(By.text("Browse"));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToBrowsePage() {
- for (int tries = MAX_BACK_ATTEMPTS; tries > 0; tries--) {
- if (isOnBrowsePage()) {
- break;
- }
- mDevice.pressBack();
- mDevice.waitForIdle();
- }
- if (!isOnBrowsePage()) {
- throw new IllegalStateException("Fail to go to Browse Page");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void goToLocalRadio() {
- if (!isOnBrowsePage()) {
- throw new IllegalStateException("Not on Browse Page");
- }
-
- UiObject2 localRadio = mDevice.findObject(By.text(UI_LOCAL_RADIO_TEXT));
-
- if (localRadio == null) {
- throw new UnknownUiException("Cannot not find local radio");
- }
- else {
- if (!localRadio.clickAndWait(Until.newWindow(), UI_ACTION_TIMEOUT)) {
- throw new UnknownUiException("Fail to load Local Radio page");
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void selectFM(int i) {
- UiObject2 fmList = mDevice.wait(
- Until.findObject(By.res(UI_PACKAGE_NAME, UI_FM_LIST_ID)),
- UI_ACTION_TIMEOUT
- );
-
- if (fmList == null) {
- throw new UnknownUiException("Cannot not find fm list to select FM");
- }
-
- if (i <= 0 && i >= fmList.getChildren().size()) {
- String errMsg = String.format("Trying to select %dth FM radio, valid range = (1, %d)",
- i, fmList.getChildren().size() - 1);
- throw new IllegalArgumentException(errMsg);
- }
-
- UiObject2 fm = fmList.getChildren().get(i);
-
- if (!fm.clickAndWait(Until.newWindow(), UI_ACTION_TIMEOUT)) {
- throw new UnknownUiException("Fail to load into fm profile page");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startChannel() {
- if (isOnFeedbackScreen()) {
- dismissFeedbackScreen();
- }
-
- UiObject2 start = mDevice
- .findObject(By.res(UI_PACKAGE_NAME, UI_START_PLAY_ID));
-
- if (start == null) {
- throw new UnknownUiException("Cannot find start play button");
- }
-
- if (!start.clickAndWait(Until.newWindow(), UI_ACTION_TIMEOUT)) {
- throw new UnknownUiException("Fail to start playing the fm");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void stopChannel() {
- UiObject2 stop = mDevice
- .findObject(By.res(UI_PACKAGE_NAME, UI_MINI_PLAYER_STOP_ID));
-
- if (stop == null) {
- throw new UnknownUiException("Could not find stop button");
- }
-
- stop.click();
-
- if (isOnFeedbackScreen()) {
- dismissFeedbackScreen();
- }
- }
-
- private boolean isOnFeedbackScreen() {
- return mDevice.wait(
- Until.hasObject(By.text("Do you love TuneIn Radio?")), UI_ACTION_TIMEOUT);
- }
-
- private void dismissFeedbackScreen() {
- UiObject2 button = mDevice.findObject(By.text("MAYBE LATER"));
-
- if (button != null) {
- button.click();
- }
- }
-
-}
diff --git a/tests/androidbvt/Android.mk b/tests/androidbvt/Android.mk
deleted file mode 100644
index 7db475c33..000000000
--- a/tests/androidbvt/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2016 Google Inc. All Rights Reserved.
-#
-# 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_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := system_current
-media_framework_app_base := frameworks/base/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test \
- first-party-app-helpers \
- launcher-helper-lib \
- settings-app-helper \
- platform-test-annotations \
- ub-uiautomator
-
-LOCAL_PACKAGE_NAME := AndroidBvtTests
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
-
-include \
- $(LOCAL_PATH)/apps/Android.mk \
- $(LOCAL_PATH)/hermetic/Android.mk \
- $(LOCAL_PATH)/sim/Android.mk \
diff --git a/tests/androidbvt/AndroidManifest.xml b/tests/androidbvt/AndroidManifest.xml
deleted file mode 100644
index cdcee1f6c..000000000
--- a/tests/androidbvt/AndroidManifest.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 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.androidbvt">
- <uses-sdk android:minSdkVersion="19"
- android:targetSdkVersion="24" />
- <uses-feature android:name="android.hardware.camera"
- android:required="true" />
-
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.BLUETOOTH" />
- <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
- <uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
- <uses-permission android:name="android.permission.CALL_PHONE" />
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.CREATE_USERS" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
- <uses-permission android:name="android.permission.GET_DETAILED_TASKS" />
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.SEND_SMS" />
- <uses-permission android:name="android.permission.SET_WALLPAPER" />
- <uses-permission android:name="android.permission.TETHER_PRIVILEGED" />
- <uses-permission android:name="android.permission.WAKE_LOCK" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- <activity android:label="MediaPlaybackTest"
- android:name=".app.MediaPlaybackTestApp"
- android:screenOrientation="landscape">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <receiver android:name="com.android.androidbvt.PackageAddedBroadcastReceiver" >
- <intent-filter android:priority="100" >
- <action android:name="android.intent.action.PACKAGE_INSTALL" />
- <action android:name="android.intent.action.PACKAGE_ADDED" />
- <data android:scheme="package" />
- </intent-filter>
- </receiver>
- </application>
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.androidbvt"
- android:label="AndroidBVT Tests" />
-</manifest>
diff --git a/tests/androidbvt/apps/Android.mk b/tests/androidbvt/apps/Android.mk
deleted file mode 100644
index 6a2b133b5..000000000
--- a/tests/androidbvt/apps/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2016 Google Inc. All Rights Reserved.
-#
-# 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_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := \
- android-support-test \
- first-party-app-helpers \
- launcher-helper-lib \
- ub-uiautomator
-LOCAL_PACKAGE_NAME := AndroidAppsBvtTests
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/androidbvt/apps/AndroidManifest.xml b/tests/androidbvt/apps/AndroidManifest.xml
deleted file mode 100644
index af20ee922..000000000
--- a/tests/androidbvt/apps/AndroidManifest.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 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.androidbvt.apps">
- <uses-sdk android:minSdkVersion="19"
- android:targetSdkVersion="24" />
- <uses-feature android:name="android.hardware.camera"
- android:required="true" />
-
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
- <uses-permission android:name="android.permission.CALL_PHONE" />
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
- <uses-permission android:name="android.permission.GET_DETAILED_TASKS" />
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.SEND_SMS" />
- <uses-permission android:name="android.permission.SET_WALLPAPER" />
- <uses-permission android:name="android.permission.TETHER_PRIVILEGED" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
- <uses-permission android:name="android.permission.WAKE_LOCK" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.WRITE_SETTINGS" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.androidbvt.apps"
- android:label="AndroidBVT Apps Tests" />
-</manifest>
diff --git a/tests/androidbvt/apps/src/com/android/androidbvt/apps/GmailTest.java b/tests/androidbvt/apps/src/com/android/androidbvt/apps/GmailTest.java
deleted file mode 100644
index ea7be56da..000000000
--- a/tests/androidbvt/apps/src/com/android/androidbvt/apps/GmailTest.java
+++ /dev/null
@@ -1,76 +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.androidbvt.apps;
-
-import android.app.Instrumentation;
-import android.os.SystemClock;
-import android.platform.test.helpers.GmailHelperImpl;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import junit.framework.TestCase;
-
-public class GmailTest extends TestCase {
-
- // TODO: move to Gmail app helper
- private static final long LOAD_WAIT = 60000;
- private static final String SEARCH_BAR = "search_actionbar_query_text";
- private static final String SEARCH_ICON = "Search";
- private static final String TEST_MAIL_TEXT = "test";
- private static final long TIMEOUT = 6000;
- private static final String UI_CONVERSATIONS_LIST_ID = "conversation_list_view";
- private static final String UI_CONVERSATIONS_LOADING = "conversation_list_loading_view";
-
- private GmailHelperImpl mHelper;
- private Instrumentation mInstrumentation;
- private UiDevice mDevice;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mInstrumentation = InstrumentationRegistry.getInstrumentation();
- mHelper = new GmailHelperImpl(mInstrumentation);
- mHelper.open();
- mHelper.dismissInitialDialogs();
- mDevice = UiDevice.getInstance(mInstrumentation);
- mDevice.freezeRotation();
- }
-
- @Override
- public void tearDown() throws Exception {
- mHelper.exit();
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- public void testMailVisible() {
- mHelper.goToInbox();
- assertTrue(mHelper.getVisibleEmailCount() > 0);
- }
-
- public void testContainsTestMail() {
- mDevice.wait(Until.findObject(By.desc(SEARCH_ICON)), TIMEOUT).click();
- mDevice.wait(Until.findObject(By.res(mHelper.getPackage(), SEARCH_BAR)), TIMEOUT)
- .setText(TEST_MAIL_TEXT);
- mDevice.pressEnter();
- mDevice.wait(Until.gone(By.res(mHelper.getPackage(), UI_CONVERSATIONS_LOADING)), LOAD_WAIT);
- assertTrue(mDevice.findObject(
- By.res(mHelper.getPackage(), UI_CONVERSATIONS_LIST_ID)).getChildCount() > 0);
- }
-}
-
diff --git a/tests/androidbvt/apps/src/com/android/androidbvt/apps/MediaCaptureTests.java b/tests/androidbvt/apps/src/com/android/androidbvt/apps/MediaCaptureTests.java
deleted file mode 100644
index 1e5713db2..000000000
--- a/tests/androidbvt/apps/src/com/android/androidbvt/apps/MediaCaptureTests.java
+++ /dev/null
@@ -1,132 +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.androidbvt.apps;
-
-import android.content.Context;
-import android.platform.test.helpers.GoogleCameraHelperImpl;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import java.io.File;
-import java.util.regex.Pattern;
-import junit.framework.TestCase;
-
-/**
- * Basic tests for the Camera app.
- */
-public class MediaCaptureTests extends TestCase {
- private static final int CAPTURE_TIMEOUT = 6000;
- private static final String DESC_BTN_DONE = "Done";
- private static final int FILE_CHECK_ATTEMPTS = 5;
- private static final long VIDEO_LENGTH = 2000;
- private static final String CAMERA_DIRECTORY = "/sdcard/DCIM/Camera";
- private Context mContext;
- private UiDevice mDevice;
- private GoogleCameraHelperImpl mCameraHelper;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.freezeRotation();
- mContext = InstrumentationRegistry.getTargetContext();
- mCameraHelper = new GoogleCameraHelperImpl(InstrumentationRegistry.getInstrumentation());
- mCameraHelper.open();
- // if there are any dialogues that pop up, dismiss them
- mCameraHelper.dismissInitialDialogs();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.pressHome();
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- /**
- * Test that the device can capture a photo.
- */
- @LargeTest
- public void testPhotoCapture() throws InterruptedException {
- int beforeCount = getValidFileCountFromFilesystem();
- mCameraHelper.goToCameraMode();
- // Capture photo using front camera
- mCameraHelper.goToFrontCamera();
- mCameraHelper.capturePhoto();
- Thread.sleep(CAPTURE_TIMEOUT);
- int afterCount = getValidFileCountFromFilesystem();
- assertTrue("Camera didnt capture picture using front camera", afterCount > beforeCount);
- // Capture photo using back camera
- beforeCount = getValidFileCountFromFilesystem();
- mCameraHelper.goToBackCamera();
- mCameraHelper.capturePhoto();
- Thread.sleep(CAPTURE_TIMEOUT);
- afterCount = getValidFileCountFromFilesystem();
- assertTrue("Camera didnt capture picture using back camera", afterCount > beforeCount);
- }
-
- /**
- * Test that the device can capture a video.
- */
- @LargeTest
- public void testVideoCapture() throws InterruptedException {
- int beforeCount = getValidFileCountFromFilesystem();
- mCameraHelper.goToVideoMode();
- Thread.sleep(CAPTURE_TIMEOUT);
- // Capture video using front camera
- mCameraHelper.goToFrontCamera();
- mCameraHelper.captureVideo(VIDEO_LENGTH);
- pushButton(DESC_BTN_DONE);
- Thread.sleep(CAPTURE_TIMEOUT);
- int afterCount = getValidFileCountFromFilesystem();
- assertTrue("Camera didnt capture video", afterCount > beforeCount);
- // Capture video using back camera
- beforeCount = getValidFileCountFromFilesystem();
- mCameraHelper.goToBackCamera();
- mCameraHelper.captureVideo(VIDEO_LENGTH);
- pushButton(DESC_BTN_DONE);
- Thread.sleep(CAPTURE_TIMEOUT);
- afterCount = getValidFileCountFromFilesystem();
- assertTrue("Camera didnt capture video", afterCount > beforeCount);
- }
-
- private void pushButton(String desc) {
- Pattern pattern = Pattern.compile(desc, Pattern.CASE_INSENSITIVE);
- UiObject2 doneBtn = mDevice.wait(Until.findObject(By.desc(pattern)), CAPTURE_TIMEOUT);
- if (null != doneBtn) {
- doneBtn.clickAndWait(Until.newWindow(), 500);
- }
- }
-
- private int getValidFileCountFromFilesystem() {
- int count = 0;
- File file = new File(CAMERA_DIRECTORY);
- for (File child : file.listFiles()) {
- if (validateSavedFile(child)) {
- count++;
- }
- }
- return count;
- }
-
- private boolean validateSavedFile(File file) {
- return (file.exists() && file.length() > 0);
- }
-}
diff --git a/tests/androidbvt/hermetic/Android.mk b/tests/androidbvt/hermetic/Android.mk
deleted file mode 100644
index d63e3103a..000000000
--- a/tests/androidbvt/hermetic/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2016 Google Inc. All Rights Reserved.
-#
-# 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_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := system_current
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator launcher-helper-lib
-
-LOCAL_PACKAGE_NAME := HermeticAndroidBvtTests
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/androidbvt/hermetic/AndroidManifest.xml b/tests/androidbvt/hermetic/AndroidManifest.xml
deleted file mode 100644
index 51d90ca5d..000000000
--- a/tests/androidbvt/hermetic/AndroidManifest.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 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.androidbvt.hermetic">
- <uses-sdk android:minSdkVersion="19"
- android:targetSdkVersion="24" />
- <uses-feature android:name="android.hardware.camera"
- android:required="true" />
-
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
- <uses-permission android:name="android.permission.GET_DETAILED_TASKS" />
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.SET_WALLPAPER" />
- <uses-permission android:name="android.permission.TETHER_PRIVILEGED" />
- <uses-permission android:name="android.permission.WAKE_LOCK" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.WRITE_SETTINGS" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.androidbvt.hermetic"
- android:label="AndroidBVT Tests" />
-</manifest>
diff --git a/tests/androidbvt/res/drawable-xhdpi/stat_notify_email.png b/tests/androidbvt/res/drawable-xhdpi/stat_notify_email.png
deleted file mode 100644
index 23c4672e8..000000000
--- a/tests/androidbvt/res/drawable-xhdpi/stat_notify_email.png
+++ /dev/null
Binary files differ
diff --git a/tests/androidbvt/res/layout/surface_view.xml b/tests/androidbvt/res/layout/surface_view.xml
deleted file mode 100644
index 4999e5d44..000000000
--- a/tests/androidbvt/res/layout/surface_view.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <SurfaceView
- android:id="@+id/surface_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_centerInParent="true"
- />
-
- <ImageView android:id="@+id/overlay_layer"
- android:layout_width="0dip"
- android:layout_height="392dip"/>
-
- <VideoView
- android:id="@+id/video_view"
- android:layout_width="320px"
- android:layout_height="240px"
- />
-
- </FrameLayout>
-
-</LinearLayout>
-
diff --git a/tests/androidbvt/res/raw/bbb.mkv b/tests/androidbvt/res/raw/bbb.mkv
deleted file mode 100644
index e286e01ab..000000000
--- a/tests/androidbvt/res/raw/bbb.mkv
+++ /dev/null
Binary files differ
diff --git a/tests/androidbvt/sim/Android.mk b/tests/androidbvt/sim/Android.mk
deleted file mode 100644
index f055f01cc..000000000
--- a/tests/androidbvt/sim/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2016 Google Inc. All Rights Reserved.
-#
-# 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_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := system_current
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_SRC_FILES += ../src/com/android/androidbvt/AndroidBvtHelper.java
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test \
- first-party-app-helpers \
- launcher-helper-lib \
- settings-app-helper \
- platform-test-annotations \
- ub-uiautomator
-
-LOCAL_PACKAGE_NAME := AndroidBvtSimTests
-LOCAL_CERTIFICATE := platform
-include $(BUILD_PACKAGE)
diff --git a/tests/androidbvt/sim/AndroidManifest.xml b/tests/androidbvt/sim/AndroidManifest.xml
deleted file mode 100644
index b16e6e6e1..000000000
--- a/tests/androidbvt/sim/AndroidManifest.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 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.androidbvt.sim">
- <uses-sdk android:minSdkVersion="19"
- android:targetSdkVersion="24" />
-
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.CALL_PHONE" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.androidbvt.sim"
- android:label="AndroidBVT Sim Tests" />
-</manifest> \ No newline at end of file
diff --git a/tests/androidbvt/sim/src/com/android/androidbvt/sim/ConnectivityWithSimTests.java b/tests/androidbvt/sim/src/com/android/androidbvt/sim/ConnectivityWithSimTests.java
deleted file mode 100644
index 4484d623e..000000000
--- a/tests/androidbvt/sim/src/com/android/androidbvt/sim/ConnectivityWithSimTests.java
+++ /dev/null
@@ -1,210 +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.androidbvt.sim;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.telecom.TelecomManager;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.view.KeyEvent;
-import com.android.androidbvt.AndroidBvtHelper;
-import junit.framework.TestCase;
-
-public class ConnectivityWithSimTests extends TestCase {
- private UiDevice mDevice;
- private Context mContext = null;
- private AndroidBvtHelper mABvtHelper = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.setOrientationNatural();
- mContext = InstrumentationRegistry.getTargetContext();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- if (!mABvtHelper.hasDeviceSim()) {
- fail("Device has no sim");
- }
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.wakeUp();
- mDevice.unfreezeRotation();
- mDevice.pressHome();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * check wifi calling option is displayed and by default off
- */
- @MediumTest
- public void testWifiCallingNotDefaultEnabled() throws InterruptedException {
- mABvtHelper.launchIntent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
- assertNotNull("Wifi Calling status should be off by default",
- getWifiStatusObjectByStatus("Off"));
- }
-
- /**
- * tests while wifi is off, device can connect to data using mobile data service
- * @throws InterruptedException
- */
- @LargeTest
- public void testMobileDataOnlyConnection() throws InterruptedException {
- int counter;
- int netId = -1;
- try {
- // disconnect wifi if it is connected and save the netid to re-connect in future
- if (mABvtHelper.hasWifiData()) {
- netId = mABvtHelper.disconnectWifi();
- }
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // ensure device has mobile data service
- assertTrue(mABvtHelper.hasMobileData());
- // verify device is connected to web
- counter = 5;
- while (--counter > 0 && !mABvtHelper.isConnected()) {
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
- assertTrue("Device has no data connection over mobile data", counter != 0);
- } finally {
- // finally re-connect wifi
- if (netId != -1) {
- mABvtHelper.getWifiManager().enableNetwork(netId, true);
- counter = 5;
- while (--counter > 0 && !mABvtHelper.isConnected()) {
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
- }
- }
- }
-
- /**
- * Ensures device can't connect to any data while device is put on Airplane mode
- * @throws InterruptedException
- */
- @LargeTest
- public void testNoDataConnectionWithAirPlaneModeOn() throws InterruptedException {
- assertTrue("Device should be connected via either wifi or mobile data",
- mABvtHelper.isConnected());
- try {
- toggleAirplaneSettingsViaUI("Off");
- int counter = 5;
- while (--counter > 0 && mABvtHelper.isConnected()) {
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
- assertTrue("Device is still connected to data", counter != 0);
- } finally {
- toggleAirplaneSettingsViaUI("On");
- int counter = 5;
- while (--counter > 0 && !mABvtHelper.isConnected()) {
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
- assertTrue("Device is not connected to data yet", counter != 0);
- }
- }
-
- /**
- * Ensure wifi calling has wifi preferred mode
- * @throws InterruptedException
- */
- @LargeTest
- public void testWifiCallingHasPreferredMode() throws InterruptedException {
- assertTrue("Wifi isn't enabled", mABvtHelper.getWifiManager().isWifiEnabled());
- try {
- turnWiFiCallSettingOnViaUI(true);
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- assertTrue("Wifi calling doesn't have wifi preferred mode", mDevice.wait(
- Until.hasObject(By.text("Wi-Fi preferred")), mABvtHelper.LONG_TIMEOUT));
- } finally {
- turnWiFiCallSettingOnViaUI(false);
- mDevice.pressHome();
- }
- }
-
- /**
- * Make a call when wifi calling is setup
- * @throws InterruptedException
- */
- @LargeTest
- public void testWifiOutgoingCall() throws InterruptedException {
- assertTrue("Wifi isn't enabled", mABvtHelper.getWifiManager().isWifiEnabled());
- try {
- turnWiFiCallSettingOnViaUI(true);
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- // Make a call
- Uri uri = Uri.fromParts("tel", "2468", null);
- Bundle extras = new Bundle();
- TelecomManager telecomManager = (TelecomManager) mContext
- .getSystemService(Context.TELECOM_SERVICE);
- mABvtHelper.getTelecomManager().placeCall(uri, extras);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- if (mABvtHelper.getTelecomManager().isInCall()) {
- mDevice.pressKeyCode(KeyEvent.KEYCODE_ENDCALL);
- } else {
- fail("Phone call wasn't successful");
- }
- } finally {
- turnWiFiCallSettingOnViaUI(false);
- mDevice.pressHome();
- }
- }
-
- private UiObject2 getWifiCallingObject() {
- return mDevice.wait(Until.findObject(By.text("Wi-Fi calling")), mABvtHelper.LONG_TIMEOUT);
- }
-
- private UiObject2 getWifiStatusObjectByStatus(String status) {
- return mDevice.wait(Until.findObject(By.res("android:id/summary").text(status)),
- mABvtHelper.LONG_TIMEOUT);
- }
-
- private void toggleAirplaneSettingsViaUI(String expected) throws InterruptedException {
- mDevice.openQuickSettings();
- UiObject2 airplaneObject = mDevice.wait(Until.findObject(By.desc("Airplane mode")),
- mABvtHelper.LONG_TIMEOUT);
- assertTrue("Airplane mode isn't set to expected val",
- airplaneObject.getText().equalsIgnoreCase(expected));
- airplaneObject.click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- mDevice.pressHome();
- }
-
- private void turnWiFiCallSettingOnViaUI(boolean turnOn) throws InterruptedException {
- String stateNow = (turnOn ? "Off" : "On");
- String stateToBe = (turnOn ? "On" : "Off");
- Intent intent = new Intent(
- android.provider.Settings.ACTION_WIRELESS_SETTINGS);
- mContext.startActivity(intent);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- getWifiCallingObject().clickAndWait(Until.newWindow(), mABvtHelper.SHORT_TIMEOUT);
- mDevice.wait(
- Until.findObject(By.res("com.android.settings:id/switch_text")),
- mABvtHelper.LONG_TIMEOUT).click();
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/AndroidBvtHelper.java b/tests/androidbvt/src/com/android/androidbvt/AndroidBvtHelper.java
deleted file mode 100644
index 300fabd90..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/AndroidBvtHelper.java
+++ /dev/null
@@ -1,505 +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.androidbvt;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.app.DownloadManager;
-import android.app.UiAutomation;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.wifi.WifiManager;
-import android.os.ParcelFileDescriptor;
-import android.os.RemoteException;
-import android.os.UserManager;
-import android.provider.Settings;
-import android.support.test.launcherhelper.ILauncherStrategy;
-import android.support.test.launcherhelper.LauncherStrategyFactory;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.telecom.TelecomManager;
-import android.telephony.TelephonyManager;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.WindowManager;
-import android.view.inputmethod.InputMethodManager;
-import junit.framework.Assert;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import junit.framework.Assert;
-
-/**
- * Defines constants & implements common methods to be used by Framework, SysUI, System e2e BVT
- * tests. Also ensures single instance of this object
- */
-public class AndroidBvtHelper {
- public static final String CALCULATOR_PACKAGE = "com.google.android.calculator";
- public static final String CALCULATOR_ACTIVITY = "com.android.calculator2.Calculator";
- public static final String CAMERA_PACKAGE = "com.google.android.GoogleCamera";
- public static final String CAMERA2_PACKAGE = "com.android.camera2";
- public static final String DESKCLOCK_PACKAGE = "com.google.android.deskclock";
- public static final String GOOGLE_KB_PACKAGE = "com.google.android.inputmethod.latin";
- public static final String GOOGLE_KB_SVC = "com.android.inputmethod.latin.LatinIME";
- public static final String SETTINGS_PACKAGE = "com.android.settings";
- public static final String SYSTEMUI_PACKAGE = "com.android.systemui";
-
- public static final int FULLSCREEN = 1;
- public static final int SPLITSCREEN = 3;
-
- private final static String DEFAULT_PING_SITE = "www.google.com";
-
- public static final String TEST_TAG = "AndroidBVT";
- public static final int SHORT_TIMEOUT = 1000;
- public static final int LONG_TIMEOUT = 5000;
- public static final String MARLIN = "marlin";
- public static final String SAILFISH = "sailfish";
- // 600dp is the threshold value for 7-inch tablets.
- private static final int TABLET_DP_THRESHOLD = 600;
- private static AndroidBvtHelper sInstance = null;
- private Context mContext = null;
- private UiDevice mDevice = null;
- private UiAutomation mUiAutomation = null;
- private ContentResolver mResolver = null;
-
- public AndroidBvtHelper(UiDevice device, Context context, UiAutomation uiAutomation) {
- mContext = context;
- mDevice = device;
- mUiAutomation = uiAutomation;
- mResolver = mContext.getContentResolver();
- }
-
- public static AndroidBvtHelper getInstance(UiDevice device, Context context,
- UiAutomation uiAutomation) {
- if (sInstance == null) {
- sInstance = new AndroidBvtHelper(device, context, uiAutomation);
- }
- return sInstance;
- }
-
- public TelecomManager getTelecomManager() {
- return (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
- }
-
- public WifiManager getWifiManager() {
- return (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
- }
-
- public ConnectivityManager getConnectivityManager() {
- return (ConnectivityManager) (ConnectivityManager) mContext
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- }
-
- public DownloadManager getDownloadManager() {
- return (DownloadManager) (DownloadManager) mContext
- .getSystemService(Context.DOWNLOAD_SERVICE);
- }
-
- public UserManager getUserManager() {
- return (UserManager) (UserManager) mContext
- .getSystemService(Context.USER_SERVICE);
- }
-
- public InputMethodManager getInputMethodManager() {
- return (InputMethodManager) mContext
- .getSystemService(mContext.INPUT_METHOD_SERVICE);
- }
-
- /**
- * Only executes 'adb shell' commands that run in the same process as the runner. Converts
- * output of the command from ParcelFileDescriptior to user friendly list of strings
- * https://developer.android.com/reference/android/app/UiAutomation.html#executeShellCommand(
- * java.lang.String)
- */
- public List<String> executeShellCommand(String cmd) {
- if (cmd == null || cmd.isEmpty()) {
- return null;
- }
- List<String> output = new ArrayList<String>();
- ParcelFileDescriptor pfd = mUiAutomation.executeShellCommand(cmd);
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(new FileInputStream(pfd.getFileDescriptor())))) {
- String line;
- while ((line = reader.readLine()) != null) {
- output.add(line);
- Log.i(TEST_TAG, line);
- }
- } catch (IOException e) {
- Log.e(TEST_TAG, e.getMessage());
- return null;
- }
- return output;
- }
-
- /** Returns true if the device is a tablet */
- public boolean isTablet() {
- // Get screen density & screen size from window manager
- WindowManager wm = (WindowManager) mContext.getSystemService(
- Context.WINDOW_SERVICE);
- DisplayMetrics metrics = new DisplayMetrics();
- wm.getDefaultDisplay().getMetrics(metrics);
- // Determines the smallest screen width DP which is
- // calculated as ( pixels * density-independent pixel unit ) / density.
- // http://developer.android.com/guide/practices/screens_support.html.
- int screenDensity = metrics.densityDpi;
- int screenWidth = Math.min(
- metrics.widthPixels, metrics.heightPixels);
- int screenHeight = Math.max(
- metrics.widthPixels, metrics.heightPixels);
- int smallestScreenWidthDp = (Math.min(screenWidth, screenHeight)
- * DisplayMetrics.DENSITY_DEFAULT) / screenDensity;
- return smallestScreenWidthDp >= TABLET_DP_THRESHOLD;
- }
-
- public boolean isNexusExperienceDevice() {
- String result = mDevice.getProductName();
- if (result.indexOf(MARLIN) >= 0 || result.indexOf(SAILFISH) >= 0) {
- return true;
- }
- return false;
- }
-
- public void launchIntent(String intentName) throws InterruptedException {
- mDevice.pressHome();
- Intent intent = new Intent(intentName);
- launchIntent(intent);
- }
-
- public void launchIntent(Intent intent) throws InterruptedException {
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(intent);
- Thread.sleep(LONG_TIMEOUT * 2);
- }
-
- public void launchPackage(String pkgName) throws InterruptedException {
- Intent pkgIntent = mContext.getPackageManager()
- .getLaunchIntentForPackage(pkgName);
- launchIntent(pkgIntent);
- }
-
- public void launchApp(String packageName, String appName) {
- ILauncherStrategy mLauncherStrategy = LauncherStrategyFactory.getInstance(mDevice)
- .getLauncherStrategy();
- if (!mDevice.hasObject(By.pkg(packageName).depth(0))) {
- mLauncherStrategy.launch(appName, packageName);
- }
- }
-
- public void removeDir(String dir) {
- String cmd = " rm -rf " + dir;
- executeShellCommand(cmd);
- }
-
- public String getStringSetting(SettingType type, String sName) {
- switch (type) {
- case SYSTEM:
- return Settings.System.getString(mResolver, sName);
- case GLOBAL:
- return Settings.Global.getString(mResolver, sName);
- case SECURE:
- return Settings.Secure.getString(mResolver, sName);
- }
- return null;
- }
-
- public void launchQuickSettingsAndWait()throws Exception {
- mDevice.openQuickSettings();
- Thread.sleep(SHORT_TIMEOUT);
- }
-
- /**
- * Clears apps in overview/recents
- * @throws InterruptedException
- * @throws RemoteException
- */
- public void clearRecents() throws InterruptedException, RemoteException {
- // Launch recents if it's not already
- if (!mDevice.wait(Until.hasObject(By.res(SYSTEMUI_PACKAGE, "recents_view")),
- LONG_TIMEOUT)) {
- mDevice.pressRecentApps();
- }
- // Return if there is no apps in recents
- if (mDevice.wait(Until.hasObject(By.text("No recent items")),
- LONG_TIMEOUT)) {
- return;
- }
- // Get recents items
- int recents = mDevice
- .wait(Until.findObjects(By.res(SYSTEMUI_PACKAGE, "task_view_thumbnail")),
- LONG_TIMEOUT)
- .size();
- // Clear recents
- for (int i = 0; i < recents; ++i) {
- mDevice.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH);
- mDevice.pressKeyCode(KeyEvent.KEYCODE_DEL);
- Thread.sleep(SHORT_TIMEOUT);
- }
- }
-
- /**
- * Multiuser helper methods
- */
- /**
- * Creates a test user
- * @return id for created secondary user
- */
- public int createSecondaryUser(String userName) {
- // Create user
- List<String> cmdOut = executeShellCommand("pm create-user " + userName);
- Assert.assertTrue("Output should have 1 line",
- cmdOut.size() == 1 && cmdOut.get(0).startsWith("Success"));
- // Find user id from user-create output
- // output format : "Success: created user id 10"
- Pattern pattern = Pattern.compile(
- "(.*)(:)(.*?)(\\d+)");
- Matcher matcher = pattern.matcher(cmdOut.get(0));
- if (matcher.find()) {
- Log.i(TEST_TAG, String.format("User Name:%s UserId:%d",
- matcher.group(1), Integer.parseInt(matcher.group(4))));
- return Integer.parseInt(matcher.group(4));
- }
- return -1;
- }
-
- /**
- * Returns id for first secondary user
- * @return userid
- */
- public int getSecondaryUserId() {
- List<String> cmdOut = executeShellCommand("pm list users");
- Pattern pattern = Pattern.compile(
- "(.*\\{)(\\d+)(:)(.*?)(:)(\\d+)(\\}.*)"); // 2 = id 6 = flag
- Matcher matcher = pattern.matcher(cmdOut.get(2));
- if (matcher.find()) {
- return Integer.parseInt(matcher.group(2));
- }
- return -1;
- }
-
- public void removeSecondaryUser(int userId) {
- int prevUserCount = getUserCount();
- List<String> cmdOut = executeShellCommand("pm remove-user " + userId);
- Assert.assertTrue("User hasn't been removed", getUserCount() == (prevUserCount - 1));
- }
-
- public int getUserCount() {
- return getUserManager().getUserCount();
- }
-
- /**
- * Multiwindow helper methods
- */
- /**
- * Returns a taskId for a given package and activity
- * @param pkgName
- * @param activityName
- * @return taskId
- */
- public int getTaskIdForActivity(String pkgName, String activityName) {
- int taskId = -1;
- // Find task id for given package and activity
- List<String> cmdOut = executeShellCommand("am stack list");
- for (String line : cmdOut) {
- Pattern pattern = Pattern.compile(String.format(".*taskId=([0-9]+): %s/%s.*",
- pkgName, activityName));
- Matcher matcher = pattern.matcher(line);
- if (matcher.find()) {
- taskId = Integer.parseInt(matcher.group(1));
- break;
- }
- }
- Assert.assertTrue("Taskid hasn't been found", taskId != -1);
- return taskId;
- }
-
- /**
- * Helper to change window mode between fullscreen and splitscreen for a given task
- * @param taskId
- * @param mode
- * @throws InterruptedException
- */
- public void changeWindowMode(int taskId, int mode) throws InterruptedException {
- mUiAutomation.executeShellCommand(
- String.format("am stack movetask %d %d true", taskId, mode));
- Thread.sleep(SHORT_TIMEOUT * 2);
- }
-
- /**
- * Backup restore helper methods
- */
- /*
- * Enables backup manager
- */
- public void enableBmgr(boolean enable) {
- List<String> output = executeShellCommand("bmgr enable " + Boolean.toString(enable));
- if (enable) {
- Assert.assertTrue("Bmgr not enabled",
- output.get(0).equalsIgnoreCase("Backup Manager now enabled"));
- } else {
- Assert.assertTrue("Bmgr not disabled",
- output.get(0).equalsIgnoreCase("Backup Manager now disabled"));
- }
- }
-
- /**
- * Checks whether a google account has been enabled in device for backup
- * @return true/false
- * @throws InterruptedException
- */
- public boolean hasDeviceBackupAccount() throws InterruptedException {
- launchIntent(android.provider.Settings.ACTION_PRIVACY_SETTINGS);
- UiObject2 deviceBackup = mDevice.wait(Until.findObject(By.text("Device backup")),
- LONG_TIMEOUT);
- String backupAcct = deviceBackup.getParent().getChildren().get(1).getText();
- if (backupAcct.equals(getRegisteredGoogleAccountOnDevice())) {
- return true;
- } else if (backupAcct.startsWith("No Account")) {
- return false;
- }
- return false;
- }
-
- /**
- * Get registered accounts ensures there is at least one account registered returns the google
- * account name
- * @return The registered gogole/gmail account on device
- */
- public String getRegisteredGoogleAccountOnDevice() {
- Account[] accounts = AccountManager.get(mContext).getAccounts();
- Assert.assertTrue("Device doesn't have any account registered", accounts.length >= 1);
- for (int i = 0; i < accounts.length; ++i) {
- if (accounts[i].type.equals("com.google")) {
- return accounts[i].name;
- }
- }
- throw new RuntimeException("The device is not registered with a google account");
- }
-
- /**
- * Settings helper methods for ABVT
- */
- public void setSettingStringValue(SettingType settingType, String settingName, String val)
- throws InterruptedException {
- switch (settingType) {
- case SYSTEM:
- Settings.System.putString(mContext.getContentResolver(), settingName, val);
- case GLOBAL:
- Settings.Global.putString(mContext.getContentResolver(), settingName, val);
- case SECURE:
- Settings.Secure.putString(mContext.getContentResolver(), settingName, val);
- }
- Thread.sleep(LONG_TIMEOUT);
- }
-
- /**
- * There are 3 setting types in Android as below
- */
- public static enum SettingType {
- SYSTEM, SECURE, GLOBAL
- }
-
- /**
- * Wifi helper methods
- */
- /**
- * Checks if device connection is active either through wifi or mobile data by sending an HTTP
- * request, check for HTTP_OK
- */
- public boolean isConnected() throws InterruptedException {
- int counter = 10;
- while (--counter > 0) {
- try {
- String mPingSite = String.format("http://%s", DEFAULT_PING_SITE);
- URL url = new URL(mPingSite);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("GET");
- conn.setConnectTimeout(LONG_TIMEOUT * 12);
- conn.setReadTimeout(LONG_TIMEOUT * 12);
- if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
- return true;
- }
- Thread.sleep(SHORT_TIMEOUT);
- } catch (IOException ex) {
- // Wifi being flaky in the lab, test retries 10 times to connect to google.com
- // as IOException is throws connection isn't made and response stream is null
- // so for retrying purpose, exception hasn't been rethrown
- Log.i(TEST_TAG, ex.getMessage());
- }
- }
- return false;
- }
-
- /**
- * Disconnects and disables network
- */
- public int disconnectWifi() {
- Assert.assertTrue("Wifi not disconnected", getWifiManager().disconnect());
- int netId = getWifiManager().getConnectionInfo().getNetworkId();
- getWifiManager().disableNetwork(netId);
- getWifiManager().saveConfiguration();
- return netId;
- }
-
- /**
- * Ensures wifi is enabled in device
- * @throws InterruptedException
- */
- public void ensureWifiEnabled() throws InterruptedException {
- // Device already connected to wifi as part of tradefed setup
- if (!getWifiManager().isWifiEnabled()) {
- getWifiManager().enableNetwork(getWifiManager().getConnectionInfo().getNetworkId(),
- true);
- int counter = 5;
- while (--counter > 0 && !getWifiManager().isWifiEnabled()) {
- Thread.sleep(LONG_TIMEOUT);
- }
- }
- Assert.assertTrue("Wifi should be enabled by now", getWifiManager().isWifiEnabled());
- }
-
- public boolean hasWifiData() {
- NetworkInfo netInfo = getConnectivityManager().getActiveNetworkInfo();
- Assert.assertNotNull(netInfo);
- return (netInfo.getType() == ConnectivityManager.TYPE_WIFI);
- }
-
- public boolean hasMobileData() {
- NetworkInfo netInfo = getConnectivityManager().getActiveNetworkInfo();
- Assert.assertNotNull(netInfo);
- return (netInfo.getType() == ConnectivityManager.TYPE_MOBILE);
- }
-
- public boolean hasDeviceSim() {
- TelephonyManager telMgr = (TelephonyManager) mContext
- .getSystemService(mContext.TELEPHONY_SERVICE);
- return (telMgr.getSimState() == TelephonyManager.SIM_STATE_READY);
- }
-} \ No newline at end of file
diff --git a/tests/androidbvt/src/com/android/androidbvt/ConnectivityWifiTests.java b/tests/androidbvt/src/com/android/androidbvt/ConnectivityWifiTests.java
deleted file mode 100644
index 30df45be2..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/ConnectivityWifiTests.java
+++ /dev/null
@@ -1,166 +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.androidbvt;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiConfiguration.AuthAlgorithm;
-import android.net.wifi.WifiConfiguration.KeyMgmt;
-import android.net.wifi.WifiManager;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.Suppress;
-import android.util.Log;
-import junit.framework.TestCase;
-
-public class ConnectivityWifiTests extends TestCase {
- private final String NETWORK_ID = "AndroidAP";
- private final String PASSWD = "androidwifi";
- private UiDevice mDevice;
- private WifiManager mWifiManager = null;
- private Context mContext = null;
- private AndroidBvtHelper mABvtHelper = null;
- private WifiConfiguration mOriginalConfig = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.setOrientationNatural();
- mContext = InstrumentationRegistry.getTargetContext();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- mWifiManager = mABvtHelper.getWifiManager();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.wakeUp();
- mDevice.unfreezeRotation();
- mDevice.pressHome();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * Test verifies wifi can be disconnected, disabled followed by enable and reconnect. As part of
- * connection check, it pings a site and ensures HTTP_OK return
- */
- @LargeTest
- public void testWifiConnection() throws InterruptedException {
- // Wifi is already connected as part of tradefed device setup, assert that
- assertTrue("Wifi should be connected", mABvtHelper.isConnected());
- assertNotNull("Wifi manager is null", mWifiManager);
- assertTrue("Wifi isn't enabled", mWifiManager.isWifiEnabled());
- // Disconnect wifi and disable network, save NetId to be used for re-enabling network
- int netId = mWifiManager.getConnectionInfo().getNetworkId();
- mABvtHelper.disconnectWifi();
- Log.d("MyTestTag", "before sleep");
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- Log.d("MyTestTag", "after sleep");
- assertFalse("Wifi shouldn't be connected", mABvtHelper.isConnected());
- // Network enabled successfully
- assertTrue("Network isn't enabled", mWifiManager.enableNetwork(netId, true));
- // Allow time to settle down
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- assertTrue("Wifi should be connected", mABvtHelper.isConnected());
- }
-
- /**
- * Test verifies from UI that bunch of AP are listed on enabling Wifi
- */
- @LargeTest
- public void testWifiDiscoveredAPShownUI() throws InterruptedException {
- Intent intent_as = new Intent(
- android.provider.Settings.ACTION_WIFI_SETTINGS);
- mContext.startActivity(intent_as);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- assertNotNull("AP list shouldn't be null",
- mDevice.wait(Until.findObject(By.res(mABvtHelper.SETTINGS_PACKAGE, "list")),
- mABvtHelper.LONG_TIMEOUT));
- assertTrue("At least 1 AP should be visible",
- mDevice.wait(Until.findObject(By.res(mABvtHelper.SETTINGS_PACKAGE, "list")),
- mABvtHelper.LONG_TIMEOUT)
- .getChildren().size() > 0);
- }
-
- /**
- * Verifies WifiAp is by default disabled Then enable adn disable it
- */
- @LargeTest
- @Suppress
- public void testWifiTetheringDisableEnable() throws InterruptedException {
- WifiConfiguration config = new WifiConfiguration();
- config.SSID = NETWORK_ID;
- config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
- config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
- config.preSharedKey = PASSWD;
- int counter;
- try {
- // disable wifiap
- assertTrue("wifi hotspot not disabled by default",
- mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED);
- // Enable wifiap
- assertTrue("failed to disable wifi hotspot",
- mWifiManager.setWifiApEnabled(config, true));
- Log.d("MyTestTag", "Now checkign wifi ap");
- counter = 10;
- while (--counter > 0
- && mWifiManager.getWifiApState() != WifiManager.WIFI_AP_STATE_ENABLED) {
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- }
- assertTrue("wifi hotspot not enabled",
- mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED);
- // Navigate to Wireless Settings page and verify Wifi AP setting is on
- Intent intent_as = new Intent(
- android.provider.Settings.ACTION_WIRELESS_SETTINGS);
- mContext.startActivity(intent_as);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- mDevice.wait(Until.findObject(By.text("Tethering & portable hotspot")),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- assertTrue("Settings UI for Wifi AP is not ON",
- mDevice.wait(Until.hasObject(By.text("Portable hotspot AndroidAP active")),
- mABvtHelper.LONG_TIMEOUT));
-
- mDevice.wait(Until.findObject(By.text("Portable Wi‑Fi hotspot")),
- mABvtHelper.LONG_TIMEOUT).click();
- assertTrue("Wifi ap disable call fails", mWifiManager.setWifiApEnabled(config,
- false));
- counter = 5;
- while (--counter > 0
- && mWifiManager.getWifiApState() != WifiManager.WIFI_AP_STATE_DISABLED) {
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
- assertTrue("wifi hotspot not enabled",
- mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- } finally {
- assertTrue("Wifi enable call fails", mWifiManager
- .enableNetwork(mWifiManager.getConnectionInfo().getNetworkId(), false));
- counter = 10;
- while (--counter > 0 && !mWifiManager.isWifiEnabled()) {
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
- assertTrue("Wifi isn't enabled", mWifiManager.isWifiEnabled());
- }
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/FrameworkBackupRestoreTests.java b/tests/androidbvt/src/com/android/androidbvt/FrameworkBackupRestoreTests.java
deleted file mode 100644
index df7fdadc9..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/FrameworkBackupRestoreTests.java
+++ /dev/null
@@ -1,155 +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.androidbvt;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.net.wifi.WifiConfiguration;
-import android.provider.Settings;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import java.util.List;
-import junit.framework.TestCase;
-
-/**
- * Class contains tests to verify an account can be enabled as backup account 'bmgr' service backsup
- * and restore FYI: 'bmgr' svc doesn't verify what has been stored in cloud e2e, rather relies on
- * the fact if backed up contents can be restored, it works e2e
- */
-public class FrameworkBackupRestoreTests extends TestCase {
- private UiDevice mDevice;
- private Context mContext = null;
- private AndroidBvtHelper mABvtHelper = null;
- private WifiConfiguration mOriginalConfig = null;
- private ContentResolver mResolver = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.setOrientationNatural();
- mContext = InstrumentationRegistry.getTargetContext();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- mResolver = mContext.getContentResolver();
-
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.wakeUp();
- mDevice.unfreezeRotation();
- mDevice.pressHome();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * Ensure an account can be set as backup account
- * @throws InterruptedException
- */
- @LargeTest
- public void testAddBackupAccount() throws InterruptedException {
- // Enable back manager
- mABvtHelper.enableBmgr(true);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- enableAccountAsBackup();
- }
-
- /**
- * Test to ensure whether bmgr can backup and restore data. It doesn't test integration with
- * GMSCore and storing data in the cloud rather that is implied
- * 1. Enable test account as backup account
- * 2 .Make some setting changes and backup the data
- * 3. Change settings to default value
- * 4. Restore data and verify that it restores to the state 2
- * @throws InterruptedException
- */
- @LargeTest
- public void testBmgrBacksUpAndRestore() throws InterruptedException {
- // Enable back manager
- mABvtHelper.enableBmgr(true);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- enableAccountAsBackup();
- try {
- // Change Display -> Adaptive Brightness 0 - 1
- mABvtHelper.setSettingStringValue(AndroidBvtHelper.SettingType.SYSTEM,
- Settings.System.SCREEN_BRIGHTNESS_MODE, "1");
- Boolean backUpSuccess = false;
- List<String> cmdOut = mABvtHelper
- .executeShellCommand(
- String.format("bmgr backupnow %s", mABvtHelper.SETTINGS_PACKAGE));
- for (String str : cmdOut) {
- if (str.equalsIgnoreCase("Backup finished with result: Success")) {
- backUpSuccess = true;
- continue;
- }
- }
- assertTrue("bmgr failed in backup data now", backUpSuccess);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // Set Display -> Adaptive Brightness 1 - 0
- mABvtHelper.setSettingStringValue(AndroidBvtHelper.SettingType.SYSTEM,
- Settings.System.SCREEN_BRIGHTNESS_MODE, "0");
- int counter = 10;
- while (--counter > 0 && Settings.System
- .getString(mResolver, Settings.System.SCREEN_BRIGHTNESS_MODE).equals("1")) {
- mABvtHelper.executeShellCommand(
- String.format("bmgr restore %s", mABvtHelper.SETTINGS_PACKAGE));
- }
- } finally {
- // Set Display -> Adaptive Brightness 1 - 0
- mABvtHelper.setSettingStringValue(AndroidBvtHelper.SettingType.SYSTEM,
- Settings.System.SCREEN_BRIGHTNESS_MODE, "0");
- // Disable back manager
- mABvtHelper.enableBmgr(false);
- }
- }
-
- private void enableAccountAsBackup() throws InterruptedException {
- if (mABvtHelper.hasDeviceBackupAccount())
- return;
- // Get device google account
- String gAccount = mABvtHelper.getRegisteredGoogleAccountOnDevice();
- mABvtHelper.launchIntent(android.provider.Settings.ACTION_PRIVACY_SETTINGS);
- mDevice.wait(Until.hasObject(By.text("Device backup")), mABvtHelper.LONG_TIMEOUT);
- UiObject2 noAcctBackUp = mDevice.wait(
- Until.findObject(By.textStartsWith("No account")),
- mABvtHelper.LONG_TIMEOUT);
- if (noAcctBackUp != null) {
- noAcctBackUp.clickAndWait(Until.newWindow(), mABvtHelper.LONG_TIMEOUT);
- UiObject2 backUpAcct = mDevice.wait(Until.findObject(By.text("Backup account")),
- mABvtHelper.LONG_TIMEOUT);
- backUpAcct.clickAndWait(Until.newWindow(), mABvtHelper.LONG_TIMEOUT);
- backUpAcct = mDevice.wait(
- Until.findObject(By.text(gAccount)),
- mABvtHelper.LONG_TIMEOUT);
- assertNotNull("Backup account is still not set", backUpAcct);
- backUpAcct.getText().equalsIgnoreCase(gAccount);
- backUpAcct.click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- backUpAcct = mDevice.wait(
- Until.findObject(By.text(gAccount)),
- mABvtHelper.LONG_TIMEOUT);
- assertNotNull("Backup account isn't set to gmail account yet", backUpAcct);
- mDevice.pressHome();
- }
- }
-} \ No newline at end of file
diff --git a/tests/androidbvt/src/com/android/androidbvt/FrameworkDownloadTests.java b/tests/androidbvt/src/com/android/androidbvt/FrameworkDownloadTests.java
deleted file mode 100644
index 381d58e86..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/FrameworkDownloadTests.java
+++ /dev/null
@@ -1,209 +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.androidbvt;
-
-import android.app.DownloadManager;
-import android.app.DownloadManager.Query;
-import android.app.DownloadManager.Request;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.database.Cursor;
-import android.net.Uri;
-import android.net.wifi.WifiManager;
-import android.os.ParcelFileDescriptor;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import java.io.IOException;
-import java.util.HashSet;
-import junit.framework.TestCase;
-
-public class FrameworkDownloadTests extends TestCase {
- private static final String TEST_TAG = "AndroidBVT";
- private final String TEST_HOST = "209.119.80.137:10090/";
- private final String PHOTOS_PATH = "new_ui/all_content/photos";
- private final String APPS_PATH = "new_ui/all_content/apps";
- private final String TEST_FILE = "android_apps.jpeg";
- private final String APP_FILE = "Auto1kb.apk";
- private final int TEST_FILE_SIZE = 159709;
- private final int TEST_APK_SIZE = 16384;
- private DownloadManager mDownloadManager = null;
- private WifiManager mWifiManager = null;
- private AndroidBvtHelper mABvtHelper = null;
- private UiDevice mDevice;
- private Context mContext = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.freezeRotation();
- mContext = InstrumentationRegistry.getTargetContext();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- mDownloadManager = mABvtHelper.getDownloadManager();
- mWifiManager = mABvtHelper.getWifiManager();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- mDevice.pressHome();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * Following test verifies that download service is running and serves any download request
- * Enqueues a request to download a photo After download completion, compares file size that
- * mentioned in server
- */
- @LargeTest
- public void testPhotoDownloadSucceed() throws InterruptedException, IOException {
- mABvtHelper.ensureWifiEnabled();
- removeAllCurrentDownloads(); // if there are any in progress
- long downloadId = -1;
- try {
- downloadId = downloadItem(PHOTOS_PATH, TEST_FILE, TEST_FILE_SIZE);
- } finally {
- mDownloadManager.remove(downloadId);
- }
- }
-
- /**
- * Test to verify that user gets security message when it tries to install an apk downloaded
- * from unreliable source
- * @throws InterruptedException
- * @throws IOException
- */
- @LargeTest
- public void testInstallDownloadedAppFromUnreliableSource()
- throws InterruptedException, IOException {
- mABvtHelper.ensureWifiEnabled();
- removeAllCurrentDownloads(); // if there are any in progress
- long dlId = -1;
- try {
- dlId = downloadItem(APPS_PATH, APP_FILE, TEST_APK_SIZE);
- mABvtHelper.launchApp("com.android.documentsui", "Downloads");
- mDevice.wait(Until.findObject(By.text(APP_FILE)), mABvtHelper.LONG_TIMEOUT).click();
- assertTrue("Security message isn't shown on installing an apk downloaded from "
- + "unreliable source",
- mDevice.wait(Until.hasObject(By.textStartsWith("For security")),
- mABvtHelper.LONG_TIMEOUT));
- mDevice.wait(Until.findObject(By.text("CANCEL")), mABvtHelper.LONG_TIMEOUT)
- .clickAndWait(Until.newWindow(), mABvtHelper.LONG_TIMEOUT);
- } finally {
- mDownloadManager.remove(dlId);
- }
- }
-
- private long downloadItem(String path, String file, int size)
- throws InterruptedException, IOException {
- Uri downloadUri = Uri.parse(String.format("http://%s/%s/%s", TEST_HOST, path, file));
- Request request = new Request(downloadUri);
- // on enqueuing an item for download, dlMgr returns a unique id for future ref
- long dlId = mDownloadManager.enqueue(request);
-
- // Register receiver to listen to DownloadComplete Broadcase message
- // Wait for download to finish
- final DownloadCompleteReceiver receiver = new DownloadCompleteReceiver();
- try {
- IntentFilter intentFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
- mContext.registerReceiver(receiver, intentFilter);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- assertTrue("download not finished", receiver.isDownloadCompleted(dlId));
- // Verify Download file size
- ParcelFileDescriptor pfd = null;
- try {
- pfd = mDownloadManager.openDownloadedFile(dlId);
- assertTrue("File size should be same as mentioned in server",
- pfd.getStatSize() == size);
- } finally {
- if (pfd != null) {
- pfd.close();
- }
- }
- } finally {
- mContext.unregisterReceiver(receiver);
- }
- return dlId;
- }
-
- /**
- * Remove all downloads those are in progress now
- */
- private void removeAllCurrentDownloads() {
- DownloadManager downloadManager = (DownloadManager) mContext
- .getSystemService(Context.DOWNLOAD_SERVICE);
- Cursor cursor = downloadManager.query(new Query());
- try {
- if (cursor.moveToFirst()) {
- do {
- int index = cursor.getColumnIndex(DownloadManager.COLUMN_ID);
- long downloadId = cursor.getLong(index);
- downloadManager.remove(downloadId);
- } while (cursor.moveToNext());
- }
- } finally {
- cursor.close();
- }
- }
-
- /**
- * DownloadManager broadcasts 'DownloadManager.ACTION_DOWNLOAD_COMPLETE' once download is
- * complete and copied from cache to Downloads folder Following receiver to intercept download
- * intent to parse out the downloaded id to ensure that the item has been downloaded that was
- * initiated in the test. Please note that when a download action is enqueued, DownloadManager
- * provides a download id
- */
- private class DownloadCompleteReceiver extends BroadcastReceiver {
- private HashSet<Long> mCompleteIds = new HashSet<>();
-
- public DownloadCompleteReceiver() {
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- synchronized (mCompleteIds) {
- mCompleteIds.add(intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1));
- Log.i(TEST_TAG, "Request Id = "
- + intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1));
- mCompleteIds.notifyAll();
- }
- }
-
- // Tries 5 times/5 secs for download to be completed
- public boolean isDownloadCompleted(long id)
- throws InterruptedException {
- int counter = 10;
- while (--counter > 0) {
- synchronized (mCompleteIds) {
- mCompleteIds.wait(mABvtHelper.LONG_TIMEOUT);
- if (mCompleteIds.contains(id)) {
- return true;
- }
- }
- }
- return false;
- }
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/FrameworkIMETests.java b/tests/androidbvt/src/com/android/androidbvt/FrameworkIMETests.java
deleted file mode 100644
index 5d8007a90..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/FrameworkIMETests.java
+++ /dev/null
@@ -1,135 +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.androidbvt;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.view.inputmethod.InputMethodInfo;
-import java.util.List;
-import junit.framework.TestCase;
-
-/**
- * Tests to ensure IME service runs and onClick() on a EditTextView prompts GoogleKB to popup and
- * onClick() on any char commits to EditTextView. For tests, Settings search view which is a
- * EditText view has been chosen.
- */
-public class FrameworkIMETests extends TestCase {
- private final String SEARCH_RES_ID = "android:id/search_src_text";
- private UiDevice mDevice;
- private Context mContext = null;
- private AndroidBvtHelper mABvtHelper = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mContext = InstrumentationRegistry.getTargetContext();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- mDevice.setOrientationNatural();
- mDevice.pressHome();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.wakeUp();
- mDevice.unfreezeRotation();
- mDevice.pressHome();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * IME should be one of default IME services By default, 2 IME are default services
- * com.android.inputmethod.latin.LatinIME
- * com.google.android.voicesearch.ime.VoiceInputMethodService
- */
- public void testIsEnabledLatinIME() {
- List<InputMethodInfo> inputMethodList = mABvtHelper.getInputMethodManager()
- .getEnabledInputMethodList();
- for (InputMethodInfo im : inputMethodList) {
- if (im.getServiceName().equalsIgnoreCase(mABvtHelper.GOOGLE_KB_SVC)) {
- return;
- }
- }
- fail("Latin IME isn't one of default IME");
- }
-
- /**
- * Tests onClick() on EditTextView, GoogleKB pops up
- */
- public void testGoogleKBShownWhenTextViewClicked() throws InterruptedException {
- openSettingsSearchEditTextView();
- assertTrue("Google KB hasn't popped up", mDevice.wait(
- Until.hasObject(By.res(mABvtHelper.GOOGLE_KB_PACKAGE, "keyboard_area")),
- mABvtHelper.LONG_TIMEOUT));
- assertFalse("Google KB shouldn't be full screen",
- mABvtHelper.getInputMethodManager().isFullscreenMode());
- }
-
- /**
- * Tests onClick() a char on GoogleKB shows up in Edit text view
- */
- public void testCharInputFromKBCommitsInEditTextView() throws InterruptedException {
- openSettingsSearchEditTextView();
- /**
- * chars can be identified on KB by indices For QWERTY KB example:
- * 'Q' is the first char on first row, index : 0, 0. It's resource id is key_pos_0_0
- * 'A' is the first char on first row. index : 1, 0. It's resource id is key_pos_1_0
- */
- try {
- for (int i = 0; i < 2; ++i) {
- mDevice.wait(
- Until.findObject(By.res(mABvtHelper.GOOGLE_KB_PACKAGE,
- String.format("key_pos_%d_0", i))),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- }
- // Hide KB now
- mDevice.pressBack();
- // Now ensure text is committed in search text view
- assertTrue("Search textview's text isn't 'qa' as expected",
- mDevice.wait(Until.findObject(By.res(SEARCH_RES_ID)),
- mABvtHelper.LONG_TIMEOUT).getText().equals("qa"));
- } finally {
- mDevice.wait(Until.findObject(By.res(SEARCH_RES_ID)),
- mABvtHelper.LONG_TIMEOUT).setText("");
- }
- }
-
- /**
- * Clicking on EditTextView causes IME to pop up Search box in settings is an EditTextView.
- * There are EditTextView too But searchbox in settings have been chosen for its simplicity
- * Following method opens searchbox in settings view
- * @throws InterruptedException
- */
- private void openSettingsSearchEditTextView() throws InterruptedException {
- mABvtHelper.launchPackage(mABvtHelper.SETTINGS_PACKAGE);
- mDevice.waitForIdle();
- mDevice.wait(Until
- .findObject(By.res(mABvtHelper.SETTINGS_PACKAGE, "search")),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- mDevice.wait(
- Until.findObject(By.res(SEARCH_RES_ID)),
- mABvtHelper.LONG_TIMEOUT).setText("");
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- }
-} \ No newline at end of file
diff --git a/tests/androidbvt/src/com/android/androidbvt/MediaPlaybackTests.java b/tests/androidbvt/src/com/android/androidbvt/MediaPlaybackTests.java
deleted file mode 100644
index 474e820b7..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/MediaPlaybackTests.java
+++ /dev/null
@@ -1,109 +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.androidbvt;
-
-import android.media.MediaPlayer;
-import android.os.Looper;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-import com.android.androidbvt.app.MediaPlaybackTestApp;
-
-/**
- * Basic tests for video playback
- */
-public class MediaPlaybackTests extends ActivityInstrumentationTestCase2<MediaPlaybackTestApp> {
-
- private static final String TAG = "MediaPlaybackTest";
- private static final int LOOP_START_BUFFER_MS = 10000;
- private static final int PLAY_BUFFER_MS = 2000;
- private final Object mCompletionLock = new Object();
- private final Object mLooperLock = new Object();
- private boolean mPlaybackSucceeded = false;
- private boolean mPlaybackError = false;
- private Looper mLooper;
- private MediaPlayer mPlayer;
-
- public MediaPlaybackTests() {
- super(MediaPlaybackTestApp.class);
- }
-
- @Override
- public void setUp() throws Exception {
- // start activity
- getActivity();
- }
-
- @LargeTest
- public void testVideoPlayback() {
- // start the MediaPlayer on a Looper thread, so it does not deadlock itself
- new Thread() {
- @Override
- public void run() {
- Looper.prepare();
- mLooper = Looper.myLooper();
- mPlayer = MediaPlayer.create(getInstrumentation().getContext(), R.raw.bbb);
- mPlayer.setDisplay(getActivity().getSurfaceHolder());
- synchronized (mLooperLock) {
- mLooperLock.notify();
- }
- Looper.loop();
- }
- }.start();
- // make sure the looper is really started before we proceed
- synchronized (mLooperLock) {
- try {
- mLooperLock.wait(LOOP_START_BUFFER_MS);
- } catch (InterruptedException e) {
- fail("Loop thread start was interrupted");
- }
- }
- mPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
- @Override
- public boolean onError(MediaPlayer mp, int what, int extra) {
- mPlaybackError = true;
- mp.reset();
- return true;
- }
- });
- mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- synchronized (mCompletionLock) {
- Log.w(TAG, "Hit onCompletion!");
- mPlaybackSucceeded = true;
- mCompletionLock.notifyAll();
- }
- }
- });
- mPlayer.start();
- int duration = mPlayer.getDuration();
- int currentPosition = mPlayer.getCurrentPosition();
- synchronized (mCompletionLock) {
- try {
- mCompletionLock.wait(duration - currentPosition + PLAY_BUFFER_MS);
- } catch (InterruptedException e) {
- fail("Wait for playback was interrupted");
- }
- }
- mLooper.quit();
- mPlayer.release();
- assertFalse(mPlaybackError);
- assertTrue(mPlaybackSucceeded);
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/PackageAddedBroadcastReceiver.java b/tests/androidbvt/src/com/android/androidbvt/PackageAddedBroadcastReceiver.java
deleted file mode 100644
index c351675f7..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/PackageAddedBroadcastReceiver.java
+++ /dev/null
@@ -1,53 +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.androidbvt;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-import android.widget.Toast;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * BroadcastReceiver that listens for package-added events.
- */
-public class PackageAddedBroadcastReceiver extends BroadcastReceiver {
-
- private static final String TEST_TAG = "AndroidBVT";
- public static AtomicBoolean isInstalled = new AtomicBoolean(false);
-
- @Override
- public void onReceive(Context context, Intent arg1) {
- Log.v(TEST_TAG, "there is a broadcast for app installation");
- isInstalled.compareAndSet(false, true);
- }
-
- // Tries 10 times/10 secs for install to be completed
- public boolean isInstallCompleted()
- throws InterruptedException {
- int counter = 10;
- while (--counter > 0) {
- if (isInstalled.get()) {
- return true;
- }
- Thread.sleep(1000);
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/tests/androidbvt/src/com/android/androidbvt/PlayStoreDownloadTests.java b/tests/androidbvt/src/com/android/androidbvt/PlayStoreDownloadTests.java
deleted file mode 100644
index 1861cc9ab..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/PlayStoreDownloadTests.java
+++ /dev/null
@@ -1,105 +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.androidbvt;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.PackageManager;
-import android.database.Cursor;
-import android.os.RemoteException;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.widget.Toast;
-import android.platform.test.helpers.PlayStoreHelperImpl;
-
-import junit.framework.TestCase;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-
-/*
- * Basic test for installing apk from playstore
- */
-public class PlayStoreDownloadTests extends TestCase {
- private static final String TEST_TAG = "AndroidBVT";
- //Test apk uploaded in PlayStore for testing purpose only
- private static final String TEST_APK_NAME = "w35location1";
- private static final String TEST_PKG_NAME = "com.test.w35location1";
- private static final String PLAYSTORE_PKG = "com.android.vending";
- private AndroidBvtHelper mABvtHelper = null;
- private UiDevice mDevice;
- private Context mContext = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.freezeRotation();
- mContext = InstrumentationRegistry.getTargetContext();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- mDevice.pressMenu();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- @LargeTest
- public void testPlayStoreDownload() throws Exception {
- installFromPlayStore(TEST_APK_NAME);
- PackageAddedBroadcastReceiver pBroadcastReceiver = new PackageAddedBroadcastReceiver();
- assertTrue("The apk has not been installed from playstore", pBroadcastReceiver.isInstallCompleted());
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- uninstallFromPlayStore(TEST_PKG_NAME);
- }
-
- public void installFromPlayStore(String appName) throws Exception {
- PlayStoreHelperImpl mHelper = new PlayStoreHelperImpl(
- InstrumentationRegistry.getInstrumentation());
- mHelper.open();
- mHelper.doSearch(appName);
- mHelper.selectFirstResult();
- mDevice.wait(Until.findObject(By.res(PLAYSTORE_PKG, "buy_button").text("INSTALL")),
- mABvtHelper.LONG_TIMEOUT)
- .clickAndWait(Until.newWindow(), 2 * mABvtHelper.LONG_TIMEOUT);
- UiObject2 continueBtn = mDevice.wait(
- Until.findObject(By.res(PLAYSTORE_PKG, "positive_button")),
- mABvtHelper.LONG_TIMEOUT);
- if (continueBtn != null) {
- continueBtn.click();
- }
- }
-
- public void uninstallFromPlayStore(String pkgName) throws Exception {
- String cmd = " pm uninstall " + pkgName;
- mABvtHelper.executeShellCommand(cmd);
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysBugReportTests.java b/tests/androidbvt/src/com/android/androidbvt/SysBugReportTests.java
deleted file mode 100644
index ace7b0154..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysBugReportTests.java
+++ /dev/null
@@ -1,128 +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.androidbvt;
-
-import android.app.UiAutomation;
-import android.content.Context;
-import android.os.Environment;
-import android.provider.Settings;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import junit.framework.TestCase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/*
- * Basic test for bug reports:
- * Take Bug report from developer options
- * Verify bug report exists *
- */
-public class SysBugReportTests extends TestCase{
- private static final String BUGREPORTS_DIR
- = "./data/user_de/0/com.android.shell/files/bugreports/";
- private static final String BUGREPORT_BUTTON = "Take bug report";
- private static final String BUGREPORT_CHECK
- = " dumpsys activity service BugreportProgressService";
- private static final String DEVELOPER_OPTION_PAGE
- = android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS;
- private static final String SYSUI_PKG = "com.android.systemui";
- private Context mContext = null;
- private UiAutomation mUiAutomation = null;
- private UiDevice mDevice = null;
- private AndroidBvtHelper mABvtHelper = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.setOrientationNatural();
- mContext = InstrumentationRegistry.getTargetContext();
- mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext, mUiAutomation);
- mDevice.wakeUp();
- mDevice.pressMenu();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- @LargeTest
- public void testBugReportFromDeveloperOptions() throws Exception {
- DismissNotifications();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- mDevice.pressBack();
- mABvtHelper.removeDir(BUGREPORTS_DIR);
- //launch developer options page
- String cmd = " am start -n com.android.settings/.DevelopmentSettings ";
- mABvtHelper.executeShellCommand(cmd);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- UiObject2 bugReportBtn = mDevice
- .wait(Until.findObject(By.text(BUGREPORT_BUTTON)), mABvtHelper.LONG_TIMEOUT);
- assertNotNull("Can not find bug report button!", bugReportBtn);
- bugReportBtn.click();
- mDevice.wait(Until.findObject(By.res("android", "button1")), mABvtHelper.LONG_TIMEOUT)
- .click();
- //sleep 1 minute as bug report will take at least 60 seconds generally.
- Thread.sleep(60000);
- assertTrue("Bug report has not been generated!", isBugReportGenerated());
- }
-
- private boolean isBugReportGenerated() throws Exception {
- int counter = 10;
- List<String> results = null;
- while (--counter > 0) {
- results = mABvtHelper.executeShellCommand(BUGREPORT_CHECK);
- if (findBugReport(results)) {
- return true;
- }
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
- return false;
- }
-
- private boolean findBugReport(List<String> results) {
- List<String> bugResults = new ArrayList<String>();
- for(String s:results){
- if (s.indexOf("finished")> 0){
- bugResults.add(s);
- }
- }
- if (bugResults.size()>0 && bugResults.get(bugResults.size()-1).indexOf("true")>0){
- return true;
- }
- return false;
- }
-
- private void DismissNotifications(){
- mDevice.openNotification();
- UiObject2 clearAllBtn = mDevice.wait(
- Until.findObject(By.res(SYSUI_PKG, "dismiss_text")),
- mABvtHelper.LONG_TIMEOUT);
- if (clearAllBtn!=null){
- clearAllBtn.click();
- }
- }
-} \ No newline at end of file
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysMediaTests.java b/tests/androidbvt/src/com/android/androidbvt/SysMediaTests.java
deleted file mode 100644
index 67463e252..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysMediaTests.java
+++ /dev/null
@@ -1,55 +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.androidbvt;
-
-import android.content.Context;
-import android.media.AudioManager;
-import android.support.test.InstrumentationRegistry;
-import android.test.suitebuilder.annotation.MediumTest;
-import junit.framework.TestCase;
-
-/**
- * Verify setting vol = 0, device goes into vibrate mode
- */
-public class SysMediaTests extends TestCase {
- private Context mContext = null;
- private AudioManager mAudioManager = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mContext = InstrumentationRegistry.getTargetContext();
- mAudioManager = (AudioManager) mContext.getSystemService(mContext.AUDIO_SERVICE);
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Verifies setting volume to 0, vibration turns on Ringer Volume icon changes to vibration icon
- * in Sound Settings
- * @throws InterruptedException
- */
- @MediumTest
- public void testVolumeMuteAndVibrate() throws InterruptedException {
- assertTrue(mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_VIBRATE);
- mAudioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, 0, AudioManager.FLAG_VIBRATE);
- assertTrue(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE);
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysPowerTests.java b/tests/androidbvt/src/com/android/androidbvt/SysPowerTests.java
deleted file mode 100644
index ce9032f5b..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysPowerTests.java
+++ /dev/null
@@ -1,79 +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.androidbvt;
-
-import android.app.UiAutomation;
-import android.content.Context;
-import android.os.PowerManager;
-import android.os.RemoteException;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.KeyEvent;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-
-/**
- * Basic tests for Power On/Off
- */
-public class SysPowerTests extends TestCase {
- private static final int SLEEP_TIMEOUT = 30000;
- private UiAutomation mUiAutomation = null;
- private UiDevice mDevice;
- private Context mContext = null;
- private PowerManager mPowerManager;
- private AndroidBvtHelper mABvtHelper = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.setOrientationNatural();
- mContext = InstrumentationRegistry.getTargetContext();
- mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
- mPowerManager = (PowerManager) mContext.getSystemService(mContext.POWER_SERVICE);
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext, mUiAutomation);
- mDevice.pressMenu();
- mDevice.pressHome();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.pressHome();
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- public void testPowerOnOff() throws InterruptedException, RemoteException {
- mDevice.pressKeyCode(KeyEvent.KEYCODE_POWER);
- Thread.sleep(SLEEP_TIMEOUT);
- assertFalse("Screen is still on", mPowerManager.isInteractive());
- Thread.sleep(SLEEP_TIMEOUT);
- assertFalse("Screen is still on", mPowerManager.isInteractive());
- mDevice.pressKeyCode(KeyEvent.KEYCODE_POWER);
- mDevice.pressMenu();
- mDevice.pressHome();
- UiObject2 hotseat = mDevice.findObject(By.res(mDevice.getLauncherPackageName(), "hotseat"));
- assertNotNull("Not on home screen", hotseat);
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysSettingTests.java b/tests/androidbvt/src/com/android/androidbvt/SysSettingTests.java
deleted file mode 100644
index 26d2e075d..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysSettingTests.java
+++ /dev/null
@@ -1,454 +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.androidbvt;
-
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothManager;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.provider.Settings;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.MediumTest;
-import com.android.androidbvt.AndroidBvtHelper.SettingType;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-/**
- * Contain following tests for setting tests:
- * -Verify that common settings are set to default value
- * -Verify that user can change common settings using UI
- * -Verify quick settings are displayed on the phone screen
- * -Verify that user can change settings from quick settings panel
- */
-public class SysSettingTests extends TestCase {
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final String SWITCH_WIDGET = "switch_widget";
- private static final String WIFI = "Wi-Fi";
- private static final String BLUETOOTH = "Bluetooth";
- private static final String AIRPLANE = "Airplane mode";
- private static final String LOCATION = "Location";
- private static final String DND = "Do not disturb";
- private static final String ZEN_MODE = "zen_mode";
- private static final String FLASHLIGHT="Flashlight";
- private static final String AUTO_ROTATE_SCREEN = "Auto-rotate screen";
-
- private HashMap<String, String> mGlobalSettings = new HashMap<String, String>();
- {
- // Bluetooth is by default OFF.
- mGlobalSettings.put("bluetooth_on", "0");
- // Airplane mode is by default OFF
- mGlobalSettings.put("airplane_mode_on", "0");
- // Wifi is by default on for testing
- mGlobalSettings.put("wifi_on", "1");
- // Data roaming is by default OFF
- mGlobalSettings.put("data_roaming", "0");
- // Do not Disturb mode is by default OFF
- mGlobalSettings.put("zen_mode", "0");
- }
-
- private HashMap<String, String> mSystemSettings = new HashMap<String, String>();
- {
- // Automatic Brightness mode is by default on
- mSystemSettings.put("screen_brightness_mode", "1");
- // By default 30 sec before the device goes to sleep after inactivity
- mSystemSettings.put("screen_off_timeout", "30000");
- // By default Font is 1.0
- mSystemSettings.put("font_scale", "1.0");
- }
-
- private HashMap<String, String> mSecureSettings = new HashMap<String, String>();
- {
- // By default screensaver is disabled
- mSecureSettings.put("screensaver_enabled", "0");
- }
-
- private Map<SettingType, HashMap<String, String>> mSettings =
- new HashMap<SettingType, HashMap<String, String>>();
- {
- mSettings.put(SettingType.GLOBAL, mGlobalSettings);
- mSettings.put(SettingType.SYSTEM, mSystemSettings);
- mSettings.put(SettingType.SECURE, mSecureSettings);
- }
-
- private Map<String, List<String>> QuickSettingTiles = new HashMap<String, List<String>>();
- {
- List<String> tiles = Arrays.asList("Wi-Fi", "Do not disturb", "Battery", "Flashlight",
- "screen", "Bluetooth", "Airplane mode", "Location");
- QuickSettingTiles.put("Tablet", tiles);
- List<String> tiles1 = Arrays.asList("Wi-Fi", "SIM", "Do not disturb", "Battery",
- "Flashlight", "screen", "Bluetooth", "Airplane mode", "Location");
- QuickSettingTiles.put("Phone", tiles1);
- List<String> tilesMr1 = Arrays.asList("Wi-Fi", "SIM", "Do not disturb", "Battery",
- "Flashlight", "screen", "Bluetooth", "Airplane mode", "Nearby");
- QuickSettingTiles.put("MR1", tilesMr1);
- }
-
- private Context mContext = null;
- private AndroidBvtHelper mABvtHelper = null;
- private ContentResolver mResolver = null;
- private UiDevice mDevice = null;
- private boolean isMr1Device = false;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mContext = InstrumentationRegistry.getTargetContext();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.freezeRotation();
- mResolver = mContext.getContentResolver();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- mDevice.setOrientationNatural();
- mDevice.pressHome();
- isMr1Device = mABvtHelper.isNexusExperienceDevice();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.pressHome();
- mDevice.unfreezeRotation();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * Verify that common settings are set to default value
- */
- @MediumTest
- public void testSettingDefaultValues() {
- for(Entry<SettingType, HashMap<String, String>> settingsByType : mSettings.entrySet()){
- SettingType settingType = settingsByType.getKey();
- if (!(settingType.equals(SettingType.SYSTEM) && mABvtHelper.isTablet())) {
- HashMap<String, String> settings = settingsByType.getValue();
- for (Entry<String, String> settingPair : settings.entrySet()) {
- assertTrue(
- String.format("%s does not have default value: %s",
- settingPair.getKey(),
- settingPair.getValue()),
- mABvtHelper.getStringSetting(settingType, settingPair.getKey())
- .equals(settingPair.getValue()));
- }
- }
- }
- }
-
- @MediumTest
- public void testNavigationToNOESettings() {
- mABvtHelper.launchApp("com.android.settings", "Settings");
- Pattern pattern = Pattern.compile("Support", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), mABvtHelper.LONG_TIMEOUT).click();
- assertTrue("", mDevice.wait(Until.hasObject(By.text("We're here to help")),
- mABvtHelper.LONG_TIMEOUT));
- assertTrue("", mDevice.wait(Until.hasObject(By.text("Search help & send feedback")),
- mABvtHelper.LONG_TIMEOUT));
- assertTrue("", mDevice.wait(Until.hasObject(By.text("Explore tips & tricks")),
- mABvtHelper.LONG_TIMEOUT));
- }
-
- /**
- * Verify that user can change common settings using UI
- */
- @LargeTest
- public void testSettingValues() throws Exception {
- //Check wifi setting can be toggled
- verifyWiFiOnOrOff(true, false);
- // check bluetooth setting can be toggled
- verifyBluetoothOnOrOff(true, false);
- // check airplane mode can be toggled
- verifyAirplaneModeOnOrOff(false, false);
- // check Location can be toggled
- verifyLocationSettingsOnOrOff(false, false);
- }
-
- /**
- * Verify that user can open Quick Setting shade and icons can be displayed in the shade
- */
- @LargeTest
- public void testQuickSettingsOpenAndIconsDisplayed() throws Exception {
- mABvtHelper.launchQuickSettingsAndWait();;
- List<String> tiles = null;
- // Verify quick settings are displayed on the phone screen.
- if (mABvtHelper.isTablet()){
- tiles = QuickSettingTiles.get("Tablet");
- }else if (mABvtHelper.isNexusExperienceDevice()){
- tiles = QuickSettingTiles.get("MR1");
- }else{
- tiles = QuickSettingTiles.get("Phone");
- }
- for (String tile : tiles) {
- UiObject2 quickSettingTile = mDevice.wait(
- Until.findObject(By.descContains(tile)),
- mABvtHelper.SHORT_TIMEOUT);
- assertNotNull(String.format("%s did not load correctly", tile),
- quickSettingTile);
- }
- }
-
- /**
- * Verify tapping on Settings icon in Quick settings launches Settings.
- */
- public void testLaunchSettingFromQuickSetting() throws Exception {
- mABvtHelper.launchQuickSettingsAndWait();;
- mDevice.wait(Until.findObject(By.descContains("Open settings.")), mABvtHelper.LONG_TIMEOUT)
- .click();
- Pattern pattern = Pattern.compile("Settings", Pattern.CASE_INSENSITIVE);
- UiObject2 settingHeading = mDevice.wait(Until.findObject(By.text(pattern)),
- mABvtHelper.LONG_TIMEOUT);
- assertNotNull("Setting menu has not loaded correctly", settingHeading);
- }
-
- /**
- * Verify User can change settings from quick setting shade: Wifi, Bluetooth, Airplane mode,
- * Location, Do not disturb, flashlight
- */
- @LargeTest
- public void testQuickSettingsChangeFromQuickSettingsPanel() throws Exception {
- mDevice.openQuickSettings();
- // Check wifi setting can be toggled
- verifyWiFiOnOrOff(true, true);
- // check bluetooth setting can be toggled
- verifyBluetoothOnOrOff(true, true);
- // check airplane mode can be toggled
- verifyAirplaneModeOnOrOff(false, true);
- // check DND can be toggled
- verifyQuickSettingDND();
- // check FlashLight can be toggled
- verifyQuickSettingFlashLight();
- // check Orientation can be toggled
- verifyQuickSettingOrientation();
- // check Location can be toggled for legacy devices
- if (!isMr1Device) {
- verifyLocationSettingsOnOrOff(false, true);
- }
- }
-
- private void verifyWiFiOnOrOff(boolean verifyOn, boolean isQuickSettings) throws Exception {
- String switchText = "ON";
- if (verifyOn) {
- switchText = "OFF";
- }
- WifiManager wifiManager = (WifiManager) mContext
- .getSystemService(Context.WIFI_SERVICE);
- wifiManager.setWifiEnabled(!verifyOn);
- if (isQuickSettings){
- mABvtHelper.launchQuickSettingsAndWait();;
- mDevice.wait(Until.findObject(By.descContains(WIFI)),
- mABvtHelper.LONG_TIMEOUT).click();
- }else{
- mABvtHelper.launchIntent(Settings.ACTION_WIFI_SETTINGS);
- mDevice.wait(Until
- .findObject(By.res(SETTINGS_PACKAGE, SWITCH_WIDGET).text(switchText)),
- mABvtHelper.LONG_TIMEOUT)
- .click();
- }
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- String wifiValue = Settings.Global.getString(mResolver,
- Settings.Global.WIFI_ON);
- if (verifyOn) {
- assertEquals("1", wifiValue);
- } else {
- assertEquals("0", wifiValue);
- }
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
-
- private void verifyBluetoothOnOrOff(boolean verifyOn, boolean isQuickSettings)
- throws Exception {
- String switchText = "ON";
- BluetoothAdapter bluetoothAdapter = ((BluetoothManager) mContext
- .getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
- if (verifyOn) {
- switchText = "OFF";
- bluetoothAdapter.disable();
- } else {
- bluetoothAdapter.enable();
- }
- if (isQuickSettings) {
- mABvtHelper.launchQuickSettingsAndWait();;
- mDevice.wait(Until.findObject(By.descContains(BLUETOOTH)),
- mABvtHelper.LONG_TIMEOUT).click();
- } else {
- mABvtHelper.launchIntent(Settings.ACTION_BLUETOOTH_SETTINGS);
- mDevice.wait(Until
- .findObject(By.res(SETTINGS_PACKAGE, SWITCH_WIDGET).text(switchText)),
- mABvtHelper.LONG_TIMEOUT)
- .click();
- }
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- String bluetoothValue = Settings.Global.getString(
- mResolver,
- Settings.Global.BLUETOOTH_ON);
- if (verifyOn) {
- assertEquals("1", bluetoothValue);
- } else {
- assertEquals("0", bluetoothValue);
- }
- bluetoothAdapter.disable();
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
-
- private void verifyAirplaneModeOnOrOff(boolean verifyOn, boolean isQuickSettings)
- throws Exception {
- if (verifyOn) {
- Settings.Global.putString(mResolver,
- Settings.Global.AIRPLANE_MODE_ON, "0");
- }else {
- Settings.Global.putString(mResolver,
- Settings.Global.AIRPLANE_MODE_ON, "1");
- }
- if (isQuickSettings) {
- mABvtHelper.launchQuickSettingsAndWait();
- mDevice.wait(Until.findObject(By.descContains(AIRPLANE)),
- mABvtHelper.LONG_TIMEOUT).click();
- } else {
- mABvtHelper.launchIntent(Settings.ACTION_WIRELESS_SETTINGS);
- mDevice.wait(Until
- .findObject(By.text(AIRPLANE)), mABvtHelper.LONG_TIMEOUT)
- .click();
- }
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- String airplaneModeValue = Settings.Global
- .getString(mResolver,
- Settings.Global.AIRPLANE_MODE_ON);
- if (verifyOn) {
- assertEquals("1", airplaneModeValue);
- }
- else {
- assertEquals("0", airplaneModeValue);
- }
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
-
- private void verifyLocationSettingsOnOrOff(boolean verifyOn, boolean isQuickSettings)
- throws Exception {
- // Set location flag
- if (verifyOn) {
- Settings.Secure.putInt(mResolver,
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
- }
- else {
- Settings.Secure.putInt(mResolver,
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
- }
- // Load location settings
- if (isQuickSettings) {
- mABvtHelper.launchQuickSettingsAndWait();
- mDevice.wait(Until.findObject(By.descContains(LOCATION)),
- mABvtHelper.LONG_TIMEOUT).click();
- } else {
- mABvtHelper.launchIntent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
- // Toggle UI
- mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, SWITCH_WIDGET)),
- mABvtHelper.LONG_TIMEOUT).click();
- }
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // Verify change in setting
- int locationEnabled = Settings.Secure.getInt(mResolver,
- Settings.Secure.LOCATION_MODE);
- if (verifyOn) {
- assertFalse("Location not enabled correctly", locationEnabled == 0);
- }else {
- assertEquals("Location not disabled correctly", 0, locationEnabled);
- }
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
-
- /**
- * Verify Quick Setting DND can be toggled
- * DND default value is OFF
- * @throws Exception
- */
- private void verifyQuickSettingDND() throws Exception {
- try{
- int onSetting = Settings.Global.getInt(mResolver, ZEN_MODE);
- mABvtHelper.launchQuickSettingsAndWait();
- mDevice.wait(Until.findObject(By.descContains(DND)),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- int changedSetting = Settings.Global.getInt(mResolver, ZEN_MODE);
- assertFalse(onSetting == changedSetting);
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }finally{
- //change to DND default value
- int setting = Settings.Global.getInt(mResolver, ZEN_MODE);
- if (setting > 0){
- mABvtHelper.launchQuickSettingsAndWait();;
- mDevice.wait(Until.findObject(By.descContains(DND)),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
- }
- }
-
- private void verifyQuickSettingFlashLight() throws Exception {
- String lightOn = "On";
- String lightOff = "Off";
- boolean verifyOn = false;
- mABvtHelper.launchQuickSettingsAndWait();
- UiObject2 flashLight = mDevice.wait(
- Until.findObject(By.descContains(FLASHLIGHT)),
- mABvtHelper.LONG_TIMEOUT);
- if (flashLight.getText().equals(lightOn)) {
- verifyOn = true;
- }
- mDevice.wait(Until.findObject(By.textContains(FLASHLIGHT)),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- flashLight = mDevice.wait(
- Until.findObject(By.descContains(FLASHLIGHT)),
- mABvtHelper.LONG_TIMEOUT);
- if (verifyOn) {
- assertTrue(flashLight.getText().equals(lightOff));
- } else {
- assertTrue(flashLight.getText().equals(lightOn));
- mDevice.wait(Until.findObject(By.textContains(FLASHLIGHT)),
- mABvtHelper.LONG_TIMEOUT).click();
- }
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
-
- private void verifyQuickSettingOrientation() throws Exception {
- mABvtHelper.launchQuickSettingsAndWait();
- mDevice.wait(Until.findObject(By.descContains(AUTO_ROTATE_SCREEN)),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- String rotation = Settings.System.getString(mResolver,
- Settings.System.ACCELEROMETER_ROTATION);
- assertEquals("1", rotation);
- mDevice.setOrientationNatural();
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysUIGSATests.java b/tests/androidbvt/src/com/android/androidbvt/SysUIGSATests.java
deleted file mode 100644
index 935e169dc..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysUIGSATests.java
+++ /dev/null
@@ -1,219 +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.androidbvt;
-
-import android.app.UiAutomation;
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.KeyEvent;
-
-import junit.framework.TestCase;
-
-import java.util.List;
-
-/**
- * Contains tests for features that are loosely coupled with Android system for sanity
- */
-public class SysUIGSATests extends TestCase {
- private final String QSB_PKG = "com.google.android.googlequicksearchbox";
- private final String NEXUS_LAUNCHER_PKG = "com.google.android.apps.nexuslauncher";
- private UiAutomation mUiAutomation = null;
- private UiDevice mDevice;
- private Context mContext = null;
- private AndroidBvtHelper mABvtHelper = null;
- private boolean mIsMr1Device = false;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.setOrientationNatural();
- mContext = InstrumentationRegistry.getTargetContext();
- mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext, mUiAutomation);
- mIsMr1Device = mABvtHelper.isNexusExperienceDevice();
- mDevice.pressMenu();
- mDevice.pressHome();
- dismissInitialDialog();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.pressHome();
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- /**
- * Ensures search via QSB searches both web and device apps Suuggested texts starts with
- * searched text Remembers searched item, suggests as top suggestion next time
- */
- @LargeTest
- public void testGoogleQuickSearchBar() throws InterruptedException {
- String container = "search_suggestions_container";
- if (mIsMr1Device) {
- mDevice.wait(Until.findObject(By.res(NEXUS_LAUNCHER_PKG, "g_icon")),
- mABvtHelper.LONG_TIMEOUT).click();
- container = "cards_view";
- }
- final String TextToSearch = "co";
- UiObject2 searchBox = null;
- int counter = 5;
- while (--counter > 0
- && ((searchBox = mDevice.wait(Until.findObject(By.res(QSB_PKG, "search_box")),
- mABvtHelper.SHORT_TIMEOUT)) == null)) {
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- mDevice.pressHome();
- mDevice.pressSearch();
- }
- mDevice.wait(Until.findObject(By.res(QSB_PKG, "search_box")),
- mABvtHelper.LONG_TIMEOUT).setText(TextToSearch);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // make the IME down
- mDevice.pressKeyCode(KeyEvent.KEYCODE_BACK);
- // searching for 'co' will result from web, as well as 'Contacts' app. So there should be
- // more than 1 container
- UiObject2 searchSuggestionsContainer = mDevice.wait(Until.findObject(By.res(
- QSB_PKG, container)), mABvtHelper.LONG_TIMEOUT);
- assertTrue("QS suggestion should have more than 1 container",
- searchSuggestionsContainer.getChildCount() > 1);
- UiObject2 searchSuggestions = mDevice.wait(Until.findObject(By.res(
- QSB_PKG, "search_suggestions_web")), mABvtHelper.LONG_TIMEOUT);
- assertNotNull(
- "Web Search suggestions shouldn't be null & should have more than 1 suggestions",
- searchSuggestions != null && searchSuggestions.getChildCount() > 1);
- List<UiObject2> suggestions = mDevice.wait(Until.findObjects(By.res(QSB_PKG, "text_1")),
- mABvtHelper.LONG_TIMEOUT);
- assertNotNull("Contacts app should be found", mDevice.wait(Until.findObject(
- By.res(QSB_PKG, "text_1").text("Contacts")), mABvtHelper.LONG_TIMEOUT));
- String topSuggestedText = suggestions.get(0).getText();
- suggestions.get(0).clickAndWait(Until.newWindow(), mABvtHelper.LONG_TIMEOUT);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // Search again and ensure last searched item showed as top suggestion
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- if (mIsMr1Device) {
- mDevice.wait(Until.findObject(By.res(NEXUS_LAUNCHER_PKG, "g_icon")),
- mABvtHelper.LONG_TIMEOUT).click();
- } else {
- mDevice.pressSearch();
- }
- String currentTopSuggestion = mDevice.wait(Until.findObjects(By.res(QSB_PKG, "text_1")),
- mABvtHelper.LONG_TIMEOUT).get(0).getText();
- assertTrue("Previous searched item isn't top suggested word",
- topSuggestedText.toLowerCase().equals(topSuggestedText.toLowerCase()));
- }
-
- /**
- * Ensures if any account is opted in GoogleNow, Google-assist offers card on long home press
- */
- @LargeTest
- public void testGoogleAssist() throws InterruptedException {
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- if (mIsMr1Device) {
- mDevice.wait(Until.findObject(By.res(NEXUS_LAUNCHER_PKG, "g_icon")),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(2000);
- } else {
- mDevice.wait(Until.findObject(By.res(QSB_PKG, "search_plate")),
- mABvtHelper.LONG_TIMEOUT).click();
- }
- // Search for Paris and click on first suggested text
- mDevice.wait(Until.findObject(By.clazz("android.widget.EditText")),
- mABvtHelper.LONG_TIMEOUT).setText("Paris");
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- List<UiObject2> suggestedTexts = null;
- int counter = 5;
- while (--counter > 0
- && ((suggestedTexts = mDevice.wait(Until.findObjects(By.res(QSB_PKG, "text_1")),
- mABvtHelper.LONG_TIMEOUT)) == null)) {
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- }
- assertNotNull("Suggested text shouldn't be null", suggestedTexts);
- UiObject2 itemToClick = suggestedTexts.get(0);
- for (UiObject2 item : suggestedTexts) {
- if (item.getText().toLowerCase().equals("paris")) {
- itemToClick = item;
- }
- }
- itemToClick.clickAndWait(Until.newWindow(), mABvtHelper.SHORT_TIMEOUT);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // Now long press home to load assist layer
- mDevice.pressKeyCode(KeyEvent.KEYCODE_ASSIST);
- // Ensure some cards are loaded
- // Note card's content isn't verified
- counter = 5;
- UiObject2 cardContainer = null;
- while (--counter > 0 && ((cardContainer = mDevice.wait(
- Until.findObject(By.res(QSB_PKG, "card_container")),
- mABvtHelper.SHORT_TIMEOUT)) != null)) {
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- }
- assertNotNull("Some cards should be loaded", cardContainer);
- }
-
- public void dismissInitialDialog() throws InterruptedException {
- if (mIsMr1Device) {
- mDevice.pressHome();
- mDevice.wait(Until.findObject(By.res(NEXUS_LAUNCHER_PKG, "g_icon")),
- mABvtHelper.SHORT_TIMEOUT).click();
- Thread.sleep(2000);
- mDevice.wait(Until.findObject(By.res(QSB_PKG, "navigation_viewport")),
- mABvtHelper.SHORT_TIMEOUT).click();
- } else {
- mDevice.wait(Until.findObject(By.res(QSB_PKG, "search_plate")),
- mABvtHelper.LONG_TIMEOUT).click();
- }
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- UiObject2 getStarted = mDevice.wait(Until.findObject(By.text("GET STARTED")),
- mABvtHelper.SHORT_TIMEOUT);
- if (getStarted != null) {
- getStarted.clickAndWait(Until.newWindow(), mABvtHelper.SHORT_TIMEOUT);
- mDevice.wait(Until.findObject(By.res(QSB_PKG, "text_container")),
- mABvtHelper.SHORT_TIMEOUT).swipe(Direction.UP, 1.0f);
- mDevice.wait(Until.findObject(By.text("YES, I’M IN")),
- mABvtHelper.SHORT_TIMEOUT)
- .clickAndWait(Until.newWindow(), mABvtHelper.SHORT_TIMEOUT);
- }
- // Now long press home to load assist layer
- mDevice.pressKeyCode(KeyEvent.KEYCODE_ASSIST);
- if (mIsMr1Device) {
- UiObject2 optInYes = mDevice.wait(
- Until.findObject(By.res(QSB_PKG, "opa_error_cancel_button")),
- mABvtHelper.SHORT_TIMEOUT);
- if (optInYes != null) {
- optInYes.clickAndWait(Until.newWindow(), mABvtHelper.SHORT_TIMEOUT);
- }
- } else {
- UiObject2 optInYes = mDevice.wait(
- Until.findObject(By.res(QSB_PKG, "screen_assist_opt_in_yes")),
- mABvtHelper.SHORT_TIMEOUT);
- if (optInYes != null) {
- optInYes.clickAndWait(Until.newWindow(), mABvtHelper.SHORT_TIMEOUT);
- }
- }
- mDevice.pressHome();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysUILauncherTests.java b/tests/androidbvt/src/com/android/androidbvt/SysUILauncherTests.java
deleted file mode 100644
index fcf49245f..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysUILauncherTests.java
+++ /dev/null
@@ -1,267 +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.androidbvt;
-
-import android.app.WallpaperManager;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Point;
-import android.graphics.drawable.Drawable;
-import android.platform.test.annotations.HermeticTest;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.provider.Settings;
-import android.provider.Telephony.Threads;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.launcherhelper.ILauncherStrategy;
-import android.support.test.launcherhelper.LauncherStrategyFactory;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import java.io.IOException;
-import java.util.regex.Pattern;
-import junit.framework.TestCase;
-
-@HermeticTest
-public class SysUILauncherTests extends TestCase {
- private static final int LONG_TIMEOUT = 5000;
- private static final String APP_NAME = "Calculator";
- private static final String PKG_NAME = "com.google.android.deskclock";
- private static final String WIDGET_PREVIEW = "widget_preview";
- private static final String APP_WIDGET_VIEW = "android.appwidget.AppWidgetHostView";
- private static final String WIDGET_TEXT_VIEW = "android.widget.TextView";
- private static final String WALLPAPER_PKG = "com.google.android.apps.wallpaper";
- private static final String GOOGLE_SEARCH_PKG = "com.google.android.googlequicksearchbox";
- private static final String GOOGLE_NOW_HEADER = "now_header_hamburger";
- private UiDevice mDevice = null;
- private Context mContext;
- private ILauncherStrategy mLauncherStrategy = null;
- private AndroidBvtHelper mABvtHelper = null;
- private SettingsHelperImpl mHelper;
- private boolean mIsNexusDevice = false;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mContext = InstrumentationRegistry.getTargetContext();
- mDevice.setOrientationNatural();
- mLauncherStrategy = LauncherStrategyFactory.getInstance(mDevice).getLauncherStrategy();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- mIsNexusDevice = mABvtHelper.isNexusExperienceDevice();
- mHelper = new SettingsHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.pressHome();
- mDevice.unfreezeRotation();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * Add and remove a widget from home screen
- */
- @LargeTest
- public void testAddAndRemoveWidget() throws InterruptedException, IOException {
- // press menu key
- mDevice.pressMenu();
- Thread.sleep(LONG_TIMEOUT);
- mDevice.wait(Until.findObject(By.clazz(WIDGET_TEXT_VIEW)
- .text("WIDGETS")), LONG_TIMEOUT).click();
- Thread.sleep(LONG_TIMEOUT);
- // Long click to add widget
- mDevice.wait(
- Until.findObject(
- By.res(mDevice.getLauncherPackageName(), WIDGET_PREVIEW)),
- LONG_TIMEOUT).click(1000);
- mDevice.pressHome();
- UiObject2 appWidget = mDevice.wait(
- Until.findObject(By.clazz(APP_WIDGET_VIEW)), LONG_TIMEOUT);
- assertNotNull("Widget has not been added", appWidget);
- removeObject(appWidget);
- appWidget = mDevice.wait(Until.findObject(By.clazz(APP_WIDGET_VIEW)),
- LONG_TIMEOUT);
- assertNull("Widget is still there", appWidget);
- }
-
- /**
- * Change Wall Paper
- */
- @LargeTest
- public void testChangeWallPaper() throws InterruptedException, IOException {
- try {
- WallpaperManager wallpaperManagerPre = WallpaperManager.getInstance(mContext);
- wallpaperManagerPre.clear();
- Thread.sleep(LONG_TIMEOUT);
- Drawable wallPaperPre = wallpaperManagerPre.getDrawable().getCurrent();
- // press menu key
- mDevice.pressMenu();
- Thread.sleep(LONG_TIMEOUT);
- mDevice.wait(Until.findObject(By.clazz(WIDGET_TEXT_VIEW)
- .text("WALLPAPERS")), LONG_TIMEOUT).click();
- Thread.sleep(LONG_TIMEOUT);
- testWallPaper(mIsNexusDevice);
- Thread.sleep(LONG_TIMEOUT);
- WallpaperManager wallpaperManagerPost = WallpaperManager.getInstance(mContext);
- Drawable wallPaperPost = wallpaperManagerPost.getDrawable().getCurrent();
- assertFalse("Wallpaper has not been changed", wallPaperPre.equals(wallPaperPost));
- } finally {
- WallpaperManager wallpaperManagerCurrrent = WallpaperManager.getInstance(mContext);
- wallpaperManagerCurrrent.clear();
- Thread.sleep(LONG_TIMEOUT);
- }
- }
-
- /**
- * Add and remove short cut from home screen
- */
- @LargeTest
- public void testAddAndRemoveShortCut() throws InterruptedException {
- mLauncherStrategy.openAllApps(true);
- Thread.sleep(LONG_TIMEOUT);
- // This is a long press and should add the shortcut to the Home screen
- mDevice.wait(Until.findObject(By.clazz("android.widget.TextView")
- .desc(APP_NAME)), LONG_TIMEOUT).click(2000);
- // Searching for the object on the Home screen
- UiObject2 app = mDevice.wait(Until.findObject(By.text(APP_NAME)), LONG_TIMEOUT);
- assertNotNull("Apps has been added", app);
- removeObject(app);
- app = mDevice.wait(Until.findObject(By.text(APP_NAME)), LONG_TIMEOUT);
- assertNull(APP_NAME + " is still there", app);
- }
-
- /**
- * Remove object from home screen
- */
- private void removeObject(UiObject2 app) throws InterruptedException {
- // Drag shortcut/widget icon to Remove button which behinds Google Search bar
- String remove = mIsNexusDevice ? "Search" : "Google Search";
- UiObject2 removeButton = mDevice.wait(Until.findObject(By.desc(remove)),
- LONG_TIMEOUT);
- if (mIsNexusDevice){
- app.drag(new Point(removeButton.getVisibleCenter().x, removeButton.getVisibleCenter().y),
- 1000);
- }else{
- app.drag(new Point(mDevice.getDisplayWidth() / 2, removeButton.getVisibleCenter().y),
- 1000);
- }
- }
-
- private void testWallPaper(boolean mIsNexusDevice) throws InterruptedException {
- if (mIsNexusDevice){ //test marlin and sailfish
- UiObject2 viewScroll = mDevice.wait(Until.findObject(By.clazz("android.support.v7.widget.RecyclerView")), LONG_TIMEOUT);
- while(viewScroll.scroll(Direction.DOWN, 1.0f));
- UiObject2 wallpaperSets = mDevice.wait(Until.findObject(By.res(WALLPAPER_PKG,"tile")), LONG_TIMEOUT);
- assertNotNull("No wallpaper sets has been found", wallpaperSets);
- wallpaperSets.click();
- Thread.sleep(LONG_TIMEOUT);
- mDevice.wait(Until.findObject(By.res(WALLPAPER_PKG,"tile")), LONG_TIMEOUT).click();
- }else{//test other devices
- // set second wall paper as current wallpaper for home screen and lockscreen
- mDevice.wait(Until.findObject(By.descContains("Wallpaper 2")), LONG_TIMEOUT).click();
- }
- Thread.sleep(LONG_TIMEOUT);
- String s1= GOOGLE_SEARCH_PKG + ":id/set_wallpaper_button";
- String s2= WALLPAPER_PKG+ ":id/set_wallpaper";
- Pattern p = Pattern.compile(s1+"|"+s2);
- UiObject2 button = mDevice.wait(Until.findObject(By.res(p)), LONG_TIMEOUT * 2);
- assertNotNull("Can not find Set Wallpaper");
- button.click();
- UiObject2 homeScreen = mDevice
- .wait(Until.findObject(By.text("Home screen")), LONG_TIMEOUT);
- if (homeScreen != null) {
- homeScreen.click();
- }
- }
-
- public void testGoogleNowShowInGel() throws Exception {
- mDevice.pressHome();
- swipeToLeftScreen();
- // Enable Now cards if GEL is not enabled.
- if (!isOnGoogleNowPage()) {
- // enable Now Cards
- enableNowCardsSetting();
- // swipe left to Screen -1
- swipeToLeftScreen();
- }
- // verify GoogleNow shows up in Screen -1
- assertTrue("Not on Google now page!", isOnGoogleNowPage());
- }
-
- private void enableNowCardsSetting() throws Exception {
- mABvtHelper.launchIntent(Settings.ACTION_SETTINGS);
- UiObject2 obj = launchSettingItems("Google");
- obj.click();
- obj = launchSettingItems("Search & Now");
- obj.click();
- obj = launchSettingItems("Now cards");
- obj.click();
- obj = (mDevice.wait(Until.findObject(By.res("android","list")), mABvtHelper.LONG_TIMEOUT)).getChildren().get(0);
- if (obj.hasObject(By.text("OFF"))){
- obj.click();
- //click setup
- UiObject2 setUp = mDevice.wait(Until.findObject(By.res(GOOGLE_SEARCH_PKG,"accept_button")),
- mABvtHelper.SHORT_TIMEOUT);
- if (setUp != null) {
- setUp.clickAndWait(Until.newWindow(), mABvtHelper.SHORT_TIMEOUT);
- mDevice.wait(Until.findObject(By.res(GOOGLE_SEARCH_PKG, "text_container")),
- mABvtHelper.SHORT_TIMEOUT).swipe(Direction.UP, 1.0f);
- mDevice.wait(Until.findObject(By.res(GOOGLE_SEARCH_PKG,"accept_button")),
- mABvtHelper.SHORT_TIMEOUT)
- .clickAndWait(Until.newWindow(), mABvtHelper.SHORT_TIMEOUT);
- }
- }
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- mDevice.pressHome();
- Thread.sleep( mABvtHelper.SHORT_TIMEOUT);
- }
-
- private UiObject2 launchSettingItems(String title) throws Exception {
- int maxAttempt = 5;
- UiObject2 item = null;
- UiObject2 view = null;
- while (maxAttempt-- > 0) {
- item = mDevice.wait(Until.findObject(By.res("android:id/title").text(title)),
- mABvtHelper.LONG_TIMEOUT);
- if (item == null) {
- mHelper.scrollVert(false);
- } else {
- return item;
- }
- }
- assertNotNull(String.format("Can't find %s", title), item);
- return null;
- }
-
- private boolean isOnGoogleNowPage(){
- return mDevice.wait(Until.findObject(By.res(GOOGLE_SEARCH_PKG, GOOGLE_NOW_HEADER)),
- mABvtHelper.LONG_TIMEOUT) != null;
- }
-
- //swipe to left screen
- private void swipeToLeftScreen() throws Exception{
- mDevice.swipe(0, mDevice.getDisplayHeight() / 2, mDevice.getDisplayWidth() - 50,
- mDevice.getDisplayHeight() / 2, 30);
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysUILockScreenTests.java b/tests/androidbvt/src/com/android/androidbvt/SysUILockScreenTests.java
deleted file mode 100644
index 8cb6a5866..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysUILockScreenTests.java
+++ /dev/null
@@ -1,457 +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.androidbvt;
-
-import android.app.KeyguardManager;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Environment;
-import android.os.RemoteException;
-import android.platform.test.annotations.HermeticTest;
-import android.platform.test.helpers.GoogleCameraHelperImpl;
-import android.provider.Settings;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.accessibility.AccessibilityWindowInfo;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-@HermeticTest
-public class SysUILockScreenTests extends TestCase {
- private static final String EDIT_TEXT_CLASS_NAME = "android.widget.EditText";
- private static final int SHORT_TIMEOUT = 200;
- private static final int LONG_TIMEOUT = 2000;
- private static final int PIN = 1234;
- private static final String PASSWORD = "aaaa";
- private AndroidBvtHelper mABvtHelper = null;
- private UiDevice mDevice = null;
- private Context mContext;
- private boolean mIsNexusDevice = false;
- private GoogleCameraHelperImpl mCameraHelper;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.freezeRotation();
- mContext = InstrumentationRegistry.getTargetContext();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- mDevice.wakeUp();
- mDevice.pressHome();
- mIsNexusDevice = mABvtHelper.isNexusExperienceDevice();
- mCameraHelper = new GoogleCameraHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.pressHome();
- mDevice.pressMenu();
- mDevice.unfreezeRotation();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * Following test will add PIN for Lock Screen, and remove PIN
- * @throws InterruptedException, IOException, RemoteException
- */
- @LargeTest
- public void testLockScreenPIN() throws InterruptedException, IOException, RemoteException {
- setScreenLock(Integer.toString(PIN), "PIN");
- sleepAndWakeUpDevice();
- unlockScreen(Integer.toString(PIN));
- removeScreenLock(Integer.toString(PIN));
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- Assert.assertFalse("Lock Screen is still enabled", isLockScreenEnabled());
- }
-
- /**
- * Following test will add password for Lock Screen, and remove Password
- * @throws InterruptedException, IOException, RemoteException
- */
- @LargeTest
- public void testLockScreenPwd() throws InterruptedException, IOException, RemoteException {
- setScreenLock(PASSWORD, "Password");
- sleepAndWakeUpDevice();
- unlockScreen(PASSWORD);
- removeScreenLock(PASSWORD);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- Assert.assertFalse("Lock Screen is still enabled", isLockScreenEnabled());
- }
-
- /**
- * Following test will add password for Lock Screen, check Emergency Call Page existence, and
- * remove password for Lock Screen
- * @throws InterruptedException, IOException, RemoteException
- */
- @LargeTest
- public void testEmergencyCall() throws InterruptedException, IOException, RemoteException {
- if (!mABvtHelper.isTablet()) {
- setScreenLock(PASSWORD, "Password");
- sleepAndWakeUpDevice();
- checkEmergencyCall();
- unlockScreen(PASSWORD);
- removeScreenLock(PASSWORD);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- Assert.assertFalse("Lock Screen is still enabled", isLockScreenEnabled());
- }
- }
-
- /**
- * Just lock the screen and slide up to unlock
- * @throws InterruptedException, IOException, RemoteException
- */
- @LargeTest
- public void testSlideUnlock() throws InterruptedException, IOException, RemoteException {
- sleepAndWakeUpDevice();
- mDevice.wait(Until.findObject(
- By.res(mABvtHelper.SYSTEMUI_PACKAGE, "notification_stack_scroller")), 2000)
- .swipe(Direction.UP, 1.0f);
- int counter = 6;
- Thread.sleep(LONG_TIMEOUT);
- UiObject2 workspace = mDevice
- .wait(Until.findObject(By.clazz("com.android.launcher3.Workspace")), LONG_TIMEOUT);
- assertNotNull("Workspace wasn't found", workspace);
- }
-
- /**
- * Verify Camera can be launched on LockScreen
- * @throws InterruptedException, IOException, RemoteException
- */
- public void testLaunchCameraOnLockScreen()
- throws InterruptedException, IOException, RemoteException {
- setScreenLock(Integer.toString(PIN), "PIN");
- sleepAndWakeUpDevice();
- try {
- launchCameraOnLockScreen();
- } finally {
- mDevice.pressHome();
- mDevice.waitForIdle();
- unlockScreen(Integer.toString(PIN));
- removeScreenLock(Integer.toString(PIN));
- }
- }
-
- /**
- * Test photo can be captured on lockscreen
- * @throws InterruptedException, IOException, RemoteException
- */
- public void testCapturePhotoOnLockScreen()
- throws InterruptedException, IOException, RemoteException {
- setScreenLock(Integer.toString(PIN), "PIN");
- sleepAndWakeUpDevice();
- try {
- int prevPhotoCount = getPhotoVideoCount("jpg");
- launchCameraOnLockScreen();
- mCameraHelper.goToCameraMode();
- mCameraHelper.capturePhoto();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- assertTrue("", (prevPhotoCount + 1) == getPhotoVideoCount("jpg"));
- } finally {
- mDevice.pressHome();
- mDevice.waitForIdle();
- unlockScreen(Integer.toString(PIN));
- removeScreenLock(Integer.toString(PIN));
- }
- }
-
- /**
- * Test video can be recorded on lockscreen
- * @throws InterruptedException, IOException, RemoteException
- */
- public void testCaptureVideoOnLockScreen()
- throws InterruptedException, IOException, RemoteException {
- setScreenLock(Integer.toString(PIN), "PIN");
- sleepAndWakeUpDevice();
- try {
- int prevVideoCount = getPhotoVideoCount("mp4");
- launchCameraOnLockScreen();
- mCameraHelper.goToVideoMode();
- // Capture video for time equal to LONG_TIMEOUT
- mCameraHelper.captureVideo((long) mABvtHelper.LONG_TIMEOUT);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- assertTrue("", (prevVideoCount + 1) == getPhotoVideoCount("mp4"));
- } finally {
- mDevice.pressHome();
- mDevice.waitForIdle();
- unlockScreen(Integer.toString(PIN));
- removeScreenLock(Integer.toString(PIN));
- }
- }
-
- /**
- * Test only photos taken from lock screen are visible to user, not all photos
- * @throws InterruptedException, IOException, RemoteException
- */
- public void testPhotosTakenOnLockscreenOnlyVisible()
- throws InterruptedException, IOException, RemoteException {
- populatePhotoInDCIM();
- setScreenLock(Integer.toString(PIN), "PIN");
- sleepAndWakeUpDevice();
- try {
- launchCameraOnLockScreen();
- mCameraHelper.goToCameraMode();
- mCameraHelper.capturePhoto();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- // Find Photo/Video viewer in bottom control panel and click to view photo taken
- mDevice.wait(
- Until.findObject(By.res(mABvtHelper.CAMERA2_PACKAGE, "rounded_thumbnail_view")),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // Ensure image view loaded and image detail icon is present
- assertTrue("Photos detail icon isn't found", mDevice.wait(Until.hasObject(
- By.res(mABvtHelper.CAMERA2_PACKAGE, "filmstrip_bottom_control_details")),
- mABvtHelper.LONG_TIMEOUT));
-
- swipePhotoVideoLeft();
- // As only photos taken in lock screen are visible
- // After swiping left there shouldn't be any photo
- // Hence, Image_Detail icon should be absent
- assertFalse("Photos taken from lockscreen can't be viewed",
- mDevice.wait(Until.hasObject(
- By.res(mABvtHelper.CAMERA2_PACKAGE,
- "filmstrip_bottom_control_details")),
- mABvtHelper.LONG_TIMEOUT));
- } finally {
- mDevice.pressHome();
- mDevice.waitForIdle();
- unlockScreen(Integer.toString(PIN));
- removeScreenLock(Integer.toString(PIN));
- }
- }
-
- /**
- * Test only videoss taken from lock screen are visible to user, not all videos
- * @throws InterruptedException, IOException, RemoteException
- */
- public void testVideoTakenOnLockscreenOnlyVisible()
- throws InterruptedException, IOException, RemoteException {
- populatePhotoInDCIM();
- setScreenLock(Integer.toString(PIN), "PIN");
- sleepAndWakeUpDevice();
- try {
- launchCameraOnLockScreen();
- mCameraHelper.goToVideoMode();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // Capture video for time equal to LONG_TIMEOUT
- mCameraHelper.captureVideo((long) mABvtHelper.LONG_TIMEOUT);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- mDevice.wait(
- Until.findObject(By.res(mABvtHelper.CAMERA2_PACKAGE, "rounded_thumbnail_view")),
- mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- // Ensure video_play_button is present
- assertTrue("Video taken from lockscreen can't be viewed",
- mDevice.wait(
- Until.hasObject(By.res(mABvtHelper.CAMERA2_PACKAGE, "play_button")),
- mABvtHelper.LONG_TIMEOUT));
- swipePhotoVideoLeft();
- // As only videos taken in lock screen are visible
- // After swiping left there shouldn't be any video
- // Hence, video_play_button should be absent
- assertFalse("",
- mDevice.wait(
- Until.hasObject(By.res(mABvtHelper.CAMERA2_PACKAGE, "play_button")),
- mABvtHelper.LONG_TIMEOUT));
- } finally {
- mDevice.pressHome();
- mDevice.waitForIdle();
- unlockScreen(Integer.toString(PIN));
- removeScreenLock(Integer.toString(PIN));
- }
- }
-
- /*
- * Tap on lock icon on Lockscreenc camera prompts for lock screen After successful unlock,camera
- * opens in Camera Mode
- * @throws InterruptedException, IOException, RemoteException
- */
- public void testLockIconCameraOpensCameraAfterUnlock()
- throws InterruptedException, IOException, RemoteException {
- setScreenLock(Integer.toString(PIN), "PIN");
- sleepAndWakeUpDevice();
- try {
- launchCameraOnLockScreen();
- mCameraHelper.goToCameraMode();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- mDevice.wait(
- Until.findObject(By.res(mABvtHelper.CAMERA2_PACKAGE, "rounded_thumbnail_view")),
- mABvtHelper.LONG_TIMEOUT).click();
- mDevice.wait(
- Until.hasObject(By.res("com.android.systemui:id/keyguard_security_container")),
- mABvtHelper.LONG_TIMEOUT);
- unlockScreen(Integer.toString(PIN));
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- List<AccessibilityWindowInfo> windows = InstrumentationRegistry.getInstrumentation()
- .getUiAutomation().getWindows();
- AccessibilityWindowInfo window = windows.get(1);
- assertTrue("Camera isn't active window",
- window.getRoot().getPackageName().equals(mABvtHelper.CAMERA_PACKAGE));
-
- removeScreenLock(Integer.toString(PIN));
- } finally {
- mDevice.pressHome();
- mDevice.waitForIdle();
- if (isLockScreenEnabled()) {
- unlockScreen(Integer.toString(PIN));
- removeScreenLock(Integer.toString(PIN));
- }
- }
- }
-
- private void launchCameraOnLockScreen() {
- int w = mDevice.getDisplayWidth();
- int h = mDevice.getDisplayHeight();
- // Load camera on LockScreen and take a photo
- mDevice.drag((w - 25), (h - 25), (int) (w * 0.5), (int) (w * 0.5), 40);
- mDevice.waitForIdle();
- assertTrue("Camera isn't lauched on lockScreen", mDevice.wait(Until.hasObject(
- By.res(mABvtHelper.CAMERA2_PACKAGE, "activity_root_view")),
- mABvtHelper.LONG_TIMEOUT));
- }
-
- private int getPhotoVideoCount(String ext) {
- File path = Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_DCIM);
- File cameraFolder = new File(String.format("%s/Camera", path));
- File[] files = cameraFolder.listFiles();
- int count = 0;
- if (files != null) {
- for (File f : files) {
- if (f.isFile() && f.getName().endsWith(String.format("%s", ext))) {
- count++;
- }
- }
- }
- return count;
- }
-
- private void swipePhotoVideoLeft() throws InterruptedException {
- // Swipe the image left to view next one, if there is any
- int w = mDevice.getDisplayWidth();
- int h = mDevice.getDisplayHeight();
- mDevice.drag((int) (w * 0.9), (int) (h * 0.5), (int) (w * 0.1), (int) (w * 0.5), 50);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
-
- }
-
- private void populatePhotoInDCIM() throws InterruptedException {
- // Ensure that DCIM folder has either a photo/video
- if (getPhotoVideoCount("jpg") == 0) {
- mCameraHelper.open();
- mCameraHelper.dismissInitialDialogs();
- mCameraHelper.capturePhoto();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- assertTrue("DCIM dir doesn't have any photo/video", getPhotoVideoCount("jpg") > 0);
- }
- }
-
- /**
- * Sets the screen lock pin or password
- * @param pwd text of Password or Pin for lockscreen
- * @param mode indicate if its password or PIN
- */
- private void setScreenLock(String pwd, String mode) throws InterruptedException {
- navigateToScreenLock();
- mDevice.wait(Until.findObject(By.text(mode)), mABvtHelper.LONG_TIMEOUT).click();
- // set up Secure start-up page
- if (!mIsNexusDevice) {
- mDevice.wait(Until.findObject(By.text("No thanks")), mABvtHelper.LONG_TIMEOUT).click();
- }
- UiObject2 pinField = mDevice.wait(Until.findObject(By.clazz(EDIT_TEXT_CLASS_NAME)),
- mABvtHelper.LONG_TIMEOUT);
- pinField.setText(pwd);
- // enter and verify password
- mDevice.pressEnter();
- pinField.setText(pwd);
- mDevice.pressEnter();
- mDevice.wait(Until.findObject(By.text("DONE")), mABvtHelper.LONG_TIMEOUT).click();
- }
-
- /**
- * check if Emergency Call page exists
- */
- private void checkEmergencyCall() throws InterruptedException {
- mDevice.pressMenu();
- mDevice.wait(Until.findObject(By.text("EMERGENCY")), mABvtHelper.LONG_TIMEOUT).click();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- UiObject2 dialButton = mDevice.wait(Until.findObject(By.desc("dial")),
- mABvtHelper.LONG_TIMEOUT);
- Assert.assertNotNull("Can't reach emergency call page", dialButton);
- mDevice.pressBack();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- }
-
- private void removeScreenLock(String pwd) throws InterruptedException {
- navigateToScreenLock();
- UiObject2 pinField = mDevice.wait(Until.findObject(By.clazz(EDIT_TEXT_CLASS_NAME)),
- mABvtHelper.LONG_TIMEOUT);
- pinField.setText(pwd);
- mDevice.pressEnter();
- mDevice.wait(Until.findObject(By.text("Swipe")), mABvtHelper.LONG_TIMEOUT).click();
- mDevice.wait(Until.findObject(By.text("YES, REMOVE")), mABvtHelper.LONG_TIMEOUT).click();
- }
-
- private void unlockScreen(String pwd) throws InterruptedException, IOException {
- swipeUp();
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- // enter password to unlock screen
- String command = String.format(" %s %s %s", "input", "text", pwd);
- mDevice.executeShellCommand(command);
- mDevice.waitForIdle();
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- mDevice.pressEnter();
- }
-
- private void navigateToScreenLock() throws InterruptedException {
- launchSettingsPage(mContext, Settings.ACTION_SECURITY_SETTINGS);
- mDevice.wait(Until.findObject(By.text("Screen lock")), mABvtHelper.LONG_TIMEOUT).click();
- }
-
- private void launchSettingsPage(Context ctx, String pageName) throws InterruptedException {
- Intent intent = new Intent(pageName);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- ctx.startActivity(intent);
- Thread.sleep(mABvtHelper.LONG_TIMEOUT * 2);
- }
-
- private void sleepAndWakeUpDevice() throws RemoteException, InterruptedException {
- mDevice.sleep();
- Thread.sleep(mABvtHelper.LONG_TIMEOUT);
- mDevice.wakeUp();
- }
-
- private void swipeUp() throws InterruptedException {
- mDevice.swipe(mDevice.getDisplayWidth() / 2, mDevice.getDisplayHeight(),
- mDevice.getDisplayWidth() / 2, 0, 30);
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- }
-
- private boolean isLockScreenEnabled() {
- KeyguardManager km = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
- return km.isKeyguardSecure();
- }
-} \ No newline at end of file
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysUIMultiUserTests.java b/tests/androidbvt/src/com/android/androidbvt/SysUIMultiUserTests.java
deleted file mode 100644
index 2f78d44c8..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysUIMultiUserTests.java
+++ /dev/null
@@ -1,127 +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.androidbvt;
-
-import android.app.UiAutomation;
-import android.content.Context;
-import android.os.Environment;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import junit.framework.TestCase;
-
-public class SysUIMultiUserTests extends TestCase {
- private final String TEST_USER = "test";
- private UiAutomation mUiAutomation = null;
- private UiDevice mDevice;
- private Context mContext = null;
- private AndroidBvtHelper mABvtHelper = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mDevice.setOrientationNatural();
- mContext = InstrumentationRegistry.getTargetContext();
- mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext, mUiAutomation);
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- /**
- * Following test creates a second user and verifies user created
- */
- @LargeTest
- public void testMultiUserCreate() throws InterruptedException, IOException {
- int secondUserId = -1;
- List<String> cmdOut;
- try {
- // Ensure there are exactly 1 user
- assertTrue("There aren't exactly 1 user", mABvtHelper.getUserCount() == 1);
- secondUserId = mABvtHelper.createSecondaryUser(TEST_USER);
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- assertTrue("There aren't exactly 2 users", mABvtHelper.getUserCount() == 2);
- assertEquals("Second User id doesn't match", mABvtHelper.getSecondaryUserId(),
- secondUserId);
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT);
- } finally {
- if (secondUserId != -1) {
- mABvtHelper.removeSecondaryUser(secondUserId);
- }
- }
- }
-
- /**
- * Test ensures Second user shows up in QS panel
- */
- public void testSecondUSerIconShowsUpInUserSettings() {
- int secondUserId = -1;
- try {
- secondUserId = mABvtHelper.createSecondaryUser(TEST_USER);
- mDevice.openQuickSettings();
- mDevice.waitForIdle();
- mDevice.wait(Until.findObject(By.res("com.android.systemui:id/multi_user_avatar")),
- mABvtHelper.SHORT_TIMEOUT)
- .clickAndWait(Until.newWindow(), mABvtHelper.LONG_TIMEOUT);
- assertTrue("", mDevice.wait(
- Until.hasObject(By.res("com.android.systemui:id/user_name").text(TEST_USER)),
- mABvtHelper.LONG_TIMEOUT));
- } finally {
- if (secondUserId != -1) {
- mABvtHelper.removeSecondaryUser(secondUserId);
- }
- }
- }
-
- /**
- * Test ensures owner has no access to second user's dir
- */
- public void testPrimaryUserHasNoAccessToSecondUserData() {
- int secondUserId = -1;
- try {
- secondUserId = mABvtHelper.createSecondaryUser(TEST_USER);
- // Ensure owner has no access to second user's directory
- final File myPath = Environment.getExternalStorageDirectory();
- final int myId = android.os.Process.myUid() / 100000;
- final File basePath = myPath.getParentFile();
- assertEquals(String.valueOf(myId), myPath.getName());
- for (int i = 0; i < 128; i++) {
- if (i == myId) {
- continue;
- }
-
- final File otherPath = new File(basePath, String.valueOf(i));
- assertNull("Owner have access to other user's resources!", otherPath.list());
- assertFalse("Owner can read other user's content!", otherPath.canRead());
- }
- } finally {
- if (secondUserId != -1) {
- mABvtHelper.removeSecondaryUser(secondUserId);
- }
- }
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysUIMultiWindowTests.java b/tests/androidbvt/src/com/android/androidbvt/SysUIMultiWindowTests.java
deleted file mode 100644
index 87b2724bd..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysUIMultiWindowTests.java
+++ /dev/null
@@ -1,188 +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.androidbvt;
-
-import android.app.UiAutomation;
-import android.content.Context;
-import android.content.Intent;
-import android.os.RemoteException;
-import android.platform.test.annotations.HermeticTest;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.KeyEvent;
-import android.view.accessibility.AccessibilityWindowInfo;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import junit.framework.TestCase;
-import android.util.Log;
-
-@HermeticTest
-public class SysUIMultiWindowTests extends TestCase {
- private UiAutomation mUiAutomation = null;
- private UiDevice mDevice;
- private Context mContext = null;
- private AndroidBvtHelper mABvtHelper = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mContext = InstrumentationRegistry.getTargetContext();
- mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext, mUiAutomation);
- mDevice.setOrientationNatural();
- mDevice.pressMenu();
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- mDevice.pressHome();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * Following test ensures any app can be docked from full-screen to split-screen, another can be
- * launched to multiwindow mode and finally, initial app can be brought back to full-screen
- */
- @LargeTest
- public void testLaunchInMultiwindow() throws InterruptedException, RemoteException {
- mABvtHelper.launchPackage(mABvtHelper.CALCULATOR_PACKAGE);
- int taskId = mABvtHelper.getTaskIdForActivity(mABvtHelper.CALCULATOR_PACKAGE,
- mABvtHelper.CALCULATOR_ACTIVITY);
- try {
- // Convert calculator to multiwindow mode
- mABvtHelper.changeWindowMode(taskId, mABvtHelper.SPLITSCREEN);
- // Launch settings and ensure it is active window
- mABvtHelper.launchPackage(mABvtHelper.SETTINGS_PACKAGE);
- List<AccessibilityWindowInfo> windows = mUiAutomation.getWindows();
- AccessibilityWindowInfo window = windows.get(windows.size() - 1);
- assertTrue("Settings isn't active window",
- window.getRoot().getPackageName().equals(mABvtHelper.SETTINGS_PACKAGE));
-
- // Calculate midpoint for Calculator window, click, ensure Calculator is in other half
- // of window
- mDevice.click(mDevice.getDisplayHeight() / 4, mDevice.getDisplayWidth() / 2);
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT * 2);
- windows = mUiAutomation.getWindows();
- window = windows.get(windows.size() - 2);
- assertTrue("Calcualtor isn't active window",
- window.getRoot().getPackageName().equals(mABvtHelper.CALCULATOR_PACKAGE));
-
- // Make Calculator FullWindow again and ensure Settings package isn't found on window
- mABvtHelper.changeWindowMode(taskId, mABvtHelper.FULLSCREEN);
- windows = mUiAutomation.getWindows();
- for (int i = 0; i < windows.size() && windows.get(i).getRoot() != null; ++i) {
- assertFalse("Settings have been found",
- windows.get(i).getRoot().getPackageName()
- .equals(mABvtHelper.SETTINGS_PACKAGE));
- }
- } finally {
- mABvtHelper.changeWindowMode(taskId, mABvtHelper.FULLSCREEN);
- mDevice.pressHome();
- }
- }
-
- /**
- * Tests apps do not loose focus and are still visible when apps are launched in MW and
- * landscape mode,
- */
- @LargeTest
- public void testMultiwindowInLandscapeMode() throws InterruptedException, RemoteException {
- // Launch calculator in full screen
- mABvtHelper.launchPackage(mABvtHelper.CALCULATOR_PACKAGE);
- int taskId = mABvtHelper.getTaskIdForActivity(mABvtHelper.CALCULATOR_PACKAGE,
- mABvtHelper.CALCULATOR_ACTIVITY);
- try {
- // Convert calculator to multiwindow mode
- mABvtHelper.changeWindowMode(taskId, mABvtHelper.SPLITSCREEN);
- // Launch Settings
- mABvtHelper.launchPackage(mABvtHelper.SETTINGS_PACKAGE);
- mDevice.setOrientationLeft();
- // Ensure calculator on left
- mDevice.click(mDevice.getDisplayHeight() / 4, mDevice.getDisplayWidth() / 2);
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT * 2);
- List<AccessibilityWindowInfo> windows = mUiAutomation.getWindows();
- AccessibilityWindowInfo window = windows.get(windows.size() - 2);
- assertTrue("Calcualtor isn't left active window",
- window.getRoot().getPackageName().equals(mABvtHelper.CALCULATOR_PACKAGE));
-
- // Ensure Settings on right
- mDevice.click((3 * mDevice.getDisplayHeight()) / 4, mDevice.getDisplayWidth() / 2);
- Thread.sleep(mABvtHelper.SHORT_TIMEOUT * 2);
- windows = mUiAutomation.getWindows();
- window = windows.get(windows.size() - 1);
- assertTrue("Settings isn't right active window",
- window.getRoot().getPackageName().equals(mABvtHelper.SETTINGS_PACKAGE));
- } finally {
- mABvtHelper.changeWindowMode(taskId, mABvtHelper.FULLSCREEN);
- mDevice.pressHome();
- }
- }
-
- /**
- * Ensure recents show up in MW mode
- */
- @LargeTest
- public void testRecentsInMultiWindowMode() throws InterruptedException, RemoteException {
- mABvtHelper.clearRecents();
- // Launch few packages to populate recents
- mABvtHelper.launchPackage(mABvtHelper.SETTINGS_PACKAGE);
- mABvtHelper.launchPackage(mABvtHelper.DESKCLOCK_PACKAGE);
- mABvtHelper.launchPackage(mABvtHelper.CALCULATOR_PACKAGE);
- int taskId = mABvtHelper.getTaskIdForActivity(mABvtHelper.CALCULATOR_PACKAGE,
- mABvtHelper.CALCULATOR_ACTIVITY);
- try {
- // Convert calculator to multiwindow mode
- mABvtHelper.changeWindowMode(taskId, mABvtHelper.SPLITSCREEN);
- assertTrue("Recents view not loaded after sending foreground calc app to split screen",
- mDevice.wait(
- Until.hasObject(By.res(mABvtHelper.SYSTEMUI_PACKAGE, "recents_view")),
- mABvtHelper.LONG_TIMEOUT));
- // Verify recents has Settings and clock
- List<String> expectedAppsInRecents = new ArrayList<String>();
- expectedAppsInRecents.add("Clock");
- expectedAppsInRecents.add("Settings");
- List<String> actualAppsInRecents = new ArrayList<String>();
- List<UiObject2> recentsObjects = mDevice.wait(
- Until.findObjects(By.res(mABvtHelper.SYSTEMUI_PACKAGE, "title")),
- mABvtHelper.LONG_TIMEOUT);
- for (UiObject2 recent : recentsObjects) {
- String appName = recent.getText();
- Log.i(mABvtHelper.TEST_TAG, "Apps in Recents" + appName);
- actualAppsInRecents.add(appName);
- }
- expectedAppsInRecents.removeAll(actualAppsInRecents);
- assertTrue("Expected recents apps doesn't match with actual",
- expectedAppsInRecents.size() == 0);
- // Change window mode to full screen
- mABvtHelper.changeWindowMode(taskId, mABvtHelper.FULLSCREEN);
- mDevice.waitForIdle();
- } finally {
- // Ensure nothing in recents
- mABvtHelper.clearRecents();
- mDevice.pressHome();
- }
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysUINotificationShadeTests.java b/tests/androidbvt/src/com/android/androidbvt/SysUINotificationShadeTests.java
deleted file mode 100644
index a56e01517..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/SysUINotificationShadeTests.java
+++ /dev/null
@@ -1,280 +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.androidbvt;
-
-import android.app.IntentService;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.RemoteInput;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Handler;
-import android.platform.test.annotations.HermeticTest;
-import android.service.notification.StatusBarNotification;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.view.KeyEvent;
-import android.view.inputmethod.InputMethodManager;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.util.Log;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.Toast;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import junit.framework.TestCase;
-
-@HermeticTest
-public class SysUINotificationShadeTests extends TestCase {
- private static final String LOG_TAG = SysUINotificationShadeTests.class.getSimpleName();
- private static final int SHORT_TIMEOUT = 200;
- private static final int LONG_TIMEOUT = 2000;
- private static final int GROUP_NOTIFICATION_ID = 1;
- private static final int CHILD_NOTIFICATION_ID = 100;
- private static final int SECOND_CHILD_NOTIFICATION_ID = 101;
- private static final int NOTIFICATION_ID_2 = 2;
- private static final String KEY_QUICK_REPLY_TEXT = "quick_reply";
- private static final String INLINE_REPLY_TITLE = "INLINE REPLY TITLE";
- private static final String RECEIVER_PKG_NAME = "com.android.systemui";
- private static final String BUNDLE_GROUP_KEY = "group key ";
- private UiDevice mDevice = null;
- private Context mContext;
- private NotificationManager mNotificationManager;
- private ContentResolver mResolver;
- private AndroidBvtHelper mABvtHelper = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mContext = InstrumentationRegistry.getTargetContext();
- mResolver = mContext.getContentResolver();
- mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
- InstrumentationRegistry.getInstrumentation().getUiAutomation());
- mDevice.setOrientationNatural();
- mNotificationManager = (NotificationManager) mContext
- .getSystemService(Context.NOTIFICATION_SERVICE);
- mDevice.pressHome();
- mNotificationManager.cancelAll();
- }
-
- @Override
- public void tearDown() throws Exception {
- mNotificationManager.cancelAll();
- mDevice.pressHome();
- mDevice.unfreezeRotation();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- /**
- * Following test will create notifications, and verify notification can be expanded and
- * redacted
- */
- @LargeTest
- public void testNotifications() throws Exception {
- // test receive notification and expand/redact notification
- verifyReceiveAndExpandRedactNotification();
- // test inline notification and dismiss notification
- verifyInlineAndDimissNotification();
- }
-
- private void verifyReceiveAndExpandRedactNotification() throws Exception {
- List<Integer> lists = new ArrayList<Integer>(Arrays.asList(GROUP_NOTIFICATION_ID,
- CHILD_NOTIFICATION_ID, SECOND_CHILD_NOTIFICATION_ID));
- sendBundlingNotifications(lists, BUNDLE_GROUP_KEY);
- Thread.sleep(LONG_TIMEOUT);
- swipeDown();
- UiObject2 obj = mDevice.wait(
- Until.findObject(By.textContains(lists.get(1).toString())),
- LONG_TIMEOUT);
- int currentY = obj.getVisibleCenter().y;
- mDevice.wait(Until.findObject(By.res("android:id/expand_button")), LONG_TIMEOUT * 2)
- .click();
- obj = mDevice.wait(Until.findObject(By.textContains(lists.get(0).toString())),
- LONG_TIMEOUT);
- assertFalse("The notifications has not been bundled",
- obj.getVisibleCenter().y == currentY);
- mDevice.wait(Until.findObject(By.res("android:id/expand_button")), LONG_TIMEOUT).click();
- obj = mDevice.wait(Until.findObject(By.textContains(lists.get(1).toString())),
- LONG_TIMEOUT);
- assertTrue("The notifications can not be redacted",
- obj.getVisibleCenter().y == currentY);
- mNotificationManager.cancelAll();
- }
-
- private void verifyInlineAndDimissNotification() throws Exception {
- sendNotificationsWithInLineReply(NOTIFICATION_ID_2, INLINE_REPLY_TITLE);
- Thread.sleep(LONG_TIMEOUT);
- mDevice.openNotification();
- mDevice.wait(Until.findObject(By.text("REPLY")), LONG_TIMEOUT).click();
- UiObject2 replyBox = mDevice.wait(
- Until.findObject(By.res(RECEIVER_PKG_NAME, "remote_input_send")),
- LONG_TIMEOUT);
- InputMethodManager imm = (InputMethodManager) mContext
- .getSystemService(Context.INPUT_METHOD_SERVICE);
- if (!imm.isAcceptingText()) {
- assertNotNull("Keyboard for inline reply has not loaded correctly", replyBox);
- }
- // make the IME down
- mDevice.pressKeyCode(KeyEvent.KEYCODE_BACK);
- UiObject2 obj = mDevice.wait(Until.findObject(By.text(INLINE_REPLY_TITLE)),
- LONG_TIMEOUT);
- obj.swipe(Direction.LEFT, 1.0f);
- Thread.sleep(LONG_TIMEOUT);
- if (checkNotificationExistence(NOTIFICATION_ID_2)) {
- fail(String.format("Notification %s has not been dismissed", NOTIFICATION_ID_2));
- }
- }
-
- /**
- * send out a group of notifications
- * @param lists notification list for a group of notifications which includes two child
- * notifications and one summary notification
- * @param groupKey the group key of group notification
- */
- private void sendBundlingNotifications(List<Integer> lists, String groupKey) throws Exception {
- Notification childNotification = new Notification.Builder(mContext)
- .setContentTitle(lists.get(1).toString())
- .setSmallIcon(R.drawable.stat_notify_email)
- .setContentText("test1")
- .setWhen(System.currentTimeMillis())
- .setGroup(groupKey)
- .build();
- mNotificationManager.notify(lists.get(1),
- childNotification);
- childNotification = new Notification.Builder(mContext)
- .setContentTitle(lists.get(2).toString())
- .setContentText("test2")
- .setSmallIcon(R.drawable.stat_notify_email)
- .setWhen(System.currentTimeMillis())
- .setGroup(groupKey)
- .build();
- mNotificationManager.notify(lists.get(2),
- childNotification);
- Notification notification = new Notification.Builder(mContext)
- .setContentTitle(lists.get(0).toString())
- .setSubText(groupKey)
- .setSmallIcon(R.drawable.stat_notify_email)
- .setGroup(groupKey)
- .setGroupSummary(true)
- .build();
- mNotificationManager.notify(lists.get(0),
- notification);
- }
-
- /**
- * send out a notification with inline reply
- *
- * @param notificationId An identifier for this notification
- * @param title notification title
- */
- private void sendNotificationsWithInLineReply(int notificationId, String title) {
- Notification.Action action = new Notification.Action.Builder(
- R.drawable.stat_notify_email, "Reply", ToastService.getPendingIntent(mContext,
- title))
- .addRemoteInput(new RemoteInput.Builder(KEY_QUICK_REPLY_TEXT)
- .setLabel("Quick reply").build())
- .build();
- Notification.Builder n = new Notification.Builder(mContext)
- .setContentTitle(Integer.toString(notificationId))
- .setContentText(title)
- .setWhen(System.currentTimeMillis())
- .setSmallIcon(R.drawable.stat_notify_email)
- .addAction(action)
- .setPriority(Notification.PRIORITY_HIGH)
- .setDefaults(Notification.DEFAULT_VIBRATE);
- mNotificationManager.notify(notificationId, n.build());
- }
-
- private boolean checkNotificationExistence(int id) throws Exception {
- boolean isFound = false;
- for (int tries = 3; tries-- > 0;) {
- isFound = false;
- StatusBarNotification[] sbns = mNotificationManager.getActiveNotifications();
- for (StatusBarNotification sbn : sbns) {
- if (sbn.getId() == id) {
- isFound = true;
- break;
- }
- }
- if (isFound) {
- break;
- }
- Thread.sleep(SHORT_TIMEOUT);
- }
- Log.i(LOG_TAG, "checkNotificationExistence..." + isFound);
- return isFound;
- }
-
- private void swipeDown() throws Exception {
- mDevice.swipe(mDevice.getDisplayWidth() / 2, 0, mDevice.getDisplayWidth() / 2,
- mDevice.getDisplayHeight() / 2 + 50, 20);
- Thread.sleep(SHORT_TIMEOUT);
- }
-
- public static class ToastService extends IntentService {
- private static final String TAG = "ToastService";
- private static final String ACTION_TOAST = "toast";
- private Handler handler;
-
- public ToastService() {
- super(TAG);
- }
-
- public ToastService(String name) {
- super(name);
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- handler = new Handler();
- return super.onStartCommand(intent, flags, startId);
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- if (intent.hasExtra("text")) {
- final String text = intent.getStringExtra("text");
- handler.post(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(ToastService.this, text, Toast.LENGTH_LONG).show();
- Log.v(TAG, "toast " + text);
- }
- });
- }
- }
-
- public static PendingIntent getPendingIntent(Context context, String text) {
- Intent toastIntent = new Intent(context, ToastService.class);
- toastIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- toastIntent.setAction(ACTION_TOAST + ":" + text); // one per toast message
- toastIntent.putExtra("text", text);
- PendingIntent pi = PendingIntent.getService(
- context, 58, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
- return pi;
- }
- }
-}
diff --git a/tests/androidbvt/src/com/android/androidbvt/app/MediaPlaybackTestApp.java b/tests/androidbvt/src/com/android/androidbvt/app/MediaPlaybackTestApp.java
deleted file mode 100644
index bfb239bf1..000000000
--- a/tests/androidbvt/src/com/android/androidbvt/app/MediaPlaybackTestApp.java
+++ /dev/null
@@ -1,40 +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.androidbvt.app;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-
-import com.android.androidbvt.R;
-
-public class MediaPlaybackTestApp extends Activity {
-
- private SurfaceView mSurfaceView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.surface_view);
- mSurfaceView = (SurfaceView)findViewById(R.id.surface_view);
- }
-
- public SurfaceHolder getSurfaceHolder() {
- return mSurfaceView.getHolder();
- }
-}
diff --git a/tests/functional/app-helper/Android.mk b/tests/functional/app-helper/Android.mk
deleted file mode 100644
index d752473b4..000000000
--- a/tests/functional/app-helper/Android.mk
+++ /dev/null
@@ -1,26 +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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-LOCAL_PACKAGE_NAME := AppHelperTests
-LOCAL_STATIC_JAVA_LIBRARIES := first-party-app-helpers ub-uiautomator android-support-test
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_PACKAGE)
diff --git a/tests/functional/app-helper/AndroidManifest.xml b/tests/functional/app-helper/AndroidManifest.xml
deleted file mode 100644
index 5db714393..000000000
--- a/tests/functional/app-helper/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright (c) 2016 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="android.platform.test.helpers.tests">
- <uses-sdk android:minSdkVersion="23"
- android:targetSdkVersion="23" />
- <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
- <uses-permission android:name="android.permission.GET_ACCOUNTS_PRIVILEGED" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.platform.test.helpers.tests"
- android:label="App Helper Tests"/>
-</manifest>
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/BaseHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/BaseHelperTest.java
deleted file mode 100644
index 6b8fae910..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/BaseHelperTest.java
+++ /dev/null
@@ -1,71 +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 android.platform.test.helpers.tests;
-
-import android.app.ActivityManager;
-import android.content.Context;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.UiDevice;
-
-import org.junit.After;
-import org.junit.Before;
-
-import android.os.RemoteException;
-
-public abstract class BaseHelperTest {
- protected ActivityManager mActivityManager;
- protected UiDevice mDevice;
-
- @Before
- public void setOrientation() throws RemoteException {
- getDevice().setOrientationNatural();
- }
-
- @Before
- public void clearAppData() {
- try {
- getActivityManager().clearApplicationUserData(getHelper().getPackage(), null);
- } catch (UnsupportedOperationException e) {
- // ignore
- }
- }
-
- @After
- public void unsetOrientation() throws RemoteException {
- getDevice().unfreezeRotation();
- }
-
- protected ActivityManager getActivityManager() {
- if (mActivityManager == null) {
- Context context = InstrumentationRegistry.getContext();
- mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
- }
-
- return mActivityManager;
- }
-
- protected UiDevice getDevice() {
- if (mDevice == null) {
- mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- }
-
- return mDevice;
- }
-
- protected abstract IStandardAppHelper getHelper();
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/ChromeHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/ChromeHelperTest.java
deleted file mode 100644
index ff81746fa..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/ChromeHelperTest.java
+++ /dev/null
@@ -1,94 +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 android.platform.test.helpers.tests;
-
-import android.platform.test.helpers.ChromeHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.Direction;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class ChromeHelperTest extends BaseHelperTest {
- private ChromeHelperImpl mHelper;
-
- public ChromeHelperTest () {
- mHelper = new ChromeHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- public void testOpenUrl() {
- mHelper.dismissInitialDialogs();
- mHelper.openUrl("news.google.com");
- }
-
- @Test
- public void testFlingPage() {
- mHelper.dismissInitialDialogs();
- mHelper.openUrl("news.google.com");
- mHelper.flingPage(Direction.DOWN);
- }
-
- @Test
- @Ignore("Not critical for testing.")
- public void testOpenMenu() {
- mHelper.dismissInitialDialogs();
- mHelper.openUrl("news.google.com");
- mHelper.openMenu();
- }
-
- @Test
- @Ignore("Not critical for testing.")
- public void testMergeTabs() {
- mHelper.dismissInitialDialogs();
- mHelper.openUrl("news.google.com");
- mHelper.mergeTabs();
- }
-
- @Test
- @Ignore("Not critical for testing.")
- public void testUnmergeTabs() {
- mHelper.dismissInitialDialogs();
- mHelper.openUrl("news.google.com");
- mHelper.mergeTabs();
- mHelper.unmergeTabs();
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/GmailHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/GmailHelperTest.java
deleted file mode 100644
index 43afb56f8..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/GmailHelperTest.java
+++ /dev/null
@@ -1,137 +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 android.platform.test.helpers.tests;
-
-import android.platform.test.helpers.GmailHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.Direction;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class GmailHelperTest extends BaseHelperTest {
- private GmailHelperImpl mHelper;
-
- public GmailHelperTest () {
- mHelper = new GmailHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- public void testGoToPrimaryInbox() {
- mHelper.dismissInitialDialogs();
- mHelper.goToPrimary();
- }
-
- @Test
- public void testScrollInbox() {
- mHelper.dismissInitialDialogs();
- mHelper.goToPrimary();
- mHelper.scrollMailbox(Direction.DOWN, 1.0f, false);
- }
-
- @Test
- public void testGoToComposeEmail() {
- mHelper.dismissInitialDialogs();
- mHelper.goToPrimary();
- mHelper.goToComposeEmail();
- }
-
- @Test
- public void testSendComposeEmail() {
- mHelper.dismissInitialDialogs();
- mHelper.goToPrimary();
- mHelper.goToComposeEmail();
- mHelper.setEmailToAddress("app.helper.test.01@gmail.com");
- mHelper.setEmailSubject("Gmail Helper Test");
- mHelper.setEmailBody("Success!");
- mHelper.clickSendButton();
- }
-
- @Test
- public void testOpenEmailByIndex() {
- mHelper.dismissInitialDialogs();
- mHelper.goToPrimary();
- mHelper.openEmailByIndex(mHelper.getVisibleEmailCount() - 1);
- }
-
- @Test
- public void testScrollEmail() {
- mHelper.dismissInitialDialogs();
- mHelper.goToPrimary();
- mHelper.openEmailByIndex(0);
- mHelper.scrollEmail(Direction.DOWN, 3.0f, true);
- }
-
- @Test
- public void testSendReplyEmail() {
- mHelper.dismissInitialDialogs();
- mHelper.goToPrimary();
- mHelper.openEmailByIndex(0);
- mHelper.sendReplyEmail("app.helper.test.01@gmail.com", "Reply!");
- }
-
- @Test
- public void testReturnToMailbox() {
- mHelper.dismissInitialDialogs();
- mHelper.goToPrimary();
- mHelper.openEmailByIndex(0);
- mHelper.returnToMailbox();
- }
-
- @Test
- public void testOpenNavigationDrawer() {
- mHelper.dismissInitialDialogs();
- mHelper.openNavigationDrawer();
- }
-
- @Test
- public void testCloseNavigationDrawer() {
- mHelper.dismissInitialDialogs();
- mHelper.openNavigationDrawer();
- mHelper.closeNavigationDrawer();
- }
-
- @Test
- public void testScrollNavigationDrawer() {
- mHelper.dismissInitialDialogs();
- mHelper.openNavigationDrawer();
- mHelper.scrollNavigationDrawer(Direction.DOWN);
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleCameraHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleCameraHelperTest.java
deleted file mode 100644
index 15fd0337c..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleCameraHelperTest.java
+++ /dev/null
@@ -1,117 +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 android.platform.test.helpers.tests;
-
-import android.platform.test.helpers.GoogleCameraHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class GoogleCameraHelperTest extends BaseHelperTest {
- private GoogleCameraHelperImpl mHelper;
-
- public GoogleCameraHelperTest () {
- mHelper = new GoogleCameraHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- public void testGoToVideoMode() {
- mHelper.dismissInitialDialogs();
- mHelper.goToVideoMode();
- }
-
- @Test
- public void testGoToCameraMode() {
- mHelper.dismissInitialDialogs();
- mHelper.goToVideoMode();
- mHelper.goToCameraMode();
- }
-
- @Test
- public void testWaitForCameraShutterEnabled() {
- mHelper.dismissInitialDialogs();
- mHelper.waitForCameraShutterEnabled();
- }
-
- @Test
- public void testWaitForVideoShutterEnabled() {
- mHelper.dismissInitialDialogs();
- mHelper.goToVideoMode();
- mHelper.waitForVideoShutterEnabled();
- }
-
- @Test
- public void testCapturePhoto() {
- mHelper.dismissInitialDialogs();
- mHelper.waitForCameraShutterEnabled();
- mHelper.capturePhoto();
- }
-
- @Test
- public void testCaptureVideo() {
- mHelper.dismissInitialDialogs();
- mHelper.goToVideoMode();
- mHelper.waitForVideoShutterEnabled();
- mHelper.captureVideo(5000);
- }
-
- @Test
- @Ignore("Not supported by all devices.")
- public void testSetHdrMode_AUTO() {
- mHelper.dismissInitialDialogs();
- mHelper.setHdrMode(GoogleCameraHelperImpl.HDR_MODE_AUTO);
- }
-
- @Test
- @Ignore("Not supported by all devices.")
- public void testSetHdrMode_OFF() {
- mHelper.dismissInitialDialogs();
- mHelper.setHdrMode(GoogleCameraHelperImpl.HDR_MODE_OFF);
- }
-
- @Test
- @Ignore("Not supported by all devices.")
- public void testSetHdrMode_ON() {
- mHelper.dismissInitialDialogs();
- mHelper.setHdrMode(GoogleCameraHelperImpl.HDR_MODE_ON);
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleKeyboardHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleKeyboardHelperTest.java
deleted file mode 100644
index a4d73da63..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleKeyboardHelperTest.java
+++ /dev/null
@@ -1,91 +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 android.platform.test.helpers.tests;
-
-import android.app.Instrumentation;
-import android.os.SystemClock;
-import android.platform.test.helpers.GoogleKeyboardHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.UiDevice;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import junit.framework.Assert;
-
-public class GoogleKeyboardHelperTest extends BaseHelperTest {
- private GoogleKeyboardHelperImpl mHelper;
- private UiDevice mDevice;
-
- public GoogleKeyboardHelperTest () {
- Instrumentation instr = InstrumentationRegistry.getInstrumentation();
- mHelper = new GoogleKeyboardHelperImpl(instr);
- mDevice = UiDevice.getInstance(instr);
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @After
- public void after() {
- mDevice.pressHome();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- // Sleep reduces flakiness after clearing state
- SystemClock.sleep(5000);
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- @Ignore("Flaky, and not critical test functionality.")
- public void testWaitForKeyboard_False() {
- // Sleep reduces flakiness after clearing state
- SystemClock.sleep(5000);
- mHelper.dismissInitialDialogs();
- mHelper.exit();
- Assert.assertFalse("Method didn't return false waiting for the keyboard",
- mHelper.waitForKeyboard(2500));
- }
-
- @Test
- @Ignore("Flaky, and not critical test functionality.")
- public void testWaitForKeyboard_True() {
- // Sleep reduces flakiness after clearing state
- SystemClock.sleep(5000);
- mHelper.dismissInitialDialogs();
- Assert.assertTrue("Method didn't return true waiting for the keyboard",
- mHelper.waitForKeyboard(2500));
- }
-
- @Test
- @Ignore("Flaky, and not critical test functionality.")
- public void testTypeText() {
- // Sleep reduces flakiness after clearing state
- SystemClock.sleep(5000);
- mHelper.dismissInitialDialogs();
- mHelper.waitForKeyboard(2500);
- mHelper.typeText("abcd efgh", 250);
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/MapsHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/MapsHelperTest.java
deleted file mode 100644
index 2d268883c..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/MapsHelperTest.java
+++ /dev/null
@@ -1,88 +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 android.platform.test.helpers.tests;
-
-import android.platform.test.helpers.MapsHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class MapsHelperTest extends BaseHelperTest {
- private MapsHelperImpl mHelper;
-
- public MapsHelperTest () {
- mHelper = new MapsHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- public void testDoSearch() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("golden gate bridge");
- }
-
- @Test
- @Ignore("Not supported for all devices.")
- public void testGetDirections() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("golden gate bridge");
- mHelper.getDirections();
- }
-
- @Test
- @Ignore("Not supported for all devices.")
- public void testStartNavigation() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("golden gate bridge");
- mHelper.getDirections();
- mHelper.startNavigation();
- }
-
- @Test
- @Ignore("Not supported for all devices.")
- public void testStopNavigation() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("golden gate bridge");
- mHelper.getDirections();
- mHelper.startNavigation();
- mHelper.stopNavigation();
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayMoviesHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayMoviesHelperTest.java
deleted file mode 100644
index f5ac42baa..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayMoviesHelperTest.java
+++ /dev/null
@@ -1,67 +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 android.platform.test.helpers.tests;
-
-import android.platform.test.helpers.PlayMoviesHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class PlayMoviesHelperTest extends BaseHelperTest {
- private PlayMoviesHelperImpl mHelper;
-
- public PlayMoviesHelperTest () {
- mHelper = new PlayMoviesHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- public void testOpenMoviesTab() {
- mHelper.dismissInitialDialogs();
- mHelper.openMoviesTab();
- }
-
- @Test
- public void testPlayMovie() {
- mHelper.dismissInitialDialogs();
- mHelper.openMoviesTab();
- mHelper.playMovie("Dangerous");
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayMusicHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayMusicHelperTest.java
deleted file mode 100644
index 85ceecbcb..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayMusicHelperTest.java
+++ /dev/null
@@ -1,67 +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 android.platform.test.helpers.tests;
-
-import android.platform.test.helpers.PlayMusicHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class PlayMusicHelperTest extends BaseHelperTest {
- private PlayMusicHelperImpl mHelper;
-
- public PlayMusicHelperTest () {
- mHelper = new PlayMusicHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- public void testGoToSongsTab() {
- mHelper.dismissInitialDialogs();
- mHelper.goToTab("Songs");
- }
-
- @Test
- public void testShuffleAllSongs() {
- mHelper.dismissInitialDialogs();
- mHelper.goToTab("Songs");
- mHelper.pressShuffleAll();
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayStoreHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayStoreHelperTest.java
deleted file mode 100644
index ac83250d8..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/PlayStoreHelperTest.java
+++ /dev/null
@@ -1,93 +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 android.platform.test.helpers.tests;
-
-import android.platform.test.helpers.PlayStoreHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import junit.framework.Assert;
-
-public class PlayStoreHelperTest extends BaseHelperTest {
- private PlayStoreHelperImpl mHelper;
-
- public PlayStoreHelperTest () {
- mHelper = new PlayStoreHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- public void testDoSearch() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("pokemon go");
- }
-
- @Test
- public void testSelectFirstResult() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("translate");
- mHelper.selectFirstResult();
- }
-
- @Test
- public void testIsAppInstalled_False() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("pokemon go");
- mHelper.selectFirstResult();
- Assert.assertFalse("Search result was installed.", mHelper.isAppInstalled());
- }
-
- @Test
- public void testIsAppInstalled_True() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("youtube");
- mHelper.selectFirstResult();
- Assert.assertTrue("Search result was not installed.", mHelper.isAppInstalled());
- }
-
- @Test
- public void testInstallApp() {
- mHelper.dismissInitialDialogs();
- mHelper.doSearch("subway surfers");
- mHelper.selectFirstResult();
- mHelper.installApp();
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/RecentsHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/RecentsHelperTest.java
deleted file mode 100644
index e1deaf4ed..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/RecentsHelperTest.java
+++ /dev/null
@@ -1,72 +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 android.platform.test.helpers.tests;
-
-import android.app.Instrumentation;
-import android.platform.test.helpers.ChromeHelperImpl;
-import android.platform.test.helpers.GoogleCameraHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.platform.test.helpers.RecentsHelperImpl;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class RecentsHelperTest extends BaseHelperTest {
- private RecentsHelperImpl mHelper;
- private UiDevice mDevice;
-
- public RecentsHelperTest () {
- Instrumentation instr = InstrumentationRegistry.getInstrumentation();
- mHelper = new RecentsHelperImpl(instr);
- mDevice = UiDevice.getInstance(instr);
-
- GoogleCameraHelperImpl cameraHelper = new GoogleCameraHelperImpl(instr);
- ChromeHelperImpl chromeHelper = new ChromeHelperImpl(instr);
- // Populate the recent apps screen
- cameraHelper.open();
- mDevice.pressHome();
- chromeHelper.open();
- mDevice.pressHome();
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testFlingRecents() {
- mHelper.flingRecents(Direction.UP);
- mDevice.waitForIdle();
- mHelper.flingRecents(Direction.DOWN);
- }
-}
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/YouTubeHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/YouTubeHelperTest.java
deleted file mode 100644
index c3e24eae5..000000000
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/YouTubeHelperTest.java
+++ /dev/null
@@ -1,67 +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 android.platform.test.helpers.tests;
-
-import android.platform.test.helpers.YouTubeHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.support.test.InstrumentationRegistry;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class YouTubeHelperTest extends BaseHelperTest {
- private YouTubeHelperImpl mHelper;
-
- public YouTubeHelperTest () {
- mHelper = new YouTubeHelperImpl(InstrumentationRegistry.getInstrumentation());
- }
-
- @Override
- protected IStandardAppHelper getHelper() {
- return mHelper;
- }
-
- @Before
- public void before() {
- mHelper.open();
- }
-
- @After
- public void after() {
- mHelper.exit();
- }
-
- @Test
- public void testDismissInitialDialogs() {
- mHelper.dismissInitialDialogs();
- }
-
- @Test
- public void testGoToHomePage() {
- mHelper.dismissInitialDialogs();
- mHelper.goToHomePage();
- }
-
- @Test
- public void testPlayHomePageVideo() {
- mHelper.dismissInitialDialogs();
- mHelper.goToHomePage();
- mHelper.playHomePageVideo();
- }
-}
diff --git a/tests/functional/externalstorage/Android.mk b/tests/functional/externalstorage/Android.mk
deleted file mode 100644
index 89c6ab62a..000000000
--- a/tests/functional/externalstorage/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := launcher-helper-lib ub-uiautomator first-party-app-helpers
-
-LOCAL_PACKAGE_NAME := ExternalStorageFunctionalTests
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/tests/functional/externalstorage/AndroidManifest.xml b/tests/functional/externalstorage/AndroidManifest.xml
deleted file mode 100644
index 8230fc312..000000000
--- a/tests/functional/externalstorage/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 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.functional.externalstoragetests">
-
- <uses-sdk android:minSdkVersion="19"
- 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.test.InstrumentationTestRunner"
- android:targetPackage="com.android.functional.externalstoragetests"
- android:label="External Storage Functional Tests" />
-</manifest> \ No newline at end of file
diff --git a/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/AdoptableStorageTests.java b/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/AdoptableStorageTests.java
deleted file mode 100644
index 84d18e22b..000000000
--- a/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/AdoptableStorageTests.java
+++ /dev/null
@@ -1,215 +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.functional.externalstoragetests;
-
-import android.app.UiAutomation;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.provider.Settings;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class AdoptableStorageTests extends InstrumentationTestCase {
- private UiDevice mDevice = null;
- private Context mContext = null;
- private UiAutomation mUiAutomation = null;
- private ExternalStorageHelper storageHelper;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mContext = getInstrumentation().getContext();
- mUiAutomation = getInstrumentation().getUiAutomation();
- storageHelper = ExternalStorageHelper.getInstance(mDevice, mContext, mUiAutomation,
- getInstrumentation());
- mDevice.setOrientationNatural();
- }
-
- /**
- * Tests external storage adoption and move data later flow via UI
- */
- @LargeTest
- public void testAdoptAsAdoptableMoveDataLaterUIFlow() throws InterruptedException {
- // ensure there is a storage to be adopted
- storageHelper.partitionDisk("public");
- initiateAdoption();
- Pattern pattern = Pattern.compile("Move later", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Next", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT).clickAndWait(
- Until.newWindow(), storageHelper.TIMEOUT);
- pattern = Pattern.compile("Done", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT).clickAndWait(
- Until.newWindow(), storageHelper.TIMEOUT);
- assertNotNull(storageHelper.getAdoptionVolumeId("private"));
- // ensure data dirs have not moved
- Intent intent = new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(intent);
- mDevice.wait(Until.findObject(By.textContains("SD card")), 2 * storageHelper.TIMEOUT)
- .clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- assertTrue(mDevice.wait(Until.hasObject(By.res("android:id/title").text("Apps")),
- storageHelper.TIMEOUT));
- }
-
- // Adoptable storage settings
- /**
- * tests to ensure that adoptable storage has setting options rename, eject, format as portable
- */
- @LargeTest
- public void testAdoptableOverflowSettings() throws InterruptedException {
- storageHelper.partitionDisk("private");
- storageHelper.openSDCard();
- Pattern pattern = Pattern.compile("More options", Pattern.CASE_INSENSITIVE);
- UiObject2 moreOptions = mDevice.wait(Until.findObject(By.desc(pattern)),
- storageHelper.TIMEOUT);
- assertNotNull("Over flow menu options shouldn't be null", moreOptions);
- moreOptions.click();
- pattern = Pattern.compile("Rename", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.text(pattern)), storageHelper.TIMEOUT));
- pattern = Pattern.compile("Eject", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.text(pattern)), storageHelper.TIMEOUT));
- pattern = Pattern.compile("Format as portable", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.text(pattern)), storageHelper.TIMEOUT));
- }
-
- /**
- * tests to ensure that adoptable storage can be renamed
- */
- @LargeTest
- public void testRenameAdoptable() throws InterruptedException {
- storageHelper.partitionDisk("private");
- storageHelper.openSDCard();
- Pattern pattern = Pattern.compile("More options", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.desc(pattern)), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Rename", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT).click();
- mDevice.wait(Until.findObject(By.res(storageHelper.SETTINGS_PKG, "edittext")),
- storageHelper.TIMEOUT).setText("My SD card");
- pattern = Pattern.compile("Save", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT).clickAndWait(
- Until.newWindow(), storageHelper.TIMEOUT);
- assertTrue(mDevice.wait(Until.hasObject(By.text("My SD card")), storageHelper.TIMEOUT));
- }
-
- /**
- * tests to ensure that adoptable storage can be ejected
- */
- @LargeTest
- public void testEjectAdoptable() throws InterruptedException {
- storageHelper.partitionDisk("private");
- storageHelper.openSDCard();
- Pattern pattern = Pattern.compile("More options", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.desc(pattern)), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Eject", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT).click();
- assertTrue(mDevice.wait(Until.hasObject(By.res(storageHelper.SETTINGS_PKG, "body")),
- storageHelper.TIMEOUT));
- mDevice.wait(Until.findObject(By.res(storageHelper.SETTINGS_PKG, "confirm").text(pattern)),
- storageHelper.TIMEOUT).clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- pattern = Pattern.compile("Ejected", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.res("android:id/summary").text(pattern)),
- storageHelper.TIMEOUT));
- mDevice.wait(Until.findObject(By.textContains("SD card")), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Mount", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.res("android:id/button1").text(pattern)),
- 2 * storageHelper.TIMEOUT).clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- }
-
- /**
- * tests to ensure that adoptable storage can be formated back as portable from settings
- */
- @LargeTest
- public void testFormatAdoptableAsPortable() throws InterruptedException {
- storageHelper.partitionDisk("private");
- storageHelper.openSDCard();
- Pattern pattern = Pattern.compile("More options", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.desc(pattern)), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Format as portable", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT)
- .clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- mDevice.wait(Until.hasObject(
- By.textContains("After formatting, you can use this")), storageHelper.TIMEOUT);
- mDevice.wait(Until.findObject(By.text("FORMAT")), 2 * storageHelper.TIMEOUT)
- .clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- pattern = Pattern.compile("Done", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), 5 * storageHelper.TIMEOUT)
- .clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- }
-
- public void initiateAdoption() throws InterruptedException {
- storageHelper.openSdCardSetUpNotification().clickAndWait(Until.newWindow(),
- storageHelper.TIMEOUT);
- UiObject2 adoptFlowUi = mDevice.wait(Until.findObject(
- By.res(storageHelper.SETTINGS_PKG, "storage_wizard_init_internal_title")),
- storageHelper.TIMEOUT);
- adoptFlowUi.click();
- Pattern pattern = Pattern.compile("NEXT", Pattern.CASE_INSENSITIVE);
- adoptFlowUi = mDevice.wait(Until.findObject(
- By.res(storageHelper.SETTINGS_PKG, "suw_navbar_next").text(pattern)),
- storageHelper.TIMEOUT);
- adoptFlowUi.clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- pattern = Pattern.compile("ERASE & FORMAT", Pattern.CASE_INSENSITIVE);
- adoptFlowUi = mDevice.wait(Until.findObject(By.text(pattern)),
- storageHelper.TIMEOUT);
- adoptFlowUi.clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- adoptFlowUi = mDevice.wait(
- Until.findObject(By.res(storageHelper.SETTINGS_PKG, "storage_wizard_progress")),
- storageHelper.TIMEOUT);
- assertNotNull(adoptFlowUi);
- if ((mDevice.wait(Until.findObject(By.res("android:id/message")),
- 60 * storageHelper.TIMEOUT)) != null) {
- mDevice.wait(Until.findObject(By.text("OK")), storageHelper.TIMEOUT).clickAndWait(
- Until.newWindow(), storageHelper.TIMEOUT);
- }
- }
-
- /**
- * System apps can't be moved to adopted storage
- */
- @LargeTest
- public void testTransferSystemApp() throws InterruptedException, NameNotFoundException {
- storageHelper.partitionDisk("private");
- storageHelper.executeShellCommand("pm move-package " + storageHelper.SETTINGS_PKG + " "
- + storageHelper.getAdoptionVolumeId("private"));
- assertTrue(storageHelper.getInstalledLocation(storageHelper.SETTINGS_PKG)
- .startsWith("/data/user_de/0"));
- }
-
- @Override
- protected void tearDown() throws Exception {
- // Convert sdcard to public
- storageHelper.executeShellCommand(String.format("sm partition %s %s",
- storageHelper.getAdoptionDisk(), "public"));
- Thread.sleep(storageHelper.TIMEOUT);
- storageHelper.executeShellCommand("sm forget all");
- Thread.sleep(storageHelper.TIMEOUT);
- // move back to homescreen
- mDevice.unfreezeRotation();
- mDevice.pressBack();
- mDevice.pressHome();
- super.tearDown();
- }
-}
diff --git a/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/ExternalStorageHelper.java b/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/ExternalStorageHelper.java
deleted file mode 100644
index 9a67ea44a..000000000
--- a/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/ExternalStorageHelper.java
+++ /dev/null
@@ -1,288 +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.functional.externalstoragetests;
-
-import android.app.Instrumentation;
-import android.app.UiAutomation;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.ParcelFileDescriptor;
-import android.os.StatFs;
-import android.os.SystemClock;
-import android.provider.Settings;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-import android.platform.test.helpers.PlayStoreHelperImpl;
-
-import junit.framework.Assert;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class ExternalStorageHelper {
- public static final String TEST_TAG = "StorageFunctionalTest";
- public final String SETTINGS_PKG = "com.android.settings";
- public final String PLAYSTORE_PKG = "com.android.vending";
- public final String DOCUMENTS_PKG = "com.android.documentsui";
- public static final Map<String, String> APPLIST = new HashMap<String, String>();
- static {
- APPLIST.put("w35location1", "com.test.w35location1");
- APPLIST.put("w35location2", "com.test.w35location2");
- APPLIST.put("w35location3", "com.test.w35location3");
- }
- public final int TIMEOUT = 2000;
- public static ExternalStorageHelper mInstance = null;
- public UiDevice mDevice;
- public Context mContext;
- public static UiAutomation mUiAutomation;
- public static Instrumentation mInstrumentation;
- public static Hashtable<String, List<String>> mPermissionGroupInfo = null;
-
- public ExternalStorageHelper(UiDevice device, Context context, UiAutomation uiAutomation,
- Instrumentation instrumentation) {
- mDevice = device;
- mContext = context;
- mUiAutomation = uiAutomation;
- mInstrumentation = instrumentation;
- }
-
- public static ExternalStorageHelper getInstance(UiDevice device, Context context,
- UiAutomation uiAutomation, Instrumentation instrumentation) {
- if (mInstance == null) {
- mInstance = new ExternalStorageHelper(device, context, uiAutomation, instrumentation);
- }
- return mInstance;
- }
-
- /**
- * Opens SD card setup notification from homescreen
- */
- public UiObject2 openSdCardSetUpNotification() throws InterruptedException {
- boolean success = mDevice.openNotification();
- Thread.sleep(TIMEOUT);
- UiObject2 sdCardDetected = mDevice
- .wait(Until.findObject(By.textContains("SD card detected")), TIMEOUT);
- Assert.assertNotNull(sdCardDetected);
- return sdCardDetected;
- }
-
- /**
- * Open Storage settings, then SD Card
- */
- public void openStorageSettings() throws InterruptedException {
- Intent intent = new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(intent);
- Thread.sleep(TIMEOUT * 2);
- }
-
- /**
- * Open Storage settings, then SD Card
- */
- public void openSDCard() throws InterruptedException {
- openStorageSettings();
- mDevice.wait(Until.findObject(By.textContains("SD card")), TIMEOUT)
- .clickAndWait(Until.newWindow(), TIMEOUT);
- }
-
- public String executeShellCommand(String command) {
- ParcelFileDescriptor pfd = mUiAutomation.executeShellCommand(command);
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(new FileInputStream(pfd.getFileDescriptor())))) {
- String str = reader.readLine();
- Log.d(TEST_TAG, String.format("Executing command: %s", command));
- return str;
- } catch (IOException e) {
- Log.e(TEST_TAG, e.getMessage());
- }
-
- return null;
- }
-
- /**
- * Create # of files in a given dir
- */
- public void createFiles(int numberOfFiles, String dir) {
- for (int i = 0; i < numberOfFiles; ++i) {
- if (!new File(String.format("%s/Test_%d", dir, i)).exists()) {
- fillInStorage(dir, String.format("Test_%d", i), 1);
- }
- }
- }
-
- public void fillInStorage(String location, String filename, int sizeInKb) {
- executeShellCommand(String.format("dd if=/dev/zero of=%s/%s bs=1024 count=%d",
- location, filename, sizeInKb));
- }
-
- public int getFreeSpaceSize(File path) {
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long availableBlocks = stat.getAvailableBlocks();
- return (int) ((availableBlocks * blockSize) / (1024 * 1024));
- }
-
- public boolean hasAdoptable() {
- return Boolean.parseBoolean(executeShellCommand("sm has-adoptable").trim());
- }
-
- public String getAdoptionDisk() throws InterruptedException {
- int counter = 10;
- String disks = null;
- while (((disks == null || disks.length() == 0)) && counter > 0) {
- disks = executeShellCommand("sm list-disks adoptable");
- Thread.sleep(TIMEOUT);
- --counter;
- }
- if (counter == 0) {
- throw new AssertionError("Devices must have adoptable media inserted");
- }
- return disks.split("\n")[0].trim();
- }
-
- public Boolean hasPublicVolume() {
- return (null != executeShellCommand("sm list-volumes public"));
- }
-
- public String getAdoptionVolumeId(String volType) throws InterruptedException {
- return getAdoptionVolumeInfo(volType).volId;
- }
-
- public String getAdoptionVolumeUuid(String volType) throws InterruptedException {
- return getAdoptionVolumeInfo(volType).uuid;
- }
-
- public LocalVolumeInfo getAdoptionVolumeInfo(String volType) throws InterruptedException {
- String[] lines = null;
- int attempt = 0;
- while (attempt++ < 5) {
- if (null != (lines = executeShellCommand("sm list-volumes " + volType).split("\n"))) {
- for (String line : lines) {
- final LocalVolumeInfo info = new LocalVolumeInfo(line.trim());
- if (info.volId.startsWith(volType) && "mounted".equals(info.state)) {
- return info;
- }
- }
- Thread.sleep(TIMEOUT);
- }
- }
- return null;
- }
-
- public void partitionDisk(String type) throws InterruptedException {
- if (type.equals("private")) {
- executeShellCommand(String.format("sm partition %s %s", getAdoptionDisk(), type));
- Thread.sleep(2 * TIMEOUT);
- } else if (!hasPublicVolume() && type.equals("public")) {
- executeShellCommand("sm forget all");
- executeShellCommand(String.format("sm partition %s %s", getAdoptionDisk(), type));
- Thread.sleep(2 * TIMEOUT);
- setupAsPortableUiFlow();
- }
- }
-
- public void setupAsPortableUiFlow() throws InterruptedException {
- openSdCardSetUpNotification();
- Thread.sleep(TIMEOUT);
- Pattern pattern = Pattern.compile("Set up", Pattern.CASE_INSENSITIVE);
- UiObject2 adoptFlowUi = mDevice.wait(Until.findObject(By.desc(pattern)), TIMEOUT);
- adoptFlowUi.clickAndWait(Until.newWindow(), TIMEOUT);
- adoptFlowUi = mDevice.wait(Until.findObject(
- By.res(SETTINGS_PKG, "storage_wizard_init_external_title")),
- TIMEOUT);
- adoptFlowUi.click();
- pattern = Pattern.compile("Next", Pattern.CASE_INSENSITIVE);
- adoptFlowUi = mDevice.wait(Until.findObject(By.text(pattern)),
- TIMEOUT);
- adoptFlowUi.clickAndWait(Until.newWindow(), TIMEOUT);
- pattern = Pattern.compile("Done", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), TIMEOUT).clickAndWait(
- Until.newWindow(), TIMEOUT);
- hasPublicVolume();
-
- }
-
- public void installFromPlayStore(String appName) {
- PlayStoreHelperImpl mHelper = new PlayStoreHelperImpl(mInstrumentation);
- mHelper.open();
- mHelper.doSearch(appName);
- mHelper.selectFirstResult();
- mDevice.wait(Until.findObject(By.res(PLAYSTORE_PKG, "buy_button").text("INSTALL")),
- TIMEOUT).clickAndWait(Until.newWindow(), 2 * TIMEOUT);
- SystemClock.sleep(2 * TIMEOUT);
- mDevice.wait(Until.findObject(By.res(PLAYSTORE_PKG, "launch_button").text("OPEN")),
- 5 * TIMEOUT);
- }
-
- public PackageInfo getPackageInfo(String packageName) throws NameNotFoundException {
- return mContext.getPackageManager().getPackageInfo(packageName, 0);
- }
-
- public Boolean doesPackageExist(String packageName) throws NameNotFoundException {
- try {
- mContext.getPackageManager().getPackageInfo(packageName, 0);
- } catch (NameNotFoundException nex) {
- throw nex;
- }
-
- return Boolean.TRUE;
- }
-
- public String getInstalledLocation(String packageName) throws NameNotFoundException {
- Assert.assertTrue(String.format("%s doesn't exist!", packageName),
- doesPackageExist(packageName));
- return getPackageInfo(packageName).applicationInfo.dataDir;
- }
-
- public void settingsUiCleanUp() {
- executeShellCommand("pm clear " + SETTINGS_PKG);
- executeShellCommand("pm clear " + DOCUMENTS_PKG);
- }
-
- private static class LocalVolumeInfo {
- public String volId;
- public String state;
- public String uuid;
-
- public LocalVolumeInfo(String line) {
- final String[] split = line.split(" ");
- volId = split[0];
- state = split[1];
- uuid = split[2];
- }
- }
-
- public PackageManager getPackageManager() {
- return mContext.getPackageManager();
- }
-}
diff --git a/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/PortableStorageTests.java b/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/PortableStorageTests.java
deleted file mode 100644
index 79cdfe228..000000000
--- a/tests/functional/externalstorage/src/com/android/functional/externalstoragetests/PortableStorageTests.java
+++ /dev/null
@@ -1,258 +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.functional.externalstoragetests;
-
-import android.app.UiAutomation;
-import android.content.Context;
-import android.content.Intent;
-import android.provider.Settings;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import junit.framework.Assert;
-
-public class PortableStorageTests extends InstrumentationTestCase {
- private UiDevice mDevice = null;
- private Context mContext = null;
- private UiAutomation mUiAutomation = null;
- private ExternalStorageHelper storageHelper;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mContext = getInstrumentation().getContext();
- mUiAutomation = getInstrumentation().getUiAutomation();
- storageHelper = ExternalStorageHelper.getInstance(mDevice, mContext, mUiAutomation,
- getInstrumentation());
- mDevice.setOrientationNatural();
- }
-
- /**
- * Test to ensure sd card can be adopted as portable storage
- */
- @LargeTest
- public void testAdoptAsPortableViaUI() throws InterruptedException {
- // ensure notification
- storageHelper.executeShellCommand(String.format(
- "sm partition %s %s", storageHelper.getAdoptionDisk(), "public"));
- Thread.sleep(storageHelper.TIMEOUT);
- storageHelper.setupAsPortableUiFlow();
- storageHelper.executeShellCommand(String.format("sm forget all"));
- Thread.sleep(storageHelper.TIMEOUT);
- }
-
- /**
- * tests to ensure copy option is visible for items on portable storage
- */
- @LargeTest
- public void testCopyFromPortable() throws InterruptedException {
- ensureHasPortable();
- storageHelper.createFiles(2,
- String.format("/storage/%s", storageHelper.getAdoptionVolumeUuid("public")));
- storageHelper.openSDCard();
- mDevice.wait(Until.findObject(By.res("android:id/title").text("Test_0")),
- storageHelper.TIMEOUT).click(storageHelper.TIMEOUT);
- mDevice.wait(Until.findObject(By.desc(Pattern.compile("More options",
- Pattern.CASE_INSENSITIVE))), storageHelper.TIMEOUT).click();
- assertNotNull(mDevice.wait(Until.findObject(By.res("android:id/title").text("Copy to…")),
- 2 * storageHelper.TIMEOUT));
- mDevice.wait(Until.findObject(By.res("android:id/title").text("Copy to…")),
- storageHelper.TIMEOUT).clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- mDevice.pressBack();
- }
-
- /**
- * tests to ensure that resources on portable storage can be deleted via UI
- */
- @LargeTest
- public void testDeleteFromPortable() throws InterruptedException {
- ensureHasPortable();
- storageHelper.createFiles(2,
- String.format("/storage/%s", storageHelper.getAdoptionVolumeUuid("public")));
- storageHelper.openSDCard();
- mDevice.wait(Until.findObject(By.res("android:id/title").text("Test_0")),
- storageHelper.TIMEOUT).click(storageHelper.TIMEOUT);
- mDevice.wait(Until.findObject(By.res("com.android.documentsui:id/menu_sort")),
- storageHelper.TIMEOUT).clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- assertNull(mDevice.wait(Until.findObject(By.res("android:id/title").text("Test_0")),
- 2 * storageHelper.TIMEOUT));
- }
-
- /**
- * tests to ensure that external storage is explorable via UI
- */
- @LargeTest
- public void testExplorePortable() throws InterruptedException {
- ensureHasPortable();
- // Create 2 random files on SDCard
- storageHelper.createFiles(2,
- String.format("/storage/%s", storageHelper.getAdoptionVolumeUuid("public")));
- Intent intent = new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(intent);
- Thread.sleep(storageHelper.TIMEOUT * 2);
- mDevice.wait(Until.findObject(By.textContains("SD card")), storageHelper.TIMEOUT)
- .clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- for (int i = 0; i < 2; ++i) {
- Assert.assertTrue(mDevice.wait(Until.hasObject(By.res("android:id/title")
- .text(String.format("Test_%d", i))), storageHelper.TIMEOUT));
- }
- }
-
- /**
- * tests to ensure that resources on portable storage can be shared via UI
- */
- @LargeTest
- public void testShareableFromPortable() throws InterruptedException {
- ensureHasPortable();
- storageHelper.createFiles(2,
- String.format("/storage/%s", storageHelper.getAdoptionVolumeUuid("public")));
- storageHelper.openSDCard();
- mDevice.wait(Until.findObject(By.res("android:id/title").text("Test_0")),
- storageHelper.TIMEOUT).click(storageHelper.TIMEOUT);
- mDevice.wait(Until.findObject(By.res("com.android.documentsui:id/menu_list")),
- storageHelper.TIMEOUT).click();
- assertNotNull(mDevice.wait(Until.findObject(By.res("android:id/resolver_list")),
- storageHelper.TIMEOUT));
- // click and ensure intent is sent to share? or actual share?
- mDevice.pressBack();
- }
-
- /**
- * tests to ensure that portable overflow menu contain all setting options
- */
- @LargeTest
- public void testPortableOverflowSettings() throws InterruptedException {
- ensureHasPortable();
- storageHelper.createFiles(2,
- String.format("/storage/%s", storageHelper.getAdoptionVolumeUuid("public")));
- storageHelper.openSDCard();
- mDevice.wait(Until.findObject(By.res("android:id/title").text("Test_0")),
- storageHelper.TIMEOUT).click(storageHelper.TIMEOUT);
- assertTrue(mDevice.wait(Until.hasObject(By.res(storageHelper.DOCUMENTS_PKG, "menu_search")),
- storageHelper.TIMEOUT));
- assertTrue(mDevice.wait(Until.hasObject(By.res(storageHelper.DOCUMENTS_PKG, "menu_sort")),
- storageHelper.TIMEOUT));
- assertTrue(mDevice.wait(Until.hasObject(By.text("1 selected")), storageHelper.TIMEOUT));
- }
-
- /**
- * tests to ensure that portable storage has setting options format, format as internal, eject
- */
- @LargeTest
- public void testPortableSettings() throws InterruptedException {
- ensureHasPortable();
- storageHelper.openSDCard();
- Pattern pattern = Pattern.compile("More options", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.desc(pattern)), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Storage settings", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT)
- .clickAndWait(
- Until.newWindow(), storageHelper.TIMEOUT);
- pattern = Pattern.compile("Eject", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.text(pattern)), storageHelper.TIMEOUT));
- pattern = Pattern.compile("Format", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.text(pattern)), storageHelper.TIMEOUT));
- pattern = Pattern.compile("Format as internal", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.text(pattern)),
- storageHelper.TIMEOUT));
- }
-
- /**
- * tests to ensure that portable storage can be ejected from settings
- */
- @LargeTest
- public void testEjectPortable() throws InterruptedException {
- ensureHasPortable();
- storageHelper.openStorageSettings();
- mDevice.wait(Until.findObject(By.res(storageHelper.SETTINGS_PKG, "unmount")),
- storageHelper.TIMEOUT).click();
- assertTrue(mDevice.wait(Until.hasObject(By.res("android:id/summary").text("Ejected")),
- 4 * storageHelper.TIMEOUT));
- mDevice.wait(Until.findObject(By.textContains("SD card")), 2 * storageHelper.TIMEOUT)
- .click();
- Pattern pattern = Pattern.compile("Mount", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.res("android:id/button1").text(pattern)),
- 2 * storageHelper.TIMEOUT).clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- ;
- }
-
- /**
- * tests to ensure that portable storage can be erased and formated from settings
- */
- @LargeTest
- public void testFormatPortable() throws InterruptedException {
- ensureHasPortable();
- storageHelper.openSDCard();
- Pattern pattern = Pattern.compile("More options", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.desc(pattern)), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Storage settings", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT)
- .clickAndWait(
- Until.newWindow(), storageHelper.TIMEOUT);
- UiObject2 format = mDevice.wait(Until.findObject(By.text("Format")), storageHelper.TIMEOUT);
- format.clickAndWait(Until.newWindow(), storageHelper.TIMEOUT);
- pattern = Pattern.compile("Erase & Format", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Done", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), 20 * storageHelper.TIMEOUT).click();
- }
-
- /**
- * tests to ensure that portable storage can be erased and formated as internal from settings
- */
- @LargeTest
- public void testFormatPortableAsAdoptable() throws InterruptedException {
- try {
- ensureHasPortable();
- storageHelper.openSDCard();
- Pattern pattern = Pattern.compile("More options", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.desc(pattern)), storageHelper.TIMEOUT).click();
- pattern = Pattern.compile("Storage settings", Pattern.CASE_INSENSITIVE);
- mDevice.wait(Until.findObject(By.text(pattern)), storageHelper.TIMEOUT)
- .clickAndWait(
- Until.newWindow(), storageHelper.TIMEOUT);
- pattern = Pattern.compile("Format", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.text(pattern)), storageHelper.TIMEOUT));
- pattern = Pattern.compile("Format as internal", Pattern.CASE_INSENSITIVE);
- assertTrue(mDevice.wait(Until.hasObject(By.text(pattern)),
- storageHelper.TIMEOUT));
- // Next flow is same as adoption, so no need to test
- } finally {
- storageHelper.partitionDisk("public");
- }
- }
-
- private void ensureHasPortable() throws InterruptedException {
- storageHelper.partitionDisk("public");
- storageHelper.settingsUiCleanUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- mDevice.pressBack();
- mDevice.pressHome();
- super.tearDown();
- }
-}
diff --git a/tests/functional/settingstests/Android.mk b/tests/functional/settingstests/Android.mk
deleted file mode 100644
index 4b373f540..000000000
--- a/tests/functional/settingstests/Android.mk
+++ /dev/null
@@ -1,31 +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.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PACKAGE_NAME := SettingsFunctionalTests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := \
- base-app-helpers \
- launcher-helper-lib \
- services.core \
- settings-app-helper \
- timeresult-helper-lib \
- ub-uiautomator
-
-#LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/tests/functional/settingstests/AndroidManifest.xml b/tests/functional/settingstests/AndroidManifest.xml
deleted file mode 100644
index cbd1bc125..000000000
--- a/tests/functional/settingstests/AndroidManifest.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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="android.settings.functional">
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <uses-sdk android:minSdkVersion="19"
- android:targetSdkVersion="24"/>
-
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
- <uses-permission android:name="android.permission.BLUETOOTH" />
- <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
-
- <instrumentation
- android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="android.settings.functional"
- android:label="Android Settings Functional Tests" />
-</manifest>
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/AboutPhoneSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/AboutPhoneSettingsTests.java
deleted file mode 100644
index 1a6a795b1..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/AboutPhoneSettingsTests.java
+++ /dev/null
@@ -1,217 +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 android.settings.functional;
-
-import android.content.Intent;
-import android.os.RemoteException;
-import android.provider.Settings;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-/** Verifies basic functionality of the About Phone screen */
-public class AboutPhoneSettingsTests extends InstrumentationTestCase {
- private static final boolean LOCAL_LOGV = false;
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final String TAG = "AboutPhoneSettingsTest";
- private static final int TIMEOUT = 2000;
-
- private UiDevice mDevice;
-
- // TODO: retrieve using name/ids from com.android.settings package
- private static final String[] sResourceTexts = {
- "Status",
- "Legal information",
- "Regulatory labels",
- "Model number",
- "Android version",
- "Android security patch level",
- "Baseband version",
- "Kernel version",
- "Build number"
- };
-
- private static final String[] sClickableResourceTexts = {
- "Status", "Legal information", "Regulatory labels",
- };
-
- @Override
- public void setUp() throws Exception {
- if (LOCAL_LOGV) {
- Log.d(TAG, "-------");
- }
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("Failed to freeze device orientaion", e);
- }
-
- // make sure we are in a clean state before starting the test
- mDevice.pressHome();
- Thread.sleep(TIMEOUT * 2);
- launchAboutPhoneSettings(Settings.ACTION_DEVICE_INFO_SETTINGS);
- // TODO: make sure we are always at the top of the app
- // currently this will fail if the user has navigated into submenus
- UiObject2 view =
- mDevice.wait(
- Until.findObject(By.res(SETTINGS_PACKAGE + ":id/main_content")), TIMEOUT);
- assertNotNull("Could not find main About Phone screen", view);
- view.scroll(Direction.UP, 1.0f);
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.pressHome(); // finish settings activity
- mDevice.waitForIdle(TIMEOUT * 2); // give UI time to finish animating
- super.tearDown();
- }
-
- private void launchAboutPhoneSettings(String aboutSetting) throws Exception {
- Intent aboutIntent = new Intent(aboutSetting);
- aboutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(aboutIntent);
- }
-
- /**
- * Callable actions that can be taken when a UIObject2 is found
- *
- * @param device The current UiDevice
- * @param item The UiObject2 that was found and can be acted on
- *
- * @return {@code true} if the call was successful, and {@code false} otherwise
- */
- public interface UIObject2Callback {
- boolean call(UiDevice device, UiObject2 item) throws Exception;
- }
-
- /**
- * Clicks the given item and then presses the Back button
- *
- * <p>Used to test whether a given UiObject2 can be successfully clicked.
- * Presses Back to restore state to the previous screen.
- *
- * @param device The device that can be used to press Back
- * @param item The item to click
- *
- * @return {@code true} if clicking the item succeeded, and {@code false} otherwise
- */
- public class UiObject2Clicker implements UIObject2Callback {
- public boolean call(UiDevice device, UiObject2 item) throws Exception {
- item.click();
- Thread.sleep(TIMEOUT * 2); // give UI time to finish animating
- boolean pressWorked = device.pressBack();
- Thread.sleep(TIMEOUT * 2);
- return pressWorked;
- }
- }
-
- /**
- * Removes items found in the view and optionally takes some action.
- *
- * @param device The current UiDevice
- * @param itemsLeftToFind The items to search for in the current view
- * @param action Action to call on each item that is found; pass {@code null} to take no action
- */
- private void removeItemsAndTakeAction(
- UiDevice device, ArrayList<String> itemsLeftToFind, UIObject2Callback action) throws Exception {
- for (Iterator<String> iterator = itemsLeftToFind.iterator(); iterator.hasNext(); ) {
- String itemText = iterator.next();
- UiObject2 item = device.wait(Until.findObject(By.text(itemText)), TIMEOUT);
- if (item != null) {
- if (LOCAL_LOGV) {
- Log.d(TAG, itemText + " is present");
- }
- iterator.remove();
- if (action != null) {
- boolean success = action.call(device, item);
- assertTrue("Calling action after " + itemText + " did not work", success);
- }
- } else {
- if (LOCAL_LOGV) {
- Log.d(TAG, "Could not find " + itemText);
- }
- }
- }
- }
-
- /**
- * Searches for UI elements in the current view and optionally takes some action.
- *
- * <p>Will scroll down the screen until it has found all elements or reached the bottom.
- * This allows elements to be found and acted on even if they change order.
- *
- * @param device The current UiDevice
- * @param itemsToFind The items to search for in the current view
- * @param action Action to call on each item that is found; pass {@code null} to take no action
- */
- public void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind, UIObject2Callback action)
- throws Exception {
-
- ArrayList<String> itemsLeftToFind = new ArrayList<String>(Arrays.asList(itemsToFind));
- assertFalse(
- "There must be at least one item to search for on the screen!",
- itemsLeftToFind.isEmpty());
-
- if (LOCAL_LOGV) {
- Log.d(TAG, "items: " + TextUtils.join(", ", itemsLeftToFind));
- }
- boolean canScrollDown = true;
- while (canScrollDown && !itemsLeftToFind.isEmpty()) {
- removeItemsAndTakeAction(device, itemsLeftToFind, action);
-
- // when we've finished searching the current view, scroll down
- UiObject2 view =
- device.wait(
- Until.findObject(By.res(SETTINGS_PACKAGE + ":id/main_content")),
- TIMEOUT * 2);
- if (view != null) {
- canScrollDown = view.scroll(Direction.DOWN, 1.0f);
- } else {
- canScrollDown = false;
- }
- }
- // check the last items once we have reached the bottom of the view
- removeItemsAndTakeAction(device, itemsLeftToFind, action);
-
- assertTrue(
- "The following items were not found on the screen: "
- + TextUtils.join(", ", itemsLeftToFind),
- itemsLeftToFind.isEmpty());
- }
-
- @MediumTest // UI interaction
- public void testAllMenuEntriesExist() throws Exception {
- searchForItemsAndTakeAction(mDevice, sResourceTexts, null);
- }
-
- @MediumTest // UI interaction
- public void testClickableEntriesCanBeClicked() throws Exception {
- searchForItemsAndTakeAction(mDevice, sClickableResourceTexts, new UiObject2Clicker());
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/AccessibilitySettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/AccessibilitySettingsTests.java
deleted file mode 100644
index c3a59da07..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/AccessibilitySettingsTests.java
+++ /dev/null
@@ -1,247 +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 android.settings.functional;
-
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.os.RemoteException;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.provider.Settings;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.Suppress;
-
-public class AccessibilitySettingsTests extends InstrumentationTestCase {
-
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final int TIMEOUT = 2000;
- private UiDevice mDevice;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- // Need to finish settings activity
- mDevice.pressBack();
- mDevice.pressHome();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- @MediumTest
- public void testHighContrastTextOn() throws Exception {
- verifyAccessibilitySettingOnOrOff("High contrast text",
- Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0, 1);
- }
-
- @MediumTest
- public void testHighContrastTextOff() throws Exception {
- verifyAccessibilitySettingOnOrOff("High contrast text",
- Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 1, 0);
- }
-
- @MediumTest
- public void testPowerButtonEndsCallOn() throws Exception {
- verifyAccessibilitySettingOnOrOff("Power button ends call",
- Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, 1, 2);
- }
-
- @MediumTest
- public void testPowerButtonEndsCallOff() throws Exception {
- verifyAccessibilitySettingOnOrOff("Power button ends call",
- Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, 2, 1);
- }
-
- /* Suppressing these four tests. The settings don't play
- * nice with Settings.System.putInt or Settings.Secure.putInt.
- * Need further clarification. Filed bug b/27792029
- */
- @Suppress
- @MediumTest
- public void testAutoRotateScreenOn() throws Exception {
- verifyAccessibilitySettingOnOrOff("Auto-rotate screen",
- Settings.System.ACCELEROMETER_ROTATION, 0, 1);
- }
-
- @Suppress
- @MediumTest
- public void testAutoRotateScreenOff() throws Exception {
- verifyAccessibilitySettingOnOrOff("Auto-rotate screen",
- Settings.System.ACCELEROMETER_ROTATION, 1, 0);
- }
-
- @Suppress
- @MediumTest
- public void testMonoAudioOn() throws Exception {
- verifyAccessibilitySettingOnOrOff("Mono audio",
- Settings.System.MASTER_MONO, 0, 1);
- }
-
- @Suppress
- @MediumTest
- public void testMonoAudioOff() throws Exception {
- verifyAccessibilitySettingOnOrOff("Mono audio",
- Settings.System.MASTER_MONO, 1, 0);
- }
-
- @MediumTest
- public void testSpeakPasswordsOn() throws Exception {
- verifyAccessibilitySettingOnOrOff("Speak passwords",
- Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0, 1);
- }
-
- @MediumTest
- public void testSpeakPasswordsOff() throws Exception {
- verifyAccessibilitySettingOnOrOff("Speak passwords",
- Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 1, 0);
- }
-
- @MediumTest
- public void testLargeMousePointerOn() throws Exception {
- verifyAccessibilitySettingOnOrOff("Large mouse pointer",
- Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, 0, 1);
- }
-
- @MediumTest
- public void testLargeMousePointerOff() throws Exception {
- verifyAccessibilitySettingOnOrOff("Large mouse pointer",
- Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, 1, 0);
- }
-
- @MediumTest
- public void testColorCorrection() throws Exception {
- verifySettingToggleAfterScreenLoad("Color correction",
- Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED);
- }
-
- // Suppressing this test, since UiAutomator + talkback don't play nice
- @Suppress
- @MediumTest
- public void testTalkback() throws Exception {
- verifySettingToggleAfterScreenLoad("TalkBack",
- Settings.Secure.ACCESSIBILITY_ENABLED);
- }
-
- @MediumTest
- public void testCaptions() throws Exception {
- verifySettingToggleAfterScreenLoad("Captions",
- Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED);
- }
-
- @MediumTest
- public void testMagnificationGesture() throws Exception {
- verifySettingToggleAfterScreenLoad("Magnification gesture",
- Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
- }
-
- @MediumTest
- public void testClickAfterPointerStopsMoving() throws Exception {
- verifySettingToggleAfterScreenLoad("Click after pointer stops moving",
- Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED);
- }
-
- public void launchAccessibilitySettings() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_ACCESSIBILITY_SETTINGS);
- }
-
- private void verifyAccessibilitySettingOnOrOff(String settingText,
- String settingFlag, int initialFlagValue, int expectedFlagValue) throws Exception {
- Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- settingFlag, initialFlagValue);
- launchAccessibilitySettings();
- UiObject2 settingsTitle = findItemOnScreen(settingText);
- settingsTitle.click();
- Thread.sleep(TIMEOUT);
- int settingValue = Settings.Secure
- .getInt(getInstrumentation().getContext().getContentResolver(), settingFlag);
- assertEquals(settingText + " not correctly set after toggle", expectedFlagValue, settingValue);
- }
-
- private void verifySettingToggleAfterScreenLoad(String settingText, String settingFlag) throws Exception {
- // Load accessibility settings
- launchAccessibilitySettings();
- Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- settingFlag, 0);
- Thread.sleep(TIMEOUT);
- // Tap on setting required
- UiObject2 settingTitle = findItemOnScreen(settingText);
- // Load screen
- settingTitle.click();
- Thread.sleep(TIMEOUT);
- // Toggle value
- UiObject2 settingToggle = mDevice.wait(Until.findObject(By.text("Off")),
- TIMEOUT);
- settingToggle.click();
- dismissOpenDialog();
- Thread.sleep(TIMEOUT);
- // Assert new value
- int settingValue = Settings.Secure.
- getInt(getInstrumentation().getContext().getContentResolver(), settingFlag);
- assertEquals(settingText + " value not set correctly", 1, settingValue);
- // Toogle value
- settingToggle.click();
- dismissOpenDialog();
- mDevice.pressBack();
- Thread.sleep(TIMEOUT);
- // Assert reset to old value
- settingValue = Settings.Secure.
- getInt(getInstrumentation().getContext().getContentResolver(), settingFlag);
- assertEquals(settingText + " value not set correctly", 0, settingValue);
- }
-
- private UiObject2 findItemOnScreen(String item) throws Exception {
- int count = 0;
- UiObject2 settingsPanel = mDevice.wait(Until.findObject
- (By.res(SETTINGS_PACKAGE, "list")), TIMEOUT);
- while (settingsPanel.fling(Direction.UP) && count < 3) {
- count++;
- }
- count = 0;
- UiObject2 setting = null;
- while(count < 3 && setting == null) {
- setting = mDevice.wait(Until.findObject(By.text(item)), TIMEOUT);
- if (setting == null) {
- settingsPanel.scroll(Direction.DOWN, 1.0f);
- }
- count++;
- }
- return setting;
- }
-
- private void dismissOpenDialog() throws Exception {
- UiObject2 okButton = mDevice.wait(Until.findObject
- (By.res("android:id/button1")), TIMEOUT*2);
- if (okButton != null) {
- okButton.click();
- }
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/BluetoothNetworkSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/BluetoothNetworkSettingsTests.java
deleted file mode 100644
index a55fea607..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/BluetoothNetworkSettingsTests.java
+++ /dev/null
@@ -1,160 +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 android.settings.functional;
-
-import java.io.IOException;
-import android.content.Context;
-import android.content.Intent;
-import android.bluetooth.BluetoothManager;
-import android.bluetooth.BluetoothAdapter;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.provider.Settings;
-import android.provider.Settings.SettingNotFoundException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-
-public class BluetoothNetworkSettingsTests extends InstrumentationTestCase {
-
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final int TIMEOUT = 2000;
- private UiDevice mDevice;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.pressBack();
- mDevice.pressHome();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- @MediumTest
- public void testBluetoothEnabled() throws Exception {
- verifyBluetoothOnOrOff(true);
- }
-
- @MediumTest
- public void testBluetoothDisabled() throws Exception {
- verifyBluetoothOnOrOff(false);
- }
-
- @MediumTest
- public void testRefreshOverflowOption() throws Exception {
- verifyBluetoothOverflowOptions("Refresh", false, null);
- }
-
- @MediumTest
- public void testRenameOverflowOption() throws Exception {
- verifyBluetoothOverflowOptions("Rename this device", true, "RENAME");
- }
-
- @MediumTest
- public void testReceivedFilesOverflowOption() throws Exception {
- verifyBluetoothOverflowOptions("Show received files", true, "Bluetooth received");
- }
-
- @MediumTest
- public void testHelpFeedbackOverflowOption() throws Exception {
- verifyBluetoothOverflowOptions("Help & feedback", true, "Help");
- }
-
- public void launchBluetoothSettings() throws Exception {
- Intent btIntent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
- btIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(btIntent);
- Thread.sleep(TIMEOUT * 2);
- }
-
- /**
- * Verifies clicking on the BT overflow option and loading the right screen
- * @param overflowOptionText the text of the option to be clicked
- * @param verifyClick if you need a click to be verified
- * @param optionLoaded text of an element on the post click screen for verification
- */
- public void verifyBluetoothOverflowOptions(String overflowOptionText, boolean verifyClick,
- String optionLoaded) throws Exception {
- BluetoothAdapter bluetoothAdapter = ((BluetoothManager) getInstrumentation().getContext()
- .getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
- bluetoothAdapter.enable();
- launchBluetoothSettings();
- mDevice.wait(Until.findObject(By.desc("More options")), TIMEOUT).click();
- Thread.sleep(TIMEOUT);
- UiObject2 overflowOption = mDevice.wait(Until.findObject(By.text(overflowOptionText)),
- TIMEOUT);
- assertNotNull(overflowOptionText + " option is not present in advanced Bluetooth menu",
- overflowOption);
- if (verifyClick) {
- overflowOption.click();
- // Adding an extra back press to deal with IME+UiAutomator bug
- if (optionLoaded.equals("RENAME")) {
- mDevice.pressBack();
- }
- UiObject2 loadOption = mDevice.wait(Until.findObject(By.text(optionLoaded)), TIMEOUT);
- assertNotNull(overflowOptionText + " option did not load correctly on tapping",
- loadOption);
- }
- }
-
- /**
- * Toggles the Bluetooth switch and verifies that the change is reflected in Settings
- * @param verifyOn set to whether you want the setting turned On or Off
- */
- private void verifyBluetoothOnOrOff(boolean verifyOn) throws Exception {
- String switchText = "ON";
- BluetoothAdapter bluetoothAdapter = ((BluetoothManager) getInstrumentation().getContext()
- .getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
- if (verifyOn) {
- switchText = "OFF";
- bluetoothAdapter.disable();
- }
- else {
- bluetoothAdapter.enable();
- }
- launchBluetoothSettings();
- mDevice.wait(Until
- .findObject(By.res(SETTINGS_PACKAGE, "switch_widget").text(switchText)), TIMEOUT)
- .click();
- Thread.sleep(TIMEOUT);
- String bluetoothValue =
- Settings.Global.getString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.BLUETOOTH_ON);
- if (verifyOn) {
- assertEquals("1", bluetoothValue);
- }
- else {
- assertEquals("0", bluetoothValue);
- }
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/DataUsageSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/DataUsageSettingsTests.java
deleted file mode 100644
index 202264bf3..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/DataUsageSettingsTests.java
+++ /dev/null
@@ -1,84 +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 android.settings.functional;
-
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.os.RemoteException;
-import android.provider.Settings;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-public class DataUsageSettingsTests extends InstrumentationTestCase {
-
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final int TIMEOUT = 2000;
- private UiDevice mDevice;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- // Need to finish settings activity
- mDevice.pressBack();
- mDevice.pressHome();
- super.tearDown();
- }
-
- @MediumTest
- public void testElementsOnDataUsageScreen() throws Exception {
- launchDataUsageSettings();
- assertNotNull("Data usage element not found",
- mDevice.wait(Until.findObject(By.text("Usage")),
- TIMEOUT));
- assertNotNull("Data usage bar not found",
- mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE,
- "color_bar")), TIMEOUT));
- assertNotNull("Data saver element not found",
- mDevice.wait(Until.findObject(By.text("Data saver")),
- TIMEOUT));
- assertNotNull("WiFi Data usage element not found",
- mDevice.wait(Until.findObject(By.text("Wi-Fi data usage")),
- TIMEOUT));
- assertNotNull("Network restrictions element not found",
- mDevice.wait(Until.findObject(By.text("Network restrictions")),
- TIMEOUT));
- }
-
- public void launchDataUsageSettings() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_SETTINGS);
- mDevice.wait(Until
- .findObject(By.text("Data usage")), TIMEOUT)
- .click();
- Thread.sleep(TIMEOUT * 2);
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/DisplaySettingsTest.java b/tests/functional/settingstests/src/com/android/settings/functional/DisplaySettingsTest.java
deleted file mode 100644
index 54653c4ba..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/DisplaySettingsTest.java
+++ /dev/null
@@ -1,267 +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 android.settings.functional;
-
-import android.content.ContentResolver;
-import android.provider.Settings;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.platform.test.helpers.SettingsHelperImpl.SettingsType;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.Suppress;
-
-import java.util.regex.Pattern;
-
-public class DisplaySettingsTest extends InstrumentationTestCase {
-
- private static final String PAGE = Settings.ACTION_DISPLAY_SETTINGS;
- private static final int TIMEOUT = 2000;
- private static final FontSetting FONT_SMALL = new FontSetting("Small", 0.85f);
- private static final FontSetting FONT_NORMAL = new FontSetting("Default", 1.00f);
- private static final FontSetting FONT_LARGE = new FontSetting("Large", 1.15f);
- private static final FontSetting FONT_HUGE = new FontSetting("Largest", 1.30f);
-
- private UiDevice mDevice;
- private ContentResolver mResolver;
- private SettingsHelperImpl mHelper;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mDevice.setOrientationNatural();
- mResolver = getInstrumentation().getContext().getContentResolver();
- mHelper = new SettingsHelperImpl(getInstrumentation());
- }
-
- @Override
- public void tearDown() throws Exception {
- // reset settings we touched that may impact others
- Settings.System.putFloat(mResolver, Settings.System.FONT_SCALE, 1.00f);
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- @MediumTest
- public void testAdaptiveBrightness() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.scrollVert(true);
- Thread.sleep(1000);
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE, "Adaptive brightness",
- Settings.System.SCREEN_BRIGHTNESS_MODE));
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE, "Adaptive brightness",
- Settings.System.SCREEN_BRIGHTNESS_MODE));
- }
-
- @MediumTest
- public void testCameraDoubleTap() throws Exception {
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SECURE, PAGE,
- "Press power button twice for camera",
- Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED));
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SECURE, PAGE,
- "Press power button twice for camera",
- Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED));
- }
-
- @MediumTest
- public void testAmbientDisplay() throws Exception {
- // unique to the ambient display setting, null is equivalent to "on",
- // so we need to populate the setting if it hasn't been yet
- String initialSetting = Settings.Secure.getString(mResolver, Settings.Secure.DOZE_ENABLED);
- if (initialSetting == null) {
- Settings.Secure.putString(mResolver, Settings.Secure.DOZE_ENABLED, "1");
- }
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SECURE, PAGE, "Ambient display",
- Settings.Secure.DOZE_ENABLED));
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SECURE, PAGE, "Ambient display",
- Settings.Secure.DOZE_ENABLED));
- }
-
- // blocked on b/27487224
- @MediumTest
- @Suppress
- public void testDaydreamToggle() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- Pattern p = Pattern.compile("On|Off");
- mHelper.clickSetting("Screen saver");
- Thread.sleep(1000);
- try {
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SECURE, PAGE, p,
- Settings.Secure.SCREENSAVER_ENABLED, false));
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SECURE, PAGE, p,
- Settings.Secure.SCREENSAVER_ENABLED, false));
- } finally {
- mDevice.pressBack();
- }
- }
-
- @MediumTest
- public void testAccelRotation() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.scrollVert(true);
- Thread.sleep(4000);
- String[] buttons = {
- "Rotate the contents of the screen",
- "Stay in portrait view"
- };
- int currentAccelSetting = Settings.System.getInt(
- mResolver, Settings.System.ACCELEROMETER_ROTATION);
- mHelper.scrollVert(false);
- mHelper.clickSetting("When device is rotated");
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
- buttons[currentAccelSetting], Settings.System.ACCELEROMETER_ROTATION, false));
- mHelper.scrollVert(false);
- mHelper.clickSetting("When device is rotated");
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
- buttons[1 - currentAccelSetting], Settings.System.ACCELEROMETER_ROTATION, false));
- }
-
- @MediumTest
- public void testDaydream() throws Exception {
- Settings.Secure.putInt(mResolver, Settings.Secure.SCREENSAVER_ENABLED, 1);
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- try {
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SECURE, PAGE,
- "Screen saver", "Clock", Settings.Secure.SCREENSAVER_COMPONENTS,
- "com.google.android.deskclock/com.android.deskclock.Screensaver"));
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SECURE, PAGE,
- null, "Colors", Settings.Secure.SCREENSAVER_COMPONENTS,
- "com.android.dreams.basic/com.android.dreams.basic.Colors"));
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SECURE, PAGE,
- null, "Photos", Settings.Secure.SCREENSAVER_COMPONENTS,
- "com.google.android.apps.photos/com.google.android.apps.photos.daydream.PhotosDreamService"));
- } finally {
- mDevice.pressBack();
- Thread.sleep(2000);
- }
- }
-
- @MediumTest
- public void testSleep15Seconds() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
- "Sleep", "15 seconds", Settings.System.SCREEN_OFF_TIMEOUT, "15000"));
- }
-
- @MediumTest
- public void testSleep30Seconds() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
- "Sleep", "30 seconds", Settings.System.SCREEN_OFF_TIMEOUT, "30000"));
- }
-
- @MediumTest
- public void testSleep1Minute() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
- "Sleep", "1 minute", Settings.System.SCREEN_OFF_TIMEOUT, "60000"));
- }
-
- @MediumTest
- public void testSleep2Minutes() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
- "Sleep", "2 minutes", Settings.System.SCREEN_OFF_TIMEOUT, "120000"));
- }
-
- @MediumTest
- public void testSleep5Minutes() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
- "Sleep", "5 minutes", Settings.System.SCREEN_OFF_TIMEOUT, "300000"));
- }
-
- @MediumTest
- public void testSleep10Minutes() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
- "Sleep", "10 minutes", Settings.System.SCREEN_OFF_TIMEOUT, "600000"));
- }
-
- @MediumTest
- public void testSleep30Minutes() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
- "Sleep", "30 minutes", Settings.System.SCREEN_OFF_TIMEOUT, "1800000"));
- }
-
- @MediumTest
- public void testFontSizeLarge() throws Exception {
- verifyFontSizeSetting(1.00f, FONT_LARGE);
- // Leaving the font size at large can make later tests fail, so reset it
- Settings.System.putFloat(mResolver, Settings.System.FONT_SCALE, 1.00f);
- // It takes a second for the new font size to be picked up
- Thread.sleep(2000);
- }
-
- @MediumTest
- public void testFontSizeDefault() throws Exception {
- verifyFontSizeSetting(1.15f, FONT_NORMAL);
- }
-
- @MediumTest
- public void testFontSizeLargest() throws Exception {
- verifyFontSizeSetting(1.00f, FONT_HUGE);
- // Leaving the font size at huge can make later tests fail, so reset it
- Settings.System.putFloat(mResolver, Settings.System.FONT_SCALE, 1.00f);
- // It takes a second for the new font size to be picked up
- Thread.sleep(2000);
- }
-
- @MediumTest
- public void testFontSizeSmall() throws Exception {
- verifyFontSizeSetting(1.00f, FONT_SMALL);
- }
-
- private void verifyFontSizeSetting(float resetValue, FontSetting setting)
- throws Exception {
- Settings.System.putFloat(mResolver, Settings.System.FONT_SCALE, resetValue);
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Font size");
- try {
- mDevice.wait(Until.findObject(By.desc(setting.getName())), TIMEOUT).click();
- Thread.sleep(1000);
- float changedValue = Settings.System.getFloat(
- mResolver, Settings.System.FONT_SCALE);
- assertEquals(setting.getSize(), changedValue, 0.0001);
- } finally {
- // Make sure to back out of the font menu
- mDevice.pressBack();
- }
- }
-
- private static class FontSetting {
- private final String mSizeName;
- private final float mSizeVal;
-
- public FontSetting(String sizeName, float sizeVal) {
- mSizeName = sizeName;
- mSizeVal = sizeVal;
- }
-
- public String getName() {
- return mSizeName;
- }
-
- public float getSize() {
- return mSizeVal;
- }
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/LocationSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/LocationSettingsTests.java
deleted file mode 100644
index a6e77bc6e..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/LocationSettingsTests.java
+++ /dev/null
@@ -1,217 +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 android.settings.functional;
-
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.nfc.NfcAdapter;
-import android.nfc.NfcManager;
-import android.os.RemoteException;
-import android.provider.Settings;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-
-public class LocationSettingsTests extends InstrumentationTestCase {
-
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final int TIMEOUT = 2000;
- private UiDevice mDevice;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.pressBack();
- mDevice.pressHome();
- super.tearDown();
- }
-
- @MediumTest
- public void testLoadingLocationSettings () throws Exception {
- // Load settings
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_SETTINGS);
- // Tap on location
- UiObject2 settingsPanel = mDevice.wait(Until.findObject
- (By.res(SETTINGS_PACKAGE, "dashboard_container")), TIMEOUT);
- int count = 0;
- UiObject2 locationTitle = null;
- while(count < 6 && locationTitle == null) {
- locationTitle = mDevice.wait(Until.findObject(By.text("Location")), TIMEOUT);
- if (locationTitle == null) {
- settingsPanel.scroll(Direction.DOWN, 1.0f);
- }
- count++;
- }
- // Verify location settings loads.
- locationTitle.click();
- Thread.sleep(TIMEOUT);
- assertNotNull("Location screen has not loaded correctly",
- mDevice.wait(Until.findObject(By.text("Location services")), TIMEOUT));
- }
-
- @MediumTest
- public void testLocationSettingOn() throws Exception {
- verifyLocationSettingsOnOrOff(true);
- }
-
- @MediumTest
- public void testLocationSettingOff() throws Exception {
- verifyLocationSettingsOnOrOff(false);
- }
-
- @MediumTest
- public void testLocationDeviceOnlyMode() throws Exception {
- // Changing the value from default before testing the toggle to Device only mode
- Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
- Thread.sleep(TIMEOUT);
- verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
- }
-
- @MediumTest
- public void testLocationBatterySavingMode() throws Exception {
- Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
- Thread.sleep(TIMEOUT);
- verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
- }
-
- @MediumTest
- public void testLocationHighAccuracyMode() throws Exception {
- Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
- Thread.sleep(TIMEOUT);
- verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
- }
-
- @MediumTest
- public void testLocationSettingsElements() throws Exception {
- String[] textElements = {"Location", "On", "Mode", "Recent location requests",
- "Location services"};
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_LOCATION_SOURCE_SETTINGS);
- Thread.sleep(TIMEOUT);
- for (String element : textElements) {
- assertNotNull(element + " item not found under Location Settings",
- mDevice.wait(Until.findObject(By.text(element)), TIMEOUT));
- }
- }
-
- @MediumTest
- public void testLocationSettingsOverflowMenuElements() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_LOCATION_SOURCE_SETTINGS);
- // Tap on overflow menu
- mDevice.wait(Until.findObject(By.desc("More options")), TIMEOUT).click();
- // Verify scanning
- assertNotNull("Scanning item not found under Location Settings",
- mDevice.wait(Until.findObject(By.text("Scanning")), TIMEOUT));
- // Verify help & feedback
- assertNotNull("Help & feedback item not found under Location Settings",
- mDevice.wait(Until.findObject(By.text("Help & feedback")), TIMEOUT));
- }
-
- private void verifyLocationSettingsMode(int mode) throws Exception {
- int modeIntValue = 1;
- String textMode = "Device only";
- if (mode == Settings.Secure.LOCATION_MODE_HIGH_ACCURACY) {
- modeIntValue = 3;
- textMode = "High accuracy";
- }
- else if (mode == Settings.Secure.LOCATION_MODE_BATTERY_SAVING) {
- modeIntValue = 2;
- textMode = "Battery saving";
- }
- // Load location settings
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_LOCATION_SOURCE_SETTINGS);
- // Tap on mode
- mDevice.wait(Until.findObject(By.text("Mode")), TIMEOUT).click();
- Thread.sleep(TIMEOUT);
- assertNotNull("Location mode screen not loaded", mDevice.wait(Until.findObject
- (By.text("Location mode")), TIMEOUT));
- // Choose said mode
- mDevice.wait(Until.findObject(By.text(textMode)), TIMEOUT).click();
- Thread.sleep(TIMEOUT);
- if (mode == Settings.Secure.LOCATION_MODE_HIGH_ACCURACY ||
- mode == Settings.Secure.LOCATION_MODE_BATTERY_SAVING) {
- // Expect another dialog here at improving location tracking
- // for the first time
- UiObject2 agreeDialog = mDevice.wait(Until.findObject
- (By.text("Improve location accuracy?")), TIMEOUT);
- if (agreeDialog != null) {
- mDevice.wait(Until.findObject
- (By.text("AGREE")), TIMEOUT).click();
- Thread.sleep(TIMEOUT);
- assertNull("Improve location dialog not dismissed", mDevice.wait(Until.findObject
- (By.text("Improve location accuracy?")), TIMEOUT));
- }
- }
- // get setting and verify value
- // Verify change of mode
- int locationSettingMode =
- Settings.Secure.getInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE);
- assertEquals(mode + " value not set correctly for location.", modeIntValue,
- locationSettingMode);
- }
-
- private void verifyLocationSettingsOnOrOff(boolean verifyOn) throws Exception {
- // Set location flag
- if (verifyOn) {
- Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
- }
- else {
- Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
- }
- // Load location settings
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_LOCATION_SOURCE_SETTINGS);
- // Toggle UI
- mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, "switch_widget")), TIMEOUT).click();
- Thread.sleep(TIMEOUT);
- // Verify change in setting
- int locationEnabled = Settings.Secure.getInt(getInstrumentation()
- .getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE);
- if (verifyOn) {
- assertFalse("Location not enabled correctly", locationEnabled == 0);
- }
- else {
- assertEquals("Location not disabled correctly", 0, locationEnabled);
- }
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/MainSettingsLargeTests.java b/tests/functional/settingstests/src/com/android/settings/functional/MainSettingsLargeTests.java
deleted file mode 100644
index afc4fe133..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/MainSettingsLargeTests.java
+++ /dev/null
@@ -1,114 +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 android.settings.functional;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.provider.Settings;
-import android.provider.Settings.SettingNotFoundException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-import junit.framework.Assert;
-
-public class MainSettingsLargeTests extends InstrumentationTestCase {
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final int TIMEOUT = 2000;
- private static final String PERSONAL_CATEGORY = "Personal";
- private static final String[] sPersonalItems = new String[] {
- "Location", "Security", "Accounts", "Google", "Languages & input", "Backup & reset"
- };
- private static final String SYSTEM_CATEGORY = "System";
- private static final String[] sSystemItems = new String[] {
- "Date & time", "Accessibility", "Printing", "About phone"
- };
- private UiDevice mDevice;
- private Context mContext = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mContext = getInstrumentation().getContext();
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- public void tearDown() throws Exception {
- // Need to finish settings activity
- mDevice.pressHome();
- super.tearDown();
- }
-
- @LargeTest
- public void testPersonalSettingCategory() throws Exception {
- launchMainSettingsCategory(PERSONAL_CATEGORY, sPersonalItems);
- }
-
- @LargeTest
- public void testSystemSettingCategory() throws Exception {
- launchMainSettingsCategory(SYSTEM_CATEGORY, sSystemItems);
- }
-
- private void launchMainSettingsCategory(String category, String[] items) throws Exception {
- launchMainSettings(Settings.ACTION_SETTINGS);
- launchSettingItems(category);
- for (String i : items) {
- launchSettingItems(i);
- Log.d(SETTINGS_PACKAGE, String.format("launch setting: %s", i));
- }
- }
-
- private void launchMainSettings(String mainSetting) throws Exception {
- mDevice.pressHome();
- Intent settingIntent = new Intent(mainSetting);
- settingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(settingIntent);
- Thread.sleep(TIMEOUT * 2);
- }
-
- private void launchSettingItems(String title) throws Exception {
- int maxAttempt = 5;
- UiObject2 item = null;
- UiObject2 view = null;
- while (maxAttempt-- > 0) {
- item = mDevice.wait(Until.findObject(By.res("android:id/title").text(title)), TIMEOUT);
- if (item == null) {
- view = mDevice.wait(
- Until.findObject(By.res(SETTINGS_PACKAGE, "main_content")),
- TIMEOUT);
- view.scroll(Direction.DOWN, 1.0f);
- } else {
- return;
- }
- }
- assertNotNull(String.format("%s in Setting has not been loaded correctly", title), item);
- }
-} \ No newline at end of file
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/MainSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/MainSettingsTests.java
deleted file mode 100644
index eec5f39fe..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/MainSettingsTests.java
+++ /dev/null
@@ -1,158 +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 android.settings.functional;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.provider.Settings;
-import android.provider.Settings.SettingNotFoundException;
-import android.util.Log;
-import android.view.inputmethod.InputMethodManager;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-import junit.framework.Assert;
-
-/** Component test for verifying basic functionality of Main Setting screen */
-public class MainSettingsTests extends InstrumentationTestCase {
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final int TIMEOUT = 2000;
- private static final String WIFI_CATEGORY = "Wireless & networks";
- private static final String[] sWifiItems = new String[] {
- "Wi‑Fi", "Bluetooth", "Data usage", "More"
- };
- private static final String DEVICE_CATEGORY = "Device";
- private static final String[] sDeviceItems = new String[] {
- "Display", "Notifications", "Sound", "Apps", "Storage", "Battery", "Memory",
- "Users"
- };
- private UiDevice mDevice;
- private Context mContext = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mContext = getInstrumentation().getContext();
- mDevice.setOrientationNatural();
- }
-
- @Override
- public void tearDown() throws Exception {
- // Need to finish settings activity
- mDevice.pressHome();
- mDevice.unfreezeRotation();
- mDevice.waitForIdle();
- super.tearDown();
- }
-
- @MediumTest
- public void testLoadSetting() throws Exception {
- launchMainSettings(Settings.ACTION_SETTINGS);
- UiObject2 settingHeading = mDevice.wait(Until.findObject(By.text("Settings")),
- TIMEOUT);
- assertNotNull("Setting menu has not loaded correctly", settingHeading);
- }
-
- @MediumTest
- public void testWifiSettingCategory() throws Exception {
- launchMainSettingsCategory(WIFI_CATEGORY, sWifiItems);
- }
-
- @MediumTest
- public void testDeviceSettingCategory() throws Exception {
- launchMainSettingsCategory(DEVICE_CATEGORY, sDeviceItems);
- }
-
- private void launchMainSettingsCategory(String category, String[] items) throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_SETTINGS);
- launchSettingItems(category);
- for (String i : items) {
- launchSettingItems(i);
- Log.d(SETTINGS_PACKAGE, String.format("launch setting: %s", i));
- }
- UiObject2 mainSettings = mDevice.wait(
- Until.findObject(By.res("com.android.settings:id/main_content")),
- TIMEOUT);
- // Scrolling back up twice so we're at the top of the settings list.
- for ( int i = 0; i < 2; i++) {
- mainSettings.scroll(Direction.UP, 1.0f);
- }
- }
-
- @MediumTest
- public void testSearchSetting() throws Exception {
- launchMainSettings(Settings.ACTION_SETTINGS);
- mDevice.wait(Until.findObject(By.desc("Search settings")), TIMEOUT).click();
- UiObject2 searchBox = mDevice.wait(Until.findObject(By.res("android:id/search_src_text")),
- TIMEOUT);
- InputMethodManager imm = (InputMethodManager) mContext
- .getSystemService(Context.INPUT_METHOD_SERVICE);
- if (!imm.isAcceptingText()) {
- mDevice.wait(Until.findObject(By.desc("Collapse")), TIMEOUT).click();
- assertNotNull("Search Setting has not loaded correctly", searchBox);
- } else {
- mDevice.wait(Until.findObject(By.desc("Collapse")), TIMEOUT).click();
- }
- }
-
- @MediumTest
- public void testOverflowSetting() throws Exception {
- launchMainSettings(Settings.ACTION_SETTINGS);
- mDevice.wait(Until.findObject(By.desc("More options")), TIMEOUT).click();
- mDevice.wait(Until.findObject(By.text("Help & feedback")), TIMEOUT).click();
- UiObject2 help = mDevice.wait(Until.findObject(By.text("Help")),
- TIMEOUT);
- assertNotNull("Overflow setting has not loaded correctly", help);
- }
-
- private void launchMainSettings(String mainSetting) throws Exception {
- mDevice.pressHome();
- Intent settingIntent = new Intent(mainSetting);
- settingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(settingIntent);
- Thread.sleep(TIMEOUT * 3);
- }
-
- private void launchSettingItems(String title) throws Exception {
- int maxAttempt = 5;
- UiObject2 item = null;
- UiObject2 view = null;
- while (maxAttempt-- > 0) {
- item = mDevice.wait(Until.findObject(By.res("android:id/title").text(title)), TIMEOUT);
- if (item == null) {
- view = mDevice.wait(
- Until.findObject(By.res("com.android.settings:id/main_content")),
- TIMEOUT);
- view.scroll(Direction.DOWN, 1.0f);
- } else {
- return;
- }
- }
- assertNotNull(String.format("%s in Setting has not been loaded correctly", title), item);
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/MoreWirelessSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/MoreWirelessSettingsTests.java
deleted file mode 100644
index e306a3fb4..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/MoreWirelessSettingsTests.java
+++ /dev/null
@@ -1,147 +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 android.settings.functional;
-
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.nfc.NfcAdapter;
-import android.nfc.NfcManager;
-import android.os.RemoteException;
-import android.provider.Settings;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-
-public class MoreWirelessSettingsTests extends InstrumentationTestCase {
-
- private static final String SETTINGS_PACKAGE = "com.android.settings";
- private static final int TIMEOUT = 2000;
- private UiDevice mDevice;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.pressBack();
- mDevice.pressHome();
- super.tearDown();
- }
-
- @MediumTest
- public void testAirplaneModeEnabled() throws Exception {
- verifyAirplaneModeOnOrOff(true);
- }
-
- @MediumTest
- public void testAirplaneModeDisabled() throws Exception {
- verifyAirplaneModeOnOrOff(false);
- }
-
- // This NFC toggle test is set up this way since there's no way to set
- // the NFC flag to enabled or disabled without touching UI.
- // This way, we get coverage for whether or not the toggle button works.
- @MediumTest
- public void testNFCToggle() throws Exception {
- NfcManager manager = (NfcManager) getInstrumentation().getContext()
- .getSystemService(Context.NFC_SERVICE);
- NfcAdapter nfcAdapter = manager.getDefaultAdapter();
- boolean nfcInitiallyEnabled = nfcAdapter.isEnabled();
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_WIRELESS_SETTINGS);
- UiObject2 nfcSetting = mDevice.wait(Until.findObject(By.text("NFC")), TIMEOUT);
- nfcSetting.click();
- Thread.sleep(TIMEOUT*2);
- if (nfcInitiallyEnabled) {
- assertFalse("NFC wasn't disabled on toggle", nfcAdapter.isEnabled());
- nfcSetting.click();
- Thread.sleep(TIMEOUT*2);
- assertTrue("NFC wasn't enabled on toggle", nfcAdapter.isEnabled());
- }
- else {
- assertTrue("NFC wasn't enabled on toggle", nfcAdapter.isEnabled());
- nfcSetting.click();
- Thread.sleep(TIMEOUT*2);
- assertFalse("NFC wasn't disabled on toggle", nfcAdapter.isEnabled());
- }
- }
-
- @MediumTest
- public void testTetheringMenuLoad() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_WIRELESS_SETTINGS);
- mDevice.wait(Until
- .findObject(By.text("Tethering & portable hotspot")), TIMEOUT)
- .click();
- Thread.sleep(TIMEOUT);
- UiObject2 usbTethering = mDevice.wait(Until
- .findObject(By.text("USB tethering")), TIMEOUT);
- assertNotNull("Tethering screen did not load correctly", usbTethering);
- }
-
- @MediumTest
- public void testVPNMenuLoad() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_WIRELESS_SETTINGS);
- mDevice.wait(Until
- .findObject(By.text("VPN")), TIMEOUT)
- .click();
- Thread.sleep(TIMEOUT);
- UiObject2 usbTethering = mDevice.wait(Until
- .findObject(By.res(SETTINGS_PACKAGE, "vpn_create")), TIMEOUT);
- assertNotNull("VPN screen did not load correctly", usbTethering);
- }
-
- private void verifyAirplaneModeOnOrOff(boolean verifyOn) throws Exception {
- if (verifyOn) {
- Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.AIRPLANE_MODE_ON, "0");
- }
- else {
- Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.AIRPLANE_MODE_ON, "1");
- }
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_WIRELESS_SETTINGS);
- mDevice.wait(Until
- .findObject(By.text("Airplane mode")), TIMEOUT)
- .click();
- Thread.sleep(TIMEOUT);
- String airplaneModeValue = Settings.Global
- .getString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.AIRPLANE_MODE_ON);
- if (verifyOn) {
- assertEquals("1", airplaneModeValue);
- }
- else {
- assertEquals("0", airplaneModeValue);
- }
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/QuickSettingsTest.java b/tests/functional/settingstests/src/com/android/settings/functional/QuickSettingsTest.java
deleted file mode 100644
index 57ce601e7..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/QuickSettingsTest.java
+++ /dev/null
@@ -1,332 +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 android.settings.functional;
-
-import android.bluetooth.BluetoothManager;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.location.LocationManager;
-import android.net.wifi.WifiManager;
-import android.os.RemoteException;
-import android.provider.Settings;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.util.Log;
-
-public class QuickSettingsTest extends InstrumentationTestCase {
- private static final String LOG_TAG = QuickSettingsTest.class.getSimpleName();
- private static final int LONG_TIMEOUT = 2000;
- private static final int SHORT_TIMEOUT = 500;
-
- private enum QuickSettingTiles {
- WIFI("Wi-Fi"), SIM("SIM"), DND("Do not disturb"), FLASHLIGHT("Flashlight"), SCREEN(
- "Auto-rotate screen"), BLUETOOTH("Bluetooth"), AIRPLANE("Airplane mode"),
- LOCATION("Location"), BRIGHTNESS("Display brightness");
-
- private final String name;
-
- private QuickSettingTiles(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
- };
-
- private UiDevice mDevice = null;
- private ContentResolver mResolver;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- getInstrumentation().getContext();
- mResolver = getInstrumentation().getContext().getContentResolver();
- mDevice.wakeUp();
- mDevice.pressHome();
- mDevice.setOrientationNatural();
- }
-
- @Override
- protected void tearDown() throws Exception {
- // Need to finish settings activity
- mDevice.pressHome();
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- @MediumTest
- public void testQuickSettingDrawDown() throws Exception {
- mDevice.pressHome();
- // Draw down once to load quick settings shade only
- swipeDown();
- UiObject2 quicksettingsShade = mDevice.wait(
- Until.findObject(By.res("com.android.systemui:id/expand_indicator")),
- LONG_TIMEOUT);
- assertNotNull("Quick settings shade not visible on draw down", quicksettingsShade);
- }
-
- @MediumTest
- public void testQuickSettingExpand() throws Exception {
- launchQuickSetting();
- // Verify that the settings object is visible on full expansion
- UiObject2 quicksettingsExpand = mDevice.wait(Until.findObject(By.desc("Open settings.")),
- LONG_TIMEOUT);
- assertNotNull("Quick settings shade did not expand correctly on two swipe downs",
- quicksettingsExpand);
- }
-
- @MediumTest
- public void testQuickSettingCollapse() throws Exception {
- launchQuickSetting();
- // Tap on the expand chevron once more to collapse the QS shade
- mDevice.wait(Until.findObject(By.res("com.android.systemui:id/expand_indicator")),
- LONG_TIMEOUT).click();
-
- // Verify that the brightness slider which is only visible on full expansion
- // isn't visible in the collapsed state
- assertTrue("Quick settings shade did not collapse correctly",
- mDevice.wait(
- Until.gone(By.descContains(QuickSettingTiles.BRIGHTNESS.getName())),
- LONG_TIMEOUT));
- }
-
- @MediumTest
- public void testQuickSettingDismiss() throws Exception {
- launchQuickSetting();
- // Swipe up twice to fully dismiss quick settings
- swipeUp();
- swipeUp();
- UiObject2 quicksettingsShade = mDevice.wait(
- Until.findObject(By.res("com.android.systemui:id/expand_indicator")),
- SHORT_TIMEOUT);
- assertNull("Quick settings collapsed shade was not dismissed correctly",
- quicksettingsShade);
- }
-
- @MediumTest
- public void testQuickSettingTilesVisible() throws Exception {
- launchQuickSetting();
- Thread.sleep(LONG_TIMEOUT);
- for (QuickSettingTiles tile : QuickSettingTiles.values()) {
- UiObject2 quickSettingTile = mDevice.wait(
- Until.findObject(By.descContains(tile.getName())),
- SHORT_TIMEOUT);
- assertNotNull(String.format("%s did not load correctly", tile.getName()),
- quickSettingTile);
- }
- }
-
- @MediumTest
- public void testQuickSettingWifiEnabled() throws Exception {
- verifyWiFiOnOrOff(true);
- }
-
- @MediumTest
- public void testQuickSettingWifiDisabled() throws Exception {
- verifyWiFiOnOrOff(false);
- }
-
- private void verifyWiFiOnOrOff(boolean verifyOn) throws Exception {
- String airPlaneMode = Settings.Global.getString(
- mResolver,
- Settings.Global.AIRPLANE_MODE_ON);
- try {
- Settings.Global.putString(mResolver,
- Settings.Global.AIRPLANE_MODE_ON, "0");
- Thread.sleep(LONG_TIMEOUT);
- WifiManager wifiManager = (WifiManager) getInstrumentation().getContext()
- .getSystemService(Context.WIFI_SERVICE);
- wifiManager.setWifiEnabled(!verifyOn);
- launchQuickSetting();
- mDevice.wait(Until.findObject(By.descContains(QuickSettingTiles.WIFI.getName())),
- LONG_TIMEOUT).click();
- if (verifyOn) {
- mDevice.pressBack();
- } else {
- mDevice.wait(Until.findObject(By.res("android:id/toggle")), LONG_TIMEOUT).click();
- }
- Thread.sleep(LONG_TIMEOUT);
- String changedWifiValue = Settings.Global.getString(mResolver, Settings.Global.WIFI_ON);
- Thread.sleep(LONG_TIMEOUT);
- if (verifyOn) {
- assertEquals("1", changedWifiValue);
- } else {
- assertEquals("0", changedWifiValue);
- }
- } finally {
- Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.AIRPLANE_MODE_ON, airPlaneMode);
- }
- }
-
- @MediumTest
- public void testQuickSettingBluetoothEnabled() throws Exception {
- verifyBluetoothOnOrOff(true);
- }
-
- @MediumTest
- public void testQuickSettingBluetoothDisabled() throws Exception {
- verifyBluetoothOnOrOff(false);
- }
-
- private void verifyBluetoothOnOrOff(boolean verifyOn) throws Exception {
- BluetoothManager bluetoothManager = (BluetoothManager) getInstrumentation().getContext()
- .getSystemService(Context.BLUETOOTH_SERVICE);
- if (!verifyOn) {
- bluetoothManager.getAdapter().enable();
- } else {
- bluetoothManager.getAdapter().disable();
- }
- launchQuickSetting();
- mDevice.wait(Until.findObject(By.textContains(QuickSettingTiles.BLUETOOTH.getName())),
- LONG_TIMEOUT).click();
- if (verifyOn) {
- mDevice.pressBack();
- } else {
- mDevice.wait(Until.findObject(By.res("android:id/toggle")), LONG_TIMEOUT).click();
- }
- Thread.sleep(LONG_TIMEOUT);
- String bluetoothVal = Settings.Global.getString(
- mResolver,
- Settings.Global.BLUETOOTH_ON);
- if (verifyOn) {
- assertEquals("1", bluetoothVal);
- } else {
- assertEquals("0", bluetoothVal);
- }
- }
-
- @MediumTest
- public void testQuickSettingFlashLight() throws Exception {
- String lightOn = "On";
- String lightOff = "Off";
- boolean verifyOn = false;
- launchQuickSetting();
- UiObject2 flashLight = mDevice.wait(
- Until.findObject(By.descContains(QuickSettingTiles.FLASHLIGHT.getName())),
- LONG_TIMEOUT);
- if (flashLight.getText().equals(lightOn)) {
- verifyOn = true;
- }
- mDevice.wait(Until.findObject(By.textContains(QuickSettingTiles.FLASHLIGHT.getName())),
- LONG_TIMEOUT).click();
- Thread.sleep(LONG_TIMEOUT);
- flashLight = mDevice.wait(
- Until.findObject(By.descContains(QuickSettingTiles.FLASHLIGHT.getName())),
- LONG_TIMEOUT);
- if (verifyOn) {
- assertTrue(flashLight.getText().equals(lightOff));
- } else {
- assertTrue(flashLight.getText().equals(lightOn));
- mDevice.wait(Until.findObject(By.textContains(QuickSettingTiles.FLASHLIGHT.getName())),
- LONG_TIMEOUT).click();
- }
- }
-
- @MediumTest
- public void testQuickSettingDND() throws Exception {
- int onSetting = Settings.Global.getInt(mResolver, "zen_mode");
- launchQuickSetting();
- mDevice.wait(Until.findObject(By.descContains(QuickSettingTiles.DND.getName())),
- LONG_TIMEOUT).click();
- if (onSetting == 0) {
- mDevice.pressBack();
- }
- Thread.sleep(LONG_TIMEOUT);
- int changedSetting = Settings.Global.getInt(mResolver, "zen_mode");
- assertFalse(onSetting == changedSetting);
- }
-
- @MediumTest
- public void testQuickSettingAirplaneMode() throws Exception {
- int onSetting = Integer.parseInt(Settings.Global.getString(
- mResolver,
- Settings.Global.AIRPLANE_MODE_ON));
- try {
- launchQuickSetting();
- mDevice.wait(Until.findObject(By.descContains(QuickSettingTiles.AIRPLANE.getName())),
- LONG_TIMEOUT).click();
- Thread.sleep(LONG_TIMEOUT);
- int changedSetting = Integer.parseInt(Settings.Global.getString(
- mResolver,
- Settings.Global.AIRPLANE_MODE_ON));
- assertTrue((1 - onSetting) == changedSetting);
- } finally {
- Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.AIRPLANE_MODE_ON, Integer.toString(onSetting));
- }
- }
-
- @MediumTest
- public void testQuickSettingOrientation() throws Exception {
- launchQuickSetting();
- mDevice.wait(Until.findObject(By.descContains(QuickSettingTiles.SCREEN.getName())),
- LONG_TIMEOUT).click();
- Thread.sleep(LONG_TIMEOUT);
- String rotation = Settings.System.getString(mResolver,
- Settings.System.ACCELEROMETER_ROTATION);
- assertEquals("1", rotation);
- }
-
- @MediumTest
- public void testQuickSettingLocation() throws Exception {
- LocationManager service = (LocationManager) getInstrumentation().getContext()
- .getSystemService(Context.LOCATION_SERVICE);
- boolean onSetting = service.isProviderEnabled(LocationManager.GPS_PROVIDER);
- try {
- launchQuickSetting();
- mDevice.wait(Until.findObject(By.descContains(QuickSettingTiles.LOCATION.getName())),
- LONG_TIMEOUT).click();
- Thread.sleep(LONG_TIMEOUT);
- boolean changedSetting = service.isProviderEnabled(LocationManager.GPS_PROVIDER);
- assertTrue(onSetting == !changedSetting);
- } finally {
- mDevice.wait(Until.findObject(By.descContains(QuickSettingTiles.LOCATION.getName())),
- LONG_TIMEOUT).click();
- }
- }
-
- private void launchQuickSetting() throws Exception {
- mDevice.pressHome();
- swipeDown();
- Thread.sleep(LONG_TIMEOUT);
- swipeDown();
- }
-
- private void swipeUp() throws Exception {
- mDevice.swipe(mDevice.getDisplayWidth() / 2, mDevice.getDisplayHeight(),
- mDevice.getDisplayWidth() / 2, 0, 30);
- Thread.sleep(SHORT_TIMEOUT);
- }
-
- private void swipeDown() throws Exception {
- mDevice.swipe(mDevice.getDisplayWidth() / 2, 0, mDevice.getDisplayWidth() / 2,
- mDevice.getDisplayHeight() / 2 + 50, 20);
- Thread.sleep(SHORT_TIMEOUT);
- }
-
- private void swipeLeft() {
- mDevice.swipe(mDevice.getDisplayWidth() / 2, mDevice.getDisplayHeight() / 2, 0,
- mDevice.getDisplayHeight() / 2, 5);
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/SettingsHelper.java b/tests/functional/settingstests/src/com/android/settings/functional/SettingsHelper.java
deleted file mode 100644
index 58875d260..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/SettingsHelper.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package android.settings.functional;
-
-import android.app.Instrumentation;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.provider.Settings;
-import android.provider.Settings.SettingNotFoundException;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-
-import java.util.regex.Pattern;
-
-public class SettingsHelper {
-
- public static final String PKG = "com.android.settings";
- private static final int TIMEOUT = 2000;
-
- private UiDevice mDevice;
- private Instrumentation mInst;
- private ContentResolver mResolver;
-
- public SettingsHelper(UiDevice device, Instrumentation inst) {
- mDevice = device;
- mInst = inst;
- mResolver = inst.getContext().getContentResolver();
- }
-
- public static enum SettingsType {
- SYSTEM,
- SECURE,
- GLOBAL
- }
-
- public static void launchSettingsPage(Context ctx, String pageName) throws Exception {
- Intent intent = new Intent(pageName);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- ctx.startActivity(intent);
- Thread.sleep(TIMEOUT * 2);
- }
-
- public void clickSetting(String settingName) {
- mDevice.wait(Until.findObject(By.text(settingName)), TIMEOUT).click();
- }
-
- public void clickSetting(Pattern settingName) {
- mDevice.wait(Until.findObject(By.text(settingName)), TIMEOUT).click();
- }
-
- public void scrollVert(boolean isUp) {
- int w = mDevice.getDisplayWidth();
- int h = mDevice.getDisplayHeight();
- mDevice.swipe(w / 2, h / 2, w / 2, isUp ? h : 0, 2);
- }
-
- public boolean verifyToggleSetting(SettingsType type, String settingAction,
- String settingName, String internalName) throws Exception {
- return verifyToggleSetting(
- type, settingAction, Pattern.compile(settingName), internalName, true);
- }
-
- public boolean verifyToggleSetting(SettingsType type, String settingAction,
- Pattern settingName, String internalName) throws Exception {
- return verifyToggleSetting(type, settingAction, settingName, internalName, true);
- }
-
- public boolean verifyToggleSetting(SettingsType type, String settingAction,
- String settingName, String internalName, boolean doLaunch) throws Exception {
- return verifyToggleSetting(
- type, settingAction, Pattern.compile(settingName), internalName, doLaunch);
- }
-
- public boolean verifyToggleSetting(SettingsType type, String settingAction,
- Pattern settingName, String internalName, boolean doLaunch) throws Exception {
- int onSetting = Integer.parseInt(getStringSetting(type, internalName));
- if (doLaunch) {
- launchSettingsPage(mInst.getContext(), settingAction);
- }
- clickSetting(settingName);
- Thread.sleep(1000);
- String changedSetting = getStringSetting(type, internalName);
- return (1 - onSetting) == Integer.parseInt(changedSetting);
- }
-
- public boolean verifyRadioSetting(SettingsType type, String settingAction,
- String baseName, String settingName,
- String internalName, String testVal) throws Exception {
- clickSetting(baseName);
- clickSetting(settingName);
- Thread.sleep(500);
- return getStringSetting(type, internalName).equals(testVal);
- }
-
- private void putStringSetting(SettingsType type, String sName, String value) {
- switch (type) {
- case SYSTEM:
- Settings.System.putString(mResolver, sName, value); break;
- case GLOBAL:
- Settings.Global.putString(mResolver, sName, value); break;
- case SECURE:
- Settings.Secure.putString(mResolver, sName, value); break;
- }
- }
-
- private String getStringSetting(SettingsType type, String sName) {
- switch (type) {
- case SYSTEM:
- return Settings.System.getString(mResolver, sName);
- case GLOBAL:
- return Settings.Global.getString(mResolver, sName);
- case SECURE:
- return Settings.Secure.getString(mResolver, sName);
- }
- return "";
- }
-
- private void putIntSetting(SettingsType type, String sName, int value) {
- switch (type) {
- case SYSTEM:
- Settings.System.putInt(mResolver, sName, value); break;
- case GLOBAL:
- Settings.Global.putInt(mResolver, sName, value); break;
- case SECURE:
- Settings.Secure.putInt(mResolver, sName, value); break;
- }
- }
-
- private int getIntSetting(SettingsType type, String sName) throws SettingNotFoundException {
- switch (type) {
- case SYSTEM:
- return Settings.System.getInt(mResolver, sName);
- case GLOBAL:
- return Settings.Global.getInt(mResolver, sName);
- case SECURE:
- return Settings.Secure.getInt(mResolver, sName);
- }
- return Integer.MIN_VALUE;
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/SoundSettingsTest.java b/tests/functional/settingstests/src/com/android/settings/functional/SoundSettingsTest.java
deleted file mode 100644
index 254a8257e..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/SoundSettingsTest.java
+++ /dev/null
@@ -1,314 +0,0 @@
-package android.settings.functional;
-
-import android.app.NotificationManager;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.os.Handler;
-import android.os.SystemClock;
-import android.provider.Settings;
-import android.service.notification.ZenModeConfig;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.platform.test.helpers.SettingsHelperImpl.SettingsType;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.Suppress;
-
-import com.android.server.notification.ConditionProviders;
-import com.android.server.notification.ManagedServices.UserProfiles;
-import com.android.server.notification.ZenModeHelper;
-
-public class SoundSettingsTest extends InstrumentationTestCase {
- private static final String PAGE = Settings.ACTION_SOUND_SETTINGS;
- private static final int TIMEOUT = 2000;
-
- private UiDevice mDevice;
- private ContentResolver mResolver;
- private SettingsHelperImpl mHelper;
- private ZenModeHelper mZenHelper;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mDevice.setOrientationNatural();
- mResolver = getInstrumentation().getContext().getContentResolver();
- mHelper = new SettingsHelperImpl(getInstrumentation());
- ConditionProviders cps = new ConditionProviders(
- getInstrumentation().getContext(), new Handler(), new UserProfiles());
- mZenHelper = new ZenModeHelper(getInstrumentation().getContext(),
- getInstrumentation().getContext().getMainLooper(),
- cps);
- }
-
- @Override
- public void tearDown() throws Exception {
- mDevice.pressBack();
- mDevice.pressHome();
- mDevice.waitForIdle();
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- @MediumTest
- public void testCallVibrate() throws Exception {
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
- "Also vibrate for calls", Settings.System.VIBRATE_WHEN_RINGING));
- assertTrue(mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
- "Also vibrate for calls", Settings.System.VIBRATE_WHEN_RINGING));
- }
-
- @MediumTest
- public void testOtherSounds() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.scrollVert(false);
- Thread.sleep(1000);
- mHelper.clickSetting("Other sounds");
- Thread.sleep(1000);
- try {
- assertTrue("Dial pad tones not toggled", mHelper.verifyToggleSetting(
- SettingsType.SYSTEM, PAGE, "Dial pad tones",
- Settings.System.DTMF_TONE_WHEN_DIALING));
- assertTrue("Screen locking sounds not toggled",
- mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
- "Screen locking sounds", Settings.System.LOCKSCREEN_SOUNDS_ENABLED));
- assertTrue("Charging sounds not toggled",
- mHelper.verifyToggleSetting(SettingsType.GLOBAL, PAGE,
- "Charging sounds", Settings.Global.CHARGING_SOUNDS_ENABLED));
- assertTrue("Touch sounds not toggled",
- mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
- "Touch sounds", Settings.System.SOUND_EFFECTS_ENABLED));
- assertTrue("Vibrate on tap not toggled",
- mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
- "Vibrate on tap", Settings.System.HAPTIC_FEEDBACK_ENABLED));
- } finally {
- mDevice.pressBack();
- }
- }
-
- @MediumTest
- @Suppress
- public void testDndPriorityAllows() throws Exception {
- SettingsHelperImpl.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- Context ctx = getInstrumentation().getContext();
- try {
- mHelper.clickSetting("Do not disturb");
- try {
- mHelper.clickSetting("Priority only allows");
- ZenModeConfig baseZenCfg = mZenHelper.getConfig();
-
- mHelper.clickSetting("Reminders");
- mHelper.clickSetting("Events");
- mHelper.clickSetting("Repeat callers");
-
- ZenModeConfig changedCfg = mZenHelper.getConfig();
- assertFalse(baseZenCfg.allowReminders == changedCfg.allowReminders);
- assertFalse(baseZenCfg.allowEvents == changedCfg.allowEvents);
- assertFalse(baseZenCfg.allowRepeatCallers == changedCfg.allowRepeatCallers);
-
- mHelper.clickSetting("Reminders");
- mHelper.clickSetting("Events");
- mHelper.clickSetting("Repeat callers");
-
- changedCfg = mZenHelper.getConfig();
- assertTrue(baseZenCfg.allowReminders == changedCfg.allowReminders);
- assertTrue(baseZenCfg.allowEvents == changedCfg.allowEvents);
- assertTrue(baseZenCfg.allowRepeatCallers == changedCfg.allowRepeatCallers);
-
- mHelper.clickSetting("Messages");
- mHelper.clickSetting("From anyone");
- mHelper.clickSetting("Calls");
- mHelper.clickSetting("From anyone");
-
- changedCfg = mZenHelper.getConfig();
- assertFalse(baseZenCfg.allowCallsFrom == changedCfg.allowCallsFrom);
- assertFalse(baseZenCfg.allowMessagesFrom == changedCfg.allowMessagesFrom);
- } finally {
- mDevice.pressBack();
- }
- } finally {
- mDevice.pressHome();
- }
- }
-
- @MediumTest
- @Suppress
- public void testDndVisualInterruptions() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- try {
- mHelper.clickSetting("Do not disturb");
- try {
- mHelper.clickSetting("Visual interruptions");
- ZenModeConfig baseZenCfg = mZenHelper.getConfig();
-
- mHelper.clickSetting("Block when screen is on");
- mHelper.clickSetting("Block when screen is off");
-
- ZenModeConfig changedCfg = mZenHelper.getConfig();
- assertFalse(baseZenCfg.allowWhenScreenOff == changedCfg.allowWhenScreenOff);
- assertFalse(baseZenCfg.allowWhenScreenOn == changedCfg.allowWhenScreenOn);
-
- mHelper.clickSetting("Block when screen is on");
- mHelper.clickSetting("Block when screen is off");
-
- changedCfg = mZenHelper.getConfig();
- assertTrue(baseZenCfg.allowWhenScreenOff == changedCfg.allowWhenScreenOff);
- assertTrue(baseZenCfg.allowWhenScreenOn == changedCfg.allowWhenScreenOn);
- } finally {
- mDevice.pressBack();
- }
- } finally {
- mDevice.pressBack();
- }
- }
-
- /*
- * Rather than verifying every ringtone, verify the ones least likely to change
- * (None and Hangouts) and an arbitrary one from the ringtone pool.
- */
- @MediumTest
- public void testPhoneRingtoneNone() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Phone ringtone");
- verifyRingtone(new RingtoneSetting("None", "null"),
- Settings.System.RINGTONE, ScrollDir.UP);
- }
-
- @MediumTest
- @Suppress
- public void testPhoneRingtoneHangouts() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Phone ringtone");
- verifyRingtone(new RingtoneSetting("Hangouts Call", "31"), Settings.System.RINGTONE);
- }
-
- @MediumTest
- public void testPhoneRingtoneUmbriel() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Phone ringtone");
- String ringtone = "Umbriel";
- String ringtoneSettingValue = "49";
- if (mDevice.getProductName().equals("marlin")
- || mDevice.getProductName().equals("sailfish")) {
- ringtone = "Spaceship";
- ringtoneSettingValue = "32";
- }
- verifyRingtone(new RingtoneSetting(ringtone, ringtoneSettingValue),
- Settings.System.RINGTONE, ScrollDir.DOWN);
- }
-
- @MediumTest
- public void testNotificationRingtoneNone() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Default notification ringtone");
- verifyRingtone(new RingtoneSetting("None", "null"),
- Settings.System.NOTIFICATION_SOUND, ScrollDir.UP);
- }
-
- @MediumTest
- @Suppress
- public void testNotificationRingtoneHangouts() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Default notification ringtone");
- verifyRingtone(new RingtoneSetting("Hangouts Message", "30"),
- Settings.System.NOTIFICATION_SOUND);
- }
-
- @MediumTest
- public void testNotificationRingtoneTitan() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Default notification ringtone");
- String notificationRingtone = "Titan";
- String notificationSettingValue = "35";
- if (mDevice.getProductName().equals("marlin")
- || mDevice.getProductName().equals("sailfish")) {
- notificationRingtone = "Trill";
- notificationSettingValue = "24";
- }
- verifyRingtone(new RingtoneSetting(notificationRingtone, notificationSettingValue),
- Settings.System.NOTIFICATION_SOUND, ScrollDir.DOWN);
- }
-
- @MediumTest
- public void testAlarmRingtoneNone() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Default alarm ringtone");
- verifyRingtone(new RingtoneSetting("None", "null"),
- Settings.System.ALARM_ALERT, ScrollDir.UP);
- }
-
- @MediumTest
- public void testAlarmRingtoneXenon() throws Exception {
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
- mHelper.clickSetting("Default alarm ringtone");
- String alarmRingtone = "Xenon";
- String alarmSettingValue = "22";
- if (mDevice.getProductName().equals("marlin")
- || mDevice.getProductName().equals("sailfish")) {
- alarmRingtone = "Wag";
- alarmSettingValue = "15";
- }
- verifyRingtone(new RingtoneSetting(alarmRingtone, alarmSettingValue),
- Settings.System.ALARM_ALERT, ScrollDir.DOWN);
- }
-
- private void verifyRingtone(RingtoneSetting r, String settingName) {
- verifyRingtone(r, settingName, ScrollDir.NOSCROLL);
- }
-
- /*
- * This method verifies that setting a custom ringtone changes the
- * ringtone code setting on the system. Each ringtone sound corresponds
- * to an arbitrary code. To see which ringtone code this is on your device, run
- * adb shell settings get system ringtone
- * The number you see at the end of the file path is the one you need.
- * To see alarms and notifications ringtone codes, run the following:
- * adb shell settings get system alarm_alert
- * adb shell settings get system notification_sound
- * @param r Ringtone setting - the name of the ringtone as displayed on device
- * @param settingName - the code of the ringtone as explained above
- * @param dir - the direction in which to scroll
- */
- private void verifyRingtone(RingtoneSetting r, String settingName, ScrollDir dir) {
- if (dir != ScrollDir.NOSCROLL) {
- mHelper.scrollVert(dir == ScrollDir.UP);
- SystemClock.sleep(1000);
- }
- mDevice.wait(Until.findObject(By.text(r.getName())), TIMEOUT).click();
- mDevice.wait(Until.findObject(By.text("OK")), TIMEOUT).click();
- SystemClock.sleep(1000);
- if (r.getVal().equals("null")) {
- assertEquals(null,
- Settings.System.getString(mResolver, settingName));
- } else if (r.getName().contains("Hangouts")) {
- assertEquals("content://media/external/audio/media/" + r.getVal(),
- Settings.System.getString(mResolver, settingName));
- } else {
- assertEquals("content://media/internal/audio/media/" + r.getVal(),
- Settings.System.getString(mResolver, settingName));
- }
- }
-
- private enum ScrollDir {
- UP,
- DOWN,
- NOSCROLL
- }
-
- class RingtoneSetting {
- private final String mName;
- private final String mMediaVal;
- public RingtoneSetting(String name, String fname) {
- mName = name;
- mMediaVal = fname;
- }
- public String getName() {
- return mName;
- }
- public String getVal() {
- return mMediaVal;
- }
- }
-}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/WirelessNetworkSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/WirelessNetworkSettingsTests.java
deleted file mode 100644
index f1ee7371d..000000000
--- a/tests/functional/settingstests/src/com/android/settings/functional/WirelessNetworkSettingsTests.java
+++ /dev/null
@@ -1,757 +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 android.settings.functional;
-
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.os.RemoteException;
-import android.provider.Settings;
-import android.platform.test.helpers.SettingsHelperImpl;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.StaleObjectException;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-public class WirelessNetworkSettingsTests extends InstrumentationTestCase {
- // These back button presses are performed in tearDown() to exit Wifi
- // Settings sub-menus that a test might finish in. This number should be
- // high enough to account for the deepest sub-menu a test might enter.
- private static final int NUM_BACK_BUTTON_PRESSES = 5;
- private static final int TIMEOUT = 2000;
- private static final int SLEEP_TIME = 500;
-
- // Note: The values of these variables might affect flakiness in tests that involve
- // scrolling. Adjust where necessary.
- private static final float SCROLL_UP_PERCENT = 10.0f;
- private static final float SCROLL_DOWN_PERCENT = 0.5f;
- private static final int MAX_SCROLL_ATTEMPTS = 10;
- private static final int MAX_ADD_NETWORK_BUTTON_ATTEMPTS = 3;
- private static final int SCROLL_SPEED = 2000;
-
- private static final String TEST_SSID = "testSsid";
- private static final String TEST_PW_GE_8_CHAR = "testPasswordGreaterThan8Char";
- private static final String TEST_PW_LT_8_CHAR = "lt8Char";
- private static final String TEST_DOMAIN = "testDomain.com";
-
- private static final String SETTINGS_PACKAGE = "com.android.settings";
-
- private static final String CHECKBOX_CLASS = "android.widget.CheckBox";
- private static final String SPINNER_CLASS = "android.widget.Spinner";
- private static final String EDIT_TEXT_CLASS = "android.widget.EditText";
- private static final String SCROLLVIEW_CLASS = "android.widget.ScrollView";
- private static final String LISTVIEW_CLASS = "android.widget.ListView";
-
- private static final String ADD_NETWORK_MENU_CANCEL_BUTTON_TEXT = "CANCEL";
- private static final String ADD_NETWORK_MENU_SAVE_BUTTON_TEXT = "SAVE";
- private static final String ADD_NETWORK_PREFERENCE_TEXT = "Add network";
- private static final String CACERT_MENU_PLEASE_SELECT_TEXT = "Please select";
- private static final String CACERT_MENU_USE_SYSTEM_CERTS_TEXT = "Use system certificates";
- private static final String CACERT_MENU_DO_NOT_VALIDATE_TEXT = "Do not validate";
- private static final String USERCERT_MENU_PLEASE_SELECT_TEXT = "Please select";
- private static final String USERCERT_MENU_DO_NOT_PROVIDE_TEXT = "Do not provide";
- private static final String SECURITY_OPTION_NONE_TEXT = "None";
- private static final String SECURITY_OPTION_WEP_TEXT = "WEP";
- private static final String SECURITY_OPTION_PSK_TEXT = "WPA/WPA2 PSK";
- private static final String SECURITY_OPTION_EAP_TEXT = "802.1x EAP";
- private static final String EAP_METHOD_PEAP_TEXT = "PEAP";
- private static final String EAP_METHOD_TLS_TEXT = "TLS";
- private static final String EAP_METHOD_TTLS_TEXT = "TTLS";
- private static final String EAP_METHOD_PWD_TEXT = "PWD";
- private static final String EAP_METHOD_SIM_TEXT = "SIM";
- private static final String EAP_METHOD_AKA_TEXT = "AKA";
- private static final String EAP_METHOD_AKA_PRIME_TEXT = "AKA'";
- private static final String PHASE2_MENU_NONE_TEXT = "None";
- private static final String PHASE2_MENU_MSCHAPV2_TEXT = "MSCHAPV2";
- private static final String PHASE2_MENU_GTC_TEXT = "GTC";
-
- private static final String ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID = "wifi_advanced_togglebox";
- private static final String ADD_NETWORK_MENU_IP_SETTINGS_RES_ID = "ip_settings";
- private static final String ADD_NETWORK_MENU_PROXY_SETTINGS_RES_ID = "proxy_settings";
- private static final String ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID = "security";
- private static final String ADD_NETWORK_MENU_EAP_METHOD_RES_ID = "method";
- private static final String ADD_NETWORK_MENU_SSID_RES_ID = "ssid";
- private static final String ADD_NETWORK_MENU_PHASE2_RES_ID = "phase2";
- private static final String ADD_NETWORK_MENU_CACERT_RES_ID = "ca_cert";
- private static final String ADD_NETWORK_MENU_USERCERT_RES_ID = "user_cert";
- private static final String ADD_NETWORK_MENU_NO_DOMAIN_WARNING_RES_ID = "no_domain_warning";
- private static final String ADD_NETWORK_MENU_NO_CACERT_WARNING_RES_ID = "no_ca_cert_warning";
- private static final String ADD_NETWORK_MENU_DOMAIN_LAYOUT_RES_ID = "l_domain";
- private static final String ADD_NETWORK_MENU_DOMAIN_RES_ID = "domain";
- private static final String ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID = "l_identity";
- private static final String ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID = "l_anonymous";
- private static final String ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID = "password_layout";
- private static final String ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID =
- "show_password_layout";
- private static final String ADD_NETWORK_MENU_PASSWORD_RES_ID = "password";
-
- private static final BySelector ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR =
- By.scrollable(true).clazz(SCROLLVIEW_CLASS);
- private static final BySelector SPINNER_OPTIONS_SCROLLABLE_BY_SELECTOR =
- By.scrollable(true).clazz(LISTVIEW_CLASS);
-
- private UiDevice mDevice;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientation", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- // Exit all settings sub-menus.
- for (int i = 0; i < NUM_BACK_BUTTON_PRESSES; ++i) {
- mDevice.pressBack();
- }
- mDevice.pressHome();
- super.tearDown();
- }
-
- @MediumTest
- public void testWiFiEnabled() throws Exception {
- verifyWiFiOnOrOff(true);
- }
-
- @MediumTest
- public void testWiFiDisabled() throws Exception {
- verifyWiFiOnOrOff(false);
- }
-
- @MediumTest
- public void testWifiMenuLoadConfigure() throws Exception {
- loadWiFiConfigureMenu();
- Thread.sleep(SLEEP_TIME);
- UiObject2 configureWiFiHeading = mDevice.wait(Until.findObject(By.text("Configure Wi‑Fi")),
- TIMEOUT);
- assertNotNull("Configure WiFi menu has not loaded correctly", configureWiFiHeading);
- }
-
- @MediumTest
- public void testNetworkNotificationsOn() throws Exception {
- verifyNetworkNotificationsOnOrOff(true);
- }
-
- @MediumTest
- public void testNetworkNotificationsOff() throws Exception {
- verifyNetworkNotificationsOnOrOff(false);
- }
-
- @MediumTest
- public void testKeepWiFiDuringSleepAlways() throws Exception {
- // Change the default and then change it back
- Settings.Global.putInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.WIFI_SLEEP_POLICY, Settings.Global.WIFI_SLEEP_POLICY_DEFAULT);
- verifyKeepWiFiOnDuringSleep("Always", Settings.Global.WIFI_SLEEP_POLICY_NEVER);
- }
-
- @MediumTest
- public void testKeepWiFiDuringSleepOnlyWhenPluggedIn() throws Exception {
- verifyKeepWiFiOnDuringSleep("Only when plugged in",
- Settings.Global.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED);
- }
-
- @MediumTest
- public void testKeepWiFiDuringSleepNever() throws Exception {
- verifyKeepWiFiOnDuringSleep("Never", Settings.Global.WIFI_SLEEP_POLICY_DEFAULT);
- }
-
- @MediumTest
- public void testAddNetworkMenu_Default() throws Exception {
- loadAddNetworkMenu();
-
- // Submit button should be disabled by default, while cancel button should be enabled.
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- assertTrue(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_CANCEL_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // Check that the SSID field is defaults to the hint.
- assertEquals("Enter the SSID", mDevice.wait(Until.findObject(By
- .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SSID_RES_ID)
- .clazz(EDIT_TEXT_CLASS)), TIMEOUT*2)
- .getText());
-
- // Check Security defaults to None.
- assertEquals("None", mDevice.wait(Until.findObject(By
- .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID)
- .clazz(SPINNER_CLASS)), TIMEOUT)
- .getChildren().get(0).getText());
-
- // Check advanced options are collapsed by default.
- assertFalse(mDevice.wait(Until.findObject(By
- .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
- .clazz(CHECKBOX_CLASS)), TIMEOUT).isChecked());
-
- }
-
- @MediumTest
- public void testAddNetworkMenu_Proxy() throws Exception {
- loadAddNetworkMenu();
-
- // Toggle advanced options.
- mDevice.wait(Until.findObject(By
- .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
- .clazz(CHECKBOX_CLASS)), TIMEOUT).click();
-
- // Verify Proxy defaults to None.
- BySelector proxySettingsBySelector =
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PROXY_SETTINGS_RES_ID)
- .clazz(SPINNER_CLASS);
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
- assertEquals("None", mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT)
- .getChildren().get(0).getText());
-
- // Verify that Proxy Manual fields appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
- mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).click();
- mDevice.wait(Until.findObject(By.text("Manual")), TIMEOUT).click();
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "proxy_warning_limited_support"));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "proxy_hostname"));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "proxy_exclusionlist"));
-
- // Verify that Proxy Auto-Config options appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
- mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).click();
- mDevice.wait(Until.findObject(By.text("Proxy Auto-Config")), TIMEOUT).click();
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "proxy_pac"));
- }
-
- @MediumTest
- public void testAddNetworkMenu_IpSettings() throws Exception {
- loadAddNetworkMenu();
-
- // Toggle advanced options.
- mDevice.wait(Until.findObject(By
- .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
- .clazz(CHECKBOX_CLASS)), TIMEOUT).click();
-
- // Verify IP settings defaults to DHCP.
- BySelector ipSettingsBySelector =
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IP_SETTINGS_RES_ID).clazz(SPINNER_CLASS);
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, ipSettingsBySelector);
- assertEquals("DHCP", mDevice.wait(Until.findObject(ipSettingsBySelector), TIMEOUT)
- .getChildren().get(0).getText());
-
- // Verify that Static IP settings options appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, ipSettingsBySelector).click();
- mDevice.wait(Until.findObject(By.text("Static")), TIMEOUT).click();
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "ipaddress"));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "gateway"));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "network_prefix_length"));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "dns1"));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, "dns2"));
- }
-
- @MediumTest
- public void testPhase2Settings() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-
- BySelector phase2SettingsBySelector =
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID).clazz(SPINNER_CLASS);
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, phase2SettingsBySelector);
- assertEquals(PHASE2_MENU_NONE_TEXT, mDevice.wait(Until
- .findObject(phase2SettingsBySelector), TIMEOUT).getChildren().get(0).getText());
- mDevice.wait(Until.findObject(phase2SettingsBySelector), TIMEOUT).click();
- Thread.sleep(SLEEP_TIME);
-
- // Verify Phase 2 authentication spinner options.
- assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_NONE_TEXT)), TIMEOUT));
- assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_MSCHAPV2_TEXT)), TIMEOUT));
- assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_GTC_TEXT)), TIMEOUT));
- }
-
- @MediumTest
- public void testCaCertSettings() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-
- BySelector caCertSettingsBySelector =
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID).clazz(SPINNER_CLASS);
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, caCertSettingsBySelector);
- assertEquals(CACERT_MENU_PLEASE_SELECT_TEXT, mDevice.wait(Until
- .findObject(caCertSettingsBySelector), TIMEOUT).getChildren().get(0).getText());
- mDevice.wait(Until.findObject(caCertSettingsBySelector), TIMEOUT).click();
- Thread.sleep(SLEEP_TIME);
-
- // Verify CA certificate spinner options.
- assertNotNull(mDevice.wait(Until.findObject(
- By.text(CACERT_MENU_PLEASE_SELECT_TEXT)), TIMEOUT));
- assertNotNull(mDevice.wait(Until.findObject(
- By.text(CACERT_MENU_USE_SYSTEM_CERTS_TEXT)), TIMEOUT));
- assertNotNull(mDevice.wait(Until.findObject(
- By.text(CACERT_MENU_DO_NOT_VALIDATE_TEXT)), TIMEOUT));
-
- // Verify that a domain field and warning appear when the user selects the
- // "Use system certificates" option.
- mDevice.wait(Until.findObject(By.text(CACERT_MENU_USE_SYSTEM_CERTS_TEXT)), TIMEOUT).click();
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_DOMAIN_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_NO_DOMAIN_WARNING_RES_ID));
-
- // Verify that a warning appears when the user chooses the "Do Not Validate" option.
- mDevice.wait(Until.findObject(caCertSettingsBySelector), TIMEOUT).click();
- mDevice.wait(Until.findObject(By.text(CACERT_MENU_DO_NOT_VALIDATE_TEXT)), TIMEOUT).click();
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_NO_CACERT_WARNING_RES_ID));
- }
-
- @MediumTest
- public void testAddNetwork_NoSecurity() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_NONE_TEXT);
-
- // Entering an SSID is enough to enable the submit button. // TODO THIS GUY
- enterSSID(TEST_SSID);
- assertTrue(mDevice.wait(Until
- .findObject(By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- }
-
- @MediumTest
- public void testAddNetwork_WEP() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_WEP_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // Verify that WEP fields appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
-
- // Entering an SSID alone does not enable the submit button.
- enterSSID(TEST_SSID);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // Submit button is only enabled after a password is entered.
- enterPassword(TEST_PW_GE_8_CHAR);
- assertTrue(mDevice.wait(Until
- .findObject(By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- }
-
- @MediumTest
- public void testAddNetwork_PSK() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_PSK_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // Verify that PSK fields appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
-
- // Entering an SSID alone does not enable the submit button.
- enterSSID(TEST_SSID);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // Entering an password that is too short does not enable submit button.
- enterPassword(TEST_PW_LT_8_CHAR);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // Submit button is only enabled after a password of valid length is entered.
- enterPassword(TEST_PW_GE_8_CHAR);
- assertTrue(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- }
-
- @MediumTest
- public void testAddNetwork_EAP_PEAP() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- selectEAPMethod(EAP_METHOD_PEAP_TEXT);
-
- // Verify that EAP-PEAP fields appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
-
- // Entering an SSID alone does not enable the submit button.
- enterSSID(TEST_SSID);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- verifyCaCertificateSubmitConditions();
- }
-
- @MediumTest
- public void testAddNetwork_EAP_TLS() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- selectEAPMethod(EAP_METHOD_TLS_TEXT);
-
- // Verify that EAP-TLS fields appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_USERCERT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
-
- // Entering an SSID alone does not enable the submit button.
- enterSSID(TEST_SSID);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // Selecting the User certificate "Do not provide" option alone does not enable the submit
- // button.
- selectUserCertificateOption(USERCERT_MENU_DO_NOT_PROVIDE_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- verifyCaCertificateSubmitConditions();
- }
-
- @MediumTest
- public void testAddNetwork_EAP_TTLS() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- selectEAPMethod(EAP_METHOD_TTLS_TEXT);
-
- // Verify that EAP-TLS fields appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
-
- // Entering an SSID alone does not enable the submit button.
- enterSSID(TEST_SSID);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- verifyCaCertificateSubmitConditions();
- }
-
- @MediumTest
- public void testAddNetwork_EAP_PWD() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- selectEAPMethod(EAP_METHOD_PWD_TEXT);
-
- // Verify that EAP-TLS fields appear.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
-
- // Entering an SSID alone enables the submit button.
- enterSSID(TEST_SSID);
- assertTrue(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- }
-
- @MediumTest
- public void testAddNetwork_EAP_SIM() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- selectEAPMethod(EAP_METHOD_SIM_TEXT);
-
- // Entering an SSID alone enables the submit button.
- enterSSID(TEST_SSID);
- assertTrue(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- }
-
- @MediumTest
- public void testAddNetwork_EAP_AKA() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- selectEAPMethod(EAP_METHOD_AKA_TEXT);
-
- // Entering an SSID alone enables the submit button.
- enterSSID(TEST_SSID);
- assertTrue(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- }
-
- @MediumTest
- public void testAddNetwork_EAP_AKA_PRIME() throws Exception {
- loadAddNetworkMenu();
- selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- selectEAPMethod(EAP_METHOD_AKA_PRIME_TEXT);
-
- // Entering an SSID alone enables the submit button.
- enterSSID(TEST_SSID);
- assertTrue(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- }
-
- private void verifyKeepWiFiOnDuringSleep(String settingToBeVerified, int settingValue)
- throws Exception {
- loadWiFiConfigureMenu();
- mDevice.wait(Until.findObject(By.text("Keep Wi‑Fi on during sleep")), TIMEOUT)
- .click();
- mDevice.wait(Until.findObject(By.clazz("android.widget.CheckedTextView")
- .text(settingToBeVerified)), TIMEOUT).click();
- Thread.sleep(SLEEP_TIME);
- int keepWiFiOnSetting =
- Settings.Global.getInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.WIFI_SLEEP_POLICY);
- assertEquals(settingValue, keepWiFiOnSetting);
- }
-
- private void verifyNetworkNotificationsOnOrOff(boolean verifyOn)
- throws Exception {
- String switchText = "ON";
- if (verifyOn) {
- switchText = "OFF";
- Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, "0");
- }
- else {
- Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, "1");
- }
- loadWiFiConfigureMenu();
- mDevice.wait(Until.findObject(By.res("android:id/switch_widget").text(switchText)), TIMEOUT)
- .click();
- Thread.sleep(SLEEP_TIME);
- String wifiNotificationValue =
- Settings.Global.getString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
- if (verifyOn) {
- assertEquals("1", wifiNotificationValue);
- }
- else {
- assertEquals("0", wifiNotificationValue);
- }
- }
-
- private void verifyWiFiOnOrOff(boolean verifyOn) throws Exception {
- String switchText = "On";
- if (verifyOn) {
- switchText = "Off";
- }
- loadWiFiSettingsPage(!verifyOn);
- mDevice.wait(Until
- .findObject(By.res(SETTINGS_PACKAGE, "switch_bar").text(switchText)), TIMEOUT)
- .click();
- Thread.sleep(SLEEP_TIME);
- String wifiValue =
- Settings.Global.getString(getInstrumentation().getContext().getContentResolver(),
- Settings.Global.WIFI_ON);
- if (verifyOn) {
- assertEquals("1", wifiValue);
- }
- else {
- assertEquals("0", wifiValue);
- }
- }
-
- private void verifyCaCertificateSubmitConditions() throws Exception {
- // Selecting the CA certificate "Do not validate" option enables the submit button.
- selectCaCertificateOption(CACERT_MENU_DO_NOT_VALIDATE_TEXT);
- assertTrue(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // However, selecting the CA certificate "Use system certificates option" is not enough to
- // enable the submit button.
- selectCaCertificateOption(CACERT_MENU_USE_SYSTEM_CERTS_TEXT);
- assertFalse(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
- // Submit button is only enabled after a domain is entered as well.
- enterDomain(TEST_DOMAIN);
- assertTrue(mDevice.wait(Until.findObject(
- By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
- }
-
- private void loadWiFiSettingsPage(boolean wifiEnabled) throws Exception {
- WifiManager wifiManager = (WifiManager)getInstrumentation().getContext()
- .getSystemService(Context.WIFI_SERVICE);
- wifiManager.setWifiEnabled(wifiEnabled);
- SettingsHelper.launchSettingsPage(getInstrumentation().getContext(),
- Settings.ACTION_WIFI_SETTINGS);
- }
-
- private void loadWiFiConfigureMenu() throws Exception {
- loadWiFiSettingsPage(true);
- mDevice.wait(Until.findObject(By.desc("Configure")), TIMEOUT).click();
- }
-
- private void loadAddNetworkMenu() throws Exception {
- loadWiFiSettingsPage(true);
- for (int attempts = 0; attempts < MAX_ADD_NETWORK_BUTTON_ATTEMPTS; ++attempts) {
- UiObject2 found = null;
- try {
- findOrScrollToObject(By.scrollable(true), By.text(ADD_NETWORK_PREFERENCE_TEXT))
- .click();
- } catch (StaleObjectException e) {
- // The network list might have been updated between when the Add network button was
- // found, and when it UI automator attempted to click on it. Retry.
- continue;
- }
- // If we get here, we successfully clicked on the Add network button, so we are done.
- Thread.sleep(SLEEP_TIME*5);
- return;
- }
-
- fail("Failed to load Add Network Menu after " + MAX_ADD_NETWORK_BUTTON_ATTEMPTS
- + " retries");
- }
-
- private void selectSecurityOption(String securityOption) throws Exception {
- // We might not need to scroll to the security options if not enough add network menu
- // options are visible.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID)
- .clazz(SPINNER_CLASS)).click();
- Thread.sleep(SLEEP_TIME);
- mDevice.wait(Until.findObject(By.text(securityOption)), TIMEOUT).click();
- }
-
- private void selectEAPMethod(String eapMethod) throws Exception {
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_EAP_METHOD_RES_ID).clazz(SPINNER_CLASS))
- .click();
- Thread.sleep(SLEEP_TIME);
- findOrScrollToObject(SPINNER_OPTIONS_SCROLLABLE_BY_SELECTOR, By.text(eapMethod)).click();
- }
-
- private void selectUserCertificateOption(String userCertificateOption) throws Exception {
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_USERCERT_RES_ID).clazz(SPINNER_CLASS))
- .click();
- mDevice.wait(Until.findObject(By.text(userCertificateOption)), TIMEOUT).click();
- }
-
- private void selectCaCertificateOption(String caCertificateOption) throws Exception {
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID).clazz(SPINNER_CLASS))
- .click();
- mDevice.wait(Until.findObject(By.text(caCertificateOption)), TIMEOUT).click();
- }
-
- private void enterSSID(String ssid) throws Exception {
- // We might not need to scroll to the SSID option if not enough add network menu options
- // are visible.
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SSID_RES_ID).clazz(EDIT_TEXT_CLASS))
- .setText(ssid);
- }
-
- private void enterPassword(String password) throws Exception {
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_RES_ID).clazz(EDIT_TEXT_CLASS))
- .setText(password);
- }
-
- private void enterDomain(String domain) throws Exception {
- findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
- By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_DOMAIN_RES_ID)).setText(domain);
- }
-
- // Use this if the UI object might or might not need to be scrolled to.
- private UiObject2 findOrScrollToObject(BySelector scrollableSelector, BySelector objectSelector)
- throws Exception {
- UiObject2 object = mDevice.wait(Until.findObject(objectSelector), TIMEOUT);
- if (object == null) {
- object = scrollToObject(scrollableSelector, objectSelector);
- }
- return object;
- }
-
- private UiObject2 scrollToObject(BySelector scrollableSelector, BySelector objectSelector)
- throws Exception {
- UiObject2 scrollable = mDevice.wait(Until.findObject(scrollableSelector), TIMEOUT);
- if (scrollable == null) {
- fail("Could not find scrollable UI object identified by " + scrollableSelector);
- }
- UiObject2 found = null;
- // Scroll all the way up first, then all the way down.
- while (true) {
- // Optimization: terminate if we find the object while scrolling up to reset, so
- // we save the time spent scrolling down again.
- boolean canScrollAgain = scrollable.scroll(Direction.UP, SCROLL_UP_PERCENT,
- SCROLL_SPEED);
- found = mDevice.findObject(objectSelector);
- if (found != null) return found;
- if (!canScrollAgain) break;
- }
- for (int attempts = 0; found == null && attempts < MAX_SCROLL_ATTEMPTS; ++attempts) {
- // Return value of UiObject2.scroll() is not reliable, so do not use it in loop
- // condition, in case it causes this loop to terminate prematurely.
- scrollable.scroll(Direction.DOWN, SCROLL_DOWN_PERCENT, SCROLL_SPEED);
- found = mDevice.findObject(objectSelector);
- }
- if (found == null) {
- fail("Could not scroll to UI object identified by " + objectSelector);
- }
- return found;
- }
-}
diff --git a/tests/functional/tv/TvSysUiTests/Android.mk b/tests/functional/tv/TvSysUiTests/Android.mk
deleted file mode 100644
index 4670cec70..000000000
--- a/tests/functional/tv/TvSysUiTests/Android.mk
+++ /dev/null
@@ -1,28 +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.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# ------------------------------------------------
-# build a test apk
-
-LOCAL_PACKAGE_NAME := TvSysUiTests
-LOCAL_CERTIFICATE := platform
-LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator android-support-test platform-test-annotations \
- leanback-app-helpers
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_PACKAGE)
diff --git a/tests/functional/tv/TvSysUiTests/AndroidManifest.xml b/tests/functional/tv/TvSysUiTests/AndroidManifest.xml
deleted file mode 100644
index fa0dd4cfb..000000000
--- a/tests/functional/tv/TvSysUiTests/AndroidManifest.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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="android.test.functional.tv.sysui"
- android:sharedUserId="android.uid.system" >
-
- <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="24"/>
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.test.functional.tv.sysui"
- android:label="TV Platform System UI Functional Tests" />
-
- <instrumentation
- android:name="android.test.functional.tv.common.TestSetupInstrumentation"
- android:targetPackage="android.test.functional.tv.sysui"
- android:label="TV test setup instrumentation" />
-</manifest>
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/SysUiTestBase.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/SysUiTestBase.java
deleted file mode 100644
index e794d74e3..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/SysUiTestBase.java
+++ /dev/null
@@ -1,149 +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 android.test.functional.tv.common;
-
-import android.app.Instrumentation;
-import android.content.Context;
-import android.content.pm.UserInfo;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.platform.test.helpers.CommandHelper;
-import android.platform.test.helpers.DPadHelper;
-import android.platform.test.helpers.tv.LeanbackDemoHelperImpl;
-import android.platform.test.helpers.tv.NoTouchAuthHelperImpl;
-import android.platform.test.helpers.tv.SearchHelperImpl;
-import android.platform.test.helpers.tv.SysUiPipHelperImpl;
-import android.platform.test.helpers.tv.SysUiRecentsHelperImpl;
-import android.platform.test.helpers.tv.SysUiSettingsHelperImpl;
-import android.platform.test.helpers.tv.YouTubeHelperImpl;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.launcherhelper.ILeanbackLauncherStrategy;
-import android.support.test.launcherhelper.LauncherStrategyFactory;
-import android.support.test.launcherhelper.LeanbackLauncherStrategy;
-import android.support.test.runner.AndroidJUnit4;
-import android.support.test.uiautomator.UiDevice;
-import android.util.Log;
-
-import org.junit.runner.RunWith;
-
-/**
- * Base test class for functional testing for leanback platform
- */
-@RunWith(AndroidJUnit4.class)
-public abstract class SysUiTestBase {
-
- private static final String TAG = SysUiTestBase.class.getSimpleName();
-
- protected UiDevice mDevice;
- protected Instrumentation mInstrumentation;
- protected Context mContext;
- protected Bundle mArguments;
-
- protected CommandHelper mCmdHelper;
- protected DPadHelper mDPadHelper;
- protected LeanbackLauncherStrategy mLauncherStrategy;
- protected LeanbackDemoHelperImpl mLeanbackDemoHelper;
- protected NoTouchAuthHelperImpl mNoTouchAuthHelper;
- protected SearchHelperImpl mSearchHelper;
- protected SysUiPipHelperImpl mPipHelper;
- protected SysUiRecentsHelperImpl mRecentsHelper;
- protected SysUiSettingsHelperImpl mSettingsHelper;
- protected YouTubeHelperImpl mYouTubeHelper;
-
-
- public SysUiTestBase() {
- initialize(InstrumentationRegistry.getInstrumentation());
- }
-
- public SysUiTestBase(Instrumentation instrumentation) {
- initialize(instrumentation);
- }
-
- private void initialize(Instrumentation instrumentation) {
- // Initialize instances of testing support library
- mInstrumentation = instrumentation;
- mContext = getInstrumentation().getContext();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mArguments = InstrumentationRegistry.getArguments();
-
- // Initialize instances of leanback and app helpers
- ILeanbackLauncherStrategy launcherStrategy = LauncherStrategyFactory.getInstance(
- mDevice).getLeanbackLauncherStrategy();
- if (launcherStrategy instanceof LeanbackLauncherStrategy) {
- mLauncherStrategy = (LeanbackLauncherStrategy) launcherStrategy;
- }
- mCmdHelper = new CommandHelper(getInstrumentation());
- mDPadHelper = DPadHelper.getInstance(getInstrumentation());
- mLeanbackDemoHelper = new LeanbackDemoHelperImpl(getInstrumentation());
- mNoTouchAuthHelper = new NoTouchAuthHelperImpl(getInstrumentation());
- mPipHelper = new SysUiPipHelperImpl(getInstrumentation());
- mRecentsHelper = new SysUiRecentsHelperImpl(getInstrumentation());
- mSearchHelper = new SearchHelperImpl(getInstrumentation());
- mSettingsHelper = new SysUiSettingsHelperImpl(getInstrumentation());
- mYouTubeHelper = new YouTubeHelperImpl(getInstrumentation());
- }
-
- protected Instrumentation getInstrumentation() {
- return mInstrumentation;
- }
-
- protected int getArgumentsAsInt(String key, int defaultValue) {
- String stringValue = mArguments.getString(key);
- if (stringValue != null) {
- try {
- return Integer.parseInt(stringValue);
- } catch (NumberFormatException e) {
- Log.w(TAG, String.format("Unable to parse arg %s with value %s to a integer.",
- key, stringValue), e);
- }
- }
- return defaultValue;
- }
-
- protected boolean getArgumentsAsBoolean(String key, boolean defaultValue) {
- String stringValue = mArguments.getString(key);
- if (stringValue != null) {
- try {
- return Boolean.parseBoolean(stringValue);
- } catch (Exception e) {
- Log.w(TAG, String.format("Unable to parse arg %s with value to a boolean.",
- key, stringValue), e);
- }
- }
- return defaultValue;
- }
-
- protected static boolean isRestrictedUser(Context context) {
- UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- UserInfo userInfo = userManager.getUserInfo(UserHandle.myUserId());
- Log.d(TAG, "isRestrictedUser? " + (userInfo.isRestricted() ? "Y" : "N"));
- return userInfo.isRestricted();
- }
-
- protected static boolean hasRestrictedUser(Context context) {
- UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- for (UserInfo userInfo : userManager.getUsers()) {
- if (userInfo.isRestricted()) {
- Log.d(TAG, "hasRestrictedUser? Y");
- return true;
- }
- }
- Log.d(TAG, "hasRestrictedUser? N");
- return false;
- }
-}
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/TestSetupInstrumentation.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/TestSetupInstrumentation.java
deleted file mode 100644
index edf03c6cf..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/TestSetupInstrumentation.java
+++ /dev/null
@@ -1,126 +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 android.test.functional.tv.common;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.os.Bundle;
-import android.support.test.InstrumentationRegistry;
-import android.test.functional.tv.settings.MultiUserInRestrictedProfileTests;
-import android.util.Log;
-
-/**
- * Test setup instrumentation for Functional verification tests
- *
- * adb shell am instrument -w -r \
- * -e restrictedProfile [create | delete | exit] \
- * -e pinCode <4 digit code> \
- * android.test.functional.tv.sysui/android.test.functional.tv.common.TestSetupInstrumentation
- */
-public class TestSetupInstrumentation extends Instrumentation {
-
- private static final String TAG = TestSetupInstrumentation.class.getSimpleName();
- private static final String ARGUMENT_SETUP_MODE = "restrictedProfile";
- private static final String ARGUMENT_PINCODE = "pinCode";
- private static final String SETUP_MODE_CREATE_RESTRICTED_PROFILE = "create";
- private static final String SETUP_MODE_DELETE_RESTRICTED_PROFILE = "delete";
- private static final String SETUP_MODE_EXIT_RESTRICTED_PROFILE = "exit";
- private static final String PIN_CODE = "1010";
-
- private Bundle mArguments;
-
- @Override
- public void onCreate(Bundle arguments) {
- super.onCreate(arguments);
- InstrumentationRegistry.registerInstance(this, arguments);
- mArguments = arguments;
- start();
- }
-
- @Override
- public void onStart() {
- super.onStart();
- try {
- setup();
- finish(Activity.RESULT_OK, new Bundle());
- } catch (TestSetupException e) {
- error(e.getMessage());
- }
- }
-
- private void setup() throws TestSetupException {
- final String setupMode = mArguments.getString(ARGUMENT_SETUP_MODE, "");
- if (setupMode == null) {
- error("Performing no setup actions because " + ARGUMENT_SETUP_MODE
- + " was not passed as an argument");
- } else {
- Log.i(TAG, "Running setup for " + setupMode + " tests.");
- switch (setupMode) {
- case SETUP_MODE_CREATE_RESTRICTED_PROFILE:
- createRestrictedProfile();
- break;
- case SETUP_MODE_DELETE_RESTRICTED_PROFILE:
- deleteRestrictedProfile();
- break;
- case SETUP_MODE_EXIT_RESTRICTED_PROFILE:
- exitRestrictedProfile();
- break;
- default:
- throw new TestSetupException(
- "Unknown " + ARGUMENT_SETUP_MODE + " of " + setupMode);
- }
- }
- }
-
- private void createRestrictedProfile() throws TestSetupException {
- final String pinCode = mArguments.getString(ARGUMENT_PINCODE, PIN_CODE);
- if (!MultiUserInRestrictedProfileTests.Setup.createRestrictedProfile(this, pinCode, true)) {
- throw new TestSetupException("Failed to create the restricted profile");
- }
- }
-
- private void deleteRestrictedProfile() throws TestSetupException {
- final String pinCode = mArguments.getString(ARGUMENT_PINCODE, PIN_CODE);
- if (!MultiUserInRestrictedProfileTests.Setup.deleteRestrictedProfile(this, pinCode)) {
- throw new TestSetupException("Failed to delete the restricted profile");
- }
- }
-
- private void exitRestrictedProfile() throws TestSetupException {
- if (!MultiUserInRestrictedProfileTests.Setup.exitRestrictedProfile(this)) {
- throw new TestSetupException("Failed to exit the restricted profile");
- }
- }
-
- /**
- * Provide an error message to the instrumentation result
- * @param message
- */
- public void error(String message) {
- Log.e(TAG, String.format("error message=%s", message));
- Bundle output = new Bundle();
- output.putString("error", message);
- finish(Activity.RESULT_CANCELED, output);
- }
-
- static class TestSetupException extends Exception {
- public TestSetupException(String msg) {
- super(msg);
- }
- }
-}
-
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/UiWatchers.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/UiWatchers.java
deleted file mode 100644
index 90cb05c7a..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/common/UiWatchers.java
+++ /dev/null
@@ -1,112 +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 android.test.functional.tv.common;
-
-import android.app.Instrumentation;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiWatcher;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Utility class to monitor a UI object to dismiss.
- */
-public final class UiWatchers {
- private static final String LOG_TAG = UiWatchers.class.getSimpleName();
- private static final long WAIT_TIME_MS = 3000;
-
- private UiDevice mDevice;
- private List<String> mWatcherNames = new ArrayList<>();
-
-
- public UiWatchers(Instrumentation instrumentation) {
- mDevice = UiDevice.getInstance(instrumentation);
- }
-
- /**
- * Register a new watcher that looks for a object and dismisses it.
- */
- public void registerDismissWatcher(final String watcherName, final BySelector watch,
- final BySelector click) {
- if (mWatcherNames.contains(watcherName)) {
- Log.i(LOG_TAG,
- String.format("The watcher %s already registered. Skipped!", watcherName));
- return;
- }
- mWatcherNames.add(watcherName);
- mDevice.registerWatcher(watcherName, new UiWatcher() {
- @Override
- public boolean checkForCondition() {
- if (mDevice.hasObject(watch)) {
- UiObject2 dismiss = mDevice.wait(Until.findObject(click), WAIT_TIME_MS);
- dismiss.click();
- postHandler(watcherName);
- return true; // triggered
- }
- return false; // not triggered
- }
- });
- }
-
- public void unregisterDismissWatcher(String watcherName) {
- mDevice.removeWatcher(watcherName);
- mWatcherNames.remove(watcherName);
- }
-
- /**
- * Checks if any registered UiWatcher have triggered.
- * @return
- */
- public boolean hasWatcherTriggered() {
- for (String watcherName : mWatcherNames) {
- if (hasWatcherTriggered(watcherName)) {
- Log.i(LOG_TAG,
- String.format("Found the watcher %s have triggered.", watcherName));
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if a specific registered UiWatcher has triggered.
- * @param watcherName
- * @return
- */
- public boolean hasWatcherTriggered(String watcherName) {
- if (!mWatcherNames.contains(watcherName)) {
- Log.w(LOG_TAG, String.format("The watcher %s not registered.", watcherName));
- }
- return mDevice.hasWatcherTriggered(watcherName);
- }
-
- public void resetWatchers() {
- mDevice.resetWatcherTriggers();
- }
-
- /**
- * Current implementation ignores the exception and continues.
- */
- public void postHandler(String watcherName) {
- Log.i(LOG_TAG, String.format("%s dismissed", watcherName));
- }
-}
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/AccessibilitySettingsTests.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/AccessibilitySettingsTests.java
deleted file mode 100644
index 9f188355f..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/AccessibilitySettingsTests.java
+++ /dev/null
@@ -1,170 +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 android.test.functional.tv.settings;
-
-import android.provider.Settings;
-import android.test.functional.tv.common.SysUiTestBase;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Functional verification tests for the caption display on TV.
- *
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.settings.AccessibilitySettingsTests \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-public class AccessibilitySettingsTests extends SysUiTestBase {
- private static final String TAG = AccessibilitySettingsTests.class.getSimpleName();
- private static final long LOADING_TIMEOUT_MS = 5000; // 5 seconds
-
- // The following constants are hidden in API 24.
- private static final String ACCESSIBILITY_CAPTIONING_ENABLED =
- "accessibility_captioning_enabled";
- private static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED =
- "high_text_contrast_enabled";
-
- private static final String TEXT_ACCESSIBILITY = "Accessibility";
- private static final String TEXT_CAPTIONS = "Captions";
- private static final String TEXT_DISPLAY = "Display";
- private static final String TEXT_HIGHCONTRASTTEXT = "High contrast text";
- private static final int TIMEOUT_MS = 3000;
-
- private boolean mHighContrastTextOn = false;
-
- @Before
- public void setUp() {
- mLauncherStrategy.open();
- }
-
- @After
- public void tearDown() {
- // Clean up: Turn off High contrast text if on.
- if (mHighContrastTextOn) {
- mHighContrastTextOn = false;
- if (mSettingsHelper.isSwitchBarOn(TEXT_HIGHCONTRASTTEXT)) {
- mSettingsHelper.clickSetting(TEXT_HIGHCONTRASTTEXT);
- }
- }
-
- mSettingsHelper.exit();
- }
-
- /**
- * Objective: Verify the captioning display is enabled.
- */
- @Test
- public void testEnableCaptionDisplay() throws Exception {
- // Open captions menu
- mSettingsHelper.open(Settings.ACTION_CAPTIONING_SETTINGS, LOADING_TIMEOUT_MS);
-
- // Turn off if the option is already turned on
- if (mSettingsHelper.isSwitchBarOn(TEXT_DISPLAY)) {
- mSettingsHelper.clickSetting(TEXT_DISPLAY);
- }
- if (!mSettingsHelper.isSwitchBarOff(TEXT_DISPLAY)) {
- throw new IllegalStateException(
- "The Display setting should be turned off before this test");
- }
-
- // Enable the caption display
- Assert.assertTrue(mSettingsHelper.clickSetting(TEXT_DISPLAY));
- Assert.assertTrue(mSettingsHelper.isSwitchBarOn(TEXT_DISPLAY));
-
- // Ensure that the sample text appears and the setting is configured correctly
- Assert.assertNotNull("Sample text not found!", mSettingsHelper.hasPreviewText());
- int value = Settings.Secure.getInt(mContext.getContentResolver(),
- ACCESSIBILITY_CAPTIONING_ENABLED);
- Assert.assertEquals("Error: Caption display not enabled!", value, 1);
- }
-
- /**
- * Objective: Verify the captioning display is disabled.
- */
- @Test
- public void testDisableCaptionDisplay() throws Exception {
- // Open captions menu from main Settings activity
- mSettingsHelper.open();
- mSettingsHelper.clickSetting(TEXT_ACCESSIBILITY);
- mSettingsHelper.clickSetting(TEXT_CAPTIONS);
-
- // Turn on if the option is already turned off
- if (mSettingsHelper.isSwitchBarOff(TEXT_DISPLAY)) {
- mSettingsHelper.clickSetting(TEXT_DISPLAY);
- }
- if (!mSettingsHelper.isSwitchBarOn(TEXT_DISPLAY)) {
- throw new IllegalStateException(
- "The Display setting should be turned on before this test");
- }
-
- // Disable the caption display
- Assert.assertTrue(mSettingsHelper.clickSetting(TEXT_DISPLAY));
- Assert.assertTrue(mSettingsHelper.isSwitchBarOff(TEXT_DISPLAY));
-
- // Ensure that the setting is configured correctly
- int value = Settings.Secure.getInt(mContext.getContentResolver(),
- ACCESSIBILITY_CAPTIONING_ENABLED);
- Assert.assertEquals("Error: Caption display not disabled!", value, 0);
- }
-
- /**
- * Objective: Verify that the high contrast text is turned on.
- */
- @Test
- public void testHighContrastTextOn() throws Settings.SettingNotFoundException {
- // Launch accessibility settings
- mSettingsHelper.open();
- Assert.assertTrue(mSettingsHelper.clickSetting(TEXT_ACCESSIBILITY));
-
- // Turn on High contrast text
- if (mSettingsHelper.isSwitchBarOff(TEXT_HIGHCONTRASTTEXT)) {
- Assert.assertTrue(mSettingsHelper.clickSetting(TEXT_HIGHCONTRASTTEXT));
- }
- Assert.assertTrue(mSettingsHelper.isSwitchBarOn(TEXT_HIGHCONTRASTTEXT));
-
- // Ensure that the setting is configured correctly
- int value = Settings.Secure.getInt(mContext.getContentResolver(),
- ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED);
- Assert.assertEquals("Error: High contrast text not enabled!", value, 1);
- mHighContrastTextOn = true;
- }
-
- /**
- * Objective: Verify that the high contrast text is turned off.
- */
- @Test
- public void testHighContrastTextOff() throws Settings.SettingNotFoundException {
- // Launch accessibility settings
- mSettingsHelper.open();
- Assert.assertTrue(mSettingsHelper.clickSetting(TEXT_ACCESSIBILITY));
-
- // Turn off High contrast text
- if (mSettingsHelper.isSwitchBarOn(TEXT_HIGHCONTRASTTEXT)) {
- Assert.assertTrue(mSettingsHelper.clickSetting(TEXT_HIGHCONTRASTTEXT));
- }
- Assert.assertTrue(mSettingsHelper.isSwitchBarOff(TEXT_HIGHCONTRASTTEXT));
-
- // Ensure that the setting is configured correctly
- int value = Settings.Secure.getInt(mContext.getContentResolver(),
- ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED);
- Assert.assertEquals("Error: High contrast text not disabled!", value, 0);
- }
-}
-
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/AccountTests.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/AccountTests.java
deleted file mode 100644
index 43c6bdd95..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/AccountTests.java
+++ /dev/null
@@ -1,351 +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 android.test.functional.tv.settings;
-
-import static junit.framework.Assert.fail;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.accounts.AccountManagerCallback;
-import android.accounts.AccountManagerFuture;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
-import android.os.Bundle;
-import android.platform.test.helpers.exceptions.UiTimeoutException;
-import android.support.test.uiautomator.Until;
-import android.test.functional.tv.common.SysUiTestBase;
-import android.util.Log;
-import android.util.Patterns;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Functional verification tests for managing accounts on TV.
- *
- * adb shell am instrument -w -r \
- * -e account <accountName1,accountName2,...> -e password <password1,password2,...> \
- * -e class android.test.functional.tv.settings.AccountTests \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-public class AccountTests extends SysUiTestBase {
- private static final String TAG = AccountTests.class.getSimpleName();
- private static final String ARGUMENT_ACCOUNT = "account";
- private static final String ARGUMENT_PASSWORD = "password";
- private static final char SEPARATOR = ','; // used to separate multiple accounts and passwords
- private static final String GOOGLE_ACCOUNT = "com.google";
- private static final String DEFAULT_EMAIL_DOMAIN = "@gmail.com";
- private static final String TITLE_ADD_ACCOUNT = "Add account";
- private static final String TITLE_REMOVE_ACCOUNT = "Remove account";
-
- private static final long SHORT_SLEEP_MS = 3000; // 3 seconds
- private static final long LONG_SLEEP_MS = 30000; // 30 seconds
-
- private List<String> mAccountNames = new ArrayList<>();
- private List<String> mPasswords = new ArrayList<>();
- private AccountManager mAm = null;
-
-
- public AccountTests() {
- mAm = AccountManager.get(mContext);
- parseArguments();
- }
-
- @Before
- public void setUp() {
- // Remove all accounts
- removeAccounts();
- mLauncherStrategy.open();
- }
-
- @After
- public void tearDown() {
- mSettingsHelper.exit();
- }
-
- /**
- * Objective: Able to sign in with an account when no account on TV, and remove the account
- */
- @Test
- public void testSignInOneAccountAndRemove() {
- // Log in with the first account info
- String accountName = getEmailFromAccountName(mAccountNames.get(0));
- String password = mPasswords.get(0);
- openSettingsAndLogin(accountName, password);
-
- // Verify that the login is successful and the account name appears in summary
- Assert.assertTrue(mSettingsHelper.hasSettingBySummary(accountName));
- Assert.assertEquals(getAccounts().size(), 1);
-
- // Remove the account in Settings
- Assert.assertTrue(
- mSettingsHelper.clickSettingBySummary(accountName));
- Assert.assertTrue(mSettingsHelper.clickSetting(TITLE_REMOVE_ACCOUNT));
- Assert.assertNotNull(mSettingsHelper.selectGuidedAction("OK"));
- mDPadHelper.pressDPadCenterAndWait(Until.newWindow(), SHORT_SLEEP_MS);
-
- // Verify that the account is removed
- Assert.assertEquals(getAccounts().size(), 0);
- }
-
- /**
- * Objective: Verify that user cannot log in the same account
- */
- @Test
- public void testDisallowSignInSameAccount() {
- // Log in with the first account info
- String accountName = mAccountNames.get(0);
- String password = mPasswords.get(0);
- openSettingsAndLogin(accountName, password);
- if (getAccounts().size() != 1) {
- throw new IllegalStateException("The first login was not successful.");
- }
-
- // Log in with the account already registered should fail
- mSettingsHelper.clickSetting(TITLE_ADD_ACCOUNT);
- mNoTouchAuthHelper.waitForOpen(SHORT_SLEEP_MS);
- if (mNoTouchAuthHelper.loginAccount(accountName, password)) {
- fail("The login with the account already registered should be disallowed.");
- }
-
- // Verify that the attempt to login with the same account is rejected
- Assert.assertEquals(getAccounts().size(), 1);
- }
-
- /**
- * Objective: Able to sign in with multiple accounts when no account on TV
- */
- @Test
- public void testSignInWithMultiAccounts() {
- int accountsCount = mAccountNames.size();
- if (accountsCount < 2) {
- throw new IllegalArgumentException("More than one account required");
- }
-
- // Log in with multiple accounts
- for (int i = 0; i < accountsCount; ++i) {
- openSettingsAndLogin(mAccountNames.get(i), mPasswords.get(i));
- }
-
- // Verify that the login with multiple accounts is successful
- for (int i = accountsCount - 1; i >= 0; --i) {
- Assert.assertTrue(mSettingsHelper.hasSettingByTitleOrSummary(
- getEmailFromAccountName(mAccountNames.get(i))));
- }
- Assert.assertEquals(getAccounts().size(), accountsCount);
- }
-
- /**
- * Objective: Verify that user can switch accounts in the YouTube app.
- */
- @Test
- public void testSwitchAccountsInYouTube() {
- // Clean data, and set up two accounts
- mCmdHelper.executeShellCommand(String.format("pm clear %s", mYouTubeHelper.getPackage()));
- int accountsCount = mAccountNames.size();
- if (accountsCount < 2) {
- throw new IllegalArgumentException("More than one account required");
- }
- for (int i = 0; i < accountsCount; ++i) {
- openSettingsAndLogin(getEmailFromAccountName(mAccountNames.get(i)), mPasswords.get(i));
- }
- if (getAccounts().size() != accountsCount) {
- throw new IllegalStateException(
- String.format("This test requires to log in with more than one account. "
- + "%d expected, %d found", accountsCount, getAccounts().size()));
- }
-
- // Verify that the login is successful in Settings
- Assert.assertEquals(getAccounts().size(), accountsCount);
-
- // Select the first account to log in YouTube
- mYouTubeHelper.open();
- // Note that the Sign-in page appears only when no account has been set up.
- // Once signed in, it would be no longer prompted even after the signout.
- // Clean app data on top of this test
- String firstAccount = getEmailFromAccountName(mAccountNames.get(0));
- Assert.assertTrue(mYouTubeHelper.signIn(firstAccount));
- mYouTubeHelper.waitForContentLoaded(SHORT_SLEEP_MS);
-
- // Verify that the account is set up in YouTube
- Assert.assertEquals(mYouTubeHelper.getSignInUserName(), firstAccount);
-
- // Sign out
- mYouTubeHelper.signOut();
-
- // Open the Setting, switch to the second account
- mYouTubeHelper.openSettings();
- mYouTubeHelper.openCardInRow("Sign in");
- String secondAccount = getEmailFromAccountName(mAccountNames.get(1));
- Assert.assertTrue(mYouTubeHelper.signIn(secondAccount));
- mYouTubeHelper.waitForContentLoaded(SHORT_SLEEP_MS);
-
- // Verify that the account is set up in YouTube
- Assert.assertEquals(mYouTubeHelper.getSignInUserName(), secondAccount);
- }
-
- @Ignore("Not yet implemented")
- @Test
- public void testSwitchAccountsInPlayStore() {
-
- }
-
- private void openSettingsAndLogin(String accountName, String password) {
- // Open the sign-in page
- mSettingsHelper.open();
- mSettingsHelper.clickSetting(TITLE_ADD_ACCOUNT);
- mNoTouchAuthHelper.waitForOpen(SHORT_SLEEP_MS);
-
- // Log in with an account
- mNoTouchAuthHelper.loginAccount(accountName, password);
-
- // Wait for it to return to the Settings
- if (!mSettingsHelper.waitForOpen(LONG_SLEEP_MS)) {
- throw new UiTimeoutException(
- "Failed to return to the Settings after attempting to login");
- }
- }
-
- /**
- * Parse account names and passwords from arguments in following format:
- * -e account accountName1,accountName2,...
- * -e password password1,password2,...
- *
- * @return list of TestArg data, empty list if input is null
- */
- private void parseArguments() {
- mAccountNames.clear();
- mPasswords.clear();
- String accountNamesArg = mArguments.getString(ARGUMENT_ACCOUNT, "");
- for (String accountName : accountNamesArg.split(String.valueOf(SEPARATOR))) {
- // The account name needs to be unique
- if (!"".equals(accountName) && !mAccountNames.contains(accountName)) {
- mAccountNames.add(accountName);
- }
- }
- String passwordsArg = mArguments.getString(ARGUMENT_PASSWORD, "");
- for (String password : passwordsArg.split(String.valueOf(SEPARATOR))) {
- if (!"".equals(password)) {
- mPasswords.add(password);
- }
- }
-
- if (mAccountNames.size() == 0) {
- throw new IllegalArgumentException(
- String.format("The argument '%s' required for test not found",
- ARGUMENT_ACCOUNT));
- } else if (mPasswords.size() == 0) {
- throw new IllegalArgumentException(
- String.format("The argument '%s' required for test not found",
- ARGUMENT_PASSWORD));
- } else if (mAccountNames.size() != mPasswords.size()) {
- throw new IllegalArgumentException(String.format(
- "The number of 'account' and 'password' arguments should be same. %d != %d",
- mAccountNames.size(), mPasswords.size()));
- }
- }
-
- // The following helper functions to manage accounts requires to sign the test apk with
- // the platform keys and the system uid.
- private List<String> getAccounts() {
- List<String> accountNames = new ArrayList<>();
- Account[] accounts = mAm.getAccountsByType(GOOGLE_ACCOUNT);
- for (Account account : accounts) {
- Log.i(TAG, String.format("Found account %s", account.name));
- accountNames.add(account.name);
- }
- return accountNames;
- }
-
- private void removeAccounts() {
- Account[] accounts = mAm.getAccountsByType(GOOGLE_ACCOUNT);
- for (Account account : accounts) {
- Log.i(TAG, String.format("Removing account %s", account.name));
- RemoveCallback callback = new RemoveCallback();
- mAm.removeAccount(account, null, callback, null);
- if (callback.waitForRemoveCompletion() == null) {
- Log.e(TAG, String.format("Failed to remove account %s: Reason: %s",
- account.name, callback.getErrorMessage()));
- return;
- }
- }
- }
-
- /**
- * @param accountName the account name passed in arguments. This may or may not be an email
- * @return the account name if the username is an email address or the account name appended
- * with @gmail.com if not
- */
- private String getEmailFromAccountName(String accountName) {
- StringBuilder sb = new StringBuilder(accountName);
- if (!Patterns.EMAIL_ADDRESS.matcher(sb).matches()) {
- sb.append(DEFAULT_EMAIL_DOMAIN);
- }
- return sb.toString();
- }
-
- static class RemoveCallback implements AccountManagerCallback<Bundle> {
- // stores the result of account removal. null means not finished
- private Bundle mResult = null;
- private String mErrorMessage = null;
-
- public synchronized Bundle waitForRemoveCompletion() {
- while (mResult == null) {
- try {
- wait(LONG_SLEEP_MS);
- } catch (InterruptedException e) {
- // ignore
- }
- }
- return mResult;
- }
-
- @Override
- public void run(AccountManagerFuture<Bundle> future) {
- try {
- mResult = future.getResult();
- } catch (OperationCanceledException e) {
- handleException(e);
- } catch (IOException e) {
- handleException(e);
- } catch (AuthenticatorException e) {
- handleException(e);
- }
- synchronized (this) {
- notifyAll();
- }
- }
-
- public String getErrorMessage() {
- return mErrorMessage;
- }
-
- private void handleException(Exception e) {
- Log.e(TAG, "Failed to remove account", e);
- mResult = null;
- mErrorMessage = e.toString();
- }
- }
-}
-
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MainSettingsTests.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MainSettingsTests.java
deleted file mode 100644
index 2d9ea4aab..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MainSettingsTests.java
+++ /dev/null
@@ -1,140 +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 android.test.functional.tv.settings;
-
-import android.test.functional.tv.common.SysUiTestBase;
-import android.util.Log;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Functional verification tests for the main settings on TV.
- *
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.settings.MainSettingsTests \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-public class MainSettingsTests extends SysUiTestBase {
-
- private static final String TAG = MainSettingsTests.class.getSimpleName();
- private static final long LOADING_TIMEOUT_MS = 5000; // 5 seconds
-
- private static final Map<String, String[]> DEVICE_SETTINGS = new HashMap<>();
- private static final Map<String, String[]> PREFERENCES_SETTINGS = new HashMap<>();
- private static final Map<String, String[]> REMOTES_SETTINGS = new HashMap<>();
- private static final Map<String, String[]> PERSONAL_SETTINGS = new HashMap<>();
- private static final Map<String, String[]> ACCOUNTS_SETTINGS = new HashMap<>();
- private static final String DEVICE_CATEGORY = "Device";
- private static final String PREFERENCES_CATEGORY = "Preferences";
- private static final String REMOTES_CATEGORY = "Remotes & accessories";
- private static final String PERSONAL_CATEGORY = "Personal";
- private static final String ACCOUNTS_CATEGORY = "Accounts";
-
- private static final String DEVELOPER_OPTIONS_MENU = "Developer options";
- private static final String PROP_BUILD_DISPLAY = "ro.build.display.id";
-
-
- static {
- DEVICE_SETTINGS.put(DEVICE_CATEGORY,
- new String[]{"Network", "Google Cast", "Sound", "Apps", "Screen saver",
- "Storage & reset", "About"});
- PREFERENCES_SETTINGS.put(PREFERENCES_CATEGORY,
- new String[]{"Date & time", "Language", "Keyboard", "Home screen", "Search",
- "Speech", "Accessibility"});
- REMOTES_SETTINGS.put(REMOTES_CATEGORY,
- new String[]{"Add accessory"});
- PERSONAL_SETTINGS.put(PERSONAL_CATEGORY,
- new String[]{"Location", "Security & restrictions", "Usage & Diagnostics"});
- ACCOUNTS_SETTINGS.put(ACCOUNTS_CATEGORY,
- new String[]{"Add account"});
-
- }
-
-
- public MainSettingsTests() {
- }
-
- @Before
- public void setUp() {
- mLauncherStrategy.open();
- mSettingsHelper.open();
- }
-
- @After
- public void tearDown() {
- mSettingsHelper.exit();
- }
-
- /**
- * Objective: Verify the important Settings items are visible and accessible.
- */
- @Test
- public void testEnsureSettingsVisible() {
- for (String s : DEVICE_SETTINGS.get(DEVICE_CATEGORY)) {
- Assert.assertTrue(selectSettingsAndExit(s));
- }
- for (String s : PREFERENCES_SETTINGS.get(PREFERENCES_CATEGORY)) {
- Assert.assertTrue(selectSettingsAndExit(s));
- }
- // The Developer options may not appear
- if (mSettingsHelper.isDeveloperOptionsEnabled()) {
- Assert.assertTrue(selectSettingsAndExit(DEVELOPER_OPTIONS_MENU));
- }
- // Skipping "Remotes & accessories" that needs to be covered in pairing steps.
- //for (String s : REMOTES_SETTINGS.get(REMOTES_CATEGORY)) {
- // Assert.assertTrue(selectSettingsAndExit(s));
- //}
- for (String s : PERSONAL_SETTINGS.get(PERSONAL_CATEGORY)) {
- Assert.assertTrue(selectSettingsAndExit(s));
- }
- for (String s : ACCOUNTS_SETTINGS.get(ACCOUNTS_CATEGORY)) {
- Assert.assertTrue(selectSettingsAndExit(s));
- }
-
- }
-
- /**
- * Objective: Verify the build version details match.
- */
- @Test
- public void testBuildVersion() {
- // Open "About"
- Assert.assertTrue(mSettingsHelper.clickSetting("About"));
-
- // Open "Build"
- // eg, fugu-userdebug 7.0 NRD90E 3040393 dev-keys
- String buildDisplay = mCmdHelper.executeGetProp(PROP_BUILD_DISPLAY);
- Assert.assertTrue(buildDisplay.equals(mSettingsHelper.getSummaryTextByTitle("Build")));
- }
-
- private boolean selectSettingsAndExit(String title) {
- Log.d(TAG, String.format("Checking %s ...", title));
- boolean ret = mSettingsHelper.clickSetting(title) &&
- mSettingsHelper.goBackGuidedSettings(1);
- if (!ret) {
- Log.e(TAG, String.format("Failed to find and exit the setting \"%s\"", title));
- }
- return ret;
- }
-}
-
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MultiUserInRestrictedProfileTests.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MultiUserInRestrictedProfileTests.java
deleted file mode 100644
index 8fa471cb8..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MultiUserInRestrictedProfileTests.java
+++ /dev/null
@@ -1,229 +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 android.test.functional.tv.settings;
-
-import static org.junit.Assert.fail;
-
-import android.app.Instrumentation;
-import android.os.SystemClock;
-import android.platform.test.helpers.DPadHelper;
-import android.platform.test.helpers.tv.SysUiSettingsHelperImpl;
-import android.support.test.launcherhelper.ILauncherStrategy;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.test.functional.tv.common.SysUiTestBase;
-import android.test.functional.tv.common.TestSetupInstrumentation;
-import android.util.Log;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.List;
-
-
-/**
- * Functional verification tests for multi users in the restricted profile
- *
- * Note that this test requires that the primary user created restricted profile and switched to
- * the restricted profile.
- * The test harness needs to set this up before test starts using {@link TestSetupInstrumentation}
- * that provides a way of creating/deleting profiles.
- *
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.settings.MultiUserInRestrictedProfileTests \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-public class MultiUserInRestrictedProfileTests extends SysUiTestBase {
- private static final String TAG = MultiUserInRestrictedProfileTests.class.getSimpleName();
- private static final String TEXT_CREATE_RESTRICTED_PROFILE = "Create restricted profile";
- private static final String TEXT_DELETE_RESTRICTED_PROFILE = "Delete restricted profile";
- private static final String TEXT_ENTER_RESTRICTED_PROFILE = "Enter restricted profile";
- private static final String TEXT_EXIT_RESTRICTED_PROFILE = "Exit restricted profile";
- private static final String TITLE_RESTRICTIONS = "Security & restrictions";
- private static final long SHORT_SLEEP_MS = 3000; // 3 seconds
-
- private static final List<String> ALLOWED_SETTINGS = Arrays.asList(
- "Network", "About", "Accessibility", "Location", "Security & restrictions");
- private static final List<String> DISALLOWED_SETTINGS = Arrays.asList(
- // Device category
- "Google Cast", "Sound", "Apps", "Screen saver", "Storage & reset",
- // Preferences category
- "Date & time", "Language", "Keyboard", "Home screen", "Search", "Speech",
- // Personal category
- "Usage & Diagnostics",
- // Accounts category
- "Add account");
-
- private static final String PIN_CODE = "1010";
-
-
- public MultiUserInRestrictedProfileTests() {
- }
-
- private MultiUserInRestrictedProfileTests(Instrumentation instrumentation) {
- super(instrumentation);
- }
-
- @Before
- public void setUp() {
- mLauncherStrategy.open();
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Objective: Verify that the restricted user could see only allowed apps and limited settings.
- */
- @Test
- public void testEnsureSettingsAsRestrictedUser() {
- // TODO Verify that only the selected apps are shown up on the launcher
-
- // Verify that the Settings has only limited items:
- // Network, About, Accessibility, Add accessory, Location, Security & restrictions
- mSettingsHelper.open();
- for (int count = ALLOWED_SETTINGS.size(); count > 0; count--) {
- String setting = mSettingsHelper.getCurrentFocusedSettingTitle();
- if (DISALLOWED_SETTINGS.contains(setting)) {
- fail(String.format(
- "This setting is disallowed in the Restricted Profile: " + setting));
- }
- if (ALLOWED_SETTINGS.contains(setting)) {
- Assert.assertTrue(selectSettingsAndExit(setting));
- }
- mDPadHelper.pressDPad(Direction.DOWN);
- }
- mSettingsHelper.exit();
- }
-
- /**
- * Objective: Verify that the restricted profile doesn't have permission to use Play store
- */
- @Test
- public void testDisallowPlaystoreAsRestrictedUser() {
- long timestamp = mLauncherStrategy.launch("Play Store", "com.android.vending");
- if (timestamp == ILauncherStrategy.LAUNCH_FAILED_TIMESTAMP) {
- throw new IllegalStateException("Failed to launch Play store");
- }
- // TODO Move this to Play store app helper
- Assert.assertTrue(mDevice.hasObject(
- By.res("android", "message").textStartsWith("You don't have permission to use")));
- }
-
- private boolean selectSettingsAndExit(String title) {
- Log.d(TAG, String.format("Checking %s ...", title));
- boolean ret = mSettingsHelper.clickSetting(title) &&
- mSettingsHelper.goBackGuidedSettings(1);
- if (!ret) {
- Log.e(TAG, String.format("Failed to find and exit the setting \"%s\"", title));
- }
- return ret;
- }
-
- /**
- * Instrumentation setup class for {@link MultiUserInRestrictedProfileTests}
- */
- public static class Setup {
-
- public static boolean createRestrictedProfile(Instrumentation instrumentation,
- String pinCode, boolean switchUser) {
- if (isRestrictedUser(instrumentation.getContext())) {
- Log.e(TAG, "Already in the restricted mode. The test setup has stopped.");
- return false;
- }
- if (hasRestrictedUser(instrumentation.getContext())) {
- Log.e(TAG, "Already has a restricted user. The test setup has stopped.");
- return false;
- }
- SysUiSettingsHelperImpl settingsHelper = new MultiUserInRestrictedProfileTests(
- instrumentation).mSettingsHelper;
- // Start from Home screen
- DPadHelper.getInstance(instrumentation).pressHome();
-
- // Create the restricted profile
- settingsHelper.open();
- settingsHelper.clickSetting(TITLE_RESTRICTIONS);
- settingsHelper.clickSetting(TEXT_CREATE_RESTRICTED_PROFILE);
- settingsHelper.setNewPinCode(pinCode);
- settingsHelper.reenterPinCode(pinCode);
-
- // Pick a few apps in Allowed apps
- settingsHelper.waitForOpenGuidedSetting("Allowed apps", SHORT_SLEEP_MS);
-
- // Then, go back and enter the restricted profile.
- settingsHelper.goBackGuidedSettings(1);
- if (switchUser) {
- settingsHelper.clickSetting(TEXT_ENTER_RESTRICTED_PROFILE);
- }
- return hasRestrictedUser(instrumentation.getContext());
- }
-
- public static boolean deleteRestrictedProfile(Instrumentation instrumentation,
- String pinCode) {
- if (isRestrictedUser(instrumentation.getContext())) {
- Log.e(TAG,
- "A restricted user cannot delete the profile. The test setup has stopped.");
- return false;
- }
- if (!hasRestrictedUser(instrumentation.getContext())) {
- Log.e(TAG, "There is no restricted user to delete. The test setup has stopped.");
- return false;
- }
- SysUiSettingsHelperImpl settingsHelper = new MultiUserInRestrictedProfileTests(
- instrumentation).mSettingsHelper;
- // Start from Home screen
- DPadHelper.getInstance(instrumentation).pressHome();
-
- // Delete the restricted profile
- settingsHelper.open();
- settingsHelper.clickSetting(TITLE_RESTRICTIONS);
- settingsHelper.clickSetting(TEXT_DELETE_RESTRICTED_PROFILE);
- settingsHelper.enterPinCode(pinCode);
- SystemClock.sleep(SHORT_SLEEP_MS);
- if (TEXT_DELETE_RESTRICTED_PROFILE.equals(
- settingsHelper.getCurrentFocusedSettingTitle())) {
- Log.e(TAG, "The setting to delete the restricted profile should be"
- + "gone. The test setup has stopped.");
- return false;
- }
- return !hasRestrictedUser(instrumentation.getContext());
- }
-
- public static boolean exitRestrictedProfile(Instrumentation instrumentation) {
- if (!isRestrictedUser(instrumentation.getContext())) {
- Log.e(TAG, "Not in the restricted mode. The test setup has stopped.");
- return false;
- }
- SysUiSettingsHelperImpl settingsHelper = new MultiUserInRestrictedProfileTests(
- instrumentation).mSettingsHelper;
- // Start from Home screen
- DPadHelper.getInstance(instrumentation).pressHome();
-
- // Exit the restricted profile
- settingsHelper.open();
- settingsHelper.clickSetting(TITLE_RESTRICTIONS);
- settingsHelper.clickSetting(TEXT_EXIT_RESTRICTED_PROFILE);
- settingsHelper.enterPinCode(PIN_CODE);
- return true;
- }
- }
-}
-
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MultiUserTests.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MultiUserTests.java
deleted file mode 100644
index 8f1d5e6f8..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/MultiUserTests.java
+++ /dev/null
@@ -1,158 +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 android.test.functional.tv.settings;
-
-import android.os.SystemClock;
-import android.support.test.uiautomator.Direction;
-import android.test.functional.tv.common.SysUiTestBase;
-import android.util.Log;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-/**
- * Functional verification tests for multi users not in the restricted profile
- *
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.settings.MultiUserTests \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-public class MultiUserTests extends SysUiTestBase {
- private static final String TAG = MultiUserTests.class.getSimpleName();
- private static final String PIN_CODE = "1010";
- private static final String TEXT_CREATE_RESTRICTED_PROFILE = "Create restricted profile";
- private static final String TEXT_DELETE_RESTRICTED_PROFILE = "Delete restricted profile";
- private static final String TITLE_RESTRICTIONS = "Security & restrictions";
-
- private static final long SHORT_SLEEP_MS = 3000; // 3 seconds
-
-
- @Before
- public void setUp() {
- mLauncherStrategy.open();
- mSettingsHelper.open();
- }
-
- @After
- public void tearDown() {
- mSettingsHelper.exit();
- forceRemoveRestrictedProfile();
- }
-
- /**
- * Objective: Able to create a Restricted Profile and delete
- */
- @Test
- public void testCreateRestrictedProfileAndDelete() {
- // Create the Restricted Profile with the PIN code
- Assert.assertTrue(mSettingsHelper.clickSetting(TITLE_RESTRICTIONS));
- Assert.assertTrue(mSettingsHelper.clickSetting(TEXT_CREATE_RESTRICTED_PROFILE));
- Assert.assertTrue(mSettingsHelper.setNewPinCode(PIN_CODE));
- Assert.assertTrue(mSettingsHelper.reenterPinCode(PIN_CODE));
-
- // Pick a few apps in Allowed apps
- Assert.assertTrue(mSettingsHelper.waitForOpenGuidedSetting("Allowed apps", SHORT_SLEEP_MS));
- String title = mSettingsHelper.getCurrentFocusedSettingTitle();
- String titlePrev = "";
- while (!title.equals(titlePrev)) {
- // Verify that all apps but "Location" are disabled by default
- if ("Location".equals(title)) {
- Assert.assertTrue(mSettingsHelper.isSwitchBarOn(title));
- } else {
- Assert.assertTrue(mSettingsHelper.isSwitchBarOff(title));
- }
- mDPadHelper.pressDPad(Direction.DOWN);
- titlePrev = title;
- title = mSettingsHelper.getCurrentFocusedSettingTitle();
- }
-
- final String[] WHITELISTED_APPS = {"YouTube"};
- for (String appName : WHITELISTED_APPS) {
- if (mSettingsHelper.hasSettingByTitle(appName)) {
- mDPadHelper.pressDPadCenter();
- Assert.assertTrue(mSettingsHelper.isSwitchBarOn(appName));
- }
- }
-
- // Then, go back and delete the profile.
- mSettingsHelper.goBackGuidedSettings(1);
- SystemClock.sleep(SHORT_SLEEP_MS); // Wait a little until it creates the profile
- mSettingsHelper.exit();
- deleteRestrictedProfileFromLauncher();
- Assert.assertFalse(hasRestrictedUser(mContext));
- }
-
-
- /**
- * Objective: Verify that entering wrong password 5 times keeps user waiting
- * for 60 seconds for retry
- */
- @Ignore
- @Test
- public void testEnterWrongPassword5Times() {
-
- }
-
- private void deleteRestrictedProfileFromLauncher() {
- if (!hasRestrictedUser(mContext)) {
- Log.d(TAG, "No-op if no restricted profile created");
- return;
- }
- mLauncherStrategy.selectRestrictedProfile();
- mSettingsHelper.clickSetting(TEXT_DELETE_RESTRICTED_PROFILE);
- mSettingsHelper.enterPinCode(PIN_CODE);
- SystemClock.sleep(SHORT_SLEEP_MS);
- if (TEXT_DELETE_RESTRICTED_PROFILE.equals(
- mSettingsHelper.getCurrentFocusedSettingTitle())) {
- throw new IllegalStateException("Failed to delete the Restricted Profile");
- }
- }
-
- // Force remove a restricted user in the tearDown. Avoid calling this method in tests
- // because it is different from the way user uses.
- // TODO Move this to CommandHelper if necessary
- private void forceRemoveRestrictedProfile() {
- if (!hasRestrictedUser(mContext)) {
- Log.d(TAG, "No-op if no restricted profile created");
- return;
- }
- // Retrieve the ID of a restricted user from the pm command.
- // Example :
- // Users:
- // UserInfo{0:Owner:13} running
- // UserInfo{18:Restricted Profile:8}
- String output = mCmdHelper.executeShellCommand("pm list users");
- final Pattern USERS_REGEX = Pattern.compile("UserInfo\\{(\\d+):Restricted Profile:");
- Matcher matcher = USERS_REGEX.matcher(output);
- int userId = 0;
- if (matcher.find()) {
- userId = Integer.parseInt(matcher.group(1));
- Log.i(TAG, String.format("The ID of restricted user is %d", userId));
- }
-
- if (userId > 0) {
- mCmdHelper.executeShellCommand(String.format("pm remove-user %d", userId));
- }
- }
-}
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/TestAll.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/TestAll.java
deleted file mode 100644
index 5246b61cd..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/settings/TestAll.java
+++ /dev/null
@@ -1,33 +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 android.test.functional.tv.settings;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.settings.TestAll \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-})
-public class TestAll {
- // the class remains empty,
- // used only as a holder for the above annotations
-}
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/HomeScreenTests.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/HomeScreenTests.java
deleted file mode 100644
index a72fd722a..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/HomeScreenTests.java
+++ /dev/null
@@ -1,66 +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 android.test.functional.tv.sysui;
-
-import android.test.functional.tv.common.SysUiTestBase;
-import android.util.Log;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Functional verification tests for leanback launcher.
- *
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.sysui.HomeScreenTests \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-public class HomeScreenTests extends SysUiTestBase {
-
- private static final String TAG = HomeScreenTests.class.getSimpleName();
-
- @Before
- public void setUp() {
- mLauncherStrategy.open();
- }
-
- /**
- * Objective: Verify the rows on Home screen
- * - Search orbs & Clock widget
- * - Recommendations row (Google + 3rd party apps)
- * - Apps row
- * - Games row (optional: In case of installed the game apps)
- * - Settings & Network
- */
- @Test
- public void testSelectHomeScreenRows() {
- Log.d(TAG, "testSelectHomeScreenRows");
- Assert.assertNotNull("Failed to select the Recommendations row",
- mLauncherStrategy.selectNotificationRow());
- Assert.assertNotNull("Failed to select the Search orbs",
- mLauncherStrategy.selectSearchRow());
- Assert.assertNotNull("Failed to find the app widget",
- mLauncherStrategy.hasAppWidgetSelector());
- Assert.assertNotNull("Failed to select the Apps row",
- mLauncherStrategy.selectAppsRow());
-
- Assert.assertNotNull("Failed to select the Settings row",
- mLauncherStrategy.selectSettingsRow());
- }
-}
-
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/PipActivityTests.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/PipActivityTests.java
deleted file mode 100644
index 18975f7d6..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/PipActivityTests.java
+++ /dev/null
@@ -1,406 +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 android.test.functional.tv.sysui;
-
-import static android.view.KeyEvent.KEYCODE_HOME;
-import static android.view.KeyEvent.KEYCODE_MEDIA_PAUSE;
-import static android.view.KeyEvent.KEYCODE_MEDIA_PLAY;
-
-import android.media.session.PlaybackState;
-import android.os.SystemClock;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.test.functional.tv.common.SysUiTestBase;
-import android.test.functional.tv.common.UiWatchers;
-import android.util.Log;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Functional verification tests for Picture-in-picture feature. This test requires to install
- * the demo apk of Android TV Leanback Support Library (com.example.android.tvleanback).
- *
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.sysui.PipActivityTests \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-public class PipActivityTests extends SysUiTestBase {
-
- private static final String TAG = PipActivityTests.class.getSimpleName();
- private static final String WATCHER_ONBOARDING = "PipOnboardingWatcher";
- private static final String PACKAGE_TVLEANBACK = "com.example.android.tvleanback";
- private static final String ACTIVITY_PLAYBACKOVERLAY =
- "com.example.android.tvleanback.ui.PlaybackOverlayActivity";
- private static final long SHORT_SLEEP_MS = 3000;
- private static final long LONG_SLEEP_MS = 10000;
- private static final long SHORT_TIMEOUT_MS = 2000;
-
- private boolean shouldStopPipPlayback = true;
-
- private UiWatchers mWatchers;
-
-
- @Before
- public void setUp() {
- shouldStopPipPlayback = true;
- // Register the watcher to dismiss the onboarding activity
- mWatchers = new UiWatchers(getInstrumentation());
- mWatchers.registerDismissWatcher(WATCHER_ONBOARDING,
- By.res("com.android.systemui", "pip_onboarding"),
- By.res("com.android.systemui", "button").text("GOT IT"));
- // clear all recent items before test run
- openAndClearAllRecents(SHORT_TIMEOUT_MS);
- mLauncherStrategy.open();
- }
-
- @After
- public void tearDown() {
- mWatchers.unregisterDismissWatcher(WATCHER_ONBOARDING);
- if (shouldStopPipPlayback) {
- stopPipPlayback();
- }
- }
-
- /**
- * Objective: Verify that PIP window is open by pressing a button given that
- * the application supports the feature.
- */
- @Test
- public void testOpenPipWindow() {
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- // TODO making hasTooltipShown less flaky
- if (!mLeanbackDemoHelper.hasTooltipShown()) {
- Log.d(TAG, "The tooltip text is not detected when opening PIP window. Test is flaky?");
- }
- Assert.assertTrue(isDemoActivityInPip());
- }
-
- /**
- * Objective: Verify that PIP window is open by pressing KEYCODE_WINDOW.
- */
- @Test
- public void testOpenPipWindowOnKeySent() throws InterruptedException {
- startPipPlayback("Google+", "Instant Upload");
- SystemClock.sleep(SHORT_SLEEP_MS);
-
- // Press the PIP key
- mDPadHelper.pressPipKey();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue(isDemoActivityInPip());
- }
-
- /**
- * Objective: Verify that PIP window is located in center and focused when PIP overlay
- * receives the KEYCODE_WINDOW key.
- */
- @Test
- public void testMovePipMenuToCenterOnKeySent() throws InterruptedException {
- startPipPlayback("Google+", "Instant Upload");
- SystemClock.sleep(SHORT_SLEEP_MS);
-
- // Press the PIP key
- mDPadHelper.pressPipKey();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue(isDemoActivityInPip());
- // Press the PIP key code again to move PIP window to center
- mDPadHelper.pressPipKey();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue("The PIP menu should be shown in center",
- mPipHelper.isPipStateMenu(PACKAGE_TVLEANBACK, ACTIVITY_PLAYBACKOVERLAY));
- }
-
- /**
- * Objective: Able to move PIP window to Recents by pressing the Home key
- */
- @Test
- public void testMovePipToRecentsFocused() {
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
- if (!isDemoActivityInPip()) {
- throw new IllegalStateException("PIP playback required for this test");
- }
-
- // Long press HOME key to move PIP to Recents
- mDPadHelper.longPressKeyCode(KEYCODE_HOME);
- SystemClock.sleep(LONG_SLEEP_MS);
- Assert.assertTrue("The PIP should be shown in Recents and focused",
- mPipHelper.isPipStateRecentsFocused(PACKAGE_TVLEANBACK, ACTIVITY_PLAYBACKOVERLAY));
- }
-
- /**
- * Objective: Able to control media playback by media keys (play/pause)
- */
- @Test
- public void testPipPlaybackStateByMediaKeys() {
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
-
- // Press the PAUSE key
- mDPadHelper.pressKeyCode(KEYCODE_MEDIA_PAUSE);
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue("The PAUSE key should pause PIP playback",
- mPipHelper.getPlaybackState(PACKAGE_TVLEANBACK) == PlaybackState.STATE_PAUSED);
-
- // Press the PLAY key
- mDPadHelper.pressKeyCode(KEYCODE_MEDIA_PLAY);
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue("The PLAY key should resume PIP playback",
- mPipHelper.getPlaybackState(PACKAGE_TVLEANBACK) == PlaybackState.STATE_PLAYING);
- }
-
- /**
- * Objective: Verify that the PIP controls is functional in Recents.
- * - Able to control media playback by UI buttons in Recents
- * - Able to send PIP window to the full screen in Recents
- * - Able to close PIP window in Recents
- */
- @Test
- public void testPipControlsInRecents() {
- // Start PIP and move it to Recents
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue(isDemoActivityInPip());
- mDPadHelper.longPressKeyCode(KEYCODE_HOME);
- SystemClock.sleep(SHORT_SLEEP_MS);
-
- // Control media playback by UI buttons in Recents. Pause first.
- mPipHelper.togglePipMediaControls();
- Assert.assertTrue(
- mPipHelper.getPlaybackState(PACKAGE_TVLEANBACK) == PlaybackState.STATE_PAUSED);
- SystemClock.sleep(SHORT_SLEEP_MS);
- mPipHelper.togglePipMediaControls();
- Assert.assertTrue(
- mPipHelper.getPlaybackState(PACKAGE_TVLEANBACK) == PlaybackState.STATE_PLAYING);
- SystemClock.sleep(SHORT_SLEEP_MS);
-
- // Move PIP to full screen
- mPipHelper.selectPipToFullScreenButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue("The activity should be in full screen", isDemoActivityInFullScreen());
-
- // Going back to PIP in Recents
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- Assert.assertTrue(isDemoActivityInPip());
- SystemClock.sleep(SHORT_SLEEP_MS);
- mDPadHelper.longPressKeyCode(KEYCODE_HOME);
- Assert.assertTrue(isDemoActivityInPip());
-
- // Close PIP in Recents
- mPipHelper.selectPipCloseButton();
- Assert.assertFalse("The PIP should be closed", isDemoActivityInPip());
- }
-
- /**
- * Objective: Verify that Recents is functional with PIP on screen.
- * - Select/Deselect PIP window by going up/down
- * - Dismiss an app in Recents
- * - Select an app in Recents
- */
- @Test
- public void testRecentsBehaviorWithPipOn() {
- // Clear all in Recents
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- mRecentsHelper.clearAll();
- mRecentsHelper.exit();
-
- // Open two apps - Play store, YouTube
- final String APP_NAME_PLAYSTORE = "Play Store";
- final String PACKAGE_PLAYSTORE = "com.android.vending";
- mLauncherStrategy.open();
- mLauncherStrategy.launch(APP_NAME_PLAYSTORE, PACKAGE_PLAYSTORE);
- mLauncherStrategy.launch(mYouTubeHelper.getLauncherName(), mYouTubeHelper.getPackage());
-
- // Open PIP in Recents
- mLauncherStrategy.open();
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue(isDemoActivityInPip());
- mDPadHelper.longPressKeyCode(KEYCODE_HOME);
- SystemClock.sleep(SHORT_SLEEP_MS);
-
- // Going up and down between PIP and Recents
- mDPadHelper.pressDPad(Direction.DOWN);
- Assert.assertTrue(
- mPipHelper.isPipStateRecents(PACKAGE_TVLEANBACK, ACTIVITY_PLAYBACKOVERLAY));
- mDPadHelper.pressDPad(Direction.UP);
- Assert.assertTrue(
- mPipHelper.isPipStateRecentsFocused(PACKAGE_TVLEANBACK, ACTIVITY_PLAYBACKOVERLAY));
-
- // Focus on tasks in Recents, move left and dismiss the app - Play store
- mDPadHelper.pressDPad(Direction.DOWN);
- mDPadHelper.pressDPad(Direction.LEFT);
- mRecentsHelper.dismissTask();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertEquals("The task should be gone after dismissed in Recents",
- mRecentsHelper.getTaskCountOnScreen(), 2);
-
- // Open another app - YouTube
- mDPadHelper.pressDPadCenter();
- SystemClock.sleep(SHORT_SLEEP_MS);
- // Verify that both YouTube is open and PIP overlay is presented.
- Assert.assertTrue(mYouTubeHelper.isAppInForeground());
- Assert.assertTrue(isDemoActivityInPip());
- }
-
- /**
- * Objective: Able to send PIP window to the full screen from Now Playing card.
- */
- @Test
- public void testPipToFullScreenOnNowPlaying() {
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
- if (!isDemoActivityInPip()) {
- throw new IllegalStateException("PIP playback required for this test");
- }
-
- // Back to Home screen, find the leftmost Now Playing card
- mLauncherStrategy.open();
- final int MAX_ATTEMPTS = 5;
- // Note that Now Playing card seems to make it hard for UiAutomator to detect idle state.
- // It takes about a minute to complete this test.
- mDPadHelper.pressDPad(Direction.LEFT, MAX_ATTEMPTS);
- mDPadHelper.pressDPadCenter();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue("The activity should be in full screen", isDemoActivityInFullScreen());
- }
-
- /**
- * Objective: Verify that PIP playback won't be interrupted by global search.
- */
- @Test
- public void testVoiceSearchWithPipOn() {
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
- if (!isDemoActivityInPip()) {
- throw new IllegalStateException("PIP playback required for this test");
- }
-
- // Launch TV search app with a query
- mSearchHelper.launchActivityAndQuery(mSearchHelper.KEYBOARD_SEARCH, "android tv");
- // Ensure that PIP video keeps playing
- Assert.assertTrue("The PIP video should keep playing.",
- mPipHelper.getPlaybackState(PACKAGE_TVLEANBACK) == PlaybackState.STATE_PLAYING);
- }
-
- /**
- * Objective: Verify that the Settings moves PIP to the left of the side panel.
- */
- @Test
- public void testMovePipToSettingsBound() {
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
- if (!isDemoActivityInPip()) {
- throw new IllegalStateException("PIP playback required for this test");
- }
-
- // Open Settings
- mSettingsHelper.open();
- SystemClock.sleep(SHORT_SLEEP_MS);
- Assert.assertTrue("The PIP should be shown on the left of Settings",
- mPipHelper.isPipStateSettings(PACKAGE_TVLEANBACK, ACTIVITY_PLAYBACKOVERLAY));
- }
-
- /**
- * Objective: Verify that the video playback from other apps dismisses the PIP playback.
- */
- @Test
- public void testPlayOtherVideoWhilePipPlaying() {
- startPipPlayback("Google+", "Instant Upload");
- mLeanbackDemoHelper.openMediaControlsAndClickPipButton();
- SystemClock.sleep(SHORT_SLEEP_MS);
- if (!isDemoActivityInPip()) {
- throw new IllegalStateException("PIP playback is required for this test");
- }
-
- // Play other video from YouTube for 5 seconds
- // Do not use open() since UiAutomator is likely to be stuck to find UI elements while
- // playing PIP on the background.
- mYouTubeHelper.launchActivity();
- if (!mYouTubeHelper.waitForOpen(SHORT_SLEEP_MS)) {
- throw new IllegalStateException("YouTube should be open for this test");
- }
- mYouTubeHelper.openHome();
- final int PLAYBACK_DURATION_MS = 5000;
- mYouTubeHelper.playFocusedVideo(PLAYBACK_DURATION_MS);
-
- // Verify that PIP playback stopped when another video starts
- int playbackState = mPipHelper.getPlaybackState(PACKAGE_TVLEANBACK);
- Assert.assertTrue("The PIP should be either stopped or gone when another video starts.",
- playbackState == PlaybackState.STATE_STOPPED ||
- playbackState == PlaybackState.STATE_NONE);
- mYouTubeHelper.exit();
- }
-
- /**
- * Objective: Verify that the onboarding screen appears on the first launch of PIP window.
- */
- @Ignore("This requires 'setprop debug.tv.pip_force_onboarding true'")
- @Test
- public void testPipOnboardSeenOnFirstLaunch() {
- // TODO
- }
-
- private void startPipPlayback(String sectionName, String videoName) {
- mLeanbackDemoHelper.open();
- mLeanbackDemoHelper.selectVideoInRowContent(sectionName, videoName);
- mLeanbackDemoHelper.selectWatchTrailer();
- }
-
- private void stopPipPlayback() {
- // Close the current playback in PIP
- mPipHelper.executeCommandPipToFullscreen(PACKAGE_TVLEANBACK, ACTIVITY_PLAYBACKOVERLAY,
- false);
- // Press the BACK key to stop the playback
- final int MAX_DEPTH = 2;
- for (int i = 0; i < MAX_DEPTH; ++i) {
- SystemClock.sleep(SHORT_SLEEP_MS);
- mDevice.pressBack();
- }
- }
-
- private boolean isDemoActivityInPip() {
- return mPipHelper.isPipOnScreen(ACTIVITY_PLAYBACKOVERLAY);
- }
-
- private boolean isDemoActivityInFullScreen() {
- return mPipHelper.isInFullscreen(ACTIVITY_PLAYBACKOVERLAY);
- }
-
- private void openAndClearAllRecents(long timeoutMs) {
- try {
- mRecentsHelper.open(timeoutMs);
- mRecentsHelper.clearAll();
- mRecentsHelper.exit();
- } catch (Exception e) {
- // Ignore
- Log.w(TAG, "Failed to clear all in Recents. " + e.getMessage());
- }
- }
-}
-
diff --git a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/RecentActivityTests.java b/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/RecentActivityTests.java
deleted file mode 100644
index 451513fc8..000000000
--- a/tests/functional/tv/TvSysUiTests/src/android/test/functional/tv/sysui/RecentActivityTests.java
+++ /dev/null
@@ -1,187 +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 android.test.functional.tv.sysui;
-
-import android.os.SystemClock;
-import android.support.test.uiautomator.Direction;
-import android.test.functional.tv.common.SysUiTestBase;
-import android.util.Log;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Functional verification tests for Recents on TV.
- *
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.sysui.RecentActivityTests \
- * android.test.functional.tv.sysui/android.support.test.runner.AndroidJUnitRunner
- */
-public class RecentActivityTests extends SysUiTestBase {
-
- private static final String TAG = RecentActivityTests.class.getSimpleName();
- private static final long SHORT_TIMEOUT_MS = 2000;
- // TODO Use app helpers instead of constants once the helpers are moved in platform_testing
- private static final String APP_NAME_PLAYSTORE = "Play Store";
- private static final String PACKAGE_PLAYSTORE = "com.android.vending";
- private static final String APP_NAME_PLAYMUSIC = "Play Music";
- private static final String PACKAGE_PLAYMUSIC = "com.android.google.music";
- private static String sYouTubeAppName;
- private static String sYouTubePackage;
-
-
- public RecentActivityTests() {
- sYouTubeAppName = mYouTubeHelper.getLauncherName();
- sYouTubePackage = mYouTubeHelper.getPackage();
- }
-
- @Before
- public void setUp() {
- // clear all recent items before test run
- openAndClearAllRecents(SHORT_TIMEOUT_MS);
- mLauncherStrategy.open();
- }
-
- @After
- public void tearDown() {
- mRecentsHelper.exit();
- }
-
- /**
- * Objective: Able to bring up Recent tasks, dismiss them, and exit.
- */
- @Test
- public void testAddDismissRecents() {
- // Open two apps
- mLauncherStrategy.launch(sYouTubeAppName, sYouTubePackage);
- mLauncherStrategy.launch(APP_NAME_PLAYSTORE, PACKAGE_PLAYSTORE);
- mLauncherStrategy.open();
-
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- // Dismiss the last open application, which is Play Store in this case
- mRecentsHelper.dismissTask();
- // Verify that the Play Store app is gone, and YouTube app is still in Recents.
- Assert.assertFalse("The task should be gone after dismissed in Recents",
- mRecentsHelper.selectTask(APP_NAME_PLAYSTORE));
- Assert.assertTrue(mRecentsHelper.selectTask(sYouTubeAppName));
- // Verify that it exits by pressing a Home key
- mRecentsHelper.exit();
- Assert.assertFalse(mRecentsHelper.isAppInForeground());
- }
-
- /**
- * Objective: Open an app in Recents
- */
- @Test
- public void testOpenAppOnRecents() {
- // Open an app
- mLauncherStrategy.launch(sYouTubeAppName, sYouTubePackage);
- mLauncherStrategy.open();
-
- // Reopen the app in Recents
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- Assert.assertTrue(mRecentsHelper.selectTask(sYouTubeAppName));
- mDPadHelper.pressDPadCenter();
- SystemClock.sleep(SHORT_TIMEOUT_MS);
- // Verify that the application is open from Recents
- Assert.assertTrue(mYouTubeHelper.isAppInForeground());
- }
-
- /**
- * Objective: "No recent items" is presented when no app has been launched
- */
- @Test
- public void testNoRecentItems() {
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- Assert.assertTrue("'No recent items' message is presented when no app has been launched",
- mRecentsHelper.hasNoRecentItems());
- }
-
- /**
- * Objective: Focus should be on the second right when it enters Recent from an app activity
- * Otherwise, the focus is on the right end (the latest item).
- */
- @Test
- public void testFocusOnMostRecent() {
- // Open two apps
- mLauncherStrategy.launch(APP_NAME_PLAYSTORE, PACKAGE_PLAYSTORE);
- mLauncherStrategy.launch(sYouTubeAppName, sYouTubePackage);
-
- // Verify that the focus should be on the right end when opening Recents on the Home screen
- mLauncherStrategy.open();
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- Assert.assertEquals("Focus should be on the right end when opening Recents on " +
- "the Home screen", mRecentsHelper.getFocusedTaskName(), sYouTubeAppName);
-
- // Verify that the focus should be on the second right when opening Recents on app activity
- mDPadHelper.pressDPadCenter();
- SystemClock.sleep(SHORT_TIMEOUT_MS);
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- Assert.assertEquals("Focus should be on the second right when opening Recents on " +
- "app activity", mRecentsHelper.getFocusedTaskName(), APP_NAME_PLAYSTORE);
- }
-
- /**
- * Objective: The most Recent task goes to the right
- */
- @Test
- public void testOrderMostRecentToRight() {
- mLauncherStrategy.launch(sYouTubeAppName, sYouTubePackage);
- mLauncherStrategy.launch(APP_NAME_PLAYSTORE, PACKAGE_PLAYSTORE);
- mLauncherStrategy.launch(APP_NAME_PLAYMUSIC, PACKAGE_PLAYMUSIC);
- mLauncherStrategy.open();
-
- // Verify that the previously open task goes to the left
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- Assert.assertEquals(mRecentsHelper.getFocusedTaskName(), APP_NAME_PLAYMUSIC);
- mDPadHelper.pressDPad(Direction.LEFT);
- Assert.assertEquals(mRecentsHelper.getFocusedTaskName(), APP_NAME_PLAYSTORE);
- mDPadHelper.pressDPad(Direction.LEFT);
- Assert.assertEquals(mRecentsHelper.getFocusedTaskName(), sYouTubeAppName);
- }
-
- /**
- * Objective: Only one Recent task is allowed for an each app on Recent activity.
- */
- @Test
- public void testAllowOnlyOneRecentPerApp() {
- // Open an app
- mLauncherStrategy.launch(sYouTubeAppName, sYouTubePackage);
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- Assert.assertTrue(mRecentsHelper.selectTask(sYouTubeAppName));
- mRecentsHelper.exit();
-
- // Reopen the same app
- mLauncherStrategy.launch(sYouTubeAppName, sYouTubePackage);
- mRecentsHelper.open(SHORT_TIMEOUT_MS);
- Assert.assertTrue("Allow only one task per each app in Recents",
- mRecentsHelper.getTaskCountOnScreen() == 1);
- }
-
- private void openAndClearAllRecents(long timeoutMs) {
- try {
- mRecentsHelper.open(timeoutMs);
- mRecentsHelper.clearAll();
- mRecentsHelper.exit();
- } catch (Exception e) {
- // Ignore
- Log.w(TAG, "Failed to clear all in Recents. " + e.getMessage());
- }
- }
-}
diff --git a/tests/functional/tv/YouTubeTests/Android.mk b/tests/functional/tv/YouTubeTests/Android.mk
deleted file mode 100644
index ecf13ce4a..000000000
--- a/tests/functional/tv/YouTubeTests/Android.mk
+++ /dev/null
@@ -1,27 +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.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# ------------------------------------------------
-# build a test apk for YouTube functional testing
-
-LOCAL_PACKAGE_NAME := YouTubeFuncTests
-LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator leanback-app-helpers android-support-test
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_PACKAGE)
-
diff --git a/tests/functional/tv/YouTubeTests/AndroidManifest.xml b/tests/functional/tv/YouTubeTests/AndroidManifest.xml
deleted file mode 100644
index 1c3a2ede3..000000000
--- a/tests/functional/tv/YouTubeTests/AndroidManifest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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="android.test.functional.tv.youtube">
-
- <uses-sdk android:minSdkVersion="21"
- android:targetSdkVersion="24"/>
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.test.functional.tv.youtube"
- android:label="TV YouTube Functional Tests" />
-
-</manifest>
-
-
diff --git a/tests/functional/tv/YouTubeTests/src/android/test/functional/tv/youtube/YouTubeTests.java b/tests/functional/tv/YouTubeTests/src/android/test/functional/tv/youtube/YouTubeTests.java
deleted file mode 100644
index 196e4d56c..000000000
--- a/tests/functional/tv/YouTubeTests/src/android/test/functional/tv/youtube/YouTubeTests.java
+++ /dev/null
@@ -1,146 +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 android.test.functional.tv.youtube;
-
-import android.app.Instrumentation;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.platform.test.helpers.tv.YouTubeHelperImpl;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.launcherhelper.ILeanbackLauncherStrategy;
-import android.support.test.launcherhelper.LauncherStrategyFactory;
-import android.support.test.launcherhelper.LeanbackLauncherStrategy;
-import android.support.test.runner.AndroidJUnit4;
-import android.support.test.uiautomator.UiDevice;
-import android.util.Log;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Functional verification tests for YouTube on TV.
- *
- * adb shell am instrument -w -r \
- * -e class android.test.functional.tv.youtube.YouTubeTests \
- * android.test.functional.tv.youtube/android.support.test.runner.AndroidJUnitRunner
- */
-@RunWith(AndroidJUnit4.class)
-public class YouTubeTests {
-
- private static final String TAG = YouTubeTests.class.getSimpleName();
- private static final String DEFAULT_SEARCH_QUERY = "never gonna give you up";
- private static final long DEFAULT_SEARCH_PLAY_DURATION_MS = 30 * 1000; // 30 seconds
-
- private UiDevice mDevice;
- private Instrumentation mInstrumentation;
- private Context mContext;
- private Bundle mArguments;
-
- private LeanbackLauncherStrategy mLauncherStrategy;
- private YouTubeHelperImpl mYouTubeHelper;
-
-
- public YouTubeTests() {
- initialize(InstrumentationRegistry.getInstrumentation());
- }
-
- private void initialize(Instrumentation instrumentation) {
- // Initialize instances of testing support library
- mInstrumentation = instrumentation;
- mContext = getInstrumentation().getContext();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mArguments = InstrumentationRegistry.getArguments();
-
- // Initialize instances of leanback and app helpers
- ILeanbackLauncherStrategy launcherStrategy = LauncherStrategyFactory.getInstance(
- mDevice).getLeanbackLauncherStrategy();
- if (launcherStrategy instanceof LeanbackLauncherStrategy) {
- mLauncherStrategy = (LeanbackLauncherStrategy) launcherStrategy;
- }
- mYouTubeHelper = new YouTubeHelperImpl(getInstrumentation());
- }
-
- protected Instrumentation getInstrumentation() {
- return mInstrumentation;
- }
-
- @Before
- public void setUp() {
- mLauncherStrategy.open();
- }
-
- @After
- public void tearDown() {
- mYouTubeHelper.exit();
- }
-
-
- /**
- * Objective: Able to play the first video on Home section.
- */
- @Test
- public void testPlayVideoAtHome() {
- mYouTubeHelper.open();
- mYouTubeHelper.openHome();
-
- Log.i(TAG, "found a video: " + mYouTubeHelper.getFocusedVideoTitleText());
- long durationMs = mYouTubeHelper.getFocusedVideoDuration();
- if (durationMs > DEFAULT_SEARCH_PLAY_DURATION_MS) {
- durationMs = DEFAULT_SEARCH_PLAY_DURATION_MS;
- }
- Assert.assertTrue(mYouTubeHelper.playFocusedVideo(durationMs));
- }
-
- /**
- * Objective: Able to search for videos and play.
- */
- @Test
- public void testSearchVideoAndPlay() {
- // Search for a video
- mYouTubeHelper.open();
- mYouTubeHelper.search(DEFAULT_SEARCH_QUERY);
-
- long durationMs = mYouTubeHelper.getFocusedVideoDuration();
- if (durationMs > DEFAULT_SEARCH_PLAY_DURATION_MS) {
- durationMs = DEFAULT_SEARCH_PLAY_DURATION_MS;
- }
-
- // Select the first video in the search results and play
- mYouTubeHelper.openFirstSearchResult();
-
- // Play the video for a given period of time
- SystemClock.sleep(durationMs);
- Assert.assertTrue(mYouTubeHelper.isInVideoPlayback());
- }
-
- /**
- * Objective: Able to launch YouTube video in the Notification row
- */
- @Test
- public void testLaunchVideoInNotificationRow() {
- Assert.assertTrue(mLauncherStrategy.launchNotification(mYouTubeHelper.getLauncherName()));
-
- // Play the video for a given period of time
- SystemClock.sleep(5000);
- Assert.assertTrue(mYouTubeHelper.isInVideoPlayback());
- }
-}
-
diff --git a/tests/jank/sysapp/Android.mk b/tests/jank/sysapp/Android.mk
deleted file mode 100644
index f47c03d6e..000000000
--- a/tests/jank/sysapp/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2015 Google Inc. All Rights Reserved.
-#
-# 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 := SystemAppJankTests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator ub-janktesthelper timeresult-helper-lib \
- first-party-app-helpers
-
-LOCAK_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/tests/jank/sysapp/AndroidManifest.xml b/tests/jank/sysapp/AndroidManifest.xml
deleted file mode 100644
index 1f41c845c..000000000
--- a/tests/jank/sysapp/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.sysapp.janktests">
-
- <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.READ_CONTACTS" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation
- android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.android.sysapp.janktests"
- android:label="SysApp Jank Tests" />
-
-</manifest>
diff --git a/tests/jank/sysapp/src/com/android/sysapp/janktests/BooksJankTests.java b/tests/jank/sysapp/src/com/android/sysapp/janktests/BooksJankTests.java
deleted file mode 100644
index a97e2179a..000000000
--- a/tests/jank/sysapp/src/com/android/sysapp/janktests/BooksJankTests.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2015 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.sysapp.janktests;
-
-import java.io.File;
-import java.io.IOException;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.support.test.jank.GfxMonitor;
-import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import junit.framework.Assert;
-import android.support.test.timeresulthelper.TimeResultLogger;
-
-/**
- * Jank test for Books app recommendation page fling
- */
-
-public class BooksJankTests extends JankTestBase {
- private static final int LONG_TIMEOUT = 1000;
- private static final int SHORT_TIMEOUT = 1000;
- private static final int INNER_LOOP = 5;
- private static final int EXPECTED_FRAMES = 100;
- private static final String PACKAGE_NAME = "com.google.android.apps.books";
- private UiDevice mDevice;
- private static final File TIMESTAMP_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "autotester.log");
- private static final File RESULTS_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "results.log");
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- public void launchApp(String packageName) throws UiObjectNotFoundException{
- PackageManager pm = getInstrumentation().getContext().getPackageManager();
- Intent appIntent = pm.getLaunchIntentForPackage(packageName);
- appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(appIntent);
- SystemClock.sleep(SHORT_TIMEOUT);
- }
-
- public void launchBooks () throws UiObjectNotFoundException, IOException {
- launchApp(PACKAGE_NAME);
- dismissClings();
- openMyLibrary();
- Assert.assertTrue("Books haven't loaded yet", getNumberOfVisibleBooks() > 3);
- TimeResultLogger.writeTimeStampLogStart(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- }
-
- public void afterTestBooksRecommendationPageFling(Bundle metrics) throws IOException {
- TimeResultLogger.writeTimeStampLogEnd(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- TimeResultLogger.writeResultToFile(String.format("%s-%s",
- getClass().getSimpleName(), getName()), RESULTS_FILE, metrics);
- super.afterTest(metrics);
- }
-
- // Measures jank while fling books mylibrary
- @JankTest(beforeTest="launchBooks", expectedFrames=EXPECTED_FRAMES,
- afterTest="afterTestBooksRecommendationPageFling")
- @GfxMonitor(processName=PACKAGE_NAME)
- // Books is not a system app anymore
- public void doNotRun_BooksRecommendationPageFling() {
- UiObject2 container = mDevice.wait(Until.findObject(
- By.res(PACKAGE_NAME, "content_container")), LONG_TIMEOUT);
- for (int i = 0; i < INNER_LOOP; i++) {
- container.scroll(Direction.DOWN, 1.0f);
- SystemClock.sleep(SHORT_TIMEOUT);
- container.scroll(Direction.UP, 1.0f);
- }
- }
-
- // All helper methods are at bottom
- // with the assumptions is that these will have their own library
- private void dismissClings() {
- // Dismiss confidentiality warning. It's okay to timeout here.
- UiObject2 warning = mDevice.wait(
- Until.findObject(By.clazz(".Button").text("OK")), LONG_TIMEOUT);
- if (warning != null) {
- warning. click();
- }
- // Close the drawer.
- UiObject2 close = mDevice.wait(
- Until.findObject(By.desc("Hide navigation drawer")), LONG_TIMEOUT);
- if (close != null) {
- close.click();
- }
- // Turn sync off
- UiObject2 syncoff = mDevice.wait(Until.findObject(
- By.clazz(Button.class).text("Keep sync off")), LONG_TIMEOUT);
- if (syncoff != null) {
- syncoff.click();
- }
- }
-
- public void openNavigationDrawer() {
- if (!mDevice.hasObject(By.res(PACKAGE_NAME, "play_drawer_container"))) {
- mDevice.findObject(By.desc("Show navigation drawer")).click();
- Assert.assertTrue("Failed to open navigation drawer", mDevice.wait(
- Until.hasObject(By.res(PACKAGE_NAME, "play_drawer_list")), LONG_TIMEOUT));
-
- // Extra sleep to wait for the drawer to finish sliding in
- SystemClock.sleep(500);
- }
- }
-
- public void openMyLibrary() {
- openNavigationDrawer();
- UiObject2 library = mDevice.wait(
- Until.findObject(By.text("My Library").res("")), LONG_TIMEOUT);
- Assert.assertNotNull("Could not find 'My Library' button", library);
- library.click();
- }
-
- public int getNumberOfVisibleBooks() {
- UiObject2 list = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "cards_grid")), LONG_TIMEOUT);
- Assert.assertNotNull("Failed to locate 'cards_grid'", list);
- return list.getChildCount();
- }
-}
diff --git a/tests/jank/sysapp/src/com/android/sysapp/janktests/CalendarJankTests.java b/tests/jank/sysapp/src/com/android/sysapp/janktests/CalendarJankTests.java
deleted file mode 100644
index c69522fdb..000000000
--- a/tests/jank/sysapp/src/com/android/sysapp/janktests/CalendarJankTests.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2015 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.sysapp.janktests;
-
-import java.io.File;
-import java.io.IOException;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.support.test.jank.GfxMonitor;
-import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.StaleObjectException;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import android.view.View;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import junit.framework.Assert;
-import android.support.test.timeresulthelper.TimeResultLogger;
-
-/**
- * Jank test for Calendar
- * open and fling
- * cal.jank.test1@gmail
- */
-
-public class CalendarJankTests extends JankTestBase {
- private static final int LONG_TIMEOUT = 2000;
- private static final int SHORT_TIMEOUT = 100;
- private static final int INNER_LOOP = 5;
- private static final int EXPECTED_FRAMES = 100;
- private static final int TAB_MIN_WIDTH = 600;
- private static final String PACKAGE_NAME = "com.google.android.calendar";
- private static final String RES_PACKAGE_NAME = "com.android.calendar";
- private UiDevice mDevice;
- private static final File TIMESTAMP_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "autotester.log");
- private static final File RESULTS_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "results.log");
-
- private BySelector mCalendarSelector = null;
- private Direction mScrollDirection = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mDevice.setOrientationNatural();
- if (mDevice.getDisplaySizeDp().x < TAB_MIN_WIDTH) {
- mCalendarSelector = By.res(PACKAGE_NAME, "timely_list");
- mScrollDirection = Direction.DOWN;
- } else {
- mCalendarSelector = By.res(PACKAGE_NAME, "main_pane");
- mScrollDirection = Direction.RIGHT;
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- public void launchApp(String packageName) throws UiObjectNotFoundException{
- PackageManager pm = getInstrumentation().getContext().getPackageManager();
- Intent appIntent = pm.getLaunchIntentForPackage(packageName);
- appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(appIntent);
- SystemClock.sleep(SHORT_TIMEOUT * 10);
- }
-
- public void launchCalendar() throws UiObjectNotFoundException, IOException {
- launchApp(PACKAGE_NAME);
- mDevice.waitForIdle();
- dismissCling();
- assertNotNull("Calendar can't be found",
- mDevice.wait(Until.findObject(mCalendarSelector), LONG_TIMEOUT));
- TimeResultLogger.writeTimeStampLogStart(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- }
-
- public void afterTestCalendarItemsFling(Bundle metrics) throws IOException {
- TimeResultLogger.writeTimeStampLogEnd(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- TimeResultLogger.writeResultToFile(String.format("%s-%s",
- getClass().getSimpleName(), getName()), RESULTS_FILE, metrics);
- super.afterTest(metrics);
- }
-
- // Measures jank of flinging calendar items
- @JankTest(beforeTest="launchCalendar", expectedFrames=EXPECTED_FRAMES,
- afterTest="afterTestCalendarItemsFling")
- @GfxMonitor(processName=PACKAGE_NAME)
- public void testCalendarItemsFling() {
- UiObject2 calendarItems = null;
- calendarItems = mDevice.wait(Until.findObject(mCalendarSelector), LONG_TIMEOUT);
- for (int i = 0; i < INNER_LOOP; i++) {
- calendarItems.scroll(mScrollDirection, 1.0f);
- SystemClock.sleep(SHORT_TIMEOUT);
- }
- }
-
- private void dismissCling() {
- UiObject2 splashScreen = null;
- splashScreen = mDevice.wait(Until.findObject(
- By.pkg(PACKAGE_NAME).clazz(View.class).desc("Got it")), LONG_TIMEOUT);
- if (splashScreen != null) {
- splashScreen.clickAndWait(Until.newWindow(), SHORT_TIMEOUT);
- }
-
- UiObject2 rightArrow = null;
- short counter = 8;
- while ((rightArrow = mDevice.wait(Until.findObject(By.res(
- PACKAGE_NAME, "right_arrow_touch")), LONG_TIMEOUT)) != null && counter > 0) {
- rightArrow.click();
- --counter;
- }
-
- Pattern pattern = Pattern.compile("GOT IT", Pattern.CASE_INSENSITIVE);
- UiObject2 gotIt = mDevice.wait(Until.findObject(
- By.res(PACKAGE_NAME, "done_button").text(pattern)), LONG_TIMEOUT);
- if (gotIt != null) {
- gotIt.click();
- }
-
- pattern = Pattern.compile("DISMISS", Pattern.CASE_INSENSITIVE);
- UiObject2 dismissSync = mDevice.wait(Until.findObject(
- By.res(PACKAGE_NAME, "button_dismiss").text(pattern)), LONG_TIMEOUT);
- if (dismissSync != null) {
- dismissSync.click();
- }
-
- }
-}
diff --git a/tests/jank/sysapp/src/com/android/sysapp/janktests/ChromeJankTests.java b/tests/jank/sysapp/src/com/android/sysapp/janktests/ChromeJankTests.java
deleted file mode 100644
index 9fe6ae15c..000000000
--- a/tests/jank/sysapp/src/com/android/sysapp/janktests/ChromeJankTests.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2015 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.sysapp.janktests;
-
-import java.io.File;
-import java.io.IOException;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.support.test.jank.GfxMonitor;
-import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import junit.framework.Assert;
-import android.platform.test.helpers.ChromeHelperImpl;
-import android.support.test.timeresulthelper.TimeResultLogger;
-
-/**
- * Jank test for Chorme apps
- * Open overflow menu
- */
-
-public class ChromeJankTests extends JankTestBase {
- private static final int SHORT_TIMEOUT = 1000;
- private static final int LONG_TIMEOUT = 30000;
- private static final int INNER_LOOP = 5;
- private static final int EXPECTED_FRAMES = 100;
- private static final String PACKAGE_NAME = "com.android.chrome";
- private UiDevice mDevice;
- private ChromeHelperImpl chromeHelper;
- private static final File TIMESTAMP_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "autotester.log");
- private static final File RESULTS_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "results.log");
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- public void launchApp(String packageName) throws UiObjectNotFoundException{
- PackageManager pm = getInstrumentation().getContext().getPackageManager();
- Intent appIntent = pm.getLaunchIntentForPackage(packageName);
- appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(appIntent);
- SystemClock.sleep(SHORT_TIMEOUT);
- }
-
- public void launchChrome() throws UiObjectNotFoundException, IOException{
- launchApp(PACKAGE_NAME);
- chromeHelper = new ChromeHelperImpl(getInstrumentation());
- chromeHelper.dismissInitialDialogs();
- getOverflowMenu();
- TimeResultLogger.writeTimeStampLogStart(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- }
-
- public void afterTestChromeOverflowMenuTap(Bundle metrics) throws IOException {
- TimeResultLogger.writeTimeStampLogEnd(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- TimeResultLogger.writeResultToFile(String.format("%s-%s",
- getClass().getSimpleName(), getName()), RESULTS_FILE, metrics);
- super.afterTest(metrics);
- }
-
- // Measures jank window render for overflow menu tap
- @JankTest(beforeTest="launchChrome", expectedFrames=EXPECTED_FRAMES,
- afterTest="afterTestChromeOverflowMenuTap")
- @GfxMonitor(processName=PACKAGE_NAME)
- public void testChromeOverflowMenuTap() {
- for (int i = 0; i < INNER_LOOP; i++) {
- UiObject2 overflow = getOverflowMenu();
- overflow.click();
- SystemClock.sleep(100);
- mDevice.pressBack();
- }
- }
-
- public UiObject2 getOverflowMenu() {
- UiObject2 overflow = mDevice.wait(
- Until.findObject(By.desc("More options")), 5 * SHORT_TIMEOUT);
- Assert.assertNotNull("Failed to locate overflow menu", overflow);
- return overflow;
- }
-}
diff --git a/tests/jank/sysapp/src/com/android/sysapp/janktests/ContactsJankTests.java b/tests/jank/sysapp/src/com/android/sysapp/janktests/ContactsJankTests.java
deleted file mode 100644
index 1d7be9b0e..000000000
--- a/tests/jank/sysapp/src/com/android/sysapp/janktests/ContactsJankTests.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2015 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.sysapp.janktests;
-
-import java.io.File;
-import java.io.IOException;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.provider.ContactsContract;
-import android.support.test.jank.GfxMonitor;
-import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.StaleObjectException;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import android.widget.TextView;
-import junit.framework.Assert;
-import android.support.test.timeresulthelper.TimeResultLogger;
-
-/**
- * Jank test for Contacts
- * open contact list and fling
- */
-
-public class ContactsJankTests extends JankTestBase {
- private static final int TIMEOUT = 5000;
- private static final int SHORT_TIMEOUT = 1000;
- private static final int INNER_LOOP = 5;
- private static final int EXPECTED_FRAMES = 100;
- private static final int MIN_CONTACT_COUNT = 75;
- private static final String PACKAGE_NAME = "com.google.android.contacts";
- private static final String RES_PACKAGE_NAME = "com.android.contacts";
- private static final String PM_PACKAGE_NAME = "com.android.packageinstaller";
- private UiDevice mDevice;
- private static final File TIMESTAMP_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "autotester.log");
- private static final File RESULTS_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "results.log");
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mDevice.setOrientationNatural();
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- public void launchApp(String packageName) throws UiObjectNotFoundException{
- PackageManager pm = getInstrumentation().getContext().getPackageManager();
- Intent appIntent = pm.getLaunchIntentForPackage(packageName);
- appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(appIntent);
- SystemClock.sleep(SHORT_TIMEOUT);
- }
-
- public void launchContacts () throws UiObjectNotFoundException, IOException {
- launchApp(PACKAGE_NAME);
- mDevice.waitForIdle();
- // To infer that test is ready to be executed
- Assert.assertNotNull("'All Contacts' not selected",
- mDevice.wait(Until.findObject(By.clazz(TextView.class).selected(true)), TIMEOUT));
- Assert.assertNotNull("Contacts list is not populated", mDevice.wait(Until.findObject(
- By.res(RES_PACKAGE_NAME, "pinned_header_list_layout")), TIMEOUT));
- Cursor cursor = getInstrumentation().getContext().getContentResolver().query(
- ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
- Assert.assertTrue("There are not enough contacts", cursor.getCount() > MIN_CONTACT_COUNT);
- TimeResultLogger.writeTimeStampLogStart(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- }
-
- public void afterTestAllContactsFling(Bundle metrics) throws IOException {
- TimeResultLogger.writeTimeStampLogEnd(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- TimeResultLogger.writeResultToFile(String.format("%s-%s",
- getClass().getSimpleName(), getName()), RESULTS_FILE, metrics);
- super.afterTest(metrics);
- }
-
- // Measures jank while flinging contacts list
- @JankTest(beforeTest="launchContacts", expectedFrames=EXPECTED_FRAMES,
- afterTest="afterTestAllContactsFling")
- @GfxMonitor(processName=PACKAGE_NAME)
- public void testAllContactsFling() {
- UiObject2 contactList = null;
- for (int i = 0; i < INNER_LOOP; i++) {
- contactList = mDevice.wait(Until.findObject(
- By.res(RES_PACKAGE_NAME, "pinned_header_list_layout")), TIMEOUT);
- contactList.fling(Direction.DOWN);
- SystemClock.sleep(100);
- contactList.fling(Direction.UP);
- SystemClock.sleep(100);
- }
- }
-}
diff --git a/tests/jank/sysapp/src/com/android/sysapp/janktests/GMailJankTests.java b/tests/jank/sysapp/src/com/android/sysapp/janktests/GMailJankTests.java
deleted file mode 100644
index 8f4b8a634..000000000
--- a/tests/jank/sysapp/src/com/android/sysapp/janktests/GMailJankTests.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (C) 2015 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.sysapp.janktests;
-
-import java.io.File;
-import java.io.IOException;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.support.test.jank.GfxMonitor;
-import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.StaleObjectException;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import android.widget.ImageButton;
-import junit.framework.Assert;
-import android.platform.test.helpers.GmailHelperImpl;
-import android.support.test.timeresulthelper.TimeResultLogger;
-import java.util.regex.Pattern;
-
-/**
- * Jank test for scrolling gmail inbox mails
- */
-
-public class GMailJankTests extends JankTestBase {
- private static final int SHORT_TIMEOUT = 1000;
- private static final int LONG_TIMEOUT = 5000;
- private static final int INNER_LOOP = 5;
- private static final int EXPECTED_FRAMES = 100;
- private static final int TAB_MIN_WIDTH = 600;
- private static final String PACKAGE_NAME = "com.google.android.gm";
- private static final String RES_PACKAGE_NAME = "android";
- private UiDevice mDevice;
- private GmailHelperImpl mGmailHelper;
- private static final File TIMESTAMP_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "autotester.log");
- private static final File RESULTS_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "results.log");
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mGmailHelper = new GmailHelperImpl(getInstrumentation());
- mDevice.setOrientationNatural();
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- public void launchApp(String packageName) throws UiObjectNotFoundException{
- PackageManager pm = getInstrumentation().getContext().getPackageManager();
- Intent appIntent = pm.getLaunchIntentForPackage(packageName);
- appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(appIntent);
- SystemClock.sleep(SHORT_TIMEOUT);
- }
-
- public void launchGMail () throws UiObjectNotFoundException {
- launchApp(PACKAGE_NAME);
- mGmailHelper.dismissInitialDialogs();
- }
-
- public void prepGMailInboxFling() throws UiObjectNotFoundException, IOException {
- launchGMail();
- // Ensure test is ready to be executed
- UiObject2 list = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "conversation_list_view")), SHORT_TIMEOUT);
- Assert.assertNotNull("Failed to locate 'conversation_list_view'", list);
- TimeResultLogger.writeTimeStampLogStart(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- }
-
- public void afterTestGMailInboxFling(Bundle metrics) throws IOException {
- TimeResultLogger.writeTimeStampLogEnd(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- TimeResultLogger.writeResultToFile(String.format("%s-%s",
- getClass().getSimpleName(), getName()), RESULTS_FILE, metrics);
- super.afterTest(metrics);
- }
-
- // Measures jank while scrolling gmail inbox
- @JankTest(beforeTest="prepGMailInboxFling", expectedFrames=EXPECTED_FRAMES,
- afterTest="afterTestGMailInboxFling")
- @GfxMonitor(processName=PACKAGE_NAME)
- public void testGMailInboxFling() {
- UiObject2 list = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "conversation_list_view")), LONG_TIMEOUT);
- Assert.assertNotNull("Failed to locate 'conversation_list_view'", list);
- for (int i = 0; i < INNER_LOOP; i++) {
- list.scroll(Direction.DOWN, 1.0f);
- SystemClock.sleep(SHORT_TIMEOUT);
- list.scroll(Direction.UP, 1.0f);
- SystemClock.sleep(SHORT_TIMEOUT);
- }
- }
-
- public void prepOpenNavDrawer() throws UiObjectNotFoundException, IOException {
- launchGMail();
- // Ensure test is ready to be executed
- Assert.assertNotNull("Failed to locate Nav Drawer Openner", openNavigationDrawer());
- TimeResultLogger.writeTimeStampLogStart(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- }
-
- public void afterTestOpenNavDrawer(Bundle metrics) throws IOException {
- TimeResultLogger.writeTimeStampLogEnd(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- TimeResultLogger.writeResultToFile(String.format("%s-%s",
- getClass().getSimpleName(), getName()), RESULTS_FILE, metrics);
- super.afterTest(metrics);
- }
-
- // Measures jank while opening Navigation Drawer
- @JankTest(beforeTest="prepOpenNavDrawer", expectedFrames=EXPECTED_FRAMES,
- afterTest="afterTestOpenNavDrawer")
- @GfxMonitor(processName=PACKAGE_NAME)
- public void testOpenNavDrawer() {
- UiObject2 navDrawer = openNavigationDrawer();
- for (int i = 0; i < INNER_LOOP; i++) {
- navDrawer.click();
- SystemClock.sleep(SHORT_TIMEOUT);
- mDevice.pressBack();
- SystemClock.sleep(SHORT_TIMEOUT);
- }
- }
-
- public void prepFlingNavDrawer() throws UiObjectNotFoundException, IOException{
- launchGMail();
- UiObject2 navDrawer = openNavigationDrawer();
- Assert.assertNotNull("Failed to locate Nav Drawer Openner", navDrawer);
- navDrawer.click();
- // Ensure test is ready to be executed
- UiObject2 acctListBtn = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "account_list_button")),
- SHORT_TIMEOUT);
- Assert.assertNotNull("Failed to locate Nav drawer ", acctListBtn);
- TimeResultLogger.writeTimeStampLogStart(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- }
-
- public void afterTestFlingNavDrawer(Bundle metrics) throws IOException {
- if (!mGmailHelper.closeNavigationDrawer()) {
- UiObject2 container = getNavigationDrawerContainer();
- if (container != null) {
- container.fling(Direction.RIGHT);
- }
- }
- TimeResultLogger.writeTimeStampLogEnd(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- TimeResultLogger.writeResultToFile(String.format("%s-%s",
- getClass().getSimpleName(), getName()), RESULTS_FILE, metrics);
- super.afterTest(metrics);
- }
-
- // Measures jank while flinging Navigation Drawer
- @JankTest(beforeTest="prepFlingNavDrawer", expectedFrames=EXPECTED_FRAMES,
- afterTest="afterTestFlingNavDrawer")
- @GfxMonitor(processName=PACKAGE_NAME)
- public void testFlingNavDrawer() {
- UiObject2 container = getNavigationDrawerContainer();
- for (int i = 0; i < INNER_LOOP; i++) {
- container.fling(Direction.DOWN);
- SystemClock.sleep(SHORT_TIMEOUT);
- container.fling(Direction.UP);
- SystemClock.sleep(SHORT_TIMEOUT);
- }
- }
-
-
- public UiObject2 openNavigationDrawer() {
- UiObject2 nav = mDevice.findObject(By.desc(Pattern.compile(
- "(Open navigation drawer)|(Navigate up)")));
- if (nav == null) {
- throw new IllegalStateException("Could not find navigation drawer");
- }
- return nav;
- }
-
- public UiObject2 getNavigationDrawerContainer() {
- UiObject2 container = null;
- if (mDevice.getDisplaySizeDp().x < TAB_MIN_WIDTH) {
- container = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "content_pane")), SHORT_TIMEOUT);
- } else {
- container = mDevice.wait(
- Until.findObject(By.res(RES_PACKAGE_NAME, "list")), SHORT_TIMEOUT);
- }
- return container;
- }
-}
diff --git a/tests/jank/sysapp/src/com/android/sysapp/janktests/YouTubeJankTests.java b/tests/jank/sysapp/src/com/android/sysapp/janktests/YouTubeJankTests.java
deleted file mode 100644
index e51f2b9ce..000000000
--- a/tests/jank/sysapp/src/com/android/sysapp/janktests/YouTubeJankTests.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2015 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.sysapp.janktests;
-
-import java.io.File;
-import java.io.IOException;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.support.test.jank.GfxMonitor;
-import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.Until;
-import junit.framework.Assert;
-import android.support.test.timeresulthelper.TimeResultLogger;
-
-/**
- * Jank test for YouTube recommendation window fling 3 times.
- */
-
-public class YouTubeJankTests extends JankTestBase {
- private static final int LONG_TIMEOUT = 5000;
- private static final int SHORT_TIMEOUT = 1000;
- private static final int INNER_LOOP = 5;
- private static final int EXPECTED_FRAMES = 100;
- private static final String PACKAGE_NAME = "com.google.android.youtube";
- private static final File TIMESTAMP_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "autotester.log");
- private static final File RESULTS_FILE = new File(Environment.getExternalStorageDirectory()
- .getAbsolutePath(), "results.log");
-
- private UiDevice mDevice;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- throw new RuntimeException("failed to freeze device orientaion", e);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDevice.unfreezeRotation();
- super.tearDown();
- }
-
- public void launchApp(String packageName) throws UiObjectNotFoundException {
- PackageManager pm = getInstrumentation().getContext().getPackageManager();
- Intent appIntent = pm.getLaunchIntentForPackage(packageName);
- appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getInstrumentation().getContext().startActivity(appIntent);
- SystemClock.sleep(SHORT_TIMEOUT);
- }
-
- public void launchYouTube () throws UiObjectNotFoundException, IOException {
- launchApp(PACKAGE_NAME);
- dismissCling();
- UiObject2 uiObject = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "pane_fragment_container")), LONG_TIMEOUT);
- Assert.assertNotNull("Recommendation container is null", uiObject);
- TimeResultLogger.writeTimeStampLogStart(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- }
-
- public void afterTestYouTubeRecomendation(Bundle metrics) throws IOException {
- TimeResultLogger.writeTimeStampLogEnd(String.format("%s-%s",
- getClass().getSimpleName(), getName()), TIMESTAMP_FILE);
- TimeResultLogger.writeResultToFile(String.format("%s-%s",
- getClass().getSimpleName(), getName()), RESULTS_FILE, metrics);
- super.afterTest(metrics);
- }
-
- // Measures jank while fling YouTube recommendation
- @JankTest(beforeTest="launchYouTube", expectedFrames=EXPECTED_FRAMES,
- afterTest="afterTestYouTubeRecomendation")
- @GfxMonitor(processName=PACKAGE_NAME)
- public void testYouTubeRecomendationWindowFling() {
- UiObject2 uiObject = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "pane_fragment_container")), LONG_TIMEOUT);
- Assert.assertNotNull("Recommendation container is null", uiObject);
- for (int i = 0; i < INNER_LOOP; i++) {
- uiObject.scroll(Direction.DOWN, 1.0f);
- SystemClock.sleep(100);
- uiObject.scroll(Direction.UP, 1.0f);
- }
- }
-
- private void dismissCling() {
- // Dismiss the dogfood splash screen that might appear on first start
- UiObject2 newNavigationDoneBtn = mDevice.wait(Until.findObject(
- By.res(PACKAGE_NAME, "done_button")), LONG_TIMEOUT);
- if (newNavigationDoneBtn != null) {
- newNavigationDoneBtn.click();
- }
- UiObject2 dialog_dismiss_btn = mDevice.wait(Until.findObject(
- By.res(PACKAGE_NAME, "dogfood_warning_dialog_dismiss_button").text("OK")), LONG_TIMEOUT);
- if (dialog_dismiss_btn != null) {
- dialog_dismiss_btn.click();
- }
- UiObject2 welcomeSkip = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "skip_button").text("Skip")), LONG_TIMEOUT);
- if (welcomeSkip != null) {
- welcomeSkip.click();
- }
- UiObject2 musicFaster = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "text").text("Find music faster")), LONG_TIMEOUT);
- if (musicFaster != null) {
- UiObject2 ok = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "ok").text("OK")), LONG_TIMEOUT);
- Assert.assertNotNull("No 'ok' button to bypass music", ok);
- ok.click();
- }
- UiObject2 laterButton = mDevice.wait(
- Until.findObject(By.res(PACKAGE_NAME, "later_button")), LONG_TIMEOUT);
- if (laterButton != null) {
- laterButton.click();
- }
- }
-}
diff --git a/utils/dialogs/Android.mk b/utils/dialogs/Android.mk
deleted file mode 100644
index 8a625bb04..000000000
--- a/utils/dialogs/Android.mk
+++ /dev/null
@@ -1,27 +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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_PACKAGE_NAME := DialogDismissalUtil
-LOCAL_STATIC_JAVA_LIBRARIES := first-party-app-helpers ub-uiautomator AuptLib android-support-test
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_SDK_VERSION := 23
-
-include $(BUILD_PACKAGE)
diff --git a/utils/dialogs/AndroidManifest.xml b/utils/dialogs/AndroidManifest.xml
deleted file mode 100644
index 3c1381beb..000000000
--- a/utils/dialogs/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright (c) 2016 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.android.test.util.dismissdialogs">
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
- <uses-sdk android:minSdkVersion="23"
- android:targetSdkVersion="23" />
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name=".DismissDialogsInstrumentation"
- android:targetPackage="com.android.test.util.dismissdialogs"
- android:label="Dismiss Dialog Util">
- </instrumentation>
-</manifest>
diff --git a/utils/dialogs/src/com/android/dialogutils/DismissDialogsInstrumentation.java b/utils/dialogs/src/com/android/dialogutils/DismissDialogsInstrumentation.java
deleted file mode 100644
index 8f6cdc027..000000000
--- a/utils/dialogs/src/com/android/dialogutils/DismissDialogsInstrumentation.java
+++ /dev/null
@@ -1,273 +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.test.util.dismissdialogs;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.platform.test.helpers.ChromeHelperImpl;
-import android.platform.test.helpers.GmailHelperImpl;
-import android.platform.test.helpers.GoogleCameraHelperImpl;
-import android.platform.test.helpers.GoogleKeyboardHelperImpl;
-import android.platform.test.helpers.IStandardAppHelper;
-import android.platform.test.helpers.MapsHelperImpl;
-import android.platform.test.helpers.PhotosHelperImpl;
-import android.platform.test.helpers.PlayMoviesHelperImpl;
-import android.platform.test.helpers.PlayMusicHelperImpl;
-import android.platform.test.helpers.PlayStoreHelperImpl;
-import android.platform.test.helpers.YouTubeHelperImpl;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.aupt.UiWatchers;
-import android.support.test.launcherhelper.ILauncherStrategy;
-import android.support.test.launcherhelper.LauncherStrategyFactory;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.util.Log;
-import java.io.File;
-import java.io.IOException;
-import java.lang.IllegalAccessException;
-import java.lang.InstantiationException;
-import java.lang.NoSuchMethodException;
-import java.lang.ReflectiveOperationException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A utility to dismiss all predictable, relevant one-time dialogs
- */
-public class DismissDialogsInstrumentation extends Instrumentation {
- private static final String LOG_TAG = DismissDialogsInstrumentation.class.getSimpleName();
- private static final String IMAGE_SUBFOLDER = "dialog-dismissal";
-
- private static final long INIT_TIMEOUT = 20000;
- private static final long MAX_INIT_RETRIES = 5;
-
- // Comma-separated value indicating for which apps to dismiss dialogs
- private static final String PARAM_APP = "apps";
- // Boolean to indicate if this should take screenshots to document dismissal
- private static final String PARAM_SCREENSHOTS = "screenshots";
- // Boolean to indicate if this should quit if any failure occurs
- private static final String PARAM_QUIT_ON_ERROR = "quitOnError";
-
- // Key for status bundles provided when running the preparer
- private static final String BUNDLE_DISMISSED_APP_KEY = "dismissedApp";
- private static final String BUNDLE_APP_ERROR_KEY = "appError";
-
- private Map<String, Class<? extends IStandardAppHelper>> mKeyHelperMap;
- private String[] mApps;
- private boolean mScreenshots;
- private boolean mQuitOnError;
- private UiDevice mDevice;
-
- @Override
- public void onCreate(Bundle arguments) {
- super.onCreate(arguments);
-
- mKeyHelperMap = new HashMap<String, Class<? extends IStandardAppHelper>>();
- mKeyHelperMap.put("Chrome", ChromeHelperImpl.class);
- mKeyHelperMap.put("GoogleCamera", GoogleCameraHelperImpl.class);
- mKeyHelperMap.put("GoogleKeyboard", GoogleKeyboardHelperImpl.class);
- mKeyHelperMap.put("Gmail", GmailHelperImpl.class);
- mKeyHelperMap.put("Maps", MapsHelperImpl.class);
- mKeyHelperMap.put("Photos", PhotosHelperImpl.class);
- mKeyHelperMap.put("PlayMovies", PlayMoviesHelperImpl.class);
- mKeyHelperMap.put("PlayMusic", PlayMusicHelperImpl.class);
- mKeyHelperMap.put("PlayStore", PlayStoreHelperImpl.class);
- //mKeyHelperMap.put("Settings", SettingsHelperImpl.class);
- mKeyHelperMap.put("YouTube", YouTubeHelperImpl.class);
-
- String appsString = arguments.getString(PARAM_APP);
- if (appsString == null) {
- throw new IllegalArgumentException("Missing 'apps' parameter.");
- }
- mApps = appsString.split(",");
-
- String screenshotsString = arguments.getString(PARAM_SCREENSHOTS);
- if (screenshotsString == null) {
- Log.i(LOG_TAG, "No 'screenshots' parameter. Defaulting to true.");
- mScreenshots = true;
- } else {
- mScreenshots = "true".equals(screenshotsString);
- }
-
- String quitString = arguments.getString(PARAM_QUIT_ON_ERROR);
- if (quitString == null) {
- Log.i(LOG_TAG, "No 'quitOnError' parameter. Defaulting to quit on error.");
- mQuitOnError = true;
- } else {
- mQuitOnError = "true".equals(quitString);
- }
-
- start();
- }
-
- @Override
- public void onStart() {
- super.onStart();
-
- InstrumentationRegistry.registerInstance(this, new Bundle());
-
- mDevice = UiDevice.getInstance(this);
-
- UiWatchers watcherManager = new UiWatchers();
- watcherManager.registerAnrAndCrashWatchers(this);
-
- takeScreenDump("init", "pre-setup");
-
- try {
- mDevice.setOrientationNatural();
- } catch (RemoteException e) {
- Log.e(LOG_TAG, "Unable to set device orientation.", e);
- }
-
- for (int retry = 1; retry <= MAX_INIT_RETRIES; retry++) {
- ILauncherStrategy launcherStrategy =
- LauncherStrategyFactory.getInstance(mDevice).getLauncherStrategy();
- boolean foundHome = mDevice.wait(Until.hasObject(
- launcherStrategy.getWorkspaceSelector()), INIT_TIMEOUT);
- if (foundHome) {
- sendStatusUpdate(Activity.RESULT_OK, "launcher");
- break;
- } else {
- takeScreenDump("init", String.format("launcher-selection-failure-%d", retry));
- if (retry == MAX_INIT_RETRIES && mQuitOnError) {
- throw new RuntimeException("Unable to select launcher workspace. Quitting.");
- } else {
- sendStatusUpdate(Activity.RESULT_CANCELED, "launcher");
- Log.e(LOG_TAG, "Failed to find home selector; try #" + retry);
- // HACK: Try to poke at UI to fix accessibility issue (b/21448825)
- try {
- mDevice.sleep();
- SystemClock.sleep(1000);
- mDevice.wakeUp();
- mDevice.pressMenu();
- UiDevice.getInstance(this).pressHome();
- } catch (RemoteException e) {
- Log.e(LOG_TAG, "Failed to avoid UI bug b/21448825.", e);
- }
- }
- }
- }
-
- for (String app : mApps) {
- Log.i(LOG_TAG, String.format("Dismissing dialogs for app, %s.", app));
- try {
- if (!dismissDialogs(app)) {
- throw new IllegalArgumentException(
- String.format("Unrecognized app \"%s\"", mApps));
- } else {
- sendStatusUpdate(Activity.RESULT_OK, app);
- }
- } catch (ReflectiveOperationException e) {
- if (mQuitOnError) {
- quitWithError(app, e);
- } else {
- sendStatusUpdate(Activity.RESULT_CANCELED, app);
- Log.w(LOG_TAG, "ReflectiveOperationException. Continuing with dismissal.", e);
- }
- } catch (RuntimeException e) {
- if (mQuitOnError) {
- quitWithError(app, e);
- } else {
- sendStatusUpdate(Activity.RESULT_CANCELED, app);
- Log.w(LOG_TAG, "RuntimeException. Continuing with dismissal.", e);
- }
- } catch (AssertionError e) {
- if (mQuitOnError) {
- quitWithError(app, new Exception(e));
- } else {
- sendStatusUpdate(Activity.RESULT_CANCELED, app);
- Log.w(LOG_TAG, "AssertionError. Continuing with dismissal.", e);
- }
- }
-
- // Always return to the home page after dismissal
- UiDevice.getInstance(this).pressHome();
- }
-
- watcherManager.removeAnrAndCrashWatchers(this);
-
- finish(Activity.RESULT_OK, new Bundle());
- }
-
- private boolean dismissDialogs(String app) throws NoSuchMethodException, InstantiationException,
- IllegalAccessException, InvocationTargetException {
- try {
- if (mKeyHelperMap.containsKey(app)) {
- Class<? extends IStandardAppHelper> appHelperClass = mKeyHelperMap.get(app);
- IStandardAppHelper helper =
- appHelperClass.getDeclaredConstructor(Instrumentation.class).newInstance(this);
- takeScreenDump(app, "-dialog1-pre-open");
- helper.open();
- takeScreenDump(app, "-dialog2-pre-dismissal");
- helper.dismissInitialDialogs();
- takeScreenDump(app, "-dialog3-post-dismissal");
- helper.exit();
- takeScreenDump(app, "-dialog4-post-exit");
- return true;
- } else {
- return false;
- }
- } catch (Exception | AssertionError e) {
- takeScreenDump(app, "-exception");
- throw e;
- }
- }
-
- private void sendStatusUpdate(int code, String app) {
- Bundle result = new Bundle();
- result.putString(BUNDLE_DISMISSED_APP_KEY, app);
- sendStatus(code, result);
- }
-
- private void quitWithError(String app, Exception exception) {
- Log.e(LOG_TAG, "Quitting with exception.", exception);
- // Pass Bundle with debugging information to TF
- Bundle result = new Bundle();
- result.putString(BUNDLE_DISMISSED_APP_KEY, app);
- result.putString(BUNDLE_APP_ERROR_KEY, exception.toString());
- finish(Activity.RESULT_CANCELED, result);
- }
-
- private void takeScreenDump(String app, String suffix) {
- if (!mScreenshots) {
- return;
- }
-
- try {
- File dir = new File(Environment.getExternalStorageDirectory(), IMAGE_SUBFOLDER);
- if (!dir.exists() && !dir.mkdirs()) {
- throw new RuntimeException(String.format(
- "Unable to create or find directory, %s.", dir.getPath()));
- }
- File scr = new File(dir, "dd-" + app + suffix + ".png");
- File uix = new File(dir, "dd-" + app + suffix + ".uix");
- Log.v(LOG_TAG, String.format("Screen file path: %s", scr.getPath()));
- Log.v(LOG_TAG, String.format("UI XML file path: %s", uix.getPath()));
- scr.createNewFile();
- uix.createNewFile();
- UiDevice.getInstance(this).takeScreenshot(scr);
- UiDevice.getInstance(this).dumpWindowHierarchy(uix);
- } catch (IOException e) {
- Log.e(LOG_TAG, "Failed screen dump.", e);
- }
- }
-}