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/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 static void CloudPrintInfoCallback( | 61 static void CloudPrintInfoCallback( |
62 const cloud_print::CloudPrintProxyInfo& proxy_info) { | 62 const cloud_print::CloudPrintProxyInfo& proxy_info) { |
63 QuitMessageLoop(); | 63 QuitMessageLoop(); |
64 } | 64 } |
65 | 65 |
66 void Disconnect() { | 66 void Disconnect() { |
67 // This will close the IPC connection. | 67 // This will close the IPC connection. |
68 ServiceProcessControl::GetInstance()->Disconnect(); | 68 ServiceProcessControl::GetInstance()->Disconnect(); |
69 } | 69 } |
70 | 70 |
71 virtual void SetUp() OVERRIDE { | 71 virtual void SetUp() override { |
72 service_process_handle_ = base::kNullProcessHandle; | 72 service_process_handle_ = base::kNullProcessHandle; |
73 } | 73 } |
74 | 74 |
75 virtual void TearDown() OVERRIDE { | 75 virtual void TearDown() override { |
76 if (ServiceProcessControl::GetInstance()->IsConnected()) | 76 if (ServiceProcessControl::GetInstance()->IsConnected()) |
77 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); | 77 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
78 #if defined(OS_MACOSX) | 78 #if defined(OS_MACOSX) |
79 // ForceServiceProcessShutdown removes the process from launched on Mac. | 79 // ForceServiceProcessShutdown removes the process from launched on Mac. |
80 ForceServiceProcessShutdown("", 0); | 80 ForceServiceProcessShutdown("", 0); |
81 #endif // OS_MACOSX | 81 #endif // OS_MACOSX |
82 if (service_process_handle_ != base::kNullProcessHandle) { | 82 if (service_process_handle_ != base::kNullProcessHandle) { |
83 EXPECT_TRUE(base::WaitForSingleProcess( | 83 EXPECT_TRUE(base::WaitForSingleProcess( |
84 service_process_handle_, | 84 service_process_handle_, |
85 TestTimeouts::action_max_timeout())); | 85 TestTimeouts::action_max_timeout())); |
(...skipping 25 matching lines...) Expand all Loading... |
111 base::MessageLoop::QuitClosure()); | 111 base::MessageLoop::QuitClosure()); |
112 } | 112 } |
113 | 113 |
114 private: | 114 private: |
115 base::ProcessHandle service_process_handle_; | 115 base::ProcessHandle service_process_handle_; |
116 }; | 116 }; |
117 | 117 |
118 class RealServiceProcessControlBrowserTest | 118 class RealServiceProcessControlBrowserTest |
119 : public ServiceProcessControlBrowserTest { | 119 : public ServiceProcessControlBrowserTest { |
120 public: | 120 public: |
121 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 121 virtual void SetUpCommandLine(CommandLine* command_line) override { |
122 ServiceProcessControlBrowserTest::SetUpCommandLine(command_line); | 122 ServiceProcessControlBrowserTest::SetUpCommandLine(command_line); |
123 base::FilePath exe; | 123 base::FilePath exe; |
124 PathService::Get(base::DIR_EXE, &exe); | 124 PathService::Get(base::DIR_EXE, &exe); |
125 #if defined(OS_MACOSX) | 125 #if defined(OS_MACOSX) |
126 exe = exe.DirName().DirName().DirName(); | 126 exe = exe.DirName().DirName().DirName(); |
127 #endif | 127 #endif |
128 exe = exe.Append(chrome::kHelperProcessExecutablePath); | 128 exe = exe.Append(chrome::kHelperProcessExecutablePath); |
129 // Run chrome instead of browser_tests.exe. | 129 // Run chrome instead of browser_tests.exe. |
130 EXPECT_TRUE(base::PathExists(exe)); | 130 EXPECT_TRUE(base::PathExists(exe)); |
131 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, exe); | 131 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, exe); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // Callback should not be called during GetHistograms call. | 279 // Callback should not be called during GetHistograms call. |
280 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); | 280 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); |
281 // Wait for real callback by providing large timeout value. | 281 // Wait for real callback by providing large timeout value. |
282 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( | 282 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( |
283 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, | 283 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, |
284 base::Unretained(this)), | 284 base::Unretained(this)), |
285 base::TimeDelta::FromHours(1))); | 285 base::TimeDelta::FromHours(1))); |
286 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); | 286 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); |
287 content::RunMessageLoop(); | 287 content::RunMessageLoop(); |
288 } | 288 } |
OLD | NEW |