| 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/test_rules_registry.h" | 5 #include "chrome/browser/extensions/api/declarative/test_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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 int GetNumberOfRules(const std::string& extension_id) { | 53 int GetNumberOfRules(const std::string& extension_id) { |
| 54 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > get_rules; | 54 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > get_rules; |
| 55 std::string error = registry_->GetAllRules(extension_id, &get_rules); | 55 std::string error = registry_->GetAllRules(extension_id, &get_rules); |
| 56 EXPECT_EQ("", error); | 56 EXPECT_EQ("", error); |
| 57 return get_rules.size(); | 57 return get_rules.size(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 MessageLoop message_loop_; | 61 base::MessageLoop message_loop_; |
| 62 content::TestBrowserThread ui_; | 62 content::TestBrowserThread ui_; |
| 63 scoped_refptr<TestRulesRegistry> registry_; | 63 scoped_refptr<TestRulesRegistry> registry_; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 TEST_F(RulesRegistryWithCacheTest, AddRules) { | 66 TEST_F(RulesRegistryWithCacheTest, AddRules) { |
| 67 // Check that nothing happens if the concrete RulesRegistry refuses to insert | 67 // Check that nothing happens if the concrete RulesRegistry refuses to insert |
| 68 // the rules. | 68 // the rules. |
| 69 registry_->SetResult("Error"); | 69 registry_->SetResult("Error"); |
| 70 EXPECT_EQ("Error", AddRule(extension_id, rule_id)); | 70 EXPECT_EQ("Error", AddRule(extension_id, rule_id)); |
| 71 EXPECT_EQ(0, GetNumberOfRules(extension_id)); | 71 EXPECT_EQ(0, GetNumberOfRules(extension_id)); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 EXPECT_EQ("", AddRule(extension_id, rule_id)); | 170 EXPECT_EQ("", AddRule(extension_id, rule_id)); |
| 171 EXPECT_EQ("", AddRule(extension2_id, rule_id)); | 171 EXPECT_EQ("", AddRule(extension2_id, rule_id)); |
| 172 | 172 |
| 173 // Check that the correct rules are removed. | 173 // Check that the correct rules are removed. |
| 174 registry_->OnExtensionUnloaded(extension_id); | 174 registry_->OnExtensionUnloaded(extension_id); |
| 175 EXPECT_EQ(0, GetNumberOfRules(extension_id)); | 175 EXPECT_EQ(0, GetNumberOfRules(extension_id)); |
| 176 EXPECT_EQ(1, GetNumberOfRules(extension2_id)); | 176 EXPECT_EQ(1, GetNumberOfRules(extension2_id)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace extensions | 179 } // namespace extensions |
| OLD | NEW |