| 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 "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 #if !defined(OS_MACOSX) | 422 #if !defined(OS_MACOSX) |
| 423 void InProcessBrowserTest::OpenDevToolsWindow( | 423 void InProcessBrowserTest::OpenDevToolsWindow( |
| 424 content::WebContents* web_contents) { | 424 content::WebContents* web_contents) { |
| 425 ASSERT_FALSE(content::DevToolsAgentHost::HasFor(web_contents)); | 425 ASSERT_FALSE(content::DevToolsAgentHost::HasFor(web_contents)); |
| 426 DevToolsWindow::OpenDevToolsWindow(web_contents); | 426 DevToolsWindow::OpenDevToolsWindow(web_contents); |
| 427 ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents)); | 427 ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents)); |
| 428 } | 428 } |
| 429 | 429 |
| 430 Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile, | 430 Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile, |
| 431 const GURL& url) { | 431 const GURL& url) { |
| 432 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); | 432 chrome::OpenURLOffTheRecord(profile, url); |
| 433 chrome::OpenURLOffTheRecord(profile, url, active_desktop); | |
| 434 Browser* browser = | 433 Browser* browser = |
| 435 chrome::FindTabbedBrowser(profile->GetOffTheRecordProfile(), false); | 434 chrome::FindTabbedBrowser(profile->GetOffTheRecordProfile(), false); |
| 436 content::TestNavigationObserver observer( | 435 content::TestNavigationObserver observer( |
| 437 browser->tab_strip_model()->GetActiveWebContents()); | 436 browser->tab_strip_model()->GetActiveWebContents()); |
| 438 observer.Wait(); | 437 observer.Wait(); |
| 439 return browser; | 438 return browser; |
| 440 } | 439 } |
| 441 | 440 |
| 442 // Creates a browser with a single tab (about:blank), waits for the tab to | 441 // Creates a browser with a single tab (about:blank), waits for the tab to |
| 443 // finish loading and shows the browser. | 442 // finish loading and shows the browser. |
| 444 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { | 443 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { |
| 445 Browser* browser = new Browser( | 444 Browser* browser = new Browser(Browser::CreateParams(profile)); |
| 446 Browser::CreateParams(profile, chrome::GetActiveDesktop())); | |
| 447 AddBlankTabAndShow(browser); | 445 AddBlankTabAndShow(browser); |
| 448 return browser; | 446 return browser; |
| 449 } | 447 } |
| 450 | 448 |
| 451 Browser* InProcessBrowserTest::CreateIncognitoBrowser() { | 449 Browser* InProcessBrowserTest::CreateIncognitoBrowser() { |
| 452 // Create a new browser with using the incognito profile. | 450 // Create a new browser with using the incognito profile. |
| 453 Browser* incognito = new Browser( | 451 Browser* incognito = new Browser( |
| 454 Browser::CreateParams(browser()->profile()->GetOffTheRecordProfile(), | 452 Browser::CreateParams(browser()->profile()->GetOffTheRecordProfile())); |
| 455 chrome::GetActiveDesktop())); | |
| 456 AddBlankTabAndShow(incognito); | 453 AddBlankTabAndShow(incognito); |
| 457 return incognito; | 454 return incognito; |
| 458 } | 455 } |
| 459 | 456 |
| 460 Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) { | 457 Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) { |
| 461 Browser* browser = | 458 Browser* browser = |
| 462 new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile, | 459 new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile)); |
| 463 chrome::GetActiveDesktop())); | |
| 464 AddBlankTabAndShow(browser); | 460 AddBlankTabAndShow(browser); |
| 465 return browser; | 461 return browser; |
| 466 } | 462 } |
| 467 | 463 |
| 468 Browser* InProcessBrowserTest::CreateBrowserForApp( | 464 Browser* InProcessBrowserTest::CreateBrowserForApp( |
| 469 const std::string& app_name, | 465 const std::string& app_name, |
| 470 Profile* profile) { | 466 Profile* profile) { |
| 471 Browser* browser = new Browser( | 467 Browser* browser = new Browser( |
| 472 Browser::CreateParams::CreateForApp( | 468 Browser::CreateParams::CreateForApp( |
| 473 app_name, false /* trusted_source */, gfx::Rect(), profile, | 469 app_name, false /* trusted_source */, gfx::Rect(), profile)); |
| 474 chrome::GetActiveDesktop())); | |
| 475 AddBlankTabAndShow(browser); | 470 AddBlankTabAndShow(browser); |
| 476 return browser; | 471 return browser; |
| 477 } | 472 } |
| 478 #endif // !defined(OS_MACOSX) | 473 #endif // !defined(OS_MACOSX) |
| 479 | 474 |
| 480 void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { | 475 void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { |
| 481 content::WindowedNotificationObserver observer( | 476 content::WindowedNotificationObserver observer( |
| 482 content::NOTIFICATION_LOAD_STOP, | 477 content::NOTIFICATION_LOAD_STOP, |
| 483 content::NotificationService::AllSources()); | 478 content::NotificationService::AllSources()); |
| 484 chrome::AddSelectedTabWithURL(browser, | 479 chrome::AddSelectedTabWithURL(browser, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 // On the Mac, this eventually reaches | 607 // On the Mac, this eventually reaches |
| 613 // -[BrowserWindowController windowWillClose:], which will post a deferred | 608 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 614 // -autorelease on itself to ultimately destroy the Browser object. The line | 609 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 615 // below is necessary to pump these pending messages to ensure all Browsers | 610 // below is necessary to pump these pending messages to ensure all Browsers |
| 616 // get deleted. | 611 // get deleted. |
| 617 content::RunAllPendingInMessageLoop(); | 612 content::RunAllPendingInMessageLoop(); |
| 618 delete autorelease_pool_; | 613 delete autorelease_pool_; |
| 619 autorelease_pool_ = NULL; | 614 autorelease_pool_ = NULL; |
| 620 #endif | 615 #endif |
| 621 } | 616 } |
| OLD | NEW |