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 "chrome/test/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
42 #include "chrome/browser/chromeos/audio_handler.h" | 42 #include "chrome/browser/chromeos/audio_handler.h" |
43 #elif defined(OS_MACOSX) | 43 #elif defined(OS_MACOSX) |
44 #include "base/mac/scoped_nsautorelease_pool.h" | 44 #include "base/mac/scoped_nsautorelease_pool.h" |
45 #endif | 45 #endif |
46 | 46 |
47 #if defined(USE_AURA) | 47 #if defined(USE_AURA) |
48 #include "ui/aura/desktop.h" | 48 #include "ui/aura/desktop.h" |
49 #endif | 49 #endif |
50 | 50 |
| 51 namespace { |
| 52 |
51 // Passed as value of kTestType. | 53 // Passed as value of kTestType. |
52 static const char kBrowserTestType[] = "browser"; | 54 const char kBrowserTestType[] = "browser"; |
| 55 |
| 56 } // namespace |
53 | 57 |
54 InProcessBrowserTest::InProcessBrowserTest() | 58 InProcessBrowserTest::InProcessBrowserTest() |
55 : browser_(NULL), | 59 : browser_(NULL), |
56 show_window_(false), | 60 show_window_(false), |
57 dom_automation_enabled_(false), | 61 dom_automation_enabled_(false), |
58 tab_closeable_state_watcher_enabled_(false) { | 62 tab_closeable_state_watcher_enabled_(false) { |
59 #if defined(OS_MACOSX) | 63 #if defined(OS_MACOSX) |
60 // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. | 64 // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. |
61 // Before we run the browser, we have to hack the path to the exe to match | 65 // Before we run the browser, we have to hack the path to the exe to match |
62 // what it would be if Chrome was running, because it is used to fork renderer | 66 // what it would be if Chrome was running, because it is used to fork renderer |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // executed (as opposed to executed inside a message loop) would autorelease | 270 // executed (as opposed to executed inside a message loop) would autorelease |
267 // objects into a higher-level pool. This pool is not recycled in-sync with | 271 // objects into a higher-level pool. This pool is not recycled in-sync with |
268 // the message loops' pools and causes problems with code relying on | 272 // the message loops' pools and causes problems with code relying on |
269 // deallocation via an autorelease pool (such as browser window closure and | 273 // deallocation via an autorelease pool (such as browser window closure and |
270 // browser shutdown). To avoid this, the following pool is recycled after each | 274 // browser shutdown). To avoid this, the following pool is recycled after each |
271 // time code is directly executed. | 275 // time code is directly executed. |
272 base::mac::ScopedNSAutoreleasePool pool; | 276 base::mac::ScopedNSAutoreleasePool pool; |
273 #endif | 277 #endif |
274 | 278 |
275 // Pump startup related events. | 279 // Pump startup related events. |
276 #if defined(USE_AURA) | 280 ui_test_utils::RunAllPendingInMessageLoop(); |
277 MessageLoopForUI::current()->RunAllPendingWithDispatcher( | 281 |
278 aura::Desktop::GetInstance()->GetDispatcher()); | |
279 #else | |
280 MessageLoopForUI::current()->RunAllPending(); | |
281 #endif | |
282 #if defined(OS_MACOSX) | 282 #if defined(OS_MACOSX) |
283 pool.Recycle(); | 283 pool.Recycle(); |
284 #endif | 284 #endif |
285 | 285 |
286 browser_ = CreateBrowser(ProfileManager::GetDefaultProfile()); | 286 browser_ = CreateBrowser(ProfileManager::GetDefaultProfile()); |
287 #if defined(OS_MACOSX) | 287 #if defined(OS_MACOSX) |
288 pool.Recycle(); | 288 pool.Recycle(); |
289 #endif | 289 #endif |
290 | 290 |
291 // Pump any pending events that were created as a result of creating a | 291 // Pump any pending events that were created as a result of creating a |
292 // browser. | 292 // browser. |
293 MessageLoopForUI::current()->RunAllPending(); | 293 ui_test_utils::RunAllPendingInMessageLoop(); |
294 | 294 |
295 SetUpOnMainThread(); | 295 SetUpOnMainThread(); |
296 #if defined(OS_MACOSX) | 296 #if defined(OS_MACOSX) |
297 pool.Recycle(); | 297 pool.Recycle(); |
298 #endif | 298 #endif |
299 | 299 |
300 if (!HasFatalFailure()) | 300 if (!HasFatalFailure()) |
301 RunTestOnMainThread(); | 301 RunTestOnMainThread(); |
302 #if defined(OS_MACOSX) | 302 #if defined(OS_MACOSX) |
303 pool.Recycle(); | 303 pool.Recycle(); |
(...skipping 16 matching lines...) Expand all Loading... |
320 if (BrowserList::size() == 0) | 320 if (BrowserList::size() == 0) |
321 return; | 321 return; |
322 | 322 |
323 // Invoke CloseAllBrowsersAndMayExit on a running message loop. | 323 // Invoke CloseAllBrowsersAndMayExit on a running message loop. |
324 // CloseAllBrowsersAndMayExit exits the message loop after everything has been | 324 // CloseAllBrowsersAndMayExit exits the message loop after everything has been |
325 // shut down properly. | 325 // shut down properly. |
326 MessageLoopForUI::current()->PostTask(FROM_HERE, | 326 MessageLoopForUI::current()->PostTask(FROM_HERE, |
327 base::Bind(&BrowserList::AttemptExit)); | 327 base::Bind(&BrowserList::AttemptExit)); |
328 ui_test_utils::RunMessageLoop(); | 328 ui_test_utils::RunMessageLoop(); |
329 } | 329 } |
OLD | NEW |