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

Unified Diff: extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc

Issue 598173003: Run clang-modernize -use-nullptr over src/extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
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 64a9bc8a8fab2fc6e1a63f8104fc3b84f55b7e6f..33097145fc2a05e649561b83a31d270e554028b5 100644
--- a/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
+++ b/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
@@ -35,12 +35,12 @@ TEST(WebRequestConditionTest, CreateCondition) {
// Test wrong condition name passed.
error.clear();
result = WebRequestCondition::Create(
- NULL,
+ nullptr,
matcher.condition_factory(),
*base::test::ParseJson(
- "{ \"invalid\": \"foobar\", \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
- "}"),
+ "{ \"invalid\": \"foobar\", \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
+ "}"),
&error);
EXPECT_FALSE(error.empty());
EXPECT_FALSE(result.get());
@@ -48,13 +48,13 @@ TEST(WebRequestConditionTest, CreateCondition) {
// Test wrong datatype in host_suffix.
error.clear();
result = WebRequestCondition::Create(
- NULL,
+ nullptr,
matcher.condition_factory(),
*base::test::ParseJson(
- "{ \n"
- " \"url\": [], \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
- "}"),
+ "{ \n"
+ " \"url\": [], \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
+ "}"),
&error);
EXPECT_FALSE(error.empty());
EXPECT_FALSE(result.get());
@@ -62,14 +62,14 @@ TEST(WebRequestConditionTest, CreateCondition) {
// Test success (can we support multiple criteria?)
error.clear();
result = WebRequestCondition::Create(
- NULL,
+ nullptr,
matcher.condition_factory(),
*base::test::ParseJson(
- "{ \n"
- " \"resourceType\": [\"main_frame\"], \n"
- " \"url\": { \"hostSuffix\": \"example.com\" }, \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
- "}"),
+ "{ \n"
+ " \"resourceType\": [\"main_frame\"], \n"
+ " \"url\": { \"hostSuffix\": \"example.com\" }, \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
+ "}"),
&error);
EXPECT_EQ("", error);
ASSERT_TRUE(result.get());
@@ -80,8 +80,8 @@ TEST(WebRequestConditionTest, CreateCondition) {
net::TestURLRequestContext context;
const GURL http_url("http://www.example.com");
- scoped_ptr<net::URLRequest> match_request(context.CreateRequest(
- http_url, net::DEFAULT_PRIORITY, NULL, NULL));
+ scoped_ptr<net::URLRequest> match_request(
+ context.CreateRequest(http_url, net::DEFAULT_PRIORITY, nullptr, nullptr));
WebRequestData data(match_request.get(), ON_BEFORE_REQUEST);
WebRequestDataWithMatchIds request_data(&data);
request_data.url_match_ids = matcher.MatchURL(http_url);
@@ -89,7 +89,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
content::ResourceRequestInfo::AllocateForTesting(
match_request.get(),
content::RESOURCE_TYPE_MAIN_FRAME,
- NULL,
+ nullptr,
-1,
-1,
-1,
@@ -98,7 +98,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
const GURL https_url("https://www.example.com");
scoped_ptr<net::URLRequest> wrong_resource_type(context.CreateRequest(
- https_url, net::DEFAULT_PRIORITY, NULL, NULL));
+ https_url, net::DEFAULT_PRIORITY, nullptr, nullptr));
data.request = wrong_resource_type.get();
request_data.url_match_ids = matcher.MatchURL(http_url);
// Make sure IsFulfilled does not fail because of URL matching.
@@ -106,7 +106,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
content::ResourceRequestInfo::AllocateForTesting(
wrong_resource_type.get(),
content::RESOURCE_TYPE_SUB_FRAME,
- NULL,
+ nullptr,
-1,
-1,
-1,
@@ -123,13 +123,13 @@ TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) {
scoped_ptr<WebRequestCondition> result;
result = WebRequestCondition::Create(
- NULL,
+ nullptr,
matcher.condition_factory(),
*base::test::ParseJson(
- "{ \n"
- " \"firstPartyForCookiesUrl\": { \"hostPrefix\": \"fpfc\"}, \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
- "}"),
+ "{ \n"
+ " \"firstPartyForCookiesUrl\": { \"hostPrefix\": \"fpfc\"}, \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
+ "}"),
&error);
EXPECT_EQ("", error);
ASSERT_TRUE(result.get());
@@ -141,8 +141,8 @@ 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(context.CreateRequest(
- http_url, net::DEFAULT_PRIORITY, NULL, NULL));
+ scoped_ptr<net::URLRequest> match_request(
+ context.CreateRequest(http_url, net::DEFAULT_PRIORITY, nullptr, nullptr));
WebRequestData data(match_request.get(), ON_BEFORE_REQUEST);
WebRequestDataWithMatchIds request_data(&data);
request_data.url_match_ids = matcher.MatchURL(http_url);
@@ -152,7 +152,7 @@ TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) {
content::ResourceRequestInfo::AllocateForTesting(
match_request.get(),
content::RESOURCE_TYPE_MAIN_FRAME,
- NULL,
+ nullptr,
-1,
-1,
-1,
@@ -175,12 +175,12 @@ TEST(WebRequestConditionTest, NoUrlAttributes) {
// The empty condition.
error.clear();
scoped_ptr<WebRequestCondition> condition_empty = WebRequestCondition::Create(
- NULL,
+ nullptr,
matcher.condition_factory(),
*base::test::ParseJson(
- "{ \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
- "}"),
+ "{ \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
+ "}"),
&error);
EXPECT_EQ("", error);
ASSERT_TRUE(condition_empty.get());
@@ -189,16 +189,16 @@ TEST(WebRequestConditionTest, NoUrlAttributes) {
error.clear();
scoped_ptr<WebRequestCondition> condition_no_url_true =
WebRequestCondition::Create(
- NULL,
+ nullptr,
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());
@@ -207,21 +207,24 @@ TEST(WebRequestConditionTest, NoUrlAttributes) {
error.clear();
scoped_ptr<WebRequestCondition> condition_no_url_false =
WebRequestCondition::Create(
- NULL,
+ nullptr,
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(
- GURL("https://www.example.com"), net::DEFAULT_PRIORITY, NULL, NULL));
+ scoped_ptr<net::URLRequest> https_request(
+ context.CreateRequest(GURL("https://www.example.com"),
+ net::DEFAULT_PRIORITY,
+ nullptr,
+ nullptr));
// 1. A non-empty condition without UrlFilter attributes is fulfilled iff its
// attributes are fulfilled.
@@ -266,7 +269,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
// Test insertion
std::string error;
scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create(
- NULL, matcher.condition_factory(), conditions, &error);
+ nullptr, matcher.condition_factory(), conditions, &error);
EXPECT_EQ("", error);
ASSERT_TRUE(result.get());
EXPECT_EQ(2u, result->conditions().size());
@@ -280,8 +283,8 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
// https://www.example.com
GURL http_url("http://www.example.com");
net::TestURLRequestContext context;
- scoped_ptr<net::URLRequest> http_request(context.CreateRequest(
- http_url, net::DEFAULT_PRIORITY, NULL, NULL));
+ scoped_ptr<net::URLRequest> http_request(
+ context.CreateRequest(http_url, net::DEFAULT_PRIORITY, nullptr, nullptr));
WebRequestData data(http_request.get(), ON_BEFORE_REQUEST);
WebRequestDataWithMatchIds request_data(&data);
request_data.url_match_ids = matcher.MatchURL(http_url);
@@ -293,7 +296,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
request_data.url_match_ids = matcher.MatchURL(https_url);
EXPECT_EQ(1u, request_data.url_match_ids.size());
scoped_ptr<net::URLRequest> https_request(context.CreateRequest(
- https_url, net::DEFAULT_PRIORITY, NULL, NULL));
+ https_url, net::DEFAULT_PRIORITY, nullptr, nullptr));
data.request = https_request.get();
EXPECT_TRUE(result->IsFulfilled(*(request_data.url_match_ids.begin()),
request_data));
@@ -303,7 +306,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
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(context.CreateRequest(
- https_foo_url, net::DEFAULT_PRIORITY, NULL, NULL));
+ https_foo_url, net::DEFAULT_PRIORITY, nullptr, nullptr));
data.request = https_foo_request.get();
EXPECT_FALSE(result->IsFulfilled(-1, request_data));
}
@@ -326,7 +329,7 @@ TEST(WebRequestConditionTest, TestPortFilter) {
// Test insertion
std::string error;
scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create(
- NULL, matcher.condition_factory(), conditions, &error);
+ nullptr, matcher.condition_factory(), conditions, &error);
EXPECT_EQ("", error);
ASSERT_TRUE(result.get());
EXPECT_EQ(1u, result->conditions().size());
@@ -341,26 +344,26 @@ TEST(WebRequestConditionTest, TestPortFilter) {
// Test various URLs.
GURL http_url("http://www.example.com");
net::TestURLRequestContext context;
- scoped_ptr<net::URLRequest> http_request(context.CreateRequest(
- http_url, net::DEFAULT_PRIORITY, NULL, NULL));
+ scoped_ptr<net::URLRequest> http_request(
+ context.CreateRequest(http_url, net::DEFAULT_PRIORITY, nullptr, nullptr));
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(context.CreateRequest(
- http_url_80, net::DEFAULT_PRIORITY, NULL, NULL));
+ http_url_80, net::DEFAULT_PRIORITY, nullptr, nullptr));
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(context.CreateRequest(
- http_url_1000, net::DEFAULT_PRIORITY, NULL, NULL));
+ http_url_1000, net::DEFAULT_PRIORITY, nullptr, nullptr));
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(context.CreateRequest(
- http_url_2000, net::DEFAULT_PRIORITY, NULL, NULL));
+ http_url_2000, net::DEFAULT_PRIORITY, nullptr, nullptr));
url_match_ids = matcher.MatchURL(http_url_2000);
ASSERT_EQ(0u, url_match_ids.size());
}
@@ -379,16 +382,16 @@ TEST(WebRequestConditionTest, ConditionsWithConflictingStages) {
// Test error on incompatible application stages for involved attributes.
error.clear();
result = WebRequestCondition::Create(
- NULL,
+ nullptr,
matcher.condition_factory(),
*base::test::ParseJson(
- "{ \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
- // Pass a JS array with one empty object to each of the header
- // filters.
- " \"requestHeaders\": [{}], \n"
- " \"responseHeaders\": [{}], \n"
- "}"),
+ "{ \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
+ // Pass a JS array with one empty object to each of the header
+ // filters.
+ " \"requestHeaders\": [{}], \n"
+ " \"responseHeaders\": [{}], \n"
+ "}"),
&error);
EXPECT_FALSE(error.empty());
EXPECT_FALSE(result.get());

Powered by Google App Engine
This is Rietveld 408576698