Index: chrome/renderer/autofill/password_generation_manager_browsertest.cc |
diff --git a/chrome/renderer/autofill/password_generation_manager_browsertest.cc b/chrome/renderer/autofill/password_generation_manager_browsertest.cc |
index ce9367f31ba69f56bf31ea3ca5d8814fb25bf4e5..b60376dc97f8fc9d2aad77c760e2fc3a18d436da 100644 |
--- a/chrome/renderer/autofill/password_generation_manager_browsertest.cc |
+++ b/chrome/renderer/autofill/password_generation_manager_browsertest.cc |
@@ -37,7 +37,7 @@ class TestPasswordGenerationManager : public PasswordGenerationManager { |
} |
protected: |
- virtual bool ShouldAnalyzeFrame(const WebKit::WebFrame& frame) const |
+ virtual bool ShouldAnalyzeDocument(const WebKit::WebDocument& document) const |
OVERRIDE { |
return true; |
} |
@@ -65,6 +65,12 @@ class PasswordGenerationManagerTest : public ChromeRenderViewTest { |
generation_manager_.reset(new TestPasswordGenerationManager(view_)); |
} |
+ void SimulateClickOnDecoration(WebKit::WebInputElement& input_element) { |
+ WebKit::WebElement decoration = |
+ input_element.decorationElementFor(generation_manager_.get()); |
+ decoration.simulateClick(); |
+ } |
+ |
protected: |
scoped_ptr<TestPasswordGenerationManager> generation_manager_; |
@@ -95,28 +101,28 @@ TEST_F(PasswordGenerationManagerTest, DetectionTest) { |
document.getElementById(WebString::fromUTF8("password")); |
ASSERT_FALSE(element.isNull()); |
WebInputElement password_element = element.to<WebInputElement>(); |
- EXPECT_EQ(0u, generation_manager_->messages().size()); |
+ EXPECT_FALSE(password_element.decorationElementFor( |
+ generation_manager_.get()).hasNonEmptyBoundingBox()); |
Ilya Sherman
2012/06/01 00:34:31
nit: This condition is somewhat lengthy -- perhaps
Garrett Casto
2012/06/01 01:21:28
Done.
|
LoadHTML(kAccountCreationFormHTML); |
- // We don't do anything yet because the feature is disabled. |
+ // We don't show the decoration yet because the feature isn't enabled. |
document = GetMainFrame()->document(); |
element = document.getElementById(WebString::fromUTF8("first_password")); |
ASSERT_FALSE(element.isNull()); |
WebInputElement first_password_element = element.to<WebInputElement>(); |
- EXPECT_EQ(0u, generation_manager_->messages().size()); |
element = document.getElementById(WebString::fromUTF8("second_password")); |
ASSERT_FALSE(element.isNull()); |
WebInputElement second_password_element = element.to<WebInputElement>(); |
- EXPECT_EQ(0u, generation_manager_->messages().size()); |
- SetFocused(first_password_element.to<WebNode>()); |
- EXPECT_EQ(0u, generation_manager_->messages().size()); |
+ EXPECT_FALSE(first_password_element.decorationElementFor( |
+ generation_manager_.get()).hasNonEmptyBoundingBox()); |
Ilya Sherman
2012/06/01 00:34:31
nit: Hmm, shouldn't there be an EXPECT_TRUE with t
Garrett Casto
2012/06/01 01:21:28
Yep, fixed.
|
// Pretend like password generation was enabled. |
AutofillMsg_PasswordGenerationEnabled msg(0, true); |
generation_manager_->OnMessageReceived(msg); |
- // Now we will send a message once the first password feld is focused. |
+ // Now check that the decoration is visible on the first password field and |
+ // that we send a message after the decoration is clicked. |
LoadHTML(kAccountCreationFormHTML); |
document = GetMainFrame()->document(); |
element = document.getElementById(WebString::fromUTF8("first_password")); |
@@ -127,7 +133,7 @@ TEST_F(PasswordGenerationManagerTest, DetectionTest) { |
ASSERT_FALSE(element.isNull()); |
second_password_element = element.to<WebInputElement>(); |
EXPECT_EQ(0u, generation_manager_->messages().size()); |
- SetFocused(first_password_element.to<WebNode>()); |
+ SimulateClickOnDecoration(first_password_element); |
EXPECT_EQ(1u, generation_manager_->messages().size()); |
EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID, |
generation_manager_->messages()[0]->type()); |