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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 ASSERT_TRUE(base::CreateNewTempDirectory( | 59 ASSERT_TRUE(base::CreateNewTempDirectory( |
60 base::FilePath::StringType(), &root_path)); | 60 base::FilePath::StringType(), &root_path)); |
61 root_path = base::MakeAbsoluteFilePath(root_path); | 61 root_path = base::MakeAbsoluteFilePath(root_path); |
62 ASSERT_FALSE(root_path.empty()); | 62 ASSERT_FALSE(root_path.empty()); |
63 | 63 |
64 base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); | 64 base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); |
65 ASSERT_TRUE(base::CreateDirectory(api_path)); | 65 ASSERT_TRUE(base::CreateDirectory(api_path)); |
66 | 66 |
67 const char data[] = "Test Data"; | 67 const char data[] = "Test Data"; |
68 base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); | 68 base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); |
69 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); | 69 ASSERT_TRUE(base::WriteFile(resource_path, data, sizeof(data))); |
70 resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js")); | 70 resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js")); |
71 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); | 71 ASSERT_TRUE(base::WriteFile(resource_path, data, sizeof(data))); |
72 | 72 |
73 #ifdef FILE_PATH_USES_WIN_SEPARATORS | 73 #ifdef FILE_PATH_USES_WIN_SEPARATORS |
74 #define SEP "\\" | 74 #define SEP "\\" |
75 #else | 75 #else |
76 #define SEP "/" | 76 #define SEP "/" |
77 #endif | 77 #endif |
78 #define URL_PREFIX "chrome-extension-resource://" | 78 #define URL_PREFIX "chrome-extension-resource://" |
79 struct TestCase { | 79 struct TestCase { |
80 const char* url; | 80 const char* url; |
81 const base::FilePath::CharType* expected_path; | 81 const base::FilePath::CharType* expected_path; |
(...skipping 30 matching lines...) Expand all Loading... |
112 expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( | 112 expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( |
113 test_cases[i].expected_path); | 113 test_cases[i].expected_path); |
114 base::FilePath actual_path = | 114 base::FilePath actual_path = |
115 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); | 115 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); |
116 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 116 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
117 " For the path " << url; | 117 " For the path " << url; |
118 } | 118 } |
119 // Remove temp files. | 119 // Remove temp files. |
120 ASSERT_TRUE(base::DeleteFile(root_path, true)); | 120 ASSERT_TRUE(base::DeleteFile(root_path, true)); |
121 } | 121 } |
OLD | NEW |