OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/file_util.h" | 5 #include "extensions/common/file_util.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 "simple.html" }, | 415 "simple.html" }, |
416 { URL_PREFIX "/simple.html", | 416 { URL_PREFIX "/simple.html", |
417 "simple.html" }, | 417 "simple.html" }, |
418 { URL_PREFIX "\\simple.html", | 418 { URL_PREFIX "\\simple.html", |
419 "simple.html" }, | 419 "simple.html" }, |
420 { URL_PREFIX "\\\\foo\\simple.html", | 420 { URL_PREFIX "\\\\foo\\simple.html", |
421 "foo/simple.html" }, | 421 "foo/simple.html" }, |
422 }; | 422 }; |
423 #undef URL_PREFIX | 423 #undef URL_PREFIX |
424 | 424 |
425 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 425 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
426 GURL url(test_cases[i].url); | 426 GURL url(test_cases[i].url); |
427 base::FilePath expected_path = | 427 base::FilePath expected_path = |
428 base::FilePath::FromUTF8Unsafe(test_cases[i].expected_relative_path); | 428 base::FilePath::FromUTF8Unsafe(test_cases[i].expected_relative_path); |
429 base::FilePath actual_path = | 429 base::FilePath actual_path = |
430 extensions::file_util::ExtensionURLToRelativeFilePath(url); | 430 extensions::file_util::ExtensionURLToRelativeFilePath(url); |
431 EXPECT_FALSE(actual_path.IsAbsolute()) << | 431 EXPECT_FALSE(actual_path.IsAbsolute()) << |
432 " For the path " << actual_path.value(); | 432 " For the path " << actual_path.value(); |
433 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 433 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
434 " For the path " << url; | 434 " For the path " << url; |
435 } | 435 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 { URL_PREFIX "apiname/..%2F../test.js", | 480 { URL_PREFIX "apiname/..%2F../test.js", |
481 NULL }, | 481 NULL }, |
482 { URL_PREFIX "apiname/f/../../../test.js", | 482 { URL_PREFIX "apiname/f/../../../test.js", |
483 FILE_PATH_LITERAL("test.js") }, | 483 FILE_PATH_LITERAL("test.js") }, |
484 { URL_PREFIX "apiname/f%2F..%2F..%2F../test.js", | 484 { URL_PREFIX "apiname/f%2F..%2F..%2F../test.js", |
485 NULL }, | 485 NULL }, |
486 }; | 486 }; |
487 #undef SEP | 487 #undef SEP |
488 #undef URL_PREFIX | 488 #undef URL_PREFIX |
489 | 489 |
490 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 490 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
491 GURL url(test_cases[i].url); | 491 GURL url(test_cases[i].url); |
492 base::FilePath expected_path; | 492 base::FilePath expected_path; |
493 if (test_cases[i].expected_path) | 493 if (test_cases[i].expected_path) |
494 expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( | 494 expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( |
495 test_cases[i].expected_path); | 495 test_cases[i].expected_path); |
496 base::FilePath actual_path = | 496 base::FilePath actual_path = |
497 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); | 497 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); |
498 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 498 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
499 " For the path " << url; | 499 " For the path " << url; |
500 } | 500 } |
501 // Remove temp files. | 501 // Remove temp files. |
502 ASSERT_TRUE(base::DeleteFile(root_path, true)); | 502 ASSERT_TRUE(base::DeleteFile(root_path, true)); |
503 } | 503 } |
504 | 504 |
505 } // namespace extensions | 505 } // namespace extensions |
OLD | NEW |