OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "net/base/sdch_dictionary.h" | 5 #include "net/base/sdch_dictionary.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "net/base/sdch_problem_codes.h" | 10 #include "net/base/sdch_problem_codes.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 // Make sure adding characters to path will also fail. | 110 // Make sure adding characters to path will also fail. |
111 EXPECT_FALSE(PathMatch("/searching", "/search/")); | 111 EXPECT_FALSE(PathMatch("/searching", "/search/")); |
112 EXPECT_FALSE(PathMatch("/searching", "/search")); | 112 EXPECT_FALSE(PathMatch("/searching", "/search")); |
113 | 113 |
114 // Make sure we're case sensitive. | 114 // Make sure we're case sensitive. |
115 EXPECT_FALSE(PathMatch("/ABC", "/abc")); | 115 EXPECT_FALSE(PathMatch("/ABC", "/abc")); |
116 EXPECT_FALSE(PathMatch("/abc", "/ABC")); | 116 EXPECT_FALSE(PathMatch("/abc", "/ABC")); |
117 } | 117 } |
118 | 118 |
| 119 TEST(SdchDictionaryTest, DomainMatch) { |
| 120 bool (*DomainMatch)(const GURL& url, const std::string& restriction) = |
| 121 SdchDictionary::DomainMatch; |
| 122 EXPECT_TRUE(DomainMatch(GURL("http://example.com"), "example.com")); |
| 123 EXPECT_TRUE(DomainMatch(GURL("http://www.example.com"), ".example.com")); |
| 124 |
| 125 // Trailing dot handling |
| 126 EXPECT_TRUE(DomainMatch(GURL("http://example.com./"), "example.com")); |
| 127 EXPECT_TRUE(DomainMatch(GURL("http://example.com/"), "example.com.")); |
| 128 |
| 129 EXPECT_FALSE(DomainMatch(GURL("http://www.example.com"), "example.com")); |
| 130 EXPECT_FALSE(DomainMatch(GURL("http://badexample.com"), "example.com")); |
| 131 EXPECT_FALSE(DomainMatch(GURL("http://badexample.com"), ".example.com")); |
| 132 EXPECT_FALSE(DomainMatch(GURL("http://example.com.tld"), "example.com")); |
| 133 EXPECT_FALSE(DomainMatch(GURL("http://example.com.tld"), ".example.com")); |
| 134 } |
| 135 |
119 TEST(SdchDictionaryTest, Expired) { | 136 TEST(SdchDictionaryTest, Expired) { |
120 EXPECT_TRUE( | 137 EXPECT_TRUE( |
121 SdchDictionary("xyzzy", 0u, "ch", "sh", GURL("http://www.example.com"), | 138 SdchDictionary("xyzzy", 0u, "ch", "sh", GURL("http://www.example.com"), |
122 "www.example.com", "/url", | 139 "www.example.com", "/url", |
123 base::Time::Now() - base::TimeDelta::FromSeconds(1), | 140 base::Time::Now() - base::TimeDelta::FromSeconds(1), |
124 std::set<int>()).Expired()); | 141 std::set<int>()).Expired()); |
125 EXPECT_FALSE( | 142 EXPECT_FALSE( |
126 SdchDictionary("xyzzy", 0u, "ch", "sh", GURL("http://www.example.com"), | 143 SdchDictionary("xyzzy", 0u, "ch", "sh", GURL("http://www.example.com"), |
127 "www.example.com", "/url", | 144 "www.example.com", "/url", |
128 base::Time::Now() + base::TimeDelta::FromSeconds(1), | 145 base::Time::Now() + base::TimeDelta::FromSeconds(1), |
129 std::set<int>()).Expired()); | 146 std::set<int>()).Expired()); |
130 } | 147 } |
131 | 148 |
132 } // namespace net | 149 } // namespace net |
OLD | NEW |