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

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

Issue 10836148: Don't print the callstack in forked browser test processes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: simplify 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/browser_test_base.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 "content/test/content_browser_test.h" 5 #include "content/test/content_browser_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/stack_trace.h"
9 #include "base/file_path.h" 8 #include "base/file_path.h"
10 #include "base/logging.h" 9 #include "base/logging.h"
11 #include "base/message_loop.h" 10 #include "base/message_loop.h"
12 #include "base/path_service.h" 11 #include "base/path_service.h"
13 #include "content/public/browser/render_process_host.h" 12 #include "content/public/browser/render_process_host.h"
14 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
15 #include "content/public/common/url_constants.h" 14 #include "content/public/common/url_constants.h"
16 #include "content/shell/shell.h" 15 #include "content/shell/shell.h"
17 #include "content/shell/shell_browser_context.h" 16 #include "content/shell/shell_browser_context.h"
18 #include "content/shell/shell_content_browser_client.h" 17 #include "content/shell/shell_content_browser_client.h"
(...skipping 24 matching lines...) Expand all
43 ContentBrowserTest::~ContentBrowserTest() { 42 ContentBrowserTest::~ContentBrowserTest() {
44 } 43 }
45 44
46 void ContentBrowserTest::SetUp() { 45 void ContentBrowserTest::SetUp() {
47 shell_main_delegate_.reset(new ShellMainDelegate); 46 shell_main_delegate_.reset(new ShellMainDelegate);
48 shell_main_delegate_->PreSandboxStartup(); 47 shell_main_delegate_->PreSandboxStartup();
49 48
50 CommandLine* command_line = CommandLine::ForCurrentProcess(); 49 CommandLine* command_line = CommandLine::ForCurrentProcess();
51 command_line->AppendSwitch(switches::kContentBrowserTest); 50 command_line->AppendSwitch(switches::kContentBrowserTest);
52 51
53 #if defined(OS_LINUX)
54 // http://crbug.com/139209
55 command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch);
56 #endif
57
58 SetUpCommandLine(command_line); 52 SetUpCommandLine(command_line);
59 53
60 // Single-process mode is not set in BrowserMain, so process it explicitly, 54 // Single-process mode is not set in BrowserMain, so process it explicitly,
61 // and set up renderer. 55 // and set up renderer.
62 if (command_line->HasSwitch(switches::kSingleProcess)) { 56 if (command_line->HasSwitch(switches::kSingleProcess)) {
63 RenderProcessHost::set_run_renderer_in_process(true); 57 RenderProcessHost::set_run_renderer_in_process(true);
64 single_process_renderer_client_.reset(new ShellContentRendererClient); 58 single_process_renderer_client_.reset(new ShellContentRendererClient);
65 content::GetContentClient()->set_renderer_for_testing( 59 content::GetContentClient()->set_renderer_for_testing(
66 single_process_renderer_client_.get()); 60 single_process_renderer_client_.get());
67 } 61 }
(...skipping 12 matching lines...) Expand all
80 74
81 BrowserTestBase::SetUp(); 75 BrowserTestBase::SetUp();
82 } 76 }
83 77
84 void ContentBrowserTest::TearDown() { 78 void ContentBrowserTest::TearDown() {
85 BrowserTestBase::TearDown(); 79 BrowserTestBase::TearDown();
86 80
87 shell_main_delegate_.reset(); 81 shell_main_delegate_.reset();
88 } 82 }
89 83
90 #if defined(OS_POSIX)
91 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make
92 // debugging easier) and also exit with a known error code (so that the test
93 // framework considers this a failure -- http://crbug.com/57578).
94 static void DumpStackTraceSignalHandler(int signal) {
95 base::debug::StackTrace().PrintBacktrace();
96 _exit(128 + signal);
97 }
98 #endif // defined(OS_POSIX)
99
100 void ContentBrowserTest::RunTestOnMainThreadLoop() { 84 void ContentBrowserTest::RunTestOnMainThreadLoop() {
101 CHECK_EQ(Shell::windows().size(), 1u); 85 CHECK_EQ(Shell::windows().size(), 1u);
102 shell_ = Shell::windows()[0]; 86 shell_ = Shell::windows()[0];
103 87
104 #if defined(OS_POSIX)
105 signal(SIGTERM, DumpStackTraceSignalHandler);
106 #endif // defined(OS_POSIX)
107
108 #if defined(OS_MACOSX) 88 #if defined(OS_MACOSX)
109 // On Mac, without the following autorelease pool, code which is directly 89 // On Mac, without the following autorelease pool, code which is directly
110 // executed (as opposed to executed inside a message loop) would autorelease 90 // executed (as opposed to executed inside a message loop) would autorelease
111 // objects into a higher-level pool. This pool is not recycled in-sync with 91 // objects into a higher-level pool. This pool is not recycled in-sync with
112 // the message loops' pools and causes problems with code relying on 92 // the message loops' pools and causes problems with code relying on
113 // deallocation via an autorelease pool (such as browser window closure and 93 // deallocation via an autorelease pool (such as browser window closure and
114 // browser shutdown). To avoid this, the following pool is recycled after each 94 // browser shutdown). To avoid this, the following pool is recycled after each
115 // time code is directly executed. 95 // time code is directly executed.
116 base::mac::ScopedNSAutoreleasePool pool; 96 base::mac::ScopedNSAutoreleasePool pool;
117 #endif 97 #endif
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 static_cast<ShellContentBrowserClient*>(GetContentClient()->browser()); 134 static_cast<ShellContentBrowserClient*>(GetContentClient()->browser());
155 return Shell::CreateNewWindow( 135 return Shell::CreateNewWindow(
156 browser_client->off_the_record_browser_context(), 136 browser_client->off_the_record_browser_context(),
157 GURL(chrome::kAboutBlankURL), 137 GURL(chrome::kAboutBlankURL),
158 NULL, 138 NULL,
159 MSG_ROUTING_NONE, 139 MSG_ROUTING_NONE,
160 NULL); 140 NULL);
161 } 141 }
162 142
163 } // namespace content 143 } // namespace content
OLDNEW
« no previous file with comments | « content/test/browser_test_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698