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

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

Issue 2073143002: [Password Generation] Run the form classifier only if AutofillMetadata is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pg_classifier_votes
Patch Set: Removed unnecessary ';' 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
« no previous file with comments | « no previous file | components/autofill/content/common/autofill_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 AllowToRunFormClassifier() {
76 AutofillMsg_AllowToRunFormClassifier msg(0);
77 static_cast<IPC::Listener*>(password_generation_)->OnMessageReceived(msg);
78 }
79
75 void ExpectFormClassifierVoteReceived( 80 void ExpectFormClassifierVoteReceived(
81 bool received,
76 const base::string16& expected_generation_element) { 82 const base::string16& expected_generation_element) {
77 const IPC::Message* message = 83 const IPC::Message* message =
78 render_thread_->sink().GetFirstMessageMatching( 84 render_thread_->sink().GetFirstMessageMatching(
79 AutofillHostMsg_SaveGenerationFieldDetectedByClassifier::ID); 85 AutofillHostMsg_SaveGenerationFieldDetectedByClassifier::ID);
80 ASSERT_TRUE(message); 86 if (received) {
81 std::tuple<autofill::PasswordForm, base::string16> actual_parameters; 87 ASSERT_TRUE(message);
82 AutofillHostMsg_SaveGenerationFieldDetectedByClassifier::Read( 88 std::tuple<autofill::PasswordForm, base::string16> actual_parameters;
83 message, &actual_parameters); 89 AutofillHostMsg_SaveGenerationFieldDetectedByClassifier::Read(
84 EXPECT_EQ(expected_generation_element, std::get<1>(actual_parameters)); 90 message, &actual_parameters);
91 EXPECT_EQ(expected_generation_element, std::get<1>(actual_parameters));
92 } else {
93 ASSERT_FALSE(message);
94 }
95
85 render_thread_->sink().ClearMessages(); 96 render_thread_->sink().ClearMessages();
86 } 97 }
87 98
88 void ShowGenerationPopUpManually(const char* element_id) { 99 void ShowGenerationPopUpManually(const char* element_id) {
89 FocusField(element_id); 100 FocusField(element_id);
90 AutofillMsg_UserTriggeredGeneratePassword msg(0); 101 AutofillMsg_UserTriggeredGeneratePassword msg(0);
91 static_cast<IPC::Listener*>(password_generation_)->OnMessageReceived(msg); 102 static_cast<IPC::Listener*>(password_generation_)->OnMessageReceived(msg);
92 } 103 }
93 104
94 private: 105 private:
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 for (size_t i = 0; i < password.length(); ++i) 665 for (size_t i = 0; i < password.length(); ++i)
655 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, false); 666 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, false);
656 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, true); 667 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, true);
657 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( 668 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
658 AutofillHostMsg_PasswordNoLongerGenerated::ID)); 669 AutofillHostMsg_PasswordNoLongerGenerated::ID));
659 render_thread_->sink().ClearMessages(); 670 render_thread_->sink().ClearMessages();
660 } 671 }
661 } 672 }
662 673
663 TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSignupForm) { 674 TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSignupForm) {
675 AllowToRunFormClassifier();
664 LoadHTMLWithUserGesture(kAccountCreationFormHTML); 676 LoadHTMLWithUserGesture(kAccountCreationFormHTML);
665 ExpectFormClassifierVoteReceived(base::ASCIIToUTF16("first_password")); 677 ExpectFormClassifierVoteReceived(true /* vote is expected */,
678 base::ASCIIToUTF16("first_password"));
666 } 679 }
667 680
668 TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSigninForm) { 681 TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSigninForm) {
682 AllowToRunFormClassifier();
669 LoadHTMLWithUserGesture(kSigninFormHTML); 683 LoadHTMLWithUserGesture(kSigninFormHTML);
670 ExpectFormClassifierVoteReceived(base::string16()); 684 ExpectFormClassifierVoteReceived(true /* vote is expected */,
685 base::string16());
686 }
687
688 TEST_F(PasswordGenerationAgentTest, FormClassifierDisabled) {
689 LoadHTMLWithUserGesture(kSigninFormHTML);
690 ExpectFormClassifierVoteReceived(false /* vote is not expected */,
691 base::string16());
671 } 692 }
672 693
673 } // namespace autofill 694 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/common/autofill_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698