| 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 19 matching lines...) Expand all Loading... |
| 30 URLPattern pattern; | 30 URLPattern pattern; |
| 31 EXPECT_TRUE(pattern.Parse("http://*/*")); | 31 EXPECT_TRUE(pattern.Parse("http://*/*")); |
| 32 EXPECT_EQ("http", pattern.scheme()); | 32 EXPECT_EQ("http", pattern.scheme()); |
| 33 EXPECT_EQ("", pattern.host()); | 33 EXPECT_EQ("", pattern.host()); |
| 34 EXPECT_TRUE(pattern.match_subdomains()); | 34 EXPECT_TRUE(pattern.match_subdomains()); |
| 35 EXPECT_EQ("/*", pattern.path()); | 35 EXPECT_EQ("/*", pattern.path()); |
| 36 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://google.com"))); | 36 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://google.com"))); |
| 37 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://yahoo.com"))); | 37 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://yahoo.com"))); |
| 38 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://google.com/foo"))); | 38 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://google.com/foo"))); |
| 39 EXPECT_FALSE(pattern.MatchesUrl(GURL("https://google.com"))); | 39 EXPECT_FALSE(pattern.MatchesUrl(GURL("https://google.com"))); |
| 40 EXPECT_TRUE(pattern.MatchesUrl(GURL("http://74.125.127.100/search"))); |
| 40 } | 41 } |
| 41 | 42 |
| 42 // all domains | 43 // all domains |
| 43 TEST(URLPatternTest, Match2) { | 44 TEST(URLPatternTest, Match2) { |
| 44 URLPattern pattern; | 45 URLPattern pattern; |
| 45 EXPECT_TRUE(pattern.Parse("https://*/foo*")); | 46 EXPECT_TRUE(pattern.Parse("https://*/foo*")); |
| 46 EXPECT_EQ("https", pattern.scheme()); | 47 EXPECT_EQ("https", pattern.scheme()); |
| 47 EXPECT_EQ("", pattern.host()); | 48 EXPECT_EQ("", pattern.host()); |
| 48 EXPECT_TRUE(pattern.match_subdomains()); | 49 EXPECT_TRUE(pattern.match_subdomains()); |
| 49 EXPECT_EQ("/foo*", pattern.path()); | 50 EXPECT_EQ("/foo*", pattern.path()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 EXPECT_TRUE(pattern.Parse("http://*.xn--gkd/a%C2%81%E1*")); | 112 EXPECT_TRUE(pattern.Parse("http://*.xn--gkd/a%C2%81%E1*")); |
| 112 EXPECT_EQ("http", pattern.scheme()); | 113 EXPECT_EQ("http", pattern.scheme()); |
| 113 EXPECT_EQ("xn--gkd", pattern.host()); | 114 EXPECT_EQ("xn--gkd", pattern.host()); |
| 114 EXPECT_TRUE(pattern.match_subdomains()); | 115 EXPECT_TRUE(pattern.match_subdomains()); |
| 115 EXPECT_EQ("/a%C2%81%E1*", pattern.path()); | 116 EXPECT_EQ("/a%C2%81%E1*", pattern.path()); |
| 116 EXPECT_TRUE(pattern.MatchesUrl( | 117 EXPECT_TRUE(pattern.MatchesUrl( |
| 117 GURL("http://abc.\xe1\x80\xbf/a\xc2\x81\xe1xyz"))); | 118 GURL("http://abc.\xe1\x80\xbf/a\xc2\x81\xe1xyz"))); |
| 118 EXPECT_TRUE(pattern.MatchesUrl( | 119 EXPECT_TRUE(pattern.MatchesUrl( |
| 119 GURL("http://\xe1\x80\xbf/a\xc2\x81\xe1\xe1"))); | 120 GURL("http://\xe1\x80\xbf/a\xc2\x81\xe1\xe1"))); |
| 120 }; | 121 }; |
| OLD | NEW |