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

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

Issue 280863002: Reduce creation of ViewsDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add widget includes for undef CreateWindow Created 6 years, 7 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
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.h ('k') | ui/views/test/test_views_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/context_factories_for_test.h" 22 #include "ui/compositor/test/context_factories_for_test.h"
23 #include "ui/wm/core/default_activation_client.h" 23 #include "ui/wm/core/default_activation_client.h"
24 #endif 24 #endif
25 25
26 #if defined(USE_ASH) 26 #if defined(USE_ASH)
27 #include "ash/test/ash_test_helper.h" 27 #include "ash/test/ash_test_helper.h"
28 #include "ash/test/ash_test_views_delegate.h"
28 #endif 29 #endif
29 30
30 #if defined(TOOLKIT_VIEWS) 31 #if defined(TOOLKIT_VIEWS)
31 #include "ui/views/test/test_views_delegate.h" 32 #include "ui/views/test/test_views_delegate.h"
32 #endif 33 #endif
33 34
34 using content::NavigationController; 35 using content::NavigationController;
35 using content::RenderViewHost; 36 using content::RenderViewHost;
36 using content::RenderViewHostTester; 37 using content::RenderViewHostTester;
37 using content::WebContents; 38 using content::WebContents;
(...skipping 14 matching lines...) Expand all
52 } 53 }
53 54
54 BrowserWithTestWindowTest::~BrowserWithTestWindowTest() { 55 BrowserWithTestWindowTest::~BrowserWithTestWindowTest() {
55 } 56 }
56 57
57 void BrowserWithTestWindowTest::SetUp() { 58 void BrowserWithTestWindowTest::SetUp() {
58 testing::Test::SetUp(); 59 testing::Test::SetUp();
59 #if defined(OS_CHROMEOS) 60 #if defined(OS_CHROMEOS)
60 // TODO(jamescook): Windows Ash support. This will require refactoring 61 // TODO(jamescook): Windows Ash support. This will require refactoring
61 // AshTestHelper and AuraTestHelper so they can be used at the same time, 62 // AshTestHelper and AuraTestHelper so they can be used at the same time,
62 // perhaps by AshTestHelper owning an AuraTestHelper. 63 // perhaps by AshTestHelper owning an AuraTestHelper. Also, need to cleanup
64 // CreateViewsDelegate() below when cleanup done.
63 ash_test_helper_.reset(new ash::test::AshTestHelper( 65 ash_test_helper_.reset(new ash::test::AshTestHelper(
64 base::MessageLoopForUI::current())); 66 base::MessageLoopForUI::current()));
65 ash_test_helper_->SetUp(true); 67 ash_test_helper_->SetUp(true);
66 #elif defined(USE_AURA) 68 #elif defined(USE_AURA)
67 // The ContextFactory must exist before any Compositors are created. 69 // The ContextFactory must exist before any Compositors are created.
68 bool enable_pixel_output = false; 70 bool enable_pixel_output = false;
69 ui::InitializeContextFactoryForTests(enable_pixel_output); 71 ui::InitializeContextFactoryForTests(enable_pixel_output);
70 72
71 aura_test_helper_.reset(new aura::test::AuraTestHelper( 73 aura_test_helper_.reset(new aura::test::AuraTestHelper(
72 base::MessageLoopForUI::current())); 74 base::MessageLoopForUI::current()));
73 aura_test_helper_->SetUp(); 75 aura_test_helper_->SetUp();
74 new wm::DefaultActivationClient(aura_test_helper_->root_window()); 76 new wm::DefaultActivationClient(aura_test_helper_->root_window());
75 #endif // USE_AURA 77 #endif // USE_AURA
76 #if defined(TOOLKIT_VIEWS) 78 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS)
77 views_delegate_.reset(CreateViewsDelegate()); 79 views_delegate_.reset(CreateViewsDelegate());
78 views::ViewsDelegate::views_delegate = views_delegate_.get();
79 #endif 80 #endif
80 81
81 // Subclasses can provide their own Profile. 82 // Subclasses can provide their own Profile.
82 profile_ = CreateProfile(); 83 profile_ = CreateProfile();
83 // Subclasses can provide their own test BrowserWindow. If they return NULL 84 // Subclasses can provide their own test BrowserWindow. If they return NULL
84 // then Browser will create the a production BrowserWindow and the subclass 85 // then Browser will create the a production BrowserWindow and the subclass
85 // is responsible for cleaning it up (usually by NativeWidget destruction). 86 // is responsible for cleaning it up (usually by NativeWidget destruction).
86 window_.reset(CreateBrowserWindow()); 87 window_.reset(CreateBrowserWindow());
87 88
88 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_, 89 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_,
(...skipping 17 matching lines...) Expand all
106 #endif 107 #endif
107 testing::Test::TearDown(); 108 testing::Test::TearDown();
108 109
109 // A Task is leaked if we don't destroy everything, then run the message 110 // A Task is leaked if we don't destroy everything, then run the message
110 // loop. 111 // loop.
111 base::MessageLoop::current()->PostTask(FROM_HERE, 112 base::MessageLoop::current()->PostTask(FROM_HERE,
112 base::MessageLoop::QuitClosure()); 113 base::MessageLoop::QuitClosure());
113 base::MessageLoop::current()->Run(); 114 base::MessageLoop::current()->Run();
114 115
115 #if defined(TOOLKIT_VIEWS) 116 #if defined(TOOLKIT_VIEWS)
116 views::ViewsDelegate::views_delegate = NULL;
117 views_delegate_.reset(NULL); 117 views_delegate_.reset(NULL);
118 #endif 118 #endif
119 } 119 }
120 120
121 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { 121 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) {
122 chrome::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED); 122 chrome::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED);
123 params.tabstrip_index = 0; 123 params.tabstrip_index = 0;
124 params.disposition = NEW_FOREGROUND_TAB; 124 params.disposition = NEW_FOREGROUND_TAB;
125 chrome::Navigate(&params); 125 chrome::Navigate(&params);
126 CommitPendingLoad(&params.target_contents->GetController()); 126 CommitPendingLoad(&params.target_contents->GetController());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 gfx::Rect(), 234 gfx::Rect(),
235 profile, 235 profile,
236 host_desktop_type); 236 host_desktop_type);
237 } else { 237 } else {
238 params.type = browser_type; 238 params.type = browser_type;
239 } 239 }
240 params.window = browser_window; 240 params.window = browser_window;
241 return new Browser(params); 241 return new Browser(params);
242 } 242 }
243 243
244 #if defined(TOOLKIT_VIEWS) 244 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS)
245 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() { 245 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() {
246 #if defined(USE_ASH)
247 return new ash::test::AshTestViewsDelegate;
248 #else
246 return new views::TestViewsDelegate; 249 return new views::TestViewsDelegate;
250 #endif
247 } 251 }
248 #endif 252 #endif
OLDNEW
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.h ('k') | ui/views/test/test_views_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698