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

Side by Side Diff: extensions/common/url_pattern_set_unittest.cc

Issue 225493002: cleanup: cpplint src/extension/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comment Created 6 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
« no previous file with comments | « extensions/common/url_pattern_set.h ('k') | extensions/common/url_pattern_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/url_pattern_set.h" 5 #include "extensions/common/url_pattern_set.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 10
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 URLPatternSet Patterns(const std::string& pattern1, 26 URLPatternSet Patterns(const std::string& pattern1,
27 const std::string& pattern2) { 27 const std::string& pattern2) {
28 URLPatternSet set; 28 URLPatternSet set;
29 AddPattern(&set, pattern1); 29 AddPattern(&set, pattern1);
30 AddPattern(&set, pattern2); 30 AddPattern(&set, pattern2);
31 return set; 31 return set;
32 } 32 }
33 33
34 } 34 } // namespace
35 35
36 TEST(URLPatternSetTest, Empty) { 36 TEST(URLPatternSetTest, Empty) {
37 URLPatternSet set; 37 URLPatternSet set;
38 EXPECT_FALSE(set.MatchesURL(GURL("http://www.foo.com/bar"))); 38 EXPECT_FALSE(set.MatchesURL(GURL("http://www.foo.com/bar")));
39 EXPECT_FALSE(set.MatchesURL(GURL())); 39 EXPECT_FALSE(set.MatchesURL(GURL()));
40 EXPECT_FALSE(set.MatchesURL(GURL("invalid"))); 40 EXPECT_FALSE(set.MatchesURL(GURL("invalid")));
41 } 41 }
42 42
43 TEST(URLPatternSetTest, One) { 43 TEST(URLPatternSetTest, One) {
44 URLPatternSet set; 44 URLPatternSet set;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 URLPatternSet result; 270 URLPatternSet result;
271 URLPatternSet::CreateUnion(test, &result); 271 URLPatternSet::CreateUnion(test, &result);
272 272
273 URLPatternSet expected = Patterns(google_a); 273 URLPatternSet expected = Patterns(google_a);
274 EXPECT_EQ(expected, result); 274 EXPECT_EQ(expected, result);
275 } 275 }
276 276
277 // List with 2 elements. 277 // List with 2 elements.
278 { 278 {
279
280 std::vector<URLPatternSet> test; 279 std::vector<URLPatternSet> test;
281 test.push_back(Patterns(google_a, google_b)); 280 test.push_back(Patterns(google_a, google_b));
282 test.push_back(Patterns(google_b, google_c)); 281 test.push_back(Patterns(google_b, google_c));
283 282
284 URLPatternSet result; 283 URLPatternSet result;
285 URLPatternSet::CreateUnion(test, &result); 284 URLPatternSet::CreateUnion(test, &result);
286 285
287 URLPatternSet expected; 286 URLPatternSet expected;
288 AddPattern(&expected, google_a); 287 AddPattern(&expected, google_a);
289 AddPattern(&expected, google_b); 288 AddPattern(&expected, google_b);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 AddPattern(&expected, yahoo_a); 356 AddPattern(&expected, yahoo_a);
358 AddPattern(&expected, yahoo_b); 357 AddPattern(&expected, yahoo_b);
359 AddPattern(&expected, yahoo_c); 358 AddPattern(&expected, yahoo_c);
360 AddPattern(&expected, reddit_a); 359 AddPattern(&expected, reddit_a);
361 AddPattern(&expected, reddit_b); 360 AddPattern(&expected, reddit_b);
362 EXPECT_EQ(expected, result); 361 EXPECT_EQ(expected, result);
363 } 362 }
364 363
365 // List with 9 elements. 364 // List with 9 elements.
366 { 365 {
367
368 std::vector<URLPatternSet> test; 366 std::vector<URLPatternSet> test;
369 test.push_back(Patterns(google_a)); 367 test.push_back(Patterns(google_a));
370 test.push_back(Patterns(google_b)); 368 test.push_back(Patterns(google_b));
371 test.push_back(Patterns(google_c)); 369 test.push_back(Patterns(google_c));
372 test.push_back(Patterns(yahoo_a)); 370 test.push_back(Patterns(yahoo_a));
373 test.push_back(Patterns(yahoo_b)); 371 test.push_back(Patterns(yahoo_b));
374 test.push_back(Patterns(yahoo_c)); 372 test.push_back(Patterns(yahoo_c));
375 test.push_back(Patterns(reddit_a)); 373 test.push_back(Patterns(reddit_a));
376 test.push_back(Patterns(reddit_b)); 374 test.push_back(Patterns(reddit_b));
377 test.push_back(Patterns(reddit_c)); 375 test.push_back(Patterns(reddit_c));
378 376
379 URLPatternSet result; 377 URLPatternSet result;
380 URLPatternSet::CreateUnion(test, &result); 378 URLPatternSet::CreateUnion(test, &result);
381 379
382 URLPatternSet expected; 380 URLPatternSet expected;
383 AddPattern(&expected, google_a); 381 AddPattern(&expected, google_a);
384 AddPattern(&expected, google_b); 382 AddPattern(&expected, google_b);
385 AddPattern(&expected, google_c); 383 AddPattern(&expected, google_c);
386 AddPattern(&expected, yahoo_a); 384 AddPattern(&expected, yahoo_a);
387 AddPattern(&expected, yahoo_b); 385 AddPattern(&expected, yahoo_b);
388 AddPattern(&expected, yahoo_c); 386 AddPattern(&expected, yahoo_c);
389 AddPattern(&expected, reddit_a); 387 AddPattern(&expected, reddit_a);
390 AddPattern(&expected, reddit_b); 388 AddPattern(&expected, reddit_b);
391 AddPattern(&expected, reddit_c); 389 AddPattern(&expected, reddit_c);
392 EXPECT_EQ(expected, result); 390 EXPECT_EQ(expected, result);
393 } 391 }
394 } 392 }
395 393
396 } // namespace extensions 394 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/url_pattern_set.h ('k') | extensions/common/url_pattern_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698