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

Unified Diff: components/syncable_prefs/pref_service_syncable_unittest.cc

Issue 2078893002: Add callback list to PrefModelAssociator after sync data is loaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@migrate_domain_scoped_settings
Patch Set: add a test for RegisterMergeDataFinishedCallback Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/syncable_prefs/pref_service_syncable.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/syncable_prefs/pref_service_syncable_unittest.cc
diff --git a/components/syncable_prefs/pref_service_syncable_unittest.cc b/components/syncable_prefs/pref_service_syncable_unittest.cc
index 5aaa09616db396c3a53545ddeb412651e6ea4e59..b888ef25e0e52e801f9efb93f8b8328525f69055 100644
--- a/components/syncable_prefs/pref_service_syncable_unittest.cc
+++ b/components/syncable_prefs/pref_service_syncable_unittest.cc
@@ -122,6 +122,7 @@ class PrefServiceSyncableTest : public testing::Test {
prefs_.GetSyncableService(syncer::PREFERENCES));
ASSERT_TRUE(pref_sync_service_);
next_pref_remote_sync_node_id_ = 0;
Bernhard Bauer 2016/07/13 08:31:52 This is not necessary, BTW (each test gets a new f
lshang 2016/07/14 01:29:03 Done.
+ callback_test_num = 0;
Bernhard Bauer 2016/07/13 08:31:52 I would initialize this in the constructor.
lshang 2016/07/14 01:29:04 Done. Also added an underscore at the end of this
}
syncer::SyncChange MakeRemoteChange(int64_t id,
@@ -204,6 +205,8 @@ class PrefServiceSyncableTest : public testing::Test {
return pref_sync_service_->IsPrefSynced(pref_name);
}
+ void CallbackFunc() { callback_test_num += 1; }
Bernhard Bauer 2016/07/13 08:31:52 Nit: you could use ++.
lshang 2016/07/14 01:29:03 Done.
+
PrefService* GetPrefs() { return &prefs_; }
TestingPrefServiceSyncable* GetTestingPrefService() { return &prefs_; }
@@ -218,6 +221,8 @@ class PrefServiceSyncableTest : public testing::Test {
base::MessageLoop loop_;
int next_pref_remote_sync_node_id_;
+
+ int callback_test_num;
Bernhard Bauer 2016/07/13 08:31:52 Nit: |num_callbacks|? Alternatively, you could us
lshang 2016/07/14 01:29:04 Done. The alternative is really cool!
};
TEST_F(PrefServiceSyncableTest, CreatePrefSyncData) {
@@ -555,6 +560,15 @@ TEST_F(PrefServiceSyncableTest, DeletePreference) {
EXPECT_TRUE(pref->IsDefaultValue());
}
+TEST_F(PrefServiceSyncableTest, RegisterMergeDataFinishedCallback) {
+ EXPECT_EQ(callback_test_num, 0);
Bernhard Bauer 2016/07/13 08:31:52 The expected value goes first, for nicer error mes
lshang 2016/07/14 01:29:03 Done.
+ prefs_.RegisterMergeDataFinishedCallback(base::Bind(
+ &PrefServiceSyncableTest::CallbackFunc, base::Unretained(this)));
+ EXPECT_EQ(callback_test_num, 0);
+ InitWithNoSyncData();
+ EXPECT_EQ(callback_test_num, 1);
+}
+
} // namespace
} // namespace syncable_prefs
« no previous file with comments | « components/syncable_prefs/pref_service_syncable.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698