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" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
14 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/common/page_transition_types.h" | 17 #include "content/public/common/page_transition_types.h" |
18 #include "content/public/test/test_renderer_host.h" | 18 #include "content/public/test/test_renderer_host.h" |
19 | 19 |
20 #if defined(USE_AURA) | 20 #if defined(USE_AURA) |
21 #include "ui/aura/test/aura_test_helper.h" | 21 #include "ui/aura/test/aura_test_helper.h" |
| 22 #include "ui/compositor/compositor.h" |
22 #include "ui/compositor/test/context_factories_for_test.h" | 23 #include "ui/compositor/test/context_factories_for_test.h" |
23 #include "ui/wm/core/default_activation_client.h" | 24 #include "ui/wm/core/default_activation_client.h" |
24 #endif | 25 #endif |
25 | 26 |
26 #if defined(USE_ASH) | 27 #if defined(USE_ASH) |
27 #include "ash/test/ash_test_helper.h" | 28 #include "ash/test/ash_test_helper.h" |
28 #include "ash/test/ash_test_views_delegate.h" | 29 #include "ash/test/ash_test_views_delegate.h" |
29 #endif | 30 #endif |
30 | 31 |
31 #if defined(TOOLKIT_VIEWS) | 32 #if defined(TOOLKIT_VIEWS) |
(...skipping 29 matching lines...) Expand all Loading... |
61 // TODO(jamescook): Windows Ash support. This will require refactoring | 62 // TODO(jamescook): Windows Ash support. This will require refactoring |
62 // AshTestHelper and AuraTestHelper so they can be used at the same time, | 63 // AshTestHelper and AuraTestHelper so they can be used at the same time, |
63 // perhaps by AshTestHelper owning an AuraTestHelper. Also, need to cleanup | 64 // perhaps by AshTestHelper owning an AuraTestHelper. Also, need to cleanup |
64 // CreateViewsDelegate() below when cleanup done. | 65 // CreateViewsDelegate() below when cleanup done. |
65 ash_test_helper_.reset(new ash::test::AshTestHelper( | 66 ash_test_helper_.reset(new ash::test::AshTestHelper( |
66 base::MessageLoopForUI::current())); | 67 base::MessageLoopForUI::current())); |
67 ash_test_helper_->SetUp(true); | 68 ash_test_helper_->SetUp(true); |
68 #elif defined(USE_AURA) | 69 #elif defined(USE_AURA) |
69 // The ContextFactory must exist before any Compositors are created. | 70 // The ContextFactory must exist before any Compositors are created. |
70 bool enable_pixel_output = false; | 71 bool enable_pixel_output = false; |
71 ui::InitializeContextFactoryForTests(enable_pixel_output); | 72 ui::ContextFactory* context_factory = |
| 73 ui::InitializeContextFactoryForTests(enable_pixel_output); |
72 | 74 |
73 aura_test_helper_.reset(new aura::test::AuraTestHelper( | 75 aura_test_helper_.reset(new aura::test::AuraTestHelper( |
74 base::MessageLoopForUI::current())); | 76 base::MessageLoopForUI::current())); |
75 aura_test_helper_->SetUp(); | 77 aura_test_helper_->SetUp(context_factory); |
76 new wm::DefaultActivationClient(aura_test_helper_->root_window()); | 78 new wm::DefaultActivationClient(aura_test_helper_->root_window()); |
77 #endif // USE_AURA | 79 #endif // USE_AURA |
78 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS) | 80 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS) |
79 views_delegate_.reset(CreateViewsDelegate()); | 81 views_delegate_.reset(CreateViewsDelegate(context_factory)); |
80 #endif | 82 #endif |
81 | 83 |
82 // Subclasses can provide their own Profile. | 84 // Subclasses can provide their own Profile. |
83 profile_ = CreateProfile(); | 85 profile_ = CreateProfile(); |
84 // Subclasses can provide their own test BrowserWindow. If they return NULL | 86 // Subclasses can provide their own test BrowserWindow. If they return NULL |
85 // then Browser will create the a production BrowserWindow and the subclass | 87 // then Browser will create the a production BrowserWindow and the subclass |
86 // is responsible for cleaning it up (usually by NativeWidget destruction). | 88 // is responsible for cleaning it up (usually by NativeWidget destruction). |
87 window_.reset(CreateBrowserWindow()); | 89 window_.reset(CreateBrowserWindow()); |
88 | 90 |
89 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_, | 91 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 profile, | 237 profile, |
236 host_desktop_type); | 238 host_desktop_type); |
237 } else { | 239 } else { |
238 params.type = browser_type; | 240 params.type = browser_type; |
239 } | 241 } |
240 params.window = browser_window; | 242 params.window = browser_window; |
241 return new Browser(params); | 243 return new Browser(params); |
242 } | 244 } |
243 | 245 |
244 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS) | 246 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS) |
245 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() { | 247 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate( |
| 248 ui::ContextFactory* context_factory) { |
246 #if defined(USE_ASH) | 249 #if defined(USE_ASH) |
247 return new ash::test::AshTestViewsDelegate; | 250 views::TestViewsDelegate* delegate = new ash::test::AshTestViewsDelegate; |
248 #else | 251 #else |
249 return new views::TestViewsDelegate; | 252 views::TestViewsDelegate* delegate = new views::TestViewsDelegate; |
250 #endif | 253 #endif |
| 254 delegate->set_context_factory(context_factory); |
| 255 return delegate; |
251 } | 256 } |
252 #endif | 257 #endif |
OLD | NEW |