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

Side by Side Diff: chrome/browser/chromeos/contacts/contact_manager_unittest.cc

Issue 10827406: contacts: Rename provider_id to contact_id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 4 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) 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 "chrome/browser/chromeos/contacts/contact_manager.h" 5 #include "chrome/browser/chromeos/contacts/contact_manager.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/test/base/testing_browser_process.h" 9 #include "chrome/test/base/testing_browser_process.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 store->NotifyObserversAboutContactsUpdate(); 109 store->NotifyObserversAboutContactsUpdate();
110 EXPECT_EQ(2, observer.num_updates()); 110 EXPECT_EQ(2, observer.num_updates());
111 111
112 profile_manager_->DeleteTestingProfile(kProfileName); 112 profile_manager_->DeleteTestingProfile(kProfileName);
113 EXPECT_EQ(2, observer.num_updates()); 113 EXPECT_EQ(2, observer.num_updates());
114 } 114 }
115 115
116 TEST_F(ContactManagerTest, GetContacts) { 116 TEST_F(ContactManagerTest, GetContacts) {
117 // Create two contacts and tell the store to return them. 117 // Create two contacts and tell the store to return them.
118 const std::string kProviderId1 = "1"; 118 const std::string kContactId1 = "1";
119 scoped_ptr<Contact> contact1(new Contact); 119 scoped_ptr<Contact> contact1(new Contact);
120 InitContact(kProviderId1, "1", false, contact1.get()); 120 InitContact(kContactId1, "1", false, contact1.get());
121 121
122 const std::string kProviderId2 = "2"; 122 const std::string kContactId2 = "2";
123 scoped_ptr<Contact> contact2(new Contact); 123 scoped_ptr<Contact> contact2(new Contact);
124 InitContact(kProviderId2, "2", false, contact2.get()); 124 InitContact(kContactId2, "2", false, contact2.get());
125 125
126 const std::string kProfileName = "test_profile"; 126 const std::string kProfileName = "test_profile";
127 TestingProfile* profile = 127 TestingProfile* profile =
128 profile_manager_->CreateTestingProfile(kProfileName); 128 profile_manager_->CreateTestingProfile(kProfileName);
129 FakeContactStore* store = store_factory_->GetContactStoreForProfile(profile); 129 FakeContactStore* store = store_factory_->GetContactStoreForProfile(profile);
130 ASSERT_TRUE(store); 130 ASSERT_TRUE(store);
131 131
132 ContactPointers store_contacts; 132 ContactPointers store_contacts;
133 store_contacts.push_back(contact1.get()); 133 store_contacts.push_back(contact1.get());
134 store_contacts.push_back(contact2.get()); 134 store_contacts.push_back(contact2.get());
135 store->SetContacts(store_contacts); 135 store->SetContacts(store_contacts);
136 store->NotifyObserversAboutContactsUpdate(); 136 store->NotifyObserversAboutContactsUpdate();
137 137
138 // Check that GetAllContacts() returns both contacts. 138 // Check that GetAllContacts() returns both contacts.
139 scoped_ptr<ContactPointers> loaded_contacts = 139 scoped_ptr<ContactPointers> loaded_contacts =
140 contact_manager_->GetAllContacts(profile); 140 contact_manager_->GetAllContacts(profile);
141 EXPECT_EQ(ContactsToString(store_contacts), 141 EXPECT_EQ(ContactsToString(store_contacts),
142 ContactsToString(*loaded_contacts)); 142 ContactsToString(*loaded_contacts));
143 143
144 // Check that we can get individual contacts using GetContactByProviderId(). 144 // Check that we can get individual contacts using GetContactById().
145 const Contact* loaded_contact = 145 const Contact* loaded_contact = contact_manager_->GetContactById(profile,
146 contact_manager_->GetContactByProviderId(profile, kProviderId1); 146 kContactId1);
147 ASSERT_TRUE(loaded_contact); 147 ASSERT_TRUE(loaded_contact);
148 EXPECT_EQ(ContactToString(*contact1), ContactToString(*loaded_contact)); 148 EXPECT_EQ(ContactToString(*contact1), ContactToString(*loaded_contact));
149 149
150 loaded_contact = 150 loaded_contact = contact_manager_->GetContactById(profile, kContactId2);
151 contact_manager_->GetContactByProviderId(profile, kProviderId2);
152 ASSERT_TRUE(loaded_contact); 151 ASSERT_TRUE(loaded_contact);
153 EXPECT_EQ(ContactToString(*contact2), ContactToString(*loaded_contact)); 152 EXPECT_EQ(ContactToString(*contact2), ContactToString(*loaded_contact));
154 153
155 // We should get NULL if we pass a nonexistent provider ID. 154 // We should get NULL if we pass a nonexistent contact ID.
156 EXPECT_FALSE(contact_manager_->GetContactByProviderId(profile, "foo")); 155 EXPECT_FALSE(contact_manager_->GetContactById(profile, "foo"));
157 156
158 profile_manager_->DeleteTestingProfile(kProfileName); 157 profile_manager_->DeleteTestingProfile(kProfileName);
159 } 158 }
160 159
161 TEST_F(ContactManagerTest, ProfileUnsupportedByContactStore) { 160 TEST_F(ContactManagerTest, ProfileUnsupportedByContactStore) {
162 // ContactManager shouldn't try to create a ContactStore for an unsuppported 161 // ContactManager shouldn't try to create a ContactStore for an unsuppported
163 // Profile. 162 // Profile.
164 store_factory_->set_permit_store_creation(false); 163 store_factory_->set_permit_store_creation(false);
165 const std::string kProfileName = "test_profile"; 164 const std::string kProfileName = "test_profile";
166 TestingProfile* profile = 165 TestingProfile* profile =
167 profile_manager_->CreateTestingProfile(kProfileName); 166 profile_manager_->CreateTestingProfile(kProfileName);
168 EXPECT_FALSE(store_factory_->GetContactStoreForProfile(profile)); 167 EXPECT_FALSE(store_factory_->GetContactStoreForProfile(profile));
169 profile_manager_->DeleteTestingProfile(kProfileName); 168 profile_manager_->DeleteTestingProfile(kProfileName);
170 } 169 }
171 170
172 } // namespace test 171 } // namespace test
173 } // namespace contacts 172 } // namespace contacts
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_manager.cc ('k') | chrome/browser/chromeos/contacts/contact_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698