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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 ServiceProcessControl::GetInstance()->GetCloudPrintProxyInfo( | 165 ServiceProcessControl::GetInstance()->GetCloudPrintProxyInfo( |
166 base::Bind(&ServiceProcessControlBrowserTest::CloudPrintInfoCallback)); | 166 base::Bind(&ServiceProcessControlBrowserTest::CloudPrintInfoCallback)); |
167 content::RunMessageLoop(); | 167 content::RunMessageLoop(); |
168 | 168 |
169 // And then shutdown the service process. | 169 // And then shutdown the service process. |
170 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); | 170 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
171 } | 171 } |
172 | 172 |
173 // This tests the case when a service process is launched when the browser | 173 // This tests the case when a service process is launched when the browser |
174 // starts but we try to launch it again while setting up Cloud Print. | 174 // starts but we try to launch it again while setting up Cloud Print. |
175 // Flaky on Mac ASan. http://crbug.com/517420 | 175 // Flaky on Mac. http://crbug.com/517420 |
176 #if defined(OS_MACOSX) | 176 #if defined(OS_MACOSX) |
177 #define MAYBE_LaunchTwice DISABLED_LaunchTwice | 177 #define MAYBE_LaunchTwice DISABLED_LaunchTwice |
178 #else | 178 #else |
179 #define MAYBE_LaunchTwice LaunchTwice | 179 #define MAYBE_LaunchTwice LaunchTwice |
180 #endif | 180 #endif |
181 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_LaunchTwice) { | 181 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_LaunchTwice) { |
182 // Launch the service process the first time. | 182 // Launch the service process the first time. |
183 LaunchServiceProcessControl(); | 183 LaunchServiceProcessControl(); |
184 | 184 |
185 // Make sure we are connected to the service process. | 185 // Make sure we are connected to the service process. |
(...skipping 10 matching lines...) Expand all Loading... |
196 content::RunMessageLoop(); | 196 content::RunMessageLoop(); |
197 } | 197 } |
198 | 198 |
199 static void DecrementUntilZero(int* count) { | 199 static void DecrementUntilZero(int* count) { |
200 (*count)--; | 200 (*count)--; |
201 if (!(*count)) | 201 if (!(*count)) |
202 base::ThreadTaskRunnerHandle::Get()->PostTask( | 202 base::ThreadTaskRunnerHandle::Get()->PostTask( |
203 FROM_HERE, base::MessageLoop::QuitClosure()); | 203 FROM_HERE, base::MessageLoop::QuitClosure()); |
204 } | 204 } |
205 | 205 |
206 // Flaky on Mac ASan. http://crbug.com/517420 | 206 // Flaky on Mac. http://crbug.com/517420 |
207 #if defined(OS_MACOSX) | 207 #if defined(OS_MACOSX) |
208 #define MAYBE_MultipleLaunchTasks DISABLED_MultipleLaunchTasks | 208 #define MAYBE_MultipleLaunchTasks DISABLED_MultipleLaunchTasks |
209 #else | 209 #else |
210 #define MAYBE_MultipleLaunchTasks MultipleLaunchTasks | 210 #define MAYBE_MultipleLaunchTasks MultipleLaunchTasks |
211 #endif | 211 #endif |
212 // Invoke multiple Launch calls in succession and ensure that all the tasks | 212 // Invoke multiple Launch calls in succession and ensure that all the tasks |
213 // get invoked. | 213 // get invoked. |
214 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, | 214 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, |
215 MAYBE_MultipleLaunchTasks) { | 215 MAYBE_MultipleLaunchTasks) { |
216 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); | 216 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); |
217 int launch_count = 5; | 217 int launch_count = 5; |
218 for (int i = 0; i < launch_count; i++) { | 218 for (int i = 0; i < launch_count; i++) { |
219 // Launch the process asynchronously. | 219 // Launch the process asynchronously. |
220 process->Launch(base::Bind(&DecrementUntilZero, &launch_count), | 220 process->Launch(base::Bind(&DecrementUntilZero, &launch_count), |
221 base::MessageLoop::QuitClosure()); | 221 base::MessageLoop::QuitClosure()); |
222 } | 222 } |
223 // Then run the message loop to keep things running. | 223 // Then run the message loop to keep things running. |
224 content::RunMessageLoop(); | 224 content::RunMessageLoop(); |
225 EXPECT_EQ(0, launch_count); | 225 EXPECT_EQ(0, launch_count); |
226 } | 226 } |
227 | 227 |
| 228 // Flaky on Mac. http://crbug.com/517420 |
| 229 #if defined(OS_MACOSX) |
| 230 #define MAYBE_SameLaunchTask DISABLED_SameLaunchTask |
| 231 #else |
| 232 #define MAYBE_SameLaunchTask SameLaunchTask |
| 233 #endif |
228 // Make sure using the same task for success and failure tasks works. | 234 // Make sure using the same task for success and failure tasks works. |
229 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, SameLaunchTask) { | 235 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_SameLaunchTask) { |
230 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); | 236 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); |
231 int launch_count = 5; | 237 int launch_count = 5; |
232 for (int i = 0; i < launch_count; i++) { | 238 for (int i = 0; i < launch_count; i++) { |
233 // Launch the process asynchronously. | 239 // Launch the process asynchronously. |
234 base::Closure task = base::Bind(&DecrementUntilZero, &launch_count); | 240 base::Closure task = base::Bind(&DecrementUntilZero, &launch_count); |
235 process->Launch(task, task); | 241 process->Launch(task, task); |
236 } | 242 } |
237 // Then run the message loop to keep things running. | 243 // Then run the message loop to keep things running. |
238 content::RunMessageLoop(); | 244 content::RunMessageLoop(); |
239 EXPECT_EQ(0, launch_count); | 245 EXPECT_EQ(0, launch_count); |
240 } | 246 } |
241 | 247 |
242 // Tests whether disconnecting from the service IPC causes the service process | 248 // Tests whether disconnecting from the service IPC causes the service process |
243 // to die. | 249 // to die. |
244 // Flaky on Mac ASan. http://crbug.com/517420 | 250 // Flaky on Mac. http://crbug.com/517420 |
245 #if defined(OS_MACOSX) | 251 #if defined(OS_MACOSX) |
246 #define MAYBE_DieOnDisconnect DISABLED_DieOnDisconnect | 252 #define MAYBE_DieOnDisconnect DISABLED_DieOnDisconnect |
247 #else | 253 #else |
248 #define MAYBE_DieOnDisconnect DieOnDisconnect | 254 #define MAYBE_DieOnDisconnect DieOnDisconnect |
249 #endif | 255 #endif |
250 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, | 256 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, |
251 MAYBE_DieOnDisconnect) { | 257 MAYBE_DieOnDisconnect) { |
252 // Launch the service process. | 258 // Launch the service process. |
253 LaunchServiceProcessControl(); | 259 LaunchServiceProcessControl(); |
254 // Make sure we are connected to the service process. | 260 // Make sure we are connected to the service process. |
255 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); | 261 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); |
256 Disconnect(); | 262 Disconnect(); |
257 } | 263 } |
258 | 264 |
259 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, ForceShutdown) { | 265 // Flaky on Mac. http://crbug.com/517420 |
| 266 #if defined(OS_MACOSX) |
| 267 #define MAYBE_ForceShutdown DISABLED_ForceShutdown |
| 268 #else |
| 269 #define MAYBE_ForceShutdown ForceShutdown |
| 270 #endif |
| 271 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_ForceShutdown) { |
260 // Launch the service process. | 272 // Launch the service process. |
261 LaunchServiceProcessControl(); | 273 LaunchServiceProcessControl(); |
262 // Make sure we are connected to the service process. | 274 // Make sure we are connected to the service process. |
263 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); | 275 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); |
264 base::ProcessId service_pid; | 276 base::ProcessId service_pid; |
265 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 277 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
266 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 278 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
267 ForceServiceProcessShutdown(version_info::GetVersionNumber(), service_pid); | 279 ForceServiceProcessShutdown(version_info::GetVersionNumber(), service_pid); |
268 } | 280 } |
269 | 281 |
270 // Flaky on Mac ASan. http://crbug.com/517420 | 282 // Flaky on Mac. http://crbug.com/517420 |
271 #if defined(OS_MACOSX) | 283 #if defined(OS_MACOSX) |
272 #define MAYBE_CheckPid DISABLED_CheckPid | 284 #define MAYBE_CheckPid DISABLED_CheckPid |
273 #else | 285 #else |
274 #define MAYBE_CheckPid CheckPid | 286 #define MAYBE_CheckPid CheckPid |
275 #endif | 287 #endif |
276 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_CheckPid) { | 288 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_CheckPid) { |
277 base::ProcessId service_pid; | 289 base::ProcessId service_pid; |
278 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); | 290 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); |
279 // Launch the service process. | 291 // Launch the service process. |
280 LaunchServiceProcessControl(); | 292 LaunchServiceProcessControl(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // Callback should not be called during GetHistograms call. | 334 // Callback should not be called during GetHistograms call. |
323 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); | 335 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); |
324 // Wait for real callback by providing large timeout value. | 336 // Wait for real callback by providing large timeout value. |
325 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( | 337 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( |
326 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, | 338 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, |
327 base::Unretained(this)), | 339 base::Unretained(this)), |
328 base::TimeDelta::FromHours(1))); | 340 base::TimeDelta::FromHours(1))); |
329 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); | 341 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); |
330 content::RunMessageLoop(); | 342 content::RunMessageLoop(); |
331 } | 343 } |
OLD | NEW |