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

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

Issue 1639563002: [Autofill] Fill from the last digits when filling a phone number with a maximum length. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 11 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 2455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 { 2466 {
2467 SCOPED_TRACE("Credit card 2"); 2467 SCOPED_TRACE("Credit card 2");
2468 ExpectFilledForm(response_page_id, response_data, kPageID3, "", "", "", "", 2468 ExpectFilledForm(response_page_id, response_data, kPageID3, "", "", "", "",
2469 "", "", "", "", "", "", "", "", "", "", "2012", true, true, 2469 "", "", "", "", "", "", "", "", "", "", "2012", true, true,
2470 false); 2470 false);
2471 } 2471 }
2472 } 2472 }
2473 2473
2474 // Test that we correctly fill a phone number split across multiple fields. 2474 // Test that we correctly fill a phone number split across multiple fields.
2475 TEST_F(AutofillManagerTest, FillPhoneNumber) { 2475 TEST_F(AutofillManagerTest, FillPhoneNumber) {
2476 // In one form, rely on the maxlength attribute to imply phone number parts. 2476 // In one form, rely on the maxlength attribute to imply phone number parts.
Mathieu 2016/01/27 14:30:49 imply US phone number parts.
sebsg 2016/01/27 21:01:21 Done.
2477 // In the other form, rely on the autocompletetype attribute. 2477 // In the other form, rely on the autocompletetype attribute.
2478 FormData form_with_maxlength; 2478 FormData form_with_maxlength;
Mathieu 2016/01/27 14:30:49 Rename to |form_with_us_number_max_length|
sebsg 2016/01/27 21:01:21 Done.
2479 form_with_maxlength.name = ASCIIToUTF16("MyMaxlengthPhoneForm"); 2479 form_with_maxlength.name = ASCIIToUTF16("MyMaxlengthPhoneForm");
2480 form_with_maxlength.origin = GURL("http://myform.com/phone_form.html"); 2480 form_with_maxlength.origin = GURL("http://myform.com/phone_form.html");
2481 form_with_maxlength.action = GURL("http://myform.com/phone_submit.html"); 2481 form_with_maxlength.action = GURL("http://myform.com/phone_submit.html");
2482 FormData form_with_autocompletetype = form_with_maxlength; 2482 FormData form_with_autocompletetype = form_with_maxlength;
2483 form_with_autocompletetype.name = ASCIIToUTF16("MyAutocompletetypePhoneForm"); 2483 form_with_autocompletetype.name = ASCIIToUTF16("MyAutocompletetypePhoneForm");
2484 2484
2485 struct { 2485 struct {
2486 const char* label; 2486 const char* label;
2487 const char* name; 2487 const char* name;
2488 size_t max_length; 2488 size_t max_length;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 &response_page_id, &response_data2); 2546 &response_page_id, &response_data2);
2547 EXPECT_EQ(2, response_page_id); 2547 EXPECT_EQ(2, response_page_id);
2548 2548
2549 ASSERT_EQ(5U, response_data2.fields.size()); 2549 ASSERT_EQ(5U, response_data2.fields.size());
2550 EXPECT_EQ(ASCIIToUTF16("1"), response_data2.fields[0].value); 2550 EXPECT_EQ(ASCIIToUTF16("1"), response_data2.fields[0].value);
2551 EXPECT_EQ(ASCIIToUTF16("650"), response_data2.fields[1].value); 2551 EXPECT_EQ(ASCIIToUTF16("650"), response_data2.fields[1].value);
2552 EXPECT_EQ(ASCIIToUTF16("555"), response_data2.fields[2].value); 2552 EXPECT_EQ(ASCIIToUTF16("555"), response_data2.fields[2].value);
2553 EXPECT_EQ(ASCIIToUTF16("4567"), response_data2.fields[3].value); 2553 EXPECT_EQ(ASCIIToUTF16("4567"), response_data2.fields[3].value);
2554 EXPECT_EQ(base::string16(), response_data2.fields[4].value); 2554 EXPECT_EQ(base::string16(), response_data2.fields[4].value);
2555 2555
2556 // We should not be able to fill prefix and suffix fields for international 2556 // We should not be able to fill prefix and suffix fields for international
Mathieu 2016/01/27 14:30:49 // We should not be able to fill international num
sebsg 2016/01/27 21:01:21 Done.
2557 // numbers. 2557 // numbers. However, the number should have the number of digits equal to the
2558 // max lenght specified, starting from the right.
Mathieu 2016/01/27 14:30:49 *length
sebsg 2016/01/27 21:01:21 Done.
2558 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("GB")); 2559 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("GB"));
2559 work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, 2560 work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER,
2560 ASCIIToUTF16("447700954321")); 2561 ASCIIToUTF16("447700954321"));
2561 page_id = 3; 2562 page_id = 3;
2562 response_page_id = 0; 2563 response_page_id = 0;
2563 FormData response_data3; 2564 FormData response_data3;
2564 FillAutofillFormDataAndSaveResults( 2565 FillAutofillFormDataAndSaveResults(
2565 page_id, form_with_maxlength, *form_with_maxlength.fields.begin(), 2566 page_id, form_with_maxlength, *form_with_maxlength.fields.begin(),
2566 MakeFrontendID(std::string(), guid), &response_page_id, &response_data3); 2567 MakeFrontendID(std::string(), guid), &response_page_id, &response_data3);
2567 EXPECT_EQ(3, response_page_id); 2568 EXPECT_EQ(3, response_page_id);
2568 2569
2569 ASSERT_EQ(5U, response_data3.fields.size()); 2570 ASSERT_EQ(5U, response_data3.fields.size());
2570 EXPECT_EQ(ASCIIToUTF16("44"), response_data3.fields[0].value); 2571 EXPECT_EQ(ASCIIToUTF16("4"), response_data3.fields[0].value);
Mathieu 2016/01/27 14:30:49 This is weird (a few digits truncated from each fi
sebsg 2016/01/27 21:01:21 Acknowledged.
2571 EXPECT_EQ(ASCIIToUTF16("7700"), response_data3.fields[1].value); 2572 EXPECT_EQ(ASCIIToUTF16("700"), response_data3.fields[1].value);
2572 EXPECT_EQ(ASCIIToUTF16("954321"), response_data3.fields[2].value); 2573 EXPECT_EQ(ASCIIToUTF16("321"), response_data3.fields[2].value);
2573 EXPECT_EQ(ASCIIToUTF16("954321"), response_data3.fields[3].value); 2574 EXPECT_EQ(ASCIIToUTF16("4321"), response_data3.fields[3].value);
2574 EXPECT_EQ(base::string16(), response_data3.fields[4].value); 2575 EXPECT_EQ(base::string16(), response_data3.fields[4].value);
2575 2576
2576 page_id = 4; 2577 page_id = 4;
2577 response_page_id = 0; 2578 response_page_id = 0;
2578 FormData response_data4; 2579 FormData response_data4;
2579 FillAutofillFormDataAndSaveResults(page_id, form_with_autocompletetype, 2580 FillAutofillFormDataAndSaveResults(page_id, form_with_autocompletetype,
2580 *form_with_autocompletetype.fields.begin(), 2581 *form_with_autocompletetype.fields.begin(),
2581 MakeFrontendID(std::string(), guid), 2582 MakeFrontendID(std::string(), guid),
2582 &response_page_id, &response_data4); 2583 &response_page_id, &response_data4);
2583 EXPECT_EQ(4, response_page_id); 2584 EXPECT_EQ(4, response_page_id);
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
4211 FormsSeen(mixed_forms); 4212 FormsSeen(mixed_forms);
4212 4213
4213 // Suggestions should always be displayed. 4214 // Suggestions should always be displayed.
4214 for (const FormFieldData& field : mixed_form.fields) { 4215 for (const FormFieldData& field : mixed_form.fields) {
4215 GetAutofillSuggestions(mixed_form, field); 4216 GetAutofillSuggestions(mixed_form, field);
4216 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); 4217 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
4217 } 4218 }
4218 } 4219 }
4219 4220
4220 } // namespace autofill 4221 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698