| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 test_dictionary_1.CanUse(GURL("http://www.example.com:4/url"))); | 70 test_dictionary_1.CanUse(GURL("http://www.example.com:4/url"))); |
| 71 EXPECT_NE(SDCH_OK, | 71 EXPECT_NE(SDCH_OK, |
| 72 test_dictionary_1.CanUse(GURL("http://www.example.com:2/wurl"))); | 72 test_dictionary_1.CanUse(GURL("http://www.example.com:2/wurl"))); |
| 73 EXPECT_NE(SDCH_OK, | 73 EXPECT_NE(SDCH_OK, |
| 74 test_dictionary_1.CanUse(GURL("https://www.example.com:2/url"))); | 74 test_dictionary_1.CanUse(GURL("https://www.example.com:2/url"))); |
| 75 EXPECT_NE(SDCH_OK, | 75 EXPECT_NE(SDCH_OK, |
| 76 test_dictionary_1.CanUse(GURL("ws://www.example.com:2/url"))); | 76 test_dictionary_1.CanUse(GURL("ws://www.example.com:2/url"))); |
| 77 } | 77 } |
| 78 | 78 |
| 79 TEST(SdchDictionaryTest, PathMatch) { | 79 TEST(SdchDictionaryTest, PathMatch) { |
| 80 bool (*PathMatch)(const std::string& path, const std::string& restriction) = | 80 bool (*PathMatch)(const base::StringPiece& path, |
| 81 const base::StringPiece& restriction) = |
| 81 SdchDictionary::PathMatch; | 82 SdchDictionary::PathMatch; |
| 82 // Perfect match is supported. | 83 // Perfect match is supported. |
| 83 EXPECT_TRUE(PathMatch("/search", "/search")); | 84 EXPECT_TRUE(PathMatch("/search", "/search")); |
| 84 EXPECT_TRUE(PathMatch("/search/", "/search/")); | 85 EXPECT_TRUE(PathMatch("/search/", "/search/")); |
| 85 | 86 |
| 86 // Prefix only works if last character of restriction is a slash, or first | 87 // Prefix only works if last character of restriction is a slash, or first |
| 87 // character in path after a match is a slash. Validate each case separately. | 88 // character in path after a match is a slash. Validate each case separately. |
| 88 | 89 |
| 89 // Rely on the slash in the path (not at the end of the restriction). | 90 // Rely on the slash in the path (not at the end of the restriction). |
| 90 EXPECT_TRUE(PathMatch("/search/something", "/search")); | 91 EXPECT_TRUE(PathMatch("/search/something", "/search")); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 base::Time::Now() - base::TimeDelta::FromSeconds(1), | 124 base::Time::Now() - base::TimeDelta::FromSeconds(1), |
| 124 std::set<int>()).Expired()); | 125 std::set<int>()).Expired()); |
| 125 EXPECT_FALSE( | 126 EXPECT_FALSE( |
| 126 SdchDictionary("xyzzy", 0u, "ch", "sh", GURL("http://www.example.com"), | 127 SdchDictionary("xyzzy", 0u, "ch", "sh", GURL("http://www.example.com"), |
| 127 "www.example.com", "/url", | 128 "www.example.com", "/url", |
| 128 base::Time::Now() + base::TimeDelta::FromSeconds(1), | 129 base::Time::Now() + base::TimeDelta::FromSeconds(1), |
| 129 std::set<int>()).Expired()); | 130 std::set<int>()).Expired()); |
| 130 } | 131 } |
| 131 | 132 |
| 132 } // namespace net | 133 } // namespace net |
| OLD | NEW |