Chromium Code Reviews| Index: chrome/browser/service_process/service_process_control_browsertest.cc |
| diff --git a/chrome/browser/service_process/service_process_control_browsertest.cc b/chrome/browser/service_process/service_process_control_browsertest.cc |
| index a15ed69cf467120a9a73845dbbf8cf0c79ddc284..191c7a3fcca279fd5a1a010b32850d0c4a316af9 100644 |
| --- a/chrome/browser/service_process/service_process_control_browsertest.cc |
| +++ b/chrome/browser/service_process/service_process_control_browsertest.cc |
| @@ -18,6 +18,7 @@ |
| #include "build/build_config.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/common/chrome_constants.h" |
| +#include "chrome/common/service_messages.h" |
| #include "chrome/common/service_process_util.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "components/version_info/version_info.h" |
| @@ -42,7 +43,7 @@ class ServiceProcessControlBrowserTest |
| MOCK_METHOD0(MockHistogramsCallback, void()); |
| protected: |
| - void LaunchServiceProcessControl() { |
| + void LaunchServiceProcessControl(bool wait = true) { |
|
Lei Zhang
2016/09/01 06:12:01
Can we avoid having default arguments? There can't
Sam McNally
2016/09/01 06:58:44
Done.
|
| // Launch the process asynchronously. |
| ServiceProcessControl::GetInstance()->Launch( |
| base::Bind(&ServiceProcessControlBrowserTest::ProcessControlLaunched, |
| @@ -52,7 +53,8 @@ class ServiceProcessControlBrowserTest |
| base::Unretained(this))); |
| // Then run the message loop to keep things running. |
| - content::RunMessageLoop(); |
| + if (wait) |
| + content::RunMessageLoop(); |
| } |
| static void QuitMessageLoop() { |
| @@ -171,6 +173,31 @@ IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, LaunchAndIPC) { |
| EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
| } |
| +IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, LaunchAndReconnect) { |
| + LaunchServiceProcessControl(); |
| + |
| + // Make sure we are connected to the service process. |
| + ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); |
| + ServiceProcessControl::GetInstance()->Send( |
| + new ServiceMsg_StayAliveForTesting); |
| + ServiceProcessControl::GetInstance()->GetCloudPrintProxyInfo( |
| + base::Bind(&ServiceProcessControlBrowserTest::CloudPrintInfoCallback)); |
| + content::RunMessageLoop(); |
| + Disconnect(); |
| + |
| + LaunchServiceProcessControl(false); |
| + |
| + ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); |
| + content::RunMessageLoop(); |
| + |
| + ServiceProcessControl::GetInstance()->GetCloudPrintProxyInfo( |
| + base::Bind(&ServiceProcessControlBrowserTest::CloudPrintInfoCallback)); |
| + content::RunMessageLoop(); |
| + |
| + // And then shutdown the service process. |
| + EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
| +} |
| + |
| // This tests the case when a service process is launched when the browser |
| // starts but we try to launch it again while setting up Cloud Print. |
| // Flaky on Mac. http://crbug.com/517420 |