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

Unified Diff: views/view_unittest.cc

Issue 7046074: views: Add unittests for View::RemoveAllChildViews() method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/view_unittest.cc
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index d7aaab15353ff9c7545b4d3b992b8c848121b2fa..fd2ef32443accc22b6fac01642d69a95c78b7d10 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -2002,6 +2002,39 @@ TEST_F(ViewTest, ConvertPointToViewWithTransform) {
}
}
+// Verify if the child views added under the root are all deleted when
+// calling RemoveAllChildViews.
+// The tree looks like this:
+// root
+// |-- child
+// | |-- foo
+// | |-- bar0
+// | |-- bar1
+// +-------|-- bar2
+TEST_F(ViewTest, RemoveAllChildViews) {
+ View root;
+
+ View* child = new View();
+ root.AddChildView(child);
+
+ View* foo = new View();
+ child->AddChildView(foo);
+
+ // Add some nodes to |foo|.
+ for (int i = 0; i < 3; ++i)
+ foo->AddChildView(new View());
+
+ ASSERT_EQ(1, root.child_count());
+ ASSERT_EQ(1, child->child_count());
+ ASSERT_EQ(3, foo->child_count());
+
+ // Now remove all child views from root.
+ root.RemoveAllChildViews(true);
+
+ ASSERT_EQ(0, root.child_count());
+ ASSERT_FALSE(root.has_children());
+}
+
TEST_F(ViewTest, Contains) {
View v1;
View* v2 = new View();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698