| Index: chrome/browser/password_manager/password_generation_interactive_uitest.cc
|
| diff --git a/chrome/browser/password_manager/password_generation_interactive_uitest.cc b/chrome/browser/password_manager/password_generation_interactive_uitest.cc
|
| index fff3b0949441899f10e0e6295d288f39fa6966aa..bdcff4065c5bc91caef68be561eebd8868bbba6e 100644
|
| --- a/chrome/browser/password_manager/password_generation_interactive_uitest.cc
|
| +++ b/chrome/browser/password_manager/password_generation_interactive_uitest.cc
|
| @@ -24,11 +24,13 @@ namespace {
|
| class TestPopupObserver : public autofill::PasswordGenerationPopupObserver {
|
| public:
|
| TestPopupObserver()
|
| - : popup_showing_(false) {}
|
| + : popup_showing_(false),
|
| + password_visible_(false) {}
|
| virtual ~TestPopupObserver() {}
|
|
|
| - virtual void OnPopupShown() OVERRIDE {
|
| + virtual void OnPopupShown(bool password_visible) OVERRIDE {
|
| popup_showing_ = true;
|
| + password_visible_ = password_visible;
|
| }
|
|
|
| virtual void OnPopupHidden() OVERRIDE {
|
| @@ -36,9 +38,11 @@ class TestPopupObserver : public autofill::PasswordGenerationPopupObserver {
|
| }
|
|
|
| bool popup_showing() { return popup_showing_; }
|
| + bool password_visible() { return password_visible_; }
|
|
|
| private:
|
| bool popup_showing_;
|
| + bool password_visible_;
|
| };
|
|
|
| } // namespace
|
| @@ -56,7 +60,7 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
|
|
|
| virtual void SetUpOnMainThread() OVERRIDE {
|
| // Disable Autofill requesting access to AddressBook data. This will cause
|
| - // test tests to hang on Mac.
|
| + // the tests to hang on Mac.
|
| autofill::test::DisableSystemServices(browser()->profile());
|
|
|
| // Set observer for popup.
|
| @@ -70,7 +74,7 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
|
| }
|
|
|
| virtual void CleanUpOnMainThread() OVERRIDE {
|
| - // Cleanup UI.
|
| + // Clean up UI.
|
| PasswordGenerationManager* generation_manager =
|
| PasswordGenerationManager::FromWebContents(GetWebContents());
|
| generation_manager->HidePopup();
|
| @@ -94,6 +98,16 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
|
| return value;
|
| }
|
|
|
| + std::string GetFocusedElement() {
|
| + std::string focused_element;
|
| + EXPECT_TRUE(content::ExecuteScriptAndExtractString(
|
| + GetRenderViewHost(),
|
| + "window.domAutomationController.send("
|
| + " document.activeElement.id)",
|
| + &focused_element));
|
| + return focused_element;
|
| + }
|
| +
|
| void FocusPasswordField() {
|
| ASSERT_TRUE(content::ExecuteScript(
|
| GetRenderViewHost(),
|
| @@ -107,8 +121,12 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
|
| GetRenderViewHost()->ForwardKeyboardEvent(event);
|
| }
|
|
|
| - bool popup_showing() {
|
| - return observer_.popup_showing();
|
| + bool GenerationPopupShowing() {
|
| + return observer_.popup_showing() && observer_.password_visible();
|
| + }
|
| +
|
| + bool EditingPopupShowing() {
|
| + return observer_.popup_showing() && !observer_.password_visible();
|
| }
|
|
|
| private:
|
| @@ -116,7 +134,7 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
|
| };
|
|
|
| #if defined(USE_AURA)
|
| -// Enabled on these platforms
|
| +// Enabled on these platforms.
|
| #define MAYBE_PopupShownAndPasswordSelected PopupShownAndPasswordSelected
|
| #define MAYBE_PopupShownAndDismissed PopupShownAndDismissed
|
| #else
|
| @@ -128,20 +146,29 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
|
| IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
|
| MAYBE_PopupShownAndPasswordSelected) {
|
| FocusPasswordField();
|
| - EXPECT_TRUE(popup_showing());
|
| + EXPECT_TRUE(GenerationPopupShowing());
|
| SendKeyToPopup(ui::VKEY_DOWN);
|
| SendKeyToPopup(ui::VKEY_RETURN);
|
|
|
| + // Selecting the password should fill the field and move focus to the
|
| + // submit button.
|
| EXPECT_FALSE(GetFieldValue("password_field").empty());
|
| + EXPECT_FALSE(GenerationPopupShowing());
|
| + EXPECT_FALSE(EditingPopupShowing());
|
| + EXPECT_EQ("input_submit_button", GetFocusedElement());
|
| +
|
| + // Re-focusing the password field should show the editing popup.
|
| + FocusPasswordField();
|
| + EXPECT_TRUE(EditingPopupShowing());
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
|
| MAYBE_PopupShownAndDismissed) {
|
| FocusPasswordField();
|
| - EXPECT_TRUE(popup_showing());
|
| + EXPECT_TRUE(GenerationPopupShowing());
|
|
|
| SendKeyToPopup(ui::VKEY_ESCAPE);
|
|
|
| // Popup is dismissed.
|
| - EXPECT_FALSE(popup_showing());
|
| + EXPECT_FALSE(GenerationPopupShowing());
|
| }
|
|
|