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

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

Issue 10822030: Move ui_test_utils::RunMessageLoop to test_utils so that it can be reused by content_browsertests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months 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
OLDNEW
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 "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 24 matching lines...) Expand all
35 void LaunchServiceProcessControl() { 35 void LaunchServiceProcessControl() {
36 // Launch the process asynchronously. 36 // Launch the process asynchronously.
37 ServiceProcessControl::GetInstance()->Launch( 37 ServiceProcessControl::GetInstance()->Launch(
38 base::Bind(&ServiceProcessControlBrowserTest::ProcessControlLaunched, 38 base::Bind(&ServiceProcessControlBrowserTest::ProcessControlLaunched,
39 this), 39 this),
40 base::Bind( 40 base::Bind(
41 &ServiceProcessControlBrowserTest::ProcessControlLaunchFailed, 41 &ServiceProcessControlBrowserTest::ProcessControlLaunchFailed,
42 this)); 42 this));
43 43
44 // Then run the message loop to keep things running. 44 // Then run the message loop to keep things running.
45 ui_test_utils::RunMessageLoop(); 45 content::RunMessageLoop();
46 } 46 }
47 47
48 // Send a Cloud Print status request and wait for a reply from the service. 48 // Send a Cloud Print status request and wait for a reply from the service.
49 void SendRequestAndWait() { 49 void SendRequestAndWait() {
50 ServiceProcessControl::GetInstance()->GetCloudPrintProxyInfo( 50 ServiceProcessControl::GetInstance()->GetCloudPrintProxyInfo(
51 base::Bind(&ServiceProcessControlBrowserTest::CloudPrintInfoCallback, 51 base::Bind(&ServiceProcessControlBrowserTest::CloudPrintInfoCallback,
52 base::Unretained(this))); 52 base::Unretained(this)));
53 ui_test_utils::RunMessageLoop(); 53 content::RunMessageLoop();
54 } 54 }
55 55
56 void CloudPrintInfoCallback( 56 void CloudPrintInfoCallback(
57 const cloud_print::CloudPrintProxyInfo& proxy_info) { 57 const cloud_print::CloudPrintProxyInfo& proxy_info) {
58 MessageLoop::current()->Quit(); 58 MessageLoop::current()->Quit();
59 } 59 }
60 60
61 void Disconnect() { 61 void Disconnect() {
62 // This will close the IPC connection. 62 // This will close the IPC connection.
63 ServiceProcessControl::GetInstance()->Disconnect(); 63 ServiceProcessControl::GetInstance()->Disconnect();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, 140 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest,
141 MultipleLaunchTasks) { 141 MultipleLaunchTasks) {
142 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); 142 ServiceProcessControl* process = ServiceProcessControl::GetInstance();
143 int launch_count = 5; 143 int launch_count = 5;
144 for (int i = 0; i < launch_count; i++) { 144 for (int i = 0; i < launch_count; i++) {
145 // Launch the process asynchronously. 145 // Launch the process asynchronously.
146 process->Launch(base::Bind(&DecrementUntilZero, &launch_count), 146 process->Launch(base::Bind(&DecrementUntilZero, &launch_count),
147 MessageLoop::QuitClosure()); 147 MessageLoop::QuitClosure());
148 } 148 }
149 // Then run the message loop to keep things running. 149 // Then run the message loop to keep things running.
150 ui_test_utils::RunMessageLoop(); 150 content::RunMessageLoop();
151 EXPECT_EQ(0, launch_count); 151 EXPECT_EQ(0, launch_count);
152 // And then shutdown the service process. 152 // And then shutdown the service process.
153 EXPECT_TRUE(process->Shutdown()); 153 EXPECT_TRUE(process->Shutdown());
154 } 154 }
155 155
156 // Make sure using the same task for success and failure tasks works. 156 // Make sure using the same task for success and failure tasks works.
157 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, SameLaunchTask) { 157 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, SameLaunchTask) {
158 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); 158 ServiceProcessControl* process = ServiceProcessControl::GetInstance();
159 int launch_count = 5; 159 int launch_count = 5;
160 for (int i = 0; i < launch_count; i++) { 160 for (int i = 0; i < launch_count; i++) {
161 // Launch the process asynchronously. 161 // Launch the process asynchronously.
162 base::Closure task = base::Bind(&DecrementUntilZero, &launch_count); 162 base::Closure task = base::Bind(&DecrementUntilZero, &launch_count);
163 process->Launch(task, task); 163 process->Launch(task, task);
164 } 164 }
165 // Then run the message loop to keep things running. 165 // Then run the message loop to keep things running.
166 ui_test_utils::RunMessageLoop(); 166 content::RunMessageLoop();
167 EXPECT_EQ(0, launch_count); 167 EXPECT_EQ(0, launch_count);
168 // And then shutdown the service process. 168 // And then shutdown the service process.
169 EXPECT_TRUE(process->Shutdown()); 169 EXPECT_TRUE(process->Shutdown());
170 } 170 }
171 171
172 // Tests whether disconnecting from the service IPC causes the service process 172 // Tests whether disconnecting from the service IPC causes the service process
173 // to die. 173 // to die.
174 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, 174 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest,
175 DieOnDisconnect) { 175 DieOnDisconnect) {
176 // Launch the service process. 176 // Launch the service process.
(...skipping 21 matching lines...) Expand all
198 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, CheckPid) { 198 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, CheckPid) {
199 base::ProcessId service_pid; 199 base::ProcessId service_pid;
200 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); 200 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid));
201 // Launch the service process. 201 // Launch the service process.
202 LaunchServiceProcessControl(); 202 LaunchServiceProcessControl();
203 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); 203 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid));
204 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); 204 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid);
205 // Disconnect from service process. 205 // Disconnect from service process.
206 ServiceProcessControl::GetInstance()->Disconnect(); 206 ServiceProcessControl::GetInstance()->Disconnect();
207 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_scraper_unittest.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698