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

Side by Side Diff: views/view_unittest.cc

Issue 7104096: views: Simplify View::RemoveAllChildViews() function implementation. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "ui/base/clipboard/clipboard.h" 10 #include "ui/base/clipboard/clipboard.h"
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 View::ConvertPointToView(&top_view, child, &point); 1999 View::ConvertPointToView(&top_view, child, &point);
2000 EXPECT_EQ(-1, point.x()); 2000 EXPECT_EQ(-1, point.x());
2001 EXPECT_EQ(-1, point.y()); 2001 EXPECT_EQ(-1, point.y());
2002 } 2002 }
2003 } 2003 }
2004 2004
2005 // Verify if the child views added under the root are all deleted when 2005 // Verify if the child views added under the root are all deleted when
2006 // calling RemoveAllChildViews. 2006 // calling RemoveAllChildViews.
2007 // The tree looks like this: 2007 // The tree looks like this:
2008 // root 2008 // root
2009 // |-- child 2009 // |-- child1
2010 // | |-- foo 2010 // | |-- foo
2011 // | |-- bar0 2011 // | |-- bar0
2012 // | |-- bar1 2012 // | |-- bar1
2013 // +-------|-- bar2 2013 // | |-- bar2
2014 // |-- child2
2015 // +-- child3
2014 TEST_F(ViewTest, RemoveAllChildViews) { 2016 TEST_F(ViewTest, RemoveAllChildViews) {
2015 View root; 2017 View root;
2016 2018
2017 View* child = new View(); 2019 View* child1 = new View();
2018 root.AddChildView(child); 2020 root.AddChildView(child1);
2021
2022 for (int i = 0; i < 2; ++i)
2023 root.AddChildView(new View());
2019 2024
2020 View* foo = new View(); 2025 View* foo = new View();
2021 child->AddChildView(foo); 2026 child1->AddChildView(foo);
2022 2027
2023 // Add some nodes to |foo|. 2028 // Add some nodes to |foo|.
2024 for (int i = 0; i < 3; ++i) 2029 for (int i = 0; i < 3; ++i)
2025 foo->AddChildView(new View()); 2030 foo->AddChildView(new View());
2026 2031
2027 ASSERT_EQ(1, root.child_count()); 2032 ASSERT_EQ(3, root.child_count());
2028 ASSERT_EQ(1, child->child_count()); 2033 ASSERT_EQ(1, child1->child_count());
2029 ASSERT_EQ(3, foo->child_count()); 2034 ASSERT_EQ(3, foo->child_count());
2030 2035
2031 // Now remove all child views from root. 2036 // Now remove all child views from root.
2032 root.RemoveAllChildViews(true); 2037 root.RemoveAllChildViews(true);
2033 2038
2034 ASSERT_EQ(0, root.child_count()); 2039 ASSERT_EQ(0, root.child_count());
2035 ASSERT_FALSE(root.has_children()); 2040 ASSERT_FALSE(root.has_children());
2036 } 2041 }
2037 2042
2038 TEST_F(ViewTest, Contains) { 2043 TEST_F(ViewTest, Contains) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 ASSERT_EQ(0, child1->GetIndexOf(foo1)); 2096 ASSERT_EQ(0, child1->GetIndexOf(foo1));
2092 2097
2093 ASSERT_EQ(-1, child2->GetIndexOf(NULL)); 2098 ASSERT_EQ(-1, child2->GetIndexOf(NULL));
2094 ASSERT_EQ(-1, child2->GetIndexOf(&root)); 2099 ASSERT_EQ(-1, child2->GetIndexOf(&root));
2095 ASSERT_EQ(-1, child2->GetIndexOf(child2)); 2100 ASSERT_EQ(-1, child2->GetIndexOf(child2));
2096 ASSERT_EQ(-1, child2->GetIndexOf(child1)); 2101 ASSERT_EQ(-1, child2->GetIndexOf(child1));
2097 ASSERT_EQ(-1, child2->GetIndexOf(foo1)); 2102 ASSERT_EQ(-1, child2->GetIndexOf(foo1));
2098 } 2103 }
2099 2104
2100 } // namespace views 2105 } // namespace views
OLDNEW
« no previous file with comments | « views/view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698