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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 TEST_F(FileUtilTest, BackgroundScriptsMustExist) { | 283 TEST_F(FileUtilTest, BackgroundScriptsMustExist) { |
284 base::ScopedTempDir temp; | 284 base::ScopedTempDir temp; |
285 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 285 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
286 | 286 |
287 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 287 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
288 value->SetString("name", "test"); | 288 value->SetString("name", "test"); |
289 value->SetString("version", "1"); | 289 value->SetString("version", "1"); |
290 value->SetInteger("manifest_version", 1); | 290 value->SetInteger("manifest_version", 1); |
291 | 291 |
292 base::ListValue* scripts = new base::ListValue(); | 292 base::ListValue* scripts = new base::ListValue(); |
293 scripts->Append(new base::StringValue("foo.js")); | 293 scripts->AppendString("foo.js"); |
294 value->Set("background.scripts", scripts); | 294 value->Set("background.scripts", scripts); |
295 | 295 |
296 std::string error; | 296 std::string error; |
297 std::vector<extensions::InstallWarning> warnings; | 297 std::vector<extensions::InstallWarning> warnings; |
298 scoped_refptr<Extension> extension = LoadExtensionManifest( | 298 scoped_refptr<Extension> extension = LoadExtensionManifest( |
299 *value.get(), temp.path(), Manifest::UNPACKED, 0, &error); | 299 *value.get(), temp.path(), Manifest::UNPACKED, 0, &error); |
300 ASSERT_TRUE(extension.get()) << error; | 300 ASSERT_TRUE(extension.get()) << error; |
301 | 301 |
302 EXPECT_FALSE( | 302 EXPECT_FALSE( |
303 file_util::ValidateExtension(extension.get(), &error, &warnings)); | 303 file_util::ValidateExtension(extension.get(), &error, &warnings)); |
304 EXPECT_EQ( | 304 EXPECT_EQ( |
305 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, | 305 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, |
306 base::ASCIIToUTF16("foo.js")), | 306 base::ASCIIToUTF16("foo.js")), |
307 error); | 307 error); |
308 EXPECT_EQ(0U, warnings.size()); | 308 EXPECT_EQ(0U, warnings.size()); |
309 | 309 |
310 scripts->Clear(); | 310 scripts->Clear(); |
311 scripts->Append(new base::StringValue("http://google.com/foo.js")); | 311 scripts->AppendString("http://google.com/foo.js"); |
312 | 312 |
313 extension = LoadExtensionManifest(*value.get(), temp.path(), | 313 extension = LoadExtensionManifest(*value.get(), temp.path(), |
314 Manifest::UNPACKED, 0, &error); | 314 Manifest::UNPACKED, 0, &error); |
315 ASSERT_TRUE(extension.get()) << error; | 315 ASSERT_TRUE(extension.get()) << error; |
316 | 316 |
317 warnings.clear(); | 317 warnings.clear(); |
318 EXPECT_FALSE( | 318 EXPECT_FALSE( |
319 file_util::ValidateExtension(extension.get(), &error, &warnings)); | 319 file_util::ValidateExtension(extension.get(), &error, &warnings)); |
320 EXPECT_EQ( | 320 EXPECT_EQ( |
321 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, | 321 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 base::FilePath actual_path = | 543 base::FilePath actual_path = |
544 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); | 544 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); |
545 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 545 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
546 " For the path " << url; | 546 " For the path " << url; |
547 } | 547 } |
548 // Remove temp files. | 548 // Remove temp files. |
549 ASSERT_TRUE(base::DeleteFile(root_path, true)); | 549 ASSERT_TRUE(base::DeleteFile(root_path, true)); |
550 } | 550 } |
551 | 551 |
552 } // namespace extensions | 552 } // namespace extensions |
OLD | NEW |