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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 | 1076 |
1077 // Ack the request to the windowtree to create the new window. | 1077 // Ack the request to the windowtree to create the new window. |
1078 uint32_t change_id; | 1078 uint32_t change_id; |
1079 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 1079 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
1080 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 1080 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
1081 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); | 1081 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); |
1082 | 1082 |
1083 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 1083 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
1084 data->window_id = server_id(top_level); | 1084 data->window_id = server_id(top_level); |
1085 const int64_t display_id = 1; | 1085 const int64_t display_id = 1; |
1086 window_tree_client()->OnTopLevelCreated( | 1086 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
1087 change_id, std::move(data), display_id, false, cc::FrameSinkId(1, 1)); | 1087 display_id, false, |
| 1088 cc::FrameSinkId(1, 1), base::nullopt); |
1088 | 1089 |
1089 EXPECT_FALSE(window_tree_host->window()->TargetVisibility()); | 1090 EXPECT_FALSE(window_tree_host->window()->TargetVisibility()); |
1090 | 1091 |
1091 // Should not be able to add a top level as a child of another window. | 1092 // Should not be able to add a top level as a child of another window. |
1092 // TODO(sky): decide how to handle this. | 1093 // TODO(sky): decide how to handle this. |
1093 // root_window()->AddChild(top_level); | 1094 // root_window()->AddChild(top_level); |
1094 // ASSERT_EQ(nullptr, top_level->parent()); | 1095 // ASSERT_EQ(nullptr, top_level->parent()); |
1095 | 1096 |
1096 // Destroy the first root, shouldn't initiate tear down. | 1097 // Destroy the first root, shouldn't initiate tear down. |
1097 window_tree_host.reset(); | 1098 window_tree_host.reset(); |
(...skipping 18 matching lines...) Expand all Loading... |
1116 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); | 1117 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); |
1117 | 1118 |
1118 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 1119 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
1119 data->window_id = server_id(top_level); | 1120 data->window_id = server_id(top_level); |
1120 data->bounds.SetRect(1, 2, 3, 4); | 1121 data->bounds.SetRect(1, 2, 3, 4); |
1121 data->visible = true; | 1122 data->visible = true; |
1122 const int64_t display_id = 10; | 1123 const int64_t display_id = 10; |
1123 uint32_t change_id; | 1124 uint32_t change_id; |
1124 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 1125 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
1125 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 1126 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
1126 window_tree_client()->OnTopLevelCreated( | 1127 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
1127 change_id, std::move(data), display_id, true, cc::FrameSinkId(1, 1)); | 1128 display_id, true, |
| 1129 cc::FrameSinkId(1, 1), base::nullopt); |
1128 EXPECT_EQ( | 1130 EXPECT_EQ( |
1129 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); | 1131 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); |
1130 | 1132 |
1131 // Make sure all the properties took. | 1133 // Make sure all the properties took. |
1132 EXPECT_TRUE(IsWindowHostVisible(top_level)); | 1134 EXPECT_TRUE(IsWindowHostVisible(top_level)); |
1133 EXPECT_TRUE(top_level->TargetVisibility()); | 1135 EXPECT_TRUE(top_level->TargetVisibility()); |
1134 EXPECT_EQ(display_id, window_tree_host.display_id()); | 1136 EXPECT_EQ(display_id, window_tree_host.display_id()); |
1135 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); | 1137 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); |
1136 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); | 1138 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); |
1137 } | 1139 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 const uint8_t server_test_property2_value = 4; | 1171 const uint8_t server_test_property2_value = 4; |
1170 data->properties[kTestPropertyServerKey2] = | 1172 data->properties[kTestPropertyServerKey2] = |
1171 ConvertToPropertyTransportValue(server_test_property2_value); | 1173 ConvertToPropertyTransportValue(server_test_property2_value); |
1172 const int64_t display_id = 1; | 1174 const int64_t display_id = 1; |
1173 // Get the id of the in flight change for creating the new top_level. | 1175 // Get the id of the in flight change for creating the new top_level. |
1174 uint32_t new_window_in_flight_change_id; | 1176 uint32_t new_window_in_flight_change_id; |
1175 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 1177 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
1176 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); | 1178 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); |
1177 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, | 1179 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, |
1178 std::move(data), display_id, true, | 1180 std::move(data), display_id, true, |
1179 cc::FrameSinkId(1, 1)); | 1181 cc::FrameSinkId(1, 1), base::nullopt); |
1180 | 1182 |
1181 // The only value that should take effect is the property for 'yy' as it was | 1183 // The only value that should take effect is the property for 'yy' as it was |
1182 // not in flight. | 1184 // not in flight. |
1183 EXPECT_FALSE(top_level->TargetVisibility()); | 1185 EXPECT_FALSE(top_level->TargetVisibility()); |
1184 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixels()); | 1186 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixels()); |
1185 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds()); | 1187 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds()); |
1186 EXPECT_EQ(explicitly_set_test_property1_value, | 1188 EXPECT_EQ(explicitly_set_test_property1_value, |
1187 top_level->GetProperty(kTestPropertyKey1)); | 1189 top_level->GetProperty(kTestPropertyKey1)); |
1188 EXPECT_EQ(server_test_property2_value, | 1190 EXPECT_EQ(server_test_property2_value, |
1189 top_level->GetProperty(kTestPropertyKey2)); | 1191 top_level->GetProperty(kTestPropertyKey2)); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 // creation. | 1393 // creation. |
1392 window_tree_host.reset(); | 1394 window_tree_host.reset(); |
1393 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); | 1395 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); |
1394 | 1396 |
1395 // Get the id of the in flight change for creating the new window. | 1397 // Get the id of the in flight change for creating the new window. |
1396 uint32_t change_id; | 1398 uint32_t change_id; |
1397 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 1399 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
1398 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 1400 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
1399 | 1401 |
1400 const int64_t display_id = 1; | 1402 const int64_t display_id = 1; |
1401 window_tree_client()->OnTopLevelCreated( | 1403 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
1402 change_id, std::move(data), display_id, true, cc::FrameSinkId(1, 1)); | 1404 display_id, true, |
| 1405 cc::FrameSinkId(1, 1), base::nullopt); |
1403 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); | 1406 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); |
1404 } | 1407 } |
1405 | 1408 |
1406 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) { | 1409 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) { |
1407 RegisterTestProperties(GetPropertyConverter()); | 1410 RegisterTestProperties(GetPropertyConverter()); |
1408 const uint8_t property_value = 11; | 1411 const uint8_t property_value = 11; |
1409 std::map<std::string, std::vector<uint8_t>> properties; | 1412 std::map<std::string, std::vector<uint8_t>> properties; |
1410 properties[kTestPropertyServerKey1] = | 1413 properties[kTestPropertyServerKey1] = |
1411 ConvertToPropertyTransportValue(property_value); | 1414 ConvertToPropertyTransportValue(property_value); |
1412 const char kUnknownPropertyKey[] = "unknown-property"; | 1415 const char kUnknownPropertyKey[] = "unknown-property"; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 // Ack the request to the windowtree to create the new window. | 1699 // Ack the request to the windowtree to create the new window. |
1697 uint32_t change_id; | 1700 uint32_t change_id; |
1698 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 1701 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
1699 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 1702 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
1700 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); | 1703 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); |
1701 | 1704 |
1702 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 1705 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
1703 data->window_id = server_id(top_level); | 1706 data->window_id = server_id(top_level); |
1704 data->visible = true; | 1707 data->visible = true; |
1705 const int64_t display_id = 1; | 1708 const int64_t display_id = 1; |
1706 window_tree_client()->OnTopLevelCreated( | 1709 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
1707 change_id, std::move(data), display_id, true, cc::FrameSinkId(1, 1)); | 1710 display_id, true, |
| 1711 cc::FrameSinkId(1, 1), base::nullopt); |
1708 EXPECT_EQ( | 1712 EXPECT_EQ( |
1709 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); | 1713 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); |
1710 EXPECT_TRUE(top_level->TargetVisibility()); | 1714 EXPECT_TRUE(top_level->TargetVisibility()); |
1711 | 1715 |
1712 std::unique_ptr<CaptureRecorder> capture_recorder1( | 1716 std::unique_ptr<CaptureRecorder> capture_recorder1( |
1713 base::MakeUnique<CaptureRecorder>(root_window())); | 1717 base::MakeUnique<CaptureRecorder>(root_window())); |
1714 std::unique_ptr<CaptureRecorder> capture_recorder2( | 1718 std::unique_ptr<CaptureRecorder> capture_recorder2( |
1715 base::MakeUnique<CaptureRecorder>(top_level)); | 1719 base::MakeUnique<CaptureRecorder>(top_level)); |
1716 EXPECT_NE(client::GetCaptureClient(root_window()), | 1720 EXPECT_NE(client::GetCaptureClient(root_window()), |
1717 client::GetCaptureClient(top_level)); | 1721 client::GetCaptureClient(top_level)); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 Window* top_level = window_tree_host.window(); | 1909 Window* top_level = window_tree_host.window(); |
1906 window_tree_host.InitHost(); | 1910 window_tree_host.InitHost(); |
1907 | 1911 |
1908 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 1912 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
1909 data->window_id = server_id(top_level); | 1913 data->window_id = server_id(top_level); |
1910 data->bounds.SetRect(2, 4, 6, 8); | 1914 data->bounds.SetRect(2, 4, 6, 8); |
1911 const int64_t display_id = 10; | 1915 const int64_t display_id = 10; |
1912 uint32_t change_id; | 1916 uint32_t change_id; |
1913 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 1917 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
1914 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); | 1918 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); |
1915 window_tree_client()->OnTopLevelCreated( | 1919 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
1916 change_id, std::move(data), display_id, true, cc::FrameSinkId(1, 1)); | 1920 display_id, true, |
| 1921 cc::FrameSinkId(1, 1), base::nullopt); |
1917 | 1922 |
1918 // aura::Window should operate in DIP and aura::WindowTreeHost should operate | 1923 // aura::Window should operate in DIP and aura::WindowTreeHost should operate |
1919 // in pixels. | 1924 // in pixels. |
1920 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); | 1925 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); |
1921 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); | 1926 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); |
1922 } | 1927 } |
1923 | 1928 |
1924 TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) { | 1929 TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) { |
1925 display::Screen* screen = display::Screen::GetScreen(); | 1930 display::Screen* screen = display::Screen::GetScreen(); |
1926 const display::Display primary_display = screen->GetPrimaryDisplay(); | 1931 const display::Display primary_display = screen->GetPrimaryDisplay(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 window_tree()->GetEventResult(event_id)); | 2027 window_tree()->GetEventResult(event_id)); |
2023 EXPECT_TRUE(window_delegate1.got_move()); | 2028 EXPECT_TRUE(window_delegate1.got_move()); |
2024 EXPECT_FALSE(window_delegate2.got_move()); | 2029 EXPECT_FALSE(window_delegate2.got_move()); |
2025 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, | 2030 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, |
2026 event_location_in_dip.y() + 30); | 2031 event_location_in_dip.y() + 30); |
2027 EXPECT_EQ(transformed_event_location_in_dip, | 2032 EXPECT_EQ(transformed_event_location_in_dip, |
2028 window_delegate1.last_event_location()); | 2033 window_delegate1.last_event_location()); |
2029 } | 2034 } |
2030 | 2035 |
2031 } // namespace aura | 2036 } // namespace aura |
OLD | NEW |