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

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

Issue 115453004: Moves management of transients out of Window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix MRUWindowTracker and MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest Created 7 years 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
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"
(...skipping 13 matching lines...) Expand all
24 #include "ash/shell.h" 24 #include "ash/shell.h"
25 #include "ash/test/test_session_state_delegate.h" 25 #include "ash/test/test_session_state_delegate.h"
26 #include "ash/test/test_shell_delegate.h" 26 #include "ash/test/test_shell_delegate.h"
27 #endif 27 #endif
28 28
29 #if defined(USE_AURA) 29 #if defined(USE_AURA)
30 #include "ui/aura/client/event_client.h" 30 #include "ui/aura/client/event_client.h"
31 #include "ui/aura/env.h" 31 #include "ui/aura/env.h"
32 #include "ui/aura/root_window.h" 32 #include "ui/aura/root_window.h"
33 #include "ui/aura/test/aura_test_helper.h" 33 #include "ui/aura/test/aura_test_helper.h"
34 #include "ui/views/corewm/transient_window_stacking_client.h"
34 #endif 35 #endif
35 36
36 #if defined(OS_CHROMEOS) 37 #if defined(OS_CHROMEOS)
37 #include "chromeos/audio/cras_audio_handler.h" 38 #include "chromeos/audio/cras_audio_handler.h"
38 #include "chromeos/network/network_handler.h" 39 #include "chromeos/network/network_handler.h"
39 #endif 40 #endif
40 41
41 namespace { 42 namespace {
42 43
43 // View subclass that allows you to specify the preferred size. 44 // View subclass that allows you to specify the preferred size.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 93
93 // If we're in a nested message loop, as is the case with menus, we 94 // If we're in a nested message loop, as is the case with menus, we
94 // need to quit twice. The second quit does that for us. Finish all 95 // need to quit twice. The second quit does that for us. Finish all
95 // pending UI events before posting closure because events it may be 96 // pending UI events before posting closure because events it may be
96 // executed before UI events are executed. 97 // executed before UI events are executed.
97 ui_controls::RunClosureAfterAllPendingUIEvents( 98 ui_controls::RunClosureAfterAllPendingUIEvents(
98 base::MessageLoop::QuitClosure()); 99 base::MessageLoop::QuitClosure());
99 } 100 }
100 101
101 void ViewEventTestBase::SetUp() { 102 void ViewEventTestBase::SetUp() {
103 #if defined(USE_AURA)
104 // SetWindowStackingClient() takes ownership of TransientWindowStackingClient.
105 aura::client::SetWindowStackingClient(
106 new views::corewm::TransientWindowStackingClient);
107 #endif
108
102 views::ViewsDelegate::views_delegate = &views_delegate_; 109 views::ViewsDelegate::views_delegate = &views_delegate_;
103 ui::InitializeInputMethodForTesting(); 110 ui::InitializeInputMethodForTesting();
104 gfx::NativeView context = NULL; 111 gfx::NativeView context = NULL;
105 112
106 #if defined(USE_ASH) 113 #if defined(USE_ASH)
107 // The ContextFactory must exist before any Compositors are created. 114 // The ContextFactory must exist before any Compositors are created.
108 bool allow_test_contexts = true; 115 bool allow_test_contexts = true;
109 ui::InitializeContextFactoryForTests(allow_test_contexts); 116 ui::InitializeContextFactoryForTests(allow_test_contexts);
110 #if defined(OS_WIN) 117 #if defined(OS_WIN)
111 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when 118 // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 message_center::MessageCenter::Shutdown(); 171 message_center::MessageCenter::Shutdown();
165 #endif // !OS_WIN 172 #endif // !OS_WIN
166 aura::Env::DeleteInstance(); 173 aura::Env::DeleteInstance();
167 ui::TerminateContextFactoryForTests(); 174 ui::TerminateContextFactoryForTests();
168 #elif defined(USE_AURA) 175 #elif defined(USE_AURA)
169 aura_test_helper_->TearDown(); 176 aura_test_helper_->TearDown();
170 #endif // !USE_ASH && USE_AURA 177 #endif // !USE_ASH && USE_AURA
171 178
172 ui::ShutdownInputMethodForTesting(); 179 ui::ShutdownInputMethodForTesting();
173 views::ViewsDelegate::views_delegate = NULL; 180 views::ViewsDelegate::views_delegate = NULL;
181
182 #if defined(USE_AURA)
183 aura::client::SetWindowStackingClient(NULL);
184 #endif
174 } 185 }
175 186
176 bool ViewEventTestBase::CanResize() const { 187 bool ViewEventTestBase::CanResize() const {
177 return true; 188 return true;
178 } 189 }
179 190
180 views::View* ViewEventTestBase::GetContentsView() { 191 views::View* ViewEventTestBase::GetContentsView() {
181 if (!content_view_) { 192 if (!content_view_) {
182 // Wrap the real view (as returned by CreateContentsView) in a View so 193 // Wrap the real view (as returned by CreateContentsView) in a View so
183 // that we can customize the preferred size. 194 // that we can customize the preferred size.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 dnd_thread_.reset(NULL); 246 dnd_thread_.reset(NULL);
236 } 247 }
237 248
238 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { 249 void ViewEventTestBase::RunTestMethod(const base::Closure& task) {
239 StopBackgroundThread(); 250 StopBackgroundThread();
240 251
241 task.Run(); 252 task.Run();
242 if (HasFatalFailure()) 253 if (HasFatalFailure())
243 Done(); 254 Done();
244 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698