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

Side by Side Diff: content/test/browser_test_base.cc

Issue 10826311: Move the corresponding cc files from content\test to be alongside their headers in content\public\t… (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
« no previous file with comments | « content/test/accessibility_test_utils_win.cc ('k') | content/test/browser_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/test/browser_test_base.h"
6
7 #include "base/bind.h"
8 #include "base/command_line.h"
9 #include "base/debug/stack_trace.h"
10 #include "base/process_util.h"
11 #include "content/public/common/content_switches.h"
12 #include "content/public/common/main_function_params.h"
13 #include "sandbox/win/src/dep.h"
14
15 #if defined(OS_MACOSX)
16 #include "base/mac/mac_util.h"
17 #include "base/system_monitor/system_monitor.h"
18 #endif
19
20 extern int BrowserMain(const content::MainFunctionParams&);
21
22 namespace {
23
24 #if defined(OS_POSIX)
25 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make
26 // debugging easier) and also exit with a known error code (so that the test
27 // framework considers this a failure -- http://crbug.com/57578).
28 // Note: We only want to do this in the browser process, and not forked
29 // processes. That might lead to hangs because of locks inside tcmalloc or the
30 // OS. See http://crbug.com/141302.
31 static int g_browser_process_pid;
32 static void DumpStackTraceSignalHandler(int signal) {
33 if (g_browser_process_pid == base::GetCurrentProcId())
34 base::debug::StackTrace().PrintBacktrace();
35 _exit(128 + signal);
36 }
37 #endif // defined(OS_POSIX)
38
39 } // namespace
40
41 namespace content {
42
43 BrowserTestBase::BrowserTestBase() {
44 #if defined(OS_MACOSX)
45 base::mac::SetOverrideAmIBundled(true);
46 base::SystemMonitor::AllocateSystemIOPorts();
47 #endif
48
49 #if defined(OS_POSIX)
50 handle_sigterm_ = true;
51 #endif
52 }
53
54 BrowserTestBase::~BrowserTestBase() {
55 }
56
57 void BrowserTestBase::SetUp() {
58 CommandLine* command_line = CommandLine::ForCurrentProcess();
59
60 // The tests assume that file:// URIs can freely access other file:// URIs.
61 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
62
63 command_line->AppendSwitch(switches::kDomAutomationController);
64
65 MainFunctionParams params(*command_line);
66 params.ui_task =
67 new base::Closure(
68 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this));
69
70 SetUpInProcessBrowserTestFixture();
71 BrowserMain(params);
72 TearDownInProcessBrowserTestFixture();
73 }
74
75 void BrowserTestBase::TearDown() {
76 }
77
78 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() {
79 #if defined(OS_POSIX)
80 if (handle_sigterm_) {
81 g_browser_process_pid = base::GetCurrentProcId();
82 signal(SIGTERM, DumpStackTraceSignalHandler);
83 }
84 #endif // defined(OS_POSIX)
85 RunTestOnMainThreadLoop();
86 }
87
88 void BrowserTestBase::CreateTestServer(const char* test_server_base) {
89 CHECK(!test_server_.get());
90 test_server_.reset(new net::TestServer(
91 net::TestServer::TYPE_HTTP,
92 net::TestServer::kLocalhost,
93 FilePath().AppendASCII(test_server_base)));
94 }
95
96 } // namespace content
OLDNEW
« no previous file with comments | « content/test/accessibility_test_utils_win.cc ('k') | content/test/browser_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698