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

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

Issue 2445163002: Make aura work with mus (Closed)
Patch Set: NON_EXPORTED_BASE_CLASS Created 4 years, 1 month 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_base.h ('k') | ui/aura/test/aura_test_helper.h » ('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_base.h" 5 #include "ui/aura/test/aura_test_base.h"
6 6
7 #include "ui/aura/client/window_parenting_client.h" 7 #include "ui/aura/client/window_parenting_client.h"
8 #include "ui/aura/test/aura_test_helper.h" 8 #include "ui/aura/mus/property_converter.h"
9 #include "ui/aura/mus/window_tree_client.h"
9 #include "ui/aura/test/test_window_delegate.h" 10 #include "ui/aura/test/test_window_delegate.h"
10 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
11 #include "ui/base/ime/input_method_initializer.h" 12 #include "ui/base/ime/input_method_initializer.h"
12 #include "ui/base/material_design/material_design_controller.h" 13 #include "ui/base/material_design/material_design_controller.h"
13 #include "ui/base/test/material_design_controller_test_api.h" 14 #include "ui/base/test/material_design_controller_test_api.h"
14 #include "ui/compositor/test/context_factories_for_test.h" 15 #include "ui/compositor/test/context_factories_for_test.h"
15 #include "ui/events/event_dispatcher.h" 16 #include "ui/events/event_dispatcher.h"
16 #include "ui/events/event_processor.h" 17 #include "ui/events/event_processor.h"
17 #include "ui/events/gesture_detection/gesture_configuration.h" 18 #include "ui/events/gesture_detection/gesture_configuration.h"
18 19
19 namespace aura { 20 namespace aura {
20 namespace test { 21 namespace test {
22 namespace {
23
24 class TestPropertyConverter : public PropertyConverter {
25 public:
26 TestPropertyConverter() {}
27 ~TestPropertyConverter() override {}
28
29 // PropertyConverter:
30 bool ConvertPropertyForTransport(
31 Window* window,
32 const void* key,
33 std::string* server_property_name,
34 std::unique_ptr<std::vector<uint8_t>>* server_property_value) override {
35 return false;
36 }
37
38 std::string GetTransportNameForPropertyKey(const void* key) override {
39 return std::string();
40 }
41
42 void SetPropertyFromTransportValue(
43 Window* window,
44 const std::string& server_property_name,
45 const std::vector<uint8_t>* data) override {}
46
47 private:
48 DISALLOW_COPY_AND_ASSIGN(TestPropertyConverter);
49 };
50
51 } // namespace
21 52
22 AuraTestBase::AuraTestBase() 53 AuraTestBase::AuraTestBase()
23 : setup_called_(false), 54 : window_manager_delegate_(this), window_tree_client_delegate_(this) {}
24 teardown_called_(false) {
25 }
26 55
27 AuraTestBase::~AuraTestBase() { 56 AuraTestBase::~AuraTestBase() {
28 CHECK(setup_called_) 57 CHECK(setup_called_)
29 << "You have overridden SetUp but never called super class's SetUp"; 58 << "You have overridden SetUp but never called super class's SetUp";
30 CHECK(teardown_called_) 59 CHECK(teardown_called_)
31 << "You have overridden TearDown but never called super class's TearDown"; 60 << "You have overridden TearDown but never called super class's TearDown";
32 } 61 }
33 62
34 void AuraTestBase::SetUp() { 63 void AuraTestBase::SetUp() {
35 setup_called_ = true; 64 setup_called_ = true;
36 testing::Test::SetUp(); 65 testing::Test::SetUp();
66 if (!property_converter_)
67 property_converter_ = base::MakeUnique<TestPropertyConverter>();
37 // ContentTestSuiteBase might have already initialized 68 // ContentTestSuiteBase might have already initialized
38 // MaterialDesignController in unit_tests suite. 69 // MaterialDesignController in unit_tests suite.
39 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); 70 ui::test::MaterialDesignControllerTestAPI::Uninitialize();
40 ui::MaterialDesignController::Initialize(); 71 ui::MaterialDesignController::Initialize();
41 ui::InitializeInputMethodForTesting(); 72 ui::InitializeInputMethodForTesting();
42 ui::GestureConfiguration* gesture_config = 73 ui::GestureConfiguration* gesture_config =
43 ui::GestureConfiguration::GetInstance(); 74 ui::GestureConfiguration::GetInstance();
44 // Changing the parameters for gesture recognition shouldn't cause 75 // Changing the parameters for gesture recognition shouldn't cause
45 // tests to fail, so we use a separate set of parameters for unit 76 // tests to fail, so we use a separate set of parameters for unit
46 // testing. 77 // testing.
(...skipping 24 matching lines...) Expand all
71 gesture_config->set_two_finger_tap_enabled(true); 102 gesture_config->set_two_finger_tap_enabled(true);
72 gesture_config->set_velocity_tracker_strategy( 103 gesture_config->set_velocity_tracker_strategy(
73 ui::VelocityTracker::Strategy::LSQ2_RESTRICTED); 104 ui::VelocityTracker::Strategy::LSQ2_RESTRICTED);
74 105
75 // The ContextFactory must exist before any Compositors are created. 106 // The ContextFactory must exist before any Compositors are created.
76 bool enable_pixel_output = false; 107 bool enable_pixel_output = false;
77 ui::ContextFactory* context_factory = 108 ui::ContextFactory* context_factory =
78 ui::InitializeContextFactoryForTests(enable_pixel_output); 109 ui::InitializeContextFactoryForTests(enable_pixel_output);
79 110
80 helper_.reset(new AuraTestHelper(&message_loop_)); 111 helper_.reset(new AuraTestHelper(&message_loop_));
112 if (use_mus_)
113 helper_->EnableMus(window_tree_client_delegate_, window_manager_delegate_);
81 helper_->SetUp(context_factory); 114 helper_->SetUp(context_factory);
82 } 115 }
83 116
84 void AuraTestBase::TearDown() { 117 void AuraTestBase::TearDown() {
85 teardown_called_ = true; 118 teardown_called_ = true;
86 119
87 // Flush the message loop because we have pending release tasks 120 // Flush the message loop because we have pending release tasks
88 // and these tasks if un-executed would upset Valgrind. 121 // and these tasks if un-executed would upset Valgrind.
89 RunAllPendingInMessageLoop(); 122 RunAllPendingInMessageLoop();
90 123
91 helper_->TearDown(); 124 helper_->TearDown();
92 ui::TerminateContextFactoryForTests(); 125 ui::TerminateContextFactoryForTests();
93 ui::ShutdownInputMethodForTesting(); 126 ui::ShutdownInputMethodForTesting();
94 testing::Test::TearDown(); 127 testing::Test::TearDown();
95 } 128 }
96 129
97 Window* AuraTestBase::CreateNormalWindow(int id, Window* parent, 130 Window* AuraTestBase::CreateNormalWindow(int id, Window* parent,
98 WindowDelegate* delegate) { 131 WindowDelegate* delegate) {
99 Window* window = new Window( 132 Window* window = new Window(
100 delegate ? delegate : 133 delegate ? delegate :
101 test::TestWindowDelegate::CreateSelfDestroyingDelegate()); 134 test::TestWindowDelegate::CreateSelfDestroyingDelegate());
102 window->set_id(id); 135 window->set_id(id);
103 window->Init(ui::LAYER_TEXTURED); 136 window->Init(ui::LAYER_TEXTURED);
104 parent->AddChild(window); 137 parent->AddChild(window);
105 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 138 window->SetBounds(gfx::Rect(0, 0, 100, 100));
106 window->Show(); 139 window->Show();
107 return window; 140 return window;
108 } 141 }
109 142
143 void AuraTestBase::EnableMus() {
144 DCHECK(!setup_called_);
145 use_mus_ = true;
146 }
147
110 void AuraTestBase::RunAllPendingInMessageLoop() { 148 void AuraTestBase::RunAllPendingInMessageLoop() {
111 helper_->RunAllPendingInMessageLoop(); 149 helper_->RunAllPendingInMessageLoop();
112 } 150 }
113 151
114 void AuraTestBase::ParentWindow(Window* window) { 152 void AuraTestBase::ParentWindow(Window* window) {
115 client::ParentWindowWithContext(window, root_window(), gfx::Rect()); 153 client::ParentWindowWithContext(window, root_window(), gfx::Rect());
116 } 154 }
117 155
118 bool AuraTestBase::DispatchEventUsingWindowDispatcher(ui::Event* event) { 156 bool AuraTestBase::DispatchEventUsingWindowDispatcher(ui::Event* event) {
119 ui::EventDispatchDetails details = 157 ui::EventDispatchDetails details =
120 event_processor()->OnEventFromSource(event); 158 event_processor()->OnEventFromSource(event);
121 CHECK(!details.dispatcher_destroyed); 159 CHECK(!details.dispatcher_destroyed);
122 return event->handled(); 160 return event->handled();
123 } 161 }
124 162
163 ui::mojom::WindowTreeClient* AuraTestBase::window_tree_client() {
164 return helper_->window_tree_client();
165 }
166
167 void AuraTestBase::SetPropertyConverter(
168 std::unique_ptr<PropertyConverter> helper) {
169 property_converter_ = std::move(helper);
170 }
171
172 void AuraTestBase::OnEmbed(Window* root) {}
173
174 void AuraTestBase::OnUnembed(Window* root) {}
175
176 void AuraTestBase::OnEmbedRootDestroyed(Window* root) {}
177
178 void AuraTestBase::OnLostConnection(WindowTreeClient* client) {}
179
180 void AuraTestBase::OnPointerEventObserved(const ui::PointerEvent& event,
181 Window* target) {}
182
183 void AuraTestBase::SetWindowManagerClient(WindowManagerClient* client) {}
184
185 bool AuraTestBase::OnWmSetBounds(Window* window, gfx::Rect* bounds) {
186 return true;
187 }
188
189 bool AuraTestBase::OnWmSetProperty(
190 Window* window,
191 const std::string& name,
192 std::unique_ptr<std::vector<uint8_t>>* new_data) {
193 return true;
194 }
195
196 Window* AuraTestBase::OnWmCreateTopLevelWindow(
197 std::map<std::string, std::vector<uint8_t>>* properties) {
198 return new Window(nullptr);
199 }
200
201 void AuraTestBase::OnWmClientJankinessChanged(
202 const std::set<Window*>& client_windows,
203 bool janky) {}
204
205 void AuraTestBase::OnWmNewDisplay(Window* window,
206 const display::Display& display) {}
207
208 void AuraTestBase::OnWmDisplayRemoved(Window* window) {}
209
210 void AuraTestBase::OnWmDisplayModified(const display::Display& display) {}
211
212 ui::mojom::EventResult AuraTestBase::OnAccelerator(uint32_t id,
213 const ui::Event& event) {
214 return ui::mojom::EventResult::HANDLED;
215 }
216
217 void AuraTestBase::OnWmPerformMoveLoop(
218 Window* window,
219 ui::mojom::MoveLoopSource source,
220 const gfx::Point& cursor_location,
221 const base::Callback<void(bool)>& on_done) {}
222
223 void AuraTestBase::OnWmCancelMoveLoop(Window* window) {}
224
225 client::FocusClient* AuraTestBase::GetFocusClient() {
226 return helper_->focus_client();
227 }
228
229 client::CaptureClient* AuraTestBase::GetCaptureClient() {
230 return helper_->capture_client();
231 }
232
233 PropertyConverter* AuraTestBase::GetPropertyConverter() {
234 return property_converter_.get();
235 }
236
125 } // namespace test 237 } // namespace test
126 } // namespace aura 238 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/aura_test_base.h ('k') | ui/aura/test/aura_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698