diff options
author | Kristian Monsen <kristianm@google.com> | 2011-06-28 21:49:31 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-07-08 17:55:00 +0100 |
commit | ddb351dbec246cf1fab5ec20d2d5520909041de1 (patch) | |
tree | 158e3fb57bdcac07c7f1e767fde3c70687c9fbb1 /chrome/browser/sync/profile_sync_service_preference_unittest.cc | |
parent | 6b92e04f5f151c896e3088e86f70db7081009308 (diff) | |
download | external_chromium-ddb351dbec246cf1fab5ec20d2d5520909041de1.zip external_chromium-ddb351dbec246cf1fab5ec20d2d5520909041de1.tar.gz external_chromium-ddb351dbec246cf1fab5ec20d2d5520909041de1.tar.bz2 |
Merge Chromium at r12.0.742.93: Initial merge by git
Change-Id: Ic5ee2fec31358bbee305f7e915442377bfa6cda6
Diffstat (limited to 'chrome/browser/sync/profile_sync_service_preference_unittest.cc')
-rw-r--r-- | chrome/browser/sync/profile_sync_service_preference_unittest.cc | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc index 8c44e17..4a99ba6 100644 --- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -9,6 +9,7 @@ #include "base/stl_util-inl.h" #include "base/string_piece.h" #include "base/task.h" +#include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/sync/abstract_profile_sync_service_test.h" #include "chrome/browser/sync/engine/syncapi.h" #include "chrome/browser/sync/glue/preference_change_processor.h" @@ -20,10 +21,10 @@ #include "chrome/browser/sync/syncable/model_type.h" #include "chrome/browser/sync/test_profile_sync_service.h" #include "chrome/common/net/gaia/gaia_constants.h" -#include "chrome/common/json_value_serializer.h" #include "chrome/common/pref_names.h" #include "chrome/test/testing_pref_service.h" #include "chrome/test/testing_profile.h" +#include "content/common/json_value_serializer.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -51,7 +52,7 @@ class ProfileSyncServicePreferenceTest virtual void SetUp() { profile_.reset(new TestingProfile()); - profile_->set_has_history_service(true); + profile_->CreateRequestContext(); prefs_ = profile_->GetTestingPrefService(); prefs_->RegisterStringPref(not_synced_preference_name_.c_str(), @@ -60,7 +61,12 @@ class ProfileSyncServicePreferenceTest virtual void TearDown() { service_.reset(); - profile_.reset(); + { + // The request context gets deleted on the I/O thread. To prevent a leak + // supply one here. + BrowserThread io_thread(BrowserThread::IO, MessageLoop::current()); + profile_.reset(); + } MessageLoop::current()->RunAllPending(); } @@ -83,10 +89,9 @@ class ProfileSyncServicePreferenceTest EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). WillOnce(ReturnNewDataTypeManager()); - service_->set_num_expected_resumes(will_fail_association ? 0 : 1); - service_->RegisterDataTypeController( new PreferenceDataTypeController(&factory_, + profile_.get(), service_.get())); profile_->GetTokenService()->IssueAuthTokenForTest( GaiaConstants::kSyncService, "token"); @@ -119,12 +124,12 @@ class ProfileSyncServicePreferenceTest return reader.JsonToValue(specifics.value(), false, false); } - int64 WriteSyncedValue(sync_api::WriteNode& node, - const std::string& name, - const Value& value) { - if (!PreferenceModelAssociator::WritePreferenceToNode(name, value, &node)) + int64 WriteSyncedValue(const std::string& name, + const Value& value, + sync_api::WriteNode* node) { + if (!PreferenceModelAssociator::WritePreferenceToNode(name, value, node)) return sync_api::kInvalidId; - return node.GetId(); + return node->GetId(); } int64 SetSyncedValue(const std::string& name, const Value& value) { @@ -139,11 +144,11 @@ class ProfileSyncServicePreferenceTest int64 node_id = model_associator_->GetSyncIdFromChromeId(name); if (node_id == sync_api::kInvalidId) { if (tag_node.InitByClientTagLookup(syncable::PREFERENCES, name)) - return WriteSyncedValue(tag_node, name, value); + return WriteSyncedValue(name, value, &tag_node); if (node.InitUniqueByCreation(syncable::PREFERENCES, root, name)) - return WriteSyncedValue(node, name, value); + return WriteSyncedValue(name, value, &node); } else if (node.InitByIdLookup(node_id)) { - return WriteSyncedValue(node, name, value); + return WriteSyncedValue(name, value, &node); } return sync_api::kInvalidId; } @@ -248,9 +253,12 @@ TEST_F(ProfileSyncServicePreferenceTest, ModelAssociationDoNotSyncDefaults) { TEST_F(ProfileSyncServicePreferenceTest, ModelAssociationEmptyCloud) { prefs_->SetString(prefs::kHomePage, example_url0_); - ListValue* url_list = prefs_->GetMutableList(prefs::kURLsToRestoreOnStartup); - url_list->Append(Value::CreateStringValue(example_url0_)); - url_list->Append(Value::CreateStringValue(example_url1_)); + { + ListPrefUpdate update(prefs_, prefs::kURLsToRestoreOnStartup); + ListValue* url_list = update.Get(); + url_list->Append(Value::CreateStringValue(example_url0_)); + url_list->Append(Value::CreateStringValue(example_url1_)); + } CreateRootTask task(this, syncable::PREFERENCES); ASSERT_TRUE(StartSyncService(&task, false)); ASSERT_TRUE(task.success()); @@ -266,9 +274,12 @@ TEST_F(ProfileSyncServicePreferenceTest, ModelAssociationEmptyCloud) { TEST_F(ProfileSyncServicePreferenceTest, ModelAssociationCloudHasData) { prefs_->SetString(prefs::kHomePage, example_url0_); - ListValue* url_list = prefs_->GetMutableList(prefs::kURLsToRestoreOnStartup); - url_list->Append(Value::CreateStringValue(example_url0_)); - url_list->Append(Value::CreateStringValue(example_url1_)); + { + ListPrefUpdate update(prefs_, prefs::kURLsToRestoreOnStartup); + ListValue* url_list = update.Get(); + url_list->Append(Value::CreateStringValue(example_url0_)); + url_list->Append(Value::CreateStringValue(example_url1_)); + } PreferenceValues cloud_data; cloud_data[prefs::kHomePage] = Value::CreateStringValue(example_url1_); |