| Index: chrome/renderer/autofill/password_generation_agent_browsertest.cc
|
| diff --git a/chrome/renderer/autofill/password_generation_agent_browsertest.cc b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
|
| index 3d0a401d568f199af0ee3f9650b41cf0ec5faaca..76e0c00c13476d1e9bdd7e4cbb3873c58c90621a 100644
|
| --- a/chrome/renderer/autofill/password_generation_agent_browsertest.cc
|
| +++ b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
|
| @@ -19,6 +19,7 @@
|
| #include "third_party/WebKit/public/web/WebDocument.h"
|
| #include "third_party/WebKit/public/web/WebLocalFrame.h"
|
| #include "third_party/WebKit/public/web/WebWidget.h"
|
| +#include "ui/events/keycodes/keyboard_codes.h"
|
|
|
| using blink::WebDocument;
|
| using blink::WebElement;
|
| @@ -309,29 +310,25 @@ TEST_F(PasswordGenerationAgentTest, EditingTest) {
|
| EXPECT_EQ(password, second_password_element.value());
|
|
|
| // After editing the first field they are still the same.
|
| - base::string16 edited_password = base::ASCIIToUTF16("edited_password");
|
| - first_password_element.setValue(edited_password);
|
| - // Cast to WebAutofillClient where textFieldDidChange() is public.
|
| - static_cast<blink::WebAutofillClient*>(autofill_agent_)->textFieldDidChange(
|
| - first_password_element);
|
| - // textFieldDidChange posts a task, so we need to wait until it's been
|
| - // processed.
|
| + std::string edited_password_ascii = "edited_password";
|
| + SimulateUserInputChangeForElement(&first_password_element, GetMainFrame(),
|
| + edited_password_ascii);
|
| + base::string16 edited_password = base::ASCIIToUTF16(edited_password_ascii);
|
| + // SimulateUserInputChangeForElement posts a task, so we need to wait until
|
| + // it's been processed.
|
| base::MessageLoop::current()->RunUntilIdle();
|
| EXPECT_EQ(edited_password, first_password_element.value());
|
| EXPECT_EQ(edited_password, second_password_element.value());
|
|
|
| // Verify that password mirroring works correctly even when the password
|
| // is deleted.
|
| - base::string16 empty_password;
|
| - first_password_element.setValue(empty_password);
|
| - // Cast to WebAutofillClient where textFieldDidChange() is public.
|
| - static_cast<blink::WebAutofillClient*>(autofill_agent_)->textFieldDidChange(
|
| - first_password_element);
|
| - // textFieldDidChange posts a task, so we need to wait until it's been
|
| - // processed.
|
| + SimulateUserInputChangeForElement(&first_password_element, GetMainFrame(),
|
| + std::string());
|
| + // SimulateUserInputChangeForElement posts a task, so we need to wait until
|
| + // it's been processed.
|
| base::MessageLoop::current()->RunUntilIdle();
|
| - EXPECT_EQ(empty_password, first_password_element.value());
|
| - EXPECT_EQ(empty_password, second_password_element.value());
|
| + EXPECT_EQ(base::string16(), first_password_element.value());
|
| + EXPECT_EQ(base::string16(), second_password_element.value());
|
| }
|
|
|
| TEST_F(PasswordGenerationAgentTest, BlacklistedTest) {
|
| @@ -394,14 +391,11 @@ TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) {
|
| WebInputElement first_password_element = element.to<WebInputElement>();
|
|
|
| // Make a password just under maximum offer size.
|
| - first_password_element.setValue(
|
| - base::ASCIIToUTF16(
|
| - std::string(password_generation_->kMaximumOfferSize - 1, 'a')));
|
| - // Cast to WebAutofillClient where textFieldDidChange() is public.
|
| - static_cast<blink::WebAutofillClient*>(autofill_agent_)->textFieldDidChange(
|
| - first_password_element);
|
| - // textFieldDidChange posts a task, so we need to wait until it's been
|
| - // processed.
|
| + SimulateUserInputChangeForElement(
|
| + &first_password_element, GetMainFrame(),
|
| + std::string(password_generation_->kMaximumOfferSize - 1, 'a'));
|
| + // SimulateUserInputChangeForElement posts a task, so we need to wait until
|
| + // it's been processed.
|
| base::MessageLoop::current()->RunUntilIdle();
|
| // There should now be a message to show the UI.
|
| ASSERT_EQ(1u, password_generation_->messages().size());
|
| @@ -410,14 +404,10 @@ TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) {
|
| password_generation_->clear_messages();
|
|
|
| // Simulate a user typing a password just over maximum offer size.
|
| - first_password_element.setValue(
|
| - base::ASCIIToUTF16(
|
| - std::string(password_generation_->kMaximumOfferSize + 1, 'a')));
|
| - // Cast to WebAutofillClient where textFieldDidChange() is public.
|
| - static_cast<blink::WebAutofillClient*>(autofill_agent_)->textFieldDidChange(
|
| - first_password_element);
|
| - // textFieldDidChange posts a task, so we need to wait until it's been
|
| - // processed.
|
| + SimulateUserTypingASCIICharacter('a');
|
| + SimulateUserTypingASCIICharacter('a');
|
| + // SimulateUserTypingASCIICharacter posts a task, so we need to wait until
|
| + // it's been processed.
|
| base::MessageLoop::current()->RunUntilIdle();
|
| // There should now be a message to hide the UI.
|
| ASSERT_EQ(1u, password_generation_->messages().size());
|
| @@ -427,14 +417,9 @@ TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) {
|
|
|
| // Simulate the user deleting characters. The generation popup should be shown
|
| // again.
|
| - first_password_element.setValue(
|
| - base::ASCIIToUTF16(
|
| - std::string(password_generation_->kMaximumOfferSize, 'a')));
|
| - // Cast to WebAutofillClient where textFieldDidChange() is public.
|
| - static_cast<blink::WebAutofillClient*>(autofill_agent_)->textFieldDidChange(
|
| - first_password_element);
|
| - // textFieldDidChange posts a task, so we need to wait until it's been
|
| - // processed.
|
| + SimulateUserTypingKeyCodeWithShift(ui::VKEY_BACK, false);
|
| + // SimulateUserTypingKeyCodeWithShift posts a task, so we need to wait until
|
| + // it's been processed.
|
| base::MessageLoop::current()->RunUntilIdle();
|
| // There should now be a message to show the UI.
|
| ASSERT_EQ(1u, password_generation_->messages().size());
|
|
|