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

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

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 years, 8 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
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 "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"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/process/kill.h" 12 #include "base/process/kill.h"
13 #include "base/process/process.h" 13 #include "base/process/process.h"
14 #include "base/process/process_iterator.h" 14 #include "base/process/process_iterator.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/test/test_timeouts.h" 16 #include "base/test/test_timeouts.h"
17 #include "base/threading/thread_restrictions.h"
17 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
20 #include "chrome/common/chrome_constants.h" 21 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/service_messages.h" 22 #include "chrome/common/service_messages.h"
22 #include "chrome/common/service_process_util.h" 23 #include "chrome/common/service_process_util.h"
23 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
24 #include "components/version_info/version_info.h" 25 #include "components/version_info/version_info.h"
25 #include "content/public/common/content_paths.h" 26 #include "content/public/common/content_paths.h"
26 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 EXPECT_TRUE(service_process_.WaitForExitWithTimeout( 93 EXPECT_TRUE(service_process_.WaitForExitWithTimeout(
93 TestTimeouts::action_max_timeout(), &exit_code)); 94 TestTimeouts::action_max_timeout(), &exit_code));
94 EXPECT_EQ(0, exit_code); 95 EXPECT_EQ(0, exit_code);
95 service_process_.Close(); 96 service_process_.Close();
96 } 97 }
97 98
98 InProcessBrowserTest::TearDown(); 99 InProcessBrowserTest::TearDown();
99 } 100 }
100 101
101 void ProcessControlLaunched() { 102 void ProcessControlLaunched() {
103 base::ThreadRestrictions::ScopedAllowIO allow_io;
102 base::ProcessId service_pid; 104 base::ProcessId service_pid;
103 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); 105 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid));
104 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); 106 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid);
105 #if defined(OS_WIN) 107 #if defined(OS_WIN)
106 service_process_ = 108 service_process_ =
107 base::Process::OpenWithAccess(service_pid, 109 base::Process::OpenWithAccess(service_pid,
108 SYNCHRONIZE | PROCESS_QUERY_INFORMATION); 110 SYNCHRONIZE | PROCESS_QUERY_INFORMATION);
109 #else 111 #else
110 service_process_ = base::Process::Open(service_pid); 112 service_process_ = base::Process::Open(service_pid);
111 #endif 113 #endif
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 #define MAYBE_ForceShutdown DISABLED_ForceShutdown 299 #define MAYBE_ForceShutdown DISABLED_ForceShutdown
298 #else 300 #else
299 #define MAYBE_ForceShutdown ForceShutdown 301 #define MAYBE_ForceShutdown ForceShutdown
300 #endif 302 #endif
301 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_ForceShutdown) { 303 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_ForceShutdown) {
302 // Launch the service process. 304 // Launch the service process.
303 LaunchServiceProcessControl(true); 305 LaunchServiceProcessControl(true);
304 // Make sure we are connected to the service process. 306 // Make sure we are connected to the service process.
305 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); 307 ASSERT_TRUE(ServiceProcessControl::GetInstance()->IsConnected());
306 base::ProcessId service_pid; 308 base::ProcessId service_pid;
309 base::ThreadRestrictions::ScopedAllowIO allow_io;
307 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); 310 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid));
308 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); 311 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid);
309 ForceServiceProcessShutdown(version_info::GetVersionNumber(), service_pid); 312 ForceServiceProcessShutdown(version_info::GetVersionNumber(), service_pid);
310 } 313 }
311 314
312 // Flaky on Mac. http://crbug.com/517420 315 // Flaky on Mac. http://crbug.com/517420
313 #if defined(OS_MACOSX) 316 #if defined(OS_MACOSX)
314 #define MAYBE_CheckPid DISABLED_CheckPid 317 #define MAYBE_CheckPid DISABLED_CheckPid
315 #else 318 #else
316 #define MAYBE_CheckPid CheckPid 319 #define MAYBE_CheckPid CheckPid
317 #endif 320 #endif
318 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_CheckPid) { 321 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, MAYBE_CheckPid) {
319 base::ProcessId service_pid; 322 base::ProcessId service_pid;
323 base::ThreadRestrictions::ScopedAllowIO allow_io;
320 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); 324 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid));
321 // Launch the service process. 325 // Launch the service process.
322 LaunchServiceProcessControl(true); 326 LaunchServiceProcessControl(true);
323 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); 327 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid));
324 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); 328 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid);
325 // Disconnect from service process. 329 // Disconnect from service process.
326 Disconnect(); 330 Disconnect();
327 } 331 }
328 332
329 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, HistogramsNoService) { 333 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, HistogramsNoService) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // Callback should not be called during GetHistograms call. 368 // Callback should not be called during GetHistograms call.
365 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); 369 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0);
366 // Wait for real callback by providing large timeout value. 370 // Wait for real callback by providing large timeout value.
367 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( 371 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms(
368 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, 372 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback,
369 base::Unretained(this)), 373 base::Unretained(this)),
370 base::TimeDelta::FromHours(1))); 374 base::TimeDelta::FromHours(1)));
371 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); 375 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1);
372 content::RunMessageLoop(); 376 content::RunMessageLoop();
373 } 377 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698