OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "components/view_manager/client_connection.h" | 9 #include "components/view_manager/client_connection.h" |
10 #include "components/view_manager/connection_manager.h" | 10 #include "components/view_manager/connection_manager.h" |
11 #include "components/view_manager/connection_manager_delegate.h" | 11 #include "components/view_manager/connection_manager_delegate.h" |
12 #include "components/view_manager/display_manager.h" | 12 #include "components/view_manager/display_manager.h" |
13 #include "components/view_manager/ids.h" | 13 #include "components/view_manager/ids.h" |
14 #include "components/view_manager/public/cpp/types.h" | 14 #include "components/view_manager/public/cpp/types.h" |
15 #include "components/view_manager/public/cpp/util.h" | 15 #include "components/view_manager/public/cpp/util.h" |
16 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 16 #include "components/view_manager/public/interfaces/view_manager.mojom.h" |
17 #include "components/view_manager/server_view.h" | 17 #include "components/view_manager/server_view.h" |
18 #include "components/view_manager/test_change_tracker.h" | 18 #include "components/view_manager/test_change_tracker.h" |
19 #include "components/view_manager/view_manager_service_impl.h" | 19 #include "components/view_manager/view_manager_service_impl.h" |
20 #include "components/window_manager/public/interfaces/window_manager.mojom.h" | |
21 #include "components/window_manager/public/interfaces/window_manager_internal.mo
jom.h" | |
22 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 20 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
23 #include "mojo/converters/geometry/geometry_type_converters.h" | 21 #include "mojo/converters/geometry/geometry_type_converters.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
26 | 24 |
27 using mojo::Array; | 25 using mojo::Array; |
28 using mojo::ERROR_CODE_NONE; | 26 using mojo::ERROR_CODE_NONE; |
29 using mojo::InterfaceRequest; | 27 using mojo::InterfaceRequest; |
30 using mojo::ServiceProvider; | 28 using mojo::ServiceProvider; |
31 using mojo::ServiceProviderPtr; | 29 using mojo::ServiceProviderPtr; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const mojo::ViewportMetrics& GetViewportMetrics() override { | 187 const mojo::ViewportMetrics& GetViewportMetrics() override { |
190 return display_metrices_; | 188 return display_metrices_; |
191 } | 189 } |
192 | 190 |
193 private: | 191 private: |
194 mojo::ViewportMetrics display_metrices_; | 192 mojo::ViewportMetrics display_metrices_; |
195 | 193 |
196 DISALLOW_COPY_AND_ASSIGN(TestDisplayManager); | 194 DISALLOW_COPY_AND_ASSIGN(TestDisplayManager); |
197 }; | 195 }; |
198 | 196 |
199 // ----------------------------------------------------------------------------- | |
200 | |
201 // Empty implementation of WindowManagerInternal. | |
202 class TestWindowManagerInternal : public mojo::WindowManagerInternal { | |
203 public: | |
204 TestWindowManagerInternal() {} | |
205 ~TestWindowManagerInternal() override {} | |
206 | |
207 // WindowManagerInternal: | |
208 void SetViewManagerClient(mojo::ScopedMessagePipeHandle) override {} | |
209 void OnAccelerator(mojo::EventPtr event) override {} | |
210 | |
211 private: | |
212 DISALLOW_COPY_AND_ASSIGN(TestWindowManagerInternal); | |
213 }; | |
214 | |
215 mojo::EventPtr CreatePointerDownEvent(int x, int y) { | 197 mojo::EventPtr CreatePointerDownEvent(int x, int y) { |
216 mojo::EventPtr event(mojo::Event::New()); | 198 mojo::EventPtr event(mojo::Event::New()); |
217 event->action = mojo::EVENT_TYPE_POINTER_DOWN; | 199 event->action = mojo::EVENT_TYPE_POINTER_DOWN; |
218 event->pointer_data = mojo::PointerData::New(); | 200 event->pointer_data = mojo::PointerData::New(); |
219 event->pointer_data->pointer_id = 1u; | 201 event->pointer_data->pointer_id = 1u; |
220 event->pointer_data->x = x; | 202 event->pointer_data->x = x; |
221 event->pointer_data->y = y; | 203 event->pointer_data->y = y; |
222 return event.Pass(); | 204 return event.Pass(); |
223 } | 205 } |
224 | 206 |
(...skipping 30 matching lines...) Expand all Loading... |
255 } | 237 } |
256 | 238 |
257 ConnectionManager* connection_manager() { return connection_manager_.get(); } | 239 ConnectionManager* connection_manager() { return connection_manager_.get(); } |
258 | 240 |
259 TestViewManagerClient* wm_client() { return wm_client_; } | 241 TestViewManagerClient* wm_client() { return wm_client_; } |
260 | 242 |
261 protected: | 243 protected: |
262 // testing::Test: | 244 // testing::Test: |
263 void SetUp() override { | 245 void SetUp() override { |
264 connection_manager_.reset(new ConnectionManager( | 246 connection_manager_.reset(new ConnectionManager( |
265 &delegate_, scoped_ptr<DisplayManager>(new TestDisplayManager), | 247 &delegate_, scoped_ptr<DisplayManager>(new TestDisplayManager))); |
266 &wm_internal_)); | |
267 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl( | 248 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl( |
268 connection_manager_.get(), kInvalidConnectionId, std::string(), | 249 connection_manager_.get(), kInvalidConnectionId, std::string(), |
269 std::string("mojo:window_manager"), RootViewId())); | 250 std::string("mojo:window_manager"), RootViewId())); |
270 scoped_ptr<TestClientConnection> client_connection( | 251 scoped_ptr<TestClientConnection> client_connection( |
271 new TestClientConnection(service.Pass())); | 252 new TestClientConnection(service.Pass())); |
272 wm_client_ = client_connection->client(); | 253 wm_client_ = client_connection->client(); |
273 ASSERT_TRUE(wm_client_ != nullptr); | 254 ASSERT_TRUE(wm_client_ != nullptr); |
274 connection_manager_->SetWindowManagerClientConnection( | 255 connection_manager_->SetWindowManagerClientConnection( |
275 client_connection.Pass()); | 256 client_connection.Pass()); |
276 ASSERT_TRUE(wm_connection() != nullptr); | 257 ASSERT_TRUE(wm_connection() != nullptr); |
277 ASSERT_TRUE(wm_connection()->root() != nullptr); | 258 ASSERT_TRUE(wm_connection()->root() != nullptr); |
278 } | 259 } |
279 | 260 |
280 private: | 261 private: |
281 // TestViewManagerClient that is used for the WM connection. | 262 // TestViewManagerClient that is used for the WM connection. |
282 TestViewManagerClient* wm_client_; | 263 TestViewManagerClient* wm_client_; |
283 | 264 |
284 TestWindowManagerInternal wm_internal_; | |
285 TestConnectionManagerDelegate delegate_; | 265 TestConnectionManagerDelegate delegate_; |
286 scoped_ptr<ConnectionManager> connection_manager_; | 266 scoped_ptr<ConnectionManager> connection_manager_; |
287 base::MessageLoop message_loop_; | 267 base::MessageLoop message_loop_; |
288 | 268 |
289 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceTest); | 269 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceTest); |
290 }; | 270 }; |
291 | 271 |
292 namespace { | 272 namespace { |
293 | 273 |
294 const ServerView* GetFirstCloned(const ServerView* view) { | 274 const ServerView* GetFirstCloned(const ServerView* view) { |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 EXPECT_EQ(connection_manager()->root(), | 537 EXPECT_EQ(connection_manager()->root(), |
558 connection_manager()->GetFocusedView()); | 538 connection_manager()->GetFocusedView()); |
559 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u); | 539 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u); |
560 EXPECT_EQ("InputEvent view=0,1 event_action=4", | 540 EXPECT_EQ("InputEvent view=0,1 event_action=4", |
561 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 541 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
562 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); | 542 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); |
563 ; | 543 ; |
564 } | 544 } |
565 | 545 |
566 } // namespace view_manager | 546 } // namespace view_manager |
OLD | NEW |