Commit 9ac286f8 authored by sadrul's avatar sadrul Committed by Commit bot

mus: Fix notifying clients about window reordering.

BUG=none

Review URL: https://codereview.chromium.org/1469603003

Cr-Commit-Position: refs/heads/master@{#361049}
parent 562d9e41
...@@ -443,6 +443,7 @@ void ConnectionManager::OnWindowClientAreaChanged( ...@@ -443,6 +443,7 @@ void ConnectionManager::OnWindowClientAreaChanged(
void ConnectionManager::OnWindowReordered(ServerWindow* window, void ConnectionManager::OnWindowReordered(ServerWindow* window,
ServerWindow* relative, ServerWindow* relative,
mojom::OrderDirection direction) { mojom::OrderDirection direction) {
ProcessWindowReorder(window, relative, direction);
if (!in_destructor_) if (!in_destructor_)
SchedulePaint(window, gfx::Rect(window->bounds().size())); SchedulePaint(window, gfx::Rect(window->bounds().size()));
} }
......
...@@ -413,9 +413,7 @@ TEST_F(WindowServerTest, MultiRoots) { ...@@ -413,9 +413,7 @@ TEST_F(WindowServerTest, MultiRoots) {
EXPECT_NE(embedded1, embedded2); EXPECT_NE(embedded1, embedded2);
} }
// TODO(alhaad): Currently, the RunLoop gets stuck waiting for order change. TEST_F(WindowServerTest, Reorder) {
// Debug and re-enable this.
TEST_F(WindowServerTest, DISABLED_Reorder) {
Window* window1 = window_manager()->NewWindow(); Window* window1 = window_manager()->NewWindow();
window1->SetVisible(true); window1->SetVisible(true);
window_manager()->GetRoot()->AddChild(window1); window_manager()->GetRoot()->AddChild(window1);
...@@ -429,29 +427,48 @@ TEST_F(WindowServerTest, DISABLED_Reorder) { ...@@ -429,29 +427,48 @@ TEST_F(WindowServerTest, DISABLED_Reorder) {
Window* window12 = embedded->NewWindow(); Window* window12 = embedded->NewWindow();
window12->SetVisible(true); window12->SetVisible(true);
embedded->GetRoot()->AddChild(window12); embedded->GetRoot()->AddChild(window12);
ASSERT_TRUE(WaitForTreeSizeToMatch(window1, 3u));
Window* root_in_embedded = embedded->GetRoot(); Window* root_in_embedded = embedded->GetRoot();
{ {
ASSERT_TRUE(WaitForTreeSizeToMatch(root_in_embedded, 3u));
window11->MoveToFront(); window11->MoveToFront();
ASSERT_TRUE(WaitForOrderChange(embedded, root_in_embedded)); // The |embedded| tree should be updated immediately.
EXPECT_EQ(root_in_embedded->children().front(), EXPECT_EQ(root_in_embedded->children().front(),
embedded->GetWindowById(window12->id())); embedded->GetWindowById(window12->id()));
EXPECT_EQ(root_in_embedded->children().back(), EXPECT_EQ(root_in_embedded->children().back(),
embedded->GetWindowById(window11->id())); embedded->GetWindowById(window11->id()));
// The |window_manager()| tree is still not updated.
EXPECT_EQ(window1->children().back(),
window_manager()->GetWindowById(window12->id()));
// Wait until |window_manager()| tree is updated.
ASSERT_TRUE(WaitForOrderChange(
window_manager(), window_manager()->GetWindowById(window11->id())));
EXPECT_EQ(window1->children().front(),
window_manager()->GetWindowById(window12->id()));
EXPECT_EQ(window1->children().back(),
window_manager()->GetWindowById(window11->id()));
} }
{ {
window11->MoveToBack(); window11->MoveToBack();
ASSERT_TRUE( // |embedded| should be updated immediately.
WaitForOrderChange(embedded, embedded->GetWindowById(window11->id())));
EXPECT_EQ(root_in_embedded->children().front(), EXPECT_EQ(root_in_embedded->children().front(),
embedded->GetWindowById(window11->id())); embedded->GetWindowById(window11->id()));
EXPECT_EQ(root_in_embedded->children().back(), EXPECT_EQ(root_in_embedded->children().back(),
embedded->GetWindowById(window12->id())); embedded->GetWindowById(window12->id()));
// |window_manager()| is also eventually updated.
EXPECT_EQ(window1->children().back(),
window_manager()->GetWindowById(window11->id()));
ASSERT_TRUE(WaitForOrderChange(
window_manager(), window_manager()->GetWindowById(window11->id())));
EXPECT_EQ(window1->children().front(),
window_manager()->GetWindowById(window11->id()));
EXPECT_EQ(window1->children().back(),
window_manager()->GetWindowById(window12->id()));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment