OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/scoped_vector.h" | 9 #include "base/scoped_vector.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 | 665 |
666 // Test that we cull duplicate profile suggestions. | 666 // Test that we cull duplicate profile suggestions. |
667 TEST_F(AutofillManagerTest, GetProfileSuggestionsWithDuplicates) { | 667 TEST_F(AutofillManagerTest, GetProfileSuggestionsWithDuplicates) { |
668 // Set up our form data. | 668 // Set up our form data. |
669 FormData form; | 669 FormData form; |
670 CreateTestAddressFormData(&form); | 670 CreateTestAddressFormData(&form); |
671 std::vector<FormData> forms(1, form); | 671 std::vector<FormData> forms(1, form); |
672 FormsSeen(forms); | 672 FormsSeen(forms); |
673 | 673 |
674 // Add a duplicate profile. | 674 // Add a duplicate profile. |
675 AutoFillProfile* duplicate_profile = static_cast<AutoFillProfile*>( | 675 AutoFillProfile* duplicate_profile = |
676 autofill_manager_->GetProfileWithGUID( | 676 new AutoFillProfile( |
677 "00000000-0000-0000-0000-000000000001")->Clone()); | 677 *(autofill_manager_->GetProfileWithGUID( |
678 "00000000-0000-0000-0000-000000000001"))); | |
Ilya Sherman
2011/03/09 00:50:50
Won't this leak memory? Or did we have a double-f
dhollowa
2011/03/09 01:55:47
No, this AddProfile call takes ownership. It adds
| |
678 autofill_manager_->AddProfile(duplicate_profile); | 679 autofill_manager_->AddProfile(duplicate_profile); |
679 | 680 |
680 const FormField& field = form.fields[0]; | 681 const FormField& field = form.fields[0]; |
681 GetAutoFillSuggestions(form, field); | 682 GetAutoFillSuggestions(form, field); |
682 | 683 |
683 // No suggestions provided, so send an empty vector as the results. | 684 // No suggestions provided, so send an empty vector as the results. |
684 // This triggers the combined message send. | 685 // This triggers the combined message send. |
685 AutocompleteSuggestionsReturned(std::vector<string16>()); | 686 AutocompleteSuggestionsReturned(std::vector<string16>()); |
686 | 687 |
687 // Test that we sent the right message to the renderer. | 688 // Test that we sent the right message to the renderer. |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1746 #else | 1747 #else |
1747 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1748 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
1748 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1749 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
1749 profile()->GetPrefs()->SetBoolean( | 1750 profile()->GetPrefs()->SetBoolean( |
1750 prefs::kAutoFillAuxiliaryProfilesEnabled, true); | 1751 prefs::kAutoFillAuxiliaryProfilesEnabled, true); |
1751 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); | 1752 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); |
1752 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1753 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
1753 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1754 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
1754 #endif | 1755 #endif |
1755 } | 1756 } |
OLD | NEW |