OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 base::FilePath root_resource = temp.path().AppendASCII(filename); | 124 base::FilePath root_resource = temp.path().AppendASCII(filename); |
125 std::string data = "some foo"; | 125 std::string data = "some foo"; |
126 ASSERT_TRUE(file_util::WriteFile(root_resource, data.c_str(), data.length())); | 126 ASSERT_TRUE(file_util::WriteFile(root_resource, data.c_str(), data.length())); |
127 | 127 |
128 // Create l10n resources (for current locale and its parents). | 128 // Create l10n resources (for current locale and its parents). |
129 base::FilePath l10n_path = | 129 base::FilePath l10n_path = |
130 temp.path().Append(kLocaleFolder); | 130 temp.path().Append(kLocaleFolder); |
131 ASSERT_TRUE(file_util::CreateDirectory(l10n_path)); | 131 ASSERT_TRUE(file_util::CreateDirectory(l10n_path)); |
132 | 132 |
133 std::vector<std::string> locales; | 133 std::vector<std::string> locales; |
134 l10n_util::GetParentLocales(l10n_util::GetApplicationLocale(""), &locales); | 134 l10n_util::GetParentLocales(l10n_util::GetApplicationLocale(std::string()), |
| 135 &locales); |
135 ASSERT_FALSE(locales.empty()); | 136 ASSERT_FALSE(locales.empty()); |
136 for (size_t i = 0; i < locales.size(); i++) { | 137 for (size_t i = 0; i < locales.size(); i++) { |
137 base::FilePath make_path; | 138 base::FilePath make_path; |
138 make_path = l10n_path.AppendASCII(locales[i]); | 139 make_path = l10n_path.AppendASCII(locales[i]); |
139 ASSERT_TRUE(file_util::CreateDirectory(make_path)); | 140 ASSERT_TRUE(file_util::CreateDirectory(make_path)); |
140 ASSERT_TRUE(file_util::WriteFile(make_path.AppendASCII(filename), | 141 ASSERT_TRUE(file_util::WriteFile(make_path.AppendASCII(filename), |
141 data.c_str(), data.length())); | 142 data.c_str(), data.length())); |
142 } | 143 } |
143 | 144 |
144 base::FilePath path; | 145 base::FilePath path; |
145 std::string extension_id = id_util::GenerateId("test"); | 146 std::string extension_id = id_util::GenerateId("test"); |
146 ExtensionResource resource(extension_id, temp.path(), | 147 ExtensionResource resource(extension_id, temp.path(), |
147 base::FilePath().AppendASCII(filename)); | 148 base::FilePath().AppendASCII(filename)); |
148 base::FilePath resolved_path = resource.GetFilePath(); | 149 base::FilePath resolved_path = resource.GetFilePath(); |
149 | 150 |
150 base::FilePath expected_path; | 151 base::FilePath expected_path; |
151 // Expect default path only, since fallback logic is disabled. | 152 // Expect default path only, since fallback logic is disabled. |
152 // See http://crbug.com/27359. | 153 // See http://crbug.com/27359. |
153 expected_path = root_resource; | 154 expected_path = root_resource; |
154 ASSERT_TRUE(file_util::AbsolutePath(&expected_path)); | 155 ASSERT_TRUE(file_util::AbsolutePath(&expected_path)); |
155 | 156 |
156 EXPECT_EQ(ToLower(expected_path.value()), ToLower(resolved_path.value())); | 157 EXPECT_EQ(ToLower(expected_path.value()), ToLower(resolved_path.value())); |
157 EXPECT_EQ(ToLower(temp.path().value()), | 158 EXPECT_EQ(ToLower(temp.path().value()), |
158 ToLower(resource.extension_root().value())); | 159 ToLower(resource.extension_root().value())); |
159 EXPECT_EQ(ToLower(base::FilePath().AppendASCII(filename).value()), | 160 EXPECT_EQ(ToLower(base::FilePath().AppendASCII(filename).value()), |
160 ToLower(resource.relative_path().value())); | 161 ToLower(resource.relative_path().value())); |
161 } | 162 } |
162 | 163 |
163 } // namespace extensions | 164 } // namespace extensions |
OLD | NEW |