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

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

Issue 1670763006: Autofill server-side heuristics for 2 fields password form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 10 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 "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 form.fields.push_back(field); 306 form.fields.push_back(field);
307 307
308 form_structure.reset(new FormStructure(form)); 308 form_structure.reset(new FormStructure(form));
309 EXPECT_TRUE(form_structure->ShouldBeParsed()); 309 EXPECT_TRUE(form_structure->ShouldBeParsed());
310 310
311 form.fields[0].form_control_type = "select-one"; 311 form.fields[0].form_control_type = "select-one";
312 312
313 // Now, no text fields. 313 // Now, no text fields.
314 form_structure.reset(new FormStructure(form)); 314 form_structure.reset(new FormStructure(form));
315 EXPECT_FALSE(form_structure->ShouldBeParsed()); 315 EXPECT_FALSE(form_structure->ShouldBeParsed());
316
317 // We have only one field, which is password, should not be parsed.
318 form.fields.clear();
319 field.label = ASCIIToUTF16("Password");
320 field.name = ASCIIToUTF16("pw");
321 field.form_control_type = "password";
322 form.fields.push_back(field);
323 form_structure.reset(new FormStructure(form));
324 EXPECT_FALSE(form_structure->ShouldBeParsed());
325
326 // We have two fields, which are passwords, should be parsed.
327 field.label = ASCIIToUTF16("New password");
328 field.name = ASCIIToUTF16("new_pw");
329 field.form_control_type = "password";
330 form.fields.push_back(field);
331 form_structure.reset(new FormStructure(form));
332 EXPECT_TRUE(form_structure->ShouldBeParsed());
316 } 333 }
317 334
318 // Tests that ShouldBeParsed returns true for a form containing less than three 335 // Tests that ShouldBeParsed returns true for a form containing less than three
319 // fields if at least one has an autocomplete attribute. 336 // fields if at least one has an autocomplete attribute.
320 TEST_F(FormStructureTest, ShouldBeParsed_TwoFields_HasAutocomplete) { 337 TEST_F(FormStructureTest, ShouldBeParsed_TwoFields_HasAutocomplete) {
321 scoped_ptr<FormStructure> form_structure; 338 scoped_ptr<FormStructure> form_structure;
322 FormData form; 339 FormData form;
323 FormFieldData field; 340 FormFieldData field;
324 341
325 field.label = ASCIIToUTF16("Name"); 342 field.label = ASCIIToUTF16("Name");
(...skipping 3167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3493 prefix = FormStructure::FindLongestCommonPrefix(strings); 3510 prefix = FormStructure::FindLongestCommonPrefix(strings);
3494 EXPECT_EQ(ASCIIToUTF16("123456789"), prefix.as_string()); 3511 EXPECT_EQ(ASCIIToUTF16("123456789"), prefix.as_string());
3495 3512
3496 // Empty vector. 3513 // Empty vector.
3497 strings.clear(); 3514 strings.clear();
3498 prefix = FormStructure::FindLongestCommonPrefix(strings); 3515 prefix = FormStructure::FindLongestCommonPrefix(strings);
3499 EXPECT_EQ(ASCIIToUTF16(""), prefix.as_string()); 3516 EXPECT_EQ(ASCIIToUTF16(""), prefix.as_string());
3500 } 3517 }
3501 3518
3502 } // namespace autofill 3519 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | components/autofill/core/common/autofill_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698