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

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

Issue 1864113002: Fixes problems with drawn state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: parentdrawn and merge Created 4 years, 8 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 | « components/mus/ws/window_tree.cc ('k') | components/mus/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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if (wait_state_.get() && 264 if (wait_state_.get() &&
265 tracker_.changes()->size() >= wait_state_->change_count) { 265 tracker_.changes()->size() >= wait_state_->change_count) {
266 wait_state_->run_loop.Quit(); 266 wait_state_->run_loop.Quit();
267 } 267 }
268 } 268 }
269 269
270 // WindowTreeClient: 270 // WindowTreeClient:
271 void OnEmbed(ConnectionSpecificId connection_id, 271 void OnEmbed(ConnectionSpecificId connection_id,
272 WindowDataPtr root, 272 WindowDataPtr root,
273 mojom::WindowTreePtr tree, 273 mojom::WindowTreePtr tree,
274 Id focused_window_id) override { 274 Id focused_window_id,
275 bool drawn) override {
275 // TODO(sky): add coverage of |focused_window_id|. 276 // TODO(sky): add coverage of |focused_window_id|.
276 ASSERT_TRUE(root); 277 ASSERT_TRUE(root);
277 root_window_id_ = root->window_id; 278 root_window_id_ = root->window_id;
278 tree_ = std::move(tree); 279 tree_ = std::move(tree);
279 connection_id_ = connection_id; 280 connection_id_ = connection_id;
280 tracker()->OnEmbed(connection_id, std::move(root)); 281 tracker()->OnEmbed(connection_id, std::move(root), drawn);
281 if (embed_run_loop_) 282 if (embed_run_loop_)
282 embed_run_loop_->Quit(); 283 embed_run_loop_->Quit();
283 } 284 }
284 void OnEmbeddedAppDisconnected(Id window_id) override { 285 void OnEmbeddedAppDisconnected(Id window_id) override {
285 tracker()->OnEmbeddedAppDisconnected(window_id); 286 tracker()->OnEmbeddedAppDisconnected(window_id);
286 } 287 }
287 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); } 288 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); }
288 void OnLostCapture(Id window_id) override { 289 void OnLostCapture(Id window_id) override {
289 tracker()->OnLostCapture(window_id); 290 tracker()->OnLostCapture(window_id);
290 } 291 }
291 void OnTopLevelCreated(uint32_t change_id, 292 void OnTopLevelCreated(uint32_t change_id,
292 mojom::WindowDataPtr data) override { 293 mojom::WindowDataPtr data,
293 tracker()->OnTopLevelCreated(change_id, std::move(data)); 294 bool drawn) override {
295 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn);
294 } 296 }
295 void OnWindowBoundsChanged(Id window_id, 297 void OnWindowBoundsChanged(Id window_id,
296 RectPtr old_bounds, 298 RectPtr old_bounds,
297 RectPtr new_bounds) override { 299 RectPtr new_bounds) override {
298 // The bounds of the root may change during startup on Android at random 300 // The bounds of the root may change during startup on Android at random
299 // times. As this doesn't matter, and shouldn't impact test exepctations, 301 // times. As this doesn't matter, and shouldn't impact test exepctations,
300 // it is ignored. 302 // it is ignored.
301 if (window_id == root_window_id_ && !track_root_bounds_changes_) 303 if (window_id == root_window_id_ && !track_root_bounds_changes_)
302 return; 304 return;
303 tracker()->OnWindowBoundsChanged(window_id, std::move(old_bounds), 305 tracker()->OnWindowBoundsChanged(window_id, std::move(old_bounds),
(...skipping 28 matching lines...) Expand all
332 Id relative_window_id, 334 Id relative_window_id,
333 mojom::OrderDirection direction) override { 335 mojom::OrderDirection direction) override {
334 tracker()->OnWindowReordered(window_id, relative_window_id, direction); 336 tracker()->OnWindowReordered(window_id, relative_window_id, direction);
335 } 337 }
336 void OnWindowDeleted(Id window) override { 338 void OnWindowDeleted(Id window) override {
337 tracker()->OnWindowDeleted(window); 339 tracker()->OnWindowDeleted(window);
338 } 340 }
339 void OnWindowVisibilityChanged(uint32_t window, bool visible) override { 341 void OnWindowVisibilityChanged(uint32_t window, bool visible) override {
340 tracker()->OnWindowVisibilityChanged(window, visible); 342 tracker()->OnWindowVisibilityChanged(window, visible);
341 } 343 }
342 void OnWindowDrawnStateChanged(uint32_t window, bool drawn) override { 344 void OnWindowParentDrawnStateChanged(uint32_t window, bool drawn) override {
343 tracker()->OnWindowDrawnStateChanged(window, drawn); 345 tracker()->OnWindowParentDrawnStateChanged(window, drawn);
344 } 346 }
345 void OnWindowInputEvent(uint32_t event_id, 347 void OnWindowInputEvent(uint32_t event_id,
346 Id window_id, 348 Id window_id,
347 EventPtr event) override { 349 EventPtr event) override {
348 // Ack input events to clear the state on the server. These can be received 350 // Ack input events to clear the state on the server. These can be received
349 // during test startup. X11Window::DispatchEvent sends a synthetic move 351 // during test startup. X11Window::DispatchEvent sends a synthetic move
350 // event to notify of entry. 352 // event to notify of entry.
351 tree()->OnWindowInputEventAck(event_id, true); 353 tree()->OnWindowInputEventAck(event_id, true);
352 // Don't log input events as none of the tests care about them and they 354 // Don't log input events as none of the tests care about them and they
353 // may come in at random points. 355 // may come in at random points.
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 Id window_1_1 = wt_client1()->NewWindow(1); 1406 Id window_1_1 = wt_client1()->NewWindow(1);
1405 Id window_1_2 = wt_client1()->NewWindow(2); 1407 Id window_1_2 = wt_client1()->NewWindow(2);
1406 ASSERT_TRUE(window_1_1); 1408 ASSERT_TRUE(window_1_1);
1407 ASSERT_TRUE(window_1_2); 1409 ASSERT_TRUE(window_1_2);
1408 1410
1409 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1411 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1410 { 1412 {
1411 std::vector<TestWindow> windows; 1413 std::vector<TestWindow> windows;
1412 GetWindowTree(wt1(), root_window_id(), &windows); 1414 GetWindowTree(wt1(), root_window_id(), &windows);
1413 ASSERT_EQ(2u, windows.size()); 1415 ASSERT_EQ(2u, windows.size());
1414 EXPECT_EQ(WindowParentToString(root_window_id(), kNullParentId) + 1416 EXPECT_EQ(
1415 " visible=true drawn=true", 1417 WindowParentToString(root_window_id(), kNullParentId) + " visible=true",
1416 windows[0].ToString2()); 1418 windows[0].ToString2());
1417 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + 1419 EXPECT_EQ(
1418 " visible=false drawn=false", 1420 WindowParentToString(window_1_1, root_window_id()) + " visible=false",
1419 windows[1].ToString2()); 1421 windows[1].ToString2());
1420 } 1422 }
1421 1423
1422 // Show all the windows. 1424 // Show all the windows.
1423 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); 1425 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1424 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true)); 1426 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true));
1425 { 1427 {
1426 std::vector<TestWindow> windows; 1428 std::vector<TestWindow> windows;
1427 GetWindowTree(wt1(), root_window_id(), &windows); 1429 GetWindowTree(wt1(), root_window_id(), &windows);
1428 ASSERT_EQ(2u, windows.size()); 1430 ASSERT_EQ(2u, windows.size());
1429 EXPECT_EQ(WindowParentToString(root_window_id(), kNullParentId) + 1431 EXPECT_EQ(
1430 " visible=true drawn=true", 1432 WindowParentToString(root_window_id(), kNullParentId) + " visible=true",
1431 windows[0].ToString2()); 1433 windows[0].ToString2());
1432 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + 1434 EXPECT_EQ(
1433 " visible=true drawn=true", 1435 WindowParentToString(window_1_1, root_window_id()) + " visible=true",
1434 windows[1].ToString2()); 1436 windows[1].ToString2());
1435 } 1437 }
1436 1438
1437 // Hide 1. 1439 // Hide 1.
1438 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, false)); 1440 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, false));
1439 { 1441 {
1440 std::vector<TestWindow> windows; 1442 std::vector<TestWindow> windows;
1441 GetWindowTree(wt1(), window_1_1, &windows); 1443 GetWindowTree(wt1(), window_1_1, &windows);
1442 ASSERT_EQ(1u, windows.size()); 1444 ASSERT_EQ(1u, windows.size());
1443 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + 1445 EXPECT_EQ(
1444 " visible=false drawn=false", 1446 WindowParentToString(window_1_1, root_window_id()) + " visible=false",
1445 windows[0].ToString2()); 1447 windows[0].ToString2());
1446 } 1448 }
1447 1449
1448 // Attach 2 to 1. 1450 // Attach 2 to 1.
1449 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2)); 1451 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
1450 { 1452 {
1451 std::vector<TestWindow> windows; 1453 std::vector<TestWindow> windows;
1452 GetWindowTree(wt1(), window_1_1, &windows); 1454 GetWindowTree(wt1(), window_1_1, &windows);
1453 ASSERT_EQ(2u, windows.size()); 1455 ASSERT_EQ(2u, windows.size());
1454 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + 1456 EXPECT_EQ(
1455 " visible=false drawn=false", 1457 WindowParentToString(window_1_1, root_window_id()) + " visible=false",
1456 windows[0].ToString2()); 1458 windows[0].ToString2());
1457 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) + 1459 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) + " visible=true",
1458 " visible=true drawn=false",
1459 windows[1].ToString2()); 1460 windows[1].ToString2());
1460 } 1461 }
1461 1462
1462 // Show 1. 1463 // Show 1.
1463 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); 1464 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1464 { 1465 {
1465 std::vector<TestWindow> windows; 1466 std::vector<TestWindow> windows;
1466 GetWindowTree(wt1(), window_1_1, &windows); 1467 GetWindowTree(wt1(), window_1_1, &windows);
1467 ASSERT_EQ(2u, windows.size()); 1468 ASSERT_EQ(2u, windows.size());
1468 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + 1469 EXPECT_EQ(
1469 " visible=true drawn=true", 1470 WindowParentToString(window_1_1, root_window_id()) + " visible=true",
1470 windows[0].ToString2()); 1471 windows[0].ToString2());
1471 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) + 1472 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) + " visible=true",
1472 " visible=true drawn=true",
1473 windows[1].ToString2()); 1473 windows[1].ToString2());
1474 } 1474 }
1475 } 1475 }
1476 1476
1477 // Test that we hear the cursor change in other connections. 1477 // Test that we hear the cursor change in other connections.
1478 TEST_F(WindowTreeClientTest, SetCursor) { 1478 TEST_F(WindowTreeClientTest, SetCursor) {
1479 // Get a second connection to listen in. 1479 // Get a second connection to listen in.
1480 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1480 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1481 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1481 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1482 changes2()->clear(); 1482 changes2()->clear();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 // Add 1,1 back to the root, connection 2 should see drawn state changed. 1575 // Add 1,1 back to the root, connection 2 should see drawn state changed.
1576 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1576 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1577 { 1577 {
1578 wt_client2_->WaitForChangeCount(1); 1578 wt_client2_->WaitForChangeCount(1);
1579 EXPECT_EQ( 1579 EXPECT_EQ(
1580 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true", 1580 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true",
1581 SingleChangeToDescription(*changes2())); 1581 SingleChangeToDescription(*changes2()));
1582 } 1582 }
1583 } 1583 }
1584 1584
1585 // Assertions for SetWindowVisibility sending notifications.
1586 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications2) {
1587 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root.
1588 Id window_1_1 = wt_client1()->NewWindow(1);
1589 ASSERT_TRUE(window_1_1);
1590 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1591 Id window_1_2 = wt_client1()->NewWindow(2);
1592 ASSERT_TRUE(window_1_2);
1593 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1594 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
1595
1596 // Establish the second connection at 1,2.
1597 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnectionWithRoot(window_1_2));
1598 EXPECT_EQ("OnEmbed drawn=true", SingleChangeToDescription2(*changes2()));
1599 changes2()->clear();
1600
1601 // Show 1,2 from connection 1. Connection 2 should see this.
1602 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true));
1603 {
1604 wt_client2_->WaitForChangeCount(1);
1605 EXPECT_EQ(
1606 "VisibilityChanged window=" + IdToString(window_1_2) + " visible=true",
1607 SingleChangeToDescription(*changes2()));
1608 }
1609 }
1610
1611 // Assertions for SetWindowVisibility sending notifications.
1612 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications3) {
1613 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root.
1614 Id window_1_1 = wt_client1()->NewWindow(1);
1615 ASSERT_TRUE(window_1_1);
1616 Id window_1_2 = wt_client1()->NewWindow(2);
1617 ASSERT_TRUE(window_1_2);
1618 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1619 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
1620
1621 // Establish the second connection at 1,2.
1622 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnectionWithRoot(window_1_2));
1623 EXPECT_EQ("OnEmbed drawn=false", SingleChangeToDescription2(*changes2()));
1624 changes2()->clear();
1625
1626 // Show 1,1, drawn should be true for 1,2 (as that is all the child sees).
1627 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1628 {
1629 wt_client2_->WaitForChangeCount(1);
1630 EXPECT_EQ(
1631 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true",
1632 SingleChangeToDescription(*changes2()));
1633 }
1634 changes2()->clear();
1635
1636 // Show 1,2, visible should be true.
1637 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true));
1638 {
1639 wt_client2_->WaitForChangeCount(1);
1640 EXPECT_EQ(
1641 "VisibilityChanged window=" + IdToString(window_1_2) + " visible=true",
1642 SingleChangeToDescription(*changes2()));
1643 }
1644 }
1645
1585 TEST_F(WindowTreeClientTest, SetWindowProperty) { 1646 TEST_F(WindowTreeClientTest, SetWindowProperty) {
1586 Id window_1_1 = wt_client1()->NewWindow(1); 1647 Id window_1_1 = wt_client1()->NewWindow(1);
1587 ASSERT_TRUE(window_1_1); 1648 ASSERT_TRUE(window_1_1);
1588 1649
1589 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1650 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1590 changes2()->clear(); 1651 changes2()->clear();
1591 1652
1592 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1653 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1593 { 1654 {
1594 std::vector<TestWindow> windows; 1655 std::vector<TestWindow> windows;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 1987
1927 // TODO(sky): make sure coverage of what was 1988 // TODO(sky): make sure coverage of what was
1928 // WindowManagerTest.SecondEmbedRoot_InitService and 1989 // WindowManagerTest.SecondEmbedRoot_InitService and
1929 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 1990 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
1930 // manager 1991 // manager
1931 // tests. 1992 // tests.
1932 1993
1933 } // namespace test 1994 } // namespace test
1934 } // namespace ws 1995 } // namespace ws
1935 } // namespace mus 1996 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree.cc ('k') | components/mus/ws/window_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698