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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "content/public/browser/render_process_host.h" |
13 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
14 #include "content/shell/shell.h" | 15 #include "content/shell/shell.h" |
15 #include "content/shell/shell_main_delegate.h" | 16 #include "content/shell/shell_main_delegate.h" |
16 #include "content/shell/shell_switches.h" | 17 #include "content/shell/shell_switches.h" |
17 #include "content/test/test_content_client.h" | 18 #include "content/test/test_content_client.h" |
18 | 19 |
19 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
20 #include "base/mac/scoped_nsautorelease_pool.h" | 21 #include "base/mac/scoped_nsautorelease_pool.h" |
21 #endif | 22 #endif |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
25 ContentBrowserTest::ContentBrowserTest() { | 26 ContentBrowserTest::ContentBrowserTest() { |
26 #if defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
27 // See comment in InProcessBrowserTest::InProcessBrowserTest(). | 28 // See comment in InProcessBrowserTest::InProcessBrowserTest(). |
28 FilePath content_shell_path; | 29 FilePath content_shell_path; |
29 CHECK(PathService::Get(base::FILE_EXE, &content_shell_path)); | 30 CHECK(PathService::Get(base::FILE_EXE, &content_shell_path)); |
30 content_shell_path = content_shell_path.DirName(); | 31 content_shell_path = content_shell_path.DirName(); |
31 content_shell_path = content_shell_path.Append( | 32 content_shell_path = content_shell_path.Append( |
32 FILE_PATH_LITERAL("Content Shell.app/Contents/MacOS/Content Shell")); | 33 FILE_PATH_LITERAL("Content Shell.app/Contents/MacOS/Content Shell")); |
33 CHECK(PathService::Override(base::FILE_EXE, content_shell_path)); | 34 CHECK(PathService::Override(base::FILE_EXE, content_shell_path)); |
34 #endif | 35 #endif |
35 } | 36 } |
36 | 37 |
37 ContentBrowserTest::~ContentBrowserTest() { | 38 ContentBrowserTest::~ContentBrowserTest() { |
38 } | 39 } |
39 | 40 |
40 void ContentBrowserTest::SetUp() { | 41 void ContentBrowserTest::SetUp() { |
41 shell_main_delegate_.reset(new content::ShellMainDelegate); | 42 shell_main_delegate_.reset(new ShellMainDelegate); |
42 shell_main_delegate_->PreSandboxStartup(); | 43 shell_main_delegate_->PreSandboxStartup(); |
43 | 44 |
44 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 45 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
45 command_line->AppendSwitch(switches::kContentBrowserTest); | 46 command_line->AppendSwitch(switches::kContentBrowserTest); |
46 | 47 |
| 48 SetUpCommandLine(command_line); |
| 49 |
47 #if defined(OS_MACOSX) | 50 #if defined(OS_MACOSX) |
48 // See InProcessBrowserTest::PrepareTestCommandLine(). | 51 // See InProcessBrowserTest::PrepareTestCommandLine(). |
49 FilePath subprocess_path; | 52 FilePath subprocess_path; |
50 PathService::Get(base::FILE_EXE, &subprocess_path); | 53 PathService::Get(base::FILE_EXE, &subprocess_path); |
51 subprocess_path = subprocess_path.DirName().DirName(); | 54 subprocess_path = subprocess_path.DirName().DirName(); |
52 DCHECK_EQ(subprocess_path.BaseName().value(), "Contents"); | 55 DCHECK_EQ(subprocess_path.BaseName().value(), "Contents"); |
53 subprocess_path = subprocess_path.Append( | 56 subprocess_path = subprocess_path.Append( |
54 "Frameworks/Content Shell Helper.app/Contents/MacOS/Content Shell Helper")
; | 57 "Frameworks/Content Shell Helper.app/Contents/MacOS/Content Shell Helper")
; |
55 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, | 58 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, |
56 subprocess_path); | 59 subprocess_path); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 base::mac::ScopedNSAutoreleasePool pool; | 97 base::mac::ScopedNSAutoreleasePool pool; |
95 #endif | 98 #endif |
96 | 99 |
97 // Pump startup related events. | 100 // Pump startup related events. |
98 MessageLoopForUI::current()->RunAllPending(); | 101 MessageLoopForUI::current()->RunAllPending(); |
99 | 102 |
100 #if defined(OS_MACOSX) | 103 #if defined(OS_MACOSX) |
101 pool.Recycle(); | 104 pool.Recycle(); |
102 #endif | 105 #endif |
103 | 106 |
| 107 SetUpOnMainThread(); |
| 108 |
104 RunTestOnMainThread(); | 109 RunTestOnMainThread(); |
105 #if defined(OS_MACOSX) | 110 #if defined(OS_MACOSX) |
106 pool.Recycle(); | 111 pool.Recycle(); |
107 #endif | 112 #endif |
| 113 |
| 114 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
| 115 !i.IsAtEnd(); i.Advance()) { |
| 116 i.GetCurrentValue()->FastShutdownIfPossible(); |
| 117 } |
108 } | 118 } |
109 | 119 |
110 } // namespace content | 120 } // namespace content |
OLD | NEW |