| 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/browser/service_process/service_process_control.h" | 5 #include "chrome/browser/service_process/service_process_control.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/process/kill.h" | 12 #include "base/process/kill.h" |
| 13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
| 14 #include "base/process/process_iterator.h" | 14 #include "base/process/process_iterator.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/test/test_timeouts.h" | 16 #include "base/test/test_timeouts.h" |
| 17 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
| 20 #include "chrome/common/chrome_version_info.h" | |
| 21 #include "chrome/common/service_process_util.h" | 20 #include "chrome/common/service_process_util.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "components/version_info/version_info.h" |
| 23 #include "content/public/common/content_paths.h" | 23 #include "content/public/common/content_paths.h" |
| 24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 25 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 27 | 27 |
| 28 class ServiceProcessControlBrowserTest | 28 class ServiceProcessControlBrowserTest |
| 29 : public InProcessBrowserTest { | 29 : public InProcessBrowserTest { |
| 30 public: | 30 public: |
| 31 ServiceProcessControlBrowserTest() { | 31 ServiceProcessControlBrowserTest() { |
| 32 } | 32 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 238 } |
| 239 | 239 |
| 240 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, ForceShutdown) { | 240 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, ForceShutdown) { |
| 241 // Launch the service process. | 241 // Launch the service process. |
| 242 LaunchServiceProcessControl(); | 242 LaunchServiceProcessControl(); |
| 243 // Make sure we are connected to the service process. | 243 // Make sure we are connected to the service process. |
| 244 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); | 244 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); |
| 245 base::ProcessId service_pid; | 245 base::ProcessId service_pid; |
| 246 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 246 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
| 247 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 247 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
| 248 chrome::VersionInfo version_info; | 248 ForceServiceProcessShutdown(version_info::GetVersionNumber(), service_pid); |
| 249 ForceServiceProcessShutdown(version_info.Version(), service_pid); | |
| 250 } | 249 } |
| 251 | 250 |
| 252 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, CheckPid) { | 251 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, CheckPid) { |
| 253 base::ProcessId service_pid; | 252 base::ProcessId service_pid; |
| 254 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); | 253 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); |
| 255 // Launch the service process. | 254 // Launch the service process. |
| 256 LaunchServiceProcessControl(); | 255 LaunchServiceProcessControl(); |
| 257 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 256 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
| 258 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 257 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
| 259 // Disconnect from service process. | 258 // Disconnect from service process. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // Callback should not be called during GetHistograms call. | 297 // Callback should not be called during GetHistograms call. |
| 299 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); | 298 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); |
| 300 // Wait for real callback by providing large timeout value. | 299 // Wait for real callback by providing large timeout value. |
| 301 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( | 300 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( |
| 302 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, | 301 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, |
| 303 base::Unretained(this)), | 302 base::Unretained(this)), |
| 304 base::TimeDelta::FromHours(1))); | 303 base::TimeDelta::FromHours(1))); |
| 305 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); | 304 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); |
| 306 content::RunMessageLoop(); | 305 content::RunMessageLoop(); |
| 307 } | 306 } |
| OLD | NEW |