| OLD | NEW |
| 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 "chrome/browser/extensions/api/declarative/rules_registry.h" | 5 #include "chrome/browser/extensions/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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 registry_->GetAllRules(kExtensionId, &gotten_rules); | 196 registry_->GetAllRules(kExtensionId, &gotten_rules); |
| 197 EXPECT_EQ(2u, gotten_rules.size()); | 197 EXPECT_EQ(2u, gotten_rules.size()); |
| 198 ASSERT_TRUE(gotten_rules[0]->id.get()); | 198 ASSERT_TRUE(gotten_rules[0]->id.get()); |
| 199 ASSERT_TRUE(gotten_rules[1]->id.get()); | 199 ASSERT_TRUE(gotten_rules[1]->id.get()); |
| 200 EXPECT_TRUE( (kRuleId == *(gotten_rules[0]->id) && | 200 EXPECT_TRUE( (kRuleId == *(gotten_rules[0]->id) && |
| 201 kRule2Id == *(gotten_rules[1]->id)) || | 201 kRule2Id == *(gotten_rules[1]->id)) || |
| 202 (kRuleId == *(gotten_rules[1]->id) && | 202 (kRuleId == *(gotten_rules[1]->id) && |
| 203 kRule2Id == *(gotten_rules[0]->id)) ); | 203 kRule2Id == *(gotten_rules[0]->id)) ); |
| 204 } | 204 } |
| 205 | 205 |
| 206 TEST_F(RulesRegistryWithCacheTest, OnExtensionUnloaded) { | 206 TEST_F(RulesRegistryWithCacheTest, OnExtensionUninstalled) { |
| 207 // Prime registry. | 207 // Prime registry. |
| 208 EXPECT_EQ("", AddRule(kExtensionId, kRuleId)); | 208 EXPECT_EQ("", AddRule(kExtensionId, kRuleId)); |
| 209 EXPECT_EQ("", AddRule(kExtension2Id, kRuleId)); | 209 EXPECT_EQ("", AddRule(kExtension2Id, kRuleId)); |
| 210 | 210 |
| 211 // Check that the correct rules are removed. | 211 // Check that the correct rules are removed. |
| 212 registry_->OnExtensionUnloaded(kExtensionId); | 212 registry_->OnExtensionUninstalled(kExtensionId); |
| 213 EXPECT_EQ(0, GetNumberOfRules(kExtensionId)); | 213 EXPECT_EQ(0, GetNumberOfRules(kExtensionId)); |
| 214 EXPECT_EQ(1, GetNumberOfRules(kExtension2Id)); | 214 EXPECT_EQ(1, GetNumberOfRules(kExtension2Id)); |
| 215 } | 215 } |
| 216 | 216 |
| 217 TEST_F(RulesRegistryWithCacheTest, DeclarativeRulesStored) { | 217 TEST_F(RulesRegistryWithCacheTest, DeclarativeRulesStored) { |
| 218 TestingProfile profile; | 218 TestingProfile profile; |
| 219 // TestingProfile::Init makes sure that the factory method for a corresponding | 219 // TestingProfile::Init makes sure that the factory method for a corresponding |
| 220 // extension system creates a TestExtensionSystem. | 220 // extension system creates a TestExtensionSystem. |
| 221 extensions::TestExtensionSystem* system = | 221 extensions::TestExtensionSystem* system = |
| 222 static_cast<extensions::TestExtensionSystem*>( | 222 static_cast<extensions::TestExtensionSystem*>( |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 "testEvent", | 378 "testEvent", |
| 379 content::BrowserThread::UI, | 379 content::BrowserThread::UI, |
| 380 cache_delegate.get(), | 380 cache_delegate.get(), |
| 381 RulesRegistry::WebViewKey(0, 0)); | 381 RulesRegistry::WebViewKey(0, 0)); |
| 382 | 382 |
| 383 message_loop_.RunUntilIdle(); // Posted tasks retrieve the stored rule. | 383 message_loop_.RunUntilIdle(); // Posted tasks retrieve the stored rule. |
| 384 EXPECT_EQ(1, GetNumberOfRules(kExtensionId, registry.get())); | 384 EXPECT_EQ(1, GetNumberOfRules(kExtensionId, registry.get())); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace extensions | 387 } // namespace extensions |
| OLD | NEW |