OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/scoped_temp_dir.h" |
16 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
18 #include "base/stl_util-inl.h" | 19 #include "base/stl_util-inl.h" |
19 #include "base/string16.h" | 20 #include "base/string16.h" |
20 #include "base/string_number_conversions.h" | 21 #include "base/string_number_conversions.h" |
21 #include "base/string_util.h" | 22 #include "base/string_util.h" |
22 #include "base/task.h" | 23 #include "base/task.h" |
23 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
24 #include "base/version.h" | 25 #include "base/version.h" |
25 #include "chrome/browser/extensions/crx_installer.h" | 26 #include "chrome/browser/extensions/crx_installer.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 513 } |
513 | 514 |
514 protected: | 515 protected: |
515 void TestExternalProvider(MockExtensionProvider* provider, | 516 void TestExternalProvider(MockExtensionProvider* provider, |
516 Extension::Location location); | 517 Extension::Location location); |
517 | 518 |
518 void PackAndInstallExtension(const FilePath& dir_path, | 519 void PackAndInstallExtension(const FilePath& dir_path, |
519 const FilePath& pem_path, | 520 const FilePath& pem_path, |
520 bool should_succeed) { | 521 bool should_succeed) { |
521 FilePath crx_path; | 522 FilePath crx_path; |
522 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &crx_path)); | 523 ScopedTempDir temp_dir; |
523 crx_path = crx_path.AppendASCII("temp.crx"); | 524 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 525 crx_path = temp_dir_.path().AppendASCII("temp.crx"); |
524 | 526 |
525 // Use the existing pem key, if provided. | 527 // Use the existing pem key, if provided. |
526 FilePath pem_output_path; | 528 FilePath pem_output_path; |
527 if (pem_path.value().empty()) { | 529 if (pem_path.value().empty()) { |
528 pem_output_path = crx_path.DirName().AppendASCII("temp.pem"); | 530 pem_output_path = crx_path.DirName().AppendASCII("temp.pem"); |
529 ASSERT_TRUE(file_util::Delete(pem_output_path, false)); | 531 ASSERT_TRUE(file_util::Delete(pem_output_path, false)); |
530 } else { | 532 } else { |
531 ASSERT_TRUE(file_util::PathExists(pem_path)); | 533 ASSERT_TRUE(file_util::PathExists(pem_path)); |
532 } | 534 } |
533 | 535 |
(...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3527 // Component extensions shouldn't get recourded in the prefs. | 3529 // Component extensions shouldn't get recourded in the prefs. |
3528 ValidatePrefKeyCount(0); | 3530 ValidatePrefKeyCount(0); |
3529 | 3531 |
3530 // Reload all extensions, and make sure it comes back. | 3532 // Reload all extensions, and make sure it comes back. |
3531 std::string extension_id = service_->extensions()->at(0)->id(); | 3533 std::string extension_id = service_->extensions()->at(0)->id(); |
3532 loaded_.clear(); | 3534 loaded_.clear(); |
3533 service_->ReloadExtensions(); | 3535 service_->ReloadExtensions(); |
3534 ASSERT_EQ(1u, service_->extensions()->size()); | 3536 ASSERT_EQ(1u, service_->extensions()->size()); |
3535 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 3537 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
3536 } | 3538 } |
OLD | NEW |