| Index: chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc
|
| diff --git a/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc b/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc
|
| index 53744d7660644578e14abbceecb806dd85a6b70a..e0cb6cc640dc7b12a5a54dad167a6e02694da7bc 100644
|
| --- a/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc
|
| +++ b/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc
|
| @@ -18,6 +18,7 @@
|
| #include "chrome/test/base/testing_profile.h"
|
| #include "content/public/test/test_browser_thread_bundle.h"
|
| #include "extensions/browser/api/declarative/rules_cache_delegate.h"
|
| +#include "extensions/browser/api/declarative/rules_registry_service.h"
|
| #include "extensions/browser/api/declarative/test_rules_registry.h"
|
| #include "extensions/browser/extension_prefs.h"
|
| #include "extensions/browser/extension_registry.h"
|
| @@ -35,6 +36,7 @@ const char kRule2Id[] = "rule2";
|
| }
|
|
|
| namespace extensions {
|
| +const int kRulesRegistryID = RulesRegistryService::kDefaultRulesRegistryID;
|
|
|
| class RulesRegistryWithCacheTest : public testing::Test {
|
| public:
|
| @@ -44,7 +46,7 @@ class RulesRegistryWithCacheTest : public testing::Test {
|
| /*event_name=*/"",
|
| content::BrowserThread::UI,
|
| &cache_delegate_,
|
| - RulesRegistry::WebViewKey(0, 0))) {}
|
| + kRulesRegistryID)) {}
|
|
|
| void SetUp() override {
|
| env_.GetExtensionPrefs(); // Force creation before adding extensions.
|
| @@ -233,10 +235,9 @@ TEST_F(RulesRegistryWithCacheTest, DeclarativeRulesStored) {
|
| RulesCacheDelegate::GetRulesStoredKey(
|
| event_name, profile()->IsOffTheRecord()));
|
| scoped_ptr<RulesCacheDelegate> cache_delegate(new RulesCacheDelegate(false));
|
| - scoped_refptr<RulesRegistry> registry(new TestRulesRegistry(
|
| - profile(), event_name, content::BrowserThread::UI,
|
| - cache_delegate.get(),
|
| - RulesRegistry::WebViewKey(0, 0)));
|
| + scoped_refptr<RulesRegistry> registry(
|
| + new TestRulesRegistry(profile(), event_name, content::BrowserThread::UI,
|
| + cache_delegate.get(), kRulesRegistryID));
|
|
|
| // 1. Test the handling of preferences.
|
| // Default value is always true.
|
| @@ -303,16 +304,14 @@ TEST_F(RulesRegistryWithCacheTest, RulesStoredFlagMultipleRegistries) {
|
| RulesCacheDelegate::GetRulesStoredKey(
|
| event_name2, profile()->IsOffTheRecord()));
|
| scoped_ptr<RulesCacheDelegate> cache_delegate1(new RulesCacheDelegate(false));
|
| - scoped_refptr<RulesRegistry> registry1(new TestRulesRegistry(
|
| - profile(), event_name1, content::BrowserThread::UI,
|
| - cache_delegate1.get(),
|
| - RulesRegistry::WebViewKey(0, 0)));
|
| + scoped_refptr<RulesRegistry> registry1(
|
| + new TestRulesRegistry(profile(), event_name1, content::BrowserThread::UI,
|
| + cache_delegate1.get(), kRulesRegistryID));
|
|
|
| scoped_ptr<RulesCacheDelegate> cache_delegate2(new RulesCacheDelegate(false));
|
| - scoped_refptr<RulesRegistry> registry2(new TestRulesRegistry(
|
| - profile(), event_name2, content::BrowserThread::UI,
|
| - cache_delegate2.get(),
|
| - RulesRegistry::WebViewKey(0, 0)));
|
| + scoped_refptr<RulesRegistry> registry2(
|
| + new TestRulesRegistry(profile(), event_name2, content::BrowserThread::UI,
|
| + cache_delegate2.get(), kRulesRegistryID));
|
|
|
| // Checkt the correct default values.
|
| EXPECT_TRUE(cache_delegate1->GetDeclarativeRulesStored(extension1_->id()));
|
| @@ -355,12 +354,9 @@ TEST_F(RulesRegistryWithCacheTest, RulesPreservedAcrossRestart) {
|
|
|
| // 2. First run, adding a rule for the extension.
|
| scoped_ptr<RulesCacheDelegate> cache_delegate(new RulesCacheDelegate(false));
|
| - scoped_refptr<TestRulesRegistry> registry(new TestRulesRegistry(
|
| - profile(),
|
| - "testEvent",
|
| - content::BrowserThread::UI,
|
| - cache_delegate.get(),
|
| - RulesRegistry::WebViewKey(0, 0)));
|
| + scoped_refptr<TestRulesRegistry> registry(
|
| + new TestRulesRegistry(profile(), "testEvent", content::BrowserThread::UI,
|
| + cache_delegate.get(), kRulesRegistryID));
|
|
|
| AddRule(extension1_->id(), kRuleId, registry.get());
|
| base::RunLoop().RunUntilIdle(); // Posted tasks store the added rule.
|
| @@ -368,12 +364,9 @@ TEST_F(RulesRegistryWithCacheTest, RulesPreservedAcrossRestart) {
|
|
|
| // 3. Restart the TestRulesRegistry and see the rule still there.
|
| cache_delegate.reset(new RulesCacheDelegate(false));
|
| - registry = new TestRulesRegistry(
|
| - profile(),
|
| - "testEvent",
|
| - content::BrowserThread::UI,
|
| - cache_delegate.get(),
|
| - RulesRegistry::WebViewKey(0, 0));
|
| + registry =
|
| + new TestRulesRegistry(profile(), "testEvent", content::BrowserThread::UI,
|
| + cache_delegate.get(), kRulesRegistryID);
|
|
|
| base::RunLoop().RunUntilIdle(); // Posted tasks retrieve the stored rule.
|
| EXPECT_EQ(1, GetNumberOfRules(extension1_->id(), registry.get()));
|
|
|