summaryrefslogtreecommitdiffstats
path: root/ui/base/models
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 18:20:50 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 18:20:50 +0000
commit9276a31166bad9c5845193b2fb6ae916d8bfdde4 (patch)
treec43d2beb2876a0fd61dc2f2eb31080c85ab5df53 /ui/base/models
parent2072dc16b549e3af6392ed23da08729d30c12029 (diff)
downloadchromium_src-9276a31166bad9c5845193b2fb6ae916d8bfdde4.zip
chromium_src-9276a31166bad9c5845193b2fb6ae916d8bfdde4.tar.gz
chromium_src-9276a31166bad9c5845193b2fb6ae916d8bfdde4.tar.bz2
ui/base/models: Allocate |root| on the stack.
Instead of allocating it on the heap, just allocate it on the stack. Thus we don't have to delete it manually. BUG=None TEST=ui_unittests --gtest_filter=TreeNodeModelTest.BasicOperations R=phajdan.jr@chromium.org,sky@chromium.org Review URL: http://codereview.chromium.org/7205022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/models')
-rw-r--r--ui/base/models/tree_node_model_unittest.cc30
1 files changed, 14 insertions, 16 deletions
diff --git a/ui/base/models/tree_node_model_unittest.cc b/ui/base/models/tree_node_model_unittest.cc
index cbf889a..b7f54c4 100644
--- a/ui/base/models/tree_node_model_unittest.cc
+++ b/ui/base/models/tree_node_model_unittest.cc
@@ -4,6 +4,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -296,28 +297,25 @@ TEST_F(TreeNodeModelTest, SetTitle) {
}
TEST_F(TreeNodeModelTest, BasicOperations) {
- TreeNodeWithValue<int>* root = new TreeNodeWithValue<int>(0);
- ASSERT_EQ(0, root->child_count());
+ TreeNodeWithValue<int> root;
+ ASSERT_EQ(0, root.child_count());
- TreeNodeWithValue<int>* child1 = new TreeNodeWithValue<int>(1);
- root->Add(child1, root->child_count());
- ASSERT_EQ(1, root->child_count());
- ASSERT_EQ(root, child1->parent());
+ TreeNodeWithValue<int>* child1 = new TreeNodeWithValue<int>();
+ root.Add(child1, root.child_count());
+ ASSERT_EQ(1, root.child_count());
+ ASSERT_EQ(&root, child1->parent());
- TreeNodeWithValue<int>* child2 = new TreeNodeWithValue<int>(1);
- root->Add(child2, root->child_count());
- ASSERT_EQ(2, root->child_count());
+ TreeNodeWithValue<int>* child2 = new TreeNodeWithValue<int>();
+ root.Add(child2, root.child_count());
+ ASSERT_EQ(2, root.child_count());
ASSERT_EQ(child1->parent(), child2->parent());
- root->Remove(child2);
- ASSERT_EQ(1, root->child_count());
+ scoped_ptr<TreeNodeWithValue<int> > c2(root.Remove(child2));
+ ASSERT_EQ(1, root.child_count());
ASSERT_EQ(NULL, child2->parent());
- delete child2;
- delete root->Remove(child1);
- ASSERT_EQ(0, root->child_count());
-
- delete root;
+ scoped_ptr<TreeNodeWithValue<int> > c1(root.Remove(child1));
+ ASSERT_EQ(0, root.child_count());
}
TEST_F(TreeNodeModelTest, IsRoot) {