| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tools/dump_cache/url_to_filename_encoder.h" | 5 #include "net/tools/dump_cache/url_to_filename_encoder.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 |
| 9 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 using base::StringPiece; | 15 using base::StringPiece; |
| 14 using std::string; | 16 using std::string; |
| 15 | 17 |
| 16 namespace net { | 18 namespace net { |
| 17 | 19 |
| 18 #ifdef WIN32 | 20 #ifdef WIN32 |
| 19 char kDirSeparator = '\\'; | 21 char kDirSeparator = '\\'; |
| 20 char kOtherDirSeparator = '/'; | 22 char kOtherDirSeparator = '/'; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 206 |
| 205 "blogutils.net" + dir_sep_ + "olct" + dir_sep_ + "online.php" + escape_ + | 207 "blogutils.net" + dir_sep_ + "olct" + dir_sep_ + "online.php" + escape_ + |
| 206 "3Fsite=http" + escape_ + "3A" + dir_sep_ + escape_ + | 208 "3Fsite=http" + escape_ + "3A" + dir_sep_ + escape_ + |
| 207 "2Fthelwordfanfics.blogspot." + escape_ + "26interval=600" + escape_); | 209 "2Fthelwordfanfics.blogspot." + escape_ + "26interval=600" + escape_); |
| 208 } | 210 } |
| 209 | 211 |
| 210 // From bug: Escapes treated the same as normal char. | 212 // From bug: Escapes treated the same as normal char. |
| 211 TEST_F(UrlToFilenameEncoderTest, UnescapeUrlsBeforeEncode) { | 213 TEST_F(UrlToFilenameEncoderTest, UnescapeUrlsBeforeEncode) { |
| 212 for (int i = 0; i < 128; ++i) { | 214 for (int i = 0; i < 128; ++i) { |
| 213 string unescaped(1, static_cast<char>(i)); | 215 string unescaped(1, static_cast<char>(i)); |
| 214 string escaped = StringPrintf("%%%02X", i); | 216 string escaped = base::StringPrintf("%%%02X", i); |
| 215 ValidateEncodeSame(unescaped, escaped); | 217 ValidateEncodeSame(unescaped, escaped); |
| 216 } | 218 } |
| 217 | 219 |
| 218 ValidateEncodeSame( | 220 ValidateEncodeSame( |
| 219 "http://www.blogger.com/navbar.g?bName=God!&Mode=FOO&searchRoot" | 221 "http://www.blogger.com/navbar.g?bName=God!&Mode=FOO&searchRoot" |
| 220 "=http%3A%2F%2Fsurvivorscanthrive.blogspot.com%2Fsearch", | 222 "=http%3A%2F%2Fsurvivorscanthrive.blogspot.com%2Fsearch", |
| 221 | 223 |
| 222 "http://www.blogger.com/navbar.g?bName=God%21&Mode=FOO&searchRoot" | 224 "http://www.blogger.com/navbar.g?bName=God%21&Mode=FOO&searchRoot" |
| 223 "=http%3A%2F%2Fsurvivorscanthrive.blogspot.com%2Fsearch"); | 225 "=http%3A%2F%2Fsurvivorscanthrive.blogspot.com%2Fsearch"); |
| 224 } | 226 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 EXPECT_EQ(long_word.size() + 4, escaped_word.size()); | 332 EXPECT_EQ(long_word.size() + 4, escaped_word.size()); |
| 331 ASSERT_LT(UrlToFilenameEncoder::kMaximumSubdirectoryLength, | 333 ASSERT_LT(UrlToFilenameEncoder::kMaximumSubdirectoryLength, |
| 332 escaped_word.size()); | 334 escaped_word.size()); |
| 333 // Check that the backslash got inserted at the correct spot. | 335 // Check that the backslash got inserted at the correct spot. |
| 334 EXPECT_EQ('\\', escaped_word[ | 336 EXPECT_EQ('\\', escaped_word[ |
| 335 UrlToFilenameEncoder::kMaximumSubdirectoryLength]); | 337 UrlToFilenameEncoder::kMaximumSubdirectoryLength]); |
| 336 } | 338 } |
| 337 | 339 |
| 338 } // namespace net | 340 } // namespace net |
| 339 | 341 |
| OLD | NEW |