| Index: extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
|
| diff --git a/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc b/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
|
| index 0de50310766516df74125755d6da0a69139d2836..fd955270c3b5cbcd19ff242d84eb7229448ef303 100644
|
| --- a/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
|
| +++ b/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
|
| @@ -4,9 +4,9 @@
|
|
|
| #include "extensions/browser/api/declarative_webrequest/webrequest_condition.h"
|
|
|
| +#include <memory>
|
| #include <set>
|
|
|
| -#include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/test/values_test_util.h"
|
| #include "base/values.h"
|
| @@ -30,7 +30,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
|
| URLMatcher matcher;
|
|
|
| std::string error;
|
| - scoped_ptr<WebRequestCondition> result;
|
| + std::unique_ptr<WebRequestCondition> result;
|
|
|
| // Test wrong condition name passed.
|
| error.clear();
|
| @@ -80,7 +80,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
|
|
|
| net::TestURLRequestContext context;
|
| const GURL http_url("http://www.example.com");
|
| - scoped_ptr<net::URLRequest> match_request(
|
| + std::unique_ptr<net::URLRequest> match_request(
|
| context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL));
|
| WebRequestData data(match_request.get(), ON_BEFORE_REQUEST);
|
| WebRequestDataWithMatchIds request_data(&data);
|
| @@ -100,7 +100,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
|
| EXPECT_TRUE(result->IsFulfilled(request_data));
|
|
|
| const GURL https_url("https://www.example.com");
|
| - scoped_ptr<net::URLRequest> wrong_resource_type(
|
| + std::unique_ptr<net::URLRequest> wrong_resource_type(
|
| context.CreateRequest(https_url, net::DEFAULT_PRIORITY, NULL));
|
| data.request = wrong_resource_type.get();
|
| request_data.url_match_ids = matcher.MatchURL(http_url);
|
| @@ -126,7 +126,7 @@ TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) {
|
| URLMatcher matcher;
|
|
|
| std::string error;
|
| - scoped_ptr<WebRequestCondition> result;
|
| + std::unique_ptr<WebRequestCondition> result;
|
|
|
| result = WebRequestCondition::Create(
|
| NULL,
|
| @@ -147,7 +147,7 @@ TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) {
|
| net::TestURLRequestContext context;
|
| const GURL http_url("http://www.example.com");
|
| const GURL first_party_url("http://fpfc.example.com");
|
| - scoped_ptr<net::URLRequest> match_request(
|
| + std::unique_ptr<net::URLRequest> match_request(
|
| context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL));
|
| WebRequestData data(match_request.get(), ON_BEFORE_REQUEST);
|
| WebRequestDataWithMatchIds request_data(&data);
|
| @@ -183,53 +183,51 @@ TEST(WebRequestConditionTest, NoUrlAttributes) {
|
|
|
| // The empty condition.
|
| error.clear();
|
| - scoped_ptr<WebRequestCondition> condition_empty = WebRequestCondition::Create(
|
| - NULL,
|
| - matcher.condition_factory(),
|
| - *base::test::ParseJson(
|
| - "{ \n"
|
| - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
|
| - "}"),
|
| - &error);
|
| + std::unique_ptr<WebRequestCondition> condition_empty =
|
| + WebRequestCondition::Create(
|
| + NULL, matcher.condition_factory(),
|
| + *base::test::ParseJson(
|
| + "{ \n"
|
| + " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
|
| + "}"),
|
| + &error);
|
| EXPECT_EQ("", error);
|
| ASSERT_TRUE(condition_empty.get());
|
|
|
| // A condition without a UrlFilter attribute, which is always true.
|
| error.clear();
|
| - scoped_ptr<WebRequestCondition> condition_no_url_true =
|
| + std::unique_ptr<WebRequestCondition> condition_no_url_true =
|
| WebRequestCondition::Create(
|
| - NULL,
|
| - matcher.condition_factory(),
|
| + NULL, matcher.condition_factory(),
|
| *base::test::ParseJson(
|
| - "{ \n"
|
| - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", "
|
| - "\n"
|
| - // There is no "1st party for cookies" URL in the requests below,
|
| - // therefore all requests are considered first party for cookies.
|
| - " \"thirdPartyForCookies\": false, \n"
|
| - "}"),
|
| + "{ \n"
|
| + " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", "
|
| + "\n"
|
| + // There is no "1st party for cookies" URL in the requests below,
|
| + // therefore all requests are considered first party for cookies.
|
| + " \"thirdPartyForCookies\": false, \n"
|
| + "}"),
|
| &error);
|
| EXPECT_EQ("", error);
|
| ASSERT_TRUE(condition_no_url_true.get());
|
|
|
| // A condition without a UrlFilter attribute, which is always false.
|
| error.clear();
|
| - scoped_ptr<WebRequestCondition> condition_no_url_false =
|
| + std::unique_ptr<WebRequestCondition> condition_no_url_false =
|
| WebRequestCondition::Create(
|
| - NULL,
|
| - matcher.condition_factory(),
|
| + NULL, matcher.condition_factory(),
|
| *base::test::ParseJson(
|
| - "{ \n"
|
| - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", "
|
| - "\n"
|
| - " \"thirdPartyForCookies\": true, \n"
|
| - "}"),
|
| + "{ \n"
|
| + " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", "
|
| + "\n"
|
| + " \"thirdPartyForCookies\": true, \n"
|
| + "}"),
|
| &error);
|
| EXPECT_EQ("", error);
|
| ASSERT_TRUE(condition_no_url_false.get());
|
|
|
| net::TestURLRequestContext context;
|
| - scoped_ptr<net::URLRequest> https_request(context.CreateRequest(
|
| + std::unique_ptr<net::URLRequest> https_request(context.CreateRequest(
|
| GURL("https://www.example.com"), net::DEFAULT_PRIORITY, NULL));
|
|
|
| // 1. A non-empty condition without UrlFilter attributes is fulfilled iff its
|
| @@ -274,8 +272,9 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
|
|
|
| // Test insertion
|
| std::string error;
|
| - scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create(
|
| - NULL, matcher.condition_factory(), conditions, &error);
|
| + std::unique_ptr<WebRequestConditionSet> result =
|
| + WebRequestConditionSet::Create(NULL, matcher.condition_factory(),
|
| + conditions, &error);
|
| EXPECT_EQ("", error);
|
| ASSERT_TRUE(result.get());
|
| EXPECT_EQ(2u, result->conditions().size());
|
| @@ -289,7 +288,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
|
| // https://www.example.com
|
| GURL http_url("http://www.example.com");
|
| net::TestURLRequestContext context;
|
| - scoped_ptr<net::URLRequest> http_request(
|
| + std::unique_ptr<net::URLRequest> http_request(
|
| context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL));
|
| WebRequestData data(http_request.get(), ON_BEFORE_REQUEST);
|
| WebRequestDataWithMatchIds request_data(&data);
|
| @@ -301,7 +300,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
|
| GURL https_url("https://www.example.com");
|
| request_data.url_match_ids = matcher.MatchURL(https_url);
|
| EXPECT_EQ(1u, request_data.url_match_ids.size());
|
| - scoped_ptr<net::URLRequest> https_request(
|
| + std::unique_ptr<net::URLRequest> https_request(
|
| context.CreateRequest(https_url, net::DEFAULT_PRIORITY, NULL));
|
| data.request = https_request.get();
|
| EXPECT_TRUE(result->IsFulfilled(*(request_data.url_match_ids.begin()),
|
| @@ -311,7 +310,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
|
| GURL https_foo_url("https://foo.example.com");
|
| request_data.url_match_ids = matcher.MatchURL(https_foo_url);
|
| EXPECT_EQ(0u, request_data.url_match_ids.size());
|
| - scoped_ptr<net::URLRequest> https_foo_request(
|
| + std::unique_ptr<net::URLRequest> https_foo_request(
|
| context.CreateRequest(https_foo_url, net::DEFAULT_PRIORITY, NULL));
|
| data.request = https_foo_request.get();
|
| EXPECT_FALSE(result->IsFulfilled(-1, request_data));
|
| @@ -334,8 +333,9 @@ TEST(WebRequestConditionTest, TestPortFilter) {
|
|
|
| // Test insertion
|
| std::string error;
|
| - scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create(
|
| - NULL, matcher.condition_factory(), conditions, &error);
|
| + std::unique_ptr<WebRequestConditionSet> result =
|
| + WebRequestConditionSet::Create(NULL, matcher.condition_factory(),
|
| + conditions, &error);
|
| EXPECT_EQ("", error);
|
| ASSERT_TRUE(result.get());
|
| EXPECT_EQ(1u, result->conditions().size());
|
| @@ -350,25 +350,25 @@ TEST(WebRequestConditionTest, TestPortFilter) {
|
| // Test various URLs.
|
| GURL http_url("http://www.example.com");
|
| net::TestURLRequestContext context;
|
| - scoped_ptr<net::URLRequest> http_request(
|
| + std::unique_ptr<net::URLRequest> http_request(
|
| context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL));
|
| url_match_ids = matcher.MatchURL(http_url);
|
| ASSERT_EQ(1u, url_match_ids.size());
|
|
|
| GURL http_url_80("http://www.example.com:80");
|
| - scoped_ptr<net::URLRequest> http_request_80(
|
| + std::unique_ptr<net::URLRequest> http_request_80(
|
| context.CreateRequest(http_url_80, net::DEFAULT_PRIORITY, NULL));
|
| url_match_ids = matcher.MatchURL(http_url_80);
|
| ASSERT_EQ(1u, url_match_ids.size());
|
|
|
| GURL http_url_1000("http://www.example.com:1000");
|
| - scoped_ptr<net::URLRequest> http_request_1000(
|
| + std::unique_ptr<net::URLRequest> http_request_1000(
|
| context.CreateRequest(http_url_1000, net::DEFAULT_PRIORITY, NULL));
|
| url_match_ids = matcher.MatchURL(http_url_1000);
|
| ASSERT_EQ(1u, url_match_ids.size());
|
|
|
| GURL http_url_2000("http://www.example.com:2000");
|
| - scoped_ptr<net::URLRequest> http_request_2000(
|
| + std::unique_ptr<net::URLRequest> http_request_2000(
|
| context.CreateRequest(http_url_2000, net::DEFAULT_PRIORITY, NULL));
|
| url_match_ids = matcher.MatchURL(http_url_2000);
|
| ASSERT_EQ(0u, url_match_ids.size());
|
| @@ -383,7 +383,7 @@ TEST(WebRequestConditionTest, ConditionsWithConflictingStages) {
|
| URLMatcher matcher;
|
|
|
| std::string error;
|
| - scoped_ptr<WebRequestCondition> result;
|
| + std::unique_ptr<WebRequestCondition> result;
|
|
|
| // Test error on incompatible application stages for involved attributes.
|
| error.clear();
|
|
|