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