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

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

Issue 1469603003: mus: Fix notifying clients about window reordering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/connection_manager.cc ('k') | no next file » | 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "components/mus/common/util.h" 8 #include "components/mus/common/util.h"
9 #include "components/mus/public/cpp/tests/window_server_test_base.h" 9 #include "components/mus/public/cpp/tests/window_server_test_base.h"
10 #include "components/mus/public/cpp/window_observer.h" 10 #include "components/mus/public/cpp/window_observer.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 Window* window2 = window_manager()->NewWindow(); 410 Window* window2 = window_manager()->NewWindow();
411 window2->SetVisible(true); 411 window2->SetVisible(true);
412 window_manager()->GetRoot()->AddChild(window2); 412 window_manager()->GetRoot()->AddChild(window2);
413 WindowTreeConnection* embedded1 = Embed(window1).connection; 413 WindowTreeConnection* embedded1 = Embed(window1).connection;
414 ASSERT_NE(nullptr, embedded1); 414 ASSERT_NE(nullptr, embedded1);
415 WindowTreeConnection* embedded2 = Embed(window2).connection; 415 WindowTreeConnection* embedded2 = Embed(window2).connection;
416 ASSERT_NE(nullptr, embedded2); 416 ASSERT_NE(nullptr, embedded2);
417 EXPECT_NE(embedded1, embedded2); 417 EXPECT_NE(embedded1, embedded2);
418 } 418 }
419 419
420 // TODO(alhaad): Currently, the RunLoop gets stuck waiting for order change. 420 TEST_F(WindowServerTest, Reorder) {
421 // Debug and re-enable this.
422 TEST_F(WindowServerTest, DISABLED_Reorder) {
423 Window* window1 = window_manager()->NewWindow(); 421 Window* window1 = window_manager()->NewWindow();
424 window1->SetVisible(true); 422 window1->SetVisible(true);
425 window_manager()->GetRoot()->AddChild(window1); 423 window_manager()->GetRoot()->AddChild(window1);
426 424
427 WindowTreeConnection* embedded = Embed(window1).connection; 425 WindowTreeConnection* embedded = Embed(window1).connection;
428 ASSERT_NE(nullptr, embedded); 426 ASSERT_NE(nullptr, embedded);
429 427
430 Window* window11 = embedded->NewWindow(); 428 Window* window11 = embedded->NewWindow();
431 window11->SetVisible(true); 429 window11->SetVisible(true);
432 embedded->GetRoot()->AddChild(window11); 430 embedded->GetRoot()->AddChild(window11);
433 Window* window12 = embedded->NewWindow(); 431 Window* window12 = embedded->NewWindow();
434 window12->SetVisible(true); 432 window12->SetVisible(true);
435 embedded->GetRoot()->AddChild(window12); 433 embedded->GetRoot()->AddChild(window12);
434 ASSERT_TRUE(WaitForTreeSizeToMatch(window1, 3u));
436 435
437 Window* root_in_embedded = embedded->GetRoot(); 436 Window* root_in_embedded = embedded->GetRoot();
438 437
439 { 438 {
440 ASSERT_TRUE(WaitForTreeSizeToMatch(root_in_embedded, 3u));
441 window11->MoveToFront(); 439 window11->MoveToFront();
442 ASSERT_TRUE(WaitForOrderChange(embedded, root_in_embedded)); 440 // The |embedded| tree should be updated immediately.
443
444 EXPECT_EQ(root_in_embedded->children().front(), 441 EXPECT_EQ(root_in_embedded->children().front(),
445 embedded->GetWindowById(window12->id())); 442 embedded->GetWindowById(window12->id()));
446 EXPECT_EQ(root_in_embedded->children().back(), 443 EXPECT_EQ(root_in_embedded->children().back(),
447 embedded->GetWindowById(window11->id())); 444 embedded->GetWindowById(window11->id()));
445
446 // The |window_manager()| tree is still not updated.
447 EXPECT_EQ(window1->children().back(),
448 window_manager()->GetWindowById(window12->id()));
449
450 // Wait until |window_manager()| tree is updated.
451 ASSERT_TRUE(WaitForOrderChange(
452 window_manager(), window_manager()->GetWindowById(window11->id())));
453 EXPECT_EQ(window1->children().front(),
454 window_manager()->GetWindowById(window12->id()));
455 EXPECT_EQ(window1->children().back(),
456 window_manager()->GetWindowById(window11->id()));
448 } 457 }
449 458
450 { 459 {
451 window11->MoveToBack(); 460 window11->MoveToBack();
452 ASSERT_TRUE( 461 // |embedded| should be updated immediately.
453 WaitForOrderChange(embedded, embedded->GetWindowById(window11->id())));
454
455 EXPECT_EQ(root_in_embedded->children().front(), 462 EXPECT_EQ(root_in_embedded->children().front(),
456 embedded->GetWindowById(window11->id())); 463 embedded->GetWindowById(window11->id()));
457 EXPECT_EQ(root_in_embedded->children().back(), 464 EXPECT_EQ(root_in_embedded->children().back(),
458 embedded->GetWindowById(window12->id())); 465 embedded->GetWindowById(window12->id()));
466
467 // |window_manager()| is also eventually updated.
468 EXPECT_EQ(window1->children().back(),
469 window_manager()->GetWindowById(window11->id()));
470 ASSERT_TRUE(WaitForOrderChange(
471 window_manager(), window_manager()->GetWindowById(window11->id())));
472 EXPECT_EQ(window1->children().front(),
473 window_manager()->GetWindowById(window11->id()));
474 EXPECT_EQ(window1->children().back(),
475 window_manager()->GetWindowById(window12->id()));
459 } 476 }
460 } 477 }
461 478
462 namespace { 479 namespace {
463 480
464 class VisibilityChangeObserver : public WindowObserver { 481 class VisibilityChangeObserver : public WindowObserver {
465 public: 482 public:
466 explicit VisibilityChangeObserver(Window* window) : window_(window) { 483 explicit VisibilityChangeObserver(Window* window) : window_(window) {
467 window_->AddObserver(this); 484 window_->AddObserver(this);
468 } 485 }
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 WaitForBoundsToChange(embedded_connection->GetRoot()); 906 WaitForBoundsToChange(embedded_connection->GetRoot());
890 EXPECT_TRUE(gfx::Rect(21, 22, 23, 24) == 907 EXPECT_TRUE(gfx::Rect(21, 22, 23, 24) ==
891 embedded_connection->GetRoot()->bounds()); 908 embedded_connection->GetRoot()->bounds());
892 EXPECT_TRUE(gfx::Insets(1, 2, 3, 4) == 909 EXPECT_TRUE(gfx::Insets(1, 2, 3, 4) ==
893 embedded_connection->GetRoot()->client_area()); 910 embedded_connection->GetRoot()->client_area());
894 } 911 }
895 912
896 } // namespace ws 913 } // namespace ws
897 914
898 } // namespace mus 915 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/connection_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698