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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void SetUp() override { | 71 void SetUp() override { |
| 72 InProcessBrowserTest::SetUp(); |
| 73 |
72 // This should not be needed because TearDown() ends with a closed | 74 // This should not be needed because TearDown() ends with a closed |
73 // service_process_, but HistogramsTimeout and Histograms fail without this | 75 // service_process_, but HistogramsTimeout and Histograms fail without this |
74 // on Mac. | 76 // on Mac. |
75 service_process_.Close(); | 77 service_process_.Close(); |
76 } | 78 } |
77 | 79 |
78 void TearDown() override { | 80 void TearDown() override { |
79 if (ServiceProcessControl::GetInstance()->IsConnected()) | 81 if (ServiceProcessControl::GetInstance()->IsConnected()) |
80 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); | 82 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
81 #if defined(OS_MACOSX) | 83 #if defined(OS_MACOSX) |
82 // ForceServiceProcessShutdown removes the process from launched on Mac. | 84 // ForceServiceProcessShutdown removes the process from launched on Mac. |
83 ForceServiceProcessShutdown("", 0); | 85 ForceServiceProcessShutdown("", 0); |
84 #endif // OS_MACOSX | 86 #endif // OS_MACOSX |
85 if (service_process_.IsValid()) { | 87 if (service_process_.IsValid()) { |
86 int exit_code; | 88 int exit_code; |
87 EXPECT_TRUE(service_process_.WaitForExitWithTimeout( | 89 EXPECT_TRUE(service_process_.WaitForExitWithTimeout( |
88 TestTimeouts::action_max_timeout(), &exit_code)); | 90 TestTimeouts::action_max_timeout(), &exit_code)); |
89 EXPECT_EQ(0, exit_code); | 91 EXPECT_EQ(0, exit_code); |
90 service_process_.Close(); | 92 service_process_.Close(); |
91 } | 93 } |
| 94 |
| 95 InProcessBrowserTest::TearDown(); |
92 } | 96 } |
93 | 97 |
94 void ProcessControlLaunched() { | 98 void ProcessControlLaunched() { |
95 base::ProcessId service_pid; | 99 base::ProcessId service_pid; |
96 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 100 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
97 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 101 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
98 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
99 service_process_ = | 103 service_process_ = |
100 base::Process::OpenWithAccess(service_pid, | 104 base::Process::OpenWithAccess(service_pid, |
101 SYNCHRONIZE | PROCESS_QUERY_INFORMATION); | 105 SYNCHRONIZE | PROCESS_QUERY_INFORMATION); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 262 |
259 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, HistogramsNoService) { | 263 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, HistogramsNoService) { |
260 ASSERT_FALSE(ServiceProcessControl::GetInstance()->IsConnected()); | 264 ASSERT_FALSE(ServiceProcessControl::GetInstance()->IsConnected()); |
261 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); | 265 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); |
262 EXPECT_FALSE(ServiceProcessControl::GetInstance()->GetHistograms( | 266 EXPECT_FALSE(ServiceProcessControl::GetInstance()->GetHistograms( |
263 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, | 267 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, |
264 base::Unretained(this)), | 268 base::Unretained(this)), |
265 base::TimeDelta())); | 269 base::TimeDelta())); |
266 } | 270 } |
267 | 271 |
268 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, HistogramsTimeout) { | 272 // Histograms disabled on OSX http://crbug.com/406227 |
| 273 #if defined(OS_MACOSX) |
| 274 #define MAYBE_HistogramsTimeout DISABLED_HistogramsTimeout |
| 275 #define MAYBE_Histograms DISABLED_Histograms |
| 276 #else |
| 277 #define MAYBE_HistogramsTimeout HistogramsTimeout |
| 278 #define MAYBE_Histograms Histograms |
| 279 #endif |
| 280 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, |
| 281 MAYBE_HistogramsTimeout) { |
269 LaunchServiceProcessControl(); | 282 LaunchServiceProcessControl(); |
270 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); | 283 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); |
271 // Callback should not be called during GetHistograms call. | 284 // Callback should not be called during GetHistograms call. |
272 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); | 285 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); |
273 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( | 286 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( |
274 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, | 287 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, |
275 base::Unretained(this)), | 288 base::Unretained(this)), |
276 base::TimeDelta::FromMilliseconds(100))); | 289 base::TimeDelta::FromMilliseconds(100))); |
277 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); | 290 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); |
278 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); | 291 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
279 content::RunMessageLoop(); | 292 content::RunMessageLoop(); |
280 } | 293 } |
281 | 294 |
282 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, Histograms) { | 295 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_Histograms) { |
283 LaunchServiceProcessControl(); | 296 LaunchServiceProcessControl(); |
284 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); | 297 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); |
285 // Callback should not be called during GetHistograms call. | 298 // Callback should not be called during GetHistograms call. |
286 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); | 299 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); |
287 // Wait for real callback by providing large timeout value. | 300 // Wait for real callback by providing large timeout value. |
288 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( | 301 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( |
289 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, | 302 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, |
290 base::Unretained(this)), | 303 base::Unretained(this)), |
291 base::TimeDelta::FromHours(1))); | 304 base::TimeDelta::FromHours(1))); |
292 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); | 305 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); |
293 content::RunMessageLoop(); | 306 content::RunMessageLoop(); |
294 } | 307 } |
OLD | NEW |