Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: chrome/browser/service/service_process_control_browsertest.cc

Issue 8620001: Cleanup pass from Cloud Print Proxy policy implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/service/service_process_control.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/process_util.h" 7 #include "base/process_util.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "chrome/browser/service/service_process_control.h" 9 #include "chrome/browser/service/service_process_control.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 }; 94 };
95 95
96 // They way that the IPC is implemented only works on windows. This has to 96 // They way that the IPC is implemented only works on windows. This has to
97 // change when we implement a different scheme for IPC. 97 // change when we implement a different scheme for IPC.
98 // Times out flakily, http://crbug.com/70076. 98 // Times out flakily, http://crbug.com/70076.
99 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, 99 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest,
100 DISABLED_LaunchAndIPC) { 100 DISABLED_LaunchAndIPC) {
101 LaunchServiceProcessControl(); 101 LaunchServiceProcessControl();
102 102
103 // Make sure we are connected to the service process. 103 // Make sure we are connected to the service process.
104 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); 104 EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected());
105 SendRequestAndWait(); 105 SendRequestAndWait();
106 106
107 // And then shutdown the service process. 107 // And then shutdown the service process.
108 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); 108 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown());
109 } 109 }
110 110
111 // This tests the case when a service process is launched when the browser 111 // This tests the case when a service process is launched when the browser
112 // starts but we try to launch it again while setting up Cloud Print. 112 // starts but we try to launch it again while setting up Cloud Print.
113 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, LaunchTwice) { 113 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, LaunchTwice) {
114 // Launch the service process the first time. 114 // Launch the service process the first time.
115 LaunchServiceProcessControl(); 115 LaunchServiceProcessControl();
116 116
117 // Make sure we are connected to the service process. 117 // Make sure we are connected to the service process.
118 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); 118 EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected());
119 SendRequestAndWait(); 119 SendRequestAndWait();
120 120
121 // Launch the service process again. 121 // Launch the service process again.
122 LaunchServiceProcessControl(); 122 LaunchServiceProcessControl();
123 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); 123 EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected());
124 SendRequestAndWait(); 124 SendRequestAndWait();
125 125
126 // And then shutdown the service process. 126 // And then shutdown the service process.
127 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); 127 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown());
128 } 128 }
129 129
130 static void DecrementUntilZero(int* count) { 130 static void DecrementUntilZero(int* count) {
131 (*count)--; 131 (*count)--;
132 if (!(*count)) 132 if (!(*count))
133 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 133 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 EXPECT_TRUE(process->Shutdown()); 167 EXPECT_TRUE(process->Shutdown());
168 } 168 }
169 169
170 // Tests whether disconnecting from the service IPC causes the service process 170 // Tests whether disconnecting from the service IPC causes the service process
171 // to die. 171 // to die.
172 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, 172 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest,
173 DieOnDisconnect) { 173 DieOnDisconnect) {
174 // Launch the service process. 174 // Launch the service process.
175 LaunchServiceProcessControl(); 175 LaunchServiceProcessControl();
176 // Make sure we are connected to the service process. 176 // Make sure we are connected to the service process.
177 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); 177 EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected());
178 Disconnect(); 178 Disconnect();
179 WaitForShutdown(); 179 WaitForShutdown();
180 } 180 }
181 181
182 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, 182 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest,
183 ForceShutdown) { 183 ForceShutdown) {
184 // Launch the service process. 184 // Launch the service process.
185 LaunchServiceProcessControl(); 185 LaunchServiceProcessControl();
186 // Make sure we are connected to the service process. 186 // Make sure we are connected to the service process.
187 EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); 187 EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected());
188 base::ProcessId service_pid; 188 base::ProcessId service_pid;
189 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); 189 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid));
190 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); 190 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid);
191 chrome::VersionInfo version_info; 191 chrome::VersionInfo version_info;
192 ForceServiceProcessShutdown(version_info.Version(), service_pid); 192 ForceServiceProcessShutdown(version_info.Version(), service_pid);
193 WaitForShutdown(); 193 WaitForShutdown();
194 } 194 }
195 195
196 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, CheckPid) { 196 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, CheckPid) {
197 base::ProcessId service_pid; 197 base::ProcessId service_pid;
198 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); 198 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid));
199 // Launch the service process. 199 // Launch the service process.
200 LaunchServiceProcessControl(); 200 LaunchServiceProcessControl();
201 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); 201 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid));
202 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); 202 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid);
203 // Disconnect from service process. 203 // Disconnect from service process.
204 ServiceProcessControl::GetInstance()->Disconnect(); 204 ServiceProcessControl::GetInstance()->Disconnect();
205 } 205 }
206 206
207 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControlBrowserTest); 207 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControlBrowserTest);
OLDNEW
« no previous file with comments | « chrome/browser/service/service_process_control.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698