OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/utility_process_host.h" | 5 #include "chrome/browser/utility_process_host.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 14 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/notification_registrar.h" | 17 #include "chrome/common/notification_registrar.h" |
18 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 class UtilityProcessHostTest : public testing::Test { | 23 class UtilityProcessHostTest : public testing::Test { |
24 public: | 24 public: |
25 UtilityProcessHostTest() : io_thread_(ChromeThread::IO, &message_loop_) { | 25 UtilityProcessHostTest() |
| 26 : ui_thread_(ChromeThread::UI, &message_loop_), |
| 27 io_thread_(ChromeThread::IO, &message_loop_) { |
26 } | 28 } |
27 | 29 |
28 protected: | 30 protected: |
29 MessageLoopForIO message_loop_; | 31 MessageLoopForIO message_loop_; |
| 32 ChromeThread ui_thread_; |
30 ChromeThread io_thread_; | 33 ChromeThread io_thread_; |
31 }; | 34 }; |
32 | 35 |
33 class TestUtilityProcessHostClient : public UtilityProcessHost::Client { | 36 class TestUtilityProcessHostClient : public UtilityProcessHost::Client { |
34 public: | 37 public: |
35 explicit TestUtilityProcessHostClient() : success_(false) { | 38 explicit TestUtilityProcessHostClient() : success_(false) { |
36 } | 39 } |
37 | 40 |
38 // UtilityProcessHost::Client methods. | 41 // UtilityProcessHost::Client methods. |
39 virtual void OnProcessCrashed() { | 42 virtual void OnProcessCrashed() { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 .AppendASCII("theme.crx"); | 135 .AppendASCII("theme.crx"); |
133 FilePath temp_extension_dir; | 136 FilePath temp_extension_dir; |
134 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &temp_extension_dir)); | 137 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &temp_extension_dir)); |
135 temp_extension_dir = temp_extension_dir.AppendASCII("extension_test"); | 138 temp_extension_dir = temp_extension_dir.AppendASCII("extension_test"); |
136 ASSERT_TRUE(file_util::CreateDirectory(temp_extension_dir)); | 139 ASSERT_TRUE(file_util::CreateDirectory(temp_extension_dir)); |
137 ASSERT_TRUE(file_util::CopyFile(extension_file, | 140 ASSERT_TRUE(file_util::CopyFile(extension_file, |
138 temp_extension_dir.AppendASCII("theme.crx"))); | 141 temp_extension_dir.AppendASCII("theme.crx"))); |
139 | 142 |
140 scoped_refptr<TestUtilityProcessHostClient> client( | 143 scoped_refptr<TestUtilityProcessHostClient> client( |
141 new TestUtilityProcessHostClient()); | 144 new TestUtilityProcessHostClient()); |
142 ResourceDispatcherHost rdh(NULL); | 145 ResourceDispatcherHost rdh; |
143 TestUtilityProcessHost* process_host = | 146 TestUtilityProcessHost* process_host = |
144 new TestUtilityProcessHost(client.get(), &rdh); | 147 new TestUtilityProcessHost(client.get(), &rdh); |
145 // process_host will delete itself when it's done. | 148 // process_host will delete itself when it's done. |
146 ProcessClosedObserver observer(&message_loop_); | 149 ProcessClosedObserver observer(&message_loop_); |
147 process_host->StartExtensionUnpacker( | 150 process_host->StartExtensionUnpacker( |
148 temp_extension_dir.AppendASCII("theme.crx")); | 151 temp_extension_dir.AppendASCII("theme.crx")); |
149 observer.RunUntilClose(process_host->id()); | 152 observer.RunUntilClose(process_host->id()); |
150 EXPECT_TRUE(client->success()); | 153 EXPECT_TRUE(client->success()); |
151 | 154 |
152 // Clean up the temp dir. | 155 // Clean up the temp dir. |
153 file_util::Delete(temp_extension_dir, true); | 156 file_util::Delete(temp_extension_dir, true); |
154 } | 157 } |
155 #endif | 158 #endif |
156 | 159 |
157 } // namespace | 160 } // namespace |
OLD | NEW |