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/public/test/content_browser_test.h" | 5 #include "content/public/test/content_browser_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 content_test_data_absolute.Append(content_test_data); | 54 content_test_data_absolute.Append(content_test_data); |
55 embedded_test_server()->ServeFilesFromDirectory(content_test_data_absolute); | 55 embedded_test_server()->ServeFilesFromDirectory(content_test_data_absolute); |
56 } | 56 } |
57 | 57 |
58 ContentBrowserTest::~ContentBrowserTest() { | 58 ContentBrowserTest::~ContentBrowserTest() { |
59 CHECK(setup_called_) << "Overridden SetUp() did not call parent " | 59 CHECK(setup_called_) << "Overridden SetUp() did not call parent " |
60 "implementation, so test not run."; | 60 "implementation, so test not run."; |
61 } | 61 } |
62 | 62 |
63 void ContentBrowserTest::SetUp() { | 63 void ContentBrowserTest::SetUp() { |
64 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 64 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
65 command_line->AppendSwitch(switches::kContentBrowserTest); | 65 command_line->AppendSwitch(switches::kContentBrowserTest); |
66 | 66 |
67 SetUpCommandLine(command_line); | 67 SetUpCommandLine(command_line); |
68 | 68 |
69 #if defined(OS_ANDROID) | 69 #if defined(OS_ANDROID) |
70 shell_main_delegate_.reset(new ShellMainDelegate); | 70 shell_main_delegate_.reset(new ShellMainDelegate); |
71 shell_main_delegate_->PreSandboxStartup(); | 71 shell_main_delegate_->PreSandboxStartup(); |
72 if (command_line->HasSwitch(switches::kSingleProcess)) { | 72 if (command_line->HasSwitch(switches::kSingleProcess)) { |
73 // We explicitly leak the new ContentRendererClient as we're | 73 // We explicitly leak the new ContentRendererClient as we're |
74 // setting a global that may be used after ContentBrowserTest is | 74 // setting a global that may be used after ContentBrowserTest is |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) | 109 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) |
110 ui::ShutdownInputMethodForTesting(); | 110 ui::ShutdownInputMethodForTesting(); |
111 #endif | 111 #endif |
112 | 112 |
113 #if defined(OS_ANDROID) | 113 #if defined(OS_ANDROID) |
114 shell_main_delegate_.reset(); | 114 shell_main_delegate_.reset(); |
115 #endif | 115 #endif |
116 } | 116 } |
117 | 117 |
118 void ContentBrowserTest::RunTestOnMainThreadLoop() { | 118 void ContentBrowserTest::RunTestOnMainThreadLoop() { |
119 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 119 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 120 switches::kDumpRenderTree)) { |
120 CHECK_EQ(Shell::windows().size(), 1u); | 121 CHECK_EQ(Shell::windows().size(), 1u); |
121 shell_ = Shell::windows()[0]; | 122 shell_ = Shell::windows()[0]; |
122 } | 123 } |
123 | 124 |
124 #if defined(OS_MACOSX) | 125 #if defined(OS_MACOSX) |
125 // On Mac, without the following autorelease pool, code which is directly | 126 // On Mac, without the following autorelease pool, code which is directly |
126 // executed (as opposed to executed inside a message loop) would autorelease | 127 // executed (as opposed to executed inside a message loop) would autorelease |
127 // objects into a higher-level pool. This pool is not recycled in-sync with | 128 // objects into a higher-level pool. This pool is not recycled in-sync with |
128 // the message loops' pools and causes problems with code relying on | 129 // the message loops' pools and causes problems with code relying on |
129 // deallocation via an autorelease pool (such as browser window closure and | 130 // deallocation via an autorelease pool (such as browser window closure and |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 167 |
167 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() { | 168 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() { |
168 return Shell::CreateNewWindow( | 169 return Shell::CreateNewWindow( |
169 ShellContentBrowserClient::Get()->off_the_record_browser_context(), | 170 ShellContentBrowserClient::Get()->off_the_record_browser_context(), |
170 GURL(url::kAboutBlankURL), | 171 GURL(url::kAboutBlankURL), |
171 NULL, | 172 NULL, |
172 gfx::Size()); | 173 gfx::Size()); |
173 } | 174 } |
174 | 175 |
175 } // namespace content | 176 } // namespace content |
OLD | NEW |