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/browser_with_test_window_test.h" | 5 #include "chrome/test/base/browser_with_test_window_test.h" |
6 | 6 |
7 #if defined(OS_WIN) | |
8 #include <ole2.h> | |
9 #endif // defined(OS_WIN) | |
10 | |
11 #include "chrome/browser/tabs/tab_strip_model.h" | 7 #include "chrome/browser/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/browser_navigator.h" | 8 #include "chrome/browser/ui/browser_navigator.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
14 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
15 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
16 #include "content/public/browser/navigation_controller.h" | 12 #include "content/public/browser/navigation_controller.h" |
17 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
18 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
19 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
20 | 16 |
21 #if defined(USE_AURA) | 17 #if defined(USE_AURA) |
22 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
23 #include "ui/aura/test/test_activation_client.h" | 19 #include "ui/aura/test/test_activation_client.h" |
24 #include "ui/aura/test/test_stacking_client.h" | 20 #include "ui/aura/test/test_stacking_client.h" |
25 #endif | 21 #endif |
26 | 22 |
27 using content::BrowserThread; | 23 using content::BrowserThread; |
28 using content::NavigationController; | 24 using content::NavigationController; |
29 using content::TestRenderViewHost; | 25 using content::TestRenderViewHost; |
30 using content::WebContents; | 26 using content::WebContents; |
31 | 27 |
32 BrowserWithTestWindowTest::BrowserWithTestWindowTest() | 28 BrowserWithTestWindowTest::BrowserWithTestWindowTest() |
33 : ui_thread_(BrowserThread::UI, message_loop()), | 29 : ui_thread_(BrowserThread::UI, message_loop()), |
34 file_thread_(BrowserThread::FILE, message_loop()), | 30 file_thread_(BrowserThread::FILE, message_loop()), |
35 file_user_blocking_thread_( | 31 file_user_blocking_thread_( |
36 BrowserThread::FILE_USER_BLOCKING, message_loop()), | 32 BrowserThread::FILE_USER_BLOCKING, message_loop()), |
37 rph_factory_(), | 33 rph_factory_(), |
38 rvh_factory_(&rph_factory_) { | 34 rvh_factory_(&rph_factory_) { |
39 #if defined(OS_WIN) | |
40 OleInitialize(NULL); | |
41 #endif | |
42 } | 35 } |
43 | 36 |
44 void BrowserWithTestWindowTest::SetUp() { | 37 void BrowserWithTestWindowTest::SetUp() { |
45 testing::Test::SetUp(); | 38 testing::Test::SetUp(); |
46 | 39 |
47 profile_.reset(CreateProfile()); | 40 profile_.reset(CreateProfile()); |
48 browser_.reset(new Browser(Browser::TYPE_TABBED, profile())); | 41 browser_.reset(new Browser(Browser::TYPE_TABBED, profile())); |
49 window_.reset(new TestBrowserWindow(browser())); | 42 window_.reset(new TestBrowserWindow(browser())); |
50 browser_->SetWindowForTesting(window_.get()); | 43 browser_->SetWindowForTesting(window_.get()); |
51 #if defined(USE_AURA) | 44 #if defined(USE_AURA) |
(...skipping 15 matching lines...) Expand all Loading... |
67 } | 60 } |
68 | 61 |
69 BrowserWithTestWindowTest::~BrowserWithTestWindowTest() { | 62 BrowserWithTestWindowTest::~BrowserWithTestWindowTest() { |
70 // A Task is leaked if we don't destroy everything, then run the message | 63 // A Task is leaked if we don't destroy everything, then run the message |
71 // loop. | 64 // loop. |
72 DestroyBrowser(); | 65 DestroyBrowser(); |
73 profile_.reset(NULL); | 66 profile_.reset(NULL); |
74 | 67 |
75 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 68 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
76 MessageLoop::current()->Run(); | 69 MessageLoop::current()->Run(); |
77 | |
78 #if defined(OS_WIN) | |
79 OleUninitialize(); | |
80 #endif | |
81 } | 70 } |
82 | 71 |
83 TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab( | 72 TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab( |
84 WebContents* web_contents) { | 73 WebContents* web_contents) { |
85 return static_cast<TestRenderViewHost*>(web_contents->GetRenderViewHost()); | 74 return static_cast<TestRenderViewHost*>(web_contents->GetRenderViewHost()); |
86 } | 75 } |
87 | 76 |
88 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { | 77 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { |
89 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED); | 78 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED); |
90 params.tabstrip_index = 0; | 79 params.tabstrip_index = 0; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Make sure we close all tabs, otherwise Browser isn't happy in its | 143 // Make sure we close all tabs, otherwise Browser isn't happy in its |
155 // destructor. | 144 // destructor. |
156 browser()->CloseAllTabs(); | 145 browser()->CloseAllTabs(); |
157 browser_.reset(NULL); | 146 browser_.reset(NULL); |
158 window_.reset(NULL); | 147 window_.reset(NULL); |
159 } | 148 } |
160 | 149 |
161 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { | 150 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { |
162 return new TestingProfile(); | 151 return new TestingProfile(); |
163 } | 152 } |
OLD | NEW |