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

Unified Diff: ui/base/models/tree_node_model_unittest.cc

Issue 7134061: ui/base/models: Rewrite the TreeNodeModelTest.RemoveAllNodes unittest. (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: ui/base/models/tree_node_model_unittest.cc
diff --git a/ui/base/models/tree_node_model_unittest.cc b/ui/base/models/tree_node_model_unittest.cc
index 051f9ce19f6228106e04b7830804bbd4236f8593..9125a73c67fa7e3e542e702e3565ca8f419bc833 100644
--- a/ui/base/models/tree_node_model_unittest.cc
+++ b/ui/base/models/tree_node_model_unittest.cc
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/basictypes.h"
#include "base/string16.h"
-#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/models/tree_node_model.h"
@@ -127,42 +127,39 @@ TEST_F(TreeNodeModelTest, RemoveNode) {
// The tree looks like this:
// root
// |-- child1
-// | |-- foo1
-// | |-- child0
-// | |-- child1
-// +-------|-- child2
+// | |-- foo
+// | |-- bar0
+// | |-- bar1
+// | |-- bar2
+// |-- child2
+// +-- child3
TEST_F(TreeNodeModelTest, RemoveAllNodes) {
- TreeNodeWithValue<int>* root =
- new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0);
- TreeNodeModel<TreeNodeWithValue<int> > model(root);
- model.AddObserver(this);
- ClearCounts();
+ TreeNodeWithValue<int> root;
- // Create the first child node.
- TreeNodeWithValue<int>* child1 =
- new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1);
- model.Add(root, child1, 0);
+ TreeNodeWithValue<int> child1;
+ TreeNodeWithValue<int> child2;
+ TreeNodeWithValue<int> child3;
- TreeNodeWithValue<int>* foo1 =
- new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 2);
- model.Add(child1, foo1, 0);
-
- // Add some nodes to |foo1|.
- for (int i = 0; i < 3; ++i) {
- model.Add(foo1,
- new TreeNodeWithValue<int>(ASCIIToUTF16("child") +
- base::IntToString16(i), i), i);
- }
+ root.Add(&child1, 0);
+ root.Add(&child2, 1);
+ root.Add(&child3, 2);
- ASSERT_EQ(3, model.GetChildCount(foo1));
+ TreeNodeWithValue<int>* foo = new TreeNodeWithValue<int>(2);
+ child1.Add(foo, 0);
- // Now remove all nodes from root.
- root->RemoveAll();
+ // Add some nodes to |foo|.
+ for (int i = 0; i < 3; ++i)
+ foo->Add(new TreeNodeWithValue<int>(i), i);
- // Release memory, so we don't leak.
- delete child1;
+ ASSERT_EQ(3, root.child_count());
+ ASSERT_EQ(1, child1.child_count());
+ ASSERT_EQ(3, foo->child_count());
- ASSERT_EQ(0, model.GetChildCount(root));
+ // Now remove all nodes from root.
+ root.RemoveAll();
+
+ ASSERT_EQ(0, root.child_count());
+ ASSERT_TRUE(root.empty());
sky 2011/06/10 15:45:59 You should add assertions that child1 & foo still
tfarina 2011/06/10 16:05:07 Done.
}
// Verify if the model returns correct indexes for the specified nodes.
« 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