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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 SetUpCommandLine(command_line); | 59 SetUpCommandLine(command_line); |
60 | 60 |
61 #if defined(OS_ANDROID) | 61 #if defined(OS_ANDROID) |
62 shell_main_delegate_.reset(new ShellMainDelegate); | 62 shell_main_delegate_.reset(new ShellMainDelegate); |
63 shell_main_delegate_->PreSandboxStartup(); | 63 shell_main_delegate_->PreSandboxStartup(); |
64 if (command_line->HasSwitch(switches::kSingleProcess)) { | 64 if (command_line->HasSwitch(switches::kSingleProcess)) { |
65 // We explicitly leak the new ContentRendererClient as we're | 65 // We explicitly leak the new ContentRendererClient as we're |
66 // setting a global that may be used after ContentBrowserTest is | 66 // setting a global that may be used after ContentBrowserTest is |
67 // destroyed. | 67 // destroyed. |
68 ContentRendererClient* old_client = | 68 ContentRendererClient* old_client = |
69 command_line->HasSwitch(switches::kRunLayoutTest) | 69 switches::IsRunLayoutTestSwitchPresent() |
70 ? SetRendererClientForTesting(new LayoutTestContentRendererClient) | 70 ? SetRendererClientForTesting(new LayoutTestContentRendererClient) |
71 : SetRendererClientForTesting(new ShellContentRendererClient); | 71 : SetRendererClientForTesting(new ShellContentRendererClient); |
72 // No-one should have set this value before we did. | 72 // No-one should have set this value before we did. |
73 DCHECK(!old_client); | 73 DCHECK(!old_client); |
74 } | 74 } |
75 #elif defined(OS_MACOSX) | 75 #elif defined(OS_MACOSX) |
76 // See InProcessBrowserTest::PrepareTestCommandLine(). | 76 // See InProcessBrowserTest::PrepareTestCommandLine(). |
77 base::FilePath subprocess_path; | 77 base::FilePath subprocess_path; |
78 PathService::Get(base::FILE_EXE, &subprocess_path); | 78 PathService::Get(base::FILE_EXE, &subprocess_path); |
79 subprocess_path = subprocess_path.DirName().DirName(); | 79 subprocess_path = subprocess_path.DirName().DirName(); |
(...skipping 19 matching lines...) Expand all Loading... |
99 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) | 99 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) |
100 ui::ShutdownInputMethodForTesting(); | 100 ui::ShutdownInputMethodForTesting(); |
101 #endif | 101 #endif |
102 | 102 |
103 #if defined(OS_ANDROID) | 103 #if defined(OS_ANDROID) |
104 shell_main_delegate_.reset(); | 104 shell_main_delegate_.reset(); |
105 #endif | 105 #endif |
106 } | 106 } |
107 | 107 |
108 void ContentBrowserTest::RunTestOnMainThreadLoop() { | 108 void ContentBrowserTest::RunTestOnMainThreadLoop() { |
109 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 109 if (!switches::IsRunLayoutTestSwitchPresent()) { |
110 switches::kRunLayoutTest)) { | |
111 CHECK_EQ(Shell::windows().size(), 1u); | 110 CHECK_EQ(Shell::windows().size(), 1u); |
112 shell_ = Shell::windows()[0]; | 111 shell_ = Shell::windows()[0]; |
113 } | 112 } |
114 | 113 |
115 #if defined(OS_MACOSX) | 114 #if defined(OS_MACOSX) |
116 // On Mac, without the following autorelease pool, code which is directly | 115 // On Mac, without the following autorelease pool, code which is directly |
117 // executed (as opposed to executed inside a message loop) would autorelease | 116 // executed (as opposed to executed inside a message loop) would autorelease |
118 // objects into a higher-level pool. This pool is not recycled in-sync with | 117 // objects into a higher-level pool. This pool is not recycled in-sync with |
119 // the message loops' pools and causes problems with code relying on | 118 // the message loops' pools and causes problems with code relying on |
120 // deallocation via an autorelease pool (such as browser window closure and | 119 // deallocation via an autorelease pool (such as browser window closure and |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 156 |
158 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() { | 157 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() { |
159 return Shell::CreateNewWindow( | 158 return Shell::CreateNewWindow( |
160 ShellContentBrowserClient::Get()->off_the_record_browser_context(), | 159 ShellContentBrowserClient::Get()->off_the_record_browser_context(), |
161 GURL(url::kAboutBlankURL), | 160 GURL(url::kAboutBlankURL), |
162 NULL, | 161 NULL, |
163 gfx::Size()); | 162 gfx::Size()); |
164 } | 163 } |
165 | 164 |
166 } // namespace content | 165 } // namespace content |
OLD | NEW |