| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/process_util.h" | 5 #include "base/process_util.h" |
| 6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
| 7 #include "chrome/browser/service/service_process_control.h" | 7 #include "chrome/browser/service/service_process_control.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/common/chrome_version_info.h" | 9 #include "chrome/common/chrome_version_info.h" |
| 10 #include "chrome/common/service_process_util.h" | 10 #include "chrome/common/service_process_util.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Make sure we are connected to the service process. | 101 // Make sure we are connected to the service process. |
| 102 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); | 102 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); |
| 103 SendRequestAndWait(); | 103 SendRequestAndWait(); |
| 104 | 104 |
| 105 // And then shutdown the service process. | 105 // And then shutdown the service process. |
| 106 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); | 106 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
| 107 } | 107 } |
| 108 | 108 |
| 109 // This tests the case when a service process is launched when the browser | 109 // This tests the case when a service process is launched when the browser |
| 110 // starts but we try to launch it again while setting up Cloud Print. | 110 // starts but we try to launch it again while setting up Cloud Print. |
| 111 // Crashes on mac. http://crbug.com/75518 | 111 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, LaunchTwice) { |
| 112 #if defined(OS_MACOSX) | |
| 113 #define MAYBE_LaunchTwice DISABLED_LaunchTwice | |
| 114 #else | |
| 115 #define MAYBE_LaunchTwice LaunchTwice | |
| 116 #endif | |
| 117 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_LaunchTwice) { | |
| 118 // Launch the service process the first time. | 112 // Launch the service process the first time. |
| 119 LaunchServiceProcessControl(); | 113 LaunchServiceProcessControl(); |
| 120 | 114 |
| 121 // Make sure we are connected to the service process. | 115 // Make sure we are connected to the service process. |
| 122 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); | 116 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); |
| 123 SendRequestAndWait(); | 117 SendRequestAndWait(); |
| 124 | 118 |
| 125 // Launch the service process again. | 119 // Launch the service process again. |
| 126 LaunchServiceProcessControl(); | 120 LaunchServiceProcessControl(); |
| 127 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); | 121 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); |
| 128 SendRequestAndWait(); | 122 SendRequestAndWait(); |
| 129 | 123 |
| 130 // And then shutdown the service process. | 124 // And then shutdown the service process. |
| 131 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); | 125 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
| 132 } | 126 } |
| 133 | 127 |
| 134 static void DecrementUntilZero(int* count) { | 128 static void DecrementUntilZero(int* count) { |
| 135 (*count)--; | 129 (*count)--; |
| 136 if (!(*count)) | 130 if (!(*count)) |
| 137 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 131 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 138 } | 132 } |
| 139 | 133 |
| 140 // Invoke multiple Launch calls in succession and ensure that all the tasks | 134 // Invoke multiple Launch calls in succession and ensure that all the tasks |
| 141 // get invoked. | 135 // get invoked. |
| 142 // Crashes on mac. http://crbug.com/75518 | |
| 143 #if defined(OS_MACOSX) | |
| 144 #define MAYBE_MultipleLaunchTasks DISABLED_MultipleLaunchTasks | |
| 145 #else | |
| 146 #define MAYBE_MultipleLaunchTasks MultipleLaunchTasks | |
| 147 #endif | |
| 148 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, | 136 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, |
| 149 MAYBE_MultipleLaunchTasks) { | 137 MultipleLaunchTasks) { |
| 150 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); | 138 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); |
| 151 int launch_count = 5; | 139 int launch_count = 5; |
| 152 for (int i = 0; i < launch_count; i++) { | 140 for (int i = 0; i < launch_count; i++) { |
| 153 // Launch the process asynchronously. | 141 // Launch the process asynchronously. |
| 154 process->Launch( | 142 process->Launch( |
| 155 NewRunnableFunction(&DecrementUntilZero, &launch_count), | 143 NewRunnableFunction(&DecrementUntilZero, &launch_count), |
| 156 new MessageLoop::QuitTask()); | 144 new MessageLoop::QuitTask()); |
| 157 } | 145 } |
| 158 // Then run the message loop to keep things running. | 146 // Then run the message loop to keep things running. |
| 159 ui_test_utils::RunMessageLoop(); | 147 ui_test_utils::RunMessageLoop(); |
| 160 EXPECT_EQ(0, launch_count); | 148 EXPECT_EQ(0, launch_count); |
| 161 // And then shutdown the service process. | 149 // And then shutdown the service process. |
| 162 EXPECT_TRUE(process->Shutdown()); | 150 EXPECT_TRUE(process->Shutdown()); |
| 163 } | 151 } |
| 164 | 152 |
| 165 // Make sure using the same task for success and failure tasks works. | 153 // Make sure using the same task for success and failure tasks works. |
| 166 // Crashes on mac. http://crbug.com/75518 | 154 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, SameLaunchTask) { |
| 167 #if defined(OS_MACOSX) | |
| 168 #define MAYBE_SameLaunchTask DISABLED_SameLaunchTask | |
| 169 #else | |
| 170 #define MAYBE_SameLaunchTask SameLaunchTask | |
| 171 #endif | |
| 172 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_SameLaunchTask) { | |
| 173 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); | 155 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); |
| 174 int launch_count = 5; | 156 int launch_count = 5; |
| 175 for (int i = 0; i < launch_count; i++) { | 157 for (int i = 0; i < launch_count; i++) { |
| 176 // Launch the process asynchronously. | 158 // Launch the process asynchronously. |
| 177 Task * task = NewRunnableFunction(&DecrementUntilZero, &launch_count); | 159 Task * task = NewRunnableFunction(&DecrementUntilZero, &launch_count); |
| 178 process->Launch(task, task); | 160 process->Launch(task, task); |
| 179 } | 161 } |
| 180 // Then run the message loop to keep things running. | 162 // Then run the message loop to keep things running. |
| 181 ui_test_utils::RunMessageLoop(); | 163 ui_test_utils::RunMessageLoop(); |
| 182 EXPECT_EQ(0, launch_count); | 164 EXPECT_EQ(0, launch_count); |
| 183 // And then shutdown the service process. | 165 // And then shutdown the service process. |
| 184 EXPECT_TRUE(process->Shutdown()); | 166 EXPECT_TRUE(process->Shutdown()); |
| 185 } | 167 } |
| 186 | 168 |
| 187 // Tests whether disconnecting from the service IPC causes the service process | 169 // Tests whether disconnecting from the service IPC causes the service process |
| 188 // to die. | 170 // to die. |
| 189 // Crashes on mac. http://crbug.com/75518 | |
| 190 #if defined(OS_MACOSX) | |
| 191 #define MAYBE_DieOnDisconnect DISABLED_DieOnDisconnect | |
| 192 #else | |
| 193 #define MAYBE_DieOnDisconnect DieOnDisconnect | |
| 194 #endif | |
| 195 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, | 171 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, |
| 196 MAYBE_DieOnDisconnect) { | 172 DieOnDisconnect) { |
| 197 // Launch the service process. | 173 // Launch the service process. |
| 198 LaunchServiceProcessControl(); | 174 LaunchServiceProcessControl(); |
| 199 // Make sure we are connected to the service process. | 175 // Make sure we are connected to the service process. |
| 200 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); | 176 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); |
| 201 Disconnect(); | 177 Disconnect(); |
| 202 WaitForShutdown(); | 178 WaitForShutdown(); |
| 203 } | 179 } |
| 204 | 180 |
| 205 //http://code.google.com/p/chromium/issues/detail?id=70793 | |
| 206 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, | 181 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, |
| 207 DISABLED_ForceShutdown) { | 182 ForceShutdown) { |
| 208 // Launch the service process. | 183 // Launch the service process. |
| 209 LaunchServiceProcessControl(); | 184 LaunchServiceProcessControl(); |
| 210 // Make sure we are connected to the service process. | 185 // Make sure we are connected to the service process. |
| 211 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); | 186 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); |
| 212 base::ProcessId service_pid; | 187 base::ProcessId service_pid; |
| 213 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 188 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
| 214 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 189 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
| 215 chrome::VersionInfo version_info; | 190 chrome::VersionInfo version_info; |
| 216 ForceServiceProcessShutdown(version_info.Version(), service_pid); | 191 ForceServiceProcessShutdown(version_info.Version(), service_pid); |
| 217 WaitForShutdown(); | 192 WaitForShutdown(); |
| 218 } | 193 } |
| 219 | 194 |
| 220 // Crashes on mac. http://crbug.com/75518 | 195 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, CheckPid) { |
| 221 #if defined(OS_MACOSX) | |
| 222 #define MAYBE_CheckPid DISABLED_CheckPid | |
| 223 #else | |
| 224 #define MAYBE_CheckPid CheckPid | |
| 225 #endif | |
| 226 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_CheckPid) { | |
| 227 base::ProcessId service_pid; | 196 base::ProcessId service_pid; |
| 228 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); | 197 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); |
| 229 // Launch the service process. | 198 // Launch the service process. |
| 230 LaunchServiceProcessControl(); | 199 LaunchServiceProcessControl(); |
| 231 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 200 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
| 232 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 201 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
| 233 // Disconnect from service process. | 202 // Disconnect from service process. |
| 234 ServiceProcessControl::GetInstance()->Disconnect(); | 203 ServiceProcessControl::GetInstance()->Disconnect(); |
| 235 } | 204 } |
| 236 | 205 |
| 237 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControlBrowserTest); | 206 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControlBrowserTest); |
| OLD | NEW |