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

Side by Side Diff: components/prefs/overlay_user_pref_store_unittest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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
« no previous file with comments | « components/prefs/json_pref_store.cc ('k') | components/prefs/pref_member.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prefs/overlay_user_pref_store.h" 5 #include "components/prefs/overlay_user_pref_store.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "components/prefs/pref_store_observer_mock.h" 9 #include "components/prefs/pref_store_observer_mock.h"
10 #include "components/prefs/testing_pref_store.h" 10 #include "components/prefs/testing_pref_store.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 // Check that GetMutableValue does not return the dictionary of the underlay. 132 // Check that GetMutableValue does not return the dictionary of the underlay.
133 TEST_F(OverlayUserPrefStoreTest, ModifyDictionaries) { 133 TEST_F(OverlayUserPrefStoreTest, ModifyDictionaries) {
134 underlay_->SetValue(overlay_key, base::WrapUnique(new DictionaryValue), 134 underlay_->SetValue(overlay_key, base::WrapUnique(new DictionaryValue),
135 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 135 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
136 136
137 Value* modify = NULL; 137 Value* modify = NULL;
138 EXPECT_TRUE(overlay_->GetMutableValue(overlay_key, &modify)); 138 EXPECT_TRUE(overlay_->GetMutableValue(overlay_key, &modify));
139 ASSERT_TRUE(modify); 139 ASSERT_TRUE(modify);
140 ASSERT_TRUE(modify->IsType(Value::TYPE_DICTIONARY)); 140 ASSERT_TRUE(modify->IsType(Value::Type::DICTIONARY));
141 static_cast<DictionaryValue*>(modify)->SetInteger(overlay_key, 42); 141 static_cast<DictionaryValue*>(modify)->SetInteger(overlay_key, 42);
142 142
143 Value* original_in_underlay = NULL; 143 Value* original_in_underlay = NULL;
144 EXPECT_TRUE(underlay_->GetMutableValue(overlay_key, &original_in_underlay)); 144 EXPECT_TRUE(underlay_->GetMutableValue(overlay_key, &original_in_underlay));
145 ASSERT_TRUE(original_in_underlay); 145 ASSERT_TRUE(original_in_underlay);
146 ASSERT_TRUE(original_in_underlay->IsType(Value::TYPE_DICTIONARY)); 146 ASSERT_TRUE(original_in_underlay->IsType(Value::Type::DICTIONARY));
147 EXPECT_TRUE(static_cast<DictionaryValue*>(original_in_underlay)->empty()); 147 EXPECT_TRUE(static_cast<DictionaryValue*>(original_in_underlay)->empty());
148 148
149 Value* modified = NULL; 149 Value* modified = NULL;
150 EXPECT_TRUE(overlay_->GetMutableValue(overlay_key, &modified)); 150 EXPECT_TRUE(overlay_->GetMutableValue(overlay_key, &modified));
151 ASSERT_TRUE(modified); 151 ASSERT_TRUE(modified);
152 ASSERT_TRUE(modified->IsType(Value::TYPE_DICTIONARY)); 152 ASSERT_TRUE(modified->IsType(Value::Type::DICTIONARY));
153 EXPECT_TRUE(Value::Equals(modify, static_cast<DictionaryValue*>(modified))); 153 EXPECT_TRUE(Value::Equals(modify, static_cast<DictionaryValue*>(modified)));
154 } 154 }
155 155
156 // Here we consider a global preference that is not overlayed. 156 // Here we consider a global preference that is not overlayed.
157 TEST_F(OverlayUserPrefStoreTest, GlobalPref) { 157 TEST_F(OverlayUserPrefStoreTest, GlobalPref) {
158 PrefStoreObserverMock obs; 158 PrefStoreObserverMock obs;
159 overlay_->AddObserver(&obs); 159 overlay_->AddObserver(&obs);
160 160
161 const Value* value = NULL; 161 const Value* value = NULL;
162 162
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value)); 303 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value));
304 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); 304 EXPECT_TRUE(base::FundamentalValue(43).Equals(value));
305 overlay_->ClearMutableValues(); 305 overlay_->ClearMutableValues();
306 306
307 // Check that an underlay preference is returned. 307 // Check that an underlay preference is returned.
308 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value)); 308 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value));
309 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); 309 EXPECT_TRUE(base::FundamentalValue(42).Equals(value));
310 } 310 }
311 311
312 } // namespace base 312 } // namespace base
OLDNEW
« no previous file with comments | « components/prefs/json_pref_store.cc ('k') | components/prefs/pref_member.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698