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

Side by Side Diff: services/ui/ws/window_tree_client_unittest.cc

Issue 2886873002: Only send the FrameSinkId to client when it is necessary (Closed)
Patch Set: Address review issues. Created 3 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
« 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 273 }
274 274
275 // WindowTreeClient: 275 // WindowTreeClient:
276 void OnEmbed( 276 void OnEmbed(
277 ClientSpecificId client_id, 277 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, 282 bool drawn,
283 const cc::FrameSinkId& frame_sink_id,
284 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override { 283 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override {
285 // TODO(sky): add coverage of |focused_window_id|. 284 // TODO(sky): add coverage of |focused_window_id|.
286 ASSERT_TRUE(root); 285 ASSERT_TRUE(root);
287 root_window_id_ = root->window_id; 286 root_window_id_ = root->window_id;
288 tree_ = std::move(tree); 287 tree_ = std::move(tree);
289 client_id_ = client_id; 288 client_id_ = client_id;
290 tracker()->OnEmbed(client_id, std::move(root), drawn, frame_sink_id); 289 tracker()->OnEmbed(client_id, std::move(root), drawn);
291 if (embed_run_loop_) 290 if (embed_run_loop_)
292 embed_run_loop_->Quit(); 291 embed_run_loop_->Quit();
293 } 292 }
294 void OnEmbeddedAppDisconnected(Id window_id) override { 293 void OnEmbeddedAppDisconnected(Id window_id) override {
295 tracker()->OnEmbeddedAppDisconnected(window_id); 294 tracker()->OnEmbeddedAppDisconnected(window_id);
296 } 295 }
297 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); } 296 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); }
298 void OnCaptureChanged(Id new_capture_window_id, 297 void OnCaptureChanged(Id new_capture_window_id,
299 Id old_capture_window_id) override { 298 Id old_capture_window_id) override {
300 tracker()->OnCaptureChanged(new_capture_window_id, old_capture_window_id); 299 tracker()->OnCaptureChanged(new_capture_window_id, old_capture_window_id);
301 } 300 }
302 void OnFrameSinkIdAllocated(Id window_id, 301 void OnFrameSinkIdAllocated(Id window_id,
303 const cc::FrameSinkId& frame_sink_id) override {} 302 const cc::FrameSinkId& frame_sink_id) override {}
304 void OnTopLevelCreated( 303 void OnTopLevelCreated(
305 uint32_t change_id, 304 uint32_t change_id,
306 mojom::WindowDataPtr data, 305 mojom::WindowDataPtr data,
307 int64_t display_id, 306 int64_t display_id,
308 bool drawn, 307 bool drawn,
309 const cc::FrameSinkId& frame_sink_id,
310 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override { 308 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override {
311 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn, 309 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn);
312 frame_sink_id);
313 } 310 }
314 void OnWindowBoundsChanged( 311 void OnWindowBoundsChanged(
315 Id window_id, 312 Id window_id,
316 const gfx::Rect& old_bounds, 313 const gfx::Rect& old_bounds,
317 const gfx::Rect& new_bounds, 314 const gfx::Rect& new_bounds,
318 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override { 315 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override {
319 // The bounds of the root may change during startup on Android at random 316 // The bounds of the root may change during startup on Android at random
320 // times. As this doesn't matter, and shouldn't impact test exepctations, 317 // times. As this doesn't matter, and shouldn't impact test exepctations,
321 // it is ignored. 318 // it is ignored.
322 if (window_id == root_window_id_ && !track_root_bounds_changes_) 319 if (window_id == root_window_id_ && !track_root_bounds_changes_)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 this, std::move(internal)); 443 this, std::move(internal));
447 tree_->GetWindowManagerClient(MakeRequest(&window_manager_client_)); 444 tree_->GetWindowManagerClient(MakeRequest(&window_manager_client_));
448 } 445 }
449 446
450 // mojom::WindowManager: 447 // mojom::WindowManager:
451 void OnConnect(uint16_t client_id) override {} 448 void OnConnect(uint16_t client_id) override {}
452 void WmNewDisplayAdded( 449 void WmNewDisplayAdded(
453 const display::Display& display, 450 const display::Display& display,
454 mojom::WindowDataPtr root_data, 451 mojom::WindowDataPtr root_data,
455 bool drawn, 452 bool drawn,
456 const cc::FrameSinkId& frame_sink_id,
457 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override { 453 const base::Optional<cc::LocalSurfaceId>& local_surface_id) override {
458 NOTIMPLEMENTED(); 454 NOTIMPLEMENTED();
459 } 455 }
460 void WmDisplayRemoved(int64_t display_id) override { NOTIMPLEMENTED(); } 456 void WmDisplayRemoved(int64_t display_id) override { NOTIMPLEMENTED(); }
461 void WmDisplayModified(const display::Display& display) override { 457 void WmDisplayModified(const display::Display& display) override {
462 NOTIMPLEMENTED(); 458 NOTIMPLEMENTED();
463 } 459 }
464 void WmSetBounds(uint32_t change_id, 460 void WmSetBounds(uint32_t change_id,
465 uint32_t window_id, 461 uint32_t window_id,
466 const gfx::Rect& bounds) override { 462 const gfx::Rect& bounds) override {
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 Id window_1_1 = wt_client1()->NewWindow(1); 1745 Id window_1_1 = wt_client1()->NewWindow(1);
1750 ASSERT_TRUE(window_1_1); 1746 ASSERT_TRUE(window_1_1);
1751 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); 1747 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1752 Id window_1_2 = wt_client1()->NewWindow(2); 1748 Id window_1_2 = wt_client1()->NewWindow(2);
1753 ASSERT_TRUE(window_1_2); 1749 ASSERT_TRUE(window_1_2);
1754 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1750 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1755 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2)); 1751 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
1756 1752
1757 // Establish the second client at 1,2. 1753 // Establish the second client at 1,2.
1758 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_2)); 1754 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_2));
1759 EXPECT_EQ( 1755 EXPECT_EQ("OnEmbed drawn=true", SingleChangeToDescription2(*changes2()));
1760 base::StringPrintf("OnEmbed FrameSinkId(%d, 0) drawn=true", window_1_2),
1761 SingleChangeToDescription2(*changes2()));
1762 changes2()->clear(); 1756 changes2()->clear();
1763 1757
1764 // Show 1,2 from client 1. Client 2 should see this. 1758 // Show 1,2 from client 1. Client 2 should see this.
1765 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true)); 1759 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true));
1766 { 1760 {
1767 wt_client2_->WaitForChangeCount(1); 1761 wt_client2_->WaitForChangeCount(1);
1768 EXPECT_EQ( 1762 EXPECT_EQ(
1769 "VisibilityChanged window=" + IdToString(window_1_2) + " visible=true", 1763 "VisibilityChanged window=" + IdToString(window_1_2) + " visible=true",
1770 SingleChangeToDescription(*changes2())); 1764 SingleChangeToDescription(*changes2()));
1771 } 1765 }
1772 } 1766 }
1773 1767
1774 // Assertions for SetWindowVisibility sending notifications. 1768 // Assertions for SetWindowVisibility sending notifications.
1775 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications3) { 1769 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications3) {
1776 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root. 1770 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root.
1777 Id window_1_1 = wt_client1()->NewWindow(1); 1771 Id window_1_1 = wt_client1()->NewWindow(1);
1778 ASSERT_TRUE(window_1_1); 1772 ASSERT_TRUE(window_1_1);
1779 Id window_1_2 = wt_client1()->NewWindow(2); 1773 Id window_1_2 = wt_client1()->NewWindow(2);
1780 ASSERT_TRUE(window_1_2); 1774 ASSERT_TRUE(window_1_2);
1781 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1775 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1782 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2)); 1776 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
1783 1777
1784 // Establish the second client at 1,2. 1778 // Establish the second client at 1,2.
1785 // TODO(fsamuel): Currently the FrameSinkId maps directly to the server's 1779 // TODO(fsamuel): Currently the FrameSinkId maps directly to the server's
1786 // window ID. This is likely bad from a security perspective and should be 1780 // window ID. This is likely bad from a security perspective and should be
1787 // fixed. 1781 // fixed.
1788 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_2)); 1782 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_2));
1789 EXPECT_EQ( 1783 EXPECT_EQ("OnEmbed drawn=false", SingleChangeToDescription2(*changes2()));
1790 base::StringPrintf("OnEmbed FrameSinkId(%d, 0) drawn=false", window_1_2),
1791 SingleChangeToDescription2(*changes2()));
1792 changes2()->clear(); 1784 changes2()->clear();
1793 1785
1794 // Show 1,1, drawn should be true for 1,2 (as that is all the child sees). 1786 // Show 1,1, drawn should be true for 1,2 (as that is all the child sees).
1795 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); 1787 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1796 { 1788 {
1797 wt_client2_->WaitForChangeCount(1); 1789 wt_client2_->WaitForChangeCount(1);
1798 EXPECT_EQ( 1790 EXPECT_EQ(
1799 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true", 1791 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true",
1800 SingleChangeToDescription(*changes2())); 1792 SingleChangeToDescription(*changes2()));
1801 } 1793 }
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 2263
2272 // TODO(sky): make sure coverage of what was 2264 // TODO(sky): make sure coverage of what was
2273 // WindowManagerTest.SecondEmbedRoot_InitService and 2265 // WindowManagerTest.SecondEmbedRoot_InitService and
2274 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 2266 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
2275 // manager 2267 // manager
2276 // tests. 2268 // tests.
2277 2269
2278 } // namespace test 2270 } // namespace test
2279 } // namespace ws 2271 } // namespace ws
2280 } // namespace ui 2272 } // 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