Commit 65cf8d7d authored by vabr@chromium.org's avatar vabr@chromium.org

Add a test for toggling logging in PasswordAutofillAgent

Test for functionality added in https://codereview.chromium.org/231283003/.
This is done as a browser test. Previous attempt to make it a unit test was scratched in https://codereview.chromium.org/258473005/.

R=isherman@chromium.org
BUG=347927

Review URL: https://codereview.chromium.org/257803004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266829 0039d316-1c4b-4281-b951-d872f2087c98
parent 557c9842
...@@ -180,6 +180,11 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { ...@@ -180,6 +180,11 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
password_autofill_->OnMessageReceived(msg); password_autofill_->OnMessageReceived(msg);
} }
void SendVisiblePasswordForms() {
password_autofill_->SendPasswordForms(GetMainFrame(),
true /* only_visible */);
}
virtual void SetUp() { virtual void SetUp() {
ChromeRenderViewTest::SetUp(); ChromeRenderViewTest::SetUp();
...@@ -1047,4 +1052,46 @@ TEST_F(PasswordAutofillAgentTest, AcceptSuggestion) { ...@@ -1047,4 +1052,46 @@ TEST_F(PasswordAutofillAgentTest, AcceptSuggestion) {
CheckTextFieldsDOMState(kBobUsername, true, kCarolPassword, true); 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 } // namespace autofill
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment