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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 typedef testing::Test FileUtilTest; | 62 typedef testing::Test FileUtilTest; |
63 | 63 |
64 TEST_F(FileUtilTest, InstallUninstallGarbageCollect) { | 64 TEST_F(FileUtilTest, InstallUninstallGarbageCollect) { |
65 base::ScopedTempDir temp; | 65 base::ScopedTempDir temp; |
66 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 66 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
67 | 67 |
68 // Create a source extension. | 68 // Create a source extension. |
69 std::string extension_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | 69 std::string extension_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |
70 std::string version("1.0"); | 70 std::string version("1.0"); |
71 base::FilePath src = temp.path().AppendASCII(extension_id); | 71 base::FilePath src = temp.GetPath().AppendASCII(extension_id); |
72 ASSERT_TRUE(base::CreateDirectory(src)); | 72 ASSERT_TRUE(base::CreateDirectory(src)); |
73 | 73 |
74 base::FilePath extension_content; | 74 base::FilePath extension_content; |
75 base::CreateTemporaryFileInDir(src, &extension_content); | 75 base::CreateTemporaryFileInDir(src, &extension_content); |
76 ASSERT_TRUE(base::PathExists(extension_content)); | 76 ASSERT_TRUE(base::PathExists(extension_content)); |
77 | 77 |
78 // Create a extensions tree. | 78 // Create a extensions tree. |
79 base::FilePath all_extensions = temp.path().AppendASCII("extensions"); | 79 base::FilePath all_extensions = temp.GetPath().AppendASCII("extensions"); |
80 ASSERT_TRUE(base::CreateDirectory(all_extensions)); | 80 ASSERT_TRUE(base::CreateDirectory(all_extensions)); |
81 | 81 |
82 // Install in empty directory. Should create parent directories as needed. | 82 // Install in empty directory. Should create parent directories as needed. |
83 base::FilePath version_1 = | 83 base::FilePath version_1 = |
84 file_util::InstallExtension(src, extension_id, version, all_extensions); | 84 file_util::InstallExtension(src, extension_id, version, all_extensions); |
85 ASSERT_EQ( | 85 ASSERT_EQ( |
86 version_1.value(), | 86 version_1.value(), |
87 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_0").value()); | 87 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_0").value()); |
88 ASSERT_TRUE(base::DirectoryExists(version_1)); | 88 ASSERT_TRUE(base::DirectoryExists(version_1)); |
89 ASSERT_TRUE(base::PathExists(version_1.Append(extension_content.BaseName()))); | 89 ASSERT_TRUE(base::PathExists(version_1.Append(extension_content.BaseName()))); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 scoped_refptr<Extension> extension(file_util::LoadExtension( | 141 scoped_refptr<Extension> extension(file_util::LoadExtension( |
142 install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); | 142 install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); |
143 ASSERT_FALSE(extension.get() == NULL); | 143 ASSERT_FALSE(extension.get() == NULL); |
144 EXPECT_TRUE(error.empty()); | 144 EXPECT_TRUE(error.empty()); |
145 } | 145 } |
146 | 146 |
147 TEST_F(FileUtilTest, CheckIllegalFilenamesNoUnderscores) { | 147 TEST_F(FileUtilTest, CheckIllegalFilenamesNoUnderscores) { |
148 base::ScopedTempDir temp; | 148 base::ScopedTempDir temp; |
149 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 149 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
150 | 150 |
151 base::FilePath src_path = temp.path().AppendASCII("some_dir"); | 151 base::FilePath src_path = temp.GetPath().AppendASCII("some_dir"); |
152 ASSERT_TRUE(base::CreateDirectory(src_path)); | 152 ASSERT_TRUE(base::CreateDirectory(src_path)); |
153 | 153 |
154 std::string data = "{ \"name\": { \"message\": \"foobar\" } }"; | 154 std::string data = "{ \"name\": { \"message\": \"foobar\" } }"; |
155 ASSERT_TRUE(base::WriteFile( | 155 ASSERT_TRUE(base::WriteFile( |
156 src_path.AppendASCII("some_file.txt"), data.c_str(), data.length())); | 156 src_path.AppendASCII("some_file.txt"), data.c_str(), data.length())); |
157 std::string error; | 157 std::string error; |
158 EXPECT_TRUE(file_util::CheckForIllegalFilenames(temp.path(), &error)); | 158 EXPECT_TRUE(file_util::CheckForIllegalFilenames(temp.GetPath(), &error)); |
159 } | 159 } |
160 | 160 |
161 TEST_F(FileUtilTest, CheckIllegalFilenamesOnlyReserved) { | 161 TEST_F(FileUtilTest, CheckIllegalFilenamesOnlyReserved) { |
162 base::ScopedTempDir temp; | 162 base::ScopedTempDir temp; |
163 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 163 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
164 | 164 |
165 const base::FilePath::CharType* folders[] = { | 165 const base::FilePath::CharType* folders[] = { |
166 extensions::kLocaleFolder, extensions::kPlatformSpecificFolder}; | 166 extensions::kLocaleFolder, extensions::kPlatformSpecificFolder}; |
167 | 167 |
168 for (size_t i = 0; i < arraysize(folders); i++) { | 168 for (size_t i = 0; i < arraysize(folders); i++) { |
169 base::FilePath src_path = temp.path().Append(folders[i]); | 169 base::FilePath src_path = temp.GetPath().Append(folders[i]); |
170 ASSERT_TRUE(base::CreateDirectory(src_path)); | 170 ASSERT_TRUE(base::CreateDirectory(src_path)); |
171 } | 171 } |
172 | 172 |
173 std::string error; | 173 std::string error; |
174 EXPECT_TRUE(file_util::CheckForIllegalFilenames(temp.path(), &error)); | 174 EXPECT_TRUE(file_util::CheckForIllegalFilenames(temp.GetPath(), &error)); |
175 } | 175 } |
176 | 176 |
177 TEST_F(FileUtilTest, CheckIllegalFilenamesReservedAndIllegal) { | 177 TEST_F(FileUtilTest, CheckIllegalFilenamesReservedAndIllegal) { |
178 base::ScopedTempDir temp; | 178 base::ScopedTempDir temp; |
179 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 179 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
180 | 180 |
181 base::FilePath src_path = temp.path().Append(extensions::kLocaleFolder); | 181 base::FilePath src_path = temp.GetPath().Append(extensions::kLocaleFolder); |
182 ASSERT_TRUE(base::CreateDirectory(src_path)); | 182 ASSERT_TRUE(base::CreateDirectory(src_path)); |
183 | 183 |
184 src_path = temp.path().AppendASCII("_some_dir"); | 184 src_path = temp.GetPath().AppendASCII("_some_dir"); |
185 ASSERT_TRUE(base::CreateDirectory(src_path)); | 185 ASSERT_TRUE(base::CreateDirectory(src_path)); |
186 | 186 |
187 std::string error; | 187 std::string error; |
188 EXPECT_FALSE(file_util::CheckForIllegalFilenames(temp.path(), &error)); | 188 EXPECT_FALSE(file_util::CheckForIllegalFilenames(temp.GetPath(), &error)); |
189 } | 189 } |
190 | 190 |
191 // These tests do not work on Windows, because it is illegal to create a | 191 // These tests do not work on Windows, because it is illegal to create a |
192 // file/directory with a Windows reserved name. Because we cannot create a | 192 // file/directory with a Windows reserved name. Because we cannot create a |
193 // file that will cause the test to fail, let's skip the test. | 193 // file that will cause the test to fail, let's skip the test. |
194 #if !defined(OS_WIN) | 194 #if !defined(OS_WIN) |
195 TEST_F(FileUtilTest, CheckIllegalFilenamesDirectoryWindowsReserved) { | 195 TEST_F(FileUtilTest, CheckIllegalFilenamesDirectoryWindowsReserved) { |
196 base::ScopedTempDir temp; | 196 base::ScopedTempDir temp; |
197 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 197 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
198 | 198 |
199 base::FilePath src_path = temp.path().AppendASCII("aux"); | 199 base::FilePath src_path = temp.GetPath().AppendASCII("aux"); |
200 ASSERT_TRUE(base::CreateDirectory(src_path)); | 200 ASSERT_TRUE(base::CreateDirectory(src_path)); |
201 | 201 |
202 std::string error; | 202 std::string error; |
203 EXPECT_FALSE( | 203 EXPECT_FALSE( |
204 file_util::CheckForWindowsReservedFilenames(temp.path(), &error)); | 204 file_util::CheckForWindowsReservedFilenames(temp.GetPath(), &error)); |
205 } | 205 } |
206 | 206 |
207 TEST_F(FileUtilTest, | 207 TEST_F(FileUtilTest, |
208 CheckIllegalFilenamesWindowsReservedFilenameWithExtension) { | 208 CheckIllegalFilenamesWindowsReservedFilenameWithExtension) { |
209 base::ScopedTempDir temp; | 209 base::ScopedTempDir temp; |
210 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 210 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
211 | 211 |
212 base::FilePath src_path = temp.path().AppendASCII("some_dir"); | 212 base::FilePath src_path = temp.GetPath().AppendASCII("some_dir"); |
213 ASSERT_TRUE(base::CreateDirectory(src_path)); | 213 ASSERT_TRUE(base::CreateDirectory(src_path)); |
214 | 214 |
215 std::string data = "{ \"name\": { \"message\": \"foobar\" } }"; | 215 std::string data = "{ \"name\": { \"message\": \"foobar\" } }"; |
216 ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("lpt1.txt"), data.c_str(), | 216 ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("lpt1.txt"), data.c_str(), |
217 data.length())); | 217 data.length())); |
218 | 218 |
219 std::string error; | 219 std::string error; |
220 EXPECT_FALSE( | 220 EXPECT_FALSE( |
221 file_util::CheckForWindowsReservedFilenames(temp.path(), &error)); | 221 file_util::CheckForWindowsReservedFilenames(temp.GetPath(), &error)); |
222 } | 222 } |
223 #endif | 223 #endif |
224 | 224 |
225 TEST_F(FileUtilTest, LoadExtensionGivesHelpfullErrorOnMissingManifest) { | 225 TEST_F(FileUtilTest, LoadExtensionGivesHelpfullErrorOnMissingManifest) { |
226 base::FilePath install_dir; | 226 base::FilePath install_dir; |
227 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &install_dir)); | 227 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &install_dir)); |
228 install_dir = | 228 install_dir = |
229 install_dir.AppendASCII("file_util").AppendASCII("missing_manifest"); | 229 install_dir.AppendASCII("file_util").AppendASCII("missing_manifest"); |
230 | 230 |
231 std::string error; | 231 std::string error; |
(...skipping 21 matching lines...) Expand all Loading... |
253 error.c_str()); | 253 error.c_str()); |
254 } | 254 } |
255 | 255 |
256 TEST_F(FileUtilTest, ValidateThemeUTF8) { | 256 TEST_F(FileUtilTest, ValidateThemeUTF8) { |
257 base::ScopedTempDir temp; | 257 base::ScopedTempDir temp; |
258 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 258 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
259 | 259 |
260 // "aeo" with accents. Use http://0xcc.net/jsescape/ to decode them. | 260 // "aeo" with accents. Use http://0xcc.net/jsescape/ to decode them. |
261 std::string non_ascii_file = "\xC3\xA0\xC3\xA8\xC3\xB2.png"; | 261 std::string non_ascii_file = "\xC3\xA0\xC3\xA8\xC3\xB2.png"; |
262 base::FilePath non_ascii_path = | 262 base::FilePath non_ascii_path = |
263 temp.path().Append(base::FilePath::FromUTF8Unsafe(non_ascii_file)); | 263 temp.GetPath().Append(base::FilePath::FromUTF8Unsafe(non_ascii_file)); |
264 base::WriteFile(non_ascii_path, "", 0); | 264 base::WriteFile(non_ascii_path, "", 0); |
265 | 265 |
266 std::string kManifest = base::StringPrintf( | 266 std::string kManifest = base::StringPrintf( |
267 "{ \"name\": \"Test\", \"version\": \"1.0\", " | 267 "{ \"name\": \"Test\", \"version\": \"1.0\", " |
268 " \"theme\": { \"images\": { \"theme_frame\": \"%s\" } }" | 268 " \"theme\": { \"images\": { \"theme_frame\": \"%s\" } }" |
269 "}", | 269 "}", |
270 non_ascii_file.c_str()); | 270 non_ascii_file.c_str()); |
271 std::string error; | 271 std::string error; |
272 scoped_refptr<Extension> extension = LoadExtensionManifest( | 272 scoped_refptr<Extension> extension = LoadExtensionManifest( |
273 kManifest, temp.path(), Manifest::UNPACKED, 0, &error); | 273 kManifest, temp.GetPath(), Manifest::UNPACKED, 0, &error); |
274 ASSERT_TRUE(extension.get()) << error; | 274 ASSERT_TRUE(extension.get()) << error; |
275 | 275 |
276 std::vector<extensions::InstallWarning> warnings; | 276 std::vector<extensions::InstallWarning> warnings; |
277 EXPECT_TRUE(file_util::ValidateExtension(extension.get(), &error, &warnings)) | 277 EXPECT_TRUE(file_util::ValidateExtension(extension.get(), &error, &warnings)) |
278 << error; | 278 << error; |
279 EXPECT_EQ(0U, warnings.size()); | 279 EXPECT_EQ(0U, warnings.size()); |
280 } | 280 } |
281 | 281 |
282 TEST_F(FileUtilTest, BackgroundScriptsMustExist) { | 282 TEST_F(FileUtilTest, BackgroundScriptsMustExist) { |
283 base::ScopedTempDir temp; | 283 base::ScopedTempDir temp; |
284 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 284 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
285 | 285 |
286 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 286 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
287 value->SetString("name", "test"); | 287 value->SetString("name", "test"); |
288 value->SetString("version", "1"); | 288 value->SetString("version", "1"); |
289 value->SetInteger("manifest_version", 1); | 289 value->SetInteger("manifest_version", 1); |
290 | 290 |
291 base::ListValue* scripts = new base::ListValue(); | 291 base::ListValue* scripts = new base::ListValue(); |
292 scripts->AppendString("foo.js"); | 292 scripts->AppendString("foo.js"); |
293 value->Set("background.scripts", scripts); | 293 value->Set("background.scripts", scripts); |
294 | 294 |
295 std::string error; | 295 std::string error; |
296 std::vector<extensions::InstallWarning> warnings; | 296 std::vector<extensions::InstallWarning> warnings; |
297 scoped_refptr<Extension> extension = | 297 scoped_refptr<Extension> extension = LoadExtensionManifest( |
298 LoadExtensionManifest(*value, temp.path(), Manifest::UNPACKED, 0, &error); | 298 *value, temp.GetPath(), Manifest::UNPACKED, 0, &error); |
299 ASSERT_TRUE(extension.get()) << error; | 299 ASSERT_TRUE(extension.get()) << error; |
300 | 300 |
301 EXPECT_FALSE( | 301 EXPECT_FALSE( |
302 file_util::ValidateExtension(extension.get(), &error, &warnings)); | 302 file_util::ValidateExtension(extension.get(), &error, &warnings)); |
303 EXPECT_EQ( | 303 EXPECT_EQ( |
304 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, | 304 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, |
305 base::ASCIIToUTF16("foo.js")), | 305 base::ASCIIToUTF16("foo.js")), |
306 error); | 306 error); |
307 EXPECT_EQ(0U, warnings.size()); | 307 EXPECT_EQ(0U, warnings.size()); |
308 | 308 |
309 scripts->Clear(); | 309 scripts->Clear(); |
310 scripts->AppendString("http://google.com/foo.js"); | 310 scripts->AppendString("http://google.com/foo.js"); |
311 | 311 |
312 extension = | 312 extension = LoadExtensionManifest(*value, temp.GetPath(), Manifest::UNPACKED, |
313 LoadExtensionManifest(*value, temp.path(), Manifest::UNPACKED, 0, &error); | 313 0, &error); |
314 ASSERT_TRUE(extension.get()) << error; | 314 ASSERT_TRUE(extension.get()) << error; |
315 | 315 |
316 warnings.clear(); | 316 warnings.clear(); |
317 EXPECT_FALSE( | 317 EXPECT_FALSE( |
318 file_util::ValidateExtension(extension.get(), &error, &warnings)); | 318 file_util::ValidateExtension(extension.get(), &error, &warnings)); |
319 EXPECT_EQ( | 319 EXPECT_EQ( |
320 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, | 320 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, |
321 base::ASCIIToUTF16("http://google.com/foo.js")), | 321 base::ASCIIToUTF16("http://google.com/foo.js")), |
322 error); | 322 error); |
323 EXPECT_EQ(0U, warnings.size()); | 323 EXPECT_EQ(0U, warnings.size()); |
(...skipping 16 matching lines...) Expand all Loading... |
340 "vHAI0Llmw7tj7jv17pAkEAz44uXRpjRKtllUIvi5pUENAHwDz+HvdpGH68jpU3hmb\n" | 340 "vHAI0Llmw7tj7jv17pAkEAz44uXRpjRKtllUIvi5pUENAHwDz+HvdpGH68jpU3hmb\n" |
341 "uOwrmnQYxaMReFV68Z2w9DcLZn07f7/R9Wn72z89CxwJAFsDoNaDes4h48bX7plct\n" | 341 "uOwrmnQYxaMReFV68Z2w9DcLZn07f7/R9Wn72z89CxwJAFsDoNaDes4h48bX7plct\n" |
342 "s9ACjmTwcCigZjN2K7AGv7ntCLF3DnV5dK0dTHNaAdD3SbY3jl29Rk2CwiURSX6Ee\n" | 342 "s9ACjmTwcCigZjN2K7AGv7ntCLF3DnV5dK0dTHNaAdD3SbY3jl29Rk2CwiURSX6Ee\n" |
343 "g==\n" | 343 "g==\n" |
344 "-----END PRIVATE KEY-----\n"; | 344 "-----END PRIVATE KEY-----\n"; |
345 | 345 |
346 TEST_F(FileUtilTest, FindPrivateKeyFiles) { | 346 TEST_F(FileUtilTest, FindPrivateKeyFiles) { |
347 base::ScopedTempDir temp; | 347 base::ScopedTempDir temp; |
348 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 348 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
349 | 349 |
350 base::FilePath src_path = temp.path().AppendASCII("some_dir"); | 350 base::FilePath src_path = temp.GetPath().AppendASCII("some_dir"); |
351 ASSERT_TRUE(base::CreateDirectory(src_path)); | 351 ASSERT_TRUE(base::CreateDirectory(src_path)); |
352 | 352 |
353 ASSERT_TRUE(base::WriteFile( | 353 ASSERT_TRUE(base::WriteFile( |
354 src_path.AppendASCII("a_key.pem"), private_key, arraysize(private_key))); | 354 src_path.AppendASCII("a_key.pem"), private_key, arraysize(private_key))); |
355 ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("second_key.pem"), | 355 ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("second_key.pem"), |
356 private_key, | 356 private_key, |
357 arraysize(private_key))); | 357 arraysize(private_key))); |
358 // Shouldn't find a key with a different extension. | 358 // Shouldn't find a key with a different extension. |
359 ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("key.diff_ext"), | 359 ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("key.diff_ext"), |
360 private_key, | 360 private_key, |
361 arraysize(private_key))); | 361 arraysize(private_key))); |
362 // Shouldn't find a key that isn't parsable. | 362 // Shouldn't find a key that isn't parsable. |
363 ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("unparsable_key.pem"), | 363 ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("unparsable_key.pem"), |
364 private_key, | 364 private_key, |
365 arraysize(private_key) - 30)); | 365 arraysize(private_key) - 30)); |
366 std::vector<base::FilePath> private_keys = | 366 std::vector<base::FilePath> private_keys = |
367 file_util::FindPrivateKeyFiles(temp.path()); | 367 file_util::FindPrivateKeyFiles(temp.GetPath()); |
368 EXPECT_EQ(2U, private_keys.size()); | 368 EXPECT_EQ(2U, private_keys.size()); |
369 EXPECT_THAT(private_keys, | 369 EXPECT_THAT(private_keys, |
370 testing::Contains(src_path.AppendASCII("a_key.pem"))); | 370 testing::Contains(src_path.AppendASCII("a_key.pem"))); |
371 EXPECT_THAT(private_keys, | 371 EXPECT_THAT(private_keys, |
372 testing::Contains(src_path.AppendASCII("second_key.pem"))); | 372 testing::Contains(src_path.AppendASCII("second_key.pem"))); |
373 } | 373 } |
374 | 374 |
375 TEST_F(FileUtilTest, WarnOnPrivateKey) { | 375 TEST_F(FileUtilTest, WarnOnPrivateKey) { |
376 base::ScopedTempDir temp; | 376 base::ScopedTempDir temp; |
377 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 377 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
378 | 378 |
379 base::FilePath ext_path = temp.path().AppendASCII("ext_root"); | 379 base::FilePath ext_path = temp.GetPath().AppendASCII("ext_root"); |
380 ASSERT_TRUE(base::CreateDirectory(ext_path)); | 380 ASSERT_TRUE(base::CreateDirectory(ext_path)); |
381 | 381 |
382 const char manifest[] = | 382 const char manifest[] = |
383 "{\n" | 383 "{\n" |
384 " \"name\": \"Test Extension\",\n" | 384 " \"name\": \"Test Extension\",\n" |
385 " \"version\": \"1.0\",\n" | 385 " \"version\": \"1.0\",\n" |
386 " \"manifest_version\": 2,\n" | 386 " \"manifest_version\": 2,\n" |
387 " \"description\": \"The first extension that I made.\"\n" | 387 " \"description\": \"The first extension that I made.\"\n" |
388 "}\n"; | 388 "}\n"; |
389 ASSERT_TRUE(base::WriteFile( | 389 ASSERT_TRUE(base::WriteFile( |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 base::FilePath actual_path = | 542 base::FilePath actual_path = |
543 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); | 543 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); |
544 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 544 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
545 " For the path " << url; | 545 " For the path " << url; |
546 } | 546 } |
547 // Remove temp files. | 547 // Remove temp files. |
548 ASSERT_TRUE(base::DeleteFile(root_path, true)); | 548 ASSERT_TRUE(base::DeleteFile(root_path, true)); |
549 } | 549 } |
550 | 550 |
551 } // namespace extensions | 551 } // namespace extensions |
OLD | NEW |