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

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

Issue 1158693006: Create a mechanism define declarative rules via the extension manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a manifest handler Created 5 years, 6 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 (kRuleId == *(gotten_rules[1]->id) && 213 (kRuleId == *(gotten_rules[1]->id) &&
214 kRule2Id == *(gotten_rules[0]->id)) ); 214 kRule2Id == *(gotten_rules[0]->id)) );
215 } 215 }
216 216
217 TEST_F(RulesRegistryWithCacheTest, OnExtensionUninstalled) { 217 TEST_F(RulesRegistryWithCacheTest, OnExtensionUninstalled) {
218 // Prime registry. 218 // Prime registry.
219 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId)); 219 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId));
220 EXPECT_EQ("", AddRule(extension2_->id(), kRuleId)); 220 EXPECT_EQ("", AddRule(extension2_->id(), kRuleId));
221 221
222 // Check that the correct rules are removed. 222 // Check that the correct rules are removed.
223 registry_->OnExtensionUninstalled(extension1_->id()); 223 registry_->OnExtensionUninstalled(extension1_.get());
224 EXPECT_EQ(0, GetNumberOfRules(extension1_->id())); 224 EXPECT_EQ(0, GetNumberOfRules(extension1_->id()));
225 EXPECT_EQ(1, GetNumberOfRules(extension2_->id())); 225 EXPECT_EQ(1, GetNumberOfRules(extension2_->id()));
226 } 226 }
227 227
228 TEST_F(RulesRegistryWithCacheTest, DeclarativeRulesStored) { 228 TEST_F(RulesRegistryWithCacheTest, DeclarativeRulesStored) {
229 ExtensionPrefs* extension_prefs = env_.GetExtensionPrefs(); 229 ExtensionPrefs* extension_prefs = env_.GetExtensionPrefs();
230 // The value store is first created during GetExtensionService. 230 // The value store is first created during GetExtensionService.
231 TestingValueStore* store = env_.GetExtensionSystem()->value_store(); 231 TestingValueStore* store = env_.GetExtensionSystem()->value_store();
232 232
233 const std::string event_name("testEvent"); 233 const std::string event_name("testEvent");
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 int write_count = store->write_count(); 384 int write_count = store->write_count();
385 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId)); 385 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId));
386 EXPECT_EQ("", AddRule(extension2_->id(), kRule2Id)); 386 EXPECT_EQ("", AddRule(extension2_->id(), kRule2Id));
387 env_.GetExtensionSystem()->SetReady(); 387 env_.GetExtensionSystem()->SetReady();
388 base::RunLoop().RunUntilIdle(); 388 base::RunLoop().RunUntilIdle();
389 EXPECT_EQ(write_count + 2, store->write_count()); 389 EXPECT_EQ(write_count + 2, store->write_count());
390 } 390 }
391 391
392 } // namespace extensions 392 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698