| Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
|
| diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
|
| index 0efc9274c26b9c66fc177b3cac73c26a0555a203..18630d9a3a83884f375d0383f9d55757b19d28b9 100644
|
| --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
|
| +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/basictypes.h"
|
| #include "base/json/json_reader.h"
|
| #include "base/memory/linked_ptr.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/stl_util.h"
|
| #include "base/test/values_test_util.h"
|
| @@ -20,6 +21,7 @@
|
| #include "components/url_matcher/url_matcher_constants.h"
|
| #include "content/public/test/test_browser_thread.h"
|
| #include "net/base/request_priority.h"
|
| +#include "net/url_request/url_request.h"
|
| #include "net/url_request/url_request_test_util.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest-message.h"
|
| @@ -281,9 +283,9 @@ TEST_F(WebRequestRulesRegistryTest, AddRulesImpl) {
|
|
|
| GURL http_url("http://www.example.com");
|
| net::TestURLRequestContext context;
|
| - net::TestURLRequest http_request(
|
| - http_url, net::DEFAULT_PRIORITY, NULL, &context);
|
| - WebRequestData request_data(&http_request, ON_BEFORE_REQUEST);
|
| + scoped_ptr<net::URLRequest> http_request(context.CreateRequest(
|
| + http_url, net::DEFAULT_PRIORITY, NULL, NULL));
|
| + WebRequestData request_data(http_request.get(), ON_BEFORE_REQUEST);
|
| matches = registry->GetMatches(request_data);
|
| EXPECT_EQ(2u, matches.size());
|
|
|
| @@ -295,9 +297,9 @@ TEST_F(WebRequestRulesRegistryTest, AddRulesImpl) {
|
| EXPECT_TRUE(ContainsKey(matches_ids, std::make_pair(kExtensionId, kRuleId2)));
|
|
|
| GURL foobar_url("http://www.foobar.com");
|
| - net::TestURLRequest foobar_request(
|
| - foobar_url, net::DEFAULT_PRIORITY, NULL, &context);
|
| - request_data.request = &foobar_request;
|
| + scoped_ptr<net::URLRequest> foobar_request(context.CreateRequest(
|
| + foobar_url, net::DEFAULT_PRIORITY, NULL, NULL));
|
| + request_data.request = foobar_request.get();
|
| matches = registry->GetMatches(request_data);
|
| EXPECT_EQ(1u, matches.size());
|
| WebRequestRule::GlobalRuleId expected_pair =
|
| @@ -422,8 +424,9 @@ TEST_F(WebRequestRulesRegistryTest, Precedences) {
|
|
|
| GURL url("http://www.google.com");
|
| net::TestURLRequestContext context;
|
| - net::TestURLRequest request(url, net::DEFAULT_PRIORITY, NULL, &context);
|
| - WebRequestData request_data(&request, ON_BEFORE_REQUEST);
|
| + scoped_ptr<net::URLRequest> request(context.CreateRequest(
|
| + url, net::DEFAULT_PRIORITY, NULL, NULL));
|
| + WebRequestData request_data(request.get(), ON_BEFORE_REQUEST);
|
| std::list<LinkedPtrEventResponseDelta> deltas =
|
| registry->CreateDeltas(NULL, request_data, false);
|
|
|
| @@ -470,8 +473,9 @@ TEST_F(WebRequestRulesRegistryTest, Priorities) {
|
|
|
| GURL url("http://www.google.com/index.html");
|
| net::TestURLRequestContext context;
|
| - net::TestURLRequest request(url, net::DEFAULT_PRIORITY, NULL, &context);
|
| - WebRequestData request_data(&request, ON_BEFORE_REQUEST);
|
| + scoped_ptr<net::URLRequest> request(context.CreateRequest(
|
| + url, net::DEFAULT_PRIORITY, NULL, NULL));
|
| + WebRequestData request_data(request.get(), ON_BEFORE_REQUEST);
|
| std::list<LinkedPtrEventResponseDelta> deltas =
|
| registry->CreateDeltas(NULL, request_data, false);
|
|
|
| @@ -543,8 +547,9 @@ TEST_F(WebRequestRulesRegistryTest, IgnoreRulesByTag) {
|
|
|
| GURL url("http://www.foo.com/test");
|
| net::TestURLRequestContext context;
|
| - net::TestURLRequest request(url, net::DEFAULT_PRIORITY, NULL, &context);
|
| - WebRequestData request_data(&request, ON_BEFORE_REQUEST);
|
| + scoped_ptr<net::URLRequest> request(context.CreateRequest(
|
| + url, net::DEFAULT_PRIORITY, NULL, NULL));
|
| + WebRequestData request_data(request.get(), ON_BEFORE_REQUEST);
|
| std::list<LinkedPtrEventResponseDelta> deltas =
|
| registry->CreateDeltas(NULL, request_data, false);
|
|
|
| @@ -592,9 +597,9 @@ TEST_F(WebRequestRulesRegistryTest, GetMatchesCheckFulfilled) {
|
|
|
| GURL http_url("http://www.example.com");
|
| net::TestURLRequestContext context;
|
| - net::TestURLRequest http_request(
|
| - http_url, net::DEFAULT_PRIORITY, NULL, &context);
|
| - WebRequestData request_data(&http_request, ON_BEFORE_REQUEST);
|
| + scoped_ptr<net::URLRequest> http_request(context.CreateRequest(
|
| + http_url, net::DEFAULT_PRIORITY, NULL, NULL));
|
| + WebRequestData request_data(http_request.get(), ON_BEFORE_REQUEST);
|
| matches = registry->GetMatches(request_data);
|
| EXPECT_EQ(1u, matches.size());
|
| WebRequestRule::GlobalRuleId expected_pair = std::make_pair(kExtensionId,
|
| @@ -649,10 +654,10 @@ TEST_F(WebRequestRulesRegistryTest, GetMatchesDifferentUrls) {
|
|
|
| for (size_t i = 0; i < arraysize(matchingRuleIds); ++i) {
|
| // Construct the inputs.
|
| - net::TestURLRequest http_request(
|
| - urls[i], net::DEFAULT_PRIORITY, NULL, &context);
|
| - WebRequestData request_data(&http_request, ON_BEFORE_REQUEST);
|
| - http_request.set_first_party_for_cookies(firstPartyUrls[i]);
|
| + scoped_ptr<net::URLRequest> http_request(context.CreateRequest(
|
| + urls[i], net::DEFAULT_PRIORITY, NULL, NULL));
|
| + WebRequestData request_data(http_request.get(), ON_BEFORE_REQUEST);
|
| + http_request->set_first_party_for_cookies(firstPartyUrls[i]);
|
| // Now run both rules on the input.
|
| matches = registry->GetMatches(request_data);
|
| SCOPED_TRACE(testing::Message("i = ") << i << ", rule id = "
|
| @@ -798,15 +803,17 @@ TEST_F(WebRequestRulesRegistryTest, CheckOriginAndPathRegEx) {
|
|
|
| // No match because match is in the query parameter.
|
| GURL url1("http://bar.com/index.html?foo.com");
|
| - net::TestURLRequest request1(url1, net::DEFAULT_PRIORITY, NULL, &context);
|
| - WebRequestData request_data1(&request1, ON_BEFORE_REQUEST);
|
| + scoped_ptr<net::URLRequest> request1(context.CreateRequest(
|
| + url1, net::DEFAULT_PRIORITY, NULL, NULL));
|
| + WebRequestData request_data1(request1.get(), ON_BEFORE_REQUEST);
|
| deltas = registry->CreateDeltas(NULL, request_data1, false);
|
| EXPECT_EQ(0u, deltas.size());
|
|
|
| // This is a correct match.
|
| GURL url2("http://foo.com/index.html");
|
| - net::TestURLRequest request2(url2, net::DEFAULT_PRIORITY, NULL, &context);
|
| - WebRequestData request_data2(&request2, ON_BEFORE_REQUEST);
|
| + scoped_ptr<net::URLRequest> request2(context.CreateRequest(
|
| + url2, net::DEFAULT_PRIORITY, NULL, NULL));
|
| + WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST);
|
| deltas = registry->CreateDeltas(NULL, request_data2, false);
|
| EXPECT_EQ(1u, deltas.size());
|
| }
|
|
|