Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3949)

Unified Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 257803004: Add a test for toggling logging in PasswordAutofillAgent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..456be28509d4bba321447af586c78ea789c01de3 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() {
+ password_autofill_->SendPasswordForms(GetMainFrame(),
+ true /* only_visible */);
+ }
+
virtual void SetUp() {
ChromeRenderViewTest::SetUp();
@@ -1047,4 +1052,46 @@ TEST_F(PasswordAutofillAgentTest, AcceptSuggestion) {
CheckTextFieldsDOMState(kBobUsername, true, kCarolPassword, true);
}
+// Tests that logging is off by default.
+TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState_NoMessage) {
+ 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, OnChangeLoggingState_Activated) {
+ // Turn the logging on.
+ AutofillMsg_ChangeLoggingState msg_activate(0, true);
+ // Up-cast to access OnMessageReceived, which is private in the agent.
+ EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_)
+ ->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, OnChangeLoggingState_Deactivated) {
+ // Turn the logging on and then off.
+ AutofillMsg_ChangeLoggingState msg_activate(0, /*active=*/true);
+ // Up-cast to access OnMessageReceived, which is private in the agent.
+ EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_)
+ ->OnMessageReceived(msg_activate));
+ AutofillMsg_ChangeLoggingState msg_deactivate(0, /*active=*/false);
+ EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_)
+ ->OnMessageReceived(msg_deactivate));
+
+ render_thread_->sink().ClearMessages();
+ SendVisiblePasswordForms();
+ const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
+ AutofillHostMsg_RecordSavePasswordProgress::ID);
+ EXPECT_FALSE(message);
+}
+
} // namespace autofill
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698