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

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

Issue 2055633003: [Password Generation] Sends form classifier vote to autofill server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pg_form_classification
Patch Set: Changed enum values Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string.h> 5 #include <string.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 render_thread_->sink().GetFirstMessageMatching( 65 render_thread_->sink().GetFirstMessageMatching(
66 AutofillHostMsg_ShowPasswordGenerationPopup::ID); 66 AutofillHostMsg_ShowPasswordGenerationPopup::ID);
67 if (available) 67 if (available)
68 ASSERT_TRUE(message); 68 ASSERT_TRUE(message);
69 else 69 else
70 ASSERT_FALSE(message); 70 ASSERT_FALSE(message);
71 71
72 render_thread_->sink().ClearMessages(); 72 render_thread_->sink().ClearMessages();
73 } 73 }
74 74
75 void ExpectFormClassifierVoteReceived(
76 const base::string16& expected_generation_element) {
77 const IPC::Message* message =
78 render_thread_->sink().GetFirstMessageMatching(
79 AutofillHostMsg_SaveFormClassifierVote::ID);
80 ASSERT_TRUE(message);
81 std::tuple<autofill::PasswordForm, base::string16> actual_parameters;
82 AutofillHostMsg_SaveFormClassifierVote::Read(message, &actual_parameters);
83 EXPECT_EQ(expected_generation_element, std::get<1>(actual_parameters));
84 render_thread_->sink().ClearMessages();
85 }
86
75 void ShowGenerationPopUpManually(const char* element_id) { 87 void ShowGenerationPopUpManually(const char* element_id) {
76 FocusField(element_id); 88 FocusField(element_id);
77 AutofillMsg_UserTriggeredGeneratePassword msg(0); 89 AutofillMsg_UserTriggeredGeneratePassword msg(0);
78 static_cast<IPC::Listener*>(password_generation_)->OnMessageReceived(msg); 90 static_cast<IPC::Listener*>(password_generation_)->OnMessageReceived(msg);
79 } 91 }
80 92
81 private: 93 private:
82 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgentTest); 94 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgentTest);
83 }; 95 };
84 96
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 652
641 for (size_t i = 0; i < password.length(); ++i) 653 for (size_t i = 0; i < password.length(); ++i)
642 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, false); 654 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, false);
643 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, true); 655 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, true);
644 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( 656 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
645 AutofillHostMsg_PasswordNoLongerGenerated::ID)); 657 AutofillHostMsg_PasswordNoLongerGenerated::ID));
646 render_thread_->sink().ClearMessages(); 658 render_thread_->sink().ClearMessages();
647 } 659 }
648 } 660 }
649 661
662 TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSignupForm) {
663 LoadHTMLWithUserGesture(kAccountCreationFormHTML);
664 ExpectFormClassifierVoteReceived(base::ASCIIToUTF16("first_password"));
665 }
666
667 TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSigninForm) {
668 LoadHTMLWithUserGesture(kSigninFormHTML);
669 ExpectFormClassifierVoteReceived(base::string16());
670 }
671
650 } // namespace autofill 672 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698