OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/test/test_file_util.h" | 15 #include "base/test/test_file_util.h" |
16 #include "base/test/test_switches.h" | 16 #include "base/test/test_switches.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/io_thread.h" | 18 #include "chrome/browser/io_thread.h" |
19 #include "chrome/browser/lifetime/application_lifetime.h" | 19 #include "chrome/browser/lifetime/application_lifetime.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
24 #include "chrome/browser/ui/browser_navigator.h" | 24 #include "chrome/browser/ui/browser_navigator.h" |
| 25 #include "chrome/browser/ui/browser_tabstrip.h" |
25 #include "chrome/browser/ui/browser_window.h" | 26 #include "chrome/browser/ui/browser_window.h" |
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
27 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/logging_chrome.h" | 31 #include "chrome/common/logging_chrome.h" |
31 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
32 #include "chrome/renderer/chrome_content_renderer_client.h" | 33 #include "chrome/renderer/chrome_content_renderer_client.h" |
33 #include "chrome/test/base/chrome_test_suite.h" | 34 #include "chrome/test/base/chrome_test_suite.h" |
34 #include "chrome/test/base/test_launcher_utils.h" | 35 #include "chrome/test/base/test_launcher_utils.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 Browser::CreateParams::CreateForApp( | 279 Browser::CreateParams::CreateForApp( |
279 Browser::TYPE_POPUP, app_name, gfx::Rect(), profile)); | 280 Browser::TYPE_POPUP, app_name, gfx::Rect(), profile)); |
280 AddBlankTabAndShow(browser); | 281 AddBlankTabAndShow(browser); |
281 return browser; | 282 return browser; |
282 } | 283 } |
283 | 284 |
284 void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { | 285 void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { |
285 ui_test_utils::WindowedNotificationObserver observer( | 286 ui_test_utils::WindowedNotificationObserver observer( |
286 content::NOTIFICATION_LOAD_STOP, | 287 content::NOTIFICATION_LOAD_STOP, |
287 content::NotificationService::AllSources()); | 288 content::NotificationService::AllSources()); |
288 browser->AddSelectedTabWithURL( | 289 chrome::AddSelectedTabWithURL(browser, GURL(chrome::kAboutBlankURL), |
289 GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_START_PAGE); | 290 content::PAGE_TRANSITION_START_PAGE); |
290 observer.Wait(); | 291 observer.Wait(); |
291 | 292 |
292 browser->window()->Show(); | 293 browser->window()->Show(); |
293 } | 294 } |
294 | 295 |
295 #if !defined(OS_MACOSX) | 296 #if !defined(OS_MACOSX) |
296 CommandLine InProcessBrowserTest::GetCommandLineForRelaunch() { | 297 CommandLine InProcessBrowserTest::GetCommandLineForRelaunch() { |
297 CommandLine new_command_line(CommandLine::ForCurrentProcess()->GetProgram()); | 298 CommandLine new_command_line(CommandLine::ForCurrentProcess()->GetProgram()); |
298 CommandLine::SwitchMap switches = | 299 CommandLine::SwitchMap switches = |
299 CommandLine::ForCurrentProcess()->GetSwitches(); | 300 CommandLine::ForCurrentProcess()->GetSwitches(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 343 |
343 // Pump startup related events. | 344 // Pump startup related events. |
344 ui_test_utils::RunAllPendingInMessageLoop(); | 345 ui_test_utils::RunAllPendingInMessageLoop(); |
345 | 346 |
346 #if defined(OS_MACOSX) | 347 #if defined(OS_MACOSX) |
347 autorelease_pool_->Recycle(); | 348 autorelease_pool_->Recycle(); |
348 #endif | 349 #endif |
349 | 350 |
350 if (!BrowserList::empty()) { | 351 if (!BrowserList::empty()) { |
351 browser_ = *BrowserList::begin(); | 352 browser_ = *BrowserList::begin(); |
352 ui_test_utils::WaitForLoadStop(browser_->GetActiveWebContents()); | 353 ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser_)); |
353 } | 354 } |
354 | 355 |
355 // Pump any pending events that were created as a result of creating a | 356 // Pump any pending events that were created as a result of creating a |
356 // browser. | 357 // browser. |
357 ui_test_utils::RunAllPendingInMessageLoop(); | 358 ui_test_utils::RunAllPendingInMessageLoop(); |
358 | 359 |
359 SetUpOnMainThread(); | 360 SetUpOnMainThread(); |
360 #if defined(OS_MACOSX) | 361 #if defined(OS_MACOSX) |
361 autorelease_pool_->Recycle(); | 362 autorelease_pool_->Recycle(); |
362 #endif | 363 #endif |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // On the Mac, this eventually reaches | 404 // On the Mac, this eventually reaches |
404 // -[BrowserWindowController windowWillClose:], which will post a deferred | 405 // -[BrowserWindowController windowWillClose:], which will post a deferred |
405 // -autorelease on itself to ultimately destroy the Browser object. The line | 406 // -autorelease on itself to ultimately destroy the Browser object. The line |
406 // below is necessary to pump these pending messages to ensure all Browsers | 407 // below is necessary to pump these pending messages to ensure all Browsers |
407 // get deleted. | 408 // get deleted. |
408 ui_test_utils::RunAllPendingInMessageLoop(); | 409 ui_test_utils::RunAllPendingInMessageLoop(); |
409 delete autorelease_pool_; | 410 delete autorelease_pool_; |
410 autorelease_pool_ = NULL; | 411 autorelease_pool_ = NULL; |
411 #endif | 412 #endif |
412 } | 413 } |
OLD | NEW |