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/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/test/test_file_util.h" | 18 #include "base/test/test_file_util.h" |
19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/devtools/devtools_window.h" |
23 #include "chrome/browser/lifetime/application_lifetime.h" | 24 #include "chrome/browser/lifetime/application_lifetime.h" |
24 #include "chrome/browser/net/net_error_tab_helper.h" | 25 #include "chrome/browser/net/net_error_tab_helper.h" |
25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/browser/ui/browser_commands.h" |
28 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/browser_list_observer.h" | 32 #include "chrome/browser/ui/browser_list_observer.h" |
31 #include "chrome/browser/ui/browser_navigator.h" | 33 #include "chrome/browser/ui/browser_navigator.h" |
32 #include "chrome/browser/ui/browser_tabstrip.h" | 34 #include "chrome/browser/ui/browser_tabstrip.h" |
33 #include "chrome/browser/ui/browser_window.h" | 35 #include "chrome/browser/ui/browser_window.h" |
34 #include "chrome/browser/ui/host_desktop.h" | 36 #include "chrome/browser/ui/host_desktop.h" |
35 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 37 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
36 #include "chrome/common/chrome_constants.h" | 38 #include "chrome/common/chrome_constants.h" |
37 #include "chrome/common/chrome_paths.h" | 39 #include "chrome/common/chrome_paths.h" |
38 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/logging_chrome.h" | 41 #include "chrome/common/logging_chrome.h" |
40 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
41 #include "chrome/renderer/chrome_content_renderer_client.h" | 43 #include "chrome/renderer/chrome_content_renderer_client.h" |
42 #include "chrome/test/base/chrome_test_suite.h" | 44 #include "chrome/test/base/chrome_test_suite.h" |
43 #include "chrome/test/base/test_launcher_utils.h" | 45 #include "chrome/test/base/test_launcher_utils.h" |
44 #include "chrome/test/base/test_switches.h" | 46 #include "chrome/test/base/test_switches.h" |
45 #include "chrome/test/base/testing_browser_process.h" | 47 #include "chrome/test/base/testing_browser_process.h" |
46 #include "components/google/core/browser/google_util.h" | 48 #include "components/google/core/browser/google_util.h" |
47 #include "components/os_crypt/os_crypt.h" | 49 #include "components/os_crypt/os_crypt.h" |
| 50 #include "content/public/browser/devtools_agent_host.h" |
48 #include "content/public/browser/notification_service.h" | 51 #include "content/public/browser/notification_service.h" |
49 #include "content/public/browser/notification_types.h" | 52 #include "content/public/browser/notification_types.h" |
50 #include "content/public/test/browser_test_utils.h" | 53 #include "content/public/test/browser_test_utils.h" |
51 #include "content/public/test/test_launcher.h" | 54 #include "content/public/test/test_launcher.h" |
52 #include "content/public/test/test_navigation_observer.h" | 55 #include "content/public/test/test_navigation_observer.h" |
53 #include "net/test/embedded_test_server/embedded_test_server.h" | 56 #include "net/test/embedded_test_server/embedded_test_server.h" |
54 #include "net/test/spawned_test_server/spawned_test_server.h" | 57 #include "net/test/spawned_test_server/spawned_test_server.h" |
55 | 58 |
56 #if defined(OS_MACOSX) | 59 #if defined(OS_MACOSX) |
57 #include "base/mac/scoped_nsautorelease_pool.h" | 60 #include "base/mac/scoped_nsautorelease_pool.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 int index, | 436 int index, |
434 const GURL& url, | 437 const GURL& url, |
435 ui::PageTransition transition) { | 438 ui::PageTransition transition) { |
436 AddTabAtIndexToBrowser(browser(), index, url, transition, true); | 439 AddTabAtIndexToBrowser(browser(), index, url, transition, true); |
437 } | 440 } |
438 | 441 |
439 bool InProcessBrowserTest::SetUpUserDataDirectory() { | 442 bool InProcessBrowserTest::SetUpUserDataDirectory() { |
440 return true; | 443 return true; |
441 } | 444 } |
442 | 445 |
| 446 #if !defined(OS_MACOSX) |
| 447 void InProcessBrowserTest::OpenDevToolsWindow( |
| 448 content::WebContents* web_contents) { |
| 449 ASSERT_FALSE(content::DevToolsAgentHost::HasFor(web_contents)); |
| 450 DevToolsWindow::OpenDevToolsWindow(web_contents); |
| 451 ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents)); |
| 452 } |
| 453 |
| 454 Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile, |
| 455 const GURL& url) { |
| 456 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); |
| 457 chrome::OpenURLOffTheRecord(profile, url, active_desktop); |
| 458 Browser* browser = chrome::FindTabbedBrowser( |
| 459 profile->GetOffTheRecordProfile(), false, active_desktop); |
| 460 content::TestNavigationObserver observer( |
| 461 browser->tab_strip_model()->GetActiveWebContents()); |
| 462 observer.Wait(); |
| 463 return browser; |
| 464 } |
| 465 |
443 // Creates a browser with a single tab (about:blank), waits for the tab to | 466 // Creates a browser with a single tab (about:blank), waits for the tab to |
444 // finish loading and shows the browser. | 467 // finish loading and shows the browser. |
445 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { | 468 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { |
446 Browser* browser = new Browser( | 469 Browser* browser = new Browser( |
447 Browser::CreateParams(profile, chrome::GetActiveDesktop())); | 470 Browser::CreateParams(profile, chrome::GetActiveDesktop())); |
448 AddBlankTabAndShow(browser); | 471 AddBlankTabAndShow(browser); |
449 return browser; | 472 return browser; |
450 } | 473 } |
451 | 474 |
452 Browser* InProcessBrowserTest::CreateIncognitoBrowser() { | 475 Browser* InProcessBrowserTest::CreateIncognitoBrowser() { |
(...skipping 16 matching lines...) Expand all Loading... |
469 Browser* InProcessBrowserTest::CreateBrowserForApp( | 492 Browser* InProcessBrowserTest::CreateBrowserForApp( |
470 const std::string& app_name, | 493 const std::string& app_name, |
471 Profile* profile) { | 494 Profile* profile) { |
472 Browser* browser = new Browser( | 495 Browser* browser = new Browser( |
473 Browser::CreateParams::CreateForApp( | 496 Browser::CreateParams::CreateForApp( |
474 app_name, false /* trusted_source */, gfx::Rect(), profile, | 497 app_name, false /* trusted_source */, gfx::Rect(), profile, |
475 chrome::GetActiveDesktop())); | 498 chrome::GetActiveDesktop())); |
476 AddBlankTabAndShow(browser); | 499 AddBlankTabAndShow(browser); |
477 return browser; | 500 return browser; |
478 } | 501 } |
| 502 #endif // !defined(OS_MACOSX) |
479 | 503 |
480 void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { | 504 void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { |
481 content::WindowedNotificationObserver observer( | 505 content::WindowedNotificationObserver observer( |
482 content::NOTIFICATION_LOAD_STOP, | 506 content::NOTIFICATION_LOAD_STOP, |
483 content::NotificationService::AllSources()); | 507 content::NotificationService::AllSources()); |
484 chrome::AddSelectedTabWithURL(browser, | 508 chrome::AddSelectedTabWithURL(browser, |
485 GURL(url::kAboutBlankURL), | 509 GURL(url::kAboutBlankURL), |
486 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); | 510 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
487 observer.Wait(); | 511 observer.Wait(); |
488 | 512 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 // On the Mac, this eventually reaches | 647 // On the Mac, this eventually reaches |
624 // -[BrowserWindowController windowWillClose:], which will post a deferred | 648 // -[BrowserWindowController windowWillClose:], which will post a deferred |
625 // -autorelease on itself to ultimately destroy the Browser object. The line | 649 // -autorelease on itself to ultimately destroy the Browser object. The line |
626 // below is necessary to pump these pending messages to ensure all Browsers | 650 // below is necessary to pump these pending messages to ensure all Browsers |
627 // get deleted. | 651 // get deleted. |
628 content::RunAllPendingInMessageLoop(); | 652 content::RunAllPendingInMessageLoop(); |
629 delete autorelease_pool_; | 653 delete autorelease_pool_; |
630 autorelease_pool_ = NULL; | 654 autorelease_pool_ = NULL; |
631 #endif | 655 #endif |
632 } | 656 } |
OLD | NEW |