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

Side by Side 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: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/test/base/chrome_render_view_test.h" 7 #include "chrome/test/base/chrome_render_view_test.h"
8 #include "components/autofill/content/common/autofill_messages.h" 8 #include "components/autofill/content/common/autofill_messages.h"
9 #include "components/autofill/content/renderer/autofill_agent.h" 9 #include "components/autofill/content/renderer/autofill_agent.h"
10 #include "components/autofill/content/renderer/form_autofill_util.h" 10 #include "components/autofill/content/renderer/form_autofill_util.h"
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 username_element_, kAliceUsername, kAlicePassword)); 1040 username_element_, kAliceUsername, kAlicePassword));
1041 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); 1041 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true);
1042 1042
1043 // Try accepting a suggestion with a password different from the one that was 1043 // Try accepting a suggestion with a password different from the one that was
1044 // initially sent to the renderer. 1044 // initially sent to the renderer.
1045 EXPECT_TRUE(password_autofill_->AcceptSuggestion( 1045 EXPECT_TRUE(password_autofill_->AcceptSuggestion(
1046 username_element_, kBobUsername, kCarolPassword)); 1046 username_element_, kBobUsername, kCarolPassword));
1047 CheckTextFieldsDOMState(kBobUsername, true, kCarolPassword, true); 1047 CheckTextFieldsDOMState(kBobUsername, true, kCarolPassword, true);
1048 } 1048 }
1049 1049
1050 // Tests that the PasswordAutofillAgent reacts appropriately to messages about
1051 // changing the logging state.
1052 // Note: this seems like better suited for a unit test, but for technical
1053 // complications was done as a browser test, see the discussion at
1054 // https://codereview.chromium.org/258473005/.
1055 TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState) {
1056 // Up-cast to access OnMessageReceived, which is private in the agent.
1057 IPC::Listener* const agent_listener(password_autofill_);
1058
1059 EXPECT_FALSE(password_autofill_->logging_state_active());
1060
1061 AutofillMsg_ChangeLoggingState msg_activate(0, true);
1062 EXPECT_TRUE(agent_listener->OnMessageReceived(msg_activate));
1063 EXPECT_TRUE(password_autofill_->logging_state_active());
1064
1065 AutofillMsg_ChangeLoggingState msg_deactivate(0, false);
1066 EXPECT_TRUE(agent_listener->OnMessageReceived(msg_deactivate));
1067 EXPECT_FALSE(password_autofill_->logging_state_active());
1068 }
Ilya Sherman 2014/04/25 18:25:29 Hmm, could you instead test that RPCs are or aren'
vabr (Chromium) 2014/04/28 14:31:09 Absolutely, that's a very good point. Done.
1069
1050 } // namespace autofill 1070 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698