summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2017-05-04 18:01:08 +0000
committerandroid-build-prod (mdb) <android-build-team-robot@google.com>2017-05-04 18:01:08 +0000
commit7aaa8a26454cb80a072d637adfd46f0f5694b3f3 (patch)
tree44e30a071461ca3c986168a8df3ed34713f788e5
parent32d478e595397f032b83fda8e7aaf405cc5d77af (diff)
parentfa8fa49af590d449a4f7af7e6406be200b5855e8 (diff)
downloadadt-infra-emu-2.4-release.tar.gz
release-request-1f23c1cc-67f0-4164-92f6-7dae0712394d-for-aosp-emu-2.4-release-3972579 snap-temp-L97500000060558537emu-2.4-release
Change-Id: If296675d1053a45b6638a6e97d1edd60f81a1825
-rw-r--r--emu_test/test_avd/launch_avd.py25
-rw-r--r--emu_test/test_console/testcase_help.py18
-rw-r--r--emu_test/test_console/testcase_ping.py72
-rw-r--r--emu_test/test_console/utils/util.py21
-rw-r--r--emu_test/utils/download_unzip_image.py7
-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/main/java/com/android/devtools/systemimage/uitest/common/Res.java2
-rw-r--r--system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/PlayStoreUtil.java36
-rw-r--r--system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/watchers/PlayStoreConfirmationWatcher.java (renamed from system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/unittest/watchers/PlayStoreConfirmationWatcher.java)41
9 files changed, 288 insertions, 58 deletions
diff --git a/emu_test/test_avd/launch_avd.py b/emu_test/test_avd/launch_avd.py
index 75aa79c0..b3337924 100644
--- a/emu_test/test_avd/launch_avd.py
+++ b/emu_test/test_avd/launch_avd.py
@@ -18,6 +18,8 @@ import unittest
import util
+from emu_test.utils.emu_testcase import EmuBaseTestCase, AVDConfig
+
log = logging.getLogger('launch_avd')
def arg_parser():
@@ -27,9 +29,6 @@ def arg_parser():
parser.add_argument('-t', '--timeout', type=int, dest='timeout_in_seconds', action='store',
default=600,
help='an integer for timeout in seconds, default is 600')
- parser.add_argument('--avd', type=str, dest='avd', action='store',
- required=True,
- help='run test for given AVD')
parser.add_argument('--exec', type=str, dest='emulator_exec', action='store',
default='emulator',
help='path of emulator executable, default is system emulator')
@@ -37,8 +36,7 @@ def arg_parser():
return parser
class TimeoutError(Exception):
- """Exception raised for timeout
-
+ """Exception raised for timeout.
Attributes:
cmd -- cmd which timed out
timeout -- value of timeout
@@ -49,12 +47,10 @@ class TimeoutError(Exception):
self.timeout = timeout
def run_with_timeout(cmd, timeout):
- """Run command with specified timeout.
-
+ """Run command with specified timeout.
Args:
cmd - Required : command to run
- timeout - Required : timeout (in seconds)
-
+ timeout - Required : timeout (in seconds)
Returns:
Tuple of form (returncode, output, err), where:
* returncode is the exit code of the command
@@ -145,11 +141,12 @@ def launch_emu_and_wait(avd, emu_args):
return success
-class LaunchAVDTest(unittest.TestCase):
- def test_launch_avd(self):
+class LaunchAVDTest(EmuBaseTestCase):
+ def test_launch_avd(self, avd_config):
+ self.avd_config = avd_config
+ self.assertEqual(self.create_avd(avd_config), 0)
args = arg_parser().parse_args()
- avd = args.avd
- return launch_emu_and_wait(avd, args)
+ return launch_emu_and_wait(avd_config, args)
if __name__ == '__main__':
console_handler = logging.StreamHandler(sys.stdout)
@@ -157,4 +154,4 @@ if __name__ == '__main__':
log.addHandler(console_handler)
log.setLevel(logging.DEBUG)
suite = unittest.TestLoader().loadTestsFromTestCase(LaunchAVDTest)
- unittest.TextTestRunner(verbosity=2).run(suite)
+ unittest.TextTestRunner(verbosity=2).run(suite) \ No newline at end of file
diff --git a/emu_test/test_console/testcase_help.py b/emu_test/test_console/testcase_help.py
index 18e2f516..56ac6aed 100644
--- a/emu_test/test_console/testcase_help.py
+++ b/emu_test/test_console/testcase_help.py
@@ -40,6 +40,20 @@ class HelpTest(testcase_base.BaseConsoleTest):
'Failed to properly list all command options.',
False, '', 'Pattern: \n%s' % expected_output, output)
+ def _help_verbose_command(self, expected_output):
+ """Executes help-verbose command and verifies output.
+
+ Args:
+ expected_output: Expected console output for help-vebose command.
+ """
+ is_command_successful, output = util.execute_console_command(
+ self.telnet, util.CMD_HELP_VERBOSE, expected_output)
+
+ self.assert_cmd_successful(
+ is_command_successful,
+ 'Failed to properly list all command options.',
+ False, '', 'Pattern: \n%s' % expected_output, output)
+
def _auth_user_for_emulator_console(self):
"""Authorization user."""
auth_token = util.get_auth_token()
@@ -68,8 +82,12 @@ class HelpTest(testcase_base.BaseConsoleTest):
"""
print 'Running test: %s' % (inspect.stack()[0][3])
self._help_command(util.REGEX_HELP_DISPLAY_NO_AUTH)
+ self._help_verbose_command(util.REGEX_HELP_VERBOSE_DISPLAY_NO_AUTH)
+
self._auth_user_for_emulator_console()
+
self._help_command(util.REGEX_HELP_DISPLAY_AUTH)
+ self._help_verbose_command(util.REGEX_HELP_VERBOSE_DISPLAY_AUTH)
if __name__ == '__main__':
diff --git a/emu_test/test_console/testcase_ping.py b/emu_test/test_console/testcase_ping.py
new file mode 100644
index 00000000..322adb71
--- /dev/null
+++ b/emu_test/test_console/testcase_ping.py
@@ -0,0 +1,72 @@
+"""Tests for the ping command."""
+
+import inspect
+import time
+import unittest
+
+import testcase_base
+from utils import util
+
+CMD_PING = 'ping\n'
+PING_RESPONSE = 'I am alive!.*\nOK'
+
+
+
+class PingTest(testcase_base.BaseConsoleTest):
+ """Tests for the ping command."""
+
+ def __init__(self, method_name=None, avd=None):
+ if method_name:
+ super(PingTest, self).__init__(method_name)
+ else:
+ super(PingTest, self).__init__()
+ self.avd = avd
+
+ def _execute_command_and_verify(self, command, expected_output, assert_msg):
+ """Executes console command and verify output.
+
+ Args:
+ command: Console command to be executed.
+ expected_output: Expected console output.
+ assert_msg: Assertion message.
+ """
+ is_command_successful, output = util.execute_console_command(
+ self.telnet, command, expected_output)
+
+ self.assert_cmd_successful(is_command_successful, assert_msg, False, '',
+ 'Pattern:\n%s' % expected_output, output)
+
+ def _auth_user_for_emulator_console(self):
+ """Authorize user."""
+ auth_token = util.get_auth_token()
+ self.telnet = util.telnet_emulator()
+ self.telnet.write('%s %s\n' % (util.AUTH, auth_token))
+ util.wait_on_windows()
+ if (not util.check_read_until(
+ self.telnet.read_until(util.OK, util.TIMEOUT_S))):
+ sys.exit(-1)
+
+ def test_ping(self):
+ """Test for command: ping
+
+ Test Rail ID: ?
+ Test steps:
+ 1. Launch an emulator avd
+ 2. From command prompt, run: ping
+ 3. Verify 1
+ 4. Copy the auth_token value from ~/.emulator_console_auth_token
+ 5. Run: auth auth_token
+ 6. Run: ping
+ 7. Verify 1
+ Verify:
+ 1. The ping response is displayed
+ """
+ print 'Running test: %s' % (inspect.stack()[0][3])
+ assert_msg = 'Failed to properly display the ping response.'
+ self._execute_command_and_verify(CMD_PING, PING_RESPONSE, assert_msg)
+ self._auth_user_for_emulator_console()
+ self._execute_command_and_verify(CMD_PING, PING_RESPONSE, assert_msg)
+
+if __name__ == '__main__':
+ print '======= Ping Test ======='
+ unittest.main()
diff --git a/emu_test/test_console/utils/util.py b/emu_test/test_console/utils/util.py
index 79495bf9..8efa0fdd 100644
--- a/emu_test/test_console/utils/util.py
+++ b/emu_test/test_console/utils/util.py
@@ -56,14 +56,25 @@ EVENTS_EV_TYPES_FILENAME = os.path.join(EVENT_DIR, 'EVENTS_EV_TYPES')
PORT_NO_REDIR = 'no active redirections\r\nOK'
PORT_REDIR_ADD = 'tcp:5556 => 5554 \r\nOK'
CMD_HELP = 'help\n'
-REGEX_HELP_DISPLAY_NO_AUTH = (r'.*\n.*\n.*help.*\n.*avd.*\n.*auth.*\n'
- r'.*quit\|exit.*\n.*\n.*\nOK')
-REGEX_HELP_DISPLAY_AUTH = (r'.*\n.*\n.*help.*\n.*event.*\n.*geo.*\n.*gsm.*\n'
- r'.*cdma.*\n.*crash.*\n.*crash-on-exit.*\n'
+REGEX_HELP_DISPLAY_NO_AUTH = (r'.*\n.*help.*\n.*help-verbose.*\n.*ping.*\n'
+ r'.*avd.*\n.*auth.*\n.*quit\|exit.*\n.*\n.*\n.*\nOK')
+REGEX_HELP_DISPLAY_AUTH = (r'.*\n.*help.*\n.*help-verbose.*\n.*ping.*\n.*event.*\n'
+ r'.*geo.*\n.*gsm.*\n.*cdma.*\n.*crash.*\n.*crash-on-exit.*\n'
r'.*kill.*\n.*network.*\n'
r'.*power.*\n.*quit\|exit.*\n.*redir.*\n'
r'.*sms.*\n.*avd.*\n.*qemu.*\n.*sensor.*\n.'
- r'*finger.*\n.*debug.*\n.*rotate.*\n.*\n.*\nOK')
+ r'*finger.*\n.*debug.*\n.*rotate.*\n.*\n.*\n.*\nOK')
+CMD_HELP_VERBOSE = 'help-verbose\n'
+REGEX_HELP_VERBOSE_DISPLAY_NO_AUTH = (
+ r'.*\n.*\n.*help.*\n.*help-verbose.*\n.*ping.*\n'
+ r'.*avd.*\n.*auth.*\n.*quit\|exit.*\n.*\n.*\nOK')
+REGEX_HELP_VERBOSE_DISPLAY_AUTH = (
+ r'.*\n.*\n.*help.*\n.*help-verbose.*\n.*ping.*\n.*event.*\n'
+ r'.*geo.*\n.*gsm.*\n.*cdma.*\n.*crash.*\n.*crash-on-exit.*\n'
+ r'.*kill.*\n.*network.*\n'
+ r'.*power.*\n.*quit\|exit.*\n.*redir.*\n'
+ r'.*sms.*\n.*avd.*\n.*qemu.*\n.*sensor.*\n.'
+ r'*finger.*\n.*debug.*\n.*rotate.*\n.*\n.*\nOK')
AUTH = 'auth'
CMD_RANDOM_AUTH_TOKEN = '%s axxB123cc\n' % AUTH
CMD_EMPTY_AUTH_TOKEN = '%s \n' % AUTH
diff --git a/emu_test/utils/download_unzip_image.py b/emu_test/utils/download_unzip_image.py
index e96491f9..feb8748a 100644
--- a/emu_test/utils/download_unzip_image.py
+++ b/emu_test/utils/download_unzip_image.py
@@ -17,10 +17,13 @@ args = parser.parse_args()
def get_dst_dir(remote_path):
file_name = os.path.basename(remote_path)
emulator_branches = ["emu-master-dev", "emu-2.0-release", "emu-2.2-release", "emu-2.3-release"]
+ # sdk_google_phone contains the playstore system images.
if file_name.startswith('sdk-repo-linux-system-images') or file_name.startswith('sdk-repo-linux-addon') \
- or file_name.startswith('sdk-repo-darwin-system-images'):
+ or file_name.startswith('sdk-repo-darwin-system-images') or file_name.startswith('sdk_google_phone'):
branch_name = remote_path.split('/')[-4]
- if 'google' in branch_name and 'addon' in branch_name:
+ if 'user' in branch_name:
+ tag = 'google_apis_playstore'
+ elif 'google' in branch_name and 'addon' in branch_name:
tag = 'google_apis'
elif 'google_atv' in branch_name:
tag = 'android-tv'
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/main/java/com/android/devtools/systemimage/uitest/common/Res.java b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/common/Res.java
index 32da225a..f852b00e 100644
--- a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/common/Res.java
+++ b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/common/Res.java
@@ -71,8 +71,8 @@ public class Res {
public static final String GOOGLE_PLAY_IDLE_RES = "com.android.vending:id/search_box_idle_text";
public static final String GOOGLE_PLAY_INPUT_RES =
"com.android.vending:id/search_box_text_input";
- public static final String GOOGLE_PLAY_NAV_RES = "com.android.vending:id/navigation_button";
public static final String GOOGLE_PLAY_BUY_BUTTON_RES = "com.android.vending:id/buy_button";
+ public static final String GOOGLE_PLAY_CONTINUE_BUTTON_RES = "com.android.vending:id/continue_button";
public static final String DIALER_BUTTON_RES =
"com.android.dialer:id/dialpad_floating_action_button";
diff --git a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/PlayStoreUtil.java b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/PlayStoreUtil.java
index 3fbc99ba..91eb4f62 100644
--- a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/PlayStoreUtil.java
+++ b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/PlayStoreUtil.java
@@ -24,6 +24,7 @@ import android.support.test.uiautomator.UiScrollable;
import android.support.test.uiautomator.UiSelector;
import com.android.devtools.systemimage.uitest.common.Res;
+import com.android.devtools.systemimage.uitest.watchers.PlayStoreConfirmationWatcher;
import java.util.concurrent.TimeUnit;
@@ -61,28 +62,28 @@ public class PlayStoreUtil {
}
/**
- * Launches Google Play and then searches for an application
+ * Backtracks to the opening Play Store screen.
+ */
+ public static void resetPlayStore(Instrumentation instrumentation) {
+ final UiDevice device = UiDevice.getInstance(instrumentation);
+
+ for (int i = 0; i < 5; i++) {
+ device.pressBack();
+ }
+ }
+
+ /**
+ * Launches Play Store and then searches for an application.
*/
public static void searchGooglePlay(Instrumentation instrumentation, String appName) throws Exception {
final UiDevice device = UiDevice.getInstance(instrumentation);
final String playStore = "Play Store";
final String application = appName;
- device.findObject(new UiSelector().text(playStore)).clickAndWaitForNewWindow();
- boolean backButtonExists = new Wait().until(new Wait.ExpectedCondition() {
- @Override
- public boolean isTrue() throws UiObjectNotFoundException {
- return device.findObject(
- new UiSelector().resourceId(Res.GOOGLE_PLAY_NAV_RES)
- .description("Back")).exists();
- }
- });
-
- if (backButtonExists) {
- device.findObject(
- new UiSelector().resourceId(Res.GOOGLE_PLAY_NAV_RES)
- .description("Back")).click();
- }
+ device.findObject(new UiSelector().text(playStore)).clickAndWaitForNewWindow();
+ resetPlayStore(instrumentation);
+ device.pressHome();
+ device.findObject(new UiSelector().text(playStore)).clickAndWaitForNewWindow();
boolean idleTextFieldExists = new Wait().until(new Wait.ExpectedCondition() {
@Override
@@ -115,7 +116,7 @@ public class PlayStoreUtil {
}
/**
- * Selects an application listed in Google Play
+ * Selects an application listed in the Play Store.
*/
public static void selectFromGooglePlay(Instrumentation instrumentation, String appDescription) throws Exception {
final UiDevice device = UiDevice.getInstance(instrumentation);
@@ -162,6 +163,7 @@ public class PlayStoreUtil {
}
device.findObject(new UiSelector().text("INSTALL")).clickAndWaitForNewWindow();
+ new PlayStoreConfirmationWatcher(device).checkForCondition();
UiObject openButton = device.findObject(new UiSelector().text("OPEN"));
boolean isAppInstalled = openButton.waitForExists(TimeUnit.SECONDS.toMillis(60));
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/main/java/com/android/devtools/systemimage/uitest/watchers/PlayStoreConfirmationWatcher.java
index ff203529..b4b7c627 100644
--- a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/unittest/watchers/PlayStoreConfirmationWatcher.java
+++ b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/watchers/PlayStoreConfirmationWatcher.java
@@ -14,17 +14,14 @@
* limitations under the License.
*/
-package com.android.devtools.systemimage.uitest.unittest.watchers;
-
+package com.android.devtools.systemimage.uitest.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;
+import java.util.concurrent.TimeUnit;
/**
* VPN app popup watcher that monitors and dismisses the VPN popup dialog.
@@ -40,21 +37,33 @@ public class PlayStoreConfirmationWatcher implements UiWatcher {
@Override
public boolean checkForCondition() {
- UiObject confirmBox = mDevice.findObject(new UiSelector().text("CONFIRM"));
- UiObject okBox = mDevice.findObject(new UiSelector().text("OK"));
+ boolean condition = false;
+ boolean isSuccess =
+ mDevice.findObject(new UiSelector().text("CONTINUE"))
+ .waitForExists(TimeUnit.MILLISECONDS.convert(3L, TimeUnit.SECONDS));
try {
- if (confirmBox.exists()) {
- confirmBox.click();
+ if (isSuccess) {
+ mDevice.findObject(new UiSelector().text("CONTINUE")).click();
+ condition = true;
}
- if (okBox.exists()) {
- okBox.click();
- return true;
+ isSuccess =
+ mDevice.findObject(new UiSelector().text("CONFIRM"))
+ .waitForExists(TimeUnit.MILLISECONDS.convert(3L, TimeUnit.SECONDS));
+ if (isSuccess) {
+ mDevice.findObject(new UiSelector().text("CONFIRM")).click();
+ condition = true;
}
- else {
- return false;
+ isSuccess =
+ mDevice.findObject(new UiSelector().text("SKIP"))
+ .waitForExists(TimeUnit.MILLISECONDS.convert(3L, TimeUnit.SECONDS));
+ if (isSuccess) {
+ mDevice.findObject(new UiSelector().text("SKIP")).click();
+ condition = true;
}
- } catch (UiObjectNotFoundException e) {
- throw new AssertionError("Failed to dismiss the VPN popup dialog");
}
+ catch (UiObjectNotFoundException e) {
+ throw new AssertionError("Failed to dismiss the play store popup dialogs");
+ }
+ return condition;
}
} \ No newline at end of file