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

Unified Diff: components/autofill/core/browser/autofill_manager_unittest.cc

Issue 2830303002: Fix sending autofill votes for sign-in forms. (Closed)
Patch Set: Comments added Created 3 years, 8 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
Index: components/autofill/core/browser/autofill_manager_unittest.cc
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index e9d94a48d4007bdfa171308b4ec47b95e6fa3aa5..b6e9583be0751e667a5fc588131139c41bcc2783 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -334,6 +334,13 @@ class TestAutofillDownloadManager : public AutofillDownloadManager {
}
}
+ MOCK_METHOD5(StartUploadRequest,
+ bool(const FormStructure&,
+ bool,
+ const ServerFieldTypeSet&,
+ const std::string&,
+ bool));
+
private:
std::vector<FormStructure*> last_queried_forms_;
@@ -538,7 +545,8 @@ class TestAutofillManager : public AutofillManager {
autofill_enabled_(true),
credit_card_upload_enabled_(false),
credit_card_was_uploaded_(false),
- expected_observed_submission_(true) {
+ expected_observed_submission_(true),
+ call_parent_upload_form_data_(false) {
set_payments_client(
new TestPaymentsClient(driver->GetURLRequestContext(), this));
}
@@ -569,6 +577,10 @@ class TestAutofillManager : public AutofillManager {
expected_observed_submission_ = expected;
}
+ void set_call_parent_upload_form_data(bool value) {
+ call_parent_upload_form_data_ = value;
+ }
+
void UploadFormDataAsyncCallback(const FormStructure* submitted_form,
const base::TimeTicks& load_time,
const base::TimeTicks& interaction_time,
@@ -615,6 +627,9 @@ class TestAutofillManager : public AutofillManager {
void UploadFormData(const FormStructure& submitted_form,
bool observed_submission) override {
submitted_form_signature_ = submitted_form.FormSignatureAsStr();
+
+ if (call_parent_upload_form_data_)
+ AutofillManager::UploadFormData(submitted_form, observed_submission);
}
const std::string GetSubmittedFormSignature() {
@@ -664,6 +679,7 @@ class TestAutofillManager : public AutofillManager {
bool credit_card_upload_enabled_;
bool credit_card_was_uploaded_;
bool expected_observed_submission_;
+ bool call_parent_upload_form_data_;
std::unique_ptr<base::RunLoop> run_loop_;
@@ -6071,6 +6087,7 @@ TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) {
// callback initiated by WaitForAsyncUploadProcess checks these expectations.)
autofill_manager_->set_expected_submitted_field_types(expected_types);
autofill_manager_->set_expected_observed_submission(true);
+ autofill_manager_->set_call_parent_upload_form_data(true);
autofill_manager_->ResetRunLoop();
std::unique_ptr<FormStructure> form_structure(new FormStructure(form));
@@ -6078,6 +6095,11 @@ TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) {
form_structure->field(1)->set_possible_types({autofill::PASSWORD});
std::string signature = form_structure->FormSignatureAsStr();
+
+ ServerFieldTypeSet uploaded_available_types;
+ EXPECT_CALL(*download_manager_,
+ StartUploadRequest(_, false, _, std::string(), true))
+ .WillOnce(DoAll(SaveArg<2>(&uploaded_available_types), Return(true)));
autofill_manager_->StartUploadProcess(std::move(form_structure),
base::TimeTicks::Now(), true);
@@ -6085,6 +6107,8 @@ TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) {
autofill_manager_->WaitForAsyncUploadProcess();
EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature());
+ EXPECT_NE(uploaded_available_types.end(),
+ uploaded_available_types.find(autofill::PASSWORD));
}
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/form_structure.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698