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

Side by Side Diff: extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc

Issue 1854993002: [Extensions] Remove linked_ptr entirely from extensions generated code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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 unified diff | Download patch
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 "extensions/browser/api/declarative_webrequest/webrequest_condition.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_condition.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 data = WebRequestData(https_request.get(), ON_BEFORE_REQUEST); 247 data = WebRequestData(https_request.get(), ON_BEFORE_REQUEST);
248 EXPECT_TRUE(condition_empty->IsFulfilled(WebRequestDataWithMatchIds(&data))); 248 EXPECT_TRUE(condition_empty->IsFulfilled(WebRequestDataWithMatchIds(&data)));
249 } 249 }
250 250
251 TEST(WebRequestConditionTest, CreateConditionSet) { 251 TEST(WebRequestConditionTest, CreateConditionSet) {
252 // Necessary for TestURLRequest. 252 // Necessary for TestURLRequest.
253 base::MessageLoopForIO message_loop; 253 base::MessageLoopForIO message_loop;
254 URLMatcher matcher; 254 URLMatcher matcher;
255 255
256 WebRequestConditionSet::Values conditions; 256 WebRequestConditionSet::Values conditions;
257 conditions.push_back(linked_ptr<base::Value>(base::test::ParseJson( 257 conditions.push_back(base::test::ParseJson(
258 "{ \n" 258 "{ \n"
259 " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" 259 " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
260 " \"url\": { \n" 260 " \"url\": { \n"
261 " \"hostSuffix\": \"example.com\", \n" 261 " \"hostSuffix\": \"example.com\", \n"
262 " \"schemes\": [\"http\"], \n" 262 " \"schemes\": [\"http\"], \n"
263 " }, \n" 263 " }, \n"
264 "}").release())); 264 "}"));
265 conditions.push_back(linked_ptr<base::Value>(base::test::ParseJson( 265 conditions.push_back(base::test::ParseJson(
266 "{ \n" 266 "{ \n"
267 " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" 267 " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
268 " \"url\": { \n" 268 " \"url\": { \n"
269 " \"hostSuffix\": \"example.com\", \n" 269 " \"hostSuffix\": \"example.com\", \n"
270 " \"hostPrefix\": \"www\", \n" 270 " \"hostPrefix\": \"www\", \n"
271 " \"schemes\": [\"https\"], \n" 271 " \"schemes\": [\"https\"], \n"
272 " }, \n" 272 " }, \n"
273 "}").release())); 273 "}"));
274 274
275 // Test insertion 275 // Test insertion
276 std::string error; 276 std::string error;
277 scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create( 277 scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create(
278 NULL, matcher.condition_factory(), conditions, &error); 278 NULL, matcher.condition_factory(), conditions, &error);
279 EXPECT_EQ("", error); 279 EXPECT_EQ("", error);
280 ASSERT_TRUE(result.get()); 280 ASSERT_TRUE(result.get());
281 EXPECT_EQ(2u, result->conditions().size()); 281 EXPECT_EQ(2u, result->conditions().size());
282 282
283 // Tell the URLMatcher about our shiny new patterns. 283 // Tell the URLMatcher about our shiny new patterns.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 data.request = https_foo_request.get(); 316 data.request = https_foo_request.get();
317 EXPECT_FALSE(result->IsFulfilled(-1, request_data)); 317 EXPECT_FALSE(result->IsFulfilled(-1, request_data));
318 } 318 }
319 319
320 TEST(WebRequestConditionTest, TestPortFilter) { 320 TEST(WebRequestConditionTest, TestPortFilter) {
321 // Necessary for TestURLRequest. 321 // Necessary for TestURLRequest.
322 base::MessageLoopForIO message_loop; 322 base::MessageLoopForIO message_loop;
323 URLMatcher matcher; 323 URLMatcher matcher;
324 324
325 WebRequestConditionSet::Values conditions; 325 WebRequestConditionSet::Values conditions;
326 conditions.push_back(linked_ptr<base::Value>(base::test::ParseJson( 326 conditions.push_back(base::test::ParseJson(
327 "{ \n" 327 "{ \n"
328 " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" 328 " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
329 " \"url\": { \n" 329 " \"url\": { \n"
330 " \"ports\": [80, [1000, 1010]], \n" // Allow 80;1000-1010. 330 " \"ports\": [80, [1000, 1010]], \n" // Allow 80;1000-1010.
331 " \"hostSuffix\": \"example.com\", \n" 331 " \"hostSuffix\": \"example.com\", \n"
332 " }, \n" 332 " }, \n"
333 "}").release())); 333 "}"));
334 334
335 // Test insertion 335 // Test insertion
336 std::string error; 336 std::string error;
337 scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create( 337 scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create(
338 NULL, matcher.condition_factory(), conditions, &error); 338 NULL, matcher.condition_factory(), conditions, &error);
339 EXPECT_EQ("", error); 339 EXPECT_EQ("", error);
340 ASSERT_TRUE(result.get()); 340 ASSERT_TRUE(result.get());
341 EXPECT_EQ(1u, result->conditions().size()); 341 EXPECT_EQ(1u, result->conditions().size());
342 342
343 // Tell the URLMatcher about our shiny new patterns. 343 // Tell the URLMatcher about our shiny new patterns.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // filters. 397 // filters.
398 " \"requestHeaders\": [{}], \n" 398 " \"requestHeaders\": [{}], \n"
399 " \"responseHeaders\": [{}], \n" 399 " \"responseHeaders\": [{}], \n"
400 "}"), 400 "}"),
401 &error); 401 &error);
402 EXPECT_FALSE(error.empty()); 402 EXPECT_FALSE(error.empty());
403 EXPECT_FALSE(result.get()); 403 EXPECT_FALSE(result.get());
404 } 404 }
405 405
406 } // namespace extensions 406 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/declarative/rules_registry.h ('k') | extensions/browser/api/system_storage/system_storage_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698