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

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: replaced " DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage()) 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_SaveGenerationFieldDetectedByClassifier::ID);
80 ASSERT_TRUE(message);
81 std::tuple<autofill::PasswordForm, base::string16> actual_parameters;
82 AutofillHostMsg_SaveGenerationFieldDetectedByClassifier::Read(
83 message, &actual_parameters);
84 EXPECT_EQ(expected_generation_element, std::get<1>(actual_parameters));
85 render_thread_->sink().ClearMessages();
86 }
87
75 void ShowGenerationPopUpManually(const char* element_id) { 88 void ShowGenerationPopUpManually(const char* element_id) {
76 FocusField(element_id); 89 FocusField(element_id);
77 AutofillMsg_UserTriggeredGeneratePassword msg(0); 90 AutofillMsg_UserTriggeredGeneratePassword msg(0);
78 static_cast<IPC::Listener*>(password_generation_)->OnMessageReceived(msg); 91 static_cast<IPC::Listener*>(password_generation_)->OnMessageReceived(msg);
79 } 92 }
80 93
81 private: 94 private:
82 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgentTest); 95 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgentTest);
83 }; 96 };
84 97
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 653
641 for (size_t i = 0; i < password.length(); ++i) 654 for (size_t i = 0; i < password.length(); ++i)
642 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, false); 655 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, false);
643 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, true); 656 SimulateUserTypingASCIICharacter(ui::VKEY_BACK, true);
644 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( 657 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
645 AutofillHostMsg_PasswordNoLongerGenerated::ID)); 658 AutofillHostMsg_PasswordNoLongerGenerated::ID));
646 render_thread_->sink().ClearMessages(); 659 render_thread_->sink().ClearMessages();
647 } 660 }
648 } 661 }
649 662
663 TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSignupForm) {
664 LoadHTMLWithUserGesture(kAccountCreationFormHTML);
665 ExpectFormClassifierVoteReceived(base::ASCIIToUTF16("first_password"));
666 }
667
668 TEST_F(PasswordGenerationAgentTest, FormClassifierVotesSigninForm) {
669 LoadHTMLWithUserGesture(kSigninFormHTML);
670 ExpectFormClassifierVoteReceived(base::string16());
671 }
672
650 } // namespace autofill 673 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698