OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser/extensions/extension_protocol.h" | 5 #include "chrome/browser/extensions/extension_protocol.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 class ExtensionProtocolTest : public testing::Test { | 8 class ExtensionProtocolTest : public testing::Test { |
9 }; | 9 }; |
10 | 10 |
11 TEST(ExtensionProtocolTest, GetPathForExtensionResource) { | 11 TEST(ExtensionProtocolTest, GetPathForExtensionResource) { |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 FilePath extension_path(FILE_PATH_LITERAL("C:\\myextension")); | 13 FilePath extension_path(FILE_PATH_LITERAL("C:\\myextension")); |
14 EXPECT_EQ(std::wstring(L"C:\\myextension\\foo\\bar.gif"), | 14 EXPECT_EQ(std::wstring(L"C:\\myextension\\foo\\bar.gif"), |
15 GetPathForExtensionResource(extension_path, "/foo/bar.gif").value())
; | 15 GetPathForExtensionResource(extension_path, "/foo/bar.gif").value())
; |
16 EXPECT_EQ(std::wstring(L"C:\\myextension\\"), | 16 EXPECT_EQ(std::wstring(L"C:\\myextension\\"), |
17 GetPathForExtensionResource(extension_path, "/").value()); | 17 GetPathForExtensionResource(extension_path, "/").value()); |
18 // TODO(aa): This one is a bit weird, but is what net::FileURLToFilePath() | |
19 // returns for this input. Investigate adding more validation. | |
20 EXPECT_EQ(std::wstring(L"C:\\myextension\\c:\\foo.gif"), | 18 EXPECT_EQ(std::wstring(L"C:\\myextension\\c:\\foo.gif"), |
21 GetPathForExtensionResource(extension_path, "/c:/foo.gif").value()); | 19 GetPathForExtensionResource(extension_path, "/c:/foo.gif").value()); |
22 EXPECT_EQ(std::wstring(L"C:\\myextension\\foo.gif"), | |
23 GetPathForExtensionResource(extension_path, "//foo.gif").value()); | |
24 EXPECT_EQ(std::wstring(L""), | 20 EXPECT_EQ(std::wstring(L""), |
25 GetPathForExtensionResource(extension_path, "/../foo.gif").value()); | 21 GetPathForExtensionResource(extension_path, "/../foo.gif").value()); |
26 #else | 22 #else |
27 FilePath extension_path(FILE_PATH_LITERAL("/myextension")); | 23 FilePath extension_path(FILE_PATH_LITERAL("/myextension")); |
28 EXPECT_EQ(std::wstring("/myextension/foo/bar.gif"), | 24 EXPECT_EQ(std::wstring("/myextension/foo/bar.gif"), |
29 GetPathForExtensionResource(extension_path, "/foo/bar.gif").value())
; | 25 GetPathForExtensionResource(extension_path, "/foo/bar.gif").value())
; |
30 EXPECT_EQ(std::wstring("/myextension/"), | 26 EXPECT_EQ(std::wstring("/myextension/"), |
31 GetPathForExtensionResource(extension_path, "/").value()); | 27 GetPathForExtensionResource(extension_path, "/").value()); |
32 EXPECT_EQ(std::wstring("/myextension/foo.gif"), | |
33 GetPathForExtensionResource(extension_path, "//foo.gif").value()); | |
34 EXPECT_EQ(std::wstring(""), | 28 EXPECT_EQ(std::wstring(""), |
35 GetPathForExtensionResource(extension_path, "/../foo.gif").value()); | 29 GetPathForExtensionResource(extension_path, "/../foo.gif").value()); |
36 #endif | 30 #endif |
37 | 31 |
38 | 32 |
39 } | 33 } |
OLD | NEW |