| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/test_extension_system.h" | 16 #include "chrome/browser/extensions/test_extension_system.h" |
| 16 #include "chrome/browser/extensions/zipfile_installer.h" | 17 #include "chrome/browser/extensions/zipfile_installer.h" |
| 17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 19 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 20 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
| 21 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
| 22 #include "extensions/browser/extension_registry_observer.h" | 23 #include "extensions/browser/extension_registry_observer.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 void RunInstaller(const std::string& zip_name) { | 90 void RunInstaller(const std::string& zip_name) { |
| 90 base::FilePath original_path; | 91 base::FilePath original_path; |
| 91 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); | 92 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); |
| 92 original_path = original_path.AppendASCII("extensions") | 93 original_path = original_path.AppendASCII("extensions") |
| 93 .AppendASCII("zipfile_installer") | 94 .AppendASCII("zipfile_installer") |
| 94 .AppendASCII(zip_name); | 95 .AppendASCII(zip_name); |
| 95 ASSERT_TRUE(base::PathExists(original_path)) << original_path.value(); | 96 ASSERT_TRUE(base::PathExists(original_path)) << original_path.value(); |
| 96 | 97 |
| 97 zipfile_installer_ = ZipFileInstaller::Create(extension_service_); | 98 zipfile_installer_ = ZipFileInstaller::Create(extension_service_); |
| 98 | 99 |
| 99 base::MessageLoopProxy::current()->PostTask( | 100 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 100 FROM_HERE, | 101 FROM_HERE, |
| 101 base::Bind(&ZipFileInstaller::LoadFromZipFile, | 102 base::Bind(&ZipFileInstaller::LoadFromZipFile, |
| 102 zipfile_installer_.get(), | 103 zipfile_installer_.get(), |
| 103 original_path)); | 104 original_path)); |
| 104 observer_.WaitForInstall(); | 105 observer_.WaitForInstall(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 protected: | 108 protected: |
| 108 scoped_refptr<ZipFileInstaller> zipfile_installer_; | 109 scoped_refptr<ZipFileInstaller> zipfile_installer_; |
| 109 | 110 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 127 RunInstaller("good.zip"); | 128 RunInstaller("good.zip"); |
| 128 } | 129 } |
| 129 | 130 |
| 130 TEST_F(ZipFileInstallerTest, ZipWithPublicKey) { | 131 TEST_F(ZipFileInstallerTest, ZipWithPublicKey) { |
| 131 RunInstaller("public_key.zip"); | 132 RunInstaller("public_key.zip"); |
| 132 const char kIdForPublicKey[] = "ikppjpenhoddphklkpdfdfdabbakkpal"; | 133 const char kIdForPublicKey[] = "ikppjpenhoddphklkpdfdfdabbakkpal"; |
| 133 EXPECT_EQ(observer_.last_extension_installed, kIdForPublicKey); | 134 EXPECT_EQ(observer_.last_extension_installed, kIdForPublicKey); |
| 134 } | 135 } |
| 135 | 136 |
| 136 } // namespace extensions | 137 } // namespace extensions |
| OLD | NEW |