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 "chrome/common/extensions/extension_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
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/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 base::FilePath expected_path; | 332 base::FilePath expected_path; |
333 if (test_cases[i].expected_path) | 333 if (test_cases[i].expected_path) |
334 expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( | 334 expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( |
335 test_cases[i].expected_path); | 335 test_cases[i].expected_path); |
336 base::FilePath actual_path = | 336 base::FilePath actual_path = |
337 extension_file_util::ExtensionResourceURLToFilePath(url, root_path); | 337 extension_file_util::ExtensionResourceURLToFilePath(url, root_path); |
338 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 338 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
339 " For the path " << url; | 339 " For the path " << url; |
340 } | 340 } |
341 // Remove temp files. | 341 // Remove temp files. |
342 ASSERT_TRUE(base::Delete(root_path, true)); | 342 ASSERT_TRUE(base::DeleteFile(root_path, true)); |
343 } | 343 } |
344 | 344 |
345 static scoped_refptr<Extension> LoadExtensionManifest( | 345 static scoped_refptr<Extension> LoadExtensionManifest( |
346 base::DictionaryValue* manifest, | 346 base::DictionaryValue* manifest, |
347 const base::FilePath& manifest_dir, | 347 const base::FilePath& manifest_dir, |
348 Manifest::Location location, | 348 Manifest::Location location, |
349 int extra_flags, | 349 int extra_flags, |
350 std::string* error) { | 350 std::string* error) { |
351 scoped_refptr<Extension> extension = Extension::Create( | 351 scoped_refptr<Extension> extension = Extension::Create( |
352 manifest_dir, location, *manifest, extra_flags, error); | 352 manifest_dir, location, *manifest, extra_flags, error); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( | 567 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( |
568 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); | 568 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); |
569 EXPECT_TRUE(extension3.get() == NULL); | 569 EXPECT_TRUE(extension3.get() == NULL); |
570 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", | 570 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", |
571 error.c_str()); | 571 error.c_str()); |
572 } | 572 } |
573 | 573 |
574 // TODO(aa): More tests as motivation allows. Maybe steal some from | 574 // TODO(aa): More tests as motivation allows. Maybe steal some from |
575 // ExtensionService? Many of them could probably be tested here without the | 575 // ExtensionService? Many of them could probably be tested here without the |
576 // MessageLoop shenanigans. | 576 // MessageLoop shenanigans. |
OLD | NEW |