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 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/profiles/profile_destroyer.h" | 8 #include "chrome/browser/profiles/profile_destroyer.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "ui/compositor/test/context_factories_for_test.h" | 23 #include "ui/compositor/test/context_factories_for_test.h" |
24 #include "ui/wm/core/default_activation_client.h" | 24 #include "ui/wm/core/default_activation_client.h" |
25 #endif | 25 #endif |
26 | 26 |
27 #if defined(USE_ASH) | 27 #if defined(USE_ASH) |
28 #include "ash/test/ash_test_helper.h" | 28 #include "ash/test/ash_test_helper.h" |
29 #include "ash/test/ash_test_views_delegate.h" | 29 #include "ash/test/ash_test_views_delegate.h" |
30 #endif | 30 #endif |
31 | 31 |
32 #if defined(TOOLKIT_VIEWS) | 32 #if defined(TOOLKIT_VIEWS) |
33 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" | |
34 #include "components/constrained_window/constrained_window_views.h" | |
33 #include "ui/views/test/test_views_delegate.h" | 35 #include "ui/views/test/test_views_delegate.h" |
34 #endif | 36 #endif |
35 | 37 |
36 using content::NavigationController; | 38 using content::NavigationController; |
37 using content::RenderFrameHost; | 39 using content::RenderFrameHost; |
38 using content::RenderFrameHostTester; | 40 using content::RenderFrameHostTester; |
39 using content::WebContents; | 41 using content::WebContents; |
40 | 42 |
41 BrowserWithTestWindowTest::BrowserWithTestWindowTest() | 43 BrowserWithTestWindowTest::BrowserWithTestWindowTest() |
42 : browser_type_(Browser::TYPE_TABBED), | 44 : browser_type_(Browser::TYPE_TABBED), |
(...skipping 27 matching lines...) Expand all Loading... | |
70 // The ContextFactory must exist before any Compositors are created. | 72 // The ContextFactory must exist before any Compositors are created. |
71 bool enable_pixel_output = false; | 73 bool enable_pixel_output = false; |
72 ui::ContextFactory* context_factory = | 74 ui::ContextFactory* context_factory = |
73 ui::InitializeContextFactoryForTests(enable_pixel_output); | 75 ui::InitializeContextFactoryForTests(enable_pixel_output); |
74 | 76 |
75 aura_test_helper_.reset(new aura::test::AuraTestHelper( | 77 aura_test_helper_.reset(new aura::test::AuraTestHelper( |
76 base::MessageLoopForUI::current())); | 78 base::MessageLoopForUI::current())); |
77 aura_test_helper_->SetUp(context_factory); | 79 aura_test_helper_->SetUp(context_factory); |
78 new wm::DefaultActivationClient(aura_test_helper_->root_window()); | 80 new wm::DefaultActivationClient(aura_test_helper_->root_window()); |
79 #endif // USE_AURA | 81 #endif // USE_AURA |
80 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS) | 82 |
83 #if defined(TOOLKIT_VIEWS) | |
84 #if !defined(OS_CHROMEOS) | |
81 views_delegate_.reset(CreateViewsDelegate()); | 85 views_delegate_.reset(CreateViewsDelegate()); |
82 #endif | 86 #endif // !OS_CHROMEOS |
87 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); | |
88 #endif // TOOLKIT_VIEWS | |
83 | 89 |
84 // Subclasses can provide their own Profile. | 90 // Subclasses can provide their own Profile. |
85 profile_ = CreateProfile(); | 91 profile_ = CreateProfile(); |
86 // Subclasses can provide their own test BrowserWindow. If they return NULL | 92 // Subclasses can provide their own test BrowserWindow. If they return NULL |
87 // then Browser will create the a production BrowserWindow and the subclass | 93 // then Browser will create the a production BrowserWindow and the subclass |
88 // is responsible for cleaning it up (usually by NativeWidget destruction). | 94 // is responsible for cleaning it up (usually by NativeWidget destruction). |
89 window_.reset(CreateBrowserWindow()); | 95 window_.reset(CreateBrowserWindow()); |
90 | 96 |
91 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_, | 97 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_, |
92 host_desktop_type_, window_.get())); | 98 host_desktop_type_, window_.get())); |
(...skipping 16 matching lines...) Expand all Loading... | |
109 #endif | 115 #endif |
110 testing::Test::TearDown(); | 116 testing::Test::TearDown(); |
111 | 117 |
112 // A Task is leaked if we don't destroy everything, then run the message | 118 // A Task is leaked if we don't destroy everything, then run the message |
113 // loop. | 119 // loop. |
114 base::MessageLoop::current()->PostTask(FROM_HERE, | 120 base::MessageLoop::current()->PostTask(FROM_HERE, |
115 base::MessageLoop::QuitClosure()); | 121 base::MessageLoop::QuitClosure()); |
116 base::MessageLoop::current()->Run(); | 122 base::MessageLoop::current()->Run(); |
117 | 123 |
118 #if defined(TOOLKIT_VIEWS) | 124 #if defined(TOOLKIT_VIEWS) |
125 SetConstrainedWindowViewsClient(scoped_ptr<ConstrainedWindowViewsClient>()); | |
sky
2014/10/24 18:04:22
I think there was a conversion from nullptr->scope
oshima
2014/10/24 20:36:47
Hmm, it didn't work.
../../chrome/test/base/brows
blundell
2014/10/27 06:54:44
I think the idea is that you now can do SetConstra
| |
119 views_delegate_.reset(NULL); | 126 views_delegate_.reset(NULL); |
120 #endif | 127 #endif |
121 } | 128 } |
122 | 129 |
123 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { | 130 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { |
124 chrome::NavigateParams params(browser, url, ui::PAGE_TRANSITION_TYPED); | 131 chrome::NavigateParams params(browser, url, ui::PAGE_TRANSITION_TYPED); |
125 params.tabstrip_index = 0; | 132 params.tabstrip_index = 0; |
126 params.disposition = NEW_FOREGROUND_TAB; | 133 params.disposition = NEW_FOREGROUND_TAB; |
127 chrome::Navigate(¶ms); | 134 chrome::Navigate(¶ms); |
128 CommitPendingLoad(¶ms.target_contents->GetController()); | 135 CommitPendingLoad(¶ms.target_contents->GetController()); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 251 |
245 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS) | 252 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS) |
246 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() { | 253 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() { |
247 #if defined(USE_ASH) | 254 #if defined(USE_ASH) |
248 return new ash::test::AshTestViewsDelegate; | 255 return new ash::test::AshTestViewsDelegate; |
249 #else | 256 #else |
250 return new views::TestViewsDelegate; | 257 return new views::TestViewsDelegate; |
251 #endif | 258 #endif |
252 } | 259 } |
253 #endif | 260 #endif |
OLD | NEW |