| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 TestWindowTreeClient* last_client() { | 255 TestWindowTreeClient* last_client() { |
| 256 return last_connection_ ? last_connection_->client() : nullptr; | 256 return last_connection_ ? last_connection_->client() : nullptr; |
| 257 } | 257 } |
| 258 | 258 |
| 259 TestClientConnection* last_connection() { return last_connection_; } | 259 TestClientConnection* last_connection() { return last_connection_; } |
| 260 | 260 |
| 261 private: | 261 private: |
| 262 // ConnectionManagerDelegate: | 262 // ConnectionManagerDelegate: |
| 263 void OnNoMoreRootConnections() override {} | 263 void OnNoMoreRootConnections() override {} |
| 264 | |
| 265 ClientConnection* CreateClientConnectionForEmbedAtWindow( | 264 ClientConnection* CreateClientConnectionForEmbedAtWindow( |
| 266 ConnectionManager* connection_manager, | 265 ConnectionManager* connection_manager, |
| 267 mojo::InterfaceRequest<mus::mojom::WindowTree> service_request, | 266 mojo::InterfaceRequest<mus::mojom::WindowTree> service_request, |
| 268 ServerWindow* root, | 267 ServerWindow* root, |
| 269 uint32_t policy_bitmask, | 268 uint32_t policy_bitmask, |
| 270 mus::mojom::WindowTreeClientPtr client) override { | 269 mus::mojom::WindowTreeClientPtr client) override { |
| 271 // Used by ConnectionManager::AddRoot. | |
| 272 scoped_ptr<WindowTreeImpl> service( | 270 scoped_ptr<WindowTreeImpl> service( |
| 273 new WindowTreeImpl(connection_manager, root, policy_bitmask)); | 271 new WindowTreeImpl(connection_manager, root, policy_bitmask)); |
| 274 last_connection_ = new TestClientConnection(std::move(service)); | 272 last_connection_ = new TestClientConnection(std::move(service)); |
| 275 return last_connection_; | 273 return last_connection_; |
| 276 } | 274 } |
| 275 ClientConnection* CreateClientConnectionForWindowManager( |
| 276 WindowTreeHostImpl* tree_host, |
| 277 ServerWindow* window, |
| 278 const mojom::Display& display, |
| 279 uint32_t user_id, |
| 280 mojom::WindowManagerFactory* factory) override { |
| 281 NOTREACHED(); |
| 282 return nullptr; |
| 283 } |
| 284 void CreateDefaultWindowTreeHosts() override { NOTREACHED(); } |
| 277 | 285 |
| 278 TestClientConnection* last_connection_; | 286 TestClientConnection* last_connection_; |
| 279 WindowTreeHostImpl* window_tree_host_; | 287 WindowTreeHostImpl* window_tree_host_; |
| 280 | 288 |
| 281 DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate); | 289 DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate); |
| 282 }; | 290 }; |
| 283 | 291 |
| 284 // ----------------------------------------------------------------------------- | 292 // ----------------------------------------------------------------------------- |
| 285 | 293 |
| 286 class TestWindowTreeHostConnection : public WindowTreeHostConnection { | 294 class TestWindowTreeHostConnection : public WindowTreeHostConnection { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 DispatchEventAndAckImmediately(CreatePointerUpEvent(21, 22)); | 642 DispatchEventAndAckImmediately(CreatePointerUpEvent(21, 22)); |
| 635 wm_client()->tracker()->changes()->clear(); | 643 wm_client()->tracker()->changes()->clear(); |
| 636 connection1_client->tracker()->changes()->clear(); | 644 connection1_client->tracker()->changes()->clear(); |
| 637 | 645 |
| 638 // Press in the same location. Should not get a focus change event (only input | 646 // Press in the same location. Should not get a focus change event (only input |
| 639 // event). | 647 // event). |
| 640 DispatchEventAndAckImmediately(CreatePointerDownEvent(61, 22)); | 648 DispatchEventAndAckImmediately(CreatePointerDownEvent(61, 22)); |
| 641 EXPECT_EQ(child1, window_tree_host_->GetFocusedWindow()); | 649 EXPECT_EQ(child1, window_tree_host_->GetFocusedWindow()); |
| 642 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u) | 650 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u) |
| 643 << SingleChangeToDescription(*wm_client()->tracker()->changes()); | 651 << SingleChangeToDescription(*wm_client()->tracker()->changes()); |
| 644 EXPECT_EQ("InputEvent window=0,2 event_action=4", | 652 EXPECT_EQ("InputEvent window=0,3 event_action=4", |
| 645 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 653 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
| 646 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); | 654 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); |
| 647 } | 655 } |
| 648 | 656 |
| 649 TEST_F(WindowTreeTest, BasicInputEventTarget) { | 657 TEST_F(WindowTreeTest, BasicInputEventTarget) { |
| 650 TestWindowTreeClient* embed_connection = nullptr; | 658 TestWindowTreeClient* embed_connection = nullptr; |
| 651 WindowTreeImpl* window_tree_connection = nullptr; | 659 WindowTreeImpl* window_tree_connection = nullptr; |
| 652 ServerWindow* window = nullptr; | 660 ServerWindow* window = nullptr; |
| 653 EXPECT_NO_FATAL_FAILURE( | 661 EXPECT_NO_FATAL_FAILURE( |
| 654 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); | 662 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 wm_connection()->NewWindow(embed_window_id, ServerWindow::Properties())); | 820 wm_connection()->NewWindow(embed_window_id, ServerWindow::Properties())); |
| 813 EXPECT_TRUE(wm_connection()->SetWindowVisibility(embed_window_id, true)); | 821 EXPECT_TRUE(wm_connection()->SetWindowVisibility(embed_window_id, true)); |
| 814 ASSERT_TRUE(FirstRoot(wm_connection())); | 822 ASSERT_TRUE(FirstRoot(wm_connection())); |
| 815 EXPECT_TRUE(wm_connection()->AddWindow(FirstRootId(wm_connection()), | 823 EXPECT_TRUE(wm_connection()->AddWindow(FirstRootId(wm_connection()), |
| 816 embed_window_id)); | 824 embed_window_id)); |
| 817 window_tree_host_->root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 825 window_tree_host_->root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 818 | 826 |
| 819 wm_client()->tracker()->changes()->clear(); | 827 wm_client()->tracker()->changes()->clear(); |
| 820 DispatchEventWithoutAck(CreateMouseMoveEvent(21, 22)); | 828 DispatchEventWithoutAck(CreateMouseMoveEvent(21, 22)); |
| 821 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); | 829 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); |
| 822 EXPECT_EQ("InputEvent window=0,2 event_action=5", | 830 EXPECT_EQ("InputEvent window=0,3 event_action=5", |
| 823 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 831 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
| 824 wm_client()->tracker()->changes()->clear(); | 832 wm_client()->tracker()->changes()->clear(); |
| 825 | 833 |
| 826 // Send another event. This event shouldn't reach the client. | 834 // Send another event. This event shouldn't reach the client. |
| 827 DispatchEventWithoutAck(CreateMouseMoveEvent(21, 22)); | 835 DispatchEventWithoutAck(CreateMouseMoveEvent(21, 22)); |
| 828 ASSERT_EQ(0u, wm_client()->tracker()->changes()->size()); | 836 ASSERT_EQ(0u, wm_client()->tracker()->changes()->size()); |
| 829 | 837 |
| 830 // Ack the first event. That should trigger the dispatch of the second event. | 838 // Ack the first event. That should trigger the dispatch of the second event. |
| 831 AckPreviousEvent(); | 839 AckPreviousEvent(); |
| 832 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); | 840 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); |
| 833 EXPECT_EQ("InputEvent window=0,2 event_action=5", | 841 EXPECT_EQ("InputEvent window=0,3 event_action=5", |
| 834 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 842 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
| 835 } | 843 } |
| 836 | 844 |
| 837 // Establish connection, call NewTopLevelWindow(), make sure get id, and make | 845 // Establish connection, call NewTopLevelWindow(), make sure get id, and make |
| 838 // sure client paused. | 846 // sure client paused. |
| 839 TEST_F(WindowTreeTest, NewTopLevelWindow) { | 847 TEST_F(WindowTreeTest, NewTopLevelWindow) { |
| 840 TestWindowManager wm_internal; | 848 TestWindowManager wm_internal; |
| 841 set_window_manager_internal(wm_connection(), &wm_internal); | 849 set_window_manager_internal(wm_connection(), &wm_internal); |
| 842 TestWindowTreeClient* embed_connection = nullptr; | 850 TestWindowTreeClient* embed_connection = nullptr; |
| 843 WindowTreeImpl* window_tree_connection = nullptr; | 851 WindowTreeImpl* window_tree_connection = nullptr; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 mojom_window_tree->ReleaseCapture(++change_id, | 948 mojom_window_tree->ReleaseCapture(++change_id, |
| 941 WindowIdToTransportId(root_window->id())); | 949 WindowIdToTransportId(root_window->id())); |
| 942 EXPECT_EQ(window, host->GetCaptureWindow()); | 950 EXPECT_EQ(window, host->GetCaptureWindow()); |
| 943 mojom_window_tree->ReleaseCapture(++change_id, | 951 mojom_window_tree->ReleaseCapture(++change_id, |
| 944 WindowIdToTransportId(window->id())); | 952 WindowIdToTransportId(window->id())); |
| 945 EXPECT_EQ(nullptr, host->GetCaptureWindow()); | 953 EXPECT_EQ(nullptr, host->GetCaptureWindow()); |
| 946 } | 954 } |
| 947 | 955 |
| 948 } // namespace ws | 956 } // namespace ws |
| 949 } // namespace mus | 957 } // namespace mus |
| OLD | NEW |