| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 75 // destroyed. | 75 // destroyed. |
| 76 ContentRendererClient* old_client = | 76 ContentRendererClient* old_client = |
| 77 command_line->HasSwitch(switches::kRunLayoutTest) | 77 command_line->HasSwitch(switches::kDumpRenderTree) |
| 78 ? SetRendererClientForTesting(new LayoutTestContentRendererClient) | 78 ? SetRendererClientForTesting(new LayoutTestContentRendererClient) |
| 79 : SetRendererClientForTesting(new ShellContentRendererClient); | 79 : SetRendererClientForTesting(new ShellContentRendererClient); |
| 80 // No-one should have set this value before we did. | 80 // No-one should have set this value before we did. |
| 81 DCHECK(!old_client); | 81 DCHECK(!old_client); |
| 82 } | 82 } |
| 83 #elif defined(OS_MACOSX) | 83 #elif defined(OS_MACOSX) |
| 84 // See InProcessBrowserTest::PrepareTestCommandLine(). | 84 // See InProcessBrowserTest::PrepareTestCommandLine(). |
| 85 base::FilePath subprocess_path; | 85 base::FilePath subprocess_path; |
| 86 PathService::Get(base::FILE_EXE, &subprocess_path); | 86 PathService::Get(base::FILE_EXE, &subprocess_path); |
| 87 subprocess_path = subprocess_path.DirName().DirName(); | 87 subprocess_path = subprocess_path.DirName().DirName(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 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 (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 119 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 120 switches::kRunLayoutTest)) { | 120 switches::kDumpRenderTree)) { |
| 121 CHECK_EQ(Shell::windows().size(), 1u); | 121 CHECK_EQ(Shell::windows().size(), 1u); |
| 122 shell_ = Shell::windows()[0]; | 122 shell_ = Shell::windows()[0]; |
| 123 } | 123 } |
| 124 | 124 |
| 125 #if defined(OS_MACOSX) | 125 #if defined(OS_MACOSX) |
| 126 // On Mac, without the following autorelease pool, code which is directly | 126 // On Mac, without the following autorelease pool, code which is directly |
| 127 // executed (as opposed to executed inside a message loop) would autorelease | 127 // executed (as opposed to executed inside a message loop) would autorelease |
| 128 // 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 |
| 129 // the message loops' pools and causes problems with code relying on | 129 // the message loops' pools and causes problems with code relying on |
| 130 // 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... |
| 167 | 167 |
| 168 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() { | 168 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() { |
| 169 return Shell::CreateNewWindow( | 169 return Shell::CreateNewWindow( |
| 170 ShellContentBrowserClient::Get()->off_the_record_browser_context(), | 170 ShellContentBrowserClient::Get()->off_the_record_browser_context(), |
| 171 GURL(url::kAboutBlankURL), | 171 GURL(url::kAboutBlankURL), |
| 172 NULL, | 172 NULL, |
| 173 gfx::Size()); | 173 gfx::Size()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace content | 176 } // namespace content |
| OLD | NEW |