summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-03 21:21:53 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-03 21:21:53 +0000
commitd0e2995ccee3e321647a1d743f18b873e08a737f (patch)
tree92f57d9b65b5668bcd617f93416c1d16d3a8823d
parent6e60cd796b714c9fc943c0f9dc5faf9dea9e8422 (diff)
downloadchromium_src-d0e2995ccee3e321647a1d743f18b873e08a737f.zip
chromium_src-d0e2995ccee3e321647a1d743f18b873e08a737f.tar.gz
chromium_src-d0e2995ccee3e321647a1d743f18b873e08a737f.tar.bz2
contacts: Add ContactStoreFactory and FakeContactStore.
This adds a factory interface for ContactStores and a fake, in-memory implementation of ContactStore. Both will be needed for testing the upcoming ContactManager class. I'm also fixing a bug in GoogleContactStore (all contacts were being passed to ContactDatabase in partial updates instead of just the updated ones) and another bug in FakeContactDatabase::SaveContacts() that was hidden by the GoogleContactStore bug. BUG=128805 TEST=none TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10850033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149924 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/contacts/contact_store.h25
-rw-r--r--chrome/browser/chromeos/contacts/fake_contact_database.cc29
-rw-r--r--chrome/browser/chromeos/contacts/fake_contact_database.h10
-rw-r--r--chrome/browser/chromeos/contacts/fake_contact_store.cc112
-rw-r--r--chrome/browser/chromeos/contacts/fake_contact_store.h103
-rw-r--r--chrome/browser/chromeos/contacts/google_contact_store.cc45
-rw-r--r--chrome/browser/chromeos/contacts/google_contact_store.h17
-rw-r--r--chrome/browser/chromeos/contacts/google_contact_store_unittest.cc40
-rw-r--r--chrome/chrome_tests.gypi2
9 files changed, 352 insertions, 31 deletions
diff --git a/chrome/browser/chromeos/contacts/contact_store.h b/chrome/browser/chromeos/contacts/contact_store.h
index 4ac8909..d0277ec 100644
--- a/chrome/browser/chromeos/contacts/contact_store.h
+++ b/chrome/browser/chromeos/contacts/contact_store.h
@@ -10,6 +10,8 @@
#include "base/basictypes.h"
+class Profile;
+
namespace contacts {
class Contact;
@@ -22,6 +24,9 @@ class ContactStore {
ContactStore() {}
virtual ~ContactStore() {}
+ // Initializes the object.
+ virtual void Init() = 0;
+
// Appends all (non-deleted) contacts to |contacts_out|.
virtual void AppendContacts(ContactPointers* contacts_out) = 0;
@@ -38,6 +43,26 @@ class ContactStore {
DISALLOW_COPY_AND_ASSIGN(ContactStore);
};
+// Interface for factories that return ContactStore objects of a given type.
+class ContactStoreFactory {
+ public:
+ ContactStoreFactory() {}
+ virtual ~ContactStoreFactory() {}
+
+ // Does |profile| support this type of ContactStore?
+ virtual bool CanCreateContactStoreForProfile(Profile* profile) = 0;
+
+ // Creates and returns a new, uninitialized ContactStore for |profile|.
+ // CanCreateContactStoreForProfile() should be called first.
+ // TODO(derat): Figure out how this should work if/when there are other
+ // ContactStore implementations that need additional information beyond the
+ // stuff contained in a Profile.
+ virtual ContactStore* CreateContactStore(Profile* profile) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ContactStoreFactory);
+};
+
} // namespace contacts
#endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_
diff --git a/chrome/browser/chromeos/contacts/fake_contact_database.cc b/chrome/browser/chromeos/contacts/fake_contact_database.cc
index 1dab542..a6e8b52 100644
--- a/chrome/browser/chromeos/contacts/fake_contact_database.cc
+++ b/chrome/browser/chromeos/contacts/fake_contact_database.cc
@@ -15,7 +15,8 @@ namespace contacts {
FakeContactDatabase::FakeContactDatabase()
: init_success_(true),
save_success_(true),
- load_success_(true) {
+ load_success_(true),
+ num_saved_contacts_(0) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
@@ -42,7 +43,11 @@ void FakeContactDatabase::SaveContacts(scoped_ptr<ContactPointers> contacts,
SaveCallback callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (save_success_) {
- test::CopyContacts(*contacts, &contacts_);
+ num_saved_contacts_ += contacts->size();
+ if (is_full_update)
+ test::CopyContacts(*contacts, &contacts_);
+ else
+ MergeContacts(*contacts);
metadata_ = *metadata;
}
callback.Run(save_success_);
@@ -62,4 +67,24 @@ void FakeContactDatabase::LoadContacts(LoadCallback callback) {
FakeContactDatabase::~FakeContactDatabase() {
}
+void FakeContactDatabase::MergeContacts(
+ const ContactPointers& updated_contacts) {
+ for (ContactPointers::const_iterator updated_it = updated_contacts.begin();
+ updated_it != updated_contacts.end(); ++updated_it) {
+ const Contact& updated_contact = **updated_it;
+ bool found = false;
+ for (ScopedVector<Contact>::const_iterator existing_it = contacts_.begin();
+ existing_it != contacts_.end(); ++existing_it) {
+ Contact* existing_contact = *existing_it;
+ if (existing_contact->provider_id() == updated_contact.provider_id()) {
+ *existing_contact = updated_contact;
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ contacts_.push_back(new Contact(updated_contact));
+ }
+}
+
} // namespace contacts
diff --git a/chrome/browser/chromeos/contacts/fake_contact_database.h b/chrome/browser/chromeos/contacts/fake_contact_database.h
index bc2256c..952a833 100644
--- a/chrome/browser/chromeos/contacts/fake_contact_database.h
+++ b/chrome/browser/chromeos/contacts/fake_contact_database.h
@@ -22,6 +22,9 @@ class FakeContactDatabase : public ContactDatabaseInterface {
void set_save_success(bool success) { save_success_ = success; }
void set_load_success(bool success) { load_success_ = success; }
+ int num_saved_contacts() const { return num_saved_contacts_; }
+ void reset_stats() { num_saved_contacts_ = 0; }
+
// Copies |contacts| into |contacts_| and |metadata| into |metadata_|. These
// values will be returned by subsequent calls to LoadContacts().
void SetContacts(const ContactPointers& contacts,
@@ -41,11 +44,18 @@ class FakeContactDatabase : public ContactDatabaseInterface {
virtual ~FakeContactDatabase();
private:
+ // Merges |updated_contacts| into |contacts_|.
+ void MergeContacts(const ContactPointers& updated_contacts);
+
// Should we report success in response to various requests?
bool init_success_;
bool save_success_;
bool load_success_;
+ // Total number of contacts that have been passed to SaveContacts() while
+ // |save_success_| is true.
+ int num_saved_contacts_;
+
// Currently-stored contacts and metadata.
ScopedVector<Contact> contacts_;
UpdateMetadata metadata_;
diff --git a/chrome/browser/chromeos/contacts/fake_contact_store.cc b/chrome/browser/chromeos/contacts/fake_contact_store.cc
new file mode 100644
index 0000000..f61f6bd
--- /dev/null
+++ b/chrome/browser/chromeos/contacts/fake_contact_store.cc
@@ -0,0 +1,112 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/contacts/fake_contact_store.h"
+
+#include <utility>
+
+#include "chrome/browser/chromeos/contacts/contact.pb.h"
+#include "chrome/browser/chromeos/contacts/contact_store_observer.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+namespace contacts {
+
+FakeContactStore::FakeContactStore(FakeContactStoreFactory* factory)
+ : factory_(factory),
+ contacts_deleter_(&contacts_) {
+}
+
+FakeContactStore::~FakeContactStore() {
+ factory_->RemoveStore(this);
+}
+
+void FakeContactStore::SetContacts(const ContactPointers& contacts) {
+ STLDeleteValues(&contacts_);
+ contacts_.clear();
+ for (ContactPointers::const_iterator it = contacts.begin();
+ it != contacts.end(); ++it) {
+ contacts_[(*it)->provider_id()] = new Contact(**it);
+ }
+}
+
+void FakeContactStore::NotifyObserversAboutContactsUpdate() {
+ FOR_EACH_OBSERVER(ContactStoreObserver,
+ observers_,
+ OnContactsUpdated(this));
+}
+
+void FakeContactStore::Init() {
+}
+
+void FakeContactStore::AppendContacts(ContactPointers* contacts_out) {
+ CHECK(contacts_out);
+ for (ContactMap::const_iterator it = contacts_.begin();
+ it != contacts_.end(); ++it) {
+ if (!it->second->deleted())
+ contacts_out->push_back(it->second);
+ }
+}
+
+const Contact* FakeContactStore::GetContactByProviderId(
+ const std::string& provider_id) {
+ ContactMap::const_iterator it = contacts_.find(provider_id);
+ return (it != contacts_.end() && !it->second->deleted()) ? it->second : NULL;
+}
+
+void FakeContactStore::AddObserver(ContactStoreObserver* observer) {
+ CHECK(observer);
+ observers_.AddObserver(observer);
+}
+
+void FakeContactStore::RemoveObserver(ContactStoreObserver* observer) {
+ CHECK(observer);
+ observers_.RemoveObserver(observer);
+}
+
+FakeContactStoreFactory::FakeContactStoreFactory()
+ : permit_store_creation_(true) {
+}
+
+FakeContactStoreFactory::~FakeContactStoreFactory() {
+ CHECK(stores_.empty());
+}
+
+FakeContactStore* FakeContactStoreFactory::GetContactStoreForProfile(
+ Profile* profile) {
+ CHECK(profile);
+ return stores_[profile];
+}
+
+void FakeContactStoreFactory::RemoveStore(FakeContactStore* store) {
+ CHECK(store);
+ for (ProfileStoreMap::iterator it = stores_.begin();
+ it != stores_.end(); ++it) {
+ if (it->second == store) {
+ stores_.erase(it);
+ return;
+ }
+ }
+ NOTREACHED() << "No record of destroyed FakeContactStore " << store;
+}
+
+bool FakeContactStoreFactory::CanCreateContactStoreForProfile(
+ Profile* profile) {
+ CHECK(profile);
+ return permit_store_creation_;
+}
+
+ContactStore* FakeContactStoreFactory::CreateContactStore(Profile* profile) {
+ CHECK(profile);
+ CHECK(CanCreateContactStoreForProfile(profile));
+ FakeContactStore* store = new FakeContactStore(this);
+ CHECK(stores_.insert(std::make_pair(profile, store)).second)
+ << "Got request to create second FakeContactStore for profile "
+ << profile << " (" << profile->GetProfileName() << ")";
+ return store;
+}
+
+} // namespace contacts
diff --git a/chrome/browser/chromeos/contacts/fake_contact_store.h b/chrome/browser/chromeos/contacts/fake_contact_store.h
new file mode 100644
index 0000000..9c9fdb8
--- /dev/null
+++ b/chrome/browser/chromeos/contacts/fake_contact_store.h
@@ -0,0 +1,103 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_
+#define CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_
+
+#include "chrome/browser/chromeos/contacts/contact_store.h"
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/observer_list.h"
+#include "base/stl_util.h"
+
+class Profile;
+
+namespace contacts {
+
+class Contact;
+class FakeContactStoreFactory;
+typedef std::vector<const Contact*> ContactPointers;
+
+// A "fake" in-memory implementation of ContactStore used for testing.
+class FakeContactStore : public ContactStore {
+ public:
+ explicit FakeContactStore(FakeContactStoreFactory* factory);
+ virtual ~FakeContactStore();
+
+ // Makes an internal copy of |contacts| so they can be returned by
+ // AppendContacts() and GetContactByProviderId().
+ void SetContacts(const ContactPointers& contacts);
+
+ // Invokes observers' OnContactsUpdated() methods.
+ void NotifyObserversAboutContactsUpdate();
+
+ // ContactStore implementation:
+ virtual void Init() OVERRIDE;
+ virtual void AppendContacts(ContactPointers* contacts_out) OVERRIDE;
+ virtual const Contact* GetContactByProviderId(
+ const std::string& provider_id) OVERRIDE;
+ virtual void AddObserver(ContactStoreObserver* observer) OVERRIDE;
+ virtual void RemoveObserver(ContactStoreObserver* observer) OVERRIDE;
+
+ private:
+ // Map from a contact's provider ID to the contact itself.
+ typedef std::map<std::string, Contact*> ContactMap;
+
+ // Factory that created this store. Not owned.
+ FakeContactStoreFactory* factory_;
+
+ ObserverList<ContactStoreObserver> observers_;
+
+ // Owns the pointed-to Contact values.
+ ContactMap contacts_;
+
+ // Deletes values in |contacts_|.
+ STLValueDeleter<ContactMap> contacts_deleter_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeContactStore);
+};
+
+// ContactStoreFactory implementation that returns FakeContactStores.
+class FakeContactStoreFactory : public ContactStoreFactory {
+ public:
+ FakeContactStoreFactory();
+ virtual ~FakeContactStoreFactory();
+
+ void set_permit_store_creation(bool permit) {
+ permit_store_creation_ = permit;
+ }
+
+ // Returns the FakeContactStore previously created for |profile|.
+ FakeContactStore* GetContactStoreForProfile(Profile* profile);
+
+ // Removes |store| from |stores_| after being called by a FakeContactStore's
+ // d'tor.
+ void RemoveStore(FakeContactStore* store);
+
+ // ContactStoreFactory implementation:
+ virtual bool CanCreateContactStoreForProfile(Profile* profile) OVERRIDE;
+ virtual ContactStore* CreateContactStore(Profile* profile) OVERRIDE;
+
+ private:
+ typedef std::map<Profile*, FakeContactStore*> ProfileStoreMap;
+
+ // Live FakeContactStore objects that we've handed out. We don't retain
+ // ownership of these, but we hang on to the pointers so that tests can
+ // manipulate the stores while they're in use.
+ ProfileStoreMap stores_;
+
+ // Should CanCreateContactStoreForProfile() return true?
+ bool permit_store_creation_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeContactStoreFactory);
+};
+
+} // namespace contacts
+
+#endif // CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_
diff --git a/chrome/browser/chromeos/contacts/google_contact_store.cc b/chrome/browser/chromeos/contacts/google_contact_store.cc
index e1a9981..b809618 100644
--- a/chrome/browser/chromeos/contacts/google_contact_store.cc
+++ b/chrome/browser/chromeos/contacts/google_contact_store.cc
@@ -85,7 +85,8 @@ GoogleContactStore::GoogleContactStore(Profile* profile)
}
GoogleContactStore::~GoogleContactStore() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ // This should also be running on the UI thread but we can't check it; the
+ // message loop is typically already getting torn down at this point.
weak_ptr_factory_.InvalidateWeakPtrs();
DestroyDatabase();
}
@@ -261,27 +262,32 @@ void GoogleContactStore::OnDownloadSuccess(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
VLOG(1) << "Got " << updated_contacts->size() << " contact(s) for "
<< profile_->GetProfileName();
- size_t num_updated_contacts = updated_contacts->size();
+
+ // Copy the pointers so we can update just these contacts in the database.
+ scoped_ptr<ContactPointers> contacts_to_save_to_db(new ContactPointers);
+ if (db_) {
+ for (size_t i = 0; i < updated_contacts->size(); ++i)
+ contacts_to_save_to_db->push_back((*updated_contacts)[i]);
+ }
+ bool got_updates = !updated_contacts->empty();
+
MergeContacts(is_full_update, updated_contacts.Pass());
last_successful_update_start_time_ = update_start_time;
- if (is_full_update || num_updated_contacts > 0) {
+ if (is_full_update || got_updates > 0) {
FOR_EACH_OBSERVER(ContactStoreObserver,
observers_,
OnContactsUpdated(this));
}
if (db_) {
- scoped_ptr<ContactPointers> contacts_to_save(new ContactPointers);
- for (ContactMap::const_iterator it = contacts_.begin();
- it != contacts_.end(); ++it) {
- contacts_to_save->push_back(it->second);
- }
+ VLOG(1) << "Saving " << contacts_to_save_to_db->size() << " contact(s) to "
+ << "database as " << (is_full_update ? "full" : "partial")
+ << " update";
scoped_ptr<UpdateMetadata> metadata(new UpdateMetadata);
metadata->set_last_update_start_time(update_start_time.ToInternalValue());
-
db_->SaveContacts(
- contacts_to_save.Pass(),
+ contacts_to_save_to_db.Pass(),
metadata.Pass(),
is_full_update,
base::Bind(&GoogleContactStore::OnDatabaseContactsSaved,
@@ -350,4 +356,23 @@ void GoogleContactStore::OnDatabaseContactsSaved(bool success) {
ScheduleUpdate(true);
}
+GoogleContactStoreFactory::GoogleContactStoreFactory() {
+}
+
+GoogleContactStoreFactory::~GoogleContactStoreFactory() {
+}
+
+bool GoogleContactStoreFactory::CanCreateContactStoreForProfile(
+ Profile* profile) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(profile);
+ return gdata::util::IsGDataAvailable(profile);
+}
+
+ContactStore* GoogleContactStoreFactory::CreateContactStore(Profile* profile) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(CanCreateContactStoreForProfile(profile));
+ return new GoogleContactStore(profile);
+}
+
} // namespace contacts
diff --git a/chrome/browser/chromeos/contacts/google_contact_store.h b/chrome/browser/chromeos/contacts/google_contact_store.h
index 9876e82..c51fca4 100644
--- a/chrome/browser/chromeos/contacts/google_contact_store.h
+++ b/chrome/browser/chromeos/contacts/google_contact_store.h
@@ -65,9 +65,8 @@ class GoogleContactStore : public ContactStore {
explicit GoogleContactStore(Profile* profile);
virtual ~GoogleContactStore();
- void Init();
-
// ContactStore implementation:
+ virtual void Init() OVERRIDE;
virtual void AppendContacts(ContactPointers* contacts_out) OVERRIDE;
virtual const Contact* GetContactByProviderId(
const std::string& provider_id) OVERRIDE;
@@ -162,6 +161,20 @@ class GoogleContactStore : public ContactStore {
DISALLOW_COPY_AND_ASSIGN(GoogleContactStore);
};
+// ContactStoreFactory implementation that returns GoogleContactStores.
+class GoogleContactStoreFactory : public ContactStoreFactory {
+ public:
+ GoogleContactStoreFactory();
+ virtual ~GoogleContactStoreFactory();
+
+ // ContactStoreFactory implementation:
+ virtual bool CanCreateContactStoreForProfile(Profile* profile) OVERRIDE;
+ virtual ContactStore* CreateContactStore(Profile* profile) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GoogleContactStoreFactory);
+};
+
} // namespace contacts
#endif // CHROME_BROWSER_CHROMEOS_CONTACTS_GOOGLE_CONTACT_STORE_H_
diff --git a/chrome/browser/chromeos/contacts/google_contact_store_unittest.cc b/chrome/browser/chromeos/contacts/google_contact_store_unittest.cc
index 17bc6b8..eae94fd 100644
--- a/chrome/browser/chromeos/contacts/google_contact_store_unittest.cc
+++ b/chrome/browser/chromeos/contacts/google_contact_store_unittest.cc
@@ -184,6 +184,7 @@ TEST_F(GoogleContactStoreTest, UpdateFromGData) {
EXPECT_EQ(VarContactsToString(
3, contact1.get(), contact2.get(), contact3.get()),
ContactsToString(db_->contacts()));
+ EXPECT_EQ(3, db_->num_saved_contacts());
EXPECT_TRUE(test_api_->update_scheduled());
}
@@ -195,21 +196,23 @@ TEST_F(GoogleContactStoreTest, FetchUpdatedContacts) {
scoped_ptr<Contact> contact3(new Contact);
InitContact("provider3", "3", false, contact3.get());
+ ContactPointers kAllContacts;
+ kAllContacts.push_back(contact1.get());
+ kAllContacts.push_back(contact2.get());
+ kAllContacts.push_back(contact3.get());
+
// Tell the GData service to return all three contacts in response to a full
// update.
- ContactPointers gdata_contacts;
- gdata_contacts.push_back(contact1.get());
- gdata_contacts.push_back(contact2.get());
- gdata_contacts.push_back(contact3.get());
+ ContactPointers gdata_contacts(kAllContacts);
gdata_service_->SetContacts(gdata_contacts, base::Time());
+ // All the contacts should be loaded and saved to the database.
store_->Init();
ContactPointers loaded_contacts;
store_->AppendContacts(&loaded_contacts);
- EXPECT_EQ(ContactsToString(gdata_contacts),
- ContactsToString(loaded_contacts));
- EXPECT_EQ(ContactsToString(gdata_contacts),
- ContactsToString(db_->contacts()));
+ EXPECT_EQ(ContactsToString(kAllContacts), ContactsToString(loaded_contacts));
+ EXPECT_EQ(ContactsToString(kAllContacts), ContactsToString(db_->contacts()));
+ EXPECT_EQ(static_cast<int>(kAllContacts.size()), db_->num_saved_contacts());
EXPECT_TRUE(test_api_->update_scheduled());
EXPECT_EQ(1, observer_.num_updates());
observer_.reset_stats();
@@ -221,19 +224,21 @@ TEST_F(GoogleContactStoreTest, FetchUpdatedContacts) {
contact3->set_update_time(
(old_contact3_update_time +
base::TimeDelta::FromSeconds(10)).ToInternalValue());
+ gdata_contacts.clear();
+ gdata_contacts.push_back(contact3.get());
gdata_service_->SetContacts(
gdata_contacts,
old_contact3_update_time + base::TimeDelta::FromMilliseconds(1));
// Check that the updated contact is loaded (i.e. the store passed the
- // correct minimum update time to the service).
+ // correct minimum update time to the service) and saved back to the database.
+ db_->reset_stats();
test_api_->DoUpdate();
loaded_contacts.clear();
store_->AppendContacts(&loaded_contacts);
- EXPECT_EQ(ContactsToString(gdata_contacts),
- ContactsToString(loaded_contacts));
- EXPECT_EQ(ContactsToString(gdata_contacts),
- ContactsToString(db_->contacts()));
+ EXPECT_EQ(ContactsToString(kAllContacts), ContactsToString(loaded_contacts));
+ EXPECT_EQ(ContactsToString(kAllContacts), ContactsToString(db_->contacts()));
+ EXPECT_EQ(1, db_->num_saved_contacts());
EXPECT_TRUE(test_api_->update_scheduled());
EXPECT_EQ(1, observer_.num_updates());
observer_.reset_stats();
@@ -244,13 +249,14 @@ TEST_F(GoogleContactStoreTest, FetchUpdatedContacts) {
gdata_contacts,
base::Time::FromInternalValue(contact3->update_time()) +
base::TimeDelta::FromMilliseconds(1));
+
+ db_->reset_stats();
test_api_->DoUpdate();
loaded_contacts.clear();
store_->AppendContacts(&loaded_contacts);
- EXPECT_EQ(ContactsToString(gdata_contacts),
- ContactsToString(loaded_contacts));
- EXPECT_EQ(ContactsToString(gdata_contacts),
- ContactsToString(db_->contacts()));
+ EXPECT_EQ(ContactsToString(kAllContacts), ContactsToString(loaded_contacts));
+ EXPECT_EQ(ContactsToString(kAllContacts), ContactsToString(db_->contacts()));
+ EXPECT_EQ(1, db_->num_saved_contacts());
EXPECT_TRUE(test_api_->update_scheduled());
EXPECT_EQ(1, observer_.num_updates());
}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 0d6636c..2f282c0 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1086,6 +1086,8 @@
'browser/chromeos/contacts/contact_test_util.h',
'browser/chromeos/contacts/fake_contact_database.cc',
'browser/chromeos/contacts/fake_contact_database.h',
+ 'browser/chromeos/contacts/fake_contact_store.cc',
+ 'browser/chromeos/contacts/fake_contact_store.h',
'browser/chromeos/contacts/google_contact_store_unittest.cc',
'browser/chromeos/cros/cros_network_functions_unittest.cc',
'browser/chromeos/cros/network_constants.h',