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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/autofill/content/common/autofill_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/autofill/password_generation_agent_browsertest.cc
diff --git a/chrome/renderer/autofill/password_generation_agent_browsertest.cc b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
index 2743a9af67ea17ca6e4986c687f9e66ec536edf7..d376f05d21d0c711cc7aa4d1e33b63a78d99becb 100644
--- a/chrome/renderer/autofill/password_generation_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
@@ -72,16 +72,27 @@ class PasswordGenerationAgentTest : public ChromeRenderViewTest {
render_thread_->sink().ClearMessages();
}
+ void AllowToRunFormClassifier() {
+ AutofillMsg_AllowToRunFormClassifier msg(0);
+ static_cast<IPC::Listener*>(password_generation_)->OnMessageReceived(msg);
+ }
+
void ExpectFormClassifierVoteReceived(
+ bool received,
const base::string16& expected_generation_element) {
const IPC::Message* message =
render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_SaveGenerationFieldDetectedByClassifier::ID);
- ASSERT_TRUE(message);
- std::tuple<autofill::PasswordForm, base::string16> actual_parameters;
- AutofillHostMsg_SaveGenerationFieldDetectedByClassifier::Read(
- message, &actual_parameters);
- EXPECT_EQ(expected_generation_element, std::get<1>(actual_parameters));
+ if (received) {
+ ASSERT_TRUE(message);
+ std::tuple<autofill::PasswordForm, base::string16> actual_parameters;
+ AutofillHostMsg_SaveGenerationFieldDetectedByClassifier::Read(
+ message, &actual_parameters);
+ EXPECT_EQ(expected_generation_element, std::get<1>(actual_parameters));
+ } else {
+ ASSERT_FALSE(message);
+ }
+
render_thread_->sink().ClearMessages();
}
@@ -661,13 +672,23 @@ TEST_F(PasswordGenerationAgentTest, PresavingGeneratedPassword) {
}
TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSignupForm) {
+ AllowToRunFormClassifier();
LoadHTMLWithUserGesture(kAccountCreationFormHTML);
- ExpectFormClassifierVoteReceived(base::ASCIIToUTF16("first_password"));
+ ExpectFormClassifierVoteReceived(true /* vote is expected */,
+ base::ASCIIToUTF16("first_password"));
}
TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSigninForm) {
+ AllowToRunFormClassifier();
+ LoadHTMLWithUserGesture(kSigninFormHTML);
+ ExpectFormClassifierVoteReceived(true /* vote is expected */,
+ base::string16());
+}
+
+TEST_F(PasswordGenerationAgentTest, FormClassifierDisabled) {
LoadHTMLWithUserGesture(kSigninFormHTML);
- ExpectFormClassifierVoteReceived(base::string16());
+ ExpectFormClassifierVoteReceived(false /* vote is not expected */,
+ base::string16());
}
} // namespace autofill
« 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