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

Side by Side Diff: ui/aura/test/aura_test_helper.cc

Issue 2660813002: Add WidgetTest::GetAllWidgets() to find dialogs created by TestBrowserDialog. (Closed)
Patch Set: respond to comments Created 3 years, 10 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
« no previous file with comments | « ui/aura/test/aura_test_helper.h ('k') | ui/views/BUILD.gn » ('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 "ui/aura/test/aura_test_helper.h" 5 #include "ui/aura/test/aura_test_helper.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "ui/aura/client/default_capture_client.h" 10 #include "ui/aura/client/default_capture_client.h"
(...skipping 20 matching lines...) Expand all
31 #include "ui/display/screen.h" 31 #include "ui/display/screen.h"
32 #include "ui/wm/core/wm_state.h" 32 #include "ui/wm/core/wm_state.h"
33 33
34 #if defined(USE_X11) 34 #if defined(USE_X11)
35 #include "ui/aura/window_tree_host_x11.h" 35 #include "ui/aura/window_tree_host_x11.h"
36 #include "ui/base/x/x11_util.h" // nogncheck 36 #include "ui/base/x/x11_util.h" // nogncheck
37 #endif 37 #endif
38 38
39 namespace aura { 39 namespace aura {
40 namespace test { 40 namespace test {
41 namespace {
42
43 AuraTestHelper* g_instance = nullptr;
44
45 } // namespace
41 46
42 AuraTestHelper::AuraTestHelper(base::MessageLoopForUI* message_loop) 47 AuraTestHelper::AuraTestHelper(base::MessageLoopForUI* message_loop)
43 : setup_called_(false), teardown_called_(false) { 48 : setup_called_(false), teardown_called_(false) {
44 DCHECK(message_loop); 49 DCHECK(message_loop);
45 // Disable animations during tests. 50 // Disable animations during tests.
46 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( 51 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
47 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); 52 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
48 #if defined(USE_X11) 53 #if defined(USE_X11)
49 test::SetUseOverrideRedirectWindowByDefault(true); 54 test::SetUseOverrideRedirectWindowByDefault(true);
50 #endif 55 #endif
51 InitializeAuraEventGeneratorDelegate(); 56 InitializeAuraEventGeneratorDelegate();
52 } 57 }
53 58
54 AuraTestHelper::~AuraTestHelper() { 59 AuraTestHelper::~AuraTestHelper() {
55 CHECK(setup_called_) 60 CHECK(setup_called_)
56 << "AuraTestHelper::SetUp() never called."; 61 << "AuraTestHelper::SetUp() never called.";
57 CHECK(teardown_called_) 62 CHECK(teardown_called_)
58 << "AuraTestHelper::TearDown() never called."; 63 << "AuraTestHelper::TearDown() never called.";
59 } 64 }
60 65
66 // static
67 AuraTestHelper* AuraTestHelper::GetInstance() {
68 return g_instance;
69 }
70
61 void AuraTestHelper::EnableMusWithTestWindowTree( 71 void AuraTestHelper::EnableMusWithTestWindowTree(
62 WindowTreeClientDelegate* window_tree_delegate, 72 WindowTreeClientDelegate* window_tree_delegate,
63 WindowManagerDelegate* window_manager_delegate) { 73 WindowManagerDelegate* window_manager_delegate) {
64 DCHECK(!setup_called_); 74 DCHECK(!setup_called_);
65 DCHECK_EQ(Mode::LOCAL, mode_); 75 DCHECK_EQ(Mode::LOCAL, mode_);
66 mode_ = Mode::MUS_CREATE_WINDOW_TREE_CLIENT; 76 mode_ = Mode::MUS_CREATE_WINDOW_TREE_CLIENT;
67 window_tree_delegate_ = window_tree_delegate; 77 window_tree_delegate_ = window_tree_delegate;
68 window_manager_delegate_ = window_manager_delegate; 78 window_manager_delegate_ = window_manager_delegate;
69 } 79 }
70 80
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 client::SetFocusClient(root_window(), focus_client_.get()); 131 client::SetFocusClient(root_window(), focus_client_.get());
122 client::SetCaptureClient(root_window(), capture_client()); 132 client::SetCaptureClient(root_window(), capture_client());
123 parenting_client_.reset(new TestWindowParentingClient(root_window())); 133 parenting_client_.reset(new TestWindowParentingClient(root_window()));
124 134
125 root_window()->Show(); 135 root_window()->Show();
126 // Ensure width != height so tests won't confuse them. 136 // Ensure width != height so tests won't confuse them.
127 host()->SetBoundsInPixels(gfx::Rect(host_size)); 137 host()->SetBoundsInPixels(gfx::Rect(host_size));
128 138
129 if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT) 139 if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT)
130 window_tree()->AckAllChanges(); 140 window_tree()->AckAllChanges();
141
142 g_instance = this;
131 } 143 }
132 144
133 void AuraTestHelper::TearDown() { 145 void AuraTestHelper::TearDown() {
146 g_instance = nullptr;
134 teardown_called_ = true; 147 teardown_called_ = true;
135 parenting_client_.reset(); 148 parenting_client_.reset();
136 client::SetFocusClient(root_window(), nullptr); 149 client::SetFocusClient(root_window(), nullptr);
137 client::SetCaptureClient(root_window(), nullptr); 150 client::SetCaptureClient(root_window(), nullptr);
138 host_.reset(); 151 host_.reset();
139 ui::GestureRecognizer::Reset(); 152 ui::GestureRecognizer::Reset();
140 if (display::Screen::GetScreen() == test_screen_.get()) 153 if (display::Screen::GetScreen() == test_screen_.get())
141 display::Screen::SetScreenInstance(nullptr); 154 display::Screen::SetScreenInstance(nullptr);
142 test_screen_.reset(); 155 test_screen_.reset();
143 156
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 189
177 void AuraTestHelper::InitWindowTreeClient() { 190 void AuraTestHelper::InitWindowTreeClient() {
178 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>(); 191 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>();
179 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_, 192 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_,
180 window_manager_delegate_); 193 window_manager_delegate_);
181 window_tree_client_ = window_tree_client_setup_->window_tree_client(); 194 window_tree_client_ = window_tree_client_setup_->window_tree_client();
182 } 195 }
183 196
184 } // namespace test 197 } // namespace test
185 } // namespace aura 198 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/aura_test_helper.h ('k') | ui/views/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698