| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "chrome/common/extensions/url_pattern.h" | 5 #include "chrome/common/extensions/url_pattern.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 // See url_pattern.h for examples of valid and invalid patterns. | 8 // See url_pattern.h for examples of valid and invalid patterns. |
| 9 | 9 |
| 10 TEST(URLPatternTest, ParseInvalid) { | 10 TEST(URLPatternTest, ParseInvalid) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://google.com/foobar"))); | 63 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://google.com/foobar"))); |
| 64 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://www.google.com/foo?bar"))); | 64 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://www.google.com/foo?bar"))); |
| 65 EXPECT_TRUE(pattern.MatchesUrl( | 65 EXPECT_TRUE(pattern.MatchesUrl( |
| 66 GURL("http://monkey.images.google.com/foooobar"))); | 66 GURL("http://monkey.images.google.com/foooobar"))); |
| 67 EXPECT_FALSE(pattern.MatchesUrl(GURL("http://yahoo.com/foobar"))); | 67 EXPECT_FALSE(pattern.MatchesUrl(GURL("http://yahoo.com/foobar"))); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // odd schemes and normalization | 70 // odd schemes and normalization |
| 71 TEST(URLPatternTest, Match4) { | 71 TEST(URLPatternTest, Match4) { |
| 72 URLPattern pattern; | 72 URLPattern pattern; |
| 73 EXPECT_TRUE(pattern.Parse("chrome-ui://thinger/*")); | 73 EXPECT_TRUE(pattern.Parse("chrome://thinger/*")); |
| 74 EXPECT_EQ("chrome-ui", pattern.scheme()); | 74 EXPECT_EQ("chrome", pattern.scheme()); |
| 75 EXPECT_EQ("thinger", pattern.host()); | 75 EXPECT_EQ("thinger", pattern.host()); |
| 76 EXPECT_FALSE(pattern.match_subdomains()); | 76 EXPECT_FALSE(pattern.match_subdomains()); |
| 77 EXPECT_EQ("/*", pattern.path()); | 77 EXPECT_EQ("/*", pattern.path()); |
| 78 EXPECT_TRUE(pattern.MatchesUrl(GURL("chrome-ui://thinger/foobar"))); | 78 EXPECT_TRUE(pattern.MatchesUrl(GURL("chrome://thinger/foobar"))); |
| 79 EXPECT_TRUE(pattern.MatchesUrl(GURL("CHROME-UI://thinger/"))); | 79 EXPECT_TRUE(pattern.MatchesUrl(GURL("CHROME://thinger/"))); |
| 80 EXPECT_FALSE(pattern.MatchesUrl(GURL("http://thinger/"))); | 80 EXPECT_FALSE(pattern.MatchesUrl(GURL("http://thinger/"))); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // glob escaping | 83 // glob escaping |
| 84 TEST(URLPatternTest, Match5) { | 84 TEST(URLPatternTest, Match5) { |
| 85 URLPattern pattern; | 85 URLPattern pattern; |
| 86 EXPECT_TRUE(pattern.Parse("file:///foo?bar\\*baz")); | 86 EXPECT_TRUE(pattern.Parse("file:///foo?bar\\*baz")); |
| 87 EXPECT_EQ("file", pattern.scheme()); | 87 EXPECT_EQ("file", pattern.scheme()); |
| 88 EXPECT_EQ("", pattern.host()); | 88 EXPECT_EQ("", pattern.host()); |
| 89 EXPECT_FALSE(pattern.match_subdomains()); | 89 EXPECT_FALSE(pattern.match_subdomains()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 EXPECT_TRUE(pattern.Parse("http://*.xn--gkd/a%C2%81%E1*")); | 123 EXPECT_TRUE(pattern.Parse("http://*.xn--gkd/a%C2%81%E1*")); |
| 124 EXPECT_EQ("http", pattern.scheme()); | 124 EXPECT_EQ("http", pattern.scheme()); |
| 125 EXPECT_EQ("xn--gkd", pattern.host()); | 125 EXPECT_EQ("xn--gkd", pattern.host()); |
| 126 EXPECT_TRUE(pattern.match_subdomains()); | 126 EXPECT_TRUE(pattern.match_subdomains()); |
| 127 EXPECT_EQ("/a%C2%81%E1*", pattern.path()); | 127 EXPECT_EQ("/a%C2%81%E1*", pattern.path()); |
| 128 EXPECT_TRUE(pattern.MatchesUrl( | 128 EXPECT_TRUE(pattern.MatchesUrl( |
| 129 GURL("http://abc.\xe1\x80\xbf/a\xc2\x81\xe1xyz"))); | 129 GURL("http://abc.\xe1\x80\xbf/a\xc2\x81\xe1xyz"))); |
| 130 EXPECT_TRUE(pattern.MatchesUrl( | 130 EXPECT_TRUE(pattern.MatchesUrl( |
| 131 GURL("http://\xe1\x80\xbf/a\xc2\x81\xe1\xe1"))); | 131 GURL("http://\xe1\x80\xbf/a\xc2\x81\xe1\xe1"))); |
| 132 }; | 132 }; |
| OLD | NEW |