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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "services/ui/common/util.h" | 13 #include "services/ui/common/util.h" |
14 #include "services/ui/ws/window_server_test_base.h" | 14 #include "services/ui/ws/window_server_test_base.h" |
15 #include "ui/aura/client/transient_window_client.h" | 15 #include "ui/aura/client/transient_window_client.h" |
16 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
17 #include "ui/aura/mus/window_port_mus.h" | 17 #include "ui/aura/mus/window_port_mus.h" |
18 #include "ui/aura/mus/window_tree_client.h" | 18 #include "ui/aura/mus/window_tree_client.h" |
19 #include "ui/aura/mus/window_tree_client_delegate.h" | 19 #include "ui/aura/mus/window_tree_client_delegate.h" |
20 #include "ui/aura/mus/window_tree_host_mus.h" | 20 #include "ui/aura/mus/window_tree_host_mus.h" |
| 21 #include "ui/aura/mus/window_tree_host_mus_init_params.h" |
21 #include "ui/aura/test/mus/window_tree_client_private.h" | 22 #include "ui/aura/test/mus/window_tree_client_private.h" |
22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
23 #include "ui/aura/window_observer.h" | 24 #include "ui/aura/window_observer.h" |
24 #include "ui/aura/window_tracker.h" | 25 #include "ui/aura/window_tracker.h" |
25 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
26 | 27 |
27 namespace ui { | 28 namespace ui { |
28 namespace ws { | 29 namespace ws { |
29 | 30 |
30 namespace { | 31 namespace { |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 DISALLOW_COPY_AND_ASSIGN(EstablishConnectionViaFactoryDelegate); | 718 DISALLOW_COPY_AND_ASSIGN(EstablishConnectionViaFactoryDelegate); |
718 }; | 719 }; |
719 | 720 |
720 TEST_F(WindowServerTest, EstablishConnectionViaFactory) { | 721 TEST_F(WindowServerTest, EstablishConnectionViaFactory) { |
721 EstablishConnectionViaFactoryDelegate delegate(window_manager()); | 722 EstablishConnectionViaFactoryDelegate delegate(window_manager()); |
722 set_window_manager_delegate(&delegate); | 723 set_window_manager_delegate(&delegate); |
723 aura::WindowTreeClient second_client(connector(), this, nullptr, nullptr, | 724 aura::WindowTreeClient second_client(connector(), this, nullptr, nullptr, |
724 nullptr, false); | 725 nullptr, false); |
725 second_client.ConnectViaWindowTreeFactory(); | 726 second_client.ConnectViaWindowTreeFactory(); |
726 aura::WindowTreeHostMus window_tree_host_in_second_client( | 727 aura::WindowTreeHostMus window_tree_host_in_second_client( |
727 &second_client, cc::FrameSinkId(1, 1)); | 728 aura::CreateInitParamsForTopLevel(&second_client)); |
728 window_tree_host_in_second_client.InitHost(); | 729 window_tree_host_in_second_client.InitHost(); |
729 window_tree_host_in_second_client.window()->Show(); | 730 window_tree_host_in_second_client.window()->Show(); |
730 ASSERT_TRUE(second_client.GetRoots().count( | 731 ASSERT_TRUE(second_client.GetRoots().count( |
731 window_tree_host_in_second_client.window()) > 0); | 732 window_tree_host_in_second_client.window()) > 0); |
732 // Wait for the window to appear in the wm. | 733 // Wait for the window to appear in the wm. |
733 ASSERT_TRUE(delegate.QuitOnCreate()); | 734 ASSERT_TRUE(delegate.QuitOnCreate()); |
734 | 735 |
735 aura::Window* window_in_wm = delegate.created_window(); | 736 aura::Window* window_in_wm = delegate.created_window(); |
736 ASSERT_TRUE(window_in_wm); | 737 ASSERT_TRUE(window_in_wm); |
737 | 738 |
738 // Change the bounds in the wm, and make sure the child sees it. | 739 // Change the bounds in the wm, and make sure the child sees it. |
739 const gfx::Rect window_bounds(1, 11, 12, 101); | 740 const gfx::Rect window_bounds(1, 11, 12, 101); |
740 window_in_wm->SetBounds(window_bounds); | 741 window_in_wm->SetBounds(window_bounds); |
741 ASSERT_TRUE( | 742 ASSERT_TRUE( |
742 WaitForBoundsToChange(window_tree_host_in_second_client.window())); | 743 WaitForBoundsToChange(window_tree_host_in_second_client.window())); |
743 EXPECT_EQ(window_bounds, | 744 EXPECT_EQ(window_bounds, |
744 window_tree_host_in_second_client.GetBoundsInPixels()); | 745 window_tree_host_in_second_client.GetBoundsInPixels()); |
745 } | 746 } |
746 | 747 |
747 TEST_F(WindowServerTest, OnWindowHierarchyChangedIncludesTransientParent) { | 748 TEST_F(WindowServerTest, OnWindowHierarchyChangedIncludesTransientParent) { |
748 // Create a second connection. In the second connection create a window, | 749 // Create a second connection. In the second connection create a window, |
749 // parent it to the root, create another window, mark it as a transient parent | 750 // parent it to the root, create another window, mark it as a transient parent |
750 // of the first window and then add it. | 751 // of the first window and then add it. |
751 EstablishConnectionViaFactoryDelegate delegate(window_manager()); | 752 EstablishConnectionViaFactoryDelegate delegate(window_manager()); |
752 set_window_manager_delegate(&delegate); | 753 set_window_manager_delegate(&delegate); |
753 aura::WindowTreeClient second_client(connector(), this, nullptr, nullptr, | 754 aura::WindowTreeClient second_client(connector(), this, nullptr, nullptr, |
754 nullptr, false); | 755 nullptr, false); |
755 second_client.ConnectViaWindowTreeFactory(); | 756 second_client.ConnectViaWindowTreeFactory(); |
756 aura::WindowTreeHostMus window_tree_host_in_second_client( | 757 aura::WindowTreeHostMus window_tree_host_in_second_client( |
757 &second_client, cc::FrameSinkId(1, 1)); | 758 aura::CreateInitParamsForTopLevel(&second_client)); |
758 window_tree_host_in_second_client.InitHost(); | 759 window_tree_host_in_second_client.InitHost(); |
759 window_tree_host_in_second_client.window()->Show(); | 760 window_tree_host_in_second_client.window()->Show(); |
760 aura::Window* second_client_child = NewVisibleWindow( | 761 aura::Window* second_client_child = NewVisibleWindow( |
761 window_tree_host_in_second_client.window(), &second_client); | 762 window_tree_host_in_second_client.window(), &second_client); |
762 std::unique_ptr<aura::WindowPortMus> window_port_mus = | 763 std::unique_ptr<aura::WindowPortMus> window_port_mus = |
763 base::MakeUnique<aura::WindowPortMus>(&second_client, | 764 base::MakeUnique<aura::WindowPortMus>(&second_client, |
764 aura::WindowMusType::LOCAL); | 765 aura::WindowMusType::LOCAL); |
765 // Create the transient without a parent, set transient parent, then add. | 766 // Create the transient without a parent, set transient parent, then add. |
766 aura::Window* transient = NewVisibleWindow(nullptr, &second_client); | 767 aura::Window* transient = NewVisibleWindow(nullptr, &second_client); |
767 aura::client::TransientWindowClient* transient_window_client = | 768 aura::client::TransientWindowClient* transient_window_client = |
(...skipping 11 matching lines...) Expand all Loading... |
779 ASSERT_EQ(1u, top_level_in_wm->children().size()); | 780 ASSERT_EQ(1u, top_level_in_wm->children().size()); |
780 aura::Window* second_client_child_in_wm = top_level_in_wm->children()[0]; | 781 aura::Window* second_client_child_in_wm = top_level_in_wm->children()[0]; |
781 ASSERT_EQ(1u, second_client_child_in_wm->children().size()); | 782 ASSERT_EQ(1u, second_client_child_in_wm->children().size()); |
782 aura::Window* transient_in_wm = second_client_child_in_wm->children()[0]; | 783 aura::Window* transient_in_wm = second_client_child_in_wm->children()[0]; |
783 ASSERT_EQ(second_client_child_in_wm, | 784 ASSERT_EQ(second_client_child_in_wm, |
784 transient_window_client->GetTransientParent(transient_in_wm)); | 785 transient_window_client->GetTransientParent(transient_in_wm)); |
785 } | 786 } |
786 | 787 |
787 } // namespace ws | 788 } // namespace ws |
788 } // namespace ui | 789 } // namespace ui |
OLD | NEW |