| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_MUS_WS_TEST_UTILS_H_ | 5 #ifndef COMPONENTS_MUS_WS_TEST_UTILS_H_ |
| 6 #define COMPONENTS_MUS_WS_TEST_UTILS_H_ | 6 #define COMPONENTS_MUS_WS_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "components/mus/public/interfaces/display.mojom.h" | 10 #include "components/mus/public/interfaces/display.mojom.h" |
| 11 #include "components/mus/public/interfaces/window_tree.mojom.h" | 11 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 12 #include "components/mus/ws/connection_manager_delegate.h" | 12 #include "components/mus/ws/connection_manager_delegate.h" |
| 13 #include "components/mus/ws/display.h" | 13 #include "components/mus/ws/display.h" |
| 14 #include "components/mus/ws/event_dispatcher.h" |
| 14 #include "components/mus/ws/platform_display.h" | 15 #include "components/mus/ws/platform_display.h" |
| 15 #include "components/mus/ws/platform_display_factory.h" | 16 #include "components/mus/ws/platform_display_factory.h" |
| 16 #include "components/mus/ws/test_change_tracker.h" | 17 #include "components/mus/ws/test_change_tracker.h" |
| 17 #include "components/mus/ws/user_display_manager.h" | 18 #include "components/mus/ws/user_display_manager.h" |
| 18 #include "components/mus/ws/window_manager_factory_registry.h" | 19 #include "components/mus/ws/window_manager_factory_registry.h" |
| 20 #include "components/mus/ws/window_manager_state.h" |
| 19 #include "components/mus/ws/window_tree.h" | 21 #include "components/mus/ws/window_tree.h" |
| 20 #include "components/mus/ws/window_tree_binding.h" | 22 #include "components/mus/ws/window_tree_binding.h" |
| 21 | 23 |
| 22 namespace mus { | 24 namespace mus { |
| 23 namespace ws { | 25 namespace ws { |
| 24 namespace test { | 26 namespace test { |
| 25 | 27 |
| 26 // Collection of utilities useful in creating mus tests. | 28 // Collection of utilities useful in creating mus tests. |
| 27 | 29 |
| 28 class WindowManagerFactoryRegistryTestApi { | 30 class WindowManagerFactoryRegistryTestApi { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 63 |
| 62 class WindowTreeTestApi { | 64 class WindowTreeTestApi { |
| 63 public: | 65 public: |
| 64 WindowTreeTestApi(WindowTree* tree); | 66 WindowTreeTestApi(WindowTree* tree); |
| 65 ~WindowTreeTestApi(); | 67 ~WindowTreeTestApi(); |
| 66 | 68 |
| 67 void set_window_manager_internal(mojom::WindowManager* wm_internal) { | 69 void set_window_manager_internal(mojom::WindowManager* wm_internal) { |
| 68 tree_->window_manager_internal_ = wm_internal; | 70 tree_->window_manager_internal_ = wm_internal; |
| 69 } | 71 } |
| 70 | 72 |
| 73 void EnableCapture() { tree_->event_ack_id_ = 1u; } |
| 74 |
| 71 private: | 75 private: |
| 72 WindowTree* tree_; | 76 WindowTree* tree_; |
| 73 | 77 |
| 74 DISALLOW_COPY_AND_ASSIGN(WindowTreeTestApi); | 78 DISALLOW_COPY_AND_ASSIGN(WindowTreeTestApi); |
| 75 }; | 79 }; |
| 76 | 80 |
| 77 // ----------------------------------------------------------------------------- | 81 // ----------------------------------------------------------------------------- |
| 78 | 82 |
| 79 class DisplayTestApi { | 83 class DisplayTestApi { |
| 80 public: | 84 public: |
| 81 explicit DisplayTestApi(Display* display); | 85 explicit DisplayTestApi(Display* display); |
| 82 ~DisplayTestApi(); | 86 ~DisplayTestApi(); |
| 83 | 87 |
| 84 void OnEvent(const ui::Event& event) { display_->OnEvent(event); } | 88 void OnEvent(const ui::Event& event) { display_->OnEvent(event); } |
| 85 | 89 |
| 86 mojom::WindowTree* tree_awaiting_input_ack() { | |
| 87 return display_->tree_awaiting_input_ack_; | |
| 88 } | |
| 89 | |
| 90 private: | 90 private: |
| 91 Display* display_; | 91 Display* display_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(DisplayTestApi); | 93 DISALLOW_COPY_AND_ASSIGN(DisplayTestApi); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 // ----------------------------------------------------------------------------- | 96 // ----------------------------------------------------------------------------- |
| 97 |
| 98 class EventDispatcherTestApi { |
| 99 public: |
| 100 explicit EventDispatcherTestApi(EventDispatcher* ed) : ed_(ed) {} |
| 101 ~EventDispatcherTestApi() {} |
| 102 |
| 103 bool AreAnyPointersDown() const { return ed_->AreAnyPointersDown(); } |
| 104 bool is_mouse_button_down() const { return ed_->mouse_button_down_; } |
| 105 bool IsObservingWindow(ServerWindow* window) { |
| 106 return ed_->IsObservingWindow(window); |
| 107 } |
| 108 int NumberPointerTargetsForWindow(ServerWindow* window); |
| 109 |
| 110 private: |
| 111 EventDispatcher* ed_; |
| 112 |
| 113 DISALLOW_COPY_AND_ASSIGN(EventDispatcherTestApi); |
| 114 }; |
| 115 |
| 116 // ----------------------------------------------------------------------------- |
| 117 |
| 118 class WindowManagerStateTestApi { |
| 119 public: |
| 120 explicit WindowManagerStateTestApi(WindowManagerState* wms) : wms_(wms) {} |
| 121 ~WindowManagerStateTestApi() {} |
| 122 |
| 123 mojom::WindowTree* tree_awaiting_input_ack() { |
| 124 return wms_->tree_awaiting_input_ack_; |
| 125 } |
| 126 |
| 127 private: |
| 128 WindowManagerState* wms_; |
| 129 |
| 130 DISALLOW_COPY_AND_ASSIGN(WindowManagerStateTestApi); |
| 131 }; |
| 132 |
| 133 // ----------------------------------------------------------------------------- |
| 97 | 134 |
| 98 // Factory that dispenses TestPlatformDisplays. | 135 // Factory that dispenses TestPlatformDisplays. |
| 99 class TestPlatformDisplayFactory : public PlatformDisplayFactory { | 136 class TestPlatformDisplayFactory : public PlatformDisplayFactory { |
| 100 public: | 137 public: |
| 101 explicit TestPlatformDisplayFactory(int32_t* cursor_id_storage); | 138 explicit TestPlatformDisplayFactory(int32_t* cursor_id_storage); |
| 102 ~TestPlatformDisplayFactory(); | 139 ~TestPlatformDisplayFactory(); |
| 103 | 140 |
| 104 // PlatformDisplayFactory: | 141 // PlatformDisplayFactory: |
| 105 PlatformDisplay* CreatePlatformDisplay( | 142 PlatformDisplay* CreatePlatformDisplay( |
| 106 mojo::Connector* connector, | 143 mojo::Connector* connector, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 bool got_on_no_more_displays_ = false; | 290 bool got_on_no_more_displays_ = false; |
| 254 | 291 |
| 255 DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate); | 292 DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate); |
| 256 }; | 293 }; |
| 257 | 294 |
| 258 } // namespace test | 295 } // namespace test |
| 259 } // namespace ws | 296 } // namespace ws |
| 260 } // namespace mus | 297 } // namespace mus |
| 261 | 298 |
| 262 #endif // COMPONENTS_MUS_WS_TEST_UTILS_H_ | 299 #endif // COMPONENTS_MUS_WS_TEST_UTILS_H_ |
| OLD | NEW |