diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-18 17:31:37 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-18 17:31:37 +0000 |
commit | a0dd6a39ec26eb15c408cd5969d2368035549b7f (patch) | |
tree | 8f41f8f2ad505829b62ba420f54acbdd3bfcf5b1 /ui/base/models | |
parent | 6ecdfa3f5a6fcc570a18c789389b1c8cdf294c04 (diff) | |
download | chromium_src-a0dd6a39ec26eb15c408cd5969d2368035549b7f.zip chromium_src-a0dd6a39ec26eb15c408cd5969d2368035549b7f.tar.gz chromium_src-a0dd6a39ec26eb15c408cd5969d2368035549b7f.tar.bz2 |
Reverse the order of parameters in TreeNode::Add function.
This is so it matches with the signature used in View class.
BUG=None
TEST=None
R=sky@chromium.org
Review URL: http://codereview.chromium.org/6683024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78712 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/models')
-rw-r--r-- | ui/base/models/tree_node_iterator_unittest.cc | 10 | ||||
-rw-r--r-- | ui/base/models/tree_node_model.h | 20 | ||||
-rw-r--r-- | ui/base/models/tree_node_model_unittest.cc | 44 |
3 files changed, 37 insertions, 37 deletions
diff --git a/ui/base/models/tree_node_iterator_unittest.cc b/ui/base/models/tree_node_iterator_unittest.cc index 2913bd5..13140e9 100644 --- a/ui/base/models/tree_node_iterator_unittest.cc +++ b/ui/base/models/tree_node_iterator_unittest.cc @@ -11,13 +11,13 @@ namespace ui { TEST(TreeNodeIteratorTest, Test) { TreeNodeWithValue<int> root; - root.Add(0, new TreeNodeWithValue<int>(1)); - root.Add(1, new TreeNodeWithValue<int>(2)); + root.Add(new TreeNodeWithValue<int>(1), 0); + root.Add(new TreeNodeWithValue<int>(2), 1); TreeNodeWithValue<int>* f3 = new TreeNodeWithValue<int>(3); - root.Add(2, f3); + root.Add(f3, 2); TreeNodeWithValue<int>* f4 = new TreeNodeWithValue<int>(4); - f3->Add(0, f4); - f4->Add(0, new TreeNodeWithValue<int>(5)); + f3->Add(f4, 0); + f4->Add(new TreeNodeWithValue<int>(5), 0); TreeNodeIterator<TreeNodeWithValue<int> > iterator(&root); ASSERT_TRUE(iterator.has_next()); diff --git a/ui/base/models/tree_node_model.h b/ui/base/models/tree_node_model.h index e0b8e21..9720b8a 100644 --- a/ui/base/models/tree_node_model.h +++ b/ui/base/models/tree_node_model.h @@ -73,17 +73,17 @@ class TreeNode : public TreeModelNode { virtual ~TreeNode() {} - // Adds the specified child node. - virtual void Add(int index, NodeType* child) { - DCHECK(child); + // Adds a TreeNode as a child of this one, at |index|. + virtual void Add(NodeType* node, int index) { + DCHECK(node); DCHECK_LE(0, index); DCHECK_GE(child_count(), index); // If the node has a parent, remove it from its parent. - NodeType* node_parent = child->parent(); - if (node_parent) - node_parent->Remove(node_parent->GetIndexOf(child)); - child->parent_ = static_cast<NodeType*>(this); - children_->insert(children_->begin() + index, child); + NodeType* parent = node->parent(); + if (parent) + parent->Remove(parent->GetIndexOf(node)); + node->parent_ = static_cast<NodeType*>(this); + children_->insert(children_->begin() + index, node); } // Removes the node by index. This does NOT delete the specified node, it is @@ -213,9 +213,9 @@ class TreeNodeModel : public TreeModel { return static_cast<NodeType*>(model_node); } - void Add(NodeType* parent, int index, NodeType* child) { + void Add(NodeType* parent, NodeType* child, int index) { DCHECK(parent && child); - parent->Add(index, child); + parent->Add(child, index); NotifyObserverTreeNodesAdded(parent, index, 1); } diff --git a/ui/base/models/tree_node_model_unittest.cc b/ui/base/models/tree_node_model_unittest.cc index afeed6d..43e92623 100644 --- a/ui/base/models/tree_node_model_unittest.cc +++ b/ui/base/models/tree_node_model_unittest.cc @@ -68,7 +68,7 @@ TEST_F(TreeNodeModelTest, AddNode) { // Create the first root child. TreeNodeWithValue<int>* child1 = new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1); - model.Add(root, 0, child1); + model.Add(root, child1, 0); AssertObserverCount(1, 0, 0); @@ -77,13 +77,13 @@ TEST_F(TreeNodeModelTest, AddNode) { new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 3); TreeNodeWithValue<int>* foo2 = new TreeNodeWithValue<int>(ASCIIToUTF16("foo2"), 4); - child1->Add(0, foo1); - child1->Add(1, foo2); + child1->Add(foo1, 0); + child1->Add(foo2, 1); // Create the second root child. TreeNodeWithValue<int>* child2 = new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 2); - root->Add(1, child2); + root->Add(child2, 1); // Check if there is two nodes under the root. ASSERT_EQ(2, model.GetChildCount(root)); @@ -109,7 +109,7 @@ TEST_F(TreeNodeModelTest, RemoveNode) { new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1); // And add it to the root node. - root->Add(0, child1); + root->Add(child1, 0); ASSERT_EQ(1, model.GetChildCount(root)); @@ -141,17 +141,17 @@ TEST_F(TreeNodeModelTest, RemoveAllNodes) { // Create the first child node. TreeNodeWithValue<int>* child1 = new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1); - model.Add(root, 0, child1); + model.Add(root, child1, 0); TreeNodeWithValue<int>* foo1 = new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 2); - model.Add(child1, 0, foo1); + model.Add(child1, foo1, 0); // Add some nodes to |foo1|. for (int i = 0; i < 3; ++i) { - model.Add(foo1, i, + model.Add(foo1, new TreeNodeWithValue<int>(ASCIIToUTF16("child") + - base::IntToString16(i), i)); + base::IntToString16(i), i), i); } ASSERT_EQ(3, model.GetChildCount(foo1)); @@ -180,15 +180,15 @@ TEST_F(TreeNodeModelTest, GetIndexOf) { TreeNodeWithValue<int>* child1 = new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1); - model.Add(root, 0, child1); + model.Add(root, child1, 0); TreeNodeWithValue<int>* child2 = new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 2); - model.Add(root, 1, child2); + model.Add(root, child2, 1); TreeNodeWithValue<int>* foo1 = new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 0); - model.Add(child1, 0, foo1); + model.Add(child1, foo1, 0); ASSERT_EQ(0, model.GetIndexOf(root, child1)); ASSERT_EQ(1, model.GetIndexOf(root, child2)); @@ -208,11 +208,11 @@ TEST_F(TreeNodeModelTest, HasAncestor) { TreeNodeWithValue<int>* child1 = new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 0); - model.Add(root, 0, child1); + model.Add(root, child1, 0); TreeNodeWithValue<int>* child2 = new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 1); - model.Add(root, 1, child2); + model.Add(root, child2, 1); ASSERT_TRUE(root->HasAncestor(root)); ASSERT_FALSE(root->HasAncestor(child1)); @@ -260,16 +260,16 @@ TEST_F(TreeNodeModelTest, GetTotalNodeCount) { TreeNodeWithValue<int>* bar1 = new TreeNodeWithValue<int>(ASCIIToUTF16("bar1"), 8); - model.Add(root, 0, child1); - model.Add(child1, 0, child2); - model.Add(child2, 0, child3); + model.Add(root, child1, 0); + model.Add(child1, child2, 0); + model.Add(child2, child3, 0); - model.Add(root, 1, foo1); - model.Add(foo1, 0, foo2); - model.Add(foo1, 1, foo4); - model.Add(foo2, 0, foo3); + model.Add(root, foo1, 1); + model.Add(foo1, foo2, 0); + model.Add(foo1, foo4, 1); + model.Add(foo2, foo3, 0); - model.Add(root, 0, bar1); + model.Add(root, bar1, 0); ASSERT_EQ(9, root->GetTotalNodeCount()); ASSERT_EQ(3, child1->GetTotalNodeCount()); |