Commit f27ddd72 authored by tfarina@chromium.org's avatar tfarina@chromium.org

views: Simplify View::RemoveAllChildViews() function implementation.

BUG=72040
TEST=views_unittests --gtest_filter=ViewTest.RemoveAllChildViews

R=sky@chromium.org

Review URL: http://codereview.chromium.org/7104096

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88608 0039d316-1c4b-4281-b951-d872f2087c98
parent 9d899a0d
......@@ -187,9 +187,8 @@ void View::RemoveChildView(View* view) {
}
void View::RemoveAllChildViews(bool delete_children) {
Views::iterator iter;
while ((iter = children_.begin()) != children_.end())
DoRemoveChildView(*iter, false, false, delete_children);
while (!children_.empty())
DoRemoveChildView(children_.front(), false, false, delete_children);
UpdateTooltip();
}
......
......@@ -2006,26 +2006,31 @@ TEST_F(ViewTest, ConvertPointToViewWithTransform) {
// calling RemoveAllChildViews.
// The tree looks like this:
// root
// |-- child
// |-- child1
// | |-- foo
// | |-- bar0
// | |-- bar1
// +-------|-- bar2
// | |-- bar2
// |-- child2
// +-- child3
TEST_F(ViewTest, RemoveAllChildViews) {
View root;
View* child = new View();
root.AddChildView(child);
View* child1 = new View();
root.AddChildView(child1);
for (int i = 0; i < 2; ++i)
root.AddChildView(new View());
View* foo = new View();
child->AddChildView(foo);
child1->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, root.child_count());
ASSERT_EQ(1, child1->child_count());
ASSERT_EQ(3, foo->child_count());
// Now remove all child views from root.
......
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