Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2764433003: mus-ws: Plumb FrameSinkId to Children (Closed)
Patch Set: Addressed Antoine's comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/mus/window_tree_host_mus.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 gfx::Point last_event_location_; 567 gfx::Point last_event_location_;
568 uint32_t event_id_ = 0; 568 uint32_t event_id_ = 0;
569 569
570 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestEventHandler); 570 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestEventHandler);
571 }; 571 };
572 572
573 } // namespace 573 } // namespace
574 574
575 TEST_F(WindowTreeClientClientTest, InputEventBasic) { 575 TEST_F(WindowTreeClientClientTest, InputEventBasic) {
576 InputEventBasicTestWindowDelegate window_delegate(window_tree()); 576 InputEventBasicTestWindowDelegate window_delegate(window_tree());
577 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 577 WindowTreeHostMus window_tree_host(window_tree_client_impl(),
578 cc::FrameSinkId(1, 1));
578 Window* top_level = window_tree_host.window(); 579 Window* top_level = window_tree_host.window();
579 const gfx::Rect bounds(0, 0, 100, 100); 580 const gfx::Rect bounds(0, 0, 100, 100);
580 window_tree_host.SetBoundsInPixels(bounds); 581 window_tree_host.SetBoundsInPixels(bounds);
581 window_tree_host.InitHost(); 582 window_tree_host.InitHost();
582 window_tree_host.Show(); 583 window_tree_host.Show();
583 EXPECT_EQ(bounds, top_level->bounds()); 584 EXPECT_EQ(bounds, top_level->bounds());
584 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); 585 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
585 Window child(&window_delegate); 586 Window child(&window_delegate);
586 child.Init(ui::LAYER_NOT_DRAWN); 587 child.Init(ui::LAYER_NOT_DRAWN);
587 top_level->AddChild(&child); 588 top_level->AddChild(&child);
(...skipping 12 matching lines...) Expand all
600 ui::Event::Clone(*ui_event.get()), 0); 601 ui::Event::Clone(*ui_event.get()), 0);
601 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 602 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
602 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 603 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
603 window_tree()->GetEventResult(event_id)); 604 window_tree()->GetEventResult(event_id));
604 EXPECT_TRUE(window_delegate.got_move()); 605 EXPECT_TRUE(window_delegate.got_move());
605 EXPECT_FALSE(window_delegate.was_acked()); 606 EXPECT_FALSE(window_delegate.was_acked());
606 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); 607 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location());
607 } 608 }
608 609
609 TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) { 610 TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) {
610 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 611 WindowTreeHostMus window_tree_host(window_tree_client_impl(),
612 cc::FrameSinkId(1, 1));
611 Window* top_level = window_tree_host.window(); 613 Window* top_level = window_tree_host.window();
612 const gfx::Rect bounds(0, 0, 100, 100); 614 const gfx::Rect bounds(0, 0, 100, 100);
613 window_tree_host.SetBoundsInPixels(bounds); 615 window_tree_host.SetBoundsInPixels(bounds);
614 window_tree_host.InitHost(); 616 window_tree_host.InitHost();
615 window_tree_host.Show(); 617 window_tree_host.Show();
616 EXPECT_EQ(bounds, top_level->bounds()); 618 EXPECT_EQ(bounds, top_level->bounds());
617 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); 619 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
618 InputEventBasicTestWindowDelegate window_delegate1(window_tree()); 620 InputEventBasicTestWindowDelegate window_delegate1(window_tree());
619 Window child1(&window_delegate1); 621 Window child1(&window_delegate1);
620 child1.Init(ui::LAYER_NOT_DRAWN); 622 child1.Init(ui::LAYER_NOT_DRAWN);
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 1076
1075 // Ack the request to the windowtree to create the new window. 1077 // Ack the request to the windowtree to create the new window.
1076 uint32_t change_id; 1078 uint32_t change_id;
1077 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1079 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1078 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1080 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1079 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); 1081 EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
1080 1082
1081 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 1083 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
1082 data->window_id = server_id(top_level); 1084 data->window_id = server_id(top_level);
1083 const int64_t display_id = 1; 1085 const int64_t display_id = 1;
1084 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1086 window_tree_client()->OnTopLevelCreated(
1085 display_id, false); 1087 change_id, std::move(data), display_id, false, cc::FrameSinkId(1, 1));
1086 1088
1087 EXPECT_FALSE(window_tree_host->window()->TargetVisibility()); 1089 EXPECT_FALSE(window_tree_host->window()->TargetVisibility());
1088 1090
1089 // Should not be able to add a top level as a child of another window. 1091 // Should not be able to add a top level as a child of another window.
1090 // TODO(sky): decide how to handle this. 1092 // TODO(sky): decide how to handle this.
1091 // root_window()->AddChild(top_level); 1093 // root_window()->AddChild(top_level);
1092 // ASSERT_EQ(nullptr, top_level->parent()); 1094 // ASSERT_EQ(nullptr, top_level->parent());
1093 1095
1094 // Destroy the first root, shouldn't initiate tear down. 1096 // Destroy the first root, shouldn't initiate tear down.
1095 window_tree_host.reset(); 1097 window_tree_host.reset();
(...skipping 18 matching lines...) Expand all
1114 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); 1116 EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
1115 1117
1116 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 1118 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
1117 data->window_id = server_id(top_level); 1119 data->window_id = server_id(top_level);
1118 data->bounds.SetRect(1, 2, 3, 4); 1120 data->bounds.SetRect(1, 2, 3, 4);
1119 data->visible = true; 1121 data->visible = true;
1120 const int64_t display_id = 10; 1122 const int64_t display_id = 10;
1121 uint32_t change_id; 1123 uint32_t change_id;
1122 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1124 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1123 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1125 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1124 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1126 window_tree_client()->OnTopLevelCreated(
1125 display_id, true); 1127 change_id, std::move(data), display_id, true, cc::FrameSinkId(1, 1));
1126 EXPECT_EQ( 1128 EXPECT_EQ(
1127 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); 1129 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
1128 1130
1129 // Make sure all the properties took. 1131 // Make sure all the properties took.
1130 EXPECT_TRUE(IsWindowHostVisible(top_level)); 1132 EXPECT_TRUE(IsWindowHostVisible(top_level));
1131 EXPECT_TRUE(top_level->TargetVisibility()); 1133 EXPECT_TRUE(top_level->TargetVisibility());
1132 EXPECT_EQ(display_id, window_tree_host.display_id()); 1134 EXPECT_EQ(display_id, window_tree_host.display_id());
1133 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); 1135 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
1134 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); 1136 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels());
1135 } 1137 }
(...skipping 30 matching lines...) Expand all
1166 ConvertToPropertyTransportValue(server_test_property1_value); 1168 ConvertToPropertyTransportValue(server_test_property1_value);
1167 const uint8_t server_test_property2_value = 4; 1169 const uint8_t server_test_property2_value = 4;
1168 data->properties[kTestPropertyServerKey2] = 1170 data->properties[kTestPropertyServerKey2] =
1169 ConvertToPropertyTransportValue(server_test_property2_value); 1171 ConvertToPropertyTransportValue(server_test_property2_value);
1170 const int64_t display_id = 1; 1172 const int64_t display_id = 1;
1171 // Get the id of the in flight change for creating the new top_level. 1173 // Get the id of the in flight change for creating the new top_level.
1172 uint32_t new_window_in_flight_change_id; 1174 uint32_t new_window_in_flight_change_id;
1173 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1175 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1174 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); 1176 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id));
1175 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, 1177 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id,
1176 std::move(data), display_id, true); 1178 std::move(data), display_id, true,
1179 cc::FrameSinkId(1, 1));
1177 1180
1178 // The only value that should take effect is the property for 'yy' as it was 1181 // The only value that should take effect is the property for 'yy' as it was
1179 // not in flight. 1182 // not in flight.
1180 EXPECT_FALSE(top_level->TargetVisibility()); 1183 EXPECT_FALSE(top_level->TargetVisibility());
1181 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixels()); 1184 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixels());
1182 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds()); 1185 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds());
1183 EXPECT_EQ(explicitly_set_test_property1_value, 1186 EXPECT_EQ(explicitly_set_test_property1_value,
1184 top_level->GetProperty(kTestPropertyKey1)); 1187 top_level->GetProperty(kTestPropertyKey1));
1185 EXPECT_EQ(server_test_property2_value, 1188 EXPECT_EQ(server_test_property2_value,
1186 top_level->GetProperty(kTestPropertyKey2)); 1189 top_level->GetProperty(kTestPropertyKey2));
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 // creation. 1391 // creation.
1389 window_tree_host.reset(); 1392 window_tree_host.reset();
1390 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); 1393 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
1391 1394
1392 // Get the id of the in flight change for creating the new window. 1395 // Get the id of the in flight change for creating the new window.
1393 uint32_t change_id; 1396 uint32_t change_id;
1394 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1397 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1395 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1398 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1396 1399
1397 const int64_t display_id = 1; 1400 const int64_t display_id = 1;
1398 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1401 window_tree_client()->OnTopLevelCreated(
1399 display_id, true); 1402 change_id, std::move(data), display_id, true, cc::FrameSinkId(1, 1));
1400 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); 1403 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
1401 } 1404 }
1402 1405
1403 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) { 1406 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) {
1404 RegisterTestProperties(GetPropertyConverter()); 1407 RegisterTestProperties(GetPropertyConverter());
1405 const uint8_t property_value = 11; 1408 const uint8_t property_value = 11;
1406 std::map<std::string, std::vector<uint8_t>> properties; 1409 std::map<std::string, std::vector<uint8_t>> properties;
1407 properties[kTestPropertyServerKey1] = 1410 properties[kTestPropertyServerKey1] =
1408 ConvertToPropertyTransportValue(property_value); 1411 ConvertToPropertyTransportValue(property_value);
1409 const char kUnknownPropertyKey[] = "unknown-property"; 1412 const char kUnknownPropertyKey[] = "unknown-property";
1410 using UnknownPropertyType = int32_t; 1413 using UnknownPropertyType = int32_t;
1411 const UnknownPropertyType kUnknownPropertyValue = 101; 1414 const UnknownPropertyType kUnknownPropertyValue = 101;
1412 properties[kUnknownPropertyKey] = 1415 properties[kUnknownPropertyKey] =
1413 mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue); 1416 mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue);
1414 std::unique_ptr<WindowTreeHostMus> window_tree_host = 1417 std::unique_ptr<WindowTreeHostMus> window_tree_host =
1415 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(), 1418 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(),
1416 &properties); 1419 cc::FrameSinkId(1, 1), &properties);
1417 window_tree_host->InitHost(); 1420 window_tree_host->InitHost();
1418 window_tree_host->window()->Show(); 1421 window_tree_host->window()->Show();
1419 // Verify the property made it to the window. 1422 // Verify the property made it to the window.
1420 EXPECT_EQ(property_value, 1423 EXPECT_EQ(property_value,
1421 window_tree_host->window()->GetProperty(kTestPropertyKey1)); 1424 window_tree_host->window()->GetProperty(kTestPropertyKey1));
1422 1425
1423 // Get the id of the in flight change for creating the new top level window. 1426 // Get the id of the in flight change for creating the new top level window.
1424 uint32_t change_id; 1427 uint32_t change_id;
1425 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1428 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1426 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1429 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 // Ack the request to the windowtree to create the new window. 1696 // Ack the request to the windowtree to create the new window.
1694 uint32_t change_id; 1697 uint32_t change_id;
1695 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1698 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1696 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1699 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1697 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); 1700 EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
1698 1701
1699 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 1702 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
1700 data->window_id = server_id(top_level); 1703 data->window_id = server_id(top_level);
1701 data->visible = true; 1704 data->visible = true;
1702 const int64_t display_id = 1; 1705 const int64_t display_id = 1;
1703 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1706 window_tree_client()->OnTopLevelCreated(
1704 display_id, true); 1707 change_id, std::move(data), display_id, true, cc::FrameSinkId(1, 1));
1705 EXPECT_EQ( 1708 EXPECT_EQ(
1706 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); 1709 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
1707 EXPECT_TRUE(top_level->TargetVisibility()); 1710 EXPECT_TRUE(top_level->TargetVisibility());
1708 1711
1709 std::unique_ptr<CaptureRecorder> capture_recorder1( 1712 std::unique_ptr<CaptureRecorder> capture_recorder1(
1710 base::MakeUnique<CaptureRecorder>(root_window())); 1713 base::MakeUnique<CaptureRecorder>(root_window()));
1711 std::unique_ptr<CaptureRecorder> capture_recorder2( 1714 std::unique_ptr<CaptureRecorder> capture_recorder2(
1712 base::MakeUnique<CaptureRecorder>(top_level)); 1715 base::MakeUnique<CaptureRecorder>(top_level));
1713 EXPECT_NE(client::GetCaptureClient(root_window()), 1716 EXPECT_NE(client::GetCaptureClient(root_window()),
1714 client::GetCaptureClient(top_level)); 1717 client::GetCaptureClient(top_level));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 Window* top_level = window_tree_host.window(); 1905 Window* top_level = window_tree_host.window();
1903 window_tree_host.InitHost(); 1906 window_tree_host.InitHost();
1904 1907
1905 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 1908 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
1906 data->window_id = server_id(top_level); 1909 data->window_id = server_id(top_level);
1907 data->bounds.SetRect(2, 4, 6, 8); 1910 data->bounds.SetRect(2, 4, 6, 8);
1908 const int64_t display_id = 10; 1911 const int64_t display_id = 10;
1909 uint32_t change_id; 1912 uint32_t change_id;
1910 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1913 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1911 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1914 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1912 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1915 window_tree_client()->OnTopLevelCreated(
1913 display_id, true); 1916 change_id, std::move(data), display_id, true, cc::FrameSinkId(1, 1));
1914 1917
1915 // aura::Window should operate in DIP and aura::WindowTreeHost should operate 1918 // aura::Window should operate in DIP and aura::WindowTreeHost should operate
1916 // in pixels. 1919 // in pixels.
1917 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); 1920 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
1918 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); 1921 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels());
1919 } 1922 }
1920 1923
1921 TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) { 1924 TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) {
1922 display::Screen* screen = display::Screen::GetScreen(); 1925 display::Screen* screen = display::Screen::GetScreen();
1923 const display::Display primary_display = screen->GetPrimaryDisplay(); 1926 const display::Display primary_display = screen->GetPrimaryDisplay();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 window_tree()->GetEventResult(event_id)); 2022 window_tree()->GetEventResult(event_id));
2020 EXPECT_TRUE(window_delegate1.got_move()); 2023 EXPECT_TRUE(window_delegate1.got_move());
2021 EXPECT_FALSE(window_delegate2.got_move()); 2024 EXPECT_FALSE(window_delegate2.got_move());
2022 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, 2025 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20,
2023 event_location_in_dip.y() + 30); 2026 event_location_in_dip.y() + 30);
2024 EXPECT_EQ(transformed_event_location_in_dip, 2027 EXPECT_EQ(transformed_event_location_in_dip,
2025 window_delegate1.last_event_location()); 2028 window_delegate1.last_event_location());
2026 } 2029 }
2027 2030
2028 } // namespace aura 2031 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/mus/window_tree_host_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698