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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc

Issue 63933003: Moved ExtensionInfoMap and ExtensionsQuotaService to extensions/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix Created 7 years, 1 month 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 | Annotate | Revision Log
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 "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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 using base::Value; 42 using base::Value;
43 using testing::HasSubstr; 43 using testing::HasSubstr;
44 44
45 namespace helpers = extension_web_request_api_helpers; 45 namespace helpers = extension_web_request_api_helpers;
46 namespace keys = declarative_webrequest_constants; 46 namespace keys = declarative_webrequest_constants;
47 namespace keys2 = url_matcher_constants; 47 namespace keys2 = url_matcher_constants;
48 48
49 class TestWebRequestRulesRegistry : public WebRequestRulesRegistry { 49 class TestWebRequestRulesRegistry : public WebRequestRulesRegistry {
50 public: 50 public:
51 explicit TestWebRequestRulesRegistry( 51 explicit TestWebRequestRulesRegistry(
52 scoped_refptr<ExtensionInfoMap> extension_info_map) 52 scoped_refptr<InfoMap> extension_info_map)
53 : WebRequestRulesRegistry(NULL /*profile*/, NULL /* cache_delegate */), 53 : WebRequestRulesRegistry(NULL /*profile*/, NULL /* cache_delegate */),
54 num_clear_cache_calls_(0) { 54 num_clear_cache_calls_(0) {
55 SetExtensionInfoMapForTesting(extension_info_map); 55 SetExtensionInfoMapForTesting(extension_info_map);
56 } 56 }
57 57
58 // Returns how often the in-memory caches of the renderers were instructed 58 // Returns how often the in-memory caches of the renderers were instructed
59 // to be cleared. 59 // to be cleared.
60 int num_clear_cache_calls() const { return num_clear_cache_calls_; } 60 int num_clear_cache_calls() const { return num_clear_cache_calls_; }
61 61
62 // How many rules are there which have some conditions not triggered by URL 62 // How many rules are there which have some conditions not triggered by URL
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 protected: 223 protected:
224 base::MessageLoop message_loop_; 224 base::MessageLoop message_loop_;
225 content::TestBrowserThread ui_; 225 content::TestBrowserThread ui_;
226 content::TestBrowserThread io_; 226 content::TestBrowserThread io_;
227 // Two extensions with host permissions for all URLs and the DWR permission. 227 // Two extensions with host permissions for all URLs and the DWR permission.
228 // Installation times will be so that |extension_| is older than 228 // Installation times will be so that |extension_| is older than
229 // |extension2_|. 229 // |extension2_|.
230 scoped_refptr<Extension> extension_; 230 scoped_refptr<Extension> extension_;
231 scoped_refptr<Extension> extension2_; 231 scoped_refptr<Extension> extension2_;
232 scoped_refptr<ExtensionInfoMap> extension_info_map_; 232 scoped_refptr<InfoMap> extension_info_map_;
233 }; 233 };
234 234
235 void WebRequestRulesRegistryTest::SetUp() { 235 void WebRequestRulesRegistryTest::SetUp() {
236 testing::Test::SetUp(); 236 testing::Test::SetUp();
237 237
238 std::string error; 238 std::string error;
239 extension_ = LoadManifestUnchecked("permissions", 239 extension_ = LoadManifestUnchecked("permissions",
240 "web_request_all_host_permissions.json", 240 "web_request_all_host_permissions.json",
241 Manifest::INVALID_LOCATION, 241 Manifest::INVALID_LOCATION,
242 Extension::NO_FLAGS, 242 Extension::NO_FLAGS,
243 kExtensionId, 243 kExtensionId,
244 &error); 244 &error);
245 ASSERT_TRUE(extension_.get()) << error; 245 ASSERT_TRUE(extension_.get()) << error;
246 extension2_ = LoadManifestUnchecked("permissions", 246 extension2_ = LoadManifestUnchecked("permissions",
247 "web_request_all_host_permissions.json", 247 "web_request_all_host_permissions.json",
248 Manifest::INVALID_LOCATION, 248 Manifest::INVALID_LOCATION,
249 Extension::NO_FLAGS, 249 Extension::NO_FLAGS,
250 kExtensionId2, 250 kExtensionId2,
251 &error); 251 &error);
252 ASSERT_TRUE(extension2_.get()) << error; 252 ASSERT_TRUE(extension2_.get()) << error;
253 extension_info_map_ = new ExtensionInfoMap; 253 extension_info_map_ = new InfoMap;
254 ASSERT_TRUE(extension_info_map_.get()); 254 ASSERT_TRUE(extension_info_map_.get());
255 extension_info_map_->AddExtension(extension_.get(), 255 extension_info_map_->AddExtension(extension_.get(),
256 base::Time() + base::TimeDelta::FromDays(1), 256 base::Time() + base::TimeDelta::FromDays(1),
257 false /*incognito_enabled*/); 257 false /*incognito_enabled*/);
258 extension_info_map_->AddExtension(extension2_.get(), 258 extension_info_map_->AddExtension(extension2_.get(),
259 base::Time() + base::TimeDelta::FromDays(2), 259 base::Time() + base::TimeDelta::FromDays(2),
260 false /*incognito_enabled*/); 260 false /*incognito_enabled*/);
261 } 261 }
262 262
263 263
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 800
801 // This is a correct match. 801 // This is a correct match.
802 GURL url2("http://foo.com/index.html"); 802 GURL url2("http://foo.com/index.html");
803 net::TestURLRequest request2(url2, net::DEFAULT_PRIORITY, NULL, &context); 803 net::TestURLRequest request2(url2, net::DEFAULT_PRIORITY, NULL, &context);
804 WebRequestData request_data2(&request2, ON_BEFORE_REQUEST); 804 WebRequestData request_data2(&request2, ON_BEFORE_REQUEST);
805 deltas = registry->CreateDeltas(NULL, request_data2, false); 805 deltas = registry->CreateDeltas(NULL, request_data2, false);
806 EXPECT_EQ(1u, deltas.size()); 806 EXPECT_EQ(1u, deltas.size());
807 } 807 }
808 808
809 } // namespace extensions 809 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698