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

Side by Side Diff: components/autofill/core/browser/form_structure_unittest.cc

Issue 2148303005: [Password Generation] Sends the flag whether a field has nonempty user input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes addressed to reviewer comments Created 4 years, 4 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 "components/autofill/core/browser/form_structure.h" 5 #include "components/autofill/core/browser/form_structure.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 if (form_structure->field(i)->name == ASCIIToUTF16("password")) { 2210 if (form_structure->field(i)->name == ASCIIToUTF16("password")) {
2211 form_structure->field(i)->set_generation_type( 2211 form_structure->field(i)->set_generation_type(
2212 AutofillUploadContents::Field:: 2212 AutofillUploadContents::Field::
2213 MANUALLY_TRIGGERED_GENERATION_ON_SIGN_UP_FORM); 2213 MANUALLY_TRIGGERED_GENERATION_ON_SIGN_UP_FORM);
2214 form_structure->field(i)->set_form_classifier_outcome( 2214 form_structure->field(i)->set_form_classifier_outcome(
2215 AutofillUploadContents::Field::GENERATION_ELEMENT); 2215 AutofillUploadContents::Field::GENERATION_ELEMENT);
2216 } else { 2216 } else {
2217 form_structure->field(i)->set_form_classifier_outcome( 2217 form_structure->field(i)->set_form_classifier_outcome(
2218 AutofillUploadContents::Field::NON_GENERATION_ELEMENT); 2218 AutofillUploadContents::Field::NON_GENERATION_ELEMENT);
2219 } 2219 }
2220 if (form_structure->field(i)->name == ASCIIToUTF16("firstname")) {
2221 form_structure->field(i)->properties_mask =
2222 FieldPropertiesFlags::HAD_FOCUS;
2223 } else {
2224 form_structure->field(i)->properties_mask =
2225 FieldPropertiesFlags::HAD_FOCUS | FieldPropertiesFlags::USER_TYPED;
2226 }
2220 } 2227 }
2221 2228
2222 ServerFieldTypeSet available_field_types; 2229 ServerFieldTypeSet available_field_types;
2223 available_field_types.insert(NAME_FIRST); 2230 available_field_types.insert(NAME_FIRST);
2224 available_field_types.insert(NAME_LAST); 2231 available_field_types.insert(NAME_LAST);
2225 available_field_types.insert(EMAIL_ADDRESS); 2232 available_field_types.insert(EMAIL_ADDRESS);
2226 available_field_types.insert(USERNAME); 2233 available_field_types.insert(USERNAME);
2227 available_field_types.insert(ACCOUNT_CREATION_PASSWORD); 2234 available_field_types.insert(ACCOUNT_CREATION_PASSWORD);
2228 2235
2229 // Prepare the expected proto string. 2236 // Prepare the expected proto string.
2230 AutofillUploadContents upload; 2237 AutofillUploadContents upload;
2231 upload.set_submission(true); 2238 upload.set_submission(true);
2232 upload.set_client_version("6.1.1715.1442/en (GGLL)"); 2239 upload.set_client_version("6.1.1715.1442/en (GGLL)");
2233 upload.set_form_signature(5810032074788446513U); 2240 upload.set_form_signature(5810032074788446513U);
2234 upload.set_autofill_used(true); 2241 upload.set_autofill_used(true);
2235 upload.set_data_present("1440000000000000000802"); 2242 upload.set_data_present("1440000000000000000802");
2236 upload.set_action_signature(15724779818122431245U); 2243 upload.set_action_signature(15724779818122431245U);
2237 upload.set_login_form_signature(42); 2244 upload.set_login_form_signature(42);
2238 2245
2239 AutofillUploadContents::Field* upload_firstname_field = upload.add_field(); 2246 AutofillUploadContents::Field* upload_firstname_field = upload.add_field();
2240 test::FillUploadField(upload_firstname_field, 4224610201U, "firstname", "", 2247 test::FillUploadField(upload_firstname_field, 4224610201U, "firstname", "",
2241 "given-name", 3U, nullptr); 2248 "given-name", 3U, nullptr);
2242 upload_firstname_field->set_form_classifier_outcome( 2249 upload_firstname_field->set_form_classifier_outcome(
2243 AutofillUploadContents::Field::NON_GENERATION_ELEMENT); 2250 AutofillUploadContents::Field::NON_GENERATION_ELEMENT);
2251 upload_firstname_field->set_properties_mask(FieldPropertiesFlags::HAD_FOCUS);
2244 2252
2245 AutofillUploadContents::Field* upload_lastname_field = upload.add_field(); 2253 AutofillUploadContents::Field* upload_lastname_field = upload.add_field();
2246 test::FillUploadField(upload_lastname_field, 2786066110U, "lastname", "", 2254 test::FillUploadField(upload_lastname_field, 2786066110U, "lastname", "",
2247 "family-name", 5U, nullptr); 2255 "family-name", 5U, nullptr);
2248 upload_lastname_field->set_form_classifier_outcome( 2256 upload_lastname_field->set_form_classifier_outcome(
2249 AutofillUploadContents::Field::NON_GENERATION_ELEMENT); 2257 AutofillUploadContents::Field::NON_GENERATION_ELEMENT);
2258 upload_lastname_field->set_properties_mask(FieldPropertiesFlags::HAD_FOCUS |
2259 FieldPropertiesFlags::USER_TYPED);
2250 2260
2251 AutofillUploadContents::Field* upload_email_field = upload.add_field(); 2261 AutofillUploadContents::Field* upload_email_field = upload.add_field();
2252 test::FillUploadField(upload_email_field, 1029417091U, "email", "email", 2262 test::FillUploadField(upload_email_field, 1029417091U, "email", "email",
2253 "email", 9U, nullptr); 2263 "email", 9U, nullptr);
2254 upload_email_field->set_form_classifier_outcome( 2264 upload_email_field->set_form_classifier_outcome(
2255 AutofillUploadContents::Field::NON_GENERATION_ELEMENT); 2265 AutofillUploadContents::Field::NON_GENERATION_ELEMENT);
2266 upload_email_field->set_properties_mask(FieldPropertiesFlags::HAD_FOCUS |
2267 FieldPropertiesFlags::USER_TYPED);
2256 2268
2257 AutofillUploadContents::Field* upload_username_field = upload.add_field(); 2269 AutofillUploadContents::Field* upload_username_field = upload.add_field();
2258 test::FillUploadField(upload_username_field, 239111655U, "username", "text", 2270 test::FillUploadField(upload_username_field, 239111655U, "username", "text",
2259 "email", 86U, nullptr); 2271 "email", 86U, nullptr);
2260 upload_username_field->set_form_classifier_outcome( 2272 upload_username_field->set_form_classifier_outcome(
2261 AutofillUploadContents::Field::NON_GENERATION_ELEMENT); 2273 AutofillUploadContents::Field::NON_GENERATION_ELEMENT);
2274 upload_username_field->set_properties_mask(FieldPropertiesFlags::HAD_FOCUS |
2275 FieldPropertiesFlags::USER_TYPED);
2262 2276
2263 AutofillUploadContents::Field* upload_password_field = upload.add_field(); 2277 AutofillUploadContents::Field* upload_password_field = upload.add_field();
2264 test::FillUploadField(upload_password_field, 2051817934U, "password", 2278 test::FillUploadField(upload_password_field, 2051817934U, "password",
2265 "password", "email", 76U, nullptr); 2279 "password", "email", 76U, nullptr);
2266 upload_password_field->set_form_classifier_outcome( 2280 upload_password_field->set_form_classifier_outcome(
2267 AutofillUploadContents::Field::GENERATION_ELEMENT); 2281 AutofillUploadContents::Field::GENERATION_ELEMENT);
2268 upload_password_field->set_generation_type( 2282 upload_password_field->set_generation_type(
2269 AutofillUploadContents::Field:: 2283 AutofillUploadContents::Field::
2270 MANUALLY_TRIGGERED_GENERATION_ON_SIGN_UP_FORM); 2284 MANUALLY_TRIGGERED_GENERATION_ON_SIGN_UP_FORM);
2285 upload_password_field->set_properties_mask(FieldPropertiesFlags::HAD_FOCUS |
2286 FieldPropertiesFlags::USER_TYPED);
2271 2287
2272 std::string expected_upload_string; 2288 std::string expected_upload_string;
2273 ASSERT_TRUE(upload.SerializeToString(&expected_upload_string)); 2289 ASSERT_TRUE(upload.SerializeToString(&expected_upload_string));
2274 2290
2275 AutofillUploadContents encoded_upload; 2291 AutofillUploadContents encoded_upload;
2276 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, 2292 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true,
2277 "42", true, &encoded_upload)); 2293 "42", true, &encoded_upload));
2278 2294
2279 std::string encoded_upload_string; 2295 std::string encoded_upload_string;
2280 encoded_upload.SerializeToString(&encoded_upload_string); 2296 encoded_upload.SerializeToString(&encoded_upload_string);
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3659 prefix = FormStructure::FindLongestCommonPrefix(strings); 3675 prefix = FormStructure::FindLongestCommonPrefix(strings);
3660 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix); 3676 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix);
3661 3677
3662 // Empty vector. 3678 // Empty vector.
3663 strings.clear(); 3679 strings.clear();
3664 prefix = FormStructure::FindLongestCommonPrefix(strings); 3680 prefix = FormStructure::FindLongestCommonPrefix(strings);
3665 EXPECT_EQ(ASCIIToUTF16(""), prefix); 3681 EXPECT_EQ(ASCIIToUTF16(""), prefix);
3666 } 3682 }
3667 3683
3668 } // namespace autofill 3684 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698