diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2018-04-28 01:30:49 +0000 |
---|---|---|
committer | android-build-prod (mdb) <android-build-team-robot@google.com> | 2018-04-28 01:30:49 +0000 |
commit | 19d526e1984f34c9746230f3ef4ffed867073073 (patch) | |
tree | 8c57ce949b01e3944e68a81cdbbbbd7189ba5a19 | |
parent | 72bcfa136911d29304506f3b6f666b4ddb75cbc7 (diff) | |
parent | e9e7f36094e8bab7059e43bb07f7e334d69f37f6 (diff) | |
download | adt-infra-19d526e1984f34c9746230f3ef4ffed867073073.tar.gz |
Snap for 4750750 from e9e7f36094e8bab7059e43bb07f7e334d69f37f6 to emu-2.7-release
Change-Id: I1a6243973e9058961cdf9f8a7e4ed8110aded7a2
3 files changed, 93 insertions, 69 deletions
diff --git a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/GoogleServicesTest.java b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/GoogleServicesTest.java index 0659ebab..9d298050 100644 --- a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/GoogleServicesTest.java +++ b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/GoogleServicesTest.java @@ -32,6 +32,7 @@ import com.android.devtools.systemimage.uitest.utils.AppManager; import com.android.devtools.systemimage.uitest.utils.GoogleAppUtil; import com.android.devtools.systemimage.uitest.utils.Wait; import com.android.devtools.systemimage.uitest.watchers.AddGoogleAccountWatcher; +import com.android.devtools.systemimage.uitest.watchers.GoogleAppConfirmationWatcher; import org.junit.Rule; import org.junit.Test; @@ -175,7 +176,7 @@ public class GoogleServicesTest { * 6. Log user out of Chrome. * Verify: * 1. Logged in user name is present. - * 2. Log in user prompt is present. + * 2. Log in user prompt or user promo is present. * </pre> */ @Test @@ -194,7 +195,7 @@ public class GoogleServicesTest { new AddGoogleAccountWatcher(device).checkForCondition(); final UiObject signInButton = device.findObject(new UiSelector().text("SIGN IN")); - boolean hasSignInButton = new Wait(5L). + final boolean hasSignInButton = new Wait(5L). until(new Wait.ExpectedCondition() { @Override public boolean isTrue() throws UiObjectNotFoundException { @@ -204,130 +205,149 @@ public class GoogleServicesTest { // A different UI is presented if the user previously signed in. // The SIGN IN button will not be displayed when Chrome launches. - if (!hasSignInButton) { - return; - }; - - signInButton.clickAndWaitForNewWindow(); - GoogleAppUtil.loginGoogleApp(instrumentation); - - AppLauncher.launch(instrumentation, "Chrome"); + if (hasSignInButton) { + signInButton.clickAndWaitForNewWindow(); + GoogleAppUtil.loginGoogleApp(instrumentation); + AppLauncher.launch(instrumentation, "Chrome"); + new GoogleAppConfirmationWatcher(device).checkForCondition(); + } final UiObject moreButton = device.findObject( new UiSelector().resourceId(Res.CHROME_MORE_BUTTON_RES) ); - if (new Wait(). - until(new Wait.ExpectedCondition() { + if (new Wait().until(new Wait.ExpectedCondition() { @Override public boolean isTrue() throws UiObjectNotFoundException { return moreButton.exists(); - } - })) { + }})) { moreButton.clickAndWaitForNewWindow(); } final UiObject gotItButton = device.findObject(new UiSelector().text("OK, GOT IT")); - if (new Wait(). - until(new Wait.ExpectedCondition() { + if (new Wait().until(new Wait.ExpectedCondition() { @Override public boolean isTrue() throws UiObjectNotFoundException { return gotItButton.exists(); - } - })) { + }})) { gotItButton.clickAndWaitForNewWindow(); } final UiObject chromeUpdateButton = device.findObject( - new UiSelector().resourceId(Res.CHROME_MENU_ITEM_ICON_RES) + new UiSelector().resourceId(Res.CHROME_MENU_BADGE_RES) ); - if (new Wait(). - until(new Wait.ExpectedCondition() { + if (new Wait().until(new Wait.ExpectedCondition() { @Override public boolean isTrue() throws UiObjectNotFoundException { return chromeUpdateButton.exists(); - } - })) { + }})) { chromeUpdateButton.clickAndWaitForNewWindow(); } final UiObject chromeMenuButton = device.findObject( new UiSelector().resourceId(Res.CHROME_MENU_BUTTON_RES)); - if (new Wait(). - until(new Wait.ExpectedCondition() { + if (new Wait().until(new Wait.ExpectedCondition() { @Override public boolean isTrue() throws UiObjectNotFoundException { return chromeMenuButton.exists(); - } - })) { + }})) { chromeMenuButton.clickAndWaitForNewWindow(); } - final UiObject settingsButton = device.findObject( - new UiSelector().text("Settings")); + final UiObject settingsButton = device.findObject(new UiSelector().text("Settings")); - if (new Wait(). - until(new Wait.ExpectedCondition() { - @Override - public boolean isTrue() throws UiObjectNotFoundException { - return settingsButton.exists(); - } - })) { + if (new Wait().until(new Wait.ExpectedCondition() { + @Override + public boolean isTrue() throws UiObjectNotFoundException { + return settingsButton.exists(); + }})) { settingsButton.clickAndWaitForNewWindow(); } - final UiObject signedInLabel = device.findObject( - new UiSelector().text(username)); + final UiObject signInPromoButton = device.findObject( + new UiSelector().resourceId(Res.CHROME_SIGNIN_PROMO_RES)); + + if (new Wait().until(new Wait.ExpectedCondition() { + @Override + public boolean isTrue() throws UiObjectNotFoundException { + return signInPromoButton.exists(); + }})) { + signInPromoButton.clickAndWaitForNewWindow(); + } + + final UiObject signInLabel = device.findObject(new UiSelector().text("Sign in to Chrome")); + if (!hasSignInButton) { + if (new Wait().until(new Wait.ExpectedCondition() { + @Override + public boolean isTrue() throws UiObjectNotFoundException { + return signInLabel.exists(); + }})) { + signInLabel.clickAndWaitForNewWindow(); + } + new GoogleAppConfirmationWatcher(device).checkForCondition(); + if (new Wait().until(new Wait.ExpectedCondition() { + @Override + public boolean isTrue() throws UiObjectNotFoundException { + return gotItButton.exists(); + }})) { + gotItButton.clickAndWaitForNewWindow(); + } + } + + final UiObject signedInLabel = device.findObject(new UiSelector().text(username)); assertTrue("Google log in was unsuccessful", new Wait(). until(new Wait.ExpectedCondition() { @Override public boolean isTrue() throws UiObjectNotFoundException { return signedInLabel.exists(); - } - })); + }}) + ); signedInLabel.clickAndWaitForNewWindow(); + final UiObject signOutLabel = device.findObject(new UiSelector().text("Sign out of Chrome")); - final UiObject signOutLabel = device.findObject( - new UiSelector().text("Sign out of Chrome")); - - if (new Wait(). - until(new Wait.ExpectedCondition() { - @Override - public boolean isTrue() throws UiObjectNotFoundException { - return signOutLabel.exists(); - } - })) { + if (new Wait().until(new Wait.ExpectedCondition() { + @Override + public boolean isTrue() throws UiObjectNotFoundException { + return signOutLabel.exists(); + }})) { signOutLabel.clickAndWaitForNewWindow(); } - final UiObject signOutButton = device.findObject( - new UiSelector().text("SIGN OUT")); + final UiObject signOutButton = device.findObject(new UiSelector().text("SIGN OUT")); - if (new Wait(). - until(new Wait.ExpectedCondition() { - @Override - public boolean isTrue() throws UiObjectNotFoundException { - return signOutButton.exists(); - } - })) { + if (new Wait().until(new Wait.ExpectedCondition() { + @Override + public boolean isTrue() throws UiObjectNotFoundException { + return signOutButton.exists(); + }})) { signOutButton.clickAndWaitForNewWindow(); } - final UiObject signInLabel = device.findObject( - new UiSelector().text("Sign in to Chrome")); + final UiObject signInPromoCloseButton = device.findObject( + new UiSelector().resourceId(Res.CHROME_SIGNIN_PROMO_CLOSE_RES)); + + if (new Wait().until(new Wait.ExpectedCondition() { + @Override + public boolean isTrue() throws UiObjectNotFoundException { + return signInPromoCloseButton.exists(); + }})) { + signInPromoCloseButton.clickAndWaitForNewWindow(); + } assertTrue("Google log out was unsuccessful", new Wait(). until(new Wait.ExpectedCondition() { @Override public boolean isTrue() throws UiObjectNotFoundException { - return signInLabel.exists(); - } - })); - - signInLabel.clickAndWaitForNewWindow(); + return signInLabel.exists() || signInPromoCloseButton.exists(); + }})); + if (signInLabel.exists()) { + signInLabel.click(); + } else { + signInPromoCloseButton.click(); + } } } 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 6ede8f89..4a34f1fb 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 @@ -34,7 +34,9 @@ public class Res { public static final String CHROME_SEARCH_BOX_RES = "com.android.chrome:id/search_box_text"; public static final String CHROME_URL_BAR_RES = "com.android.chrome:id/url_bar"; public static final String CHROME_MENU_BUTTON_RES = "com.android.chrome:id/menu_button"; - public static final String CHROME_MENU_ITEM_ICON_RES = "com.android.chrome:id/menu_item_icon"; + public static final String CHROME_MENU_BADGE_RES = "com.android.chrome:id/menu_badge"; + public static final String CHROME_SIGNIN_PROMO_RES = "com.android.chrome:id/signin_promo_signin_button"; + public static final String CHROME_SIGNIN_PROMO_CLOSE_RES = "com.android.chrome:id/signin_promo_close_button"; public static final String CHROME_MORE_BUTTON_RES = "com.android.chrome:id/more_button"; public static final String CHROME_CLOSE_MENU_BUTTON_RES = "com.android.chrome:id/close_menu_id"; public static final String CHROME_TITLE_RES = "com.android.chrome:id/title"; diff --git a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/watchers/GoogleAppConfirmationWatcher.java b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/watchers/GoogleAppConfirmationWatcher.java index f84941c8..198dbb0b 100644 --- a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/watchers/GoogleAppConfirmationWatcher.java +++ b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/watchers/GoogleAppConfirmationWatcher.java @@ -24,9 +24,11 @@ import android.support.test.uiautomator.UiWatcher; import java.util.concurrent.TimeUnit; /** - * Play Store popup watcher that monitors and dismisses Google Play Store confirmation popup dialogs. + * This popup watcher monitors and dismisses confirmation popup dialogs that + * could be displayed when logging into a Google application. * <p> - * Note that this watcher should only be registered before using the Google Play Store app. + * This watcher will be deployed when logging the Google test user into either + * Google Play Store or Google Chrome. */ public class GoogleAppConfirmationWatcher implements UiWatcher { private final UiDevice mDevice; |