| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/base/models/tree_node_model.h" | 5 #include "ui/base/models/tree_node_model.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 using base::ASCIIToUTF16; | 16 using base::ASCIIToUTF16; |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 | 19 |
| 19 class TreeNodeModelTest : public testing::Test, public TreeModelObserver { | 20 class TreeNodeModelTest : public testing::Test, public TreeModelObserver { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 TestNode* child1 = new TestNode; | 297 TestNode* child1 = new TestNode; |
| 297 root.Add(child1, root.child_count()); | 298 root.Add(child1, root.child_count()); |
| 298 EXPECT_EQ(1, root.child_count()); | 299 EXPECT_EQ(1, root.child_count()); |
| 299 EXPECT_EQ(&root, child1->parent()); | 300 EXPECT_EQ(&root, child1->parent()); |
| 300 | 301 |
| 301 TestNode* child2 = new TestNode; | 302 TestNode* child2 = new TestNode; |
| 302 root.Add(child2, root.child_count()); | 303 root.Add(child2, root.child_count()); |
| 303 EXPECT_EQ(2, root.child_count()); | 304 EXPECT_EQ(2, root.child_count()); |
| 304 EXPECT_EQ(child1->parent(), child2->parent()); | 305 EXPECT_EQ(child1->parent(), child2->parent()); |
| 305 | 306 |
| 306 scoped_ptr<TestNode > c2(root.Remove(child2)); | 307 std::unique_ptr<TestNode> c2(root.Remove(child2)); |
| 307 EXPECT_EQ(1, root.child_count()); | 308 EXPECT_EQ(1, root.child_count()); |
| 308 EXPECT_EQ(NULL, child2->parent()); | 309 EXPECT_EQ(NULL, child2->parent()); |
| 309 | 310 |
| 310 scoped_ptr<TestNode > c1(root.Remove(child1)); | 311 std::unique_ptr<TestNode> c1(root.Remove(child1)); |
| 311 EXPECT_EQ(0, root.child_count()); | 312 EXPECT_EQ(0, root.child_count()); |
| 312 } | 313 } |
| 313 | 314 |
| 314 TEST_F(TreeNodeModelTest, IsRoot) { | 315 TEST_F(TreeNodeModelTest, IsRoot) { |
| 315 TestNode root; | 316 TestNode root; |
| 316 EXPECT_TRUE(root.is_root()); | 317 EXPECT_TRUE(root.is_root()); |
| 317 | 318 |
| 318 TestNode* child1 = new TestNode; | 319 TestNode* child1 = new TestNode; |
| 319 root.Add(child1, root.child_count()); | 320 root.Add(child1, root.child_count()); |
| 320 EXPECT_FALSE(child1->is_root()); | 321 EXPECT_FALSE(child1->is_root()); |
| 321 } | 322 } |
| 322 | 323 |
| 323 } // namespace ui | 324 } // namespace ui |
| OLD | NEW |