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

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

Issue 21052007: aura: Clean up compositor initialization/destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanupcompositor: UseRealGLBindings for CompositingRWHVBrowserTests on win_rel Created 7 years, 4 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/test_launcher_utils.cc ('k') | chrome/test/gpu/gpu_feature_browsertest.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/view_event_test_base.h" 5 #include "chrome/test/base/view_event_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "chrome/test/base/interactive_test_utils.h" 11 #include "chrome/test/base/interactive_test_utils.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "ui/base/ime/input_method_initializer.h" 14 #include "ui/base/ime/input_method_initializer.h"
15 #include "ui/base/test/ui_controls.h" 15 #include "ui/base/test/ui_controls.h"
16 #include "ui/message_center/message_center.h" 16 #include "ui/message_center/message_center.h"
17 #include "ui/views/view.h" 17 #include "ui/views/view.h"
18 #include "ui/views/widget/desktop_aura/desktop_screen.h" 18 #include "ui/views/widget/desktop_aura/desktop_screen.h"
19 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
20 20
21 #if defined(USE_ASH) 21 #if defined(USE_ASH)
22 #include "ash/shell.h" 22 #include "ash/shell.h"
23 #include "ash/test/test_session_state_delegate.h" 23 #include "ash/test/test_session_state_delegate.h"
24 #include "ash/test/test_shell_delegate.h" 24 #include "ash/test/test_shell_delegate.h"
25 #if defined(OS_WIN)
26 #include "ui/compositor/compositor.h"
27 #endif
25 #endif 28 #endif
26 29
27 #if defined(USE_AURA) 30 #if defined(USE_AURA)
28 #include "ui/aura/client/event_client.h" 31 #include "ui/aura/client/event_client.h"
29 #include "ui/aura/env.h" 32 #include "ui/aura/env.h"
30 #include "ui/aura/root_window.h" 33 #include "ui/aura/root_window.h"
31 #include "ui/aura/test/aura_test_helper.h" 34 #include "ui/aura/test/aura_test_helper.h"
32 #endif 35 #endif
33 36
34 #if defined(OS_CHROMEOS) 37 #if defined(OS_CHROMEOS)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 97
95 void ViewEventTestBase::SetUp() { 98 void ViewEventTestBase::SetUp() {
96 ui::InitializeInputMethodForTesting(); 99 ui::InitializeInputMethodForTesting();
97 gfx::NativeView context = NULL; 100 gfx::NativeView context = NULL;
98 #if defined(USE_ASH) 101 #if defined(USE_ASH)
99 #if defined(OS_WIN) 102 #if defined(OS_WIN)
100 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when 103 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when
101 // interactive_ui_tests is brought up on that platform. 104 // interactive_ui_tests is brought up on that platform.
102 gfx::Screen::SetScreenInstance( 105 gfx::Screen::SetScreenInstance(
103 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); 106 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
104 #else 107
108 // The ContextFactory must exist before any Compositors are created. The
109 // ash::Shell code path below handles this, but since we skip it we must
110 // do this here.
111 bool allow_test_contexts = true;
112 ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts);
113 #else // !OS_WIN
105 // Ash Shell can't just live on its own without a browser process, we need to 114 // Ash Shell can't just live on its own without a browser process, we need to
106 // also create the message center. 115 // also create the message center.
107 message_center::MessageCenter::Initialize(); 116 message_center::MessageCenter::Initialize();
108 #if defined(OS_CHROMEOS) 117 #if defined(OS_CHROMEOS)
109 chromeos::CrasAudioHandler::InitializeForTesting(); 118 chromeos::CrasAudioHandler::InitializeForTesting();
110 #endif 119 #endif // OS_CHROMEOS
111 ash::test::TestShellDelegate* shell_delegate = 120 ash::test::TestShellDelegate* shell_delegate =
112 new ash::test::TestShellDelegate(); 121 new ash::test::TestShellDelegate();
113 ash::Shell::CreateInstance(shell_delegate); 122 ash::Shell::CreateInstance(shell_delegate);
114 shell_delegate->test_session_state_delegate() 123 shell_delegate->test_session_state_delegate()
115 ->SetActiveUserSessionStarted(true); 124 ->SetActiveUserSessionStarted(true);
116 context = ash::Shell::GetPrimaryRootWindow(); 125 context = ash::Shell::GetPrimaryRootWindow();
117 #endif 126 #endif // !OS_WIN
118 #elif defined(USE_AURA) 127 #elif defined(USE_AURA)
119 // Instead of using the ash shell, use an AuraTestHelper to create and manage 128 // Instead of using the ash shell, use an AuraTestHelper to create and manage
120 // the test screen. 129 // the test screen.
121 aura_test_helper_.reset( 130 aura_test_helper_.reset(
122 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); 131 new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
123 aura_test_helper_->SetUp(); 132 aura_test_helper_->SetUp();
124 context = aura_test_helper_->root_window(); 133 context = aura_test_helper_->root_window();
125 #endif 134 #endif // USE_AURA
126 window_ = views::Widget::CreateWindowWithContext(this, context); 135 window_ = views::Widget::CreateWindowWithContext(this, context);
127 } 136 }
128 137
129 void ViewEventTestBase::TearDown() { 138 void ViewEventTestBase::TearDown() {
130 if (window_) { 139 if (window_) {
131 #if defined(OS_WIN) && !defined(USE_AURA) 140 #if defined(OS_WIN) && !defined(USE_AURA)
132 DestroyWindow(window_->GetNativeWindow()); 141 DestroyWindow(window_->GetNativeWindow());
133 #else 142 #else
134 window_->Close(); 143 window_->Close();
135 content::RunAllPendingInMessageLoop(); 144 content::RunAllPendingInMessageLoop();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 dnd_thread_.reset(NULL); 224 dnd_thread_.reset(NULL);
216 } 225 }
217 226
218 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { 227 void ViewEventTestBase::RunTestMethod(const base::Closure& task) {
219 StopBackgroundThread(); 228 StopBackgroundThread();
220 229
221 task.Run(); 230 task.Run();
222 if (HasFatalFailure()) 231 if (HasFatalFailure())
223 Done(); 232 Done();
224 } 233 }
OLDNEW
« no previous file with comments | « chrome/test/base/test_launcher_utils.cc ('k') | chrome/test/gpu/gpu_feature_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698