summaryrefslogtreecommitdiff
path: root/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage
diff options
context:
space:
mode:
Diffstat (limited to 'system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage')
-rw-r--r--system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/PlayStoreTest.java124
-rw-r--r--system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/unittest/watchers/PlayStoreConfirmationWatcher.java60
2 files changed, 121 insertions, 63 deletions
diff --git a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/PlayStoreTest.java b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/PlayStoreTest.java
index 34e43559..45b9a062 100644
--- a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/PlayStoreTest.java
+++ b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/PlayStoreTest.java
@@ -19,9 +19,7 @@ package com.android.devtools.systemimage.uitest.smoke;
import android.app.Instrumentation;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.UiScrollable;
import android.support.test.uiautomator.UiSelector;
import com.android.devtools.systemimage.uitest.annotations.TestInfo;
@@ -29,7 +27,7 @@ import com.android.devtools.systemimage.uitest.common.Res;
import com.android.devtools.systemimage.uitest.framework.SystemImageTestFramework;
import com.android.devtools.systemimage.uitest.utils.PlayStoreUtil;
import com.android.devtools.systemimage.uitest.utils.Wait;
-import com.android.devtools.systemimage.uitest.unittest.watchers.PlayStoreConfirmationWatcher;
+import com.android.devtools.systemimage.uitest.watchers.PlayStoreConfirmationWatcher;
import org.junit.Ignore;
import org.junit.Rule;
@@ -65,6 +63,7 @@ public class PlayStoreTest {
* 3. Confirm that Play Store is present, then launch.
* 5. Search for free app in store.
* 6. If app is available for install, begin installation.
+ * 7. Uninstall the app.
* Verify:
* 1a. If Install button is displayed, allow installation to complete then
* confirm that the Open button to launch the app is present.
@@ -98,6 +97,125 @@ public class PlayStoreTest {
assertTrue("Unable to uninstall the application from Google Play",
PlayStoreUtil.uninstallApplication(instrumentation));
+
+ PlayStoreUtil.resetPlayStore(instrumentation);
+ device.pressHome();
+ }
+ }
+ }
+
+ /**
+ * Verify that an app can be installed and launched from Play Store.
+ * <p>
+ * TR ID: C14603433
+ * <p>
+ * <pre>
+ * Test Steps:
+ * 1. Start an emulator and launch home screen.
+ * 2. Open Apps.
+ * 3. Confirm that Play Store is present, then launch.
+ * 5. Search for free app in store.
+ * 6. If app is available for install, begin installation.
+ * 7. Launch the application.
+ * 7. Close and uninstall the app.
+ * Verify:
+ * 1. App is installed without errors.
+ * 2. App is launched without errors.
+ * </pre>
+ */
+ @Ignore("Testing play store requires google login that may trigger 2-auth factor. Test to be initiated manually by tester.")
+ @Test
+ @TestInfo(id = "14578827")
+ public void testAppInstallationAndLaunch() throws Exception {
+ Instrumentation instrumentation = testFramework.getInstrumentation();
+ final UiDevice device = UiDevice.getInstance(instrumentation);
+ final String application = "Trello";
+
+ if (testFramework.getApi() >= 24 && testFramework.isGoogleApiImage()) {
+ device.pressHome();
+ device.findObject(new UiSelector().description("Apps")).clickAndWaitForNewWindow();
+
+ boolean playStoreInstalled = PlayStoreUtil.isPlayStoreInstalled(instrumentation);
+
+ if (playStoreInstalled) {
+ PlayStoreUtil.searchGooglePlay(instrumentation, application);
+ PlayStoreUtil.selectFromGooglePlay(
+ instrumentation, "App: "+application);
+
+ new PlayStoreConfirmationWatcher(device).checkForCondition();
+
+ assertTrue("Unable to install the application from Google Play",
+ PlayStoreUtil.installApplication(instrumentation));
+
+ device.findObject(new UiSelector().text("OPEN")).clickAndWaitForNewWindow();
+ assertTrue("App could not be opened",
+ new Wait().until(new Wait.ExpectedCondition() {
+ @Override
+ public boolean isTrue() throws UiObjectNotFoundException {
+ return device.findObject(new UiSelector()
+ .packageName("com.trello")).exists();
+ }
+ }));
+
+ device.pressBack();
+
+ assertTrue("Unable to uninstall the application from Google Play",
+ PlayStoreUtil.uninstallApplication(instrumentation));
+
+ PlayStoreUtil.resetPlayStore(instrumentation);
+ device.pressHome();
+ }
+ }
+ }
+
+ /**
+ * Verify that Google Play can reach the payment method prompt during paid app installation.
+ * <p>
+ * TR ID: C14603432
+ * <p>
+ * <pre>
+ * Test Steps:
+ * 1. Start an emulator and launch home screen.
+ * 2. Open Apps.
+ * 3. Confirm that Play Store is present, then launch.
+ * 4. Search for pay app in store.
+ * Verify:
+ * 1. Confirm that user is presented with a Pay Button with a $.
+ * </pre>
+ */
+ @Ignore("Testing play store requires google login that may trigger 2-auth factor. Test to be initiated manually by tester.")
+ @Test
+ @TestInfo(id = "14578827")
+ public void testPayAppVerification() throws Exception {
+ Instrumentation instrumentation = testFramework.getInstrumentation();
+ final UiDevice device = UiDevice.getInstance(instrumentation);
+ final String application = "Weather Live";
+
+ if (testFramework.getApi() >= 24 && testFramework.isGoogleApiImage()) {
+ device.pressHome();
+ device.findObject(new UiSelector().description("Apps")).clickAndWaitForNewWindow();
+
+ boolean playStoreInstalled = PlayStoreUtil.isPlayStoreInstalled(instrumentation);
+
+ if (playStoreInstalled) {
+ PlayStoreUtil.searchGooglePlay(instrumentation, application);
+ PlayStoreUtil.selectFromGooglePlay(instrumentation, "App: "+application);
+
+ new PlayStoreConfirmationWatcher(device).checkForCondition();
+
+ assertTrue(
+ "Target application is not a pay app", new Wait().until(
+ new Wait.ExpectedCondition() {
+ @Override
+ public boolean isTrue() throws UiObjectNotFoundException {
+ return device.findObject(new UiSelector()
+ .resourceId(
+ Res.GOOGLE_PLAY_BUY_BUTTON_RES).textContains("$")).exists();
+ }
+ }));
+
+ PlayStoreUtil.resetPlayStore(instrumentation);
+ device.pressHome();
}
}
}
diff --git a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/unittest/watchers/PlayStoreConfirmationWatcher.java b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/unittest/watchers/PlayStoreConfirmationWatcher.java
deleted file mode 100644
index ff203529..00000000
--- a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/unittest/watchers/PlayStoreConfirmationWatcher.java
+++ /dev/null
@@ -1,60 +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.devtools.systemimage.uitest.unittest.watchers;
-
-
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject;
-import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.UiSelector;
-import android.support.test.uiautomator.UiWatcher;
-
-import com.android.devtools.systemimage.uitest.common.Res;
-import com.android.devtools.systemimage.uitest.utils.Wait;
-
-/**
- * VPN app popup watcher that monitors and dismisses the VPN popup dialog.
- * <p>
- * Note that this watcher should only be registered before playing the VPN app.
- */
-public class PlayStoreConfirmationWatcher implements UiWatcher {
- private final UiDevice mDevice;
-
- public PlayStoreConfirmationWatcher(UiDevice device) {
- this.mDevice = device;
- }
-
- @Override
- public boolean checkForCondition() {
- UiObject confirmBox = mDevice.findObject(new UiSelector().text("CONFIRM"));
- UiObject okBox = mDevice.findObject(new UiSelector().text("OK"));
- try {
- if (confirmBox.exists()) {
- confirmBox.click();
- }
- if (okBox.exists()) {
- okBox.click();
- return true;
- }
- else {
- return false;
- }
- } catch (UiObjectNotFoundException e) {
- throw new AssertionError("Failed to dismiss the VPN popup dialog");
- }
- }
-} \ No newline at end of file