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

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

Issue 9420036: Also delay regular profile destruction... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_with_test_window_test.h" 5 #include "chrome/test/base/browser_with_test_window_test.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <ole2.h> 8 #include <ole2.h>
9 #endif // defined(OS_WIN) 9 #endif // defined(OS_WIN)
10 10
11 #include "chrome//browser/profiles/profile_destroyer.h"
11 #include "chrome/browser/tabs/tab_strip_model.h" 12 #include "chrome/browser/tabs/tab_strip_model.h"
12 #include "chrome/browser/ui/browser_navigator.h" 13 #include "chrome/browser/ui/browser_navigator.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
14 #include "chrome/common/render_messages.h" 15 #include "chrome/common/render_messages.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/page_transition_types.h" 20 #include "content/public/common/page_transition_types.h"
20 21
(...skipping 10 matching lines...) Expand all
31 OleInitialize(NULL); 32 OleInitialize(NULL);
32 #endif 33 #endif
33 #if defined(USE_AURA) 34 #if defined(USE_AURA)
34 test_activation_client_.reset(new aura::test::TestActivationClient); 35 test_activation_client_.reset(new aura::test::TestActivationClient);
35 #endif 36 #endif
36 } 37 }
37 38
38 void BrowserWithTestWindowTest::SetUp() { 39 void BrowserWithTestWindowTest::SetUp() {
39 testing::Test::SetUp(); 40 testing::Test::SetUp();
40 41
41 profile_.reset(CreateProfile()); 42 set_profile(CreateProfile());
42 browser_.reset(new Browser(Browser::TYPE_TABBED, profile())); 43 browser_.reset(new Browser(Browser::TYPE_TABBED, profile()));
43 window_.reset(new TestBrowserWindow(browser())); 44 window_.reset(new TestBrowserWindow(browser()));
44 browser_->SetWindowForTesting(window_.get()); 45 browser_->SetWindowForTesting(window_.get());
45 } 46 }
46 47
47 BrowserWithTestWindowTest::~BrowserWithTestWindowTest() { 48 BrowserWithTestWindowTest::~BrowserWithTestWindowTest() {
48 // A Task is leaked if we don't destroy everything, then run the message 49 // A Task is leaked if we don't destroy everything, then run the message
49 // loop. 50 // loop.
50 DestroyBrowser(); 51 DestroyBrowser();
51 profile_.reset(NULL); 52 profile_.reset(NULL);
52 53
53 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 54 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
54 MessageLoop::current()->Run(); 55 MessageLoop::current()->Run();
55 56
56 #if defined(OS_WIN) 57 #if defined(OS_WIN)
57 OleUninitialize(); 58 OleUninitialize();
58 #endif 59 #endif
59 } 60 }
60 61
62 void BrowserWithTestWindowTest::set_profile(TestingProfile* profile) {
63 if (profile_.get() != NULL)
64 ProfileDestroyer::DestroyProfileWhenAppropriate(profile_.release());
65
66 profile_.reset(profile);
67 }
68
61 TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab( 69 TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab(
62 WebContents* web_contents) { 70 WebContents* web_contents) {
63 return static_cast<TestRenderViewHost*>(web_contents->GetRenderViewHost()); 71 return static_cast<TestRenderViewHost*>(web_contents->GetRenderViewHost());
64 } 72 }
65 73
66 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { 74 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) {
67 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED); 75 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED);
68 params.tabstrip_index = 0; 76 params.tabstrip_index = 0;
69 params.disposition = NEW_FOREGROUND_TAB; 77 params.disposition = NEW_FOREGROUND_TAB;
70 browser::Navigate(&params); 78 browser::Navigate(&params);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Make sure we close all tabs, otherwise Browser isn't happy in its 140 // Make sure we close all tabs, otherwise Browser isn't happy in its
133 // destructor. 141 // destructor.
134 browser()->CloseAllTabs(); 142 browser()->CloseAllTabs();
135 browser_.reset(NULL); 143 browser_.reset(NULL);
136 window_.reset(NULL); 144 window_.reset(NULL);
137 } 145 }
138 146
139 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { 147 TestingProfile* BrowserWithTestWindowTest::CreateProfile() {
140 return new TestingProfile(); 148 return new TestingProfile();
141 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698