| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mac/scoped_nsautorelease_pool.h" | 7 #include "base/mac/scoped_nsautorelease_pool.h" |
| 8 #include "chrome/browser/devtools/devtools_window.h" | 8 #include "chrome/browser/devtools/devtools_window.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 DevToolsWindow::OpenDevToolsWindow(web_contents); | 23 DevToolsWindow::OpenDevToolsWindow(web_contents); |
| 24 ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents)); | 24 ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents)); |
| 25 } | 25 } |
| 26 | 26 |
| 27 Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile, | 27 Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile, |
| 28 const GURL& url) { | 28 const GURL& url) { |
| 29 // Opening an incognito window can cause AppKit to throw objects into the | 29 // Opening an incognito window can cause AppKit to throw objects into the |
| 30 // autorelease pool. Flush the pool when this function returns. | 30 // autorelease pool. Flush the pool when this function returns. |
| 31 base::mac::ScopedNSAutoreleasePool pool; | 31 base::mac::ScopedNSAutoreleasePool pool; |
| 32 | 32 |
| 33 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); | 33 chrome::OpenURLOffTheRecord(profile, url); |
| 34 chrome::OpenURLOffTheRecord(profile, url, active_desktop); | |
| 35 Browser* browser = | 34 Browser* browser = |
| 36 chrome::FindTabbedBrowser(profile->GetOffTheRecordProfile(), false); | 35 chrome::FindTabbedBrowser(profile->GetOffTheRecordProfile(), false); |
| 37 content::TestNavigationObserver observer( | 36 content::TestNavigationObserver observer( |
| 38 browser->tab_strip_model()->GetActiveWebContents()); | 37 browser->tab_strip_model()->GetActiveWebContents()); |
| 39 observer.Wait(); | 38 observer.Wait(); |
| 40 return browser; | 39 return browser; |
| 41 } | 40 } |
| 42 | 41 |
| 43 // Creates a browser with a single tab (about:blank), waits for the tab to | 42 // Creates a browser with a single tab (about:blank), waits for the tab to |
| 44 // finish loading and shows the browser. | 43 // finish loading and shows the browser. |
| 45 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { | 44 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { |
| 46 // Making a browser window can cause AppKit to throw objects into the | 45 // Making a browser window can cause AppKit to throw objects into the |
| 47 // autorelease pool. Flush the pool when this function returns. | 46 // autorelease pool. Flush the pool when this function returns. |
| 48 base::mac::ScopedNSAutoreleasePool pool; | 47 base::mac::ScopedNSAutoreleasePool pool; |
| 49 | 48 |
| 50 Browser* browser = new Browser( | 49 Browser* browser = new Browser(Browser::CreateParams(profile)); |
| 51 Browser::CreateParams(profile, chrome::GetActiveDesktop())); | |
| 52 AddBlankTabAndShow(browser); | 50 AddBlankTabAndShow(browser); |
| 53 return browser; | 51 return browser; |
| 54 } | 52 } |
| 55 | 53 |
| 56 Browser* InProcessBrowserTest::CreateIncognitoBrowser() { | 54 Browser* InProcessBrowserTest::CreateIncognitoBrowser() { |
| 57 // Making a browser window can cause AppKit to throw objects into the | 55 // Making a browser window can cause AppKit to throw objects into the |
| 58 // autorelease pool. Flush the pool when this function returns. | 56 // autorelease pool. Flush the pool when this function returns. |
| 59 base::mac::ScopedNSAutoreleasePool pool; | 57 base::mac::ScopedNSAutoreleasePool pool; |
| 60 | 58 |
| 61 // Create a new browser with using the incognito profile. | 59 // Create a new browser with using the incognito profile. |
| 62 Browser* incognito = new Browser( | 60 Browser* incognito = new Browser( |
| 63 Browser::CreateParams(browser()->profile()->GetOffTheRecordProfile(), | 61 Browser::CreateParams(browser()->profile()->GetOffTheRecordProfile())); |
| 64 chrome::GetActiveDesktop())); | |
| 65 AddBlankTabAndShow(incognito); | 62 AddBlankTabAndShow(incognito); |
| 66 return incognito; | 63 return incognito; |
| 67 } | 64 } |
| 68 | 65 |
| 69 Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) { | 66 Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) { |
| 70 // Making a browser window can cause AppKit to throw objects into the | 67 // Making a browser window can cause AppKit to throw objects into the |
| 71 // autorelease pool. Flush the pool when this function returns. | 68 // autorelease pool. Flush the pool when this function returns. |
| 72 base::mac::ScopedNSAutoreleasePool pool; | 69 base::mac::ScopedNSAutoreleasePool pool; |
| 73 | 70 |
| 74 Browser* browser = | 71 Browser* browser = |
| 75 new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile, | 72 new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile)); |
| 76 chrome::GetActiveDesktop())); | |
| 77 AddBlankTabAndShow(browser); | 73 AddBlankTabAndShow(browser); |
| 78 return browser; | 74 return browser; |
| 79 } | 75 } |
| 80 | 76 |
| 81 Browser* InProcessBrowserTest::CreateBrowserForApp( | 77 Browser* InProcessBrowserTest::CreateBrowserForApp( |
| 82 const std::string& app_name, | 78 const std::string& app_name, |
| 83 Profile* profile) { | 79 Profile* profile) { |
| 84 // Making a browser window can cause AppKit to throw objects into the | 80 // Making a browser window can cause AppKit to throw objects into the |
| 85 // autorelease pool. Flush the pool when this function returns. | 81 // autorelease pool. Flush the pool when this function returns. |
| 86 base::mac::ScopedNSAutoreleasePool pool; | 82 base::mac::ScopedNSAutoreleasePool pool; |
| 87 | 83 |
| 88 Browser* browser = new Browser( | 84 Browser* browser = new Browser(Browser::CreateParams::CreateForApp( |
| 89 Browser::CreateParams::CreateForApp( | 85 app_name, false /* trusted_source */, gfx::Rect(), profile)); |
| 90 app_name, false /* trusted_source */, gfx::Rect(), profile, | |
| 91 chrome::GetActiveDesktop())); | |
| 92 AddBlankTabAndShow(browser); | 86 AddBlankTabAndShow(browser); |
| 93 return browser; | 87 return browser; |
| 94 } | 88 } |
| OLD | NEW |