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

Side by Side Diff: chrome/browser/autofill/autofill_browsertest.cc

Issue 2950803002: Use ContainsValue() instead of std::find() in chrome/browser/ and chrome/test/ (Closed)
Patch Set: Reverted code for file thumbnail_cache.cc Created 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/stl_util.h"
16 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "base/time/time.h" 21 #include "base/time/time.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "chrome/browser/autofill/personal_data_manager_factory.h" 23 #include "chrome/browser/autofill/personal_data_manager_factory.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_navigator_params.h" 26 #include "chrome/browser/ui/browser_navigator_params.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 profile7.SetRawInfo(ADDRESS_HOME_ZIP, WideToUTF16(L"94086")); 352 profile7.SetRawInfo(ADDRESS_HOME_ZIP, WideToUTF16(L"94086"));
352 profile7.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, WideToUTF16(L"15466784565")); 353 profile7.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, WideToUTF16(L"15466784565"));
353 profile7.SetInfo( 354 profile7.SetInfo(
354 AutofillType(ADDRESS_HOME_COUNTRY), WideToUTF16(L"United States"), 355 AutofillType(ADDRESS_HOME_COUNTRY), WideToUTF16(L"United States"),
355 "en-US"); 356 "en-US");
356 profiles.push_back(profile7); 357 profiles.push_back(profile7);
357 358
358 SetProfiles(&profiles); 359 SetProfiles(&profiles);
359 ASSERT_EQ(profiles.size(), personal_data_manager()->GetProfiles().size()); 360 ASSERT_EQ(profiles.size(), personal_data_manager()->GetProfiles().size());
360 for (size_t i = 0; i < profiles.size(); ++i) { 361 for (size_t i = 0; i < profiles.size(); ++i) {
361 EXPECT_TRUE(std::find(profiles.begin(), 362 EXPECT_TRUE(base::ContainsValue(
362 profiles.end(), 363 profiles, *personal_data_manager()->GetProfiles()[i]));
363 *personal_data_manager()->GetProfiles()[i]) !=
364 profiles.end());
365 } 364 }
366 365
367 std::vector<CreditCard> cards; 366 std::vector<CreditCard> cards;
368 CreditCard card1; 367 CreditCard card1;
369 card1.SetRawInfo(CREDIT_CARD_NAME_FULL, 368 card1.SetRawInfo(CREDIT_CARD_NAME_FULL,
370 WideToUTF16(L"\u751f\u6d3b\u5f88\u6709\u89c4\u5f8b " 369 WideToUTF16(L"\u751f\u6d3b\u5f88\u6709\u89c4\u5f8b "
371 L"\u4ee5\u73a9\u4e3a\u4e3b")); 370 L"\u4ee5\u73a9\u4e3a\u4e3b"));
372 card1.SetRawInfo(CREDIT_CARD_NUMBER, WideToUTF16(L"6011111111111117")); 371 card1.SetRawInfo(CREDIT_CARD_NUMBER, WideToUTF16(L"6011111111111117"));
373 card1.SetRawInfo(CREDIT_CARD_EXP_MONTH, WideToUTF16(L"12")); 372 card1.SetRawInfo(CREDIT_CARD_EXP_MONTH, WideToUTF16(L"12"));
374 card1.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, WideToUTF16(L"2011")); 373 card1.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, WideToUTF16(L"2011"));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 L"\u03ba\u03b1\u03c4\u03b1\u03c1\u03b3\u03ae" 405 L"\u03ba\u03b1\u03c4\u03b1\u03c1\u03b3\u03ae"
407 L"\u03c3\u03b5\u03b9\u03c2")); 406 L"\u03c3\u03b5\u03b9\u03c2"));
408 card4.SetRawInfo(CREDIT_CARD_NUMBER, WideToUTF16(L"00000000000000000000000")); 407 card4.SetRawInfo(CREDIT_CARD_NUMBER, WideToUTF16(L"00000000000000000000000"));
409 card4.SetRawInfo(CREDIT_CARD_EXP_MONTH, WideToUTF16(L"01")); 408 card4.SetRawInfo(CREDIT_CARD_EXP_MONTH, WideToUTF16(L"01"));
410 card4.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, WideToUTF16(L"2016")); 409 card4.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, WideToUTF16(L"2016"));
411 cards.push_back(card4); 410 cards.push_back(card4);
412 411
413 SetCards(&cards); 412 SetCards(&cards);
414 ASSERT_EQ(cards.size(), personal_data_manager()->GetCreditCards().size()); 413 ASSERT_EQ(cards.size(), personal_data_manager()->GetCreditCards().size());
415 for (size_t i = 0; i < cards.size(); ++i) { 414 for (size_t i = 0; i < cards.size(); ++i) {
416 EXPECT_TRUE(std::find(cards.begin(), 415 EXPECT_TRUE(base::ContainsValue(
417 cards.end(), 416 cards, *personal_data_manager()->GetCreditCards()[i]));
418 *personal_data_manager()->GetCreditCards()[i]) !=
419 cards.end());
420 } 417 }
421 } 418 }
422 419
423 // Test filling in invalid values for profiles are saved as-is. Phone 420 // Test filling in invalid values for profiles are saved as-is. Phone
424 // information entered into the prefs UI is not validated or rejected except for 421 // information entered into the prefs UI is not validated or rejected except for
425 // duplicates. 422 // duplicates.
426 // TODO(isherman): rewrite as WebUI test? 423 // TODO(isherman): rewrite as WebUI test?
427 IN_PROC_BROWSER_TEST_F(AutofillTest, Invalid) { 424 IN_PROC_BROWSER_TEST_F(AutofillTest, Invalid) {
428 // First try profiles with invalid ZIP input. 425 // First try profiles with invalid ZIP input.
429 AutofillProfile without_invalid; 426 AutofillProfile without_invalid;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 IN_PROC_BROWSER_TEST_F(AutofillTest, 804 IN_PROC_BROWSER_TEST_F(AutofillTest,
808 DISABLED_MergeAggregatedDuplicatedProfiles) { 805 DISABLED_MergeAggregatedDuplicatedProfiles) {
809 int num_of_profiles = 806 int num_of_profiles =
810 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt"); 807 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt");
811 808
812 ASSERT_GT(num_of_profiles, 809 ASSERT_GT(num_of_profiles,
813 static_cast<int>(personal_data_manager()->GetProfiles().size())); 810 static_cast<int>(personal_data_manager()->GetProfiles().size()));
814 } 811 }
815 812
816 } // namespace autofill 813 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/android/preferences/website_preference_bridge.cc ('k') | chrome/browser/browsing_data/browsing_data_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698