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

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

Issue 2511883006: Mojo C++ bindings: switch services/ui/public/interfaces mojom target to use STL types. (Closed)
Patch Set: . Created 4 years 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/test/mus/test_window_tree.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/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 // Register some test window properties for aura/mus conversion. 68 // Register some test window properties for aura/mus conversion.
69 void RegisterTestProperties(PropertyConverter* converter) { 69 void RegisterTestProperties(PropertyConverter* converter) {
70 converter->RegisterProperty(kTestPropertyKey1, kTestPropertyServerKey1); 70 converter->RegisterProperty(kTestPropertyKey1, kTestPropertyServerKey1);
71 converter->RegisterProperty(kTestPropertyKey2, kTestPropertyServerKey2); 71 converter->RegisterProperty(kTestPropertyKey2, kTestPropertyServerKey2);
72 converter->RegisterProperty(kTestPropertyKey3, kTestPropertyServerKey3); 72 converter->RegisterProperty(kTestPropertyKey3, kTestPropertyServerKey3);
73 } 73 }
74 74
75 // Convert a primitive aura property value to a mus transport value. 75 // Convert a primitive aura property value to a mus transport value.
76 // Note that this implicitly casts arguments to the aura storage type, int64_t. 76 // Note that this implicitly casts arguments to the aura storage type, int64_t.
77 mojo::Array<uint8_t> ConvertToPropertyTransportValue(int64_t value) { 77 std::vector<uint8_t> ConvertToPropertyTransportValue(int64_t value) {
78 return mojo::Array<uint8_t>(mojo::ConvertTo<std::vector<uint8_t>>(value)); 78 return mojo::ConvertTo<std::vector<uint8_t>>(value);
79 } 79 }
80 80
81 } // namespace 81 } // namespace
82 82
83 using WindowTreeClientWmTest = test::AuraMusWmTestBase; 83 using WindowTreeClientWmTest = test::AuraMusWmTestBase;
84 using WindowTreeClientClientTest = test::AuraMusClientTestBase; 84 using WindowTreeClientClientTest = test::AuraMusClientTestBase;
85 85
86 // Verifies bounds are reverted if the server replied that the change failed. 86 // Verifies bounds are reverted if the server replied that the change failed.
87 TEST_F(WindowTreeClientWmTest, SetBoundsFailed) { 87 TEST_F(WindowTreeClientWmTest, SetBoundsFailed) {
88 Window window(nullptr); 88 Window window(nullptr);
(...skipping 10 matching lines...) Expand all
99 99
100 // Verifies a new window from the server doesn't result in attempting to add 100 // Verifies a new window from the server doesn't result in attempting to add
101 // the window back to the server. 101 // the window back to the server.
102 TEST_F(WindowTreeClientWmTest, AddFromServerDoesntAddAgain) { 102 TEST_F(WindowTreeClientWmTest, AddFromServerDoesntAddAgain) {
103 const Id child_window_id = server_id(root_window()) + 11; 103 const Id child_window_id = server_id(root_window()) + 11;
104 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 104 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
105 data->parent_id = server_id(root_window()); 105 data->parent_id = server_id(root_window());
106 data->window_id = child_window_id; 106 data->window_id = child_window_id;
107 data->bounds = gfx::Rect(1, 2, 3, 4); 107 data->bounds = gfx::Rect(1, 2, 3, 4);
108 data->visible = false; 108 data->visible = false;
109 mojo::Array<ui::mojom::WindowDataPtr> data_array(1); 109 std::vector<ui::mojom::WindowDataPtr> data_array(1);
110 data_array[0] = std::move(data); 110 data_array[0] = std::move(data);
111 ASSERT_TRUE(root_window()->children().empty()); 111 ASSERT_TRUE(root_window()->children().empty());
112 window_tree_client()->OnWindowHierarchyChanged( 112 window_tree_client()->OnWindowHierarchyChanged(
113 child_window_id, 0, server_id(root_window()), std::move(data_array)); 113 child_window_id, 0, server_id(root_window()), std::move(data_array));
114 ASSERT_FALSE(window_tree()->has_change()); 114 ASSERT_FALSE(window_tree()->has_change());
115 ASSERT_EQ(1u, root_window()->children().size()); 115 ASSERT_EQ(1u, root_window()->children().size());
116 Window* child = root_window()->children()[0]; 116 Window* child = root_window()->children()[0];
117 EXPECT_FALSE(child->TargetVisibility()); 117 EXPECT_FALSE(child->TargetVisibility());
118 } 118 }
119 119
120 // Verifies a reparent from the server doesn't attempt signal the server. 120 // Verifies a reparent from the server doesn't attempt signal the server.
121 TEST_F(WindowTreeClientWmTest, ReparentFromServerDoesntAddAgain) { 121 TEST_F(WindowTreeClientWmTest, ReparentFromServerDoesntAddAgain) {
122 Window window1(nullptr); 122 Window window1(nullptr);
123 window1.Init(ui::LAYER_NOT_DRAWN); 123 window1.Init(ui::LAYER_NOT_DRAWN);
124 Window window2(nullptr); 124 Window window2(nullptr);
125 window2.Init(ui::LAYER_NOT_DRAWN); 125 window2.Init(ui::LAYER_NOT_DRAWN);
126 root_window()->AddChild(&window1); 126 root_window()->AddChild(&window1);
127 root_window()->AddChild(&window2); 127 root_window()->AddChild(&window2);
128 128
129 window_tree()->AckAllChanges(); 129 window_tree()->AckAllChanges();
130 // Simulate moving |window1| to be a child of |window2| from the server. 130 // Simulate moving |window1| to be a child of |window2| from the server.
131 window_tree_client()->OnWindowHierarchyChanged(server_id(&window1), 131 window_tree_client()->OnWindowHierarchyChanged(
132 server_id(root_window()), 132 server_id(&window1), server_id(root_window()), server_id(&window2),
133 server_id(&window2), nullptr); 133 std::vector<ui::mojom::WindowDataPtr>());
134 ASSERT_FALSE(window_tree()->has_change()); 134 ASSERT_FALSE(window_tree()->has_change());
135 EXPECT_EQ(&window2, window1.parent()); 135 EXPECT_EQ(&window2, window1.parent());
136 EXPECT_EQ(root_window(), window2.parent()); 136 EXPECT_EQ(root_window(), window2.parent());
137 window1.parent()->RemoveChild(&window1); 137 window1.parent()->RemoveChild(&window1);
138 } 138 }
139 139
140 // Verifies properties passed in OnWindowHierarchyChanged() make there way to 140 // Verifies properties passed in OnWindowHierarchyChanged() make there way to
141 // the new window. 141 // the new window.
142 TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithProperties) { 142 TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithProperties) {
143 RegisterTestProperties(GetPropertyConverter()); 143 RegisterTestProperties(GetPropertyConverter());
144 window_tree()->AckAllChanges(); 144 window_tree()->AckAllChanges();
145 const Id child_window_id = server_id(root_window()) + 11; 145 const Id child_window_id = server_id(root_window()) + 11;
146 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 146 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
147 const uint8_t server_test_property1_value = 91; 147 const uint8_t server_test_property1_value = 91;
148 data->properties[kTestPropertyServerKey1] = 148 data->properties[kTestPropertyServerKey1] =
149 ConvertToPropertyTransportValue(server_test_property1_value); 149 ConvertToPropertyTransportValue(server_test_property1_value);
150 data->parent_id = server_id(root_window()); 150 data->parent_id = server_id(root_window());
151 data->window_id = child_window_id; 151 data->window_id = child_window_id;
152 data->bounds = gfx::Rect(1, 2, 3, 4); 152 data->bounds = gfx::Rect(1, 2, 3, 4);
153 data->visible = false; 153 data->visible = false;
154 mojo::Array<ui::mojom::WindowDataPtr> data_array(1); 154 std::vector<ui::mojom::WindowDataPtr> data_array(1);
155 data_array[0] = std::move(data); 155 data_array[0] = std::move(data);
156 ASSERT_TRUE(root_window()->children().empty()); 156 ASSERT_TRUE(root_window()->children().empty());
157 window_tree_client()->OnWindowHierarchyChanged( 157 window_tree_client()->OnWindowHierarchyChanged(
158 child_window_id, 0, server_id(root_window()), std::move(data_array)); 158 child_window_id, 0, server_id(root_window()), std::move(data_array));
159 ASSERT_FALSE(window_tree()->has_change()); 159 ASSERT_FALSE(window_tree()->has_change());
160 ASSERT_EQ(1u, root_window()->children().size()); 160 ASSERT_EQ(1u, root_window()->children().size());
161 Window* child = root_window()->children()[0]; 161 Window* child = root_window()->children()[0];
162 EXPECT_FALSE(child->TargetVisibility()); 162 EXPECT_FALSE(child->TargetVisibility());
163 EXPECT_EQ(server_test_property1_value, child->GetProperty(kTestPropertyKey1)); 163 EXPECT_EQ(server_test_property1_value, child->GetProperty(kTestPropertyKey1));
164 } 164 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(WindowTreeChangeType::BOUNDS, 250 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(WindowTreeChangeType::BOUNDS,
251 false)); 251 false));
252 EXPECT_EQ(original_bounds, root_window()->bounds()); 252 EXPECT_EQ(original_bounds, root_window()->bounds());
253 } 253 }
254 254
255 // Verifies properties are set if the server replied that the change succeeded. 255 // Verifies properties are set if the server replied that the change succeeded.
256 TEST_F(WindowTreeClientWmTest, SetPropertySucceeded) { 256 TEST_F(WindowTreeClientWmTest, SetPropertySucceeded) {
257 ASSERT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey)); 257 ASSERT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey));
258 root_window()->SetProperty(client::kAlwaysOnTopKey, true); 258 root_window()->SetProperty(client::kAlwaysOnTopKey, true);
259 EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey)); 259 EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey));
260 mojo::Array<uint8_t> value = window_tree()->GetLastPropertyValue(); 260 base::Optional<std::vector<uint8_t>> value =
261 ASSERT_FALSE(value.is_null()); 261 window_tree()->GetLastPropertyValue();
262 ASSERT_TRUE(value.has_value());
262 // PropertyConverter uses int64_t values, even for smaller types, like bool. 263 // PropertyConverter uses int64_t values, even for smaller types, like bool.
263 ASSERT_EQ(8u, value.size()); 264 ASSERT_EQ(8u, value->size());
264 EXPECT_EQ(1, mojo::ConvertTo<int64_t>(value.PassStorage())); 265 EXPECT_EQ(1, mojo::ConvertTo<int64_t>(*value));
265 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 266 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
266 WindowTreeChangeType::PROPERTY, true)); 267 WindowTreeChangeType::PROPERTY, true));
267 EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey)); 268 EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey));
268 } 269 }
269 270
270 // Verifies properties are reverted if the server replied that the change 271 // Verifies properties are reverted if the server replied that the change
271 // failed. 272 // failed.
272 TEST_F(WindowTreeClientWmTest, SetPropertyFailed) { 273 TEST_F(WindowTreeClientWmTest, SetPropertyFailed) {
273 ASSERT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey)); 274 ASSERT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey));
274 root_window()->SetProperty(client::kAlwaysOnTopKey, true); 275 root_window()->SetProperty(client::kAlwaysOnTopKey, true);
275 EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey)); 276 EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey));
276 mojo::Array<uint8_t> value = window_tree()->GetLastPropertyValue(); 277 base::Optional<std::vector<uint8_t>> value =
277 ASSERT_FALSE(value.is_null()); 278 window_tree()->GetLastPropertyValue();
279 ASSERT_TRUE(value.has_value());
278 // PropertyConverter uses int64_t values, even for smaller types, like bool. 280 // PropertyConverter uses int64_t values, even for smaller types, like bool.
279 ASSERT_EQ(8u, value.size()); 281 ASSERT_EQ(8u, value->size());
280 EXPECT_EQ(1, mojo::ConvertTo<int64_t>(value.PassStorage())); 282 EXPECT_EQ(1, mojo::ConvertTo<int64_t>(*value));
281 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 283 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
282 WindowTreeChangeType::PROPERTY, false)); 284 WindowTreeChangeType::PROPERTY, false));
283 EXPECT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey)); 285 EXPECT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey));
284 } 286 }
285 287
286 // Simulates a property change, and while the property change is in flight the 288 // Simulates a property change, and while the property change is in flight the
287 // server replies with a new property and the original property change fails. 289 // server replies with a new property and the original property change fails.
288 TEST_F(WindowTreeClientWmTest, SetPropertyFailedWithPendingChange) { 290 TEST_F(WindowTreeClientWmTest, SetPropertyFailedWithPendingChange) {
289 RegisterTestProperties(GetPropertyConverter()); 291 RegisterTestProperties(GetPropertyConverter());
290 const uint8_t value1 = 11; 292 const uint8_t value1 = 11;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 WindowTreeChangeType::PROPERTY, false)); 352 WindowTreeChangeType::PROPERTY, false));
351 EXPECT_FALSE(root_window()->GetProperty(kTestPropertyKey3)); 353 EXPECT_FALSE(root_window()->GetProperty(kTestPropertyKey3));
352 } 354 }
353 355
354 // Verifies property setting behavior for a gfx::Rect* property. 356 // Verifies property setting behavior for a gfx::Rect* property.
355 TEST_F(WindowTreeClientWmTest, SetRectProperty) { 357 TEST_F(WindowTreeClientWmTest, SetRectProperty) {
356 gfx::Rect example(1, 2, 3, 4); 358 gfx::Rect example(1, 2, 3, 4);
357 ASSERT_EQ(nullptr, root_window()->GetProperty(client::kRestoreBoundsKey)); 359 ASSERT_EQ(nullptr, root_window()->GetProperty(client::kRestoreBoundsKey));
358 root_window()->SetProperty(client::kRestoreBoundsKey, new gfx::Rect(example)); 360 root_window()->SetProperty(client::kRestoreBoundsKey, new gfx::Rect(example));
359 EXPECT_TRUE(root_window()->GetProperty(client::kRestoreBoundsKey)); 361 EXPECT_TRUE(root_window()->GetProperty(client::kRestoreBoundsKey));
360 mojo::Array<uint8_t> value = window_tree()->GetLastPropertyValue(); 362 base::Optional<std::vector<uint8_t>> value =
361 ASSERT_FALSE(value.is_null()); 363 window_tree()->GetLastPropertyValue();
362 EXPECT_EQ(example, mojo::ConvertTo<gfx::Rect>(value.PassStorage())); 364 ASSERT_TRUE(value.has_value());
365 EXPECT_EQ(example, mojo::ConvertTo<gfx::Rect>(*value));
363 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 366 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
364 WindowTreeChangeType::PROPERTY, true)); 367 WindowTreeChangeType::PROPERTY, true));
365 EXPECT_EQ(example, *root_window()->GetProperty(client::kRestoreBoundsKey)); 368 EXPECT_EQ(example, *root_window()->GetProperty(client::kRestoreBoundsKey));
366 369
367 root_window()->SetProperty(client::kRestoreBoundsKey, new gfx::Rect()); 370 root_window()->SetProperty(client::kRestoreBoundsKey, new gfx::Rect());
368 EXPECT_EQ(gfx::Rect(), 371 EXPECT_EQ(gfx::Rect(),
369 *root_window()->GetProperty(client::kRestoreBoundsKey)); 372 *root_window()->GetProperty(client::kRestoreBoundsKey));
370 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 373 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
371 WindowTreeChangeType::PROPERTY, false)); 374 WindowTreeChangeType::PROPERTY, false));
372 EXPECT_EQ(example, *root_window()->GetProperty(client::kRestoreBoundsKey)); 375 EXPECT_EQ(example, *root_window()->GetProperty(client::kRestoreBoundsKey));
373 } 376 }
374 377
375 // Verifies property setting behavior for a std::string* property. 378 // Verifies property setting behavior for a std::string* property.
376 TEST_F(WindowTreeClientWmTest, SetStringProperty) { 379 TEST_F(WindowTreeClientWmTest, SetStringProperty) {
377 std::string example = "123"; 380 std::string example = "123";
378 ASSERT_EQ(nullptr, root_window()->GetProperty(client::kAppIdKey)); 381 ASSERT_EQ(nullptr, root_window()->GetProperty(client::kAppIdKey));
379 root_window()->SetProperty(client::kAppIdKey, new std::string(example)); 382 root_window()->SetProperty(client::kAppIdKey, new std::string(example));
380 EXPECT_TRUE(root_window()->GetProperty(client::kAppIdKey)); 383 EXPECT_TRUE(root_window()->GetProperty(client::kAppIdKey));
381 mojo::Array<uint8_t> value = window_tree()->GetLastPropertyValue(); 384 base::Optional<std::vector<uint8_t>> value =
382 ASSERT_FALSE(value.is_null()); 385 window_tree()->GetLastPropertyValue();
383 EXPECT_EQ(example, mojo::ConvertTo<std::string>(value.PassStorage())); 386 ASSERT_TRUE(value.has_value());
387 EXPECT_EQ(example, mojo::ConvertTo<std::string>(*value));
384 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 388 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
385 WindowTreeChangeType::PROPERTY, true)); 389 WindowTreeChangeType::PROPERTY, true));
386 EXPECT_EQ(example, *root_window()->GetProperty(client::kAppIdKey)); 390 EXPECT_EQ(example, *root_window()->GetProperty(client::kAppIdKey));
387 391
388 root_window()->SetProperty(client::kAppIdKey, new std::string()); 392 root_window()->SetProperty(client::kAppIdKey, new std::string());
389 EXPECT_EQ(std::string(), *root_window()->GetProperty(client::kAppIdKey)); 393 EXPECT_EQ(std::string(), *root_window()->GetProperty(client::kAppIdKey));
390 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 394 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
391 WindowTreeChangeType::PROPERTY, false)); 395 WindowTreeChangeType::PROPERTY, false));
392 EXPECT_EQ(example, *root_window()->GetProperty(client::kAppIdKey)); 396 EXPECT_EQ(example, *root_window()->GetProperty(client::kAppIdKey));
393 } 397 }
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 EXPECT_EQ(server_test_property2_value, 856 EXPECT_EQ(server_test_property2_value,
853 top_level->GetProperty(kTestPropertyKey2)); 857 top_level->GetProperty(kTestPropertyKey2));
854 } 858 }
855 859
856 TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) { 860 TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) {
857 RegisterTestProperties(GetPropertyConverter()); 861 RegisterTestProperties(GetPropertyConverter());
858 Window window(nullptr); 862 Window window(nullptr);
859 const uint8_t explicitly_set_test_property1_value = 29; 863 const uint8_t explicitly_set_test_property1_value = 29;
860 window.SetProperty(kTestPropertyKey1, explicitly_set_test_property1_value); 864 window.SetProperty(kTestPropertyKey1, explicitly_set_test_property1_value);
861 window.Init(ui::LAYER_NOT_DRAWN); 865 window.Init(ui::LAYER_NOT_DRAWN);
862 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties = 866 base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>>
863 window_tree()->GetLastNewWindowProperties(); 867 transport_properties = window_tree()->GetLastNewWindowProperties();
864 ASSERT_FALSE(transport_properties.is_null()); 868 ASSERT_TRUE(transport_properties.has_value());
865 std::map<std::string, std::vector<uint8_t>> properties = 869 std::map<std::string, std::vector<uint8_t>> properties =
866 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); 870 mojo::UnorderedMapToMap(*transport_properties);
867 ASSERT_EQ(1u, properties.count(kTestPropertyServerKey1)); 871 ASSERT_EQ(1u, properties.count(kTestPropertyServerKey1));
868 // PropertyConverter uses int64_t values, even for smaller types like uint8_t. 872 // PropertyConverter uses int64_t values, even for smaller types like uint8_t.
869 ASSERT_EQ(8u, properties[kTestPropertyServerKey1].size()); 873 ASSERT_EQ(8u, properties[kTestPropertyServerKey1].size());
870 EXPECT_EQ(static_cast<int64_t>(explicitly_set_test_property1_value), 874 EXPECT_EQ(static_cast<int64_t>(explicitly_set_test_property1_value),
871 mojo::ConvertTo<int64_t>(properties[kTestPropertyServerKey1])); 875 mojo::ConvertTo<int64_t>(properties[kTestPropertyServerKey1]));
872 ASSERT_EQ(0u, properties.count(kTestPropertyServerKey2)); 876 ASSERT_EQ(0u, properties.count(kTestPropertyServerKey2));
873 } 877 }
874 878
875 // Assertions around transient windows. 879 // Assertions around transient windows.
876 TEST_F(WindowTreeClientClientTest, Transients) { 880 TEST_F(WindowTreeClientClientTest, Transients) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 // Verify the property made it to the window. 951 // Verify the property made it to the window.
948 EXPECT_EQ(property_value, 952 EXPECT_EQ(property_value,
949 window_tree_host->window()->GetProperty(kTestPropertyKey1)); 953 window_tree_host->window()->GetProperty(kTestPropertyKey1));
950 954
951 // Get the id of the in flight change for creating the new top level window. 955 // Get the id of the in flight change for creating the new top level window.
952 uint32_t change_id; 956 uint32_t change_id;
953 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 957 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
954 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 958 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
955 959
956 // Verify the property was sent to the server. 960 // Verify the property was sent to the server.
957 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties = 961 base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>>
958 window_tree()->GetLastNewWindowProperties(); 962 transport_properties = window_tree()->GetLastNewWindowProperties();
959 ASSERT_FALSE(transport_properties.is_null()); 963 ASSERT_TRUE(transport_properties.has_value());
960 std::map<std::string, std::vector<uint8_t>> properties2 = 964 std::map<std::string, std::vector<uint8_t>> properties2 =
961 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); 965 mojo::UnorderedMapToMap(*transport_properties);
962 ASSERT_EQ(1u, properties2.count(kTestPropertyServerKey1)); 966 ASSERT_EQ(1u, properties2.count(kTestPropertyServerKey1));
963 // PropertyConverter uses int64_t values, even for smaller types like uint8_t. 967 // PropertyConverter uses int64_t values, even for smaller types like uint8_t.
964 ASSERT_EQ(8u, properties2[kTestPropertyServerKey1].size()); 968 ASSERT_EQ(8u, properties2[kTestPropertyServerKey1].size());
965 EXPECT_EQ(static_cast<int64_t>(property_value), 969 EXPECT_EQ(static_cast<int64_t>(property_value),
966 mojo::ConvertTo<int64_t>(properties2[kTestPropertyServerKey1])); 970 mojo::ConvertTo<int64_t>(properties2[kTestPropertyServerKey1]));
967 } 971 }
968 972
969 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly 973 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly
970 // updated on failures. 974 // updated on failures.
971 TEST_F(WindowTreeClientWmTest, ExplicitCapture) { 975 TEST_F(WindowTreeClientWmTest, ExplicitCapture) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 ui::mojom::WindowDataPtr data3 = ui::mojom::WindowData::New(); 1208 ui::mojom::WindowDataPtr data3 = ui::mojom::WindowData::New();
1205 data1->parent_id = server_id(root_window()); 1209 data1->parent_id = server_id(root_window());
1206 data1->window_id = server_window_id; 1210 data1->window_id = server_window_id;
1207 data1->bounds = gfx::Rect(1, 2, 3, 4); 1211 data1->bounds = gfx::Rect(1, 2, 3, 4);
1208 data2->parent_id = server_window_id; 1212 data2->parent_id = server_window_id;
1209 data2->window_id = WindowMus::Get(window1)->server_id(); 1213 data2->window_id = WindowMus::Get(window1)->server_id();
1210 data2->bounds = gfx::Rect(1, 2, 3, 4); 1214 data2->bounds = gfx::Rect(1, 2, 3, 4);
1211 data3->parent_id = server_window_id; 1215 data3->parent_id = server_window_id;
1212 data3->window_id = WindowMus::Get(window2)->server_id(); 1216 data3->window_id = WindowMus::Get(window2)->server_id();
1213 data3->bounds = gfx::Rect(1, 2, 3, 4); 1217 data3->bounds = gfx::Rect(1, 2, 3, 4);
1214 mojo::Array<ui::mojom::WindowDataPtr> data_array(3); 1218 std::vector<ui::mojom::WindowDataPtr> data_array(3);
1215 data_array[0] = std::move(data1); 1219 data_array[0] = std::move(data1);
1216 data_array[1] = std::move(data2); 1220 data_array[1] = std::move(data2);
1217 data_array[2] = std::move(data3); 1221 data_array[2] = std::move(data3);
1218 window_tree_client()->OnWindowHierarchyChanged( 1222 window_tree_client()->OnWindowHierarchyChanged(
1219 server_window_id, 0, server_id(root_window()), std::move(data_array)); 1223 server_window_id, 0, server_id(root_window()), std::move(data_array));
1220 ASSERT_FALSE(window_tree()->has_change()); 1224 ASSERT_FALSE(window_tree()->has_change());
1221 ASSERT_EQ(1u, root_window()->children().size()); 1225 ASSERT_EQ(1u, root_window()->children().size());
1222 Window* server_window = root_window()->children()[0]; 1226 Window* server_window = root_window()->children()[0];
1223 EXPECT_EQ(window1->parent(), server_window); 1227 EXPECT_EQ(window1->parent(), server_window);
1224 EXPECT_EQ(window2->parent(), server_window); 1228 EXPECT_EQ(window2->parent(), server_window);
1225 ASSERT_EQ(2u, server_window->children().size()); 1229 ASSERT_EQ(2u, server_window->children().size());
1226 EXPECT_EQ(window1, server_window->children()[0]); 1230 EXPECT_EQ(window1, server_window->children()[0]);
1227 EXPECT_EQ(window2, server_window->children()[1]); 1231 EXPECT_EQ(window2, server_window->children()[1]);
1228 } 1232 }
1229 1233
1230 } // namespace aura 1234 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/test/mus/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698