| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/aura/mus/window_tree_client.h" | 5 #include "ui/aura/mus/window_tree_client.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "mojo/common/common_type_converters.h" | 11 #include "mojo/common/common_type_converters.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/aura/client/aura_constants.h" | 13 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
| 15 #include "ui/aura/client/capture_client_observer.h" | 15 #include "ui/aura/client/capture_client_observer.h" |
| 16 #include "ui/aura/client/focus_client.h" | 16 #include "ui/aura/client/focus_client.h" |
| 17 #include "ui/aura/client/transient_window_client.h" | 17 #include "ui/aura/client/transient_window_client.h" |
| 18 #include "ui/aura/mus/property_converter.h" | 18 #include "ui/aura/mus/property_converter.h" |
| 19 #include "ui/aura/mus/window_mus.h" | 19 #include "ui/aura/mus/window_mus.h" |
| 20 #include "ui/aura/mus/window_tree_client_delegate.h" | 20 #include "ui/aura/mus/window_tree_client_delegate.h" |
| 21 #include "ui/aura/mus/window_tree_client_observer.h" | 21 #include "ui/aura/mus/window_tree_client_observer.h" |
| 22 #include "ui/aura/mus/window_tree_host_mus.h" |
| 22 #include "ui/aura/test/aura_mus_test_base.h" | 23 #include "ui/aura/test/aura_mus_test_base.h" |
| 23 #include "ui/aura/test/mus/test_window_tree.h" | 24 #include "ui/aura/test/mus/test_window_tree.h" |
| 24 #include "ui/aura/test/mus/window_tree_client_private.h" | 25 #include "ui/aura/test/mus/window_tree_client_private.h" |
| 25 #include "ui/aura/test/test_window_delegate.h" | 26 #include "ui/aura/test/test_window_delegate.h" |
| 26 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 27 #include "ui/aura/window_property.h" | 28 #include "ui/aura/window_property.h" |
| 28 #include "ui/aura/window_tracker.h" | 29 #include "ui/aura/window_tracker.h" |
| 29 #include "ui/compositor/compositor.h" | 30 #include "ui/compositor/compositor.h" |
| 30 #include "ui/events/event.h" | 31 #include "ui/events/event.h" |
| 31 #include "ui/events/event_utils.h" | 32 #include "ui/events/event_utils.h" |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 bool was_acked_ = false; | 432 bool was_acked_ = false; |
| 432 bool got_move_ = false; | 433 bool got_move_ = false; |
| 433 | 434 |
| 434 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate); | 435 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate); |
| 435 }; | 436 }; |
| 436 | 437 |
| 437 } // namespace | 438 } // namespace |
| 438 | 439 |
| 439 TEST_F(WindowTreeClientClientTest, InputEventBasic) { | 440 TEST_F(WindowTreeClientClientTest, InputEventBasic) { |
| 440 InputEventBasicTestWindowDelegate window_delegate(window_tree()); | 441 InputEventBasicTestWindowDelegate window_delegate(window_tree()); |
| 441 std::unique_ptr<Window> top_level(base::MakeUnique<Window>(&window_delegate)); | 442 WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
| 442 top_level->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 443 Window* top_level = window_tree_host.window(); |
| 443 top_level->Init(ui::LAYER_NOT_DRAWN); | |
| 444 WindowTreeHost* window_tree_host = top_level->GetRootWindow()->GetHost(); | |
| 445 const gfx::Rect bounds(0, 0, 100, 100); | 444 const gfx::Rect bounds(0, 0, 100, 100); |
| 446 window_tree_host->SetBounds(bounds); | 445 window_tree_host.SetBounds(bounds); |
| 447 window_tree_host->Show(); | 446 window_tree_host.Show(); |
| 448 EXPECT_EQ(bounds, top_level->bounds()); | 447 EXPECT_EQ(bounds, top_level->bounds()); |
| 449 EXPECT_EQ(bounds, window_tree_host->window()->bounds()); | 448 EXPECT_EQ(bounds, window_tree_host.GetBounds()); |
| 449 Window child(&window_delegate); |
| 450 child.Init(ui::LAYER_NOT_DRAWN); |
| 451 top_level->AddChild(&child); |
| 452 child.SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 453 child.Show(); |
| 450 EXPECT_FALSE(window_delegate.got_move()); | 454 EXPECT_FALSE(window_delegate.got_move()); |
| 451 EXPECT_FALSE(window_delegate.was_acked()); | 455 EXPECT_FALSE(window_delegate.was_acked()); |
| 452 std::unique_ptr<ui::Event> ui_event( | 456 std::unique_ptr<ui::Event> ui_event( |
| 453 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 457 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
| 454 ui::EventTimeForNow(), ui::EF_NONE, 0)); | 458 ui::EventTimeForNow(), ui::EF_NONE, 0)); |
| 455 window_tree_client()->OnWindowInputEvent( | 459 window_tree_client()->OnWindowInputEvent( |
| 456 InputEventBasicTestWindowDelegate::kEventId, server_id(top_level.get()), | 460 InputEventBasicTestWindowDelegate::kEventId, server_id(top_level), |
| 457 ui::Event::Clone(*ui_event.get()), 0); | 461 ui::Event::Clone(*ui_event.get()), 0); |
| 458 EXPECT_TRUE(window_tree()->WasEventAcked(1)); | 462 EXPECT_TRUE(window_tree()->WasEventAcked(1)); |
| 459 EXPECT_TRUE(window_delegate.got_move()); | 463 EXPECT_TRUE(window_delegate.got_move()); |
| 460 EXPECT_FALSE(window_delegate.was_acked()); | 464 EXPECT_FALSE(window_delegate.was_acked()); |
| 461 } | 465 } |
| 462 | 466 |
| 463 class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest { | 467 class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest { |
| 464 public: | 468 public: |
| 465 WindowTreeClientPointerObserverTest() {} | 469 WindowTreeClientPointerObserverTest() {} |
| 466 ~WindowTreeClientPointerObserverTest() override {} | 470 ~WindowTreeClientPointerObserverTest() override {} |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 // the visibility of the window. Ack the change, which should not crash or | 664 // the visibility of the window. Ack the change, which should not crash or |
| 661 // trigger DCHECKs. | 665 // trigger DCHECKs. |
| 662 child.reset(); | 666 child.reset(); |
| 663 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( | 667 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( |
| 664 WindowTreeChangeType::VISIBLE, true)); | 668 WindowTreeChangeType::VISIBLE, true)); |
| 665 } | 669 } |
| 666 | 670 |
| 667 TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) { | 671 TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) { |
| 668 const size_t initial_root_count = | 672 const size_t initial_root_count = |
| 669 window_tree_client_impl()->GetRoots().size(); | 673 window_tree_client_impl()->GetRoots().size(); |
| 670 std::unique_ptr<Window> top_level(base::MakeUnique<Window>(nullptr)); | 674 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
| 671 top_level->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 675 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); |
| 672 top_level->Init(ui::LAYER_NOT_DRAWN); | 676 aura::Window* top_level = window_tree_host->window(); |
| 673 // TODO: need to check WindowTreeHost visibility. | 677 // TODO: need to check WindowTreeHost visibility. |
| 674 // EXPECT_TRUE(WindowPrivate(root2).parent_drawn()); | 678 // EXPECT_TRUE(WindowPrivate(root2).parent_drawn()); |
| 675 EXPECT_NE(server_id(top_level.get()), server_id(root_window())); | 679 EXPECT_NE(server_id(top_level), server_id(root_window())); |
| 676 EXPECT_EQ(initial_root_count + 1, | 680 EXPECT_EQ(initial_root_count + 1, |
| 677 window_tree_client_impl()->GetRoots().size()); | 681 window_tree_client_impl()->GetRoots().size()); |
| 678 EXPECT_TRUE(window_tree_client_impl()->GetRoots().count(top_level.get()) > | 682 EXPECT_TRUE(window_tree_client_impl()->GetRoots().count(top_level) > 0u); |
| 679 0u); | |
| 680 | 683 |
| 681 // Ack the request to the windowtree to create the new window. | 684 // Ack the request to the windowtree to create the new window. |
| 682 uint32_t change_id; | 685 uint32_t change_id; |
| 683 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 686 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
| 684 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 687 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
| 685 EXPECT_EQ(window_tree()->window_id(), server_id(top_level.get())); | 688 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); |
| 686 | 689 |
| 687 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 690 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
| 688 data->window_id = server_id(top_level.get()); | 691 data->window_id = server_id(top_level); |
| 689 const int64_t display_id = 1; | 692 const int64_t display_id = 1; |
| 690 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), | 693 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
| 691 display_id, false); | 694 display_id, false); |
| 692 | 695 |
| 693 // TODO: need to check WindowTreeHost visibility. | 696 // TODO: need to check WindowTreeHost visibility. |
| 694 // EXPECT_FALSE(WindowPrivate(root2).parent_drawn()); | 697 // EXPECT_FALSE(WindowPrivate(root2).parent_drawn()); |
| 695 | 698 |
| 696 // Should not be able to add a top level as a child of another window. | 699 // Should not be able to add a top level as a child of another window. |
| 697 // TODO(sky): decide how to handle this. | 700 // TODO(sky): decide how to handle this. |
| 698 // root_window()->AddChild(top_level.get()); | 701 // root_window()->AddChild(top_level); |
| 699 // ASSERT_EQ(nullptr, top_level->parent()); | 702 // ASSERT_EQ(nullptr, top_level->parent()); |
| 700 | 703 |
| 701 // Destroy the first root, shouldn't initiate tear down. | 704 // Destroy the first root, shouldn't initiate tear down. |
| 702 top_level.reset(); | 705 window_tree_host.reset(); |
| 703 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); | 706 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); |
| 704 } | 707 } |
| 705 | 708 |
| 706 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) { | 709 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) { |
| 707 const size_t initial_root_count = | 710 const size_t initial_root_count = |
| 708 window_tree_client_impl()->GetRoots().size(); | 711 window_tree_client_impl()->GetRoots().size(); |
| 709 std::unique_ptr<Window> top_level(base::MakeUnique<Window>(nullptr)); | 712 WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
| 710 top_level->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 713 Window* top_level = window_tree_host.window(); |
| 711 top_level->Init(ui::LAYER_NOT_DRAWN); | |
| 712 EXPECT_EQ(initial_root_count + 1, | 714 EXPECT_EQ(initial_root_count + 1, |
| 713 window_tree_client_impl()->GetRoots().size()); | 715 window_tree_client_impl()->GetRoots().size()); |
| 714 | 716 |
| 715 EXPECT_FALSE(IsWindowHostVisible(top_level.get())); | 717 EXPECT_FALSE(IsWindowHostVisible(top_level)); |
| 716 EXPECT_FALSE(top_level->TargetVisibility()); | 718 EXPECT_FALSE(top_level->TargetVisibility()); |
| 717 | 719 |
| 718 // Ack the request to the windowtree to create the new window. | 720 // Ack the request to the windowtree to create the new window. |
| 719 EXPECT_EQ(window_tree()->window_id(), server_id(top_level.get())); | 721 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); |
| 720 | 722 |
| 721 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 723 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
| 722 data->window_id = server_id(top_level.get()); | 724 data->window_id = server_id(top_level); |
| 723 data->bounds.SetRect(1, 2, 3, 4); | 725 data->bounds.SetRect(1, 2, 3, 4); |
| 724 data->visible = true; | 726 data->visible = true; |
| 725 const int64_t display_id = 1; | 727 const int64_t display_id = 10; |
| 726 uint32_t change_id; | 728 uint32_t change_id; |
| 727 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 729 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
| 728 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 730 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
| 729 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), | 731 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
| 730 display_id, true); | 732 display_id, true); |
| 731 EXPECT_EQ( | 733 EXPECT_EQ( |
| 732 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); | 734 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); |
| 733 | 735 |
| 734 // Make sure all the properties took. | 736 // Make sure all the properties took. |
| 735 EXPECT_TRUE(IsWindowHostVisible(top_level.get())); | 737 EXPECT_TRUE(IsWindowHostVisible(top_level)); |
| 736 EXPECT_TRUE(top_level->TargetVisibility()); | 738 EXPECT_TRUE(top_level->TargetVisibility()); |
| 737 // TODO: check display_id. | 739 // TODO: check display_id. |
| 738 // EXPECT_EQ(1, root2->display_id()); | 740 EXPECT_EQ(display_id, window_tree_host.display_id()); |
| 739 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); | 741 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); |
| 740 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBounds()); | 742 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBounds()); |
| 741 } | 743 } |
| 742 | 744 |
| 743 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { | 745 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { |
| 744 SetPropertyConverter(base::MakeUnique<TestPropertyConverter>()); | 746 SetPropertyConverter(base::MakeUnique<TestPropertyConverter>()); |
| 745 | 747 |
| 746 std::unique_ptr<Window> top_level(base::MakeUnique<Window>(nullptr)); | 748 WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
| 747 top_level->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 749 Window* top_level = window_tree_host.window(); |
| 748 top_level->Init(ui::LAYER_NOT_DRAWN); | |
| 749 | 750 |
| 750 EXPECT_FALSE(top_level->TargetVisibility()); | 751 EXPECT_FALSE(top_level->TargetVisibility()); |
| 751 | 752 |
| 752 // Make visibility go from false->true->false. Don't ack immediately. | 753 // Make visibility go from false->true->false. Don't ack immediately. |
| 753 top_level->Show(); | 754 top_level->Show(); |
| 754 top_level->Hide(); | 755 top_level->Hide(); |
| 755 | 756 |
| 756 // Change bounds to 5, 6, 7, 8. | 757 // Change bounds to 5, 6, 7, 8. |
| 757 top_level->SetBounds(gfx::Rect(5, 6, 7, 8)); | 758 window_tree_host.SetBounds(gfx::Rect(5, 6, 7, 8)); |
| 759 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), window_tree_host.window()->bounds()); |
| 758 | 760 |
| 759 const uint8_t explicitly_set_test_property1_value = 2; | 761 const uint8_t explicitly_set_test_property1_value = 2; |
| 760 top_level->SetProperty(kTestPropertyKey1, | 762 top_level->SetProperty(kTestPropertyKey1, |
| 761 explicitly_set_test_property1_value); | 763 explicitly_set_test_property1_value); |
| 762 | 764 |
| 763 // Ack the new window top level top_level Vis and bounds shouldn't change. | 765 // Ack the new window top level top_level Vis and bounds shouldn't change. |
| 764 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 766 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
| 765 data->window_id = server_id(top_level.get()); | 767 data->window_id = server_id(top_level); |
| 766 const gfx::Rect bounds_from_server(1, 2, 3, 4); | 768 const gfx::Rect bounds_from_server(1, 2, 3, 4); |
| 767 data->bounds = bounds_from_server; | 769 data->bounds = bounds_from_server; |
| 768 data->visible = true; | 770 data->visible = true; |
| 769 const uint8_t server_test_property1_value = 3; | 771 const uint8_t server_test_property1_value = 3; |
| 770 data->properties[kTestPropertyServerKey1] = | 772 data->properties[kTestPropertyServerKey1] = |
| 771 Uint8ToPropertyTransportValue(server_test_property1_value); | 773 Uint8ToPropertyTransportValue(server_test_property1_value); |
| 772 const uint8_t server_test_property2_value = 4; | 774 const uint8_t server_test_property2_value = 4; |
| 773 data->properties[kTestPropertyServerKey2] = | 775 data->properties[kTestPropertyServerKey2] = |
| 774 Uint8ToPropertyTransportValue(server_test_property2_value); | 776 Uint8ToPropertyTransportValue(server_test_property2_value); |
| 775 const int64_t display_id = 1; | 777 const int64_t display_id = 1; |
| 776 // Get the id of the in flight change for creating the new top_level. | 778 // Get the id of the in flight change for creating the new top_level. |
| 777 uint32_t new_window_in_flight_change_id; | 779 uint32_t new_window_in_flight_change_id; |
| 778 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 780 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
| 779 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); | 781 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); |
| 780 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, | 782 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, |
| 781 std::move(data), display_id, true); | 783 std::move(data), display_id, true); |
| 782 | 784 |
| 783 // The only value that should take effect is the property for 'yy' as it was | 785 // The only value that should take effect is the property for 'yy' as it was |
| 784 // not in flight. | 786 // not in flight. |
| 785 EXPECT_FALSE(top_level->TargetVisibility()); | 787 EXPECT_FALSE(top_level->TargetVisibility()); |
| 786 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), top_level->bounds()); | 788 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBounds()); |
| 789 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds()); |
| 787 EXPECT_EQ(explicitly_set_test_property1_value, | 790 EXPECT_EQ(explicitly_set_test_property1_value, |
| 788 top_level->GetProperty(kTestPropertyKey1)); | 791 top_level->GetProperty(kTestPropertyKey1)); |
| 789 EXPECT_EQ(server_test_property2_value, | 792 EXPECT_EQ(server_test_property2_value, |
| 790 top_level->GetProperty(kTestPropertyKey2)); | 793 top_level->GetProperty(kTestPropertyKey2)); |
| 791 | 794 |
| 792 // Tell the client the changes failed. This should cause the values to change | 795 // Tell the client the changes failed. This should cause the values to change |
| 793 // to that of the server. | 796 // to that of the server. |
| 794 ASSERT_TRUE(window_tree()->AckFirstChangeOfType(WindowTreeChangeType::VISIBLE, | 797 ASSERT_TRUE(window_tree()->AckFirstChangeOfType(WindowTreeChangeType::VISIBLE, |
| 795 false)); | 798 false)); |
| 796 EXPECT_FALSE(top_level->TargetVisibility()); | 799 EXPECT_FALSE(top_level->TargetVisibility()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 transient_client->RemoveTransientChild(&parent, &transient); | 864 transient_client->RemoveTransientChild(&parent, &transient); |
| 862 ASSERT_EQ(1u, window_tree()->GetChangeCountForType( | 865 ASSERT_EQ(1u, window_tree()->GetChangeCountForType( |
| 863 WindowTreeChangeType::REMOVE_TRANSIENT)); | 866 WindowTreeChangeType::REMOVE_TRANSIENT)); |
| 864 EXPECT_EQ(server_id(&transient), window_tree()->transient_data().child_id); | 867 EXPECT_EQ(server_id(&transient), window_tree()->transient_data().child_id); |
| 865 } | 868 } |
| 866 | 869 |
| 867 TEST_F(WindowTreeClientClientTest, | 870 TEST_F(WindowTreeClientClientTest, |
| 868 TopLevelWindowDestroyedBeforeCreateComplete) { | 871 TopLevelWindowDestroyedBeforeCreateComplete) { |
| 869 const size_t initial_root_count = | 872 const size_t initial_root_count = |
| 870 window_tree_client_impl()->GetRoots().size(); | 873 window_tree_client_impl()->GetRoots().size(); |
| 871 std::unique_ptr<Window> top_level(base::MakeUnique<Window>(nullptr)); | 874 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
| 872 top_level->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 875 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); |
| 873 top_level->Init(ui::LAYER_NOT_DRAWN); | |
| 874 EXPECT_EQ(initial_root_count + 1, | 876 EXPECT_EQ(initial_root_count + 1, |
| 875 window_tree_client_impl()->GetRoots().size()); | 877 window_tree_client_impl()->GetRoots().size()); |
| 876 | 878 |
| 877 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 879 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
| 878 data->window_id = server_id(top_level.get()); | 880 data->window_id = server_id(window_tree_host->window()); |
| 879 | 881 |
| 880 // Destroy the window before the server has a chance to ack the window | 882 // Destroy the window before the server has a chance to ack the window |
| 881 // creation. | 883 // creation. |
| 882 top_level.reset(); | 884 window_tree_host.reset(); |
| 883 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); | 885 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); |
| 884 | 886 |
| 885 // Get the id of the in flight change for creating the new window. | 887 // Get the id of the in flight change for creating the new window. |
| 886 uint32_t change_id; | 888 uint32_t change_id; |
| 887 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 889 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
| 888 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 890 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
| 889 | 891 |
| 890 const int64_t display_id = 1; | 892 const int64_t display_id = 1; |
| 891 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), | 893 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
| 892 display_id, true); | 894 display_id, true); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 // Ack change as succeeding. | 1113 // Ack change as succeeding. |
| 1112 ASSERT_TRUE( | 1114 ASSERT_TRUE( |
| 1113 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true)); | 1115 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true)); |
| 1114 EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey)); | 1116 EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey)); |
| 1115 // There should be no more modal changes. | 1117 // There should be no more modal changes. |
| 1116 EXPECT_FALSE( | 1118 EXPECT_FALSE( |
| 1117 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false)); | 1119 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false)); |
| 1118 } | 1120 } |
| 1119 | 1121 |
| 1120 } // namespace aura | 1122 } // namespace aura |
| OLD | NEW |