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

Unified Diff: chrome/browser/sync/profile_sync_service_preference_unittest.cc

Issue 10804039: Make SyncBackendRegistrar aware of loaded data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
Index: chrome/browser/sync/profile_sync_service_preference_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
index 1de3d45ff881437d96af200b1aa00417ac2acf2d..3dcb1d35564e96b04dc34f4461e3ebf48da80127 100644
--- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
@@ -60,8 +60,9 @@ ACTION_P(CreateAndSaveChangeProcessor, change_processor) {
class ProfileSyncServicePreferenceTest
: public AbstractProfileSyncServiceTest {
public:
- int64 SetSyncedValue(const std::string& name, const Value& value) {
- syncer::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
+ int64 SetSyncedValue(const std::string& name, const Value& value,
+ syncer::UserShare* user_share) {
+ syncer::WriteTransaction trans(FROM_HERE, user_share);
syncer::ReadNode root(&trans);
if (root.InitByTagLookup(syncer::ModelTypeToRootTag(
syncer::PREFERENCES)) != syncer::BaseNode::INIT_OK) {
@@ -110,8 +111,9 @@ class ProfileSyncServicePreferenceTest
AbstractProfileSyncServiceTest::TearDown();
}
- bool StartSyncService(const base::Closure& callback,
- bool will_fail_association) {
+ bool StartSyncService(
+ const base::Callback<void(syncer::UserShare*)>& callback,
+ bool will_fail_association) {
if (service_.get())
return false;
@@ -224,24 +226,32 @@ class AddPreferenceEntriesHelper {
success_(false) {
}
- const base::Closure& callback() const { return callback_; }
- bool success() { return success_; }
+ const base::Callback<void(syncer::UserShare*)>& callback() const {
+ return callback_;
+ }
+
+ bool success() {
+ return success_;
+ }
private:
void AddPreferenceEntriesCallback(ProfileSyncServicePreferenceTest* test,
- const PreferenceValues& entries) {
- if (!test->CreateRoot(syncer::PREFERENCES))
+ const PreferenceValues& entries,
+ syncer::UserShare* user_share) {
+ if (!test->CreateRoot(syncer::PREFERENCES, user_share))
return;
for (PreferenceValues::const_iterator i = entries.begin();
i != entries.end(); ++i) {
- if (test->SetSyncedValue(i->first, *i->second) == syncer::kInvalidId)
+ if (test->SetSyncedValue(i->first, *i->second, user_share)
+ == syncer::kInvalidId) {
return;
+ }
}
success_ = true;
}
- base::Closure callback_;
+ base::Callback<void(syncer::UserShare*)> callback_;
bool success_;
};
@@ -350,7 +360,7 @@ TEST_F(ProfileSyncServicePreferenceTest, ModelAssociationCloudHasData) {
}
TEST_F(ProfileSyncServicePreferenceTest, FailModelAssociation) {
- ASSERT_TRUE(StartSyncService(base::Closure(), true));
+ ASSERT_TRUE(StartSyncService(TestProfileSyncService::NullCallback(), true));
EXPECT_TRUE(service_->HasUnrecoverableError());
}
@@ -392,7 +402,8 @@ TEST_F(ProfileSyncServicePreferenceTest, UpdatedSyncNodeActionUpdate) {
ASSERT_TRUE(create_root.success());
scoped_ptr<Value> expected(Value::CreateStringValue(example_url1_));
- int64 node_id = SetSyncedValue(prefs::kHomePage, *expected);
+ int64 node_id = SetSyncedValue(prefs::kHomePage, *expected,
+ service_->GetUserShare());
ASSERT_NE(node_id, syncer::kInvalidId);
{
syncer::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
@@ -413,7 +424,8 @@ TEST_F(ProfileSyncServicePreferenceTest, UpdatedSyncNodeActionAdd) {
ASSERT_TRUE(create_root.success());
scoped_ptr<Value> expected(Value::CreateStringValue(example_url0_));
- int64 node_id = SetSyncedValue(prefs::kHomePage, *expected);
+ int64 node_id = SetSyncedValue(prefs::kHomePage, *expected,
+ service_->GetUserShare());
ASSERT_NE(node_id, syncer::kInvalidId);
{
syncer::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
@@ -436,7 +448,8 @@ TEST_F(ProfileSyncServicePreferenceTest, UpdatedSyncNodeUnknownPreference) {
ASSERT_TRUE(create_root.success());
scoped_ptr<Value> expected(Value::CreateStringValue(example_url0_));
- int64 node_id = SetSyncedValue("unknown preference", *expected);
+ int64 node_id = SetSyncedValue("unknown preference", *expected,
+ service_->GetUserShare());
ASSERT_NE(node_id, syncer::kInvalidId);
{
syncer::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
@@ -471,7 +484,8 @@ TEST_F(ProfileSyncServicePreferenceTest, ManagedPreferences) {
// value.
scoped_ptr<Value> sync_value(
Value::CreateStringValue("http://crbug.com"));
- int64 node_id = SetSyncedValue(prefs::kHomePage, *sync_value);
+ int64 node_id = SetSyncedValue(prefs::kHomePage, *sync_value,
+ service_->GetUserShare());
ASSERT_NE(node_id, syncer::kInvalidId);
{
syncer::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
@@ -534,7 +548,8 @@ TEST_F(ProfileSyncServicePreferenceTest,
// Change the sync value.
scoped_ptr<Value> sync_value(
Value::CreateStringValue("http://example.com/sync"));
- int64 node_id = SetSyncedValue(prefs::kHomePage, *sync_value);
+ int64 node_id = SetSyncedValue(prefs::kHomePage, *sync_value,
+ service_->GetUserShare());
ASSERT_NE(node_id, syncer::kInvalidId);
{
syncer::WriteTransaction trans(FROM_HERE, service_->GetUserShare());

Powered by Google App Engine
This is Rietveld 408576698