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

Side by Side Diff: services/ui/ws/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 | « services/ui/ws/window_tree.cc ('k') | services/ui/ws/window_tree_unittest.cc » ('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 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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 wait_state_->run_loop.Quit(); 272 wait_state_->run_loop.Quit();
273 } 273 }
274 } 274 }
275 275
276 // WindowTreeClient: 276 // WindowTreeClient:
277 void OnEmbed(ClientSpecificId client_id, 277 void OnEmbed(ClientSpecificId client_id,
278 WindowDataPtr root, 278 WindowDataPtr root,
279 mojom::WindowTreePtr tree, 279 mojom::WindowTreePtr tree,
280 int64_t display_id, 280 int64_t display_id,
281 Id focused_window_id, 281 Id focused_window_id,
282 bool drawn) override { 282 bool drawn,
283 const cc::FrameSinkId& frame_sink_id) override {
283 // TODO(sky): add coverage of |focused_window_id|. 284 // TODO(sky): add coverage of |focused_window_id|.
284 ASSERT_TRUE(root); 285 ASSERT_TRUE(root);
285 root_window_id_ = root->window_id; 286 root_window_id_ = root->window_id;
286 tree_ = std::move(tree); 287 tree_ = std::move(tree);
287 client_id_ = client_id; 288 client_id_ = client_id;
288 tracker()->OnEmbed(client_id, std::move(root), drawn); 289 tracker()->OnEmbed(client_id, std::move(root), drawn, frame_sink_id);
289 if (embed_run_loop_) 290 if (embed_run_loop_)
290 embed_run_loop_->Quit(); 291 embed_run_loop_->Quit();
291 } 292 }
292 void OnEmbeddedAppDisconnected(Id window_id) override { 293 void OnEmbeddedAppDisconnected(Id window_id) override {
293 tracker()->OnEmbeddedAppDisconnected(window_id); 294 tracker()->OnEmbeddedAppDisconnected(window_id);
294 } 295 }
295 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); } 296 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); }
296 void OnCaptureChanged(Id new_capture_window_id, 297 void OnCaptureChanged(Id new_capture_window_id,
297 Id old_capture_window_id) override { 298 Id old_capture_window_id) override {
298 tracker()->OnCaptureChanged(new_capture_window_id, old_capture_window_id); 299 tracker()->OnCaptureChanged(new_capture_window_id, old_capture_window_id);
299 } 300 }
300 void OnTopLevelCreated(uint32_t change_id, 301 void OnTopLevelCreated(uint32_t change_id,
301 mojom::WindowDataPtr data, 302 mojom::WindowDataPtr data,
302 int64_t display_id, 303 int64_t display_id,
303 bool drawn) override { 304 bool drawn,
304 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn); 305 const cc::FrameSinkId& frame_sink_id) override {
306 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn,
307 frame_sink_id);
305 } 308 }
306 void OnWindowBoundsChanged( 309 void OnWindowBoundsChanged(
307 Id window_id, 310 Id window_id,
308 const gfx::Rect& old_bounds, 311 const gfx::Rect& old_bounds,
309 const gfx::Rect& new_bounds, 312 const gfx::Rect& new_bounds,
310 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override { 313 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override {
311 // The bounds of the root may change during startup on Android at random 314 // The bounds of the root may change during startup on Android at random
312 // times. As this doesn't matter, and shouldn't impact test exepctations, 315 // times. As this doesn't matter, and shouldn't impact test exepctations,
313 // it is ignored. 316 // it is ignored.
314 if (window_id == root_window_id_ && !track_root_bounds_changes_) 317 if (window_id == root_window_id_ && !track_root_bounds_changes_)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 window_manager_binding_ = 439 window_manager_binding_ =
437 base::MakeUnique<mojo::AssociatedBinding<mojom::WindowManager>>( 440 base::MakeUnique<mojo::AssociatedBinding<mojom::WindowManager>>(
438 this, std::move(internal)); 441 this, std::move(internal));
439 tree_->GetWindowManagerClient(MakeRequest(&window_manager_client_)); 442 tree_->GetWindowManagerClient(MakeRequest(&window_manager_client_));
440 } 443 }
441 444
442 // mojom::WindowManager: 445 // mojom::WindowManager:
443 void OnConnect(uint16_t client_id) override {} 446 void OnConnect(uint16_t client_id) override {}
444 void WmNewDisplayAdded(const display::Display& display, 447 void WmNewDisplayAdded(const display::Display& display,
445 mojom::WindowDataPtr root_data, 448 mojom::WindowDataPtr root_data,
446 bool drawn) override { 449 bool drawn,
450 const cc::FrameSinkId& frame_sink_id) override {
447 NOTIMPLEMENTED(); 451 NOTIMPLEMENTED();
448 } 452 }
449 void WmDisplayRemoved(int64_t display_id) override { NOTIMPLEMENTED(); } 453 void WmDisplayRemoved(int64_t display_id) override { NOTIMPLEMENTED(); }
450 void WmDisplayModified(const display::Display& display) override { 454 void WmDisplayModified(const display::Display& display) override {
451 NOTIMPLEMENTED(); 455 NOTIMPLEMENTED();
452 } 456 }
453 void WmSetBounds(uint32_t change_id, 457 void WmSetBounds(uint32_t change_id,
454 uint32_t window_id, 458 uint32_t window_id,
455 const gfx::Rect& bounds) override { 459 const gfx::Rect& bounds) override {
456 window_manager_client_->WmResponse(change_id, false); 460 window_manager_client_->WmResponse(change_id, false);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 return nullptr; 643 return nullptr;
640 } 644 }
641 std::unique_ptr<TestWindowTreeClient> client = 645 std::unique_ptr<TestWindowTreeClient> client =
642 client_factory_->WaitForInstance(); 646 client_factory_->WaitForInstance();
643 if (!client.get()) { 647 if (!client.get()) {
644 ADD_FAILURE() << "WaitForInstance failed"; 648 ADD_FAILURE() << "WaitForInstance failed";
645 return nullptr; 649 return nullptr;
646 } 650 }
647 client->WaitForOnEmbed(); 651 client->WaitForOnEmbed();
648 652
653 // TODO(fsamuel): Currently the FrameSinkId maps directly to the server's
654 // window ID. This is likely bad from a security perspective and should be
655 // fixed.
649 EXPECT_EQ("OnEmbed", 656 EXPECT_EQ("OnEmbed",
650 SingleChangeToDescription(*client->tracker()->changes())); 657 SingleChangeToDescription(*client->tracker()->changes()));
651 if (client_id) 658 if (client_id)
652 *client_id = (*client->tracker()->changes())[0].client_id; 659 *client_id = (*client->tracker()->changes())[0].client_id;
653 return client; 660 return client;
654 } 661 }
655 662
656 // WindowServerServiceTestBase: 663 // WindowServerServiceTestBase:
657 bool OnConnect(const service_manager::Identity& remote_identity, 664 bool OnConnect(const service_manager::Identity& remote_identity,
658 service_manager::InterfaceRegistry* registry) override { 665 service_manager::InterfaceRegistry* registry) override {
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 Id window_1_1 = wt_client1()->NewWindow(1); 1729 Id window_1_1 = wt_client1()->NewWindow(1);
1723 ASSERT_TRUE(window_1_1); 1730 ASSERT_TRUE(window_1_1);
1724 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); 1731 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1725 Id window_1_2 = wt_client1()->NewWindow(2); 1732 Id window_1_2 = wt_client1()->NewWindow(2);
1726 ASSERT_TRUE(window_1_2); 1733 ASSERT_TRUE(window_1_2);
1727 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1734 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1728 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2)); 1735 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
1729 1736
1730 // Establish the second client at 1,2. 1737 // Establish the second client at 1,2.
1731 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_2)); 1738 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_2));
1732 EXPECT_EQ("OnEmbed drawn=true", SingleChangeToDescription2(*changes2())); 1739 EXPECT_EQ(
1740 base::StringPrintf("OnEmbed FrameSinkId(%d, 0) drawn=true", window_1_2),
1741 SingleChangeToDescription2(*changes2()));
1733 changes2()->clear(); 1742 changes2()->clear();
1734 1743
1735 // Show 1,2 from client 1. Client 2 should see this. 1744 // Show 1,2 from client 1. Client 2 should see this.
1736 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true)); 1745 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true));
1737 { 1746 {
1738 wt_client2_->WaitForChangeCount(1); 1747 wt_client2_->WaitForChangeCount(1);
1739 EXPECT_EQ( 1748 EXPECT_EQ(
1740 "VisibilityChanged window=" + IdToString(window_1_2) + " visible=true", 1749 "VisibilityChanged window=" + IdToString(window_1_2) + " visible=true",
1741 SingleChangeToDescription(*changes2())); 1750 SingleChangeToDescription(*changes2()));
1742 } 1751 }
1743 } 1752 }
1744 1753
1745 // Assertions for SetWindowVisibility sending notifications. 1754 // Assertions for SetWindowVisibility sending notifications.
1746 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications3) { 1755 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications3) {
1747 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root. 1756 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root.
1748 Id window_1_1 = wt_client1()->NewWindow(1); 1757 Id window_1_1 = wt_client1()->NewWindow(1);
1749 ASSERT_TRUE(window_1_1); 1758 ASSERT_TRUE(window_1_1);
1750 Id window_1_2 = wt_client1()->NewWindow(2); 1759 Id window_1_2 = wt_client1()->NewWindow(2);
1751 ASSERT_TRUE(window_1_2); 1760 ASSERT_TRUE(window_1_2);
1752 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1761 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1753 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2)); 1762 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
1754 1763
1755 // Establish the second client at 1,2. 1764 // Establish the second client at 1,2.
1765 // TODO(fsamuel): Currently the FrameSinkId maps directly to the server's
1766 // window ID. This is likely bad from a security perspective and should be
1767 // fixed.
1756 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_2)); 1768 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_2));
1757 EXPECT_EQ("OnEmbed drawn=false", SingleChangeToDescription2(*changes2())); 1769 EXPECT_EQ(
1770 base::StringPrintf("OnEmbed FrameSinkId(%d, 0) drawn=false", window_1_2),
1771 SingleChangeToDescription2(*changes2()));
1758 changes2()->clear(); 1772 changes2()->clear();
1759 1773
1760 // Show 1,1, drawn should be true for 1,2 (as that is all the child sees). 1774 // Show 1,1, drawn should be true for 1,2 (as that is all the child sees).
1761 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); 1775 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1762 { 1776 {
1763 wt_client2_->WaitForChangeCount(1); 1777 wt_client2_->WaitForChangeCount(1);
1764 EXPECT_EQ( 1778 EXPECT_EQ(
1765 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true", 1779 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true",
1766 SingleChangeToDescription(*changes2())); 1780 SingleChangeToDescription(*changes2()));
1767 } 1781 }
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 2249
2236 // TODO(sky): make sure coverage of what was 2250 // TODO(sky): make sure coverage of what was
2237 // WindowManagerTest.SecondEmbedRoot_InitService and 2251 // WindowManagerTest.SecondEmbedRoot_InitService and
2238 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 2252 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
2239 // manager 2253 // manager
2240 // tests. 2254 // tests.
2241 2255
2242 } // namespace test 2256 } // namespace test
2243 } // namespace ws 2257 } // namespace ws
2244 } // namespace ui 2258 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.cc ('k') | services/ui/ws/window_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698