| 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/display_manager_factory.h" | 13 #include "components/view_manager/display_manager_factory.h" |
| 14 #include "components/view_manager/ids.h" | 14 #include "components/view_manager/ids.h" |
| 15 #include "components/view_manager/public/cpp/types.h" | 15 #include "components/view_manager/public/cpp/types.h" |
| 16 #include "components/view_manager/public/cpp/util.h" | 16 #include "components/view_manager/public/cpp/util.h" |
| 17 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 17 #include "components/view_manager/public/interfaces/view_manager.mojom.h" |
| 18 #include "components/view_manager/server_view.h" | 18 #include "components/view_manager/server_view.h" |
| 19 #include "components/view_manager/surfaces/surfaces_state.h" |
| 19 #include "components/view_manager/test_change_tracker.h" | 20 #include "components/view_manager/test_change_tracker.h" |
| 20 #include "components/view_manager/view_manager_root_connection.h" | 21 #include "components/view_manager/view_manager_root_connection.h" |
| 21 #include "components/view_manager/view_manager_service_impl.h" | 22 #include "components/view_manager/view_manager_service_impl.h" |
| 22 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 23 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
| 23 #include "mojo/converters/geometry/geometry_type_converters.h" | 24 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
| 26 | 27 |
| 27 using mojo::Array; | 28 using mojo::Array; |
| 28 using mojo::ERROR_CODE_NONE; | 29 using mojo::ERROR_CODE_NONE; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 }; | 231 }; |
| 231 | 232 |
| 232 // Factory that dispenses TestDisplayManagers. | 233 // Factory that dispenses TestDisplayManagers. |
| 233 class TestDisplayManagerFactory : public DisplayManagerFactory { | 234 class TestDisplayManagerFactory : public DisplayManagerFactory { |
| 234 public: | 235 public: |
| 235 TestDisplayManagerFactory() {} | 236 TestDisplayManagerFactory() {} |
| 236 ~TestDisplayManagerFactory() {} | 237 ~TestDisplayManagerFactory() {} |
| 237 DisplayManager* CreateDisplayManager( | 238 DisplayManager* CreateDisplayManager( |
| 238 bool is_headless, | 239 bool is_headless, |
| 239 mojo::ApplicationImpl* app_impl, | 240 mojo::ApplicationImpl* app_impl, |
| 240 const scoped_refptr<gles2::GpuState>& gpu_state) override { | 241 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 242 const scoped_refptr<surfaces::SurfacesState>& surfaces_state) override { |
| 241 return new TestDisplayManager(); | 243 return new TestDisplayManager(); |
| 242 } | 244 } |
| 243 | 245 |
| 244 private: | 246 private: |
| 245 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerFactory); | 247 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerFactory); |
| 246 }; | 248 }; |
| 247 | 249 |
| 248 mojo::EventPtr CreatePointerDownEvent(int x, int y) { | 250 mojo::EventPtr CreatePointerDownEvent(int x, int y) { |
| 249 mojo::EventPtr event(mojo::Event::New()); | 251 mojo::EventPtr event(mojo::Event::New()); |
| 250 event->action = mojo::EVENT_TYPE_POINTER_DOWN; | 252 event->action = mojo::EVENT_TYPE_POINTER_DOWN; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 TestViewManagerRootConnection* root_connection() { return root_connection_; } | 296 TestViewManagerRootConnection* root_connection() { return root_connection_; } |
| 295 | 297 |
| 296 protected: | 298 protected: |
| 297 // testing::Test: | 299 // testing::Test: |
| 298 void SetUp() override { | 300 void SetUp() override { |
| 299 DisplayManager::set_factory_for_testing(&display_manager_factory_); | 301 DisplayManager::set_factory_for_testing(&display_manager_factory_); |
| 300 // TODO(fsamuel): This is probably broken. We need a root. | 302 // TODO(fsamuel): This is probably broken. We need a root. |
| 301 connection_manager_.reset(new ConnectionManager(&delegate_)); | 303 connection_manager_.reset(new ConnectionManager(&delegate_)); |
| 302 ViewManagerRootImpl* root = new ViewManagerRootImpl( | 304 ViewManagerRootImpl* root = new ViewManagerRootImpl( |
| 303 connection_manager_.get(), true /* is_headless */, nullptr, | 305 connection_manager_.get(), true /* is_headless */, nullptr, |
| 304 scoped_refptr<gles2::GpuState>()); | 306 scoped_refptr<gles2::GpuState>(), |
| 307 scoped_refptr<surfaces::SurfacesState>()); |
| 305 // TODO(fsamuel): This is way too magical. We need to find a better way to | 308 // TODO(fsamuel): This is way too magical. We need to find a better way to |
| 306 // manage lifetime. | 309 // manage lifetime. |
| 307 root_connection_ = new TestViewManagerRootConnection( | 310 root_connection_ = new TestViewManagerRootConnection( |
| 308 make_scoped_ptr(root), connection_manager_.get()); | 311 make_scoped_ptr(root), connection_manager_.get()); |
| 309 root->Init(root_connection_); | 312 root->Init(root_connection_); |
| 310 wm_client_ = delegate_.last_client(); | 313 wm_client_ = delegate_.last_client(); |
| 311 } | 314 } |
| 312 | 315 |
| 313 private: | 316 private: |
| 314 // TestViewManagerClient that is used for the WM connection. | 317 // TestViewManagerClient that is used for the WM connection. |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 CreatePointerDownEvent(61, 22)); | 603 CreatePointerDownEvent(61, 22)); |
| 601 EXPECT_EQ(root_connection()->view_manager_root()->root_view(), | 604 EXPECT_EQ(root_connection()->view_manager_root()->root_view(), |
| 602 connection_manager()->GetFocusedView()); | 605 connection_manager()->GetFocusedView()); |
| 603 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u); | 606 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u); |
| 604 EXPECT_EQ("InputEvent view=0,2 event_action=4", | 607 EXPECT_EQ("InputEvent view=0,2 event_action=4", |
| 605 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 608 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
| 606 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); | 609 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); |
| 607 } | 610 } |
| 608 | 611 |
| 609 } // namespace view_manager | 612 } // namespace view_manager |
| OLD | NEW |