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

Side by Side Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 336763002: Password internals page: notify renderer about logging state on client construction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed Created 6 years, 6 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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 render_thread_->sink().ClearMessages(); 1292 render_thread_->sink().ClearMessages();
1293 SendVisiblePasswordForms(); 1293 SendVisiblePasswordForms();
1294 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( 1294 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
1295 AutofillHostMsg_RecordSavePasswordProgress::ID); 1295 AutofillHostMsg_RecordSavePasswordProgress::ID);
1296 EXPECT_FALSE(message); 1296 EXPECT_FALSE(message);
1297 } 1297 }
1298 1298
1299 // Test that logging can be turned on by a message. 1299 // Test that logging can be turned on by a message.
1300 TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState_Activated) { 1300 TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState_Activated) {
1301 // Turn the logging on. 1301 // Turn the logging on.
1302 AutofillMsg_ChangeLoggingState msg_activate(0, true); 1302 AutofillMsg_SetLoggingState msg_activate(0, true);
1303 // Up-cast to access OnMessageReceived, which is private in the agent. 1303 // Up-cast to access OnMessageReceived, which is private in the agent.
1304 EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_) 1304 EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_)
1305 ->OnMessageReceived(msg_activate)); 1305 ->OnMessageReceived(msg_activate));
1306 1306
1307 render_thread_->sink().ClearMessages(); 1307 render_thread_->sink().ClearMessages();
1308 SendVisiblePasswordForms(); 1308 SendVisiblePasswordForms();
1309 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( 1309 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
1310 AutofillHostMsg_RecordSavePasswordProgress::ID); 1310 AutofillHostMsg_RecordSavePasswordProgress::ID);
1311 EXPECT_TRUE(message); 1311 EXPECT_TRUE(message);
1312 } 1312 }
1313 1313
1314 // Test that logging can be turned off by a message. 1314 // Test that logging can be turned off by a message.
1315 TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState_Deactivated) { 1315 TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState_Deactivated) {
1316 // Turn the logging on and then off. 1316 // Turn the logging on and then off.
1317 AutofillMsg_ChangeLoggingState msg_activate(0, /*active=*/true); 1317 AutofillMsg_SetLoggingState msg_activate(0, /*active=*/true);
1318 // Up-cast to access OnMessageReceived, which is private in the agent. 1318 // Up-cast to access OnMessageReceived, which is private in the agent.
1319 EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_) 1319 EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_)
1320 ->OnMessageReceived(msg_activate)); 1320 ->OnMessageReceived(msg_activate));
1321 AutofillMsg_ChangeLoggingState msg_deactivate(0, /*active=*/false); 1321 AutofillMsg_SetLoggingState msg_deactivate(0, /*active=*/false);
1322 EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_) 1322 EXPECT_TRUE(static_cast<IPC::Listener*>(password_autofill_)
1323 ->OnMessageReceived(msg_deactivate)); 1323 ->OnMessageReceived(msg_deactivate));
1324 1324
1325 render_thread_->sink().ClearMessages(); 1325 render_thread_->sink().ClearMessages();
1326 SendVisiblePasswordForms(); 1326 SendVisiblePasswordForms();
1327 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( 1327 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
1328 AutofillHostMsg_RecordSavePasswordProgress::ID); 1328 AutofillHostMsg_RecordSavePasswordProgress::ID);
1329 EXPECT_FALSE(message); 1329 EXPECT_FALSE(message);
1330 } 1330 }
1331 1331
1332 // Test that the agent sends an IPC call to get the current activity state of
1333 // password saving logging soon after construction.
1334 TEST_F(PasswordAutofillAgentTest, SendsLoggingStateUpdatePingOnConstruction) {
1335 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
1336 AutofillHostMsg_PasswordAutofillAgentConstructed::ID);
1337 EXPECT_TRUE(message);
1338 }
1339
1332 } // namespace autofill 1340 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698