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

Unified Diff: ui/aura/window_unittest.cc

Issue 8477019: Adds Window::MoveChildToFront, with surrounding changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 9 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/window.cc ('k') | ui/gfx/compositor/layer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_unittest.cc
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index f2ea13512da487b5e41bdf077db22667de87eb0f..1d55f0adc3b728a3ecf65020c6a53aaea6d03856 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -391,6 +391,54 @@ TEST_F(WindowTest, MoveChildToFront) {
EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
}
+// Various assertions for MoveToFront.
+TEST_F(WindowTest, MoveToFront) {
+ Window parent(NULL);
+ parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
+ Window child1(NULL);
+ child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
+ Window child2(NULL);
+ child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
+ Window child3(NULL);
+ child3.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
+
+ child1.SetParent(&parent);
+ child2.SetParent(&parent);
+
+ // Move 1 in front of 2.
+ parent.MoveChildAbove(&child1, &child2);
+ ASSERT_EQ(2u, parent.children().size());
+ EXPECT_EQ(&child2, parent.children()[0]);
+ EXPECT_EQ(&child1, parent.children()[1]);
+ ASSERT_EQ(2u, parent.layer()->children().size());
+ EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
+ EXPECT_EQ(child1.layer(), parent.layer()->children()[1]);
+
+ // Add 3, resulting in order [2, 1, 3], then move 2 in front of 1, resulting
+ // in [1, 2, 3].
+ child3.SetParent(&parent);
+ parent.MoveChildAbove(&child2, &child1);
+ ASSERT_EQ(3u, parent.children().size());
+ EXPECT_EQ(&child1, parent.children()[0]);
+ EXPECT_EQ(&child2, parent.children()[1]);
+ EXPECT_EQ(&child3, parent.children()[2]);
+ ASSERT_EQ(3u, parent.layer()->children().size());
+ EXPECT_EQ(child1.layer(), parent.layer()->children()[0]);
+ EXPECT_EQ(child2.layer(), parent.layer()->children()[1]);
+ EXPECT_EQ(child3.layer(), parent.layer()->children()[2]);
+
+ // Move 1 in front of 3, resulting in [2 3 1].
+ parent.MoveChildAbove(&child1, &child3);
+ ASSERT_EQ(3u, parent.children().size());
+ EXPECT_EQ(&child2, parent.children()[0]);
+ EXPECT_EQ(&child3, parent.children()[1]);
+ EXPECT_EQ(&child1, parent.children()[2]);
+ ASSERT_EQ(3u, parent.layer()->children().size());
+ EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
+ EXPECT_EQ(child3.layer(), parent.layer()->children()[1]);
+ EXPECT_EQ(child1.layer(), parent.layer()->children()[2]);
+}
+
// Various destruction assertions.
TEST_F(WindowTest, CaptureTests) {
aura::Desktop* desktop = aura::Desktop::GetInstance();
« no previous file with comments | « ui/aura/window.cc ('k') | ui/gfx/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698