[email protected] | 9e790bd | 2011-01-10 23:48:54 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 5 | #include "chrome/test/base/in_process_browser_test.h" |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 6 | |
| 7 | #include "base/command_line.h" |
[email protected] | b25e61d | 2011-08-23 09:02:01 | [diff] [blame] | 8 | #include "base/debug/stack_trace.h" |
[email protected] | d841205 | 2009-04-21 22:01:01 | [diff] [blame] | 9 | #include "base/file_path.h" |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 10 | #include "base/file_util.h" |
[email protected] | c2818d4 | 2010-10-18 02:47:39 | [diff] [blame] | 11 | #include "base/mac/scoped_nsautorelease_pool.h" |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 12 | #include "base/path_service.h" |
[email protected] | 528c56d | 2010-07-30 19:28:44 | [diff] [blame] | 13 | #include "base/string_number_conversions.h" |
[email protected] | fb895c6 | 2009-10-09 18:20:30 | [diff] [blame] | 14 | #include "base/test/test_file_util.h" |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 15 | #include "chrome/browser/browser_process.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 16 | #include "chrome/browser/io_thread.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 17 | #include "chrome/browser/profiles/profile.h" |
| 18 | #include "chrome/browser/profiles/profile_manager.h" |
[email protected] | c848d3d9 | 2010-09-16 21:57:45 | [diff] [blame] | 19 | #include "chrome/browser/tabs/tab_strip_model.h" |
[email protected] | f46be6e | 2010-11-16 03:52:32 | [diff] [blame] | 20 | #include "chrome/browser/ui/browser.h" |
[email protected] | 6768ac0 | 2011-04-06 17:41:04 | [diff] [blame] | 21 | #include "chrome/browser/ui/browser_list.h" |
[email protected] | 339d6dd | 2010-11-12 00:41:58 | [diff] [blame] | 22 | #include "chrome/browser/ui/browser_navigator.h" |
[email protected] | 00070c73 | 2011-04-09 15:31:33 | [diff] [blame] | 23 | #include "chrome/browser/ui/browser_window.h" |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 24 | #include "chrome/common/chrome_constants.h" |
| 25 | #include "chrome/common/chrome_paths.h" |
| 26 | #include "chrome/common/chrome_switches.h" |
[email protected] | 0750b144 | 2010-11-02 21:59:37 | [diff] [blame] | 27 | #include "chrome/common/logging_chrome.h" |
[email protected] | e0d48158 | 2009-09-15 21:06:25 | [diff] [blame] | 28 | #include "chrome/common/url_constants.h" |
[email protected] | aecb6ca | 2011-07-29 22:56:14 | [diff] [blame] | 29 | #include "chrome/test/base/test_launcher_utils.h" |
[email protected] | bf925774 | 2011-08-11 21:01:15 | [diff] [blame] | 30 | #include "chrome/test/base/testing_browser_process.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 31 | #include "chrome/test/base/ui_test_utils.h" |
[email protected] | 1bda9755 | 2011-03-01 20:11:52 | [diff] [blame] | 32 | #include "content/browser/browser_thread.h" |
| 33 | #include "content/browser/renderer_host/render_process_host.h" |
| 34 | #include "content/browser/tab_contents/tab_contents.h" |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 35 | #include "content/common/content_notification_types.h" |
[email protected] | a77e4bc | 2011-06-29 02:06:28 | [diff] [blame] | 36 | #include "content/renderer/mock_content_renderer_client.h" |
[email protected] | c4ff495 | 2010-01-08 19:12:47 | [diff] [blame] | 37 | #include "net/base/mock_host_resolver.h" |
[email protected] | 3985ba8 | 2010-07-29 21:44:12 | [diff] [blame] | 38 | #include "net/test/test_server.h" |
[email protected] | 7fac888 | 2010-11-15 19:52:52 | [diff] [blame] | 39 | |
[email protected] | e2e2411a | 2011-04-12 20:56:28 | [diff] [blame] | 40 | #if defined(OS_CHROMEOS) |
| 41 | #include "chrome/browser/chromeos/audio_handler.h" |
| 42 | #endif |
| 43 | |
[email protected] | ddf8a4b0 | 2010-03-22 23:08:30 | [diff] [blame] | 44 | // Passed as value of kTestType. |
| 45 | static const char kBrowserTestType[] = "browser"; |
| 46 | |
[email protected] | 8bcdec9 | 2009-02-25 16:15:18 | [diff] [blame] | 47 | InProcessBrowserTest::InProcessBrowserTest() |
| 48 | : browser_(NULL), |
| 49 | show_window_(false), |
[email protected] | 56cdae3 | 2009-03-12 19:58:20 | [diff] [blame] | 50 | dom_automation_enabled_(false), |
[email protected] | 06cc083a | 2011-03-01 02:28:42 | [diff] [blame] | 51 | tab_closeable_state_watcher_enabled_(false) { |
[email protected] | 86671a3 | 2011-10-06 21:15:20 | [diff] [blame] | 52 | #if defined(OS_MACOSX) |
| 53 | // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. |
[email protected] | 7fac888 | 2010-11-15 19:52:52 | [diff] [blame] | 54 | // Before we run the browser, we have to hack the path to the exe to match |
| 55 | // what it would be if Chrome was running, because it is used to fork renderer |
| 56 | // processes, on Linux at least (failure to do so will cause a browser_test to |
| 57 | // be run instead of a renderer). |
| 58 | FilePath chrome_path; |
| 59 | CHECK(PathService::Get(base::FILE_EXE, &chrome_path)); |
| 60 | chrome_path = chrome_path.DirName(); |
[email protected] | 7fac888 | 2010-11-15 19:52:52 | [diff] [blame] | 61 | chrome_path = chrome_path.Append(chrome::kBrowserProcessExecutablePath); |
[email protected] | 7fac888 | 2010-11-15 19:52:52 | [diff] [blame] | 62 | CHECK(PathService::Override(base::FILE_EXE, chrome_path)); |
[email protected] | 86671a3 | 2011-10-06 21:15:20 | [diff] [blame] | 63 | #endif // defined(OS_MACOSX) |
[email protected] | 7fac888 | 2010-11-15 19:52:52 | [diff] [blame] | 64 | |
| 65 | test_server_.reset(new net::TestServer( |
| 66 | net::TestServer::TYPE_HTTP, |
| 67 | FilePath(FILE_PATH_LITERAL("chrome/test/data")))); |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 68 | } |
| 69 | |
[email protected] | c4ff495 | 2010-01-08 19:12:47 | [diff] [blame] | 70 | InProcessBrowserTest::~InProcessBrowserTest() { |
| 71 | } |
| 72 | |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 73 | void InProcessBrowserTest::SetUp() { |
[email protected] | fc82ccf0 | 2010-10-15 18:12:47 | [diff] [blame] | 74 | // Create a temporary user data directory if required. |
| 75 | ASSERT_TRUE(CreateUserDataDirectory()) |
| 76 | << "Could not create user data directory."; |
[email protected] | 4a44bc3 | 2010-05-28 22:22:44 | [diff] [blame] | 77 | |
[email protected] | 583844c | 2011-08-27 00:38:35 | [diff] [blame] | 78 | // Undo TestingBrowserProcess creation in ChromeTestSuite. |
| 79 | // TODO(phajdan.jr): Extract a smaller test suite so we don't need this. |
| 80 | DCHECK(g_browser_process); |
| 81 | delete g_browser_process; |
| 82 | g_browser_process = NULL; |
[email protected] | 298883bc | 2010-04-30 14:50:58 | [diff] [blame] | 83 | |
[email protected] | 470f7a5 | 2010-09-23 20:20:38 | [diff] [blame] | 84 | // Allow subclasses the opportunity to make changes to the default user data |
| 85 | // dir before running any tests. |
[email protected] | fc82ccf0 | 2010-10-15 18:12:47 | [diff] [blame] | 86 | ASSERT_TRUE(SetUpUserDataDirectory()) |
| 87 | << "Could not set up user data directory."; |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 88 | |
[email protected] | 06cc083a | 2011-03-01 02:28:42 | [diff] [blame] | 89 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 90 | // Allow subclasses to change the command line before running any tests. |
[email protected] | 9665fa6 | 2009-04-13 22:15:29 | [diff] [blame] | 91 | SetUpCommandLine(command_line); |
[email protected] | 03c79d50 | 2010-11-16 00:38:26 | [diff] [blame] | 92 | // Add command line arguments that are used by all InProcessBrowserTests. |
| 93 | PrepareTestCommandLine(command_line); |
[email protected] | 9665fa6 | 2009-04-13 22:15:29 | [diff] [blame] | 94 | |
[email protected] | 15fd0df | 2011-04-29 16:00:16 | [diff] [blame] | 95 | // Single-process mode is not set in BrowserMain, so process it explicitly, |
| 96 | // and set up renderer. |
| 97 | if (command_line->HasSwitch(switches::kSingleProcess)) { |
[email protected] | 8bcdec9 | 2009-02-25 16:15:18 | [diff] [blame] | 98 | RenderProcessHost::set_run_renderer_in_process(true); |
[email protected] | a77e4bc | 2011-06-29 02:06:28 | [diff] [blame] | 99 | single_process_renderer_client_.reset( |
| 100 | new content::MockContentRendererClient); |
[email protected] | 15fd0df | 2011-04-29 16:00:16 | [diff] [blame] | 101 | content::GetContentClient()->set_renderer( |
| 102 | single_process_renderer_client_.get()); |
| 103 | } |
[email protected] | 8bcdec9 | 2009-02-25 16:15:18 | [diff] [blame] | 104 | |
[email protected] | 02dbca0b | 2010-09-17 07:44:10 | [diff] [blame] | 105 | #if defined(OS_CHROMEOS) |
[email protected] | 0750b144 | 2010-11-02 21:59:37 | [diff] [blame] | 106 | // Make sure that the log directory exists. |
| 107 | FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName(); |
| 108 | file_util::CreateDirectory(log_dir); |
[email protected] | 02dbca0b | 2010-09-17 07:44:10 | [diff] [blame] | 109 | #endif // defined(OS_CHROMEOS) |
| 110 | |
[email protected] | 6777043 | 2011-09-21 18:12:32 | [diff] [blame] | 111 | host_resolver_ = new net::RuleBasedHostResolverProc(NULL); |
[email protected] | c7ad50f | 2009-09-11 06:28:15 | [diff] [blame] | 112 | |
| 113 | // Something inside the browser does this lookup implicitly. Make it fail |
| 114 | // to avoid external dependency. It won't break the tests. |
| 115 | host_resolver_->AddSimulatedFailure("*.google.com"); |
| 116 | |
| 117 | // See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol |
| 118 | // We don't want the test code to use it. |
| 119 | host_resolver_->AddSimulatedFailure("wpad"); |
| 120 | |
[email protected] | b59ff37 | 2009-07-15 22:04:32 | [diff] [blame] | 121 | net::ScopedDefaultHostResolverProc scoped_host_resolver_proc( |
[email protected] | c7ad50f | 2009-09-11 06:28:15 | [diff] [blame] | 122 | host_resolver_.get()); |
[email protected] | 5c5de8c | 2009-09-23 17:11:26 | [diff] [blame] | 123 | |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 124 | BrowserTestBase::SetUp(); |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 125 | } |
| 126 | |
[email protected] | 06cc083a | 2011-03-01 02:28:42 | [diff] [blame] | 127 | void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { |
[email protected] | 03c79d50 | 2010-11-16 00:38:26 | [diff] [blame] | 128 | // Propagate commandline settings from test_launcher_utils. |
| 129 | test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); |
| 130 | |
[email protected] | 03c79d50 | 2010-11-16 00:38:26 | [diff] [blame] | 131 | if (dom_automation_enabled_) |
| 132 | command_line->AppendSwitch(switches::kDomAutomationController); |
| 133 | |
| 134 | // This is a Browser test. |
| 135 | command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); |
| 136 | |
| 137 | #if defined(OS_WIN) |
| 138 | // The Windows sandbox requires that the browser and child processes are the |
| 139 | // same binary. So we launch browser_process.exe which loads chrome.dll |
| 140 | command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, |
| 141 | command_line->GetProgram()); |
| 142 | #else |
| 143 | // Explicitly set the path of the binary used for child processes, otherwise |
| 144 | // they'll try to use browser_tests which doesn't contain ChromeMain. |
| 145 | FilePath subprocess_path; |
| 146 | PathService::Get(base::FILE_EXE, &subprocess_path); |
| 147 | #if defined(OS_MACOSX) |
| 148 | // Recreate the real environment, run the helper within the app bundle. |
| 149 | subprocess_path = subprocess_path.DirName().DirName(); |
| 150 | DCHECK_EQ(subprocess_path.BaseName().value(), "Contents"); |
| 151 | subprocess_path = |
| 152 | subprocess_path.Append("Versions").Append(chrome::kChromeVersion); |
| 153 | subprocess_path = |
| 154 | subprocess_path.Append(chrome::kHelperProcessExecutablePath); |
| 155 | #endif |
| 156 | command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, |
| 157 | subprocess_path); |
| 158 | #endif |
| 159 | |
[email protected] | 7c8b2067 | 2011-02-11 21:18:01 | [diff] [blame] | 160 | // If neccessary, disable TabCloseableStateWatcher. |
[email protected] | 03c79d50 | 2010-11-16 00:38:26 | [diff] [blame] | 161 | if (!tab_closeable_state_watcher_enabled_) |
| 162 | command_line->AppendSwitch(switches::kDisableTabCloseableStateWatcher); |
| 163 | } |
| 164 | |
[email protected] | fc82ccf0 | 2010-10-15 18:12:47 | [diff] [blame] | 165 | bool InProcessBrowserTest::CreateUserDataDirectory() { |
[email protected] | 06cc083a | 2011-03-01 02:28:42 | [diff] [blame] | 166 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
[email protected] | fc82ccf0 | 2010-10-15 18:12:47 | [diff] [blame] | 167 | FilePath user_data_dir = |
| 168 | command_line->GetSwitchValuePath(switches::kUserDataDir); |
| 169 | if (user_data_dir.empty()) { |
| 170 | if (temp_user_data_dir_.CreateUniqueTempDir() && |
| 171 | temp_user_data_dir_.IsValid()) { |
| 172 | user_data_dir = temp_user_data_dir_.path(); |
| 173 | } else { |
| 174 | LOG(ERROR) << "Could not create temporary user data directory \"" |
| 175 | << temp_user_data_dir_.path().value() << "\"."; |
| 176 | return false; |
| 177 | } |
| 178 | } |
| 179 | return test_launcher_utils::OverrideUserDataDir(user_data_dir); |
| 180 | } |
| 181 | |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 182 | void InProcessBrowserTest::TearDown() { |
[email protected] | b7c64d6 | 2011-08-11 00:08:04 | [diff] [blame] | 183 | DCHECK(!g_browser_process); |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 184 | BrowserTestBase::TearDown(); |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 185 | } |
| 186 | |
[email protected] | 616381f0 | 2010-11-02 15:15:33 | [diff] [blame] | 187 | void InProcessBrowserTest::AddTabAtIndexToBrowser( |
| 188 | Browser* browser, |
| 189 | int index, |
| 190 | const GURL& url, |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame^] | 191 | content::PageTransition transition) { |
[email protected] | 616381f0 | 2010-11-02 15:15:33 | [diff] [blame] | 192 | browser::NavigateParams params(browser, url, transition); |
| 193 | params.tabstrip_index = index; |
| 194 | params.disposition = NEW_FOREGROUND_TAB; |
| 195 | browser::Navigate(¶ms); |
| 196 | } |
| 197 | |
| 198 | void InProcessBrowserTest::AddTabAtIndex( |
| 199 | int index, |
| 200 | const GURL& url, |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame^] | 201 | content::PageTransition transition) { |
[email protected] | 616381f0 | 2010-11-02 15:15:33 | [diff] [blame] | 202 | AddTabAtIndexToBrowser(browser(), index, url, transition); |
| 203 | } |
| 204 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 205 | bool InProcessBrowserTest::SetUpUserDataDirectory() { |
| 206 | return true; |
| 207 | } |
| 208 | |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 209 | // Creates a browser with a single tab (about:blank), waits for the tab to |
| 210 | // finish loading and shows the browser. |
| 211 | Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { |
| 212 | Browser* browser = Browser::Create(profile); |
[email protected] | de4943f | 2011-07-28 16:25:14 | [diff] [blame] | 213 | AddBlankTabAndShow(browser); |
[email protected] | e1c10f18 | 2010-09-30 08:53:06 | [diff] [blame] | 214 | return browser; |
| 215 | } |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 216 | |
[email protected] | 46f979d | 2011-01-10 17:08:44 | [diff] [blame] | 217 | Browser* InProcessBrowserTest::CreateIncognitoBrowser() { |
| 218 | // Create a new browser with using the incognito profile. |
| 219 | Browser* incognito = |
| 220 | Browser::Create(browser()->profile()->GetOffTheRecordProfile()); |
[email protected] | de4943f | 2011-07-28 16:25:14 | [diff] [blame] | 221 | AddBlankTabAndShow(incognito); |
[email protected] | 46f979d | 2011-01-10 17:08:44 | [diff] [blame] | 222 | return incognito; |
| 223 | } |
| 224 | |
[email protected] | e1c10f18 | 2010-09-30 08:53:06 | [diff] [blame] | 225 | Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) { |
[email protected] | 1b74d212 | 2010-10-06 16:49:16 | [diff] [blame] | 226 | Browser* browser = Browser::CreateForType(Browser::TYPE_POPUP, profile); |
[email protected] | de4943f | 2011-07-28 16:25:14 | [diff] [blame] | 227 | AddBlankTabAndShow(browser); |
[email protected] | d4515eb | 2009-01-30 00:40:43 | [diff] [blame] | 228 | return browser; |
| 229 | } |
| 230 | |
[email protected] | de4943f | 2011-07-28 16:25:14 | [diff] [blame] | 231 | void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { |
[email protected] | 3114db2c | 2011-09-12 20:09:05 | [diff] [blame] | 232 | ui_test_utils::WindowedNotificationObserver observer( |
| 233 | content::NOTIFICATION_LOAD_STOP, |
| 234 | NotificationService::AllSources()); |
[email protected] | de4943f | 2011-07-28 16:25:14 | [diff] [blame] | 235 | browser->AddSelectedTabWithURL( |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame^] | 236 | GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_START_PAGE); |
[email protected] | 3114db2c | 2011-09-12 20:09:05 | [diff] [blame] | 237 | observer.Wait(); |
[email protected] | de4943f | 2011-07-28 16:25:14 | [diff] [blame] | 238 | |
[email protected] | fab6ffb | 2011-09-22 18:35:34 | [diff] [blame] | 239 | browser->window()->Show(); |
[email protected] | de4943f | 2011-07-28 16:25:14 | [diff] [blame] | 240 | } |
| 241 | |
[email protected] | b25e61d | 2011-08-23 09:02:01 | [diff] [blame] | 242 | #if defined(OS_POSIX) |
| 243 | // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
| 244 | // debugging easier) and also exit with a known error code (so that the test |
| 245 | // framework considers this a failure -- http://crbug.com/57578). |
| 246 | static void DumpStackTraceSignalHandler(int signal) { |
| 247 | base::debug::StackTrace().PrintBacktrace(); |
| 248 | _exit(128 + signal); |
| 249 | } |
| 250 | #endif // defined(OS_POSIX) |
| 251 | |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 252 | void InProcessBrowserTest::RunTestOnMainThreadLoop() { |
[email protected] | 00d0ac2 | 2010-10-05 09:30:00 | [diff] [blame] | 253 | #if defined(OS_POSIX) |
[email protected] | b25e61d | 2011-08-23 09:02:01 | [diff] [blame] | 254 | signal(SIGTERM, DumpStackTraceSignalHandler); |
[email protected] | 00d0ac2 | 2010-10-05 09:30:00 | [diff] [blame] | 255 | #endif // defined(OS_POSIX) |
| 256 | |
[email protected] | 304a317 | 2010-05-04 05:38:44 | [diff] [blame] | 257 | // On Mac, without the following autorelease pool, code which is directly |
| 258 | // executed (as opposed to executed inside a message loop) would autorelease |
| 259 | // objects into a higher-level pool. This pool is not recycled in-sync with |
| 260 | // the message loops' pools and causes problems with code relying on |
| 261 | // deallocation via an autorelease pool (such as browser window closure and |
| 262 | // browser shutdown). To avoid this, the following pool is recycled after each |
| 263 | // time code is directly executed. |
[email protected] | c2818d4 | 2010-10-18 02:47:39 | [diff] [blame] | 264 | base::mac::ScopedNSAutoreleasePool pool; |
[email protected] | 304a317 | 2010-05-04 05:38:44 | [diff] [blame] | 265 | |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 266 | // Pump startup related events. |
| 267 | MessageLoopForUI::current()->RunAllPending(); |
[email protected] | 304a317 | 2010-05-04 05:38:44 | [diff] [blame] | 268 | pool.Recycle(); |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 269 | |
[email protected] | 6777043 | 2011-09-21 18:12:32 | [diff] [blame] | 270 | browser_ = CreateBrowser(ProfileManager::GetDefaultProfile()); |
[email protected] | 304a317 | 2010-05-04 05:38:44 | [diff] [blame] | 271 | pool.Recycle(); |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 272 | |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 273 | // Pump any pending events that were created as a result of creating a |
| 274 | // browser. |
| 275 | MessageLoopForUI::current()->RunAllPending(); |
| 276 | |
[email protected] | 28dabab7 | 2011-01-05 03:31:26 | [diff] [blame] | 277 | SetUpOnMainThread(); |
| 278 | pool.Recycle(); |
| 279 | |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 280 | RunTestOnMainThread(); |
[email protected] | 304a317 | 2010-05-04 05:38:44 | [diff] [blame] | 281 | pool.Recycle(); |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 282 | |
| 283 | CleanUpOnMainThread(); |
[email protected] | 304a317 | 2010-05-04 05:38:44 | [diff] [blame] | 284 | pool.Recycle(); |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 285 | |
| 286 | QuitBrowsers(); |
[email protected] | 304a317 | 2010-05-04 05:38:44 | [diff] [blame] | 287 | pool.Recycle(); |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | void InProcessBrowserTest::QuitBrowsers() { |
| 291 | if (BrowserList::size() == 0) |
| 292 | return; |
| 293 | |
[email protected] | bc63a07 | 2011-06-28 21:12:57 | [diff] [blame] | 294 | // Invoke CloseAllBrowsersAndMayExit on a running message loop. |
| 295 | // CloseAllBrowsersAndMayExit exits the message loop after everything has been |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 296 | // shut down properly. |
| 297 | MessageLoopForUI::current()->PostTask( |
| 298 | FROM_HERE, |
[email protected] | bc63a07 | 2011-06-28 21:12:57 | [diff] [blame] | 299 | NewRunnableFunction(&BrowserList::AttemptExit)); |
[email protected] | 64f1931 | 2010-04-13 22:30:01 | [diff] [blame] | 300 | ui_test_utils::RunMessageLoop(); |
| 301 | } |