OLD | NEW |
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/debug/stack_trace.h" | 7 #include "base/debug/stack_trace.h" |
8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "content/shell/shell.h" |
| 11 #include "content/shell/shell_main_delegate.h" |
10 #include "content/test/test_content_client.h" | 12 #include "content/test/test_content_client.h" |
11 | 13 |
12 ContentBrowserTest::ContentBrowserTest() { | 14 ContentBrowserTest::ContentBrowserTest() { |
13 } | 15 } |
14 | 16 |
15 ContentBrowserTest::~ContentBrowserTest() { | 17 ContentBrowserTest::~ContentBrowserTest() { |
16 } | 18 } |
17 | 19 |
18 void ContentBrowserTest::SetUp() { | 20 void ContentBrowserTest::SetUp() { |
19 DCHECK(!content::GetContentClient()); | 21 DCHECK(!content::GetContentClient()); |
20 content_client_.reset(new TestContentClient); | 22 shell_main_delegate_.reset(new ShellMainDelegate); |
21 content::SetContentClient(content_client_.get()); | 23 shell_main_delegate_->PreSandboxStartup(); |
22 | |
23 content_browser_client_.reset(new content::MockContentBrowserClient()); | |
24 content_client_->set_browser(content_browser_client_.get()); | |
25 | 24 |
26 BrowserTestBase::SetUp(); | 25 BrowserTestBase::SetUp(); |
27 } | 26 } |
28 | 27 |
29 void ContentBrowserTest::TearDown() { | 28 void ContentBrowserTest::TearDown() { |
30 BrowserTestBase::TearDown(); | 29 BrowserTestBase::TearDown(); |
31 | 30 |
32 DCHECK_EQ(content_client_.get(), content::GetContentClient()); | 31 shell_main_delegate_.reset(); |
33 content::SetContentClient(NULL); | |
34 content_client_.reset(); | |
35 | |
36 content_browser_client_.reset(); | |
37 } | 32 } |
38 | 33 |
39 #if defined(OS_POSIX) | 34 #if defined(OS_POSIX) |
40 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 35 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
41 // debugging easier) and also exit with a known error code (so that the test | 36 // debugging easier) and also exit with a known error code (so that the test |
42 // framework considers this a failure -- http://crbug.com/57578). | 37 // framework considers this a failure -- http://crbug.com/57578). |
43 static void DumpStackTraceSignalHandler(int signal) { | 38 static void DumpStackTraceSignalHandler(int signal) { |
44 base::debug::StackTrace().PrintBacktrace(); | 39 base::debug::StackTrace().PrintBacktrace(); |
45 _exit(128 + signal); | 40 _exit(128 + signal); |
46 } | 41 } |
(...skipping 16 matching lines...) Expand all Loading... |
63 // Pump startup related events. | 58 // Pump startup related events. |
64 MessageLoopForUI::current()->RunAllPending(); | 59 MessageLoopForUI::current()->RunAllPending(); |
65 pool.Recycle(); | 60 pool.Recycle(); |
66 | 61 |
67 RunTestOnMainThread(); | 62 RunTestOnMainThread(); |
68 pool.Recycle(); | 63 pool.Recycle(); |
69 | 64 |
70 MessageLoopForUI::current()->Quit(); | 65 MessageLoopForUI::current()->Quit(); |
71 pool.Recycle(); | 66 pool.Recycle(); |
72 } | 67 } |
OLD | NEW |