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

Side by Side Diff: components/mus/ws/window_tree_client_unittest.cc

Issue 2008193002: Change mojo geometry structs from using type converters to StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "components/mus/public/cpp/tests/window_server_shelltest_base.h" 13 #include "components/mus/public/cpp/tests/window_server_shelltest_base.h"
14 #include "components/mus/public/interfaces/window_tree.mojom.h" 14 #include "components/mus/public/interfaces/window_tree.mojom.h"
15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" 15 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
16 #include "components/mus/ws/ids.h" 16 #include "components/mus/ws/ids.h"
17 #include "components/mus/ws/test_change_tracker.h" 17 #include "components/mus/ws/test_change_tracker.h"
18 #include "mojo/converters/geometry/geometry_type_converters.h"
19 #include "mojo/public/cpp/bindings/associated_binding.h" 18 #include "mojo/public/cpp/bindings/associated_binding.h"
20 #include "services/shell/public/cpp/shell_test.h" 19 #include "services/shell/public/cpp/shell_test.h"
21 20
22 using mojo::Array; 21 using mojo::Array;
23 using mojo::Callback; 22 using mojo::Callback;
24 using shell::Connection; 23 using shell::Connection;
25 using mojo::InterfaceRequest; 24 using mojo::InterfaceRequest;
26 using mojo::RectPtr;
27 using shell::ShellClient; 25 using shell::ShellClient;
28 using mojo::String; 26 using mojo::String;
29 using mus::mojom::ErrorCode; 27 using mus::mojom::ErrorCode;
30 using mus::mojom::EventPtr; 28 using mus::mojom::EventPtr;
31 using mus::mojom::ViewportMetricsPtr; 29 using mus::mojom::ViewportMetricsPtr;
32 using mus::mojom::WindowDataPtr; 30 using mus::mojom::WindowDataPtr;
33 using mus::mojom::WindowTree; 31 using mus::mojom::WindowTree;
34 using mus::mojom::WindowTreeClient; 32 using mus::mojom::WindowTreeClient;
35 33
36 namespace mus { 34 namespace mus {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); } 292 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); }
295 void OnLostCapture(Id window_id) override { 293 void OnLostCapture(Id window_id) override {
296 tracker()->OnLostCapture(window_id); 294 tracker()->OnLostCapture(window_id);
297 } 295 }
298 void OnTopLevelCreated(uint32_t change_id, 296 void OnTopLevelCreated(uint32_t change_id,
299 mojom::WindowDataPtr data, 297 mojom::WindowDataPtr data,
300 bool drawn) override { 298 bool drawn) override {
301 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn); 299 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn);
302 } 300 }
303 void OnWindowBoundsChanged(Id window_id, 301 void OnWindowBoundsChanged(Id window_id,
304 RectPtr old_bounds, 302 const gfx::Rect& old_bounds,
305 RectPtr new_bounds) override { 303 const gfx::Rect& new_bounds) override {
306 // The bounds of the root may change during startup on Android at random 304 // The bounds of the root may change during startup on Android at random
307 // times. As this doesn't matter, and shouldn't impact test exepctations, 305 // times. As this doesn't matter, and shouldn't impact test exepctations,
308 // it is ignored. 306 // it is ignored.
309 if (window_id == root_window_id_ && !track_root_bounds_changes_) 307 if (window_id == root_window_id_ && !track_root_bounds_changes_)
310 return; 308 return;
311 tracker()->OnWindowBoundsChanged(window_id, std::move(old_bounds), 309 tracker()->OnWindowBoundsChanged(window_id, old_bounds, new_bounds);
312 std::move(new_bounds));
313 } 310 }
314 void OnClientAreaChanged( 311 void OnClientAreaChanged(
315 uint32_t window_id, 312 uint32_t window_id,
316 mojo::InsetsPtr new_client_area, 313 const gfx::Insets& new_client_area,
317 mojo::Array<mojo::RectPtr> new_additional_client_areas) override {} 314 mojo::Array<gfx::Rect> new_additional_client_areas) override {}
318 void OnTransientWindowAdded(uint32_t window_id, 315 void OnTransientWindowAdded(uint32_t window_id,
319 uint32_t transient_window_id) override { 316 uint32_t transient_window_id) override {
320 tracker()->OnTransientWindowAdded(window_id, transient_window_id); 317 tracker()->OnTransientWindowAdded(window_id, transient_window_id);
321 } 318 }
322 void OnTransientWindowRemoved(uint32_t window_id, 319 void OnTransientWindowRemoved(uint32_t window_id,
323 uint32_t transient_window_id) override { 320 uint32_t transient_window_id) override {
324 tracker()->OnTransientWindowRemoved(window_id, transient_window_id); 321 tracker()->OnTransientWindowRemoved(window_id, transient_window_id);
325 } 322 }
326 void OnWindowViewportMetricsChanged(mojo::Array<uint32_t> window_ids, 323 void OnWindowViewportMetricsChanged(mojo::Array<uint32_t> window_ids,
327 ViewportMetricsPtr old_metrics, 324 ViewportMetricsPtr old_metrics,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 window_manager_binding_.reset( 387 window_manager_binding_.reset(
391 new mojo::AssociatedBinding<mojom::WindowManager>(this, 388 new mojo::AssociatedBinding<mojom::WindowManager>(this,
392 std::move(internal))); 389 std::move(internal)));
393 tree_->GetWindowManagerClient( 390 tree_->GetWindowManagerClient(
394 GetProxy(&window_manager_client_, tree_.associated_group())); 391 GetProxy(&window_manager_client_, tree_.associated_group()));
395 } 392 }
396 393
397 // mojom::WindowManager: 394 // mojom::WindowManager:
398 void WmSetBounds(uint32_t change_id, 395 void WmSetBounds(uint32_t change_id,
399 uint32_t window_id, 396 uint32_t window_id,
400 mojo::RectPtr bounds) override { 397 const gfx::Rect& bounds) override {
401 window_manager_client_->WmResponse(change_id, false); 398 window_manager_client_->WmResponse(change_id, false);
402 } 399 }
403 void WmSetProperty(uint32_t change_id, 400 void WmSetProperty(uint32_t change_id,
404 uint32_t window_id, 401 uint32_t window_id,
405 const mojo::String& name, 402 const mojo::String& name,
406 mojo::Array<uint8_t> value) override { 403 mojo::Array<uint8_t> value) override {
407 window_manager_client_->WmResponse(change_id, false); 404 window_manager_client_->WmResponse(change_id, false);
408 } 405 }
409 void WmCreateTopLevelWindow( 406 void WmCreateTopLevelWindow(
410 uint32_t change_id, 407 uint32_t change_id,
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 Id window_1_1 = wt_client1()->NewWindow(1); 1205 Id window_1_1 = wt_client1()->NewWindow(1);
1209 ASSERT_TRUE(window_1_1); 1206 ASSERT_TRUE(window_1_1);
1210 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1207 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1211 1208
1212 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1209 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1213 1210
1214 changes2()->clear(); 1211 changes2()->clear();
1215 1212
1216 wt_client2_->set_track_root_bounds_changes(true); 1213 wt_client2_->set_track_root_bounds_changes(true);
1217 1214
1218 wt1()->SetWindowBounds(10, window_1_1, 1215 wt1()->SetWindowBounds(10, window_1_1, gfx::Rect(0, 0, 100, 100));
1219 mojo::Rect::From(gfx::Rect(0, 0, 100, 100)));
1220 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(10)); 1216 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(10));
1221 1217
1222 wt_client2_->WaitForChangeCount(1); 1218 wt_client2_->WaitForChangeCount(1);
1223 EXPECT_EQ("BoundsChanged window=" + IdToString(window_1_1) + 1219 EXPECT_EQ("BoundsChanged window=" + IdToString(window_1_1) +
1224 " old_bounds=0,0 0x0 new_bounds=0,0 100x100", 1220 " old_bounds=0,0 0x0 new_bounds=0,0 100x100",
1225 SingleChangeToDescription(*changes2())); 1221 SingleChangeToDescription(*changes2()));
1226 1222
1227 // Should not be possible to change the bounds of a window created by another 1223 // Should not be possible to change the bounds of a window created by another
1228 // connection. 1224 // connection.
1229 wt2()->SetWindowBounds(11, window_1_1, 1225 wt2()->SetWindowBounds(11, window_1_1, gfx::Rect(0, 0, 0, 0));
1230 mojo::Rect::From(gfx::Rect(0, 0, 0, 0)));
1231 ASSERT_FALSE(wt_client2()->WaitForChangeCompleted(11)); 1226 ASSERT_FALSE(wt_client2()->WaitForChangeCompleted(11));
1232 } 1227 }
1233 1228
1234 // Verify AddWindow fails when trying to manipulate windows in other roots. 1229 // Verify AddWindow fails when trying to manipulate windows in other roots.
1235 TEST_F(WindowTreeClientTest, CantMoveWindowsFromOtherRoot) { 1230 TEST_F(WindowTreeClientTest, CantMoveWindowsFromOtherRoot) {
1236 // Create 1 and 2 in the first connection. 1231 // Create 1 and 2 in the first connection.
1237 Id window_1_1 = wt_client1()->NewWindow(1); 1232 Id window_1_1 = wt_client1()->NewWindow(1);
1238 Id window_1_2 = wt_client1()->NewWindow(2); 1233 Id window_1_2 = wt_client1()->NewWindow(2);
1239 ASSERT_TRUE(window_1_1); 1234 ASSERT_TRUE(window_1_1);
1240 ASSERT_TRUE(window_1_2); 1235 ASSERT_TRUE(window_1_2);
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 const Id window_2_101 = wt_client2()->NewWindow(101); 1952 const Id window_2_101 = wt_client2()->NewWindow(101);
1958 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101)); 1953 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101));
1959 const Id window_2_101_in_ws1 = BuildWindowId(connection_id_2(), 1); 1954 const Id window_2_101_in_ws1 = BuildWindowId(connection_id_2(), 1);
1960 wt_client1()->WaitForChangeCount(1); 1955 wt_client1()->WaitForChangeCount(1);
1961 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws1) + 1956 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws1) +
1962 " old_parent=null new_parent=" + IdToString(window_1_100), 1957 " old_parent=null new_parent=" + IdToString(window_1_100),
1963 SingleChangeToDescription(*changes1())); 1958 SingleChangeToDescription(*changes1()));
1964 changes1()->clear(); 1959 changes1()->clear();
1965 1960
1966 // Change the bounds of window_2_101 and make sure server gets it. 1961 // Change the bounds of window_2_101 and make sure server gets it.
1967 wt2()->SetWindowBounds(11, window_2_101, 1962 wt2()->SetWindowBounds(11, window_2_101, gfx::Rect(1, 2, 3, 4));
1968 mojo::Rect::From(gfx::Rect(1, 2, 3, 4)));
1969 ASSERT_TRUE(wt_client2()->WaitForChangeCompleted(11)); 1963 ASSERT_TRUE(wt_client2()->WaitForChangeCompleted(11));
1970 wt_client1()->WaitForChangeCount(1); 1964 wt_client1()->WaitForChangeCount(1);
1971 EXPECT_EQ("BoundsChanged window=" + IdToString(window_2_101_in_ws1) + 1965 EXPECT_EQ("BoundsChanged window=" + IdToString(window_2_101_in_ws1) +
1972 " old_bounds=0,0 0x0 new_bounds=1,2 3x4", 1966 " old_bounds=0,0 0x0 new_bounds=1,2 3x4",
1973 SingleChangeToDescription(*changes1())); 1967 SingleChangeToDescription(*changes1()));
1974 changes2()->clear(); 1968 changes2()->clear();
1975 1969
1976 // Remove 2_101 from wm, client1 should see the change. 1970 // Remove 2_101 from wm, client1 should see the change.
1977 wt1()->RemoveWindowFromParent(12, window_2_101_in_ws1); 1971 wt1()->RemoveWindowFromParent(12, window_2_101_in_ws1);
1978 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(12)); 1972 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(12));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 2034
2041 // TODO(sky): make sure coverage of what was 2035 // TODO(sky): make sure coverage of what was
2042 // WindowManagerTest.SecondEmbedRoot_InitService and 2036 // WindowManagerTest.SecondEmbedRoot_InitService and
2043 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 2037 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
2044 // manager 2038 // manager
2045 // tests. 2039 // tests.
2046 2040
2047 } // namespace test 2041 } // namespace test
2048 } // namespace ws 2042 } // namespace ws
2049 } // namespace mus 2043 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698