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

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

Issue 7967024: Profile shouldn't own PersonalDataManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addresses isherman #11 Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 9 #include "base/message_loop.h"
11 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/autofill/autofill_common_test.h" 11 #include "chrome/browser/autofill/autofill_common_test.h"
13 #include "chrome/browser/autofill/autofill_profile.h" 12 #include "chrome/browser/autofill/autofill_profile.h"
14 #include "chrome/browser/autofill/form_structure.h" 13 #include "chrome/browser/autofill/form_structure.h"
15 #include "chrome/browser/autofill/personal_data_manager.h" 14 #include "chrome/browser/autofill/personal_data_manager.h"
16 #include "chrome/browser/autofill/personal_data_manager_observer.h" 15 #include "chrome/browser/autofill/personal_data_manager_observer.h"
17 #include "chrome/browser/password_manager/encryptor.h" 16 #include "chrome/browser/password_manager/encryptor.h"
18 #include "chrome/common/guid.h" 17 #include "chrome/common/guid.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 db_thread_.Start(); 53 db_thread_.Start();
55 54
56 profile_.reset(new TestingProfile); 55 profile_.reset(new TestingProfile);
57 profile_->CreateWebDataService(false); 56 profile_->CreateWebDataService(false);
58 57
59 autofill_test::DisableSystemServices(profile_.get()); 58 autofill_test::DisableSystemServices(profile_.get());
60 ResetPersonalDataManager(); 59 ResetPersonalDataManager();
61 } 60 }
62 61
63 virtual void TearDown() { 62 virtual void TearDown() {
64 personal_data_ = NULL; 63 // Destruction order is imposed explicitly here.
65 if (profile_.get()) 64 personal_data_.reset(NULL);
66 profile_.reset(NULL); 65 profile_.reset(NULL);
67 66
68 db_thread_.Stop(); 67 db_thread_.Stop();
69 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); 68 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask);
70 MessageLoop::current()->Run(); 69 MessageLoop::current()->Run();
71 } 70 }
72 71
73 void ResetPersonalDataManager() { 72 void ResetPersonalDataManager() {
74 personal_data_ = new PersonalDataManager(); 73 personal_data_.reset(new PersonalDataManager);
75 personal_data_->Init(profile_.get()); 74 personal_data_->Init(profile_.get());
76 personal_data_->SetObserver(&personal_data_observer_); 75 personal_data_->SetObserver(&personal_data_observer_);
77 76
78 // Verify that the web database has been updated and the notification sent. 77 // Verify that the web database has been updated and the notification sent.
79 EXPECT_CALL(personal_data_observer_, 78 EXPECT_CALL(personal_data_observer_,
80 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 79 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
81 MessageLoop::current()->Run(); 80 MessageLoop::current()->Run();
82 } 81 }
83 82
84 MessageLoopForUI message_loop_; 83 MessageLoopForUI message_loop_;
85 BrowserThread ui_thread_; 84 BrowserThread ui_thread_;
86 BrowserThread db_thread_; 85 BrowserThread db_thread_;
87 scoped_ptr<TestingProfile> profile_; 86 scoped_ptr<TestingProfile> profile_;
88 scoped_refptr<PersonalDataManager> personal_data_; 87 scoped_ptr<PersonalDataManager> personal_data_;
89 NotificationRegistrar registrar_; 88 NotificationRegistrar registrar_;
90 NotificationObserverMock observer_; 89 NotificationObserverMock observer_;
91 PersonalDataLoadedObserverMock personal_data_observer_; 90 PersonalDataLoadedObserverMock personal_data_observer_;
92 }; 91 };
93 92
94 TEST_F(PersonalDataManagerTest, AddProfile) { 93 TEST_F(PersonalDataManagerTest, AddProfile) {
95 AutofillProfile profile0; 94 AutofillProfile profile0;
96 autofill_test::SetProfileInfo(&profile0, 95 autofill_test::SetProfileInfo(&profile0,
97 "John", "Mitchell", "Smith", 96 "John", "Mitchell", "Smith",
98 "j@s.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA", 97 "j@s.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA",
(...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 1838
1840 // Modify expected to include multi-valued fields. 1839 // Modify expected to include multi-valued fields.
1841 std::vector<string16> values; 1840 std::vector<string16> values;
1842 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); 1841 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values);
1843 values.push_back(ASCIIToUTF16("214-555-1234")); 1842 values.push_back(ASCIIToUTF16("214-555-1234"));
1844 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); 1843 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values);
1845 1844
1846 ASSERT_EQ(1U, results2.size()); 1845 ASSERT_EQ(1U, results2.size());
1847 EXPECT_EQ(0, expected.CompareMulti(*results2[0])); 1846 EXPECT_EQ(0, expected.CompareMulti(*results2[0]));
1848 } 1847 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/personal_data_manager_factory.cc ('k') | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698