| 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 "services/ui/ws/window_tree.h" | 5 #include "services/ui/ws/window_tree.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 ServerWindow** window) { | 205 ServerWindow** window) { |
| 206 ServerWindow* embed_window = window_event_targeting_helper_.CreatePrimaryTree( | 206 ServerWindow* embed_window = window_event_targeting_helper_.CreatePrimaryTree( |
| 207 gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 50, 50)); | 207 gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 50, 50)); |
| 208 window_event_targeting_helper_.CreateSecondaryTree( | 208 window_event_targeting_helper_.CreateSecondaryTree( |
| 209 embed_window, gfx::Rect(20, 20, 20, 20), out_client, window_tree, window); | 209 embed_window, gfx::Rect(20, 20, 20, 20), out_client, window_tree, window); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Verifies focus correctly changes on pointer events. | 212 // Verifies focus correctly changes on pointer events. |
| 213 TEST_F(WindowTreeTest, FocusOnPointer) { | 213 TEST_F(WindowTreeTest, FocusOnPointer) { |
| 214 const ClientWindowId embed_window_id = BuildClientWindowId(wm_tree(), 1); | 214 const ClientWindowId embed_window_id = BuildClientWindowId(wm_tree(), 1); |
| 215 EXPECT_TRUE( | 215 EXPECT_TRUE(wm_tree()->NewWindow(embed_window_id, ServerWindow::Properties(), |
| 216 wm_tree()->NewWindow(embed_window_id, ServerWindow::Properties())); | 216 cc::LocalFrameId())); |
| 217 ServerWindow* embed_window = wm_tree()->GetWindowByClientId(embed_window_id); | 217 ServerWindow* embed_window = wm_tree()->GetWindowByClientId(embed_window_id); |
| 218 ASSERT_TRUE(embed_window); | 218 ASSERT_TRUE(embed_window); |
| 219 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id, true)); | 219 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id, true)); |
| 220 ASSERT_TRUE(FirstRoot(wm_tree())); | 220 ASSERT_TRUE(FirstRoot(wm_tree())); |
| 221 const ClientWindowId wm_root_id = FirstRootId(wm_tree()); | 221 const ClientWindowId wm_root_id = FirstRootId(wm_tree()); |
| 222 EXPECT_TRUE(wm_tree()->AddWindow(wm_root_id, embed_window_id)); | 222 EXPECT_TRUE(wm_tree()->AddWindow(wm_root_id, embed_window_id)); |
| 223 ServerWindow* wm_root = FirstRoot(wm_tree()); | 223 ServerWindow* wm_root = FirstRoot(wm_tree()); |
| 224 ASSERT_TRUE(wm_root); | 224 ASSERT_TRUE(wm_root); |
| 225 wm_root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 225 wm_root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 226 EnableHitTest(wm_root); | 226 EnableHitTest(wm_root); |
| 227 display()->root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 227 display()->root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), |
| 228 cc::LocalFrameId()); |
| 228 mojom::WindowTreeClientPtr client; | 229 mojom::WindowTreeClientPtr client; |
| 229 mojom::WindowTreeClientRequest client_request(&client); | 230 mojom::WindowTreeClientRequest client_request(&client); |
| 230 wm_client()->Bind(std::move(client_request)); | 231 wm_client()->Bind(std::move(client_request)); |
| 231 const uint32_t embed_flags = 0; | 232 const uint32_t embed_flags = 0; |
| 232 wm_tree()->Embed(embed_window_id, std::move(client), embed_flags); | 233 wm_tree()->Embed(embed_window_id, std::move(client), embed_flags); |
| 233 WindowTree* tree1 = window_server()->GetTreeWithRoot(embed_window); | 234 WindowTree* tree1 = window_server()->GetTreeWithRoot(embed_window); |
| 234 ASSERT_TRUE(tree1 != nullptr); | 235 ASSERT_TRUE(tree1 != nullptr); |
| 235 ASSERT_NE(tree1, wm_tree()); | 236 ASSERT_NE(tree1, wm_tree()); |
| 236 | 237 |
| 237 embed_window->SetBounds(gfx::Rect(0, 0, 50, 50)); | 238 embed_window->SetBounds(gfx::Rect(0, 0, 50, 50), cc::LocalFrameId()); |
| 238 | 239 |
| 239 const ClientWindowId child1_id(BuildClientWindowId(tree1, 1)); | 240 const ClientWindowId child1_id(BuildClientWindowId(tree1, 1)); |
| 240 EXPECT_TRUE(tree1->NewWindow(child1_id, ServerWindow::Properties())); | 241 EXPECT_TRUE(tree1->NewWindow(child1_id, ServerWindow::Properties(), |
| 242 cc::LocalFrameId())); |
| 241 EXPECT_TRUE(tree1->AddWindow(ClientWindowIdForWindow(tree1, embed_window), | 243 EXPECT_TRUE(tree1->AddWindow(ClientWindowIdForWindow(tree1, embed_window), |
| 242 child1_id)); | 244 child1_id)); |
| 243 ServerWindow* child1 = tree1->GetWindowByClientId(child1_id); | 245 ServerWindow* child1 = tree1->GetWindowByClientId(child1_id); |
| 244 ASSERT_TRUE(child1); | 246 ASSERT_TRUE(child1); |
| 245 child1->SetVisible(true); | 247 child1->SetVisible(true); |
| 246 child1->SetBounds(gfx::Rect(20, 20, 20, 20)); | 248 child1->SetBounds(gfx::Rect(20, 20, 20, 20), cc::LocalFrameId()); |
| 247 EnableHitTest(child1); | 249 EnableHitTest(child1); |
| 248 | 250 |
| 249 TestWindowTreeClient* tree1_client = last_window_tree_client(); | 251 TestWindowTreeClient* tree1_client = last_window_tree_client(); |
| 250 tree1_client->tracker()->changes()->clear(); | 252 tree1_client->tracker()->changes()->clear(); |
| 251 wm_client()->tracker()->changes()->clear(); | 253 wm_client()->tracker()->changes()->clear(); |
| 252 | 254 |
| 253 // Focus should not go to |child1| yet, since the parent still doesn't allow | 255 // Focus should not go to |child1| yet, since the parent still doesn't allow |
| 254 // active children. | 256 // active children. |
| 255 DispatchEventAndAckImmediately(CreatePointerDownEvent(21, 22)); | 257 DispatchEventAndAckImmediately(CreatePointerDownEvent(21, 22)); |
| 256 Display* display1 = tree1->GetDisplay(embed_window); | 258 Display* display1 = tree1->GetDisplay(embed_window); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 ServerWindow* window = nullptr; | 553 ServerWindow* window = nullptr; |
| 552 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window)); | 554 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window)); |
| 553 | 555 |
| 554 // Put the cursor just outside the bounds of the window. | 556 // Put the cursor just outside the bounds of the window. |
| 555 DispatchEventAndAckImmediately(CreateMouseMoveEvent(41, 41)); | 557 DispatchEventAndAckImmediately(CreateMouseMoveEvent(41, 41)); |
| 556 window->SetPredefinedCursor(mojom::Cursor::IBEAM); | 558 window->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 557 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 559 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 558 | 560 |
| 559 // Expand the bounds of the window so they now include where the cursor now | 561 // Expand the bounds of the window so they now include where the cursor now |
| 560 // is. | 562 // is. |
| 561 window->SetBounds(gfx::Rect(20, 20, 25, 25)); | 563 window->SetBounds(gfx::Rect(20, 20, 25, 25), cc::LocalFrameId()); |
| 562 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); | 564 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 563 | 565 |
| 564 // Contract the bounds again. | 566 // Contract the bounds again. |
| 565 window->SetBounds(gfx::Rect(20, 20, 20, 20)); | 567 window->SetBounds(gfx::Rect(20, 20, 20, 20), cc::LocalFrameId()); |
| 566 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); | 568 EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); |
| 567 } | 569 } |
| 568 | 570 |
| 569 TEST_F(WindowTreeTest, WindowReorderingChangesCursor) { | 571 TEST_F(WindowTreeTest, WindowReorderingChangesCursor) { |
| 570 TestWindowTreeClient* embed_client = nullptr; | 572 TestWindowTreeClient* embed_client = nullptr; |
| 571 WindowTree* tree = nullptr; | 573 WindowTree* tree = nullptr; |
| 572 ServerWindow* window1 = nullptr; | 574 ServerWindow* window1 = nullptr; |
| 573 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window1)); | 575 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window1)); |
| 574 | 576 |
| 575 // Create a second window right over the first. | 577 // Create a second window right over the first. |
| 576 const ClientWindowId embed_window_id(FirstRootId(tree)); | 578 const ClientWindowId embed_window_id(FirstRootId(tree)); |
| 577 const ClientWindowId child2_id(BuildClientWindowId(tree, 2)); | 579 const ClientWindowId child2_id(BuildClientWindowId(tree, 2)); |
| 578 EXPECT_TRUE(tree->NewWindow(child2_id, ServerWindow::Properties())); | 580 EXPECT_TRUE(tree->NewWindow(child2_id, ServerWindow::Properties(), |
| 581 cc::LocalFrameId())); |
| 579 ServerWindow* child2 = tree->GetWindowByClientId(child2_id); | 582 ServerWindow* child2 = tree->GetWindowByClientId(child2_id); |
| 580 ASSERT_TRUE(child2); | 583 ASSERT_TRUE(child2); |
| 581 EXPECT_TRUE(tree->AddWindow(embed_window_id, child2_id)); | 584 EXPECT_TRUE(tree->AddWindow(embed_window_id, child2_id)); |
| 582 child2->SetVisible(true); | 585 child2->SetVisible(true); |
| 583 child2->SetBounds(gfx::Rect(20, 20, 20, 20)); | 586 child2->SetBounds(gfx::Rect(20, 20, 20, 20), cc::LocalFrameId()); |
| 584 EnableHitTest(child2); | 587 EnableHitTest(child2); |
| 585 | 588 |
| 586 // Give each window a different cursor. | 589 // Give each window a different cursor. |
| 587 window1->SetPredefinedCursor(mojom::Cursor::IBEAM); | 590 window1->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 588 child2->SetPredefinedCursor(mojom::Cursor::HAND); | 591 child2->SetPredefinedCursor(mojom::Cursor::HAND); |
| 589 | 592 |
| 590 // We expect window2 to be over window1 now. | 593 // We expect window2 to be over window1 now. |
| 591 DispatchEventAndAckImmediately(CreateMouseMoveEvent(22, 22)); | 594 DispatchEventAndAckImmediately(CreateMouseMoveEvent(22, 22)); |
| 592 EXPECT_EQ(mojom::Cursor::HAND, cursor_id()); | 595 EXPECT_EQ(mojom::Cursor::HAND, cursor_id()); |
| 593 | 596 |
| 594 // But when we put window2 at the bottom, we should adapt window1's cursor. | 597 // But when we put window2 at the bottom, we should adapt window1's cursor. |
| 595 child2->parent()->StackChildAtBottom(child2); | 598 child2->parent()->StackChildAtBottom(child2); |
| 596 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); | 599 EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); |
| 597 } | 600 } |
| 598 | 601 |
| 599 TEST_F(WindowTreeTest, EventAck) { | 602 TEST_F(WindowTreeTest, EventAck) { |
| 600 const ClientWindowId embed_window_id = BuildClientWindowId(wm_tree(), 1); | 603 const ClientWindowId embed_window_id = BuildClientWindowId(wm_tree(), 1); |
| 601 EXPECT_TRUE( | 604 EXPECT_TRUE(wm_tree()->NewWindow(embed_window_id, ServerWindow::Properties(), |
| 602 wm_tree()->NewWindow(embed_window_id, ServerWindow::Properties())); | 605 cc::LocalFrameId())); |
| 603 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id, true)); | 606 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id, true)); |
| 604 ASSERT_TRUE(FirstRoot(wm_tree())); | 607 ASSERT_TRUE(FirstRoot(wm_tree())); |
| 605 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id)); | 608 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id)); |
| 606 ASSERT_EQ(1u, display()->root_window()->children().size()); | 609 ASSERT_EQ(1u, display()->root_window()->children().size()); |
| 607 ServerWindow* wm_root = FirstRoot(wm_tree()); | 610 ServerWindow* wm_root = FirstRoot(wm_tree()); |
| 608 ASSERT_TRUE(wm_root); | 611 ASSERT_TRUE(wm_root); |
| 609 wm_root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 612 wm_root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 610 EnableHitTest(wm_root); | 613 EnableHitTest(wm_root); |
| 611 | 614 |
| 612 wm_client()->tracker()->changes()->clear(); | 615 wm_client()->tracker()->changes()->clear(); |
| 613 DispatchEventWithoutAck(CreateMouseMoveEvent(21, 22)); | 616 DispatchEventWithoutAck(CreateMouseMoveEvent(21, 22)); |
| 614 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); | 617 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); |
| 615 EXPECT_EQ("InputEvent window=0,3 event_action=17", | 618 EXPECT_EQ("InputEvent window=0,3 event_action=17", |
| 616 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 619 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
| 617 wm_client()->tracker()->changes()->clear(); | 620 wm_client()->tracker()->changes()->clear(); |
| 618 | 621 |
| 619 // Send another event. This event shouldn't reach the client. | 622 // Send another event. This event shouldn't reach the client. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 647 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, | 650 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, |
| 648 properties); | 651 properties); |
| 649 | 652 |
| 650 // The binding should be paused until the wm acks the change. | 653 // The binding should be paused until the wm acks the change. |
| 651 uint32_t wm_change_id = 0u; | 654 uint32_t wm_change_id = 0u; |
| 652 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); | 655 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); |
| 653 EXPECT_TRUE(child_binding->is_paused()); | 656 EXPECT_TRUE(child_binding->is_paused()); |
| 654 | 657 |
| 655 // Create the window for |embed_window_id2_in_child|. | 658 // Create the window for |embed_window_id2_in_child|. |
| 656 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); | 659 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); |
| 657 EXPECT_TRUE( | 660 EXPECT_TRUE(wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties(), |
| 658 wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties())); | 661 cc::LocalFrameId())); |
| 659 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); | 662 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); |
| 660 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); | 663 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); |
| 661 | 664 |
| 662 // Ack the change, which should resume the binding. | 665 // Ack the change, which should resume the binding. |
| 663 child_binding->client()->tracker()->changes()->clear(); | 666 child_binding->client()->tracker()->changes()->clear(); |
| 664 static_cast<mojom::WindowManagerClient*>(wm_tree()) | 667 static_cast<mojom::WindowManagerClient*>(wm_tree()) |
| 665 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); | 668 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); |
| 666 EXPECT_FALSE(child_binding->is_paused()); | 669 EXPECT_FALSE(child_binding->is_paused()); |
| 667 EXPECT_EQ("TopLevelCreated id=17 window_id=" + | 670 EXPECT_EQ("TopLevelCreated id=17 window_id=" + |
| 668 WindowIdToString( | 671 WindowIdToString( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 693 } | 696 } |
| 694 | 697 |
| 695 // Tests that only the capture window can release capture. | 698 // Tests that only the capture window can release capture. |
| 696 TEST_F(WindowTreeTest, ExplicitSetCapture) { | 699 TEST_F(WindowTreeTest, ExplicitSetCapture) { |
| 697 TestWindowTreeClient* embed_client = nullptr; | 700 TestWindowTreeClient* embed_client = nullptr; |
| 698 WindowTree* tree = nullptr; | 701 WindowTree* tree = nullptr; |
| 699 ServerWindow* window = nullptr; | 702 ServerWindow* window = nullptr; |
| 700 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window)); | 703 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window)); |
| 701 const ServerWindow* root_window = *tree->roots().begin(); | 704 const ServerWindow* root_window = *tree->roots().begin(); |
| 702 tree->AddWindow(FirstRootId(tree), ClientWindowIdForWindow(tree, window)); | 705 tree->AddWindow(FirstRootId(tree), ClientWindowIdForWindow(tree, window)); |
| 703 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 706 window->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 704 ASSERT_TRUE(tree->GetDisplay(window)); | 707 ASSERT_TRUE(tree->GetDisplay(window)); |
| 705 | 708 |
| 706 // Set capture. | 709 // Set capture. |
| 707 mojom::WindowTree* mojom_window_tree = static_cast<mojom::WindowTree*>(tree); | 710 mojom::WindowTree* mojom_window_tree = static_cast<mojom::WindowTree*>(tree); |
| 708 uint32_t change_id = 42; | 711 uint32_t change_id = 42; |
| 709 mojom_window_tree->SetCapture(change_id, WindowIdToTransportId(window->id())); | 712 mojom_window_tree->SetCapture(change_id, WindowIdToTransportId(window->id())); |
| 710 Display* display = tree->GetDisplay(window); | 713 Display* display = tree->GetDisplay(window); |
| 711 EXPECT_EQ(window, GetCaptureWindow(display)); | 714 EXPECT_EQ(window, GetCaptureWindow(display)); |
| 712 | 715 |
| 713 // Only the capture window should be able to release capture | 716 // Only the capture window should be able to release capture |
| 714 mojom_window_tree->ReleaseCapture(++change_id, | 717 mojom_window_tree->ReleaseCapture(++change_id, |
| 715 WindowIdToTransportId(root_window->id())); | 718 WindowIdToTransportId(root_window->id())); |
| 716 EXPECT_EQ(window, GetCaptureWindow(display)); | 719 EXPECT_EQ(window, GetCaptureWindow(display)); |
| 717 mojom_window_tree->ReleaseCapture(++change_id, | 720 mojom_window_tree->ReleaseCapture(++change_id, |
| 718 WindowIdToTransportId(window->id())); | 721 WindowIdToTransportId(window->id())); |
| 719 EXPECT_EQ(nullptr, GetCaptureWindow(display)); | 722 EXPECT_EQ(nullptr, GetCaptureWindow(display)); |
| 720 } | 723 } |
| 721 | 724 |
| 722 // Tests that while a client is interacting with input, that capture is not | 725 // Tests that while a client is interacting with input, that capture is not |
| 723 // allowed for invisible windows. | 726 // allowed for invisible windows. |
| 724 TEST_F(WindowTreeTest, CaptureWindowMustBeVisible) { | 727 TEST_F(WindowTreeTest, CaptureWindowMustBeVisible) { |
| 725 TestWindowTreeClient* embed_client = nullptr; | 728 TestWindowTreeClient* embed_client = nullptr; |
| 726 WindowTree* tree = nullptr; | 729 WindowTree* tree = nullptr; |
| 727 ServerWindow* window = nullptr; | 730 ServerWindow* window = nullptr; |
| 728 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window)); | 731 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window)); |
| 729 tree->AddWindow(FirstRootId(tree), ClientWindowIdForWindow(tree, window)); | 732 tree->AddWindow(FirstRootId(tree), ClientWindowIdForWindow(tree, window)); |
| 730 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 733 window->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 731 ASSERT_TRUE(tree->GetDisplay(window)); | 734 ASSERT_TRUE(tree->GetDisplay(window)); |
| 732 | 735 |
| 733 DispatchEventWithoutAck(CreatePointerDownEvent(10, 10)); | 736 DispatchEventWithoutAck(CreatePointerDownEvent(10, 10)); |
| 734 window->SetVisible(false); | 737 window->SetVisible(false); |
| 735 EXPECT_FALSE(tree->SetCapture(ClientWindowIdForWindow(tree, window))); | 738 EXPECT_FALSE(tree->SetCapture(ClientWindowIdForWindow(tree, window))); |
| 736 EXPECT_NE(window, GetCaptureWindow(tree->GetDisplay(window))); | 739 EXPECT_NE(window, GetCaptureWindow(tree->GetDisplay(window))); |
| 737 } | 740 } |
| 738 | 741 |
| 739 // Tests that showing a modal window releases the capture if the capture is on a | 742 // Tests that showing a modal window releases the capture if the capture is on a |
| 740 // descendant of the modal parent. | 743 // descendant of the modal parent. |
| 741 TEST_F(WindowTreeTest, ShowModalWindowWithDescendantCapture) { | 744 TEST_F(WindowTreeTest, ShowModalWindowWithDescendantCapture) { |
| 742 TestWindowTreeClient* embed_client = nullptr; | 745 TestWindowTreeClient* embed_client = nullptr; |
| 743 WindowTree* tree = nullptr; | 746 WindowTree* tree = nullptr; |
| 744 ServerWindow* w1 = nullptr; | 747 ServerWindow* w1 = nullptr; |
| 745 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); | 748 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); |
| 746 | 749 |
| 747 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 750 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 748 const ServerWindow* root_window = *tree->roots().begin(); | 751 const ServerWindow* root_window = *tree->roots().begin(); |
| 749 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); | 752 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); |
| 750 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); | 753 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); |
| 751 Display* display = tree->GetDisplay(w1); | 754 Display* display = tree->GetDisplay(w1); |
| 752 | 755 |
| 753 // Create |w11| as a child of |w1| and make it visible. | 756 // Create |w11| as a child of |w1| and make it visible. |
| 754 ClientWindowId w11_id = BuildClientWindowId(tree, 11); | 757 ClientWindowId w11_id = BuildClientWindowId(tree, 11); |
| 755 ASSERT_TRUE(tree->NewWindow(w11_id, ServerWindow::Properties())); | 758 ASSERT_TRUE( |
| 759 tree->NewWindow(w11_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 756 ServerWindow* w11 = tree->GetWindowByClientId(w11_id); | 760 ServerWindow* w11 = tree->GetWindowByClientId(w11_id); |
| 757 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 761 w11->SetBounds(gfx::Rect(10, 10, 10, 10), cc::LocalFrameId()); |
| 758 ASSERT_TRUE(tree->AddWindow(w1_id, w11_id)); | 762 ASSERT_TRUE(tree->AddWindow(w1_id, w11_id)); |
| 759 ASSERT_TRUE(tree->SetWindowVisibility(w11_id, true)); | 763 ASSERT_TRUE(tree->SetWindowVisibility(w11_id, true)); |
| 760 | 764 |
| 761 // Create |w2| as a child of |root_window| and modal to |w1| and leave it | 765 // Create |w2| as a child of |root_window| and modal to |w1| and leave it |
| 762 // hidden. | 766 // hidden. |
| 763 ClientWindowId w2_id = BuildClientWindowId(tree, 2); | 767 ClientWindowId w2_id = BuildClientWindowId(tree, 2); |
| 764 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties())); | 768 ASSERT_TRUE( |
| 769 tree->NewWindow(w2_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 765 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); | 770 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); |
| 766 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 771 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 767 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); | 772 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); |
| 768 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); | 773 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); |
| 769 ASSERT_TRUE(tree->SetModal(w2_id)); | 774 ASSERT_TRUE(tree->SetModal(w2_id)); |
| 770 | 775 |
| 771 // Set capture to |w11|. | 776 // Set capture to |w11|. |
| 772 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); | 777 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); |
| 773 ASSERT_TRUE(tree->SetCapture(w11_id)); | 778 ASSERT_TRUE(tree->SetCapture(w11_id)); |
| 774 EXPECT_EQ(w11, GetCaptureWindow(display)); | 779 EXPECT_EQ(w11, GetCaptureWindow(display)); |
| 775 AckPreviousEvent(); | 780 AckPreviousEvent(); |
| 776 | 781 |
| 777 // Make |w2| visible. This should release capture as capture is set to a | 782 // Make |w2| visible. This should release capture as capture is set to a |
| 778 // descendant of the modal parent. | 783 // descendant of the modal parent. |
| 779 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); | 784 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); |
| 780 EXPECT_EQ(nullptr, GetCaptureWindow(display)); | 785 EXPECT_EQ(nullptr, GetCaptureWindow(display)); |
| 781 } | 786 } |
| 782 | 787 |
| 783 // Tests that setting a visible window as modal releases the capture if the | 788 // Tests that setting a visible window as modal releases the capture if the |
| 784 // capture is on a descendant of the modal parent. | 789 // capture is on a descendant of the modal parent. |
| 785 TEST_F(WindowTreeTest, VisibleWindowToModalWithDescendantCapture) { | 790 TEST_F(WindowTreeTest, VisibleWindowToModalWithDescendantCapture) { |
| 786 TestWindowTreeClient* embed_client = nullptr; | 791 TestWindowTreeClient* embed_client = nullptr; |
| 787 WindowTree* tree = nullptr; | 792 WindowTree* tree = nullptr; |
| 788 ServerWindow* w1 = nullptr; | 793 ServerWindow* w1 = nullptr; |
| 789 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); | 794 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); |
| 790 | 795 |
| 791 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 796 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 792 const ServerWindow* root_window = *tree->roots().begin(); | 797 const ServerWindow* root_window = *tree->roots().begin(); |
| 793 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); | 798 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); |
| 794 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); | 799 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); |
| 795 Display* display = tree->GetDisplay(w1); | 800 Display* display = tree->GetDisplay(w1); |
| 796 | 801 |
| 797 // Create |w11| as a child of |w1| and make it visible. | 802 // Create |w11| as a child of |w1| and make it visible. |
| 798 ClientWindowId w11_id = BuildClientWindowId(tree, 11); | 803 ClientWindowId w11_id = BuildClientWindowId(tree, 11); |
| 799 ASSERT_TRUE(tree->NewWindow(w11_id, ServerWindow::Properties())); | 804 ASSERT_TRUE( |
| 805 tree->NewWindow(w11_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 800 ServerWindow* w11 = tree->GetWindowByClientId(w11_id); | 806 ServerWindow* w11 = tree->GetWindowByClientId(w11_id); |
| 801 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 807 w11->SetBounds(gfx::Rect(10, 10, 10, 10), cc::LocalFrameId()); |
| 802 ASSERT_TRUE(tree->AddWindow(w1_id, w11_id)); | 808 ASSERT_TRUE(tree->AddWindow(w1_id, w11_id)); |
| 803 ASSERT_TRUE(tree->SetWindowVisibility(w11_id, true)); | 809 ASSERT_TRUE(tree->SetWindowVisibility(w11_id, true)); |
| 804 | 810 |
| 805 // Create |w2| as a child of |root_window| and make it visible. | 811 // Create |w2| as a child of |root_window| and make it visible. |
| 806 ClientWindowId w2_id = BuildClientWindowId(tree, 2); | 812 ClientWindowId w2_id = BuildClientWindowId(tree, 2); |
| 807 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties())); | 813 ASSERT_TRUE( |
| 814 tree->NewWindow(w2_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 808 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); | 815 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); |
| 809 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 816 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 810 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); | 817 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); |
| 811 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); | 818 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); |
| 812 | 819 |
| 813 // Set capture to |w11|. | 820 // Set capture to |w11|. |
| 814 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); | 821 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); |
| 815 ASSERT_TRUE(tree->SetCapture(w11_id)); | 822 ASSERT_TRUE(tree->SetCapture(w11_id)); |
| 816 EXPECT_EQ(w11, GetCaptureWindow(display)); | 823 EXPECT_EQ(w11, GetCaptureWindow(display)); |
| 817 AckPreviousEvent(); | 824 AckPreviousEvent(); |
| 818 | 825 |
| 819 // Set |w2| modal to |w1|. This should release the capture as the capture is | 826 // Set |w2| modal to |w1|. This should release the capture as the capture is |
| 820 // set to a descendant of the modal parent. | 827 // set to a descendant of the modal parent. |
| 821 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); | 828 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); |
| 822 ASSERT_TRUE(tree->SetModal(w2_id)); | 829 ASSERT_TRUE(tree->SetModal(w2_id)); |
| 823 EXPECT_EQ(nullptr, GetCaptureWindow(display)); | 830 EXPECT_EQ(nullptr, GetCaptureWindow(display)); |
| 824 } | 831 } |
| 825 | 832 |
| 826 // Tests that showing a modal window does not change capture if the capture is | 833 // Tests that showing a modal window does not change capture if the capture is |
| 827 // not on a descendant of the modal parent. | 834 // not on a descendant of the modal parent. |
| 828 TEST_F(WindowTreeTest, ShowModalWindowWithNonDescendantCapture) { | 835 TEST_F(WindowTreeTest, ShowModalWindowWithNonDescendantCapture) { |
| 829 TestWindowTreeClient* embed_client = nullptr; | 836 TestWindowTreeClient* embed_client = nullptr; |
| 830 WindowTree* tree = nullptr; | 837 WindowTree* tree = nullptr; |
| 831 ServerWindow* w1 = nullptr; | 838 ServerWindow* w1 = nullptr; |
| 832 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); | 839 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); |
| 833 | 840 |
| 834 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 841 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 835 const ServerWindow* root_window = *tree->roots().begin(); | 842 const ServerWindow* root_window = *tree->roots().begin(); |
| 836 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); | 843 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); |
| 837 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); | 844 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); |
| 838 Display* display = tree->GetDisplay(w1); | 845 Display* display = tree->GetDisplay(w1); |
| 839 | 846 |
| 840 // Create |w2| as a child of |root_window| and modal to |w1| and leave it | 847 // Create |w2| as a child of |root_window| and modal to |w1| and leave it |
| 841 // hidden.. | 848 // hidden.. |
| 842 ClientWindowId w2_id = BuildClientWindowId(tree, 2); | 849 ClientWindowId w2_id = BuildClientWindowId(tree, 2); |
| 843 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties())); | 850 ASSERT_TRUE( |
| 851 tree->NewWindow(w2_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 844 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); | 852 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); |
| 845 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 853 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 846 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); | 854 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); |
| 847 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); | 855 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); |
| 848 ASSERT_TRUE(tree->SetModal(w2_id)); | 856 ASSERT_TRUE(tree->SetModal(w2_id)); |
| 849 | 857 |
| 850 // Create |w3| as a child of |root_window| and make it visible. | 858 // Create |w3| as a child of |root_window| and make it visible. |
| 851 ClientWindowId w3_id = BuildClientWindowId(tree, 3); | 859 ClientWindowId w3_id = BuildClientWindowId(tree, 3); |
| 852 ASSERT_TRUE(tree->NewWindow(w3_id, ServerWindow::Properties())); | 860 ASSERT_TRUE( |
| 861 tree->NewWindow(w3_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 853 ServerWindow* w3 = tree->GetWindowByClientId(w3_id); | 862 ServerWindow* w3 = tree->GetWindowByClientId(w3_id); |
| 854 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); | 863 w3->SetBounds(gfx::Rect(70, 10, 10, 10), cc::LocalFrameId()); |
| 855 ASSERT_TRUE(tree->AddWindow(root_window_id, w3_id)); | 864 ASSERT_TRUE(tree->AddWindow(root_window_id, w3_id)); |
| 856 ASSERT_TRUE(tree->SetWindowVisibility(w3_id, true)); | 865 ASSERT_TRUE(tree->SetWindowVisibility(w3_id, true)); |
| 857 | 866 |
| 858 // Set capture to |w3|. | 867 // Set capture to |w3|. |
| 859 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); | 868 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); |
| 860 ASSERT_TRUE(tree->SetCapture(w3_id)); | 869 ASSERT_TRUE(tree->SetCapture(w3_id)); |
| 861 EXPECT_EQ(w3, GetCaptureWindow(display)); | 870 EXPECT_EQ(w3, GetCaptureWindow(display)); |
| 862 AckPreviousEvent(); | 871 AckPreviousEvent(); |
| 863 | 872 |
| 864 // Make |w2| visible. This should not change the capture as the capture is not | 873 // Make |w2| visible. This should not change the capture as the capture is not |
| 865 // set to a descendant of the modal parent. | 874 // set to a descendant of the modal parent. |
| 866 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); | 875 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); |
| 867 EXPECT_EQ(w3, GetCaptureWindow(display)); | 876 EXPECT_EQ(w3, GetCaptureWindow(display)); |
| 868 } | 877 } |
| 869 | 878 |
| 870 // Tests that setting a visible window as modal does not change the capture if | 879 // Tests that setting a visible window as modal does not change the capture if |
| 871 // the capture is not set to a descendant of the modal parent. | 880 // the capture is not set to a descendant of the modal parent. |
| 872 TEST_F(WindowTreeTest, VisibleWindowToModalWithNonDescendantCapture) { | 881 TEST_F(WindowTreeTest, VisibleWindowToModalWithNonDescendantCapture) { |
| 873 TestWindowTreeClient* embed_client = nullptr; | 882 TestWindowTreeClient* embed_client = nullptr; |
| 874 WindowTree* tree = nullptr; | 883 WindowTree* tree = nullptr; |
| 875 ServerWindow* w1 = nullptr; | 884 ServerWindow* w1 = nullptr; |
| 876 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); | 885 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); |
| 877 | 886 |
| 878 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 887 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 879 const ServerWindow* root_window = *tree->roots().begin(); | 888 const ServerWindow* root_window = *tree->roots().begin(); |
| 880 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); | 889 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); |
| 881 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); | 890 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); |
| 882 Display* display = tree->GetDisplay(w1); | 891 Display* display = tree->GetDisplay(w1); |
| 883 | 892 |
| 884 // Create |w2| and |w3| as children of |root_window| and make them visible. | 893 // Create |w2| and |w3| as children of |root_window| and make them visible. |
| 885 ClientWindowId w2_id = BuildClientWindowId(tree, 2); | 894 ClientWindowId w2_id = BuildClientWindowId(tree, 2); |
| 886 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties())); | 895 ASSERT_TRUE( |
| 896 tree->NewWindow(w2_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 887 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); | 897 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); |
| 888 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 898 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 889 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); | 899 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); |
| 890 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); | 900 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); |
| 891 | 901 |
| 892 ClientWindowId w3_id = BuildClientWindowId(tree, 3); | 902 ClientWindowId w3_id = BuildClientWindowId(tree, 3); |
| 893 ASSERT_TRUE(tree->NewWindow(w3_id, ServerWindow::Properties())); | 903 ASSERT_TRUE( |
| 904 tree->NewWindow(w3_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 894 ServerWindow* w3 = tree->GetWindowByClientId(w3_id); | 905 ServerWindow* w3 = tree->GetWindowByClientId(w3_id); |
| 895 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); | 906 w3->SetBounds(gfx::Rect(70, 10, 10, 10), cc::LocalFrameId()); |
| 896 ASSERT_TRUE(tree->AddWindow(root_window_id, w3_id)); | 907 ASSERT_TRUE(tree->AddWindow(root_window_id, w3_id)); |
| 897 ASSERT_TRUE(tree->SetWindowVisibility(w3_id, true)); | 908 ASSERT_TRUE(tree->SetWindowVisibility(w3_id, true)); |
| 898 | 909 |
| 899 // Set capture to |w3|. | 910 // Set capture to |w3|. |
| 900 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); | 911 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); |
| 901 ASSERT_TRUE(tree->SetCapture(w3_id)); | 912 ASSERT_TRUE(tree->SetCapture(w3_id)); |
| 902 EXPECT_EQ(w3, GetCaptureWindow(display)); | 913 EXPECT_EQ(w3, GetCaptureWindow(display)); |
| 903 AckPreviousEvent(); | 914 AckPreviousEvent(); |
| 904 | 915 |
| 905 // Set |w2| modal to |w1|. This should not release the capture as the capture | 916 // Set |w2| modal to |w1|. This should not release the capture as the capture |
| 906 // is not set to a descendant of the modal parent. | 917 // is not set to a descendant of the modal parent. |
| 907 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); | 918 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); |
| 908 ASSERT_TRUE(tree->SetModal(w2_id)); | 919 ASSERT_TRUE(tree->SetModal(w2_id)); |
| 909 EXPECT_EQ(w3, GetCaptureWindow(display)); | 920 EXPECT_EQ(w3, GetCaptureWindow(display)); |
| 910 } | 921 } |
| 911 | 922 |
| 912 // Tests that showing a system modal window releases the capture. | 923 // Tests that showing a system modal window releases the capture. |
| 913 TEST_F(WindowTreeTest, ShowSystemModalWindowWithCapture) { | 924 TEST_F(WindowTreeTest, ShowSystemModalWindowWithCapture) { |
| 914 TestWindowTreeClient* embed_client = nullptr; | 925 TestWindowTreeClient* embed_client = nullptr; |
| 915 WindowTree* tree = nullptr; | 926 WindowTree* tree = nullptr; |
| 916 ServerWindow* w1 = nullptr; | 927 ServerWindow* w1 = nullptr; |
| 917 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); | 928 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); |
| 918 | 929 |
| 919 w1->SetBounds(gfx::Rect(10, 10, 10, 10)); | 930 w1->SetBounds(gfx::Rect(10, 10, 10, 10), cc::LocalFrameId()); |
| 920 const ServerWindow* root_window = *tree->roots().begin(); | 931 const ServerWindow* root_window = *tree->roots().begin(); |
| 921 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); | 932 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); |
| 922 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); | 933 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); |
| 923 Display* display = tree->GetDisplay(w1); | 934 Display* display = tree->GetDisplay(w1); |
| 924 | 935 |
| 925 // Create a system modal window |w2| as a child of |root_window| and leave it | 936 // Create a system modal window |w2| as a child of |root_window| and leave it |
| 926 // hidden. | 937 // hidden. |
| 927 ClientWindowId w2_id = BuildClientWindowId(tree, 2); | 938 ClientWindowId w2_id = BuildClientWindowId(tree, 2); |
| 928 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties())); | 939 ASSERT_TRUE( |
| 940 tree->NewWindow(w2_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 929 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); | 941 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); |
| 930 w2->SetBounds(gfx::Rect(30, 10, 10, 10)); | 942 w2->SetBounds(gfx::Rect(30, 10, 10, 10), cc::LocalFrameId()); |
| 931 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); | 943 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); |
| 932 ASSERT_TRUE(tree->SetModal(w2_id)); | 944 ASSERT_TRUE(tree->SetModal(w2_id)); |
| 933 | 945 |
| 934 // Set capture to |w1|. | 946 // Set capture to |w1|. |
| 935 DispatchEventWithoutAck(CreatePointerDownEvent(15, 15)); | 947 DispatchEventWithoutAck(CreatePointerDownEvent(15, 15)); |
| 936 ASSERT_TRUE(tree->SetCapture(w1_id)); | 948 ASSERT_TRUE(tree->SetCapture(w1_id)); |
| 937 EXPECT_EQ(w1, GetCaptureWindow(display)); | 949 EXPECT_EQ(w1, GetCaptureWindow(display)); |
| 938 AckPreviousEvent(); | 950 AckPreviousEvent(); |
| 939 | 951 |
| 940 // Make |w2| visible. This should release capture as it is system modal | 952 // Make |w2| visible. This should release capture as it is system modal |
| 941 // window. | 953 // window. |
| 942 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); | 954 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); |
| 943 EXPECT_EQ(nullptr, GetCaptureWindow(display)); | 955 EXPECT_EQ(nullptr, GetCaptureWindow(display)); |
| 944 } | 956 } |
| 945 | 957 |
| 946 // Tests that setting a visible window as modal to system releases the capture. | 958 // Tests that setting a visible window as modal to system releases the capture. |
| 947 TEST_F(WindowTreeTest, VisibleWindowToSystemModalWithCapture) { | 959 TEST_F(WindowTreeTest, VisibleWindowToSystemModalWithCapture) { |
| 948 TestWindowTreeClient* embed_client = nullptr; | 960 TestWindowTreeClient* embed_client = nullptr; |
| 949 WindowTree* tree = nullptr; | 961 WindowTree* tree = nullptr; |
| 950 ServerWindow* w1 = nullptr; | 962 ServerWindow* w1 = nullptr; |
| 951 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); | 963 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); |
| 952 | 964 |
| 953 w1->SetBounds(gfx::Rect(10, 10, 10, 10)); | 965 w1->SetBounds(gfx::Rect(10, 10, 10, 10), cc::LocalFrameId()); |
| 954 const ServerWindow* root_window = *tree->roots().begin(); | 966 const ServerWindow* root_window = *tree->roots().begin(); |
| 955 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); | 967 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); |
| 956 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); | 968 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); |
| 957 Display* display = tree->GetDisplay(w1); | 969 Display* display = tree->GetDisplay(w1); |
| 958 | 970 |
| 959 // Create |w2| as a child of |root_window| and make it visible. | 971 // Create |w2| as a child of |root_window| and make it visible. |
| 960 ClientWindowId w2_id = BuildClientWindowId(tree, 2); | 972 ClientWindowId w2_id = BuildClientWindowId(tree, 2); |
| 961 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties())); | 973 ASSERT_TRUE( |
| 974 tree->NewWindow(w2_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 962 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); | 975 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); |
| 963 w2->SetBounds(gfx::Rect(30, 10, 10, 10)); | 976 w2->SetBounds(gfx::Rect(30, 10, 10, 10), cc::LocalFrameId()); |
| 964 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); | 977 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); |
| 965 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); | 978 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); |
| 966 | 979 |
| 967 // Set capture to |w1|. | 980 // Set capture to |w1|. |
| 968 DispatchEventWithoutAck(CreatePointerDownEvent(15, 15)); | 981 DispatchEventWithoutAck(CreatePointerDownEvent(15, 15)); |
| 969 ASSERT_TRUE(tree->SetCapture(w1_id)); | 982 ASSERT_TRUE(tree->SetCapture(w1_id)); |
| 970 EXPECT_EQ(w1, GetCaptureWindow(display)); | 983 EXPECT_EQ(w1, GetCaptureWindow(display)); |
| 971 AckPreviousEvent(); | 984 AckPreviousEvent(); |
| 972 | 985 |
| 973 // Make |w2| modal to system. This should release capture. | 986 // Make |w2| modal to system. This should release capture. |
| 974 ASSERT_TRUE(tree->SetModal(w2_id)); | 987 ASSERT_TRUE(tree->SetModal(w2_id)); |
| 975 EXPECT_EQ(nullptr, GetCaptureWindow(display)); | 988 EXPECT_EQ(nullptr, GetCaptureWindow(display)); |
| 976 } | 989 } |
| 977 | 990 |
| 978 // Tests that moving the capture window to a modal parent releases the capture | 991 // Tests that moving the capture window to a modal parent releases the capture |
| 979 // as capture cannot be blocked by a modal window. | 992 // as capture cannot be blocked by a modal window. |
| 980 TEST_F(WindowTreeTest, MoveCaptureWindowToModalParent) { | 993 TEST_F(WindowTreeTest, MoveCaptureWindowToModalParent) { |
| 981 TestWindowTreeClient* embed_client = nullptr; | 994 TestWindowTreeClient* embed_client = nullptr; |
| 982 WindowTree* tree = nullptr; | 995 WindowTree* tree = nullptr; |
| 983 ServerWindow* w1 = nullptr; | 996 ServerWindow* w1 = nullptr; |
| 984 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); | 997 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &w1)); |
| 985 | 998 |
| 986 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 999 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 987 const ServerWindow* root_window = *tree->roots().begin(); | 1000 const ServerWindow* root_window = *tree->roots().begin(); |
| 988 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); | 1001 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window); |
| 989 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); | 1002 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1); |
| 990 Display* display = tree->GetDisplay(w1); | 1003 Display* display = tree->GetDisplay(w1); |
| 991 | 1004 |
| 992 // Create |w2| and |w3| as children of |root_window| and make them visible. | 1005 // Create |w2| and |w3| as children of |root_window| and make them visible. |
| 993 ClientWindowId w2_id = BuildClientWindowId(tree, 2); | 1006 ClientWindowId w2_id = BuildClientWindowId(tree, 2); |
| 994 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties())); | 1007 ASSERT_TRUE( |
| 1008 tree->NewWindow(w2_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 995 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); | 1009 ServerWindow* w2 = tree->GetWindowByClientId(w2_id); |
| 996 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1010 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 997 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); | 1011 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id)); |
| 998 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); | 1012 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true)); |
| 999 | 1013 |
| 1000 ClientWindowId w3_id = BuildClientWindowId(tree, 3); | 1014 ClientWindowId w3_id = BuildClientWindowId(tree, 3); |
| 1001 ASSERT_TRUE(tree->NewWindow(w3_id, ServerWindow::Properties())); | 1015 ASSERT_TRUE( |
| 1016 tree->NewWindow(w3_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 1002 ServerWindow* w3 = tree->GetWindowByClientId(w3_id); | 1017 ServerWindow* w3 = tree->GetWindowByClientId(w3_id); |
| 1003 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); | 1018 w3->SetBounds(gfx::Rect(70, 10, 10, 10), cc::LocalFrameId()); |
| 1004 ASSERT_TRUE(tree->AddWindow(root_window_id, w3_id)); | 1019 ASSERT_TRUE(tree->AddWindow(root_window_id, w3_id)); |
| 1005 ASSERT_TRUE(tree->SetWindowVisibility(w3_id, true)); | 1020 ASSERT_TRUE(tree->SetWindowVisibility(w3_id, true)); |
| 1006 | 1021 |
| 1007 // Set |w2| modal to |w1|. | 1022 // Set |w2| modal to |w1|. |
| 1008 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); | 1023 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); |
| 1009 ASSERT_TRUE(tree->SetModal(w2_id)); | 1024 ASSERT_TRUE(tree->SetModal(w2_id)); |
| 1010 | 1025 |
| 1011 // Set capture to |w3|. | 1026 // Set capture to |w3|. |
| 1012 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); | 1027 DispatchEventWithoutAck(CreatePointerDownEvent(25, 25)); |
| 1013 ASSERT_TRUE(tree->SetCapture(w3_id)); | 1028 ASSERT_TRUE(tree->SetCapture(w3_id)); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, | 1111 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, |
| 1097 properties); | 1112 properties); |
| 1098 | 1113 |
| 1099 // The binding should be paused until the wm acks the change. | 1114 // The binding should be paused until the wm acks the change. |
| 1100 uint32_t wm_change_id = 0u; | 1115 uint32_t wm_change_id = 0u; |
| 1101 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); | 1116 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); |
| 1102 EXPECT_TRUE(child_binding->is_paused()); | 1117 EXPECT_TRUE(child_binding->is_paused()); |
| 1103 | 1118 |
| 1104 // Create the window for |embed_window_id2_in_child|. | 1119 // Create the window for |embed_window_id2_in_child|. |
| 1105 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); | 1120 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); |
| 1106 EXPECT_TRUE( | 1121 EXPECT_TRUE(wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties(), |
| 1107 wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties())); | 1122 cc::LocalFrameId())); |
| 1108 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); | 1123 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); |
| 1109 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); | 1124 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); |
| 1110 | 1125 |
| 1111 // Ack the change, which should resume the binding. | 1126 // Ack the change, which should resume the binding. |
| 1112 child_binding->client()->tracker()->changes()->clear(); | 1127 child_binding->client()->tracker()->changes()->clear(); |
| 1113 static_cast<mojom::WindowManagerClient*>(wm_tree()) | 1128 static_cast<mojom::WindowManagerClient*>(wm_tree()) |
| 1114 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); | 1129 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); |
| 1115 EXPECT_FALSE(child_binding->is_paused()); | 1130 EXPECT_FALSE(child_binding->is_paused()); |
| 1116 | 1131 |
| 1117 // The child_tree is the one that has to make this call; the | 1132 // The child_tree is the one that has to make this call; the |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1141 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, | 1156 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, |
| 1142 properties); | 1157 properties); |
| 1143 | 1158 |
| 1144 // The binding should be paused until the wm acks the change. | 1159 // The binding should be paused until the wm acks the change. |
| 1145 uint32_t wm_change_id = 0u; | 1160 uint32_t wm_change_id = 0u; |
| 1146 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); | 1161 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); |
| 1147 EXPECT_TRUE(child_binding->is_paused()); | 1162 EXPECT_TRUE(child_binding->is_paused()); |
| 1148 | 1163 |
| 1149 // Create the window for |embed_window_id2_in_child|. | 1164 // Create the window for |embed_window_id2_in_child|. |
| 1150 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); | 1165 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); |
| 1151 EXPECT_TRUE( | 1166 EXPECT_TRUE(wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties(), |
| 1152 wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties())); | 1167 cc::LocalFrameId())); |
| 1153 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); | 1168 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); |
| 1154 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); | 1169 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); |
| 1155 | 1170 |
| 1156 // Ack the change, which should resume the binding. | 1171 // Ack the change, which should resume the binding. |
| 1157 child_binding->client()->tracker()->changes()->clear(); | 1172 child_binding->client()->tracker()->changes()->clear(); |
| 1158 static_cast<mojom::WindowManagerClient*>(wm_tree()) | 1173 static_cast<mojom::WindowManagerClient*>(wm_tree()) |
| 1159 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); | 1174 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); |
| 1160 EXPECT_FALSE(child_binding->is_paused()); | 1175 EXPECT_FALSE(child_binding->is_paused()); |
| 1161 | 1176 |
| 1162 // The child_tree is the one that has to make this call; the | 1177 // The child_tree is the one that has to make this call; the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, | 1211 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, |
| 1197 properties); | 1212 properties); |
| 1198 | 1213 |
| 1199 // The binding should be paused until the wm acks the change. | 1214 // The binding should be paused until the wm acks the change. |
| 1200 uint32_t wm_change_id = 0u; | 1215 uint32_t wm_change_id = 0u; |
| 1201 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); | 1216 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); |
| 1202 EXPECT_TRUE(child_binding->is_paused()); | 1217 EXPECT_TRUE(child_binding->is_paused()); |
| 1203 | 1218 |
| 1204 // Create the window for |embed_window_id2_in_child|. | 1219 // Create the window for |embed_window_id2_in_child|. |
| 1205 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); | 1220 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); |
| 1206 EXPECT_TRUE( | 1221 EXPECT_TRUE(wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties(), |
| 1207 wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties())); | 1222 cc::LocalFrameId())); |
| 1208 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); | 1223 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); |
| 1209 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); | 1224 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); |
| 1210 | 1225 |
| 1211 // Ack the change, which should resume the binding. | 1226 // Ack the change, which should resume the binding. |
| 1212 child_binding->client()->tracker()->changes()->clear(); | 1227 child_binding->client()->tracker()->changes()->clear(); |
| 1213 static_cast<mojom::WindowManagerClient*>(wm_tree()) | 1228 static_cast<mojom::WindowManagerClient*>(wm_tree()) |
| 1214 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); | 1229 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); |
| 1215 EXPECT_FALSE(child_binding->is_paused()); | 1230 EXPECT_FALSE(child_binding->is_paused()); |
| 1216 | 1231 |
| 1217 // Making this call from the wm_tree() must be invalid. | 1232 // Making this call from the wm_tree() must be invalid. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1241 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, | 1256 ->NewTopLevelWindow(initial_change_id, embed_window_id2_in_child.id, |
| 1242 properties); | 1257 properties); |
| 1243 | 1258 |
| 1244 // The binding should be paused until the wm acks the change. | 1259 // The binding should be paused until the wm acks the change. |
| 1245 uint32_t wm_change_id = 0u; | 1260 uint32_t wm_change_id = 0u; |
| 1246 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); | 1261 ASSERT_TRUE(wm_internal.did_call_create_top_level_window(&wm_change_id)); |
| 1247 EXPECT_TRUE(child_binding->is_paused()); | 1262 EXPECT_TRUE(child_binding->is_paused()); |
| 1248 | 1263 |
| 1249 // Create the window for |embed_window_id2_in_child|. | 1264 // Create the window for |embed_window_id2_in_child|. |
| 1250 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); | 1265 const ClientWindowId embed_window_id2 = BuildClientWindowId(wm_tree(), 2); |
| 1251 EXPECT_TRUE( | 1266 EXPECT_TRUE(wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties(), |
| 1252 wm_tree()->NewWindow(embed_window_id2, ServerWindow::Properties())); | 1267 cc::LocalFrameId())); |
| 1253 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); | 1268 EXPECT_TRUE(wm_tree()->SetWindowVisibility(embed_window_id2, true)); |
| 1254 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); | 1269 EXPECT_TRUE(wm_tree()->AddWindow(FirstRootId(wm_tree()), embed_window_id2)); |
| 1255 | 1270 |
| 1256 // Ack the change, which should resume the binding. | 1271 // Ack the change, which should resume the binding. |
| 1257 child_binding->client()->tracker()->changes()->clear(); | 1272 child_binding->client()->tracker()->changes()->clear(); |
| 1258 static_cast<mojom::WindowManagerClient*>(wm_tree()) | 1273 static_cast<mojom::WindowManagerClient*>(wm_tree()) |
| 1259 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); | 1274 ->OnWmCreatedTopLevelWindow(wm_change_id, embed_window_id2.id); |
| 1260 EXPECT_FALSE(child_binding->is_paused()); | 1275 EXPECT_FALSE(child_binding->is_paused()); |
| 1261 | 1276 |
| 1262 // The child_tree is the one that has to make this call; the | 1277 // The child_tree is the one that has to make this call; the |
| 1263 const uint32_t change_id = 7; | 1278 const uint32_t change_id = 7; |
| 1264 static_cast<mojom::WindowTree*>(child_tree) | 1279 static_cast<mojom::WindowTree*>(child_tree) |
| 1265 ->PerformWindowMove(change_id, embed_window_id2_in_child.id, | 1280 ->PerformWindowMove(change_id, embed_window_id2_in_child.id, |
| 1266 mojom::MoveLoopSource::MOUSE, gfx::Point(0, 0)); | 1281 mojom::MoveLoopSource::MOUSE, gfx::Point(0, 0)); |
| 1267 | 1282 |
| 1268 ServerWindow* server_window = | 1283 ServerWindow* server_window = |
| 1269 wm_tree()->GetWindowByClientId(embed_window_id2); | 1284 wm_tree()->GetWindowByClientId(embed_window_id2); |
| 1270 gfx::Rect old_bounds = server_window->bounds(); | 1285 gfx::Rect old_bounds = server_window->bounds(); |
| 1271 server_window->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1286 server_window->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1272 | 1287 |
| 1273 // Cancel the move loop. | 1288 // Cancel the move loop. |
| 1274 const uint32_t kFirstWMChange = 1; | 1289 const uint32_t kFirstWMChange = 1; |
| 1275 static_cast<mojom::WindowManagerClient*>(wm_tree())->WmResponse( | 1290 static_cast<mojom::WindowManagerClient*>(wm_tree())->WmResponse( |
| 1276 kFirstWMChange, false); | 1291 kFirstWMChange, false); |
| 1277 | 1292 |
| 1278 // Canceling the move loop should have reverted the bounds. | 1293 // Canceling the move loop should have reverted the bounds. |
| 1279 EXPECT_EQ(old_bounds, server_window->bounds()); | 1294 EXPECT_EQ(old_bounds, server_window->bounds()); |
| 1280 } | 1295 } |
| 1281 | 1296 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 ServerWindow* window = window_event_targeting_helper_.CreatePrimaryTree( | 1331 ServerWindow* window = window_event_targeting_helper_.CreatePrimaryTree( |
| 1317 gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 50, 50)); | 1332 gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 50, 50)); |
| 1318 TestWindowTreeClient* embed_client = last_window_tree_client(); | 1333 TestWindowTreeClient* embed_client = last_window_tree_client(); |
| 1319 WindowTree* owning_tree = | 1334 WindowTree* owning_tree = |
| 1320 window_server()->GetTreeWithId(window->id().client_id); | 1335 window_server()->GetTreeWithId(window->id().client_id); |
| 1321 WindowTree* embed_tree = window_server()->GetTreeWithRoot(window); | 1336 WindowTree* embed_tree = window_server()->GetTreeWithRoot(window); |
| 1322 ASSERT_NE(owning_tree, embed_tree); | 1337 ASSERT_NE(owning_tree, embed_tree); |
| 1323 | 1338 |
| 1324 const ClientWindowId embed_child_window_id = | 1339 const ClientWindowId embed_child_window_id = |
| 1325 BuildClientWindowId(embed_tree, 2); | 1340 BuildClientWindowId(embed_tree, 2); |
| 1326 ASSERT_TRUE( | 1341 ASSERT_TRUE(embed_tree->NewWindow( |
| 1327 embed_tree->NewWindow(embed_child_window_id, ServerWindow::Properties())); | 1342 embed_child_window_id, ServerWindow::Properties(), cc::LocalFrameId())); |
| 1328 EXPECT_TRUE(embed_tree->SetWindowVisibility(embed_child_window_id, true)); | 1343 EXPECT_TRUE(embed_tree->SetWindowVisibility(embed_child_window_id, true)); |
| 1329 EXPECT_TRUE( | 1344 EXPECT_TRUE( |
| 1330 embed_tree->AddWindow(FirstRootId(embed_tree), embed_child_window_id)); | 1345 embed_tree->AddWindow(FirstRootId(embed_tree), embed_child_window_id)); |
| 1331 wm_client()->tracker()->changes()->clear(); | 1346 wm_client()->tracker()->changes()->clear(); |
| 1332 embed_client->tracker()->changes()->clear(); | 1347 embed_client->tracker()->changes()->clear(); |
| 1333 EXPECT_TRUE(embed_tree->SetCapture(embed_child_window_id)); | 1348 EXPECT_TRUE(embed_tree->SetCapture(embed_child_window_id)); |
| 1334 ASSERT_TRUE(!wm_client()->tracker()->changes()->empty()); | 1349 ASSERT_TRUE(!wm_client()->tracker()->changes()->empty()); |
| 1335 EXPECT_EQ("OnCaptureChanged new_window=2,1 old_window=null", | 1350 EXPECT_EQ("OnCaptureChanged new_window=2,1 old_window=null", |
| 1336 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 1351 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
| 1337 EXPECT_TRUE(embed_client->tracker()->changes()->empty()); | 1352 EXPECT_TRUE(embed_client->tracker()->changes()->empty()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1368 window_server->user_id_tracker()->AddUserId(kTestUserId1); | 1383 window_server->user_id_tracker()->AddUserId(kTestUserId1); |
| 1369 screen_manager.AddDisplay(); | 1384 screen_manager.AddDisplay(); |
| 1370 | 1385 |
| 1371 AddWindowManager(window_server, kTestUserId1); | 1386 AddWindowManager(window_server, kTestUserId1); |
| 1372 window_server->user_id_tracker()->SetActiveUserId(kTestUserId1); | 1387 window_server->user_id_tracker()->SetActiveUserId(kTestUserId1); |
| 1373 TestWindowTreeBinding* test_binding = | 1388 TestWindowTreeBinding* test_binding = |
| 1374 ws_test_helper.window_server_delegate()->last_binding(); | 1389 ws_test_helper.window_server_delegate()->last_binding(); |
| 1375 ASSERT_TRUE(test_binding); | 1390 ASSERT_TRUE(test_binding); |
| 1376 WindowTree* tree = test_binding->tree(); | 1391 WindowTree* tree = test_binding->tree(); |
| 1377 const ClientWindowId window_id = BuildClientWindowId(tree, 2); | 1392 const ClientWindowId window_id = BuildClientWindowId(tree, 2); |
| 1378 ASSERT_TRUE(tree->NewWindow(window_id, ServerWindow::Properties())); | 1393 ASSERT_TRUE(tree->NewWindow(window_id, ServerWindow::Properties(), |
| 1394 cc::LocalFrameId())); |
| 1379 | 1395 |
| 1380 // Release the client so that it survices shutdown. | 1396 // Release the client so that it survices shutdown. |
| 1381 client = test_binding->ReleaseClient(); | 1397 client = test_binding->ReleaseClient(); |
| 1382 client->tracker()->changes()->clear(); | 1398 client->tracker()->changes()->clear(); |
| 1383 } | 1399 } |
| 1384 | 1400 |
| 1385 // Client should not have got any messages after shutdown. | 1401 // Client should not have got any messages after shutdown. |
| 1386 EXPECT_TRUE(client->tracker()->changes()->empty()); | 1402 EXPECT_TRUE(client->tracker()->changes()->empty()); |
| 1387 } | 1403 } |
| 1388 | 1404 |
| 1389 } // namespace test | 1405 } // namespace test |
| 1390 } // namespace ws | 1406 } // namespace ws |
| 1391 } // namespace ui | 1407 } // namespace ui |
| OLD | NEW |