Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/test/base/in_process_browser_test_mac.cc

Issue 1225093003: mac: Flush the autorelease pool after making a browser window in browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser_test_base
Patch Set: Comments from jhawkins, round two. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/base/in_process_browser_test.cc ('k') | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/test/base/in_process_browser_test.h"
6
7 #include "base/mac/scoped_nsautorelease_pool.h"
8 #include "chrome/browser/devtools/devtools_window.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/browser_finder.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "content/public/test/test_navigation_observer.h"
15
16 void InProcessBrowserTest::OpenDevToolsWindow(
17 content::WebContents* web_contents) {
18 // Opening a Devtools Window can cause AppKit to throw objects into the
19 // autorelease pool. Flush the pool when this function returns.
20 base::mac::ScopedNSAutoreleasePool pool;
21
22 ASSERT_FALSE(content::DevToolsAgentHost::HasFor(web_contents));
23 DevToolsWindow::OpenDevToolsWindow(web_contents);
24 ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents));
25 }
26
27 Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
28 const GURL& url) {
29 // Opening an incognito window can cause AppKit to throw objects into the
30 // autorelease pool. Flush the pool when this function returns.
31 base::mac::ScopedNSAutoreleasePool pool;
32
33 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop();
34 chrome::OpenURLOffTheRecord(profile, url, active_desktop);
35 Browser* browser = chrome::FindTabbedBrowser(
36 profile->GetOffTheRecordProfile(), false, active_desktop);
37 content::TestNavigationObserver observer(
38 browser->tab_strip_model()->GetActiveWebContents());
39 observer.Wait();
40 return browser;
41 }
42
43 // Creates a browser with a single tab (about:blank), waits for the tab to
44 // finish loading and shows the browser.
45 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
46 // Making a browser window can cause AppKit to throw objects into the
47 // autorelease pool. Flush the pool when this function returns.
48 base::mac::ScopedNSAutoreleasePool pool;
49
50 Browser* browser = new Browser(
51 Browser::CreateParams(profile, chrome::GetActiveDesktop()));
52 AddBlankTabAndShow(browser);
53 return browser;
54 }
55
56 Browser* InProcessBrowserTest::CreateIncognitoBrowser() {
57 // Making a browser window can cause AppKit to throw objects into the
58 // autorelease pool. Flush the pool when this function returns.
59 base::mac::ScopedNSAutoreleasePool pool;
60
61 // Create a new browser with using the incognito profile.
62 Browser* incognito = new Browser(
63 Browser::CreateParams(browser()->profile()->GetOffTheRecordProfile(),
64 chrome::GetActiveDesktop()));
65 AddBlankTabAndShow(incognito);
66 return incognito;
67 }
68
69 Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) {
70 // Making a browser window can cause AppKit to throw objects into the
71 // autorelease pool. Flush the pool when this function returns.
72 base::mac::ScopedNSAutoreleasePool pool;
73
74 Browser* browser =
75 new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile,
76 chrome::GetActiveDesktop()));
77 AddBlankTabAndShow(browser);
78 return browser;
79 }
80
81 Browser* InProcessBrowserTest::CreateBrowserForApp(
82 const std::string& app_name,
83 Profile* profile) {
84 // Making a browser window can cause AppKit to throw objects into the
85 // autorelease pool. Flush the pool when this function returns.
86 base::mac::ScopedNSAutoreleasePool pool;
87
88 Browser* browser = new Browser(
89 Browser::CreateParams::CreateForApp(
90 app_name, false /* trusted_source */, gfx::Rect(), profile,
91 chrome::GetActiveDesktop()));
92 AddBlankTabAndShow(browser);
93 return browser;
94 }
OLDNEW
« no previous file with comments | « chrome/test/base/in_process_browser_test.cc ('k') | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698