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

Side by Side Diff: components/sync_preferences/pref_model_associator_unittest.cc

Issue 2843813002: Remove SetWithoutPathExpansion (Closed)
Patch Set: Fix CrOS Error Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "components/sync_preferences/pref_model_associator.h" 5 #include "components/sync_preferences/pref_model_associator.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 pref_registry->RegisterDictionaryPref( 58 pref_registry->RegisterDictionaryPref(
59 kDictionaryPrefName, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 59 kDictionaryPrefName, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
60 pref_service_ = factory.CreateSyncable(pref_registry.get()); 60 pref_service_ = factory.CreateSyncable(pref_registry.get());
61 pref_sync_service_ = static_cast<PrefModelAssociator*>( 61 pref_sync_service_ = static_cast<PrefModelAssociator*>(
62 pref_service_->GetSyncableService(syncer::PREFERENCES)); 62 pref_service_->GetSyncableService(syncer::PREFERENCES));
63 } 63 }
64 64
65 void SetContentPattern(base::DictionaryValue* patterns_dict, 65 void SetContentPattern(base::DictionaryValue* patterns_dict,
66 const std::string& expression, 66 const std::string& expression,
67 int setting) { 67 int setting) {
68 base::DictionaryValue* expression_dict; 68 base::DictionaryValue* expression_dict = nullptr;
69 bool found = patterns_dict->GetDictionaryWithoutPathExpansion( 69 bool found = patterns_dict->GetDictionaryWithoutPathExpansion(
70 expression, &expression_dict); 70 expression, &expression_dict);
71 if (!found) { 71 if (!found) {
72 expression_dict = new base::DictionaryValue; 72 patterns_dict->SetWithoutPathExpansion(
73 patterns_dict->SetWithoutPathExpansion(expression, expression_dict); 73 expression, base::MakeUnique<base::DictionaryValue>());
74 patterns_dict->GetDictionaryWithoutPathExpansion(expression,
75 &expression_dict);
74 } 76 }
75 expression_dict->SetWithoutPathExpansion("setting", 77 expression_dict->SetIntegerWithoutPathExpansion("setting", setting);
76 new base::Value(setting));
77 } 78 }
78 79
79 void SetPrefToEmpty(const std::string& pref_name) { 80 void SetPrefToEmpty(const std::string& pref_name) {
80 std::unique_ptr<base::Value> empty_value; 81 std::unique_ptr<base::Value> empty_value;
81 const PrefService::Preference* pref = 82 const PrefService::Preference* pref =
82 pref_service_->FindPreference(pref_name.c_str()); 83 pref_service_->FindPreference(pref_name.c_str());
83 ASSERT_TRUE(pref); 84 ASSERT_TRUE(pref);
84 base::Value::Type type = pref->GetType(); 85 base::Value::Type type = pref->GetType();
85 if (type == base::Value::Type::DICTIONARY) 86 if (type == base::Value::Type::DICTIONARY)
86 empty_value.reset(new base::DictionaryValue); 87 empty_value.reset(new base::DictionaryValue);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 base::DictionaryValue server_patterns_; 433 base::DictionaryValue server_patterns_;
433 }; 434 };
434 435
435 TEST_F(IndividualPreferenceMergeTest, ListPreference) { 436 TEST_F(IndividualPreferenceMergeTest, ListPreference) {
436 EXPECT_TRUE(MergeListPreference(kListPrefName)); 437 EXPECT_TRUE(MergeListPreference(kListPrefName));
437 } 438 }
438 439
439 } // namespace 440 } // namespace
440 441
441 } // namespace sync_preferences 442 } // namespace sync_preferences
OLDNEW
« no previous file with comments | « components/sync_preferences/pref_model_associator.cc ('k') | components/url_matcher/url_matcher_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698