| 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_webrequest/webrequest_rules_
registry.h" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_
registry.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 ++num_clear_cache_calls_; | 73 ++num_clear_cache_calls_; |
| 74 } | 74 } |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 int num_clear_cache_calls_; | 77 int num_clear_cache_calls_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 class WebRequestRulesRegistryTest : public testing::Test { | 80 class WebRequestRulesRegistryTest : public testing::Test { |
| 81 public: | 81 public: |
| 82 WebRequestRulesRegistryTest() | 82 WebRequestRulesRegistryTest() |
| 83 : message_loop(MessageLoop::TYPE_IO), | 83 : message_loop(base::MessageLoop::TYPE_IO), |
| 84 ui(content::BrowserThread::UI, &message_loop), | 84 ui(content::BrowserThread::UI, &message_loop), |
| 85 io(content::BrowserThread::IO, &message_loop) {} | 85 io(content::BrowserThread::IO, &message_loop) {} |
| 86 | 86 |
| 87 virtual ~WebRequestRulesRegistryTest() {} | 87 virtual ~WebRequestRulesRegistryTest() {} |
| 88 | 88 |
| 89 virtual void TearDown() OVERRIDE { | 89 virtual void TearDown() OVERRIDE { |
| 90 // Make sure that deletion traits of all registries are executed. | 90 // Make sure that deletion traits of all registries are executed. |
| 91 message_loop.RunUntilIdle(); | 91 message_loop.RunUntilIdle(); |
| 92 } | 92 } |
| 93 | 93 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 rule->priority.reset(new int(1)); | 213 rule->priority.reset(new int(1)); |
| 214 rule->actions.push_back(linked_ptr<base::Value>(action_dict.DeepCopy())); | 214 rule->actions.push_back(linked_ptr<base::Value>(action_dict.DeepCopy())); |
| 215 for (std::vector<const std::string*>::const_iterator it = | 215 for (std::vector<const std::string*>::const_iterator it = |
| 216 attributes.begin(); | 216 attributes.begin(); |
| 217 it != attributes.end(); ++it) | 217 it != attributes.end(); ++it) |
| 218 rule->conditions.push_back(CreateCondition(**it)); | 218 rule->conditions.push_back(CreateCondition(**it)); |
| 219 return rule; | 219 return rule; |
| 220 } | 220 } |
| 221 | 221 |
| 222 protected: | 222 protected: |
| 223 MessageLoop message_loop; | 223 base::MessageLoop message_loop; |
| 224 content::TestBrowserThread ui; | 224 content::TestBrowserThread ui; |
| 225 content::TestBrowserThread io; | 225 content::TestBrowserThread io; |
| 226 }; | 226 }; |
| 227 | 227 |
| 228 TEST_F(WebRequestRulesRegistryTest, AddRulesImpl) { | 228 TEST_F(WebRequestRulesRegistryTest, AddRulesImpl) { |
| 229 scoped_refptr<TestWebRequestRulesRegistry> registry( | 229 scoped_refptr<TestWebRequestRulesRegistry> registry( |
| 230 new TestWebRequestRulesRegistry()); | 230 new TestWebRequestRulesRegistry()); |
| 231 std::string error; | 231 std::string error; |
| 232 | 232 |
| 233 std::vector<linked_ptr<RulesRegistry::Rule> > rules; | 233 std::vector<linked_ptr<RulesRegistry::Rule> > rules; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 706 |
| 707 // This is a correct match. | 707 // This is a correct match. |
| 708 GURL url2("http://foo.com/index.html"); | 708 GURL url2("http://foo.com/index.html"); |
| 709 net::TestURLRequest request2(url2, NULL, &context, NULL); | 709 net::TestURLRequest request2(url2, NULL, &context, NULL); |
| 710 WebRequestData request_data2(&request2, ON_BEFORE_REQUEST); | 710 WebRequestData request_data2(&request2, ON_BEFORE_REQUEST); |
| 711 deltas = registry->CreateDeltas(NULL, request_data2, false); | 711 deltas = registry->CreateDeltas(NULL, request_data2, false); |
| 712 EXPECT_EQ(1u, deltas.size()); | 712 EXPECT_EQ(1u, deltas.size()); |
| 713 } | 713 } |
| 714 | 714 |
| 715 } // namespace extensions | 715 } // namespace extensions |
| OLD | NEW |