summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-01-23 02:19:43 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-01-23 02:19:43 +0000
commit878bd9c791bf887b0e5429dcd5e90373cda89c73 (patch)
tree7a7aa6b2eb6437eedc354794b7a9265796653960
parentb75154d5fcf0a37c2006af9c165adfc3c04d06e5 (diff)
parenta8217e8e4f455507a535d62c1bf86ea42dfadc40 (diff)
downloadplatform_testing-878bd9c791bf887b0e5429dcd5e90373cda89c73.tar.gz
Snap for 6154456 from a8217e8e4f455507a535d62c1bf86ea42dfadc40 to qt-qpr3-release
Change-Id: I70988bcfc356c6049a4c3c373a5b6754d2ff9374
-rw-r--r--libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGenericAppHelper.java2
-rw-r--r--libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterMinimizeControlBarHelper.java7
-rw-r--r--libraries/app-helpers/interfaces/auto/src/android/platform/helpers/utility/Scrollable.java83
3 files changed, 91 insertions, 1 deletions
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGenericAppHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGenericAppHelper.java
index 872f4d6d1..842c5db6b 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGenericAppHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGenericAppHelper.java
@@ -16,7 +16,7 @@
package android.platform.helpers;
-public interface IAutoGenericAppHelper extends IAppHelper {
+public interface IAutoGenericAppHelper extends IAppHelper, Scrollable {
/**
* Set the package to open. The application will be opened using the info activity or launcher
* activity of the package that has been injected here. Either setPackage or setLaunchActivity
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterMinimizeControlBarHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterMinimizeControlBarHelper.java
index 6a8710f6c..f90c0ae88 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterMinimizeControlBarHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterMinimizeControlBarHelper.java
@@ -52,4 +52,11 @@ public interface IAutoMediaCenterMinimizeControlBarHelper extends IAppHelper {
* @return to get current playing track name from home screen.
*/
String getTrackName();
+
+ /**
+ * Setup expectations: media test app is open and Minimize control bar present.
+ *
+ * This method is used to maximize the play back screen.
+ */
+ void maximizeNowPlaying();
}
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/utility/Scrollable.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/utility/Scrollable.java
index 7c8bd714b..c61dc2525 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/utility/Scrollable.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/utility/Scrollable.java
@@ -27,6 +27,8 @@ import androidx.test.InstrumentationRegistry;
* This interface is intended to be inherited by AppHelper classes to add scrolling functionlity.
*/
public interface Scrollable {
+ int DEFAULT_MARGIN = 5;
+
/**
* Setup expectations: None
*
@@ -89,6 +91,81 @@ public interface Scrollable {
}
/**
+ * Setup expectations: None.
+ *
+ * <p>This method can be implemented optionally if customized margin is required.
+ *
+ * @return the gesture margin for scrolling.
+ */
+ public default Margin getScrollableMargin() {
+ return new Margin(DEFAULT_MARGIN);
+ }
+
+ /**
+ * Setup expectations: None.
+ *
+ * <p>This method can be implemented optionally if customized margin is required. It sets the
+ * gesture margin returned by <code>getScrollableMargin()</code>.
+ *
+ * @param margin Left, top, right and bottom margins will all be set this this value.
+ */
+ public default void setScrollableMargin(int margin) {
+ throw new UnsupportedOperationException("setScrollableMargin method not implemeneted.");
+ }
+
+ /**
+ * Setup expectations: None.
+ *
+ * <p>This method can be implemented optionally if customized margin is required. It sets the
+ * gesture margin returned by <code>getScrollableMargin()</code>.
+ *
+ * @param left The value to which to set the left margin for scrollling.
+ * @param top The value to which to set the top margin for scrollling.
+ * @param right The value to which to set the right margin for scrollling.
+ * @param bottom The value to which to set the bottom margin for scrollling.
+ */
+ public default void setScrollableMargin(int left, int top, int right, int bottom) {
+ throw new UnsupportedOperationException("setScrollableMargin method not implemeneted.");
+ }
+
+ public class Margin {
+ private int mLeft;
+ private int mTop;
+ private int mRight;
+ private int mBottom;
+
+ public Margin(int margin) {
+ mLeft = margin;
+ mTop = margin;
+ mRight = margin;
+ mBottom = margin;
+ }
+
+ public Margin(int left, int top, int right, int bottom) {
+ mLeft = left;
+ mTop = top;
+ mRight = right;
+ mBottom = bottom;
+ }
+
+ public int getLeft() {
+ return mLeft;
+ }
+
+ public int getTop() {
+ return mTop;
+ }
+
+ public int getRight() {
+ return mRight;
+ }
+
+ public int getBottom() {
+ return mBottom;
+ }
+ }
+
+ /**
* This is not part of the public interface. For internal use only.
*
* <p>Scroll in <code>direction</code> direction by <code>percent</code> percent of the whole
@@ -105,6 +182,12 @@ public interface Scrollable {
UiObject2 scrollable = device.findObject(By.scrollable(true));
if (scrollable != null) {
+ Margin margin = getScrollableMargin();
+ scrollable.setGestureMargins(
+ margin.getLeft(),
+ margin.getTop(),
+ margin.getRight(),
+ margin.getBottom());
int scrollSpeed = calcScrollSpeed(scrollable, durationMs);
scrollable.scroll(direction, percent / 100, scrollSpeed);
} else {