Index: ui/aura/window_unittest.cc |
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc |
index 9d5f368b2ccdacb556e7c9bd8d3f8491a9c7f8b1..ea112f0597393181d3a618e3f859cb2cc8520235 100644 |
--- a/ui/aura/window_unittest.cc |
+++ b/ui/aura/window_unittest.cc |
@@ -137,6 +137,28 @@ TEST_F(WindowTest, GetChildById) { |
EXPECT_EQ(w111.get(), w1->GetChildById(111)); |
} |
+// Make sure that Window::Contains correctly handles children, grandchildren, |
+// and not containing NULL or parents. |
+TEST_F(WindowTest, Contains) { |
+ 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); |
+ |
+ child1.SetParent(&parent); |
+ child2.SetParent(&child1); |
+ |
+ EXPECT_TRUE(parent.Contains(&parent)); |
+ EXPECT_TRUE(parent.Contains(&child1)); |
+ EXPECT_TRUE(parent.Contains(&child2)); |
+ |
+ EXPECT_FALSE(parent.Contains(NULL)); |
+ EXPECT_FALSE(child1.Contains(&parent)); |
+ EXPECT_FALSE(child2.Contains(&child1)); |
+} |
+ |
TEST_F(WindowTest, ConvertPointToWindow) { |
// Window::ConvertPointToWindow is mostly identical to |
// Layer::ConvertPointToLayer, except NULL values for |source| are permitted, |