| 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 18 matching lines...) Expand all Loading... |
| 29 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 29 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
| 30 #include "mojo/shell/public/interfaces/service_provider.mojom.h" | 30 #include "mojo/shell/public/interfaces/service_provider.mojom.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 32 #include "ui/events/event.h" | 32 #include "ui/events/event.h" |
| 33 #include "ui/events/event_utils.h" | 33 #include "ui/events/event_utils.h" |
| 34 #include "ui/gfx/geometry/rect.h" | 34 #include "ui/gfx/geometry/rect.h" |
| 35 | 35 |
| 36 using mojo::Array; | 36 using mojo::Array; |
| 37 using mojo::InterfaceRequest; | 37 using mojo::InterfaceRequest; |
| 38 using mojo::String; | 38 using mojo::String; |
| 39 using mus::mojom::ERROR_CODE_NONE; | |
| 40 using mus::mojom::Event; | 39 using mus::mojom::Event; |
| 41 using mus::mojom::EventPtr; | 40 using mus::mojom::EventPtr; |
| 42 using mus::mojom::LocationData; | 41 using mus::mojom::LocationData; |
| 43 using mus::mojom::PointerData; | 42 using mus::mojom::PointerData; |
| 44 using mus::mojom::WindowDataPtr; | 43 using mus::mojom::WindowDataPtr; |
| 45 | 44 |
| 46 namespace mus { | 45 namespace mus { |
| 47 namespace ws { | 46 namespace ws { |
| 48 namespace { | 47 namespace { |
| 49 | 48 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 ConnectionManager* manager) | 276 ConnectionManager* manager) |
| 278 : WindowTreeHostConnection(std::move(host_impl), manager) {} | 277 : WindowTreeHostConnection(std::move(host_impl), manager) {} |
| 279 ~TestWindowTreeHostConnection() override {} | 278 ~TestWindowTreeHostConnection() override {} |
| 280 | 279 |
| 281 private: | 280 private: |
| 282 // WindowTreeHostDelegate: | 281 // WindowTreeHostDelegate: |
| 283 void OnDisplayInitialized() override { | 282 void OnDisplayInitialized() override { |
| 284 connection_manager()->AddHost(this); | 283 connection_manager()->AddHost(this); |
| 285 set_window_tree(connection_manager()->EmbedAtWindow( | 284 set_window_tree(connection_manager()->EmbedAtWindow( |
| 286 window_tree_host()->root_window(), | 285 window_tree_host()->root_window(), |
| 287 mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT, | 286 mus::mojom::WindowTree::kAccessPolicyEmbedRoot, |
| 288 mus::mojom::WindowTreeClientPtr())); | 287 mus::mojom::WindowTreeClientPtr())); |
| 289 } | 288 } |
| 290 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeHostConnection); | 289 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeHostConnection); |
| 291 }; | 290 }; |
| 292 | 291 |
| 293 // ----------------------------------------------------------------------------- | 292 // ----------------------------------------------------------------------------- |
| 294 // Empty implementation of DisplayManager. | 293 // Empty implementation of DisplayManager. |
| 295 class TestDisplayManager : public DisplayManager { | 294 class TestDisplayManager : public DisplayManager { |
| 296 public: | 295 public: |
| 297 explicit TestDisplayManager(int32_t* cursor_id_storage) | 296 explicit TestDisplayManager(int32_t* cursor_id_storage) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 return delegate_.last_connection(); | 403 return delegate_.last_connection(); |
| 405 } | 404 } |
| 406 | 405 |
| 407 ConnectionManager* connection_manager() { return connection_manager_.get(); } | 406 ConnectionManager* connection_manager() { return connection_manager_.get(); } |
| 408 | 407 |
| 409 ServerWindow* GetWindowById(const WindowId& id) { | 408 ServerWindow* GetWindowById(const WindowId& id) { |
| 410 return connection_manager_->GetWindow(id); | 409 return connection_manager_->GetWindow(id); |
| 411 } | 410 } |
| 412 | 411 |
| 413 TestWindowTreeClient* wm_client() { return wm_client_; } | 412 TestWindowTreeClient* wm_client() { return wm_client_; } |
| 414 int32_t cursor_id() { return cursor_id_; } | 413 mus::mojom::Cursor cursor_id() { |
| 414 return static_cast<mus::mojom::Cursor>(cursor_id_); |
| 415 } |
| 415 | 416 |
| 416 TestWindowTreeHostConnection* host_connection() { return host_connection_; } | 417 TestWindowTreeHostConnection* host_connection() { return host_connection_; } |
| 417 | 418 |
| 418 void DispatchEventWithoutAck(const ui::Event& event) { | 419 void DispatchEventWithoutAck(const ui::Event& event) { |
| 419 host_connection()->window_tree_host()->OnEvent(event); | 420 host_connection()->window_tree_host()->OnEvent(event); |
| 420 } | 421 } |
| 421 | 422 |
| 422 void set_window_manager_internal(WindowTreeImpl* connection, | 423 void set_window_manager_internal(WindowTreeImpl* connection, |
| 423 mojom::WindowManagerInternal* wm_internal) { | 424 mojom::WindowManagerInternal* wm_internal) { |
| 424 connection->window_manager_internal_ = wm_internal; | 425 connection->window_manager_internal_ = wm_internal; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 EXPECT_TRUE(wm_connection()->AddWindow(FirstRoot(wm_connection())->id(), | 488 EXPECT_TRUE(wm_connection()->AddWindow(FirstRoot(wm_connection())->id(), |
| 488 embed_window_id)); | 489 embed_window_id)); |
| 489 host_connection()->window_tree_host()->root_window()->SetBounds( | 490 host_connection()->window_tree_host()->root_window()->SetBounds( |
| 490 gfx::Rect(0, 0, 100, 100)); | 491 gfx::Rect(0, 0, 100, 100)); |
| 491 mojom::WindowTreeClientPtr client; | 492 mojom::WindowTreeClientPtr client; |
| 492 mojo::InterfaceRequest<mojom::WindowTreeClient> client_request = | 493 mojo::InterfaceRequest<mojom::WindowTreeClient> client_request = |
| 493 GetProxy(&client); | 494 GetProxy(&client); |
| 494 wm_client()->Bind(std::move(client_request)); | 495 wm_client()->Bind(std::move(client_request)); |
| 495 ConnectionSpecificId connection_id = 0; | 496 ConnectionSpecificId connection_id = 0; |
| 496 wm_connection()->Embed(embed_window_id, std::move(client), | 497 wm_connection()->Embed(embed_window_id, std::move(client), |
| 497 mojom::WindowTree::ACCESS_POLICY_DEFAULT, | 498 mojom::WindowTree::kAccessPolicyDefault, |
| 498 &connection_id); | 499 &connection_id); |
| 499 WindowTreeImpl* connection1 = connection_manager()->GetConnectionWithRoot( | 500 WindowTreeImpl* connection1 = connection_manager()->GetConnectionWithRoot( |
| 500 GetWindowById(embed_window_id)); | 501 GetWindowById(embed_window_id)); |
| 501 ASSERT_TRUE(connection1 != nullptr); | 502 ASSERT_TRUE(connection1 != nullptr); |
| 502 ASSERT_NE(connection1, wm_connection()); | 503 ASSERT_NE(connection1, wm_connection()); |
| 503 | 504 |
| 504 connection_manager() | 505 connection_manager() |
| 505 ->GetWindow(embed_window_id) | 506 ->GetWindow(embed_window_id) |
| 506 ->SetBounds(gfx::Rect(0, 0, 50, 50)); | 507 ->SetBounds(gfx::Rect(0, 0, 50, 50)); |
| 507 | 508 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 535 EXPECT_TRUE(wm_connection()->AddWindow(FirstRoot(wm_connection())->id(), | 536 EXPECT_TRUE(wm_connection()->AddWindow(FirstRoot(wm_connection())->id(), |
| 536 embed_window_id)); | 537 embed_window_id)); |
| 537 host_connection()->window_tree_host()->root_window()->SetBounds( | 538 host_connection()->window_tree_host()->root_window()->SetBounds( |
| 538 gfx::Rect(0, 0, 100, 100)); | 539 gfx::Rect(0, 0, 100, 100)); |
| 539 mojom::WindowTreeClientPtr client; | 540 mojom::WindowTreeClientPtr client; |
| 540 mojo::InterfaceRequest<mojom::WindowTreeClient> client_request = | 541 mojo::InterfaceRequest<mojom::WindowTreeClient> client_request = |
| 541 GetProxy(&client); | 542 GetProxy(&client); |
| 542 wm_client()->Bind(std::move(client_request)); | 543 wm_client()->Bind(std::move(client_request)); |
| 543 ConnectionSpecificId connection_id = 0; | 544 ConnectionSpecificId connection_id = 0; |
| 544 wm_connection()->Embed(embed_window_id, std::move(client), | 545 wm_connection()->Embed(embed_window_id, std::move(client), |
| 545 mojom::WindowTree::ACCESS_POLICY_DEFAULT, | 546 mojom::WindowTree::kAccessPolicyDefault, |
| 546 &connection_id); | 547 &connection_id); |
| 547 WindowTreeImpl* connection1 = connection_manager()->GetConnectionWithRoot( | 548 WindowTreeImpl* connection1 = connection_manager()->GetConnectionWithRoot( |
| 548 GetWindowById(embed_window_id)); | 549 GetWindowById(embed_window_id)); |
| 549 ASSERT_TRUE(connection1 != nullptr); | 550 ASSERT_TRUE(connection1 != nullptr); |
| 550 ASSERT_NE(connection1, wm_connection()); | 551 ASSERT_NE(connection1, wm_connection()); |
| 551 | 552 |
| 552 connection_manager() | 553 connection_manager() |
| 553 ->GetWindow(embed_window_id) | 554 ->GetWindow(embed_window_id) |
| 554 ->SetBounds(gfx::Rect(0, 0, 50, 50)); | 555 ->SetBounds(gfx::Rect(0, 0, 50, 50)); |
| 555 | 556 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 TestWindowTreeClient* embed_connection = nullptr; | 638 TestWindowTreeClient* embed_connection = nullptr; |
| 638 WindowTreeImpl* window_tree_connection = nullptr; | 639 WindowTreeImpl* window_tree_connection = nullptr; |
| 639 ServerWindow* window = nullptr; | 640 ServerWindow* window = nullptr; |
| 640 EXPECT_NO_FATAL_FAILURE( | 641 EXPECT_NO_FATAL_FAILURE( |
| 641 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); | 642 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); |
| 642 | 643 |
| 643 // Like in BasicInputEventTarget, we send a pointer down event to be | 644 // Like in BasicInputEventTarget, we send a pointer down event to be |
| 644 // dispatched. This is only to place the mouse cursor over that window though. | 645 // dispatched. This is only to place the mouse cursor over that window though. |
| 645 DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); | 646 DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); |
| 646 | 647 |
| 647 window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); | 648 window->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 648 | 649 |
| 649 // Because the cursor is over the window when SetCursor was called, we should | 650 // Because the cursor is over the window when SetCursor was called, we should |
| 650 // have immediately changed the cursor. | 651 // have immediately changed the cursor. |
| 651 EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); | 652 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 652 } | 653 } |
| 653 | 654 |
| 654 TEST_F(WindowTreeTest, CursorChangesWhenEnteringWindowWithDifferentCursor) { | 655 TEST_F(WindowTreeTest, CursorChangesWhenEnteringWindowWithDifferentCursor) { |
| 655 TestWindowTreeClient* embed_connection = nullptr; | 656 TestWindowTreeClient* embed_connection = nullptr; |
| 656 WindowTreeImpl* window_tree_connection = nullptr; | 657 WindowTreeImpl* window_tree_connection = nullptr; |
| 657 ServerWindow* window = nullptr; | 658 ServerWindow* window = nullptr; |
| 658 EXPECT_NO_FATAL_FAILURE( | 659 EXPECT_NO_FATAL_FAILURE( |
| 659 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); | 660 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); |
| 660 | 661 |
| 661 // Let's create a pointer event outside the window and then move the pointer | 662 // Let's create a pointer event outside the window and then move the pointer |
| 662 // inside. | 663 // inside. |
| 663 DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); | 664 DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); |
| 664 window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); | 665 window->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 665 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 666 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 666 | 667 |
| 667 DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); | 668 DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); |
| 668 EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); | 669 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 669 } | 670 } |
| 670 | 671 |
| 671 TEST_F(WindowTreeTest, TouchesDontChangeCursor) { | 672 TEST_F(WindowTreeTest, TouchesDontChangeCursor) { |
| 672 TestWindowTreeClient* embed_connection = nullptr; | 673 TestWindowTreeClient* embed_connection = nullptr; |
| 673 WindowTreeImpl* window_tree_connection = nullptr; | 674 WindowTreeImpl* window_tree_connection = nullptr; |
| 674 ServerWindow* window = nullptr; | 675 ServerWindow* window = nullptr; |
| 675 EXPECT_NO_FATAL_FAILURE( | 676 EXPECT_NO_FATAL_FAILURE( |
| 676 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); | 677 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); |
| 677 | 678 |
| 678 // Let's create a pointer event outside the window and then move the pointer | 679 // Let's create a pointer event outside the window and then move the pointer |
| 679 // inside. | 680 // inside. |
| 680 DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); | 681 DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); |
| 681 window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); | 682 window->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 682 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 683 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 683 | 684 |
| 684 // With a touch event, we shouldn't update the cursor. | 685 // With a touch event, we shouldn't update the cursor. |
| 685 DispatchEventAndAckImmediately(CreatePointerDownEvent(21, 22)); | 686 DispatchEventAndAckImmediately(CreatePointerDownEvent(21, 22)); |
| 686 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 687 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 687 } | 688 } |
| 688 | 689 |
| 689 TEST_F(WindowTreeTest, DragOutsideWindow) { | 690 TEST_F(WindowTreeTest, DragOutsideWindow) { |
| 690 TestWindowTreeClient* embed_connection = nullptr; | 691 TestWindowTreeClient* embed_connection = nullptr; |
| 691 WindowTreeImpl* window_tree_connection = nullptr; | 692 WindowTreeImpl* window_tree_connection = nullptr; |
| 692 ServerWindow* window = nullptr; | 693 ServerWindow* window = nullptr; |
| 693 EXPECT_NO_FATAL_FAILURE( | 694 EXPECT_NO_FATAL_FAILURE( |
| 694 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); | 695 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); |
| 695 | 696 |
| 696 // Start with the cursor outside the window. Setting the cursor shouldn't | 697 // Start with the cursor outside the window. Setting the cursor shouldn't |
| 697 // change the cursor. | 698 // change the cursor. |
| 698 DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); | 699 DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); |
| 699 window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); | 700 window->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 700 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 701 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 701 | 702 |
| 702 // Move the pointer to the inside of the window | 703 // Move the pointer to the inside of the window |
| 703 DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); | 704 DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); |
| 704 EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); | 705 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 705 | 706 |
| 706 // Start the drag. | 707 // Start the drag. |
| 707 DispatchEventAndAckImmediately(CreateMouseDownEvent(21, 22)); | 708 DispatchEventAndAckImmediately(CreateMouseDownEvent(21, 22)); |
| 708 EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); | 709 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 709 | 710 |
| 710 // Move the cursor (mouse is still down) outside the window. | 711 // Move the cursor (mouse is still down) outside the window. |
| 711 DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); | 712 DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); |
| 712 EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); | 713 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 713 | 714 |
| 714 // Release the cursor. We should now adapt the cursor of the window | 715 // Release the cursor. We should now adapt the cursor of the window |
| 715 // underneath the pointer. | 716 // underneath the pointer. |
| 716 DispatchEventAndAckImmediately(CreateMouseUpEvent(5, 5)); | 717 DispatchEventAndAckImmediately(CreateMouseUpEvent(5, 5)); |
| 717 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 718 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 718 } | 719 } |
| 719 | 720 |
| 720 TEST_F(WindowTreeTest, ChangingWindowBoundsChangesCursor) { | 721 TEST_F(WindowTreeTest, ChangingWindowBoundsChangesCursor) { |
| 721 TestWindowTreeClient* embed_connection = nullptr; | 722 TestWindowTreeClient* embed_connection = nullptr; |
| 722 WindowTreeImpl* window_tree_connection = nullptr; | 723 WindowTreeImpl* window_tree_connection = nullptr; |
| 723 ServerWindow* window = nullptr; | 724 ServerWindow* window = nullptr; |
| 724 EXPECT_NO_FATAL_FAILURE( | 725 EXPECT_NO_FATAL_FAILURE( |
| 725 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); | 726 SetupEventTargeting(&embed_connection, &window_tree_connection, &window)); |
| 726 | 727 |
| 727 // Put the cursor just outside the bounds of the window. | 728 // Put the cursor just outside the bounds of the window. |
| 728 DispatchEventAndAckImmediately(CreateMouseMoveEvent(41, 41)); | 729 DispatchEventAndAckImmediately(CreateMouseMoveEvent(41, 41)); |
| 729 window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); | 730 window->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 730 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 731 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 731 | 732 |
| 732 // Expand the bounds of the window so they now include where the cursor now | 733 // Expand the bounds of the window so they now include where the cursor now |
| 733 // is. | 734 // is. |
| 734 window->SetBounds(gfx::Rect(20, 20, 25, 25)); | 735 window->SetBounds(gfx::Rect(20, 20, 25, 25)); |
| 735 EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); | 736 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 736 | 737 |
| 737 // Contract the bounds again. | 738 // Contract the bounds again. |
| 738 window->SetBounds(gfx::Rect(20, 20, 20, 20)); | 739 window->SetBounds(gfx::Rect(20, 20, 20, 20)); |
| 739 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 740 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 740 } | 741 } |
| 741 | 742 |
| 742 TEST_F(WindowTreeTest, WindowReorderingChangesCursor) { | 743 TEST_F(WindowTreeTest, WindowReorderingChangesCursor) { |
| 743 TestWindowTreeClient* embed_connection = nullptr; | 744 TestWindowTreeClient* embed_connection = nullptr; |
| 744 WindowTreeImpl* window_tree_connection = nullptr; | 745 WindowTreeImpl* window_tree_connection = nullptr; |
| 745 ServerWindow* window1 = nullptr; | 746 ServerWindow* window1 = nullptr; |
| 746 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting( | 747 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting( |
| 747 &embed_connection, &window_tree_connection, &window1)); | 748 &embed_connection, &window_tree_connection, &window1)); |
| 748 | 749 |
| 749 // Create a second window right over the first. | 750 // Create a second window right over the first. |
| 750 const WindowId embed_window_id(wm_connection()->id(), 1); | 751 const WindowId embed_window_id(wm_connection()->id(), 1); |
| 751 const WindowId child2(window_tree_connection->id(), 2); | 752 const WindowId child2(window_tree_connection->id(), 2); |
| 752 EXPECT_TRUE( | 753 EXPECT_TRUE( |
| 753 window_tree_connection->NewWindow(child2, ServerWindow::Properties())); | 754 window_tree_connection->NewWindow(child2, ServerWindow::Properties())); |
| 754 EXPECT_TRUE(window_tree_connection->AddWindow(embed_window_id, child2)); | 755 EXPECT_TRUE(window_tree_connection->AddWindow(embed_window_id, child2)); |
| 755 window_tree_connection->GetHost( | 756 window_tree_connection->GetHost( |
| 756 GetWindowById(WindowId(wm_connection()->id(), 1))) | 757 GetWindowById(WindowId(wm_connection()->id(), 1))) |
| 757 ->AddActivationParent(WindowIdToTransportId(embed_window_id)); | 758 ->AddActivationParent(WindowIdToTransportId(embed_window_id)); |
| 758 ServerWindow* window2 = window_tree_connection->GetWindow(child2); | 759 ServerWindow* window2 = window_tree_connection->GetWindow(child2); |
| 759 window2->SetVisible(true); | 760 window2->SetVisible(true); |
| 760 window2->SetBounds(gfx::Rect(20, 20, 20, 20)); | 761 window2->SetBounds(gfx::Rect(20, 20, 20, 20)); |
| 761 EnableHitTest(window2); | 762 EnableHitTest(window2); |
| 762 | 763 |
| 763 // Give each window a different cursor. | 764 // Give each window a different cursor. |
| 764 window1->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); | 765 window1->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 765 window2->SetPredefinedCursor(mojom::Cursor::CURSOR_HAND); | 766 window2->SetPredefinedCursor(mojom::Cursor::HAND); |
| 766 | 767 |
| 767 // We expect window2 to be over window1 now. | 768 // We expect window2 to be over window1 now. |
| 768 DispatchEventAndAckImmediately(CreateMouseMoveEvent(22, 22)); | 769 DispatchEventAndAckImmediately(CreateMouseMoveEvent(22, 22)); |
| 769 EXPECT_EQ(mojom::Cursor::CURSOR_HAND, cursor_id()); | 770 EXPECT_EQ(mojom::Cursor::HAND, cursor_id()); |
| 770 | 771 |
| 771 // But when we put window2 at the bottom, we should adapt window1's cursor. | 772 // But when we put window2 at the bottom, we should adapt window1's cursor. |
| 772 window2->parent()->StackChildAtBottom(window2); | 773 window2->parent()->StackChildAtBottom(window2); |
| 773 EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); | 774 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 774 } | 775 } |
| 775 | 776 |
| 776 TEST_F(WindowTreeTest, EventAck) { | 777 TEST_F(WindowTreeTest, EventAck) { |
| 777 const WindowId embed_window_id(wm_connection()->id(), 1); | 778 const WindowId embed_window_id(wm_connection()->id(), 1); |
| 778 EXPECT_TRUE( | 779 EXPECT_TRUE( |
| 779 wm_connection()->NewWindow(embed_window_id, ServerWindow::Properties())); | 780 wm_connection()->NewWindow(embed_window_id, ServerWindow::Properties())); |
| 780 EXPECT_TRUE(wm_connection()->SetWindowVisibility(embed_window_id, true)); | 781 EXPECT_TRUE(wm_connection()->SetWindowVisibility(embed_window_id, true)); |
| 781 ASSERT_TRUE(FirstRoot(wm_connection())); | 782 ASSERT_TRUE(FirstRoot(wm_connection())); |
| 782 EXPECT_TRUE(wm_connection()->AddWindow(FirstRoot(wm_connection())->id(), | 783 EXPECT_TRUE(wm_connection()->AddWindow(FirstRoot(wm_connection())->id(), |
| 783 embed_window_id)); | 784 embed_window_id)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 SingleChangeToDescription(*embed_connection->tracker()->changes())); | 860 SingleChangeToDescription(*embed_connection->tracker()->changes())); |
| 860 | 861 |
| 861 // Set the visibility from the child using the client assigned id. | 862 // Set the visibility from the child using the client assigned id. |
| 862 ASSERT_TRUE(window_tree_connection->SetWindowVisibility( | 863 ASSERT_TRUE(window_tree_connection->SetWindowVisibility( |
| 863 embed_window_id2_in_child, false)); | 864 embed_window_id2_in_child, false)); |
| 864 EXPECT_FALSE(embed_window->visible()); | 865 EXPECT_FALSE(embed_window->visible()); |
| 865 } | 866 } |
| 866 | 867 |
| 867 } // namespace ws | 868 } // namespace ws |
| 868 } // namespace mus | 869 } // namespace mus |
| OLD | NEW |