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

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

Issue 2521001: AutoFill: Make PersonalDataManager RefCountedThreadSafe. (Closed)
Patch Set: Fix lints. Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
8 #include "base/scoped_vector.h" 9 #include "base/scoped_vector.h"
9 #include "base/string16.h" 10 #include "base/string16.h"
10 #include "base/tuple.h" 11 #include "base/tuple.h"
11 #include "chrome/browser/autofill/autofill_common_unittest.h" 12 #include "chrome/browser/autofill/autofill_common_unittest.h"
12 #include "chrome/browser/autofill/autofill_manager.h" 13 #include "chrome/browser/autofill/autofill_manager.h"
13 #include "chrome/browser/autofill/autofill_profile.h" 14 #include "chrome/browser/autofill/autofill_profile.h"
14 #include "chrome/browser/autofill/credit_card.h" 15 #include "chrome/browser/autofill/credit_card.h"
15 #include "chrome/browser/autofill/personal_data_manager.h" 16 #include "chrome/browser/autofill/personal_data_manager.h"
16 #include "chrome/browser/renderer_host/test/test_render_view_host.h" 17 #include "chrome/browser/renderer_host/test/test_render_view_host.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 "", "", "", ""); 81 "", "", "", "");
81 credit_cards->push_back(credit_card); 82 credit_cards->push_back(credit_card);
82 } 83 }
83 84
84 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); 85 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager);
85 }; 86 };
86 87
87 class TestAutoFillManager : public AutoFillManager { 88 class TestAutoFillManager : public AutoFillManager {
88 public: 89 public:
89 explicit TestAutoFillManager(TabContents* tab_contents) 90 explicit TestAutoFillManager(TabContents* tab_contents)
90 : AutoFillManager(tab_contents, &test_personal_data_) { 91 : AutoFillManager(tab_contents, NULL) {
92 test_personal_data_ = new TestPersonalDataManager();
93 set_personal_data_manager(test_personal_data_.get());
91 } 94 }
92 95
93 virtual bool IsAutoFillEnabled() const { return true; } 96 virtual bool IsAutoFillEnabled() const { return true; }
94 97
95 AutoFillProfile* GetLabeledProfile(const char* label) { 98 AutoFillProfile* GetLabeledProfile(const char* label) {
96 return test_personal_data_.GetLabeledProfile(label); 99 return test_personal_data_->GetLabeledProfile(label);
97 } 100 }
98 101
99 private: 102 private:
100 TestPersonalDataManager test_personal_data_; 103 scoped_refptr<TestPersonalDataManager> test_personal_data_;
101 104
102 DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager); 105 DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager);
103 }; 106 };
104 107
105 void CreateTestFormField(const char* label, 108 void CreateTestFormField(const char* label,
106 const char* name, 109 const char* name,
107 const char* value, 110 const char* value,
108 const char* type, 111 const char* type,
109 webkit_glue::FormField* field) { 112 webkit_glue::FormField* field) {
110 *field = webkit_glue::FormField(ASCIIToUTF16(label), ASCIIToUTF16(name), 113 *field = webkit_glue::FormField(ASCIIToUTF16(label), ASCIIToUTF16(name),
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 CreateTestFormField("Last Name", "lastname", "Presley", "text", &field); 709 CreateTestFormField("Last Name", "lastname", "Presley", "text", &field);
707 EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2])); 710 EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
708 CreateTestFormField("Phone Number", "phonenumber", "", "text", &field); 711 CreateTestFormField("Phone Number", "phonenumber", "", "text", &field);
709 EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3])); 712 EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
710 CreateTestFormField( 713 CreateTestFormField(
711 "Email", "email", "theking@gmail.com", "text", &field); 714 "Email", "email", "theking@gmail.com", "text", &field);
712 EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4])); 715 EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4]));
713 } 716 }
714 717
715 } // namespace 718 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/personal_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698