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

Side by Side Diff: chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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) 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 "extensions/browser/api/declarative/rules_registry.h" 5 #include "extensions/browser/api/declarative/rules_registry.h"
6 6
7 // Here we test the TestRulesRegistry which is the simplest possible 7 // Here we test the TestRulesRegistry which is the simplest possible
8 // implementation of RulesRegistryWithCache as a proxy for 8 // implementation of RulesRegistryWithCache as a proxy for
9 // RulesRegistryWithCache. 9 // RulesRegistryWithCache.
10 10
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 std::unique_ptr<RulesCacheDelegate> cache_delegate( 234 std::unique_ptr<RulesCacheDelegate> cache_delegate(
235 new RulesCacheDelegate(false)); 235 new RulesCacheDelegate(false));
236 scoped_refptr<RulesRegistry> registry( 236 scoped_refptr<RulesRegistry> registry(
237 new TestRulesRegistry(profile(), event_name, content::BrowserThread::UI, 237 new TestRulesRegistry(profile(), event_name, content::BrowserThread::UI,
238 cache_delegate.get(), kRulesRegistryID)); 238 cache_delegate.get(), kRulesRegistryID));
239 239
240 // 1. Test the handling of preferences. 240 // 1. Test the handling of preferences.
241 // Default value is always true. 241 // Default value is always true.
242 EXPECT_TRUE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); 242 EXPECT_TRUE(cache_delegate->GetDeclarativeRulesStored(extension1_->id()));
243 243
244 extension_prefs->UpdateExtensionPref( 244 extension_prefs->UpdateExtensionPref(extension1_->id(), rules_stored_key,
245 extension1_->id(), rules_stored_key, new base::FundamentalValue(false)); 245 new base::Value(false));
246 EXPECT_FALSE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); 246 EXPECT_FALSE(cache_delegate->GetDeclarativeRulesStored(extension1_->id()));
247 247
248 extension_prefs->UpdateExtensionPref( 248 extension_prefs->UpdateExtensionPref(extension1_->id(), rules_stored_key,
249 extension1_->id(), rules_stored_key, new base::FundamentalValue(true)); 249 new base::Value(true));
250 EXPECT_TRUE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); 250 EXPECT_TRUE(cache_delegate->GetDeclarativeRulesStored(extension1_->id()));
251 251
252 // 2. Test writing behavior. 252 // 2. Test writing behavior.
253 // The ValueStore is lazily created when reading/writing. None done yet so 253 // The ValueStore is lazily created when reading/writing. None done yet so
254 // verify that not yet created. 254 // verify that not yet created.
255 TestingValueStore* store = env_.GetExtensionSystem()->value_store(); 255 TestingValueStore* store = env_.GetExtensionSystem()->value_store();
256 // No write yet so no store should have been created. 256 // No write yet so no store should have been created.
257 ASSERT_FALSE(store); 257 ASSERT_FALSE(store);
258 258
259 std::unique_ptr<base::ListValue> value(new base::ListValue); 259 std::unique_ptr<base::ListValue> value(new base::ListValue);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 new RulesCacheDelegate(false)); 317 new RulesCacheDelegate(false));
318 scoped_refptr<RulesRegistry> registry2( 318 scoped_refptr<RulesRegistry> registry2(
319 new TestRulesRegistry(profile(), event_name2, content::BrowserThread::UI, 319 new TestRulesRegistry(profile(), event_name2, content::BrowserThread::UI,
320 cache_delegate2.get(), kRulesRegistryID)); 320 cache_delegate2.get(), kRulesRegistryID));
321 321
322 // Checkt the correct default values. 322 // Checkt the correct default values.
323 EXPECT_TRUE(cache_delegate1->GetDeclarativeRulesStored(extension1_->id())); 323 EXPECT_TRUE(cache_delegate1->GetDeclarativeRulesStored(extension1_->id()));
324 EXPECT_TRUE(cache_delegate2->GetDeclarativeRulesStored(extension1_->id())); 324 EXPECT_TRUE(cache_delegate2->GetDeclarativeRulesStored(extension1_->id()));
325 325
326 // Update the flag for the first registry. 326 // Update the flag for the first registry.
327 extension_prefs->UpdateExtensionPref( 327 extension_prefs->UpdateExtensionPref(extension1_->id(), rules_stored_key1,
328 extension1_->id(), rules_stored_key1, new base::FundamentalValue(false)); 328 new base::Value(false));
329 EXPECT_FALSE(cache_delegate1->GetDeclarativeRulesStored(extension1_->id())); 329 EXPECT_FALSE(cache_delegate1->GetDeclarativeRulesStored(extension1_->id()));
330 EXPECT_TRUE(cache_delegate2->GetDeclarativeRulesStored(extension1_->id())); 330 EXPECT_TRUE(cache_delegate2->GetDeclarativeRulesStored(extension1_->id()));
331 } 331 }
332 332
333 TEST_F(RulesRegistryWithCacheTest, RulesPreservedAcrossRestart) { 333 TEST_F(RulesRegistryWithCacheTest, RulesPreservedAcrossRestart) {
334 // This test makes sure that rules are restored from the rule store 334 // This test makes sure that rules are restored from the rule store
335 // on registry (in particular, browser) restart. 335 // on registry (in particular, browser) restart.
336 336
337 // TODO(vabr): Once some API using declarative rules enters the stable 337 // TODO(vabr): Once some API using declarative rules enters the stable
338 // channel, make sure to use that API here, and remove |channel|. 338 // channel, make sure to use that API here, and remove |channel|.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 int write_count = 0; 392 int write_count = 0;
393 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId)); 393 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId));
394 EXPECT_EQ("", AddRule(extension2_->id(), kRule2Id)); 394 EXPECT_EQ("", AddRule(extension2_->id(), kRule2Id));
395 env_.GetExtensionSystem()->SetReady(); 395 env_.GetExtensionSystem()->SetReady();
396 base::RunLoop().RunUntilIdle(); 396 base::RunLoop().RunUntilIdle();
397 EXPECT_EQ(write_count + 2, system->value_store()->write_count()); 397 EXPECT_EQ(write_count + 2, system->value_store()->write_count());
398 } 398 }
399 399
400 } // namespace extensions 400 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698