Index: chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
index 955156d58985b17bf0e878badcc60d89eaed3bb4..04c1cb9f2a97fa39819a91057b622dc7922ed10e 100644 |
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
@@ -180,6 +180,11 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { |
password_autofill_->OnMessageReceived(msg); |
} |
+ void SendVisiblePasswordForms() { |
vabr (Chromium)
2014/04/28 14:31:10
Here I'm piggybacking on PasswordAutofillAgentTest
Ilya Sherman
2014/04/28 21:13:41
It would be nice to someday get rid of the friend
vabr (Chromium)
2014/04/29 07:45:18
I agree with both -- getting rid of the friend dec
|
+ password_autofill_->SendPasswordForms(GetMainFrame(), |
+ /*only_visible=*/true); |
Ilya Sherman
2014/04/28 21:13:41
Optional nit: I'd write this as "true /* only_visi
vabr (Chromium)
2014/04/29 07:45:18
Done.
|
+ } |
+ |
virtual void SetUp() { |
ChromeRenderViewTest::SetUp(); |
@@ -1047,4 +1052,47 @@ TEST_F(PasswordAutofillAgentTest, AcceptSuggestion) { |
CheckTextFieldsDOMState(kBobUsername, true, kCarolPassword, true); |
} |
+// Tests that logging is off by default. |
+TEST_F(PasswordAutofillAgentTest, OnChangeLoggingStateNoMessage) { |
Ilya Sherman
2014/04/28 21:13:41
Optional nit: I'd name this "OnChangeLoggingState_
vabr (Chromium)
2014/04/29 07:45:18
Done.
|
+ render_thread_->sink().ClearMessages(); |
+ SendVisiblePasswordForms(); |
+ const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( |
+ AutofillHostMsg_RecordSavePasswordProgress::ID); |
+ EXPECT_FALSE(message); |
+} |
+ |
+// Test that logging can be turned on by a message. |
+TEST_F(PasswordAutofillAgentTest, OnChangeLoggingStateActivated) { |
+ // Up-cast to access OnMessageReceived, which is private in the agent. |
+ IPC::Listener* const agent_listener(password_autofill_); |
Ilya Sherman
2014/04/28 21:13:41
nit: Please use a static_cast for casting.
vabr (Chromium)
2014/04/29 07:45:18
Done.
|
+ |
+ // Turn the logging on. |
+ AutofillMsg_ChangeLoggingState msg_activate(0, true); |
+ EXPECT_TRUE(agent_listener->OnMessageReceived(msg_activate)); |
+ |
+ render_thread_->sink().ClearMessages(); |
+ SendVisiblePasswordForms(); |
+ const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( |
+ AutofillHostMsg_RecordSavePasswordProgress::ID); |
+ EXPECT_TRUE(message); |
+} |
+ |
+// Test that logging can be turned off by a message. |
+TEST_F(PasswordAutofillAgentTest, OnChangeLoggingStateDeactivated) { |
+ // Up-cast to access OnMessageReceived, which is private in the agent. |
+ IPC::Listener* const agent_listener(password_autofill_); |
+ |
+ // Turn the logging on and then off. |
+ AutofillMsg_ChangeLoggingState msg_activate(0, /*active=*/true); |
+ EXPECT_TRUE(agent_listener->OnMessageReceived(msg_activate)); |
+ AutofillMsg_ChangeLoggingState msg_deactivate(0, /*active=*/false); |
+ EXPECT_TRUE(agent_listener->OnMessageReceived(msg_deactivate)); |
+ |
+ render_thread_->sink().ClearMessages(); |
+ SendVisiblePasswordForms(); |
+ const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( |
+ AutofillHostMsg_RecordSavePasswordProgress::ID); |
+ EXPECT_FALSE(message); |
+} |
+ |
} // namespace autofill |