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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/aura/client/transient_window_client.h" | 25 #include "ui/aura/client/transient_window_client.h" |
26 #include "ui/aura/mus/capture_synchronizer.h" | 26 #include "ui/aura/mus/capture_synchronizer.h" |
27 #include "ui/aura/mus/client_surface_embedder.h" | 27 #include "ui/aura/mus/client_surface_embedder.h" |
28 #include "ui/aura/mus/focus_synchronizer.h" | 28 #include "ui/aura/mus/focus_synchronizer.h" |
29 #include "ui/aura/mus/property_converter.h" | 29 #include "ui/aura/mus/property_converter.h" |
30 #include "ui/aura/mus/window_mus.h" | 30 #include "ui/aura/mus/window_mus.h" |
31 #include "ui/aura/mus/window_port_mus.h" | 31 #include "ui/aura/mus/window_port_mus.h" |
32 #include "ui/aura/mus/window_tree_client_delegate.h" | 32 #include "ui/aura/mus/window_tree_client_delegate.h" |
33 #include "ui/aura/mus/window_tree_client_observer.h" | 33 #include "ui/aura/mus/window_tree_client_observer.h" |
34 #include "ui/aura/mus/window_tree_host_mus.h" | 34 #include "ui/aura/mus/window_tree_host_mus.h" |
| 35 #include "ui/aura/mus/window_tree_host_mus_init_params.h" |
35 #include "ui/aura/test/aura_mus_test_base.h" | 36 #include "ui/aura/test/aura_mus_test_base.h" |
36 #include "ui/aura/test/mus/test_window_tree.h" | 37 #include "ui/aura/test/mus/test_window_tree.h" |
37 #include "ui/aura/test/mus/window_tree_client_private.h" | 38 #include "ui/aura/test/mus/window_tree_client_private.h" |
38 #include "ui/aura/test/test_window_delegate.h" | 39 #include "ui/aura/test/test_window_delegate.h" |
39 #include "ui/aura/test/test_window_targeter.h" | 40 #include "ui/aura/test/test_window_targeter.h" |
40 #include "ui/aura/window.h" | 41 #include "ui/aura/window.h" |
41 #include "ui/aura/window_targeter.h" | 42 #include "ui/aura/window_targeter.h" |
42 #include "ui/aura/window_tracker.h" | 43 #include "ui/aura/window_tracker.h" |
43 #include "ui/aura/window_tree_host_observer.h" | 44 #include "ui/aura/window_tree_host_observer.h" |
44 #include "ui/base/class_property.h" | 45 #include "ui/base/class_property.h" |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 gfx::Point last_event_location_; | 723 gfx::Point last_event_location_; |
723 uint32_t event_id_ = 0; | 724 uint32_t event_id_ = 0; |
724 | 725 |
725 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestEventHandler); | 726 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestEventHandler); |
726 }; | 727 }; |
727 | 728 |
728 } // namespace | 729 } // namespace |
729 | 730 |
730 TEST_F(WindowTreeClientClientTest, InputEventBasic) { | 731 TEST_F(WindowTreeClientClientTest, InputEventBasic) { |
731 InputEventBasicTestWindowDelegate window_delegate(window_tree()); | 732 InputEventBasicTestWindowDelegate window_delegate(window_tree()); |
732 WindowTreeHostMus window_tree_host(window_tree_client_impl(), | 733 WindowTreeHostMus window_tree_host( |
733 cc::FrameSinkId(1, 1)); | 734 CreateInitParamsForTopLevel(window_tree_client_impl())); |
734 Window* top_level = window_tree_host.window(); | 735 Window* top_level = window_tree_host.window(); |
735 const gfx::Rect bounds(0, 0, 100, 100); | 736 const gfx::Rect bounds(0, 0, 100, 100); |
736 window_tree_host.SetBoundsInPixels(bounds); | 737 window_tree_host.SetBoundsInPixels(bounds); |
737 window_tree_host.InitHost(); | 738 window_tree_host.InitHost(); |
738 window_tree_host.Show(); | 739 window_tree_host.Show(); |
739 EXPECT_EQ(bounds, top_level->bounds()); | 740 EXPECT_EQ(bounds, top_level->bounds()); |
740 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); | 741 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); |
741 Window child(&window_delegate); | 742 Window child(&window_delegate); |
742 child.Init(ui::LAYER_NOT_DRAWN); | 743 child.Init(ui::LAYER_NOT_DRAWN); |
743 top_level->AddChild(&child); | 744 top_level->AddChild(&child); |
(...skipping 13 matching lines...) Expand all Loading... |
757 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); | 758 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); |
758 EXPECT_EQ(ui::mojom::EventResult::HANDLED, | 759 EXPECT_EQ(ui::mojom::EventResult::HANDLED, |
759 window_tree()->GetEventResult(event_id)); | 760 window_tree()->GetEventResult(event_id)); |
760 EXPECT_TRUE(window_delegate.got_move()); | 761 EXPECT_TRUE(window_delegate.got_move()); |
761 EXPECT_FALSE(window_delegate.was_acked()); | 762 EXPECT_FALSE(window_delegate.was_acked()); |
762 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); | 763 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); |
763 } | 764 } |
764 | 765 |
765 TEST_F(WindowTreeClientClientTest, InputEventPointerEvent) { | 766 TEST_F(WindowTreeClientClientTest, InputEventPointerEvent) { |
766 InputEventBasicTestWindowDelegate window_delegate(window_tree()); | 767 InputEventBasicTestWindowDelegate window_delegate(window_tree()); |
767 WindowTreeHostMus window_tree_host(window_tree_client_impl(), | 768 WindowTreeHostMus window_tree_host( |
768 cc::FrameSinkId(1, 1)); | 769 CreateInitParamsForTopLevel(window_tree_client_impl())); |
769 Window* top_level = window_tree_host.window(); | 770 Window* top_level = window_tree_host.window(); |
770 const gfx::Rect bounds(0, 0, 100, 100); | 771 const gfx::Rect bounds(0, 0, 100, 100); |
771 window_tree_host.SetBoundsInPixels(bounds); | 772 window_tree_host.SetBoundsInPixels(bounds); |
772 window_tree_host.InitHost(); | 773 window_tree_host.InitHost(); |
773 window_tree_host.Show(); | 774 window_tree_host.Show(); |
774 EXPECT_EQ(bounds, top_level->bounds()); | 775 EXPECT_EQ(bounds, top_level->bounds()); |
775 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); | 776 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); |
776 Window child(&window_delegate); | 777 Window child(&window_delegate); |
777 child.Init(ui::LAYER_NOT_DRAWN); | 778 child.Init(ui::LAYER_NOT_DRAWN); |
778 top_level->AddChild(&child); | 779 top_level->AddChild(&child); |
(...skipping 11 matching lines...) Expand all Loading... |
790 window_tree_host.display_id(), | 791 window_tree_host.display_id(), |
791 ui::Event::Clone(pointer_event), 0); | 792 ui::Event::Clone(pointer_event), 0); |
792 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); | 793 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); |
793 EXPECT_EQ(ui::mojom::EventResult::HANDLED, | 794 EXPECT_EQ(ui::mojom::EventResult::HANDLED, |
794 window_tree()->GetEventResult(event_id)); | 795 window_tree()->GetEventResult(event_id)); |
795 EXPECT_TRUE(window_delegate.got_move()); | 796 EXPECT_TRUE(window_delegate.got_move()); |
796 EXPECT_EQ(event_location, window_delegate.last_event_location()); | 797 EXPECT_EQ(event_location, window_delegate.last_event_location()); |
797 } | 798 } |
798 | 799 |
799 TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) { | 800 TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) { |
800 WindowTreeHostMus window_tree_host(window_tree_client_impl(), | 801 WindowTreeHostMus window_tree_host( |
801 cc::FrameSinkId(1, 1)); | 802 CreateInitParamsForTopLevel(window_tree_client_impl())); |
802 Window* top_level = window_tree_host.window(); | 803 Window* top_level = window_tree_host.window(); |
803 const gfx::Rect bounds(0, 0, 100, 100); | 804 const gfx::Rect bounds(0, 0, 100, 100); |
804 window_tree_host.SetBoundsInPixels(bounds); | 805 window_tree_host.SetBoundsInPixels(bounds); |
805 window_tree_host.InitHost(); | 806 window_tree_host.InitHost(); |
806 window_tree_host.Show(); | 807 window_tree_host.Show(); |
807 EXPECT_EQ(bounds, top_level->bounds()); | 808 EXPECT_EQ(bounds, top_level->bounds()); |
808 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); | 809 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); |
809 InputEventBasicTestWindowDelegate window_delegate1(window_tree()); | 810 InputEventBasicTestWindowDelegate window_delegate1(window_tree()); |
810 Window child1(&window_delegate1); | 811 Window child1(&window_delegate1); |
811 child1.Init(ui::LAYER_NOT_DRAWN); | 812 child1.Init(ui::LAYER_NOT_DRAWN); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 ui::Event::Clone(*ui_event1.get()), 0); | 859 ui::Event::Clone(*ui_event1.get()), 0); |
859 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); | 860 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); |
860 EXPECT_EQ(ui::mojom::EventResult::HANDLED, | 861 EXPECT_EQ(ui::mojom::EventResult::HANDLED, |
861 window_tree()->GetEventResult(event_id)); | 862 window_tree()->GetEventResult(event_id)); |
862 EXPECT_TRUE(window_delegate1.got_move()); | 863 EXPECT_TRUE(window_delegate1.got_move()); |
863 EXPECT_FALSE(window_delegate2.got_move()); | 864 EXPECT_FALSE(window_delegate2.got_move()); |
864 EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location()); | 865 EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location()); |
865 } | 866 } |
866 | 867 |
867 TEST_F(WindowTreeClientClientTest, InputEventCustomWindowTargeter) { | 868 TEST_F(WindowTreeClientClientTest, InputEventCustomWindowTargeter) { |
868 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 869 WindowTreeHostMus window_tree_host( |
| 870 CreateInitParamsForTopLevel(window_tree_client_impl())); |
869 Window* top_level = window_tree_host.window(); | 871 Window* top_level = window_tree_host.window(); |
870 const gfx::Rect bounds(0, 0, 100, 100); | 872 const gfx::Rect bounds(0, 0, 100, 100); |
871 window_tree_host.SetBoundsInPixels(bounds); | 873 window_tree_host.SetBoundsInPixels(bounds); |
872 window_tree_host.InitHost(); | 874 window_tree_host.InitHost(); |
873 window_tree_host.Show(); | 875 window_tree_host.Show(); |
874 EXPECT_EQ(bounds, top_level->bounds()); | 876 EXPECT_EQ(bounds, top_level->bounds()); |
875 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); | 877 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); |
876 InputEventBasicTestWindowDelegate window_delegate1(window_tree()); | 878 InputEventBasicTestWindowDelegate window_delegate1(window_tree()); |
877 Window child1(&window_delegate1); | 879 Window child1(&window_delegate1); |
878 child1.Init(ui::LAYER_NOT_DRAWN); | 880 child1.Init(ui::LAYER_NOT_DRAWN); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); | 925 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); |
924 EXPECT_EQ(ui::mojom::EventResult::HANDLED, | 926 EXPECT_EQ(ui::mojom::EventResult::HANDLED, |
925 window_tree()->GetEventResult(event_id)); | 927 window_tree()->GetEventResult(event_id)); |
926 EXPECT_TRUE(window_delegate1.got_move()); | 928 EXPECT_TRUE(window_delegate1.got_move()); |
927 EXPECT_FALSE(window_delegate2.got_move()); | 929 EXPECT_FALSE(window_delegate2.got_move()); |
928 EXPECT_EQ(gfx::Point(70, 90), window_delegate1.last_event_location()); | 930 EXPECT_EQ(gfx::Point(70, 90), window_delegate1.last_event_location()); |
929 } | 931 } |
930 | 932 |
931 TEST_F(WindowTreeClientClientTest, InputEventCaptureWindow) { | 933 TEST_F(WindowTreeClientClientTest, InputEventCaptureWindow) { |
932 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 934 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
933 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); | 935 base::MakeUnique<WindowTreeHostMus>( |
| 936 CreateInitParamsForTopLevel(window_tree_client_impl())); |
934 Window* top_level = window_tree_host->window(); | 937 Window* top_level = window_tree_host->window(); |
935 const gfx::Rect bounds(0, 0, 100, 100); | 938 const gfx::Rect bounds(0, 0, 100, 100); |
936 window_tree_host->SetBoundsInPixels(bounds); | 939 window_tree_host->SetBoundsInPixels(bounds); |
937 window_tree_host->InitHost(); | 940 window_tree_host->InitHost(); |
938 window_tree_host->Show(); | 941 window_tree_host->Show(); |
939 EXPECT_EQ(bounds, top_level->bounds()); | 942 EXPECT_EQ(bounds, top_level->bounds()); |
940 EXPECT_EQ(bounds, window_tree_host->GetBoundsInPixels()); | 943 EXPECT_EQ(bounds, window_tree_host->GetBoundsInPixels()); |
941 std::unique_ptr<InputEventBasicTestWindowDelegate> window_delegate1( | 944 std::unique_ptr<InputEventBasicTestWindowDelegate> window_delegate1( |
942 base::MakeUnique<InputEventBasicTestWindowDelegate>(window_tree())); | 945 base::MakeUnique<InputEventBasicTestWindowDelegate>(window_tree())); |
943 std::unique_ptr<Window> child1( | 946 std::unique_ptr<Window> child1( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 EXPECT_FALSE(window_delegate1->got_move()); | 1001 EXPECT_FALSE(window_delegate1->got_move()); |
999 EXPECT_TRUE(window_delegate2->got_move()); | 1002 EXPECT_TRUE(window_delegate2->got_move()); |
1000 EXPECT_EQ(gfx::Point(30, 30), window_delegate2->last_event_location()); | 1003 EXPECT_EQ(gfx::Point(30, 30), window_delegate2->last_event_location()); |
1001 child2.reset(); | 1004 child2.reset(); |
1002 child1.reset(); | 1005 child1.reset(); |
1003 window_tree_host.reset(); | 1006 window_tree_host.reset(); |
1004 capture_client.reset(); | 1007 capture_client.reset(); |
1005 } | 1008 } |
1006 | 1009 |
1007 TEST_F(WindowTreeClientClientTest, InputEventRootWindow) { | 1010 TEST_F(WindowTreeClientClientTest, InputEventRootWindow) { |
1008 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 1011 WindowTreeHostMus window_tree_host( |
| 1012 CreateInitParamsForTopLevel(window_tree_client_impl())); |
1009 Window* top_level = window_tree_host.window(); | 1013 Window* top_level = window_tree_host.window(); |
1010 InputEventBasicTestEventHandler root_handler; | 1014 InputEventBasicTestEventHandler root_handler; |
1011 top_level->AddPreTargetHandler(&root_handler); | 1015 top_level->AddPreTargetHandler(&root_handler); |
1012 const gfx::Rect bounds(0, 0, 100, 100); | 1016 const gfx::Rect bounds(0, 0, 100, 100); |
1013 window_tree_host.SetBoundsInPixels(bounds); | 1017 window_tree_host.SetBoundsInPixels(bounds); |
1014 window_tree_host.InitHost(); | 1018 window_tree_host.InitHost(); |
1015 window_tree_host.Show(); | 1019 window_tree_host.Show(); |
1016 EXPECT_EQ(bounds, top_level->bounds()); | 1020 EXPECT_EQ(bounds, top_level->bounds()); |
1017 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); | 1021 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); |
1018 InputEventBasicTestWindowDelegate child_delegate(window_tree()); | 1022 InputEventBasicTestWindowDelegate child_delegate(window_tree()); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 // trigger DCHECKs. | 1259 // trigger DCHECKs. |
1256 child.reset(); | 1260 child.reset(); |
1257 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( | 1261 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( |
1258 WindowTreeChangeType::VISIBLE, true)); | 1262 WindowTreeChangeType::VISIBLE, true)); |
1259 } | 1263 } |
1260 | 1264 |
1261 TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) { | 1265 TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) { |
1262 const size_t initial_root_count = | 1266 const size_t initial_root_count = |
1263 window_tree_client_impl()->GetRoots().size(); | 1267 window_tree_client_impl()->GetRoots().size(); |
1264 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 1268 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
1265 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); | 1269 base::MakeUnique<WindowTreeHostMus>( |
| 1270 CreateInitParamsForTopLevel(window_tree_client_impl())); |
1266 window_tree_host->InitHost(); | 1271 window_tree_host->InitHost(); |
1267 EXPECT_FALSE(window_tree_host->window()->TargetVisibility()); | 1272 EXPECT_FALSE(window_tree_host->window()->TargetVisibility()); |
1268 aura::Window* top_level = window_tree_host->window(); | 1273 aura::Window* top_level = window_tree_host->window(); |
1269 EXPECT_NE(server_id(top_level), server_id(root_window())); | 1274 EXPECT_NE(server_id(top_level), server_id(root_window())); |
1270 EXPECT_EQ(initial_root_count + 1, | 1275 EXPECT_EQ(initial_root_count + 1, |
1271 window_tree_client_impl()->GetRoots().size()); | 1276 window_tree_client_impl()->GetRoots().size()); |
1272 EXPECT_TRUE(window_tree_client_impl()->GetRoots().count(top_level) > 0u); | 1277 EXPECT_TRUE(window_tree_client_impl()->GetRoots().count(top_level) > 0u); |
1273 | 1278 |
1274 // Ack the request to the windowtree to create the new window. | 1279 // Ack the request to the windowtree to create the new window. |
1275 uint32_t change_id; | 1280 uint32_t change_id; |
(...skipping 16 matching lines...) Expand all Loading... |
1292 // ASSERT_EQ(nullptr, top_level->parent()); | 1297 // ASSERT_EQ(nullptr, top_level->parent()); |
1293 | 1298 |
1294 // Destroy the first root, shouldn't initiate tear down. | 1299 // Destroy the first root, shouldn't initiate tear down. |
1295 window_tree_host.reset(); | 1300 window_tree_host.reset(); |
1296 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); | 1301 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); |
1297 } | 1302 } |
1298 | 1303 |
1299 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) { | 1304 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) { |
1300 const size_t initial_root_count = | 1305 const size_t initial_root_count = |
1301 window_tree_client_impl()->GetRoots().size(); | 1306 window_tree_client_impl()->GetRoots().size(); |
1302 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 1307 WindowTreeHostMus window_tree_host( |
| 1308 CreateInitParamsForTopLevel(window_tree_client_impl())); |
1303 Window* top_level = window_tree_host.window(); | 1309 Window* top_level = window_tree_host.window(); |
1304 EXPECT_EQ(initial_root_count + 1, | 1310 EXPECT_EQ(initial_root_count + 1, |
1305 window_tree_client_impl()->GetRoots().size()); | 1311 window_tree_client_impl()->GetRoots().size()); |
1306 | 1312 |
1307 EXPECT_FALSE(IsWindowHostVisible(top_level)); | 1313 EXPECT_FALSE(IsWindowHostVisible(top_level)); |
1308 EXPECT_FALSE(top_level->TargetVisibility()); | 1314 EXPECT_FALSE(top_level->TargetVisibility()); |
1309 | 1315 |
1310 window_tree_host.InitHost(); | 1316 window_tree_host.InitHost(); |
1311 EXPECT_FALSE(window_tree_host.window()->TargetVisibility()); | 1317 EXPECT_FALSE(window_tree_host.window()->TargetVisibility()); |
1312 | 1318 |
(...skipping 18 matching lines...) Expand all Loading... |
1331 EXPECT_TRUE(IsWindowHostVisible(top_level)); | 1337 EXPECT_TRUE(IsWindowHostVisible(top_level)); |
1332 EXPECT_TRUE(top_level->TargetVisibility()); | 1338 EXPECT_TRUE(top_level->TargetVisibility()); |
1333 EXPECT_EQ(display_id, window_tree_host.display_id()); | 1339 EXPECT_EQ(display_id, window_tree_host.display_id()); |
1334 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); | 1340 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); |
1335 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); | 1341 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); |
1336 } | 1342 } |
1337 | 1343 |
1338 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { | 1344 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { |
1339 RegisterTestProperties(GetPropertyConverter()); | 1345 RegisterTestProperties(GetPropertyConverter()); |
1340 | 1346 |
1341 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 1347 WindowTreeHostMus window_tree_host( |
| 1348 CreateInitParamsForTopLevel(window_tree_client_impl())); |
1342 Window* top_level = window_tree_host.window(); | 1349 Window* top_level = window_tree_host.window(); |
1343 EXPECT_FALSE(top_level->TargetVisibility()); | 1350 EXPECT_FALSE(top_level->TargetVisibility()); |
1344 | 1351 |
1345 window_tree_host.InitHost(); | 1352 window_tree_host.InitHost(); |
1346 | 1353 |
1347 // Make visibility go from false->true->false. Don't ack immediately. | 1354 // Make visibility go from false->true->false. Don't ack immediately. |
1348 top_level->Show(); | 1355 top_level->Show(); |
1349 top_level->Hide(); | 1356 top_level->Hide(); |
1350 | 1357 |
1351 // Change bounds to 5, 6, 7, 8. | 1358 // Change bounds to 5, 6, 7, 8. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 EXPECT_EQ(1u, window_tree()->number_of_changes()); | 1578 EXPECT_EQ(1u, window_tree()->number_of_changes()); |
1572 window_tree()->AckAllChangesOfType(WindowTreeChangeType::REORDER, true); | 1579 window_tree()->AckAllChangesOfType(WindowTreeChangeType::REORDER, true); |
1573 EXPECT_EQ(0u, window_tree()->number_of_changes()); | 1580 EXPECT_EQ(0u, window_tree()->number_of_changes()); |
1574 } | 1581 } |
1575 | 1582 |
1576 TEST_F(WindowTreeClientClientTest, | 1583 TEST_F(WindowTreeClientClientTest, |
1577 TopLevelWindowDestroyedBeforeCreateComplete) { | 1584 TopLevelWindowDestroyedBeforeCreateComplete) { |
1578 const size_t initial_root_count = | 1585 const size_t initial_root_count = |
1579 window_tree_client_impl()->GetRoots().size(); | 1586 window_tree_client_impl()->GetRoots().size(); |
1580 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 1587 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
1581 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); | 1588 base::MakeUnique<WindowTreeHostMus>( |
| 1589 CreateInitParamsForTopLevel(window_tree_client_impl())); |
1582 window_tree_host->InitHost(); | 1590 window_tree_host->InitHost(); |
1583 EXPECT_EQ(initial_root_count + 1, | 1591 EXPECT_EQ(initial_root_count + 1, |
1584 window_tree_client_impl()->GetRoots().size()); | 1592 window_tree_client_impl()->GetRoots().size()); |
1585 | 1593 |
1586 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 1594 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
1587 data->window_id = server_id(window_tree_host->window()); | 1595 data->window_id = server_id(window_tree_host->window()); |
1588 | 1596 |
1589 // Destroy the window before the server has a chance to ack the window | 1597 // Destroy the window before the server has a chance to ack the window |
1590 // creation. | 1598 // creation. |
1591 window_tree_host.reset(); | 1599 window_tree_host.reset(); |
(...skipping 15 matching lines...) Expand all Loading... |
1607 RegisterTestProperties(GetPropertyConverter()); | 1615 RegisterTestProperties(GetPropertyConverter()); |
1608 const uint8_t property_value = 11; | 1616 const uint8_t property_value = 11; |
1609 std::map<std::string, std::vector<uint8_t>> properties; | 1617 std::map<std::string, std::vector<uint8_t>> properties; |
1610 properties[kTestPropertyServerKey1] = | 1618 properties[kTestPropertyServerKey1] = |
1611 ConvertToPropertyTransportValue(property_value); | 1619 ConvertToPropertyTransportValue(property_value); |
1612 const char kUnknownPropertyKey[] = "unknown-property"; | 1620 const char kUnknownPropertyKey[] = "unknown-property"; |
1613 using UnknownPropertyType = int32_t; | 1621 using UnknownPropertyType = int32_t; |
1614 const UnknownPropertyType kUnknownPropertyValue = 101; | 1622 const UnknownPropertyType kUnknownPropertyValue = 101; |
1615 properties[kUnknownPropertyKey] = | 1623 properties[kUnknownPropertyKey] = |
1616 mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue); | 1624 mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue); |
1617 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 1625 WindowTreeHostMus window_tree_host(CreateInitParamsForTopLevel( |
1618 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(), | 1626 window_tree_client_impl(), std::move(properties))); |
1619 cc::FrameSinkId(1, 1), &properties); | 1627 window_tree_host.InitHost(); |
1620 window_tree_host->InitHost(); | 1628 window_tree_host.window()->Show(); |
1621 window_tree_host->window()->Show(); | |
1622 // Verify the property made it to the window. | 1629 // Verify the property made it to the window. |
1623 EXPECT_EQ(property_value, | 1630 EXPECT_EQ(property_value, |
1624 window_tree_host->window()->GetProperty(kTestPropertyKey1)); | 1631 window_tree_host.window()->GetProperty(kTestPropertyKey1)); |
1625 | 1632 |
1626 // Get the id of the in flight change for creating the new top level window. | 1633 // Get the id of the in flight change for creating the new top level window. |
1627 uint32_t change_id; | 1634 uint32_t change_id; |
1628 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 1635 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
1629 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 1636 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
1630 | 1637 |
1631 // Verify the properties were sent to the server. | 1638 // Verify the properties were sent to the server. |
1632 base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>> | 1639 base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>> |
1633 transport_properties = window_tree()->GetLastNewWindowProperties(); | 1640 transport_properties = window_tree()->GetLastNewWindowProperties(); |
1634 ASSERT_TRUE(transport_properties.has_value()); | 1641 ASSERT_TRUE(transport_properties.has_value()); |
(...skipping 28 matching lines...) Expand all Loading... |
1663 | 1670 |
1664 private: | 1671 private: |
1665 bool root_destroyed_ = false; | 1672 bool root_destroyed_ = false; |
1666 | 1673 |
1667 DISALLOW_COPY_AND_ASSIGN(CloseWindowWindowTreeHostObserver); | 1674 DISALLOW_COPY_AND_ASSIGN(CloseWindowWindowTreeHostObserver); |
1668 }; | 1675 }; |
1669 | 1676 |
1670 } // namespace | 1677 } // namespace |
1671 | 1678 |
1672 TEST_F(WindowTreeClientClientTest, CloseWindow) { | 1679 TEST_F(WindowTreeClientClientTest, CloseWindow) { |
1673 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 1680 WindowTreeHostMus window_tree_host( |
| 1681 CreateInitParamsForTopLevel(window_tree_client_impl())); |
1674 window_tree_host.InitHost(); | 1682 window_tree_host.InitHost(); |
1675 CloseWindowWindowTreeHostObserver observer; | 1683 CloseWindowWindowTreeHostObserver observer; |
1676 window_tree_host.AddObserver(&observer); | 1684 window_tree_host.AddObserver(&observer); |
1677 Window* top_level = window_tree_host.window(); | 1685 Window* top_level = window_tree_host.window(); |
1678 | 1686 |
1679 // Close a root window should send close request to the observer of its | 1687 // Close a root window should send close request to the observer of its |
1680 // WindowTreeHost. | 1688 // WindowTreeHost. |
1681 EXPECT_FALSE(observer.root_destroyed()); | 1689 EXPECT_FALSE(observer.root_destroyed()); |
1682 window_tree_client()->RequestClose(server_id(top_level)); | 1690 window_tree_client()->RequestClose(server_id(top_level)); |
1683 EXPECT_TRUE(observer.root_destroyed()); | 1691 EXPECT_TRUE(observer.root_destroyed()); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 EXPECT_EQ(1, capture_recorder.capture_changed_count()); | 1884 EXPECT_EQ(1, capture_recorder.capture_changed_count()); |
1877 EXPECT_EQ(child2_id, capture_recorder.last_gained_capture_window_id()); | 1885 EXPECT_EQ(child2_id, capture_recorder.last_gained_capture_window_id()); |
1878 EXPECT_EQ(0, capture_recorder.last_lost_capture_window_id()); | 1886 EXPECT_EQ(0, capture_recorder.last_lost_capture_window_id()); |
1879 capture_recorder.reset_capture_captured_count(); | 1887 capture_recorder.reset_capture_captured_count(); |
1880 } | 1888 } |
1881 | 1889 |
1882 TEST_F(WindowTreeClientClientTest, TwoWindowTreesRequestCapture) { | 1890 TEST_F(WindowTreeClientClientTest, TwoWindowTreesRequestCapture) { |
1883 // Creating a WindowTreeHost so we can have two root windows: top_level | 1891 // Creating a WindowTreeHost so we can have two root windows: top_level |
1884 // and root_window(). | 1892 // and root_window(). |
1885 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 1893 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
1886 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); | 1894 base::MakeUnique<WindowTreeHostMus>( |
| 1895 CreateInitParamsForTopLevel(window_tree_client_impl())); |
1887 window_tree_host->InitHost(); | 1896 window_tree_host->InitHost(); |
1888 Window* top_level = window_tree_host->window(); | 1897 Window* top_level = window_tree_host->window(); |
1889 std::unique_ptr<client::DefaultCaptureClient> capture_client( | 1898 std::unique_ptr<client::DefaultCaptureClient> capture_client( |
1890 base::MakeUnique<client::DefaultCaptureClient>()); | 1899 base::MakeUnique<client::DefaultCaptureClient>()); |
1891 client::SetCaptureClient(top_level, capture_client.get()); | 1900 client::SetCaptureClient(top_level, capture_client.get()); |
1892 window_tree_client_impl()->capture_synchronizer()->AttachToCaptureClient( | 1901 window_tree_client_impl()->capture_synchronizer()->AttachToCaptureClient( |
1893 capture_client.get()); | 1902 capture_client.get()); |
1894 EXPECT_NE(server_id(top_level), server_id(root_window())); | 1903 EXPECT_NE(server_id(top_level), server_id(root_window())); |
1895 | 1904 |
1896 // Ack the request to the windowtree to create the new window. | 1905 // Ack the request to the windowtree to create the new window. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 // Simulate the server responding with a bounds change. Server should operate | 2104 // Simulate the server responding with a bounds change. Server should operate |
2096 // in pixels. | 2105 // in pixels. |
2097 const gfx::Rect server_changed_bounds(gfx::Rect(0, 0, 200, 200)); | 2106 const gfx::Rect server_changed_bounds(gfx::Rect(0, 0, 200, 200)); |
2098 window_tree_client()->OnWindowBoundsChanged( | 2107 window_tree_client()->OnWindowBoundsChanged( |
2099 server_id(root_window()), original_bounds, server_changed_bounds, | 2108 server_id(root_window()), original_bounds, server_changed_bounds, |
2100 base::nullopt); | 2109 base::nullopt); |
2101 EXPECT_EQ(new_bounds, root_window()->bounds()); | 2110 EXPECT_EQ(new_bounds, root_window()->bounds()); |
2102 } | 2111 } |
2103 | 2112 |
2104 TEST_F(WindowTreeClientClientTestHighDPI, NewTopLevelWindowBounds) { | 2113 TEST_F(WindowTreeClientClientTestHighDPI, NewTopLevelWindowBounds) { |
2105 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 2114 WindowTreeHostMus window_tree_host( |
| 2115 CreateInitParamsForTopLevel(window_tree_client_impl())); |
2106 Window* top_level = window_tree_host.window(); | 2116 Window* top_level = window_tree_host.window(); |
2107 window_tree_host.InitHost(); | 2117 window_tree_host.InitHost(); |
2108 | 2118 |
2109 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 2119 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
2110 data->window_id = server_id(top_level); | 2120 data->window_id = server_id(top_level); |
2111 data->bounds.SetRect(2, 4, 6, 8); | 2121 data->bounds.SetRect(2, 4, 6, 8); |
2112 const int64_t display_id = 10; | 2122 const int64_t display_id = 10; |
2113 uint32_t change_id; | 2123 uint32_t change_id; |
2114 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 2124 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
2115 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 2125 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 // Delegate received the event in Dips. | 2161 // Delegate received the event in Dips. |
2152 const ui::PointerEvent* last_event = last_event_observed(); | 2162 const ui::PointerEvent* last_event = last_event_observed(); |
2153 ASSERT_TRUE(last_event); | 2163 ASSERT_TRUE(last_event); |
2154 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, location_pixels), | 2164 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, location_pixels), |
2155 last_event->location()); | 2165 last_event->location()); |
2156 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, root_location_pixels), | 2166 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, root_location_pixels), |
2157 last_event->root_location()); | 2167 last_event->root_location()); |
2158 } | 2168 } |
2159 | 2169 |
2160 TEST_F(WindowTreeClientClientTestHighDPI, InputEventsInDip) { | 2170 TEST_F(WindowTreeClientClientTestHighDPI, InputEventsInDip) { |
2161 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 2171 WindowTreeHostMus window_tree_host( |
| 2172 CreateInitParamsForTopLevel(window_tree_client_impl())); |
2162 display::Screen* screen = display::Screen::GetScreen(); | 2173 display::Screen* screen = display::Screen::GetScreen(); |
2163 display::Display display; | 2174 display::Display display; |
2164 ASSERT_TRUE( | 2175 ASSERT_TRUE( |
2165 screen->GetDisplayWithDisplayId(window_tree_host.display_id(), &display)); | 2176 screen->GetDisplayWithDisplayId(window_tree_host.display_id(), &display)); |
2166 ASSERT_EQ(2.0f, display.device_scale_factor()); | 2177 ASSERT_EQ(2.0f, display.device_scale_factor()); |
2167 | 2178 |
2168 Window* top_level = window_tree_host.window(); | 2179 Window* top_level = window_tree_host.window(); |
2169 const gfx::Rect bounds_in_pixels(0, 0, 100, 100); | 2180 const gfx::Rect bounds_in_pixels(0, 0, 100, 100); |
2170 window_tree_host.SetBoundsInPixels(bounds_in_pixels); | 2181 window_tree_host.SetBoundsInPixels(bounds_in_pixels); |
2171 window_tree_host.InitHost(); | 2182 window_tree_host.InitHost(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 window_tree()->GetEventResult(event_id)); | 2235 window_tree()->GetEventResult(event_id)); |
2225 EXPECT_TRUE(window_delegate1.got_move()); | 2236 EXPECT_TRUE(window_delegate1.got_move()); |
2226 EXPECT_FALSE(window_delegate2.got_move()); | 2237 EXPECT_FALSE(window_delegate2.got_move()); |
2227 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, | 2238 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, |
2228 event_location_in_dip.y() + 30); | 2239 event_location_in_dip.y() + 30); |
2229 EXPECT_EQ(transformed_event_location_in_dip, | 2240 EXPECT_EQ(transformed_event_location_in_dip, |
2230 window_delegate1.last_event_location()); | 2241 window_delegate1.last_event_location()); |
2231 } | 2242 } |
2232 | 2243 |
2233 } // namespace aura | 2244 } // namespace aura |
OLD | NEW |