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

Unified Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2472983004: Fixs bug in notifying clients about hierarchy changes (Closed)
Patch Set: cleanup Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_client_unittest.cc
diff --git a/ui/aura/mus/window_tree_client_unittest.cc b/ui/aura/mus/window_tree_client_unittest.cc
index 65c9bf91cd17e07d23a1943558c5b8a320a633e3..c7705d87a0f185ea8a808cf3e654cd4552d930c1 100644
--- a/ui/aura/mus/window_tree_client_unittest.cc
+++ b/ui/aura/mus/window_tree_client_unittest.cc
@@ -1119,4 +1119,41 @@ TEST_F(WindowTreeClientClientTest, ModalSuccess) {
window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false));
}
+// Verifies OnWindowHierarchyChanged() deals correctly with identifying existing
+// windows.
+TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithExistingWindow) {
+ Window* window1 = new Window(nullptr);
+ window1->Init(ui::LAYER_NOT_DRAWN);
+ Window* window2 = new Window(nullptr);
+ window2->Init(ui::LAYER_NOT_DRAWN);
+ window_tree()->AckAllChanges();
+ const Id server_window_id = server_id(root_window()) + 11;
+ ui::mojom::WindowDataPtr data1 = ui::mojom::WindowData::New();
+ ui::mojom::WindowDataPtr data2 = ui::mojom::WindowData::New();
+ ui::mojom::WindowDataPtr data3 = ui::mojom::WindowData::New();
+ data1->parent_id = server_id(root_window());
+ data1->window_id = server_window_id;
+ data1->bounds = gfx::Rect(1, 2, 3, 4);
+ data2->parent_id = server_window_id;
+ data2->window_id = WindowMus::Get(window1)->server_id();
+ data2->bounds = gfx::Rect(1, 2, 3, 4);
+ data3->parent_id = server_window_id;
+ data3->window_id = WindowMus::Get(window2)->server_id();
+ data3->bounds = gfx::Rect(1, 2, 3, 4);
+ mojo::Array<ui::mojom::WindowDataPtr> data_array(3);
+ data_array[0] = std::move(data1);
+ data_array[1] = std::move(data2);
+ data_array[2] = std::move(data3);
+ window_tree_client()->OnWindowHierarchyChanged(
+ server_window_id, 0, server_id(root_window()), std::move(data_array));
+ ASSERT_FALSE(window_tree()->has_change());
+ ASSERT_EQ(1u, root_window()->children().size());
+ Window* server_window = root_window()->children()[0];
+ EXPECT_EQ(window1->parent(), server_window);
+ EXPECT_EQ(window2->parent(), server_window);
+ ASSERT_EQ(2u, server_window->children().size());
+ EXPECT_EQ(window1, server_window->children()[0]);
+ EXPECT_EQ(window2, server_window->children()[1]);
+}
+
} // namespace aura
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698