summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Joines <tjoines@google.com>2017-08-18 02:53:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-08-18 02:53:19 +0000
commit454cbb3b27df2cd7106df0d4dcf4624bcbf3b36b (patch)
tree9491c8f6aecdd16f12b0f90b028ad3a098d075cd
parentaaec526e4806c82b4310ea2c8606f558cfcd28ff (diff)
parent9e4ab99979abbb655c140ee2e869260c6206c8e8 (diff)
downloadplatform_testing-454cbb3b27df2cd7106df0d4dcf4624bcbf3b36b.tar.gz
Merge "Abstract methods for YouTube Go tests" into oc-mr1-dev
-rw-r--r--libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractStandardAppHelper.java25
-rw-r--r--libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractYouTubeHelper.java2
-rw-r--r--libraries/app-helpers/common/src/android/platform/test/helpers/common/IYouTubeGoHelper.java146
3 files changed, 162 insertions, 11 deletions
diff --git a/libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractStandardAppHelper.java b/libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractStandardAppHelper.java
index e63f25ab5..299cb2281 100644
--- a/libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractStandardAppHelper.java
+++ b/libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractStandardAppHelper.java
@@ -238,23 +238,28 @@ public abstract class AbstractStandardAppHelper implements IStandardAppHelper {
protected void checkElementWithIdExists(String packageStr, String id, long timeout) {
- if (!mDevice.wait(Until.hasObject(By.res(packageStr, id)), timeout)){
- throw new UnknownUiException(String.format(ERROR_NOT_FOUND,
- "with id", id, getPackage()));
+ if (!mDevice.wait(Until.hasObject(By.res(packageStr, id)), timeout)) {
+ throw new UnknownUiException(String.format(ERROR_NOT_FOUND, "with id", id, getPackage()));
}
}
protected void checkElementWithTextExists(String text, long timeout) {
- if (!mDevice.wait(Until.hasObject(By.text(text)), timeout)){
- throw new UnknownUiException(
- String.format(ERROR_NOT_FOUND, "with text", text, getPackage()));
+ if (!mDevice.wait(Until.hasObject(By.text(text)), timeout)) {
+ throw new UnknownUiException(
+ String.format(ERROR_NOT_FOUND, "with text", text, getPackage()));
}
}
protected void checkElementWithDescriptionExists(String description, long timeout) {
- if (!mDevice.wait(Until.hasObject(By.desc(description)), timeout)){
- throw new UnknownUiException(
- String.format(ERROR_NOT_FOUND, "with description", description, getPackage()));
- }
+ if (!mDevice.wait(Until.hasObject(By.desc(description)), timeout)) {
+ throw new UnknownUiException(
+ String.format(ERROR_NOT_FOUND, "with description", description, getPackage()));
+ }
+ }
+
+ protected void checkIfElementChecked(UiObject2 element) {
+ if (!element.isChecked()) {
+ throw new UnknownUiException("Element " + element + " is not checked");
+ }
}
} \ No newline at end of file
diff --git a/libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractYouTubeHelper.java b/libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractYouTubeHelper.java
index 4cbb512ba..10795ac3a 100644
--- a/libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractYouTubeHelper.java
+++ b/libraries/app-helpers/common/src/android/platform/test/helpers/common/AbstractYouTubeHelper.java
@@ -123,4 +123,4 @@ public abstract class AbstractYouTubeHelper extends AbstractStandardAppHelper {
* This method resumes the video if it is paused.
*/
public abstract void resumeVideo();
-}
+} \ No newline at end of file
diff --git a/libraries/app-helpers/common/src/android/platform/test/helpers/common/IYouTubeGoHelper.java b/libraries/app-helpers/common/src/android/platform/test/helpers/common/IYouTubeGoHelper.java
new file mode 100644
index 000000000..7d10f45bf
--- /dev/null
+++ b/libraries/app-helpers/common/src/android/platform/test/helpers/common/IYouTubeGoHelper.java
@@ -0,0 +1,146 @@
+package android.platform.test.helpers;
+
+/*
+ * Copyright (C) 2017 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.
+ */
+
+import android.platform.test.helpers.IStandardAppHelper;
+
+public interface IYouTubeGoHelper extends IStandardAppHelper {
+ enum GoVideoQuality {
+ STANDARD("medium"),
+ BASIC("low");
+
+ private String mDisplayName;
+
+ GoVideoQuality(String displayName) {
+ mDisplayName = displayName;
+ }
+
+ @Override
+ public String toString() {
+ return mDisplayName;
+ }
+ }
+
+ /**
+ * Setup expectations: YouTube app is open.
+ * <p>
+ * This method clicks on the first home page video.
+ */
+ void goToHomePage();
+
+ /**
+ * Setup expectations: YouTube is on the home page.
+ * <p>
+ * This method clicks on a video on the home page.
+ */
+ void clickOnHomePageVideo();
+
+ /**
+ * Setup expectations: YouTube app is open.
+ * <p>
+ * This method checks if video quality is the same as provided parameter and changes
+ * to desired if not.
+ *
+ * @param quality the desired {@code IYouTubeGoHelper.GoVideoQuality}
+ */
+ void chooseVideoQuality(GoVideoQuality quality);
+
+ /**
+ * Setup expectations: YouTube app is open on Home page.
+ * <p>
+ * This method clicks on the first video on home page, sets video quality and
+ * then clicks on the Play button.
+ *
+ * @param quality the desired {@code IYouTubeGoHelper.GoVideoQuality}
+ */
+ void playHomePageVideo(GoVideoQuality quality);
+
+ /**
+ * Setup expectations: YouTube is on the video player page.
+ * <p>
+ * This method pauses the video if it is playing.
+ */
+ void pauseVideo();
+
+ /**
+ * Setup expectations: YouTube is on the video player page.
+ * <p>
+ * This method resumes the video if it is paused.
+ */
+ void resumeVideo();
+
+ /**
+ * Setup expectations: YouTube is on the home page.
+ * <p>
+ * This method scrolls to the top of the home page and clicks the search button.
+ */
+ void goToSearchPage();
+
+ /**
+ * Setup expectations: YouTube is on the search page.
+ * <p>
+ * This method executes search query and checks the search results are displayed.
+ */
+ void searchVideo(String query);
+
+ /**
+ * Setup expectations: YouTube is on the search results page.
+ * <p>
+ * This method clicks on the first search result video,
+ * selects video quality and presses play button.
+ *
+ * @param quality the desired {@code IYouTubeGoHelper.GoVideoQuality}
+ */
+ void playSearchResultPageVideo(GoVideoQuality quality);
+
+ /**
+ * Setup expectations: YouTube is on the search results page.
+ * <p>
+ * This method clicks on the first video on the search results page.
+ */
+ void clickOnSearchResultPageVideo();
+
+ /**
+ * Setup expectations: Choose Video Quality pop up is open.
+ * <p>
+ * This method clicks on Play button on Choose Video Quality pop up.
+ */
+ void pressPlayButton();
+
+ /**
+ * Setup expectations: YouTube is on the non-fullscreen video player page.
+ * <p>
+ * This method changes the video player to fullscreen mode. Has no effect if the video player
+ * is already in fullscreen mode.
+ */
+ void goToFullscreenMode();
+
+ /**
+ * Setup expectations: YouTube is on the video player page.
+ * <p>
+ * This method expands video's description.
+ */
+ void expandVideoDescription();
+
+ /**
+ * Setup expectations: YouTube is on the video player page.
+ * <p>
+ * This method waits for video is finished and clicks on replay button.
+ *
+ */
+ void replayVideo();
+}