Merge "Migration of hermetic startup test to CrystalBall." am: bc06403704
Original change: undetermined
Change-Id: I0e8cd9758bf1b8852b374bc658e6c3023986c7db
diff --git a/build/tasks/tests/platform_test_list.mk b/build/tasks/tests/platform_test_list.mk
index 58aa694..fc5ba01 100644
--- a/build/tasks/tests/platform_test_list.mk
+++ b/build/tasks/tests/platform_test_list.mk
@@ -54,6 +54,7 @@
InternalLocTestApp \
JankMicroBenchmarkTests \
long_trace_config.textproto \
+ LauncherRotationStressTest \
MemoryUsage \
MultiDexLegacyTestApp \
MultiDexLegacyTestApp2 \
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
new file mode 100644
index 0000000..060004b
--- /dev/null
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGenericAppHelper.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.platform.helpers;
+
+import java.util.Map;
+
+/**
+ * An interface to open any applications. One of the member methods must be invoked after creating
+ * an instance of this class.
+ */
+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.
+ */
+ void setPackage(String pkg);
+
+ /**
+ * Set the launch activity. The application will be opened directly using the provided activity.
+ */
+ void setLaunchActivity(String pkg);
+
+ /**
+ * Set the launch action. The application will be opened using the provided launch action with
+ * given extra arguments.
+ */
+ void setLaunchAction(String action, Map<String, String> extraArgs);
+}
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGooglePlayHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGooglePlayHelper.java
index c803607..d3330db 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGooglePlayHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoGooglePlayHelper.java
@@ -35,28 +35,29 @@
/**
* Setup expectations: Google Play app is open.
*
- * This method is used to install a app.
+ * <p>This method is used to install a app.
*/
void installApp();
/**
* Setup expectations: Google Play app is open.
*
- * This method is used to cancel a download.
+ * <p>This method is used to cancel a download.
*/
void cancelDownload();
/**
* Setup expectations: Google Play app is open.
*
- * This method is used to open a installed app.
+ * <p>This method is used to return back to Google Play main page
*/
- void openApp();
+ void returnToMainPage();
/**
* Setup expectations: Google Play app is open.
*
- * This method is used to return back to Google Play main page
+ * <p>This method is used to open a installed app.
*/
- void returnToMainPage();
+ @Deprecated
+ void openApp();
}
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterHelper.java
new file mode 100644
index 0000000..52caa07
--- /dev/null
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterHelper.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.platform.helpers;
+
+public interface IAutoMediaCenterHelper extends IAppHelper {
+
+ /**
+ * Setup expectations: Media test app is open.
+ *
+ * This method is used to set account type.
+ */
+ void setAccountType(String accountType);
+
+ /**
+ * Setup expectations: Media test app is open.
+ *
+ * This method is used to set root node type.
+ */
+ void setRootNodeType(String rootNodeType);
+
+ /**
+ * Setup expectations: Media test app is open.
+ *
+ * This method is used to set root reply delay.
+ */
+ void setRootReplyDelay(String rootReplyDelay);
+
+ /**
+ * Setup expectations: media test app is open.
+ *
+ * This method is used to open Folder Menu with menuOptions.
+ * Example - openMenu->Folder->Mediafilename->trackName
+ * openMenuWith(Folder,mediafilename,trackName);
+ *
+ * @param - menuOptions used to pass multiple level of menu options in one go.
+ */
+ void selectMediaTrack(String... menuOptions);
+
+ /**
+ * Setup expectations: media test app is open.
+ *
+ * This method is used to open settings.
+ */
+ void openSettings();
+
+ /**
+ * Setup expectations: media test app is open.
+ *
+ * This method is used to close settings.
+ */
+ void closeSettings();
+
+ /**
+ * Setup expectations: media test app is open.
+ *
+ * @param - tabName used to select tab name.
+ */
+ void selectTab(String tabName);
+
+ /**
+ * Setup expectations: media test app is open.
+ *
+ * @param - title used search media track,artist.
+ */
+ void search(String title);
+
+ /**
+ * This method is used to check if media is currently playing Returns true if media is playing
+ * else returns false
+ */
+ boolean isPlaying();
+}
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
new file mode 100644
index 0000000..f90c0ae
--- /dev/null
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterMinimizeControlBarHelper.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.platform.helpers;
+
+public interface IAutoMediaCenterMinimizeControlBarHelper extends IAppHelper {
+
+ /**
+ * Setup expectations: media test app is open and Minimize control bar present.
+ *
+ * This method is used to play media.
+ */
+ void playMedia();
+
+ /**
+ * Setup expectations: media test app is open and Minimize control bar present.
+ *
+ * This method is used to pause media.
+ */
+ void pauseMedia();
+
+ /**
+ * Setup expectations: media test app is open and Minimize control bar present.
+ *
+ * This method is used to select next track.
+ */
+ void clickNextTrack();
+
+ /**
+ * Setup expectations: media test app is open and Minimize control bar present.
+ *
+ * This method is used to select previous track.
+ */
+ void clickPreviousTrack();
+
+ /**
+ * Setup expectations: media test app is open and Minimize control bar present.
+ *
+ * @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/IAutoMediaCenterNowPlayingHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterNowPlayingHelper.java
new file mode 100644
index 0000000..bbe0e2b
--- /dev/null
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaCenterNowPlayingHelper.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.platform.helpers;
+
+public interface IAutoMediaCenterNowPlayingHelper extends IAppHelper {
+
+ /**
+ * Setup expectations: Now Playing is open.
+ *
+ * This method is used to play media.
+ */
+ void playMedia();
+
+ /**
+ * Setup expectations: Now Playing is open.
+ *
+ * This method is used to pause media.
+ */
+ void pauseMedia();
+
+ /**
+ * Setup expectations: Now Playing is open.
+ *
+ * This method is used to select next track.
+ */
+ void clickNextTrack();
+
+ /**
+ * Setup expectations: Now Playing is open.
+ *
+ * This method is used to select previous track.
+ */
+ void clickPreviousTrack();
+
+ /**
+ * Setup expectations: Now Playing is open.
+ *
+ * @return to get current playing track name from home screen.
+ */
+ String getTrackName();
+
+ /**
+ * Setup expectations: Now Playing is open.
+ *
+ * This method is used to minimize now playing.
+ */
+ void minimizeNowPlaying();
+}
\ No newline at end of file
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
index 035d68f..ada56e7 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
@@ -93,4 +93,24 @@
* @return to get current playing track name.
*/
String getMediaTrackName();
+
+ /**
+ * Setup expectations: on home screen.
+ *
+ * @return to get current playing track name from home screen.
+ */
+ String getMediaTrackNameFromHomeScreen();
+
+ /**
+ * Setup expectations: Media app is open. User navigates to sub-page of the Media Player
+ *
+ * <p>This method is to go back to the Media Player main page from any sub-page.
+ */
+ void goBackToMediaHomePage();
+
+ /**
+ * This method is used to check if media is currently playing Returns true if media is playing
+ * else returns false
+ */
+ boolean isPlaying();
}
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoNotificationHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoNotificationHelper.java
index ac18ada..b5fd0f7 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoNotificationHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoNotificationHelper.java
@@ -16,4 +16,36 @@
package android.platform.helpers;
-public interface IAutoNotificationHelper extends INotificationHelper, Scrollable {}
+public interface IAutoNotificationHelper extends INotificationHelper, Scrollable, IAppHelper {
+ /**
+ * Setup expectations: Notification app is open and scrolled to the bottom.
+ *
+ * <p>Tap clear all button if present.
+ */
+ void tapClearAllBtn();
+
+ /**
+ * Setup expectations: A notification is received.
+ *
+ * <p>Check whether notification has been posted.
+ *
+ * @param title of the notification to be checked.
+ */
+ boolean checkNotificationExists(String title);
+
+ /**
+ * Setup expectations: A notification is received.
+ *
+ * <p>Swipe away a received notification.
+ *
+ * @param title of the notification to be swiped.
+ */
+ void removeNotification(String title);
+
+ /**
+ * Setup expectations: None.
+ *
+ * <p>Swipe down from status bar to open notifications.
+ */
+ void openNotification();
+}
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoNotificationMockingHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoNotificationMockingHelper.java
new file mode 100644
index 0000000..9903832
--- /dev/null
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoNotificationMockingHelper.java
@@ -0,0 +1,3 @@
+package android.platform.helpers;
+
+public interface IAutoNotificationMockingHelper extends INotificationHelper, IAppHelper {}
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 50e10e7..cc8f9a8 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
@@ -28,6 +28,8 @@
* This interface is intended to be inherited by AppHelper classes to add scrolling functionlity.
*/
public interface Scrollable {
+ int DEFAULT_MARGIN = 5;
+
/**
* Setup expectations: None
*
@@ -90,6 +92,81 @@
}
/**
+ * 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
@@ -106,6 +183,12 @@
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 {
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/README.md b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/README.md
new file mode 100644
index 0000000..e780cfd
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/README.md
@@ -0,0 +1,3 @@
+# Full Battery Capacity Configs
+
+These statsd configs collects FullBatteryCapacity metrics.
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/full-battery-capacity-run-level.pb b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/full-battery-capacity-run-level.pb
new file mode 100644
index 0000000..16a19a3
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/full-battery-capacity-run-level.pb
Binary files differ
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/full-battery-capacity-test-level.pb b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/full-battery-capacity-test-level.pb
new file mode 100644
index 0000000..4018b18
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/full-battery-capacity/full-battery-capacity-test-level.pb
Binary files differ
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/README.md b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/README.md
new file mode 100644
index 0000000..c496110
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/README.md
@@ -0,0 +1,3 @@
+# Greenday Power Configs for Run Level and Test Level Metrics
+
+Configs for a smaller set of power metrics : CPUTimePerFreq, MobileBytesTransfer, RemainingBatteryCapacity and WifiBytesTransfer.
\ No newline at end of file
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/greenday-power-smaller-run-level.pb b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/greenday-power-smaller-run-level.pb
new file mode 100644
index 0000000..dd2698b
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/greenday-power-smaller-run-level.pb
Binary files differ
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/greenday-power-smaller-test-level.pb b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/greenday-power-smaller-test-level.pb
new file mode 100644
index 0000000..43dc7c6
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/greenday-power-smaller/greenday-power-smaller-test-level.pb
Binary files differ
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/README.md b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/README.md
new file mode 100644
index 0000000..96dc0d6
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/README.md
@@ -0,0 +1,4 @@
+# On Device Power Measurement Configs
+
+These configs are used to pull the on-device power measurement before and after a test and test run as defined in the
+OnDevicePowerMeasurement atom.
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/on-device-power-measurement-run-level.pb b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/on-device-power-measurement-run-level.pb
new file mode 100644
index 0000000..803e7bb
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/on-device-power-measurement-run-level.pb
Binary files differ
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/on-device-power-measurement-test-level.pb b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/on-device-power-measurement-test-level.pb
new file mode 100644
index 0000000..8387eee
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/on-device-power-measurement/on-device-power-measurement-test-level.pb
Binary files differ
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/README.md b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/README.md
index 558107a..e3f3139 100644
--- a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/README.md
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/README.md
@@ -1,4 +1,4 @@
# Remaining Battery Capacity Configs
These configs are used to collect the remaining battery capacity on the device as defined in the
-RemainingBatteryCapacity (Colomb counter) atom.
+RemainingBatteryCapacity (Colomb counter) atom. Also includes configs with uid to package name mapping
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/remaining-battery-capacity-with-uid-run-level.pb b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/remaining-battery-capacity-with-uid-run-level.pb
new file mode 100644
index 0000000..f4a1d0a
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/remaining-battery-capacity-with-uid-run-level.pb
Binary files differ
diff --git a/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/remaining-battery-capacity-with-uid-test-level.pb b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/remaining-battery-capacity-with-uid-test-level.pb
new file mode 100644
index 0000000..4f534e1
--- /dev/null
+++ b/libraries/device-collectors/src/main/platform-collectors/res/statsd-configs/remaining-battery-capacity/remaining-battery-capacity-with-uid-test-level.pb
Binary files differ
diff --git a/libraries/launcher-helper/src/android/support/test/launcherhelper/AutoLauncherStrategy.java b/libraries/launcher-helper/src/android/support/test/launcherhelper/AutoLauncherStrategy.java
index c547f0d..869d870 100644
--- a/libraries/launcher-helper/src/android/support/test/launcherhelper/AutoLauncherStrategy.java
+++ b/libraries/launcher-helper/src/android/support/test/launcherhelper/AutoLauncherStrategy.java
@@ -23,14 +23,14 @@
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
+import android.system.helpers.CommandsHelper;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import java.util.stream.Stream;
import java.util.stream.Collectors;
-
+import java.util.stream.Stream;
public class AutoLauncherStrategy implements IAutoLauncherStrategy {
private static final String LOG_TAG = AutoLauncherStrategy.class.getSimpleName();
@@ -88,6 +88,7 @@
protected UiDevice mDevice;
private Instrumentation mInstrumentation;
+ private CommandsHelper mCommandsHelper;
/**
* {@inheritDoc}
@@ -111,6 +112,7 @@
@Override
public void setInstrumentation(Instrumentation instrumentation) {
mInstrumentation = instrumentation;
+ mCommandsHelper = CommandsHelper.getInstance(mInstrumentation);
}
/**
@@ -201,9 +203,21 @@
openFacet("Notification");
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
+ public void openNotifications() {
+ String cmd = "cmd statusbar expand-notifications";
+ mCommandsHelper.executeShellCommand(cmd);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void pressHome() {
+ String cmd = "input keyevent KEYCODE_HOME";
+ mCommandsHelper.executeShellCommand(cmd);
+ }
+
+ /** {@inheritDoc} */
@Override
public void openAssistantFacet() {
openFacet("Google Assistant");
@@ -326,6 +340,18 @@
}
}
+ @Override
+ public void openBluetoothAudioApp() {
+ String appName = "Bluetooth Audio";
+ if (checkApplicationExists(appName)) {
+ UiObject2 app = mDevice.findObject(By.clickable(true).hasDescendant(By.text(appName)));
+ app.clickAndWait(Until.newWindow(), APP_LAUNCH_TIMEOUT);
+ mDevice.waitForIdle();
+ } else {
+ throw new RuntimeException(String.format("Application %s not found", appName));
+ }
+ }
+
private UiObject2 findApplication(String appName) {
BySelector appSelector = By.clickable(true).hasDescendant(By.text(appName));
if (mDevice.hasObject(SCROLLABLE_APP_LIST)) {
diff --git a/libraries/launcher-helper/src/android/support/test/launcherhelper/IAutoLauncherStrategy.java b/libraries/launcher-helper/src/android/support/test/launcherhelper/IAutoLauncherStrategy.java
index 8351b82..731d39c 100644
--- a/libraries/launcher-helper/src/android/support/test/launcherhelper/IAutoLauncherStrategy.java
+++ b/libraries/launcher-helper/src/android/support/test/launcherhelper/IAutoLauncherStrategy.java
@@ -65,9 +65,10 @@
*/
void openAssistantFacet();
- /**
- * Open Quick Settings.
- */
+ /** This method is to open Bluetooth Audio application */
+ void openBluetoothAudioApp();
+
+ /** Open Quick Settings. */
void openQuickSettings();
/**
@@ -95,4 +96,10 @@
* @param appName application to be opened.
*/
void openApp(String appName);
+
+ /** This method is to open notifications */
+ void openNotifications();
+
+ /** This method is to navigate to device home */
+ void pressHome();
}
diff --git a/libraries/launcher-helper/src/android/support/test/launcherhelper/LauncherStrategyFactory.java b/libraries/launcher-helper/src/android/support/test/launcherhelper/LauncherStrategyFactory.java
index f812b99..8a3db41 100644
--- a/libraries/launcher-helper/src/android/support/test/launcherhelper/LauncherStrategyFactory.java
+++ b/libraries/launcher-helper/src/android/support/test/launcherhelper/LauncherStrategyFactory.java
@@ -42,6 +42,7 @@
mKnownLauncherStrategies = new HashSet<>();
registerLauncherStrategy(AospLauncherStrategy.class);
registerLauncherStrategy(AutoLauncherStrategy.class);
+ registerLauncherStrategy(VolvoLauncherStrategy.class);
registerLauncherStrategy(GoogleExperienceLauncherStrategy.class);
registerLauncherStrategy(Launcher3Strategy.class);
registerLauncherStrategy(NexusLauncherStrategy.class);
diff --git a/libraries/launcher-helper/src/android/support/test/launcherhelper/VolvoLauncherStrategy.java b/libraries/launcher-helper/src/android/support/test/launcherhelper/VolvoLauncherStrategy.java
new file mode 100644
index 0000000..695a9b2
--- /dev/null
+++ b/libraries/launcher-helper/src/android/support/test/launcherhelper/VolvoLauncherStrategy.java
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+package android.support.test.launcherhelper;
+
+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.UiDevice;
+import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.Until;
+
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/** Implementation of {@link ILauncherStrategy} to support Volvo launcher */
+public class VolvoLauncherStrategy extends AutoLauncherStrategy {
+ private static final String VOLVO_LAUNCHER_PACKAGE = "com.volvocars.launcher";
+ private static final String SYSTEM_UI_PACKAGE = "com.android.systemui";
+
+ private static final Map<String, BySelector> FACET_MAP =
+ Stream.of(
+ new Object[][] {
+ {
+ "App Grid",
+ By.res(SYSTEM_UI_PACKAGE, "nav_bar_apps").clickable(true)
+ },
+ })
+ .collect(
+ Collectors.toMap(
+ data -> (String) data[0], data -> (BySelector) data[1]));
+
+ private static final Map<String, BySelector> APP_OPEN_VERIFIERS =
+ Stream.of(
+ new Object[][] {
+ {"App Grid", By.res(VOLVO_LAUNCHER_PACKAGE, "apps_pane")},
+ })
+ .collect(
+ Collectors.toMap(
+ data -> (String) data[0], data -> (BySelector) data[1]));
+
+ private static final long APP_LAUNCH_TIMEOUT_MS = 10000;
+ private static final long UI_WAIT_TIMEOUT_MS = 5000;
+ private static final long POLL_INTERVAL = 100;
+
+ protected UiDevice mDevice;
+ private Instrumentation mInstrumentation;
+
+ @Override
+ public String getSupportedLauncherPackage() {
+ return VOLVO_LAUNCHER_PACKAGE;
+ }
+
+ @Override
+ public void setUiDevice(UiDevice uiDevice) {
+ mDevice = uiDevice;
+ }
+
+ @Override
+ public void setInstrumentation(Instrumentation instrumentation) {
+ super.setInstrumentation(instrumentation);
+ mInstrumentation = instrumentation;
+ }
+
+ @Override
+ public void openApp(String appName) {
+ if (checkApplicationExists(appName)) {
+ UiObject2 app = mDevice.findObject(By.clickable(true).hasDescendant(By.text(appName)));
+ app.clickAndWait(Until.newWindow(), APP_LAUNCH_TIMEOUT_MS);
+ mDevice.waitForIdle();
+ } else {
+ throw new RuntimeException(String.format("Application %s not found", appName));
+ }
+ }
+
+ @Override
+ public void openBluetoothAudioApp() {
+ String appName = "Bluetooth Media Player";
+ if (checkApplicationExists(appName)) {
+ UiObject2 app = mDevice.findObject(By.clickable(true).hasDescendant(By.text(appName)));
+ app.clickAndWait(Until.newWindow(), APP_LAUNCH_TIMEOUT_MS);
+ mDevice.waitForIdle();
+ } else {
+ throw new RuntimeException(String.format("Application %s not found", appName));
+ }
+ }
+
+ @Override
+ public boolean checkApplicationExists(String appName) {
+ openAppGridFacet();
+ UiObject2 app = findApplication(appName);
+ return app != null;
+ }
+
+ @Override
+ public void openAppGridFacet() {
+ openFacet("App Grid");
+ }
+
+ @Override
+ public void openMapsFacet() {
+ // Volvo does not have Facet for Maps, so open Maps from App Grid
+ openApp("Maps");
+ }
+
+ private void openFacet(String facetName) {
+ BySelector facetSelector = FACET_MAP.get(facetName);
+ UiObject2 facet = mDevice.findObject(facetSelector);
+ if (facet != null) {
+ facet.click();
+ waitUntilAppOpen(facetName, APP_LAUNCH_TIMEOUT_MS);
+ } else {
+ throw new RuntimeException(String.format("Failed to find %s facet.", facetName));
+ }
+ }
+
+ private void waitUntilAppOpen(String appName, long timeout) {
+ SystemClock.sleep(timeout);
+ long startTime = SystemClock.uptimeMillis();
+ boolean isOpen = false;
+ do {
+ isOpen = mDevice.hasObject(APP_OPEN_VERIFIERS.get(appName));
+ if (isOpen) {
+ break;
+ }
+ SystemClock.sleep(POLL_INTERVAL);
+ } while ((SystemClock.uptimeMillis() - startTime) < timeout);
+ if (!isOpen) {
+ throw new IllegalStateException(
+ String.format(
+ "Did not find any app of %s in foreground after %d ms.",
+ appName, timeout));
+ }
+ }
+
+ private UiObject2 findApplication(String appName) {
+ BySelector appSelector = By.clickable(true).hasDescendant(By.text(appName));
+ return mDevice.findObject(appSelector);
+ }
+}
diff --git a/scripts/perfetto-setup/Android.mk b/scripts/perfetto-setup/Android.mk
index ab478ec..a742eea 100644
--- a/scripts/perfetto-setup/Android.mk
+++ b/scripts/perfetto-setup/Android.mk
@@ -46,13 +46,3 @@
LOCAL_PREBUILT_MODULE_FILE := prebuilts/tools/linux-x86_64/perfetto/configs/trace_config_experimental.textproto
include $(BUILD_PREBUILT)
-include $(CLEAR_VARS)
-LOCAL_MODULE := perfetto_trace_processor_shell
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/local/tmp
-LOCAL_CHECK_ELF_FILES := false
-LOCAL_PREBUILT_MODULE_FILE := prebuilts/tools/linux-x86_64/perfetto/trace_processor_shell
-include $(BUILD_PREBUILT)
-
-