OLD | NEW |
---|---|
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 TEST(URLPatternSetTest, Two) { | 53 TEST(URLPatternSetTest, Two) { |
54 URLPatternSet set; | 54 URLPatternSet set; |
55 AddPattern(&set, "http://www.google.com/*"); | 55 AddPattern(&set, "http://www.google.com/*"); |
56 AddPattern(&set, "http://www.yahoo.com/*"); | 56 AddPattern(&set, "http://www.yahoo.com/*"); |
57 | 57 |
58 EXPECT_TRUE(set.MatchesURL(GURL("http://www.google.com/monkey"))); | 58 EXPECT_TRUE(set.MatchesURL(GURL("http://www.google.com/monkey"))); |
59 EXPECT_TRUE(set.MatchesURL(GURL("http://www.yahoo.com/monkey"))); | 59 EXPECT_TRUE(set.MatchesURL(GURL("http://www.yahoo.com/monkey"))); |
60 EXPECT_FALSE(set.MatchesURL(GURL("https://www.apple.com/monkey"))); | 60 EXPECT_FALSE(set.MatchesURL(GURL("https://www.apple.com/monkey"))); |
61 } | 61 } |
62 | 62 |
63 TEST(URLPatternSetTest, StreamOperatorEmpty) { | |
64 URLPatternSet set; | |
65 | |
66 std::ostringstream stream; | |
Jeffrey Yasskin
2014/05/28 22:32:04
This should probably have an <sstream> include als
aboxhall
2014/05/28 22:44:10
Done.
| |
67 stream << set; | |
68 EXPECT_EQ("{ }", stream.str()); | |
69 } | |
70 | |
71 TEST(URLPatternSetTest, StreamOperatorOne) { | |
72 URLPatternSet set; | |
73 AddPattern(&set, "http://www.google.com/*"); | |
74 | |
75 std::ostringstream stream; | |
76 stream << set; | |
77 EXPECT_EQ("{ \"http://www.google.com/*\" }", stream.str()); | |
78 } | |
79 | |
80 TEST(URLPatternSetTest, StreamOperatorTwo) { | |
81 URLPatternSet set; | |
82 AddPattern(&set, "http://www.google.com/*"); | |
83 AddPattern(&set, "http://www.yahoo.com/*"); | |
84 | |
85 std::ostringstream stream; | |
86 stream << set; | |
87 EXPECT_EQ("{ \"http://www.google.com/*\", \"http://www.yahoo.com/*\" }", | |
88 stream.str()); | |
89 } | |
90 | |
63 TEST(URLPatternSetTest, OverlapsWith) { | 91 TEST(URLPatternSetTest, OverlapsWith) { |
64 URLPatternSet set1; | 92 URLPatternSet set1; |
65 AddPattern(&set1, "http://www.google.com/f*"); | 93 AddPattern(&set1, "http://www.google.com/f*"); |
66 AddPattern(&set1, "http://www.yahoo.com/b*"); | 94 AddPattern(&set1, "http://www.yahoo.com/b*"); |
67 | 95 |
68 URLPatternSet set2; | 96 URLPatternSet set2; |
69 AddPattern(&set2, "http://www.reddit.com/f*"); | 97 AddPattern(&set2, "http://www.reddit.com/f*"); |
70 AddPattern(&set2, "http://www.yahoo.com/z*"); | 98 AddPattern(&set2, "http://www.yahoo.com/z*"); |
71 | 99 |
72 URLPatternSet set3; | 100 URLPatternSet set3; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 AddPattern(&expected, yahoo_b); | 413 AddPattern(&expected, yahoo_b); |
386 AddPattern(&expected, yahoo_c); | 414 AddPattern(&expected, yahoo_c); |
387 AddPattern(&expected, reddit_a); | 415 AddPattern(&expected, reddit_a); |
388 AddPattern(&expected, reddit_b); | 416 AddPattern(&expected, reddit_b); |
389 AddPattern(&expected, reddit_c); | 417 AddPattern(&expected, reddit_c); |
390 EXPECT_EQ(expected, result); | 418 EXPECT_EQ(expected, result); |
391 } | 419 } |
392 } | 420 } |
393 | 421 |
394 } // namespace extensions | 422 } // namespace extensions |
OLD | NEW |