summaryrefslogtreecommitdiffstats
path: root/chrome/views/tree_node_iterator_unittest.cc
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-09 17:12:12 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-09 17:12:12 +0000
commit775cfd76d4523b8e932e98214c0b082e20385544 (patch)
treed27e42cebe4a431b59402aefa9d2359f6173727d /chrome/views/tree_node_iterator_unittest.cc
parentadf650f2036694291449d4fb2f6b71b5ecccc331 (diff)
downloadchromium_src-775cfd76d4523b8e932e98214c0b082e20385544.zip
chromium_src-775cfd76d4523b8e932e98214c0b082e20385544.tar.gz
chromium_src-775cfd76d4523b8e932e98214c0b082e20385544.tar.bz2
Attempt 2 at landing tree node iterator. I needed an include
in tree_node_model. Review URL: http://codereview.chromium.org/13274 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/tree_node_iterator_unittest.cc')
-rw-r--r--chrome/views/tree_node_iterator_unittest.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/chrome/views/tree_node_iterator_unittest.cc b/chrome/views/tree_node_iterator_unittest.cc
new file mode 100644
index 0000000..165b5c3
--- /dev/null
+++ b/chrome/views/tree_node_iterator_unittest.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "chrome/views/tree_node_iterator.h"
+#include "chrome/views/tree_node_model.h"
+
+typedef testing::Test TreeNodeIteratorTest;
+
+using views::TreeNodeWithValue;
+
+TEST_F(TreeNodeIteratorTest, Test) {
+ TreeNodeWithValue<int> root;
+ root.Add(0, new TreeNodeWithValue<int>(1));
+ root.Add(1, new TreeNodeWithValue<int>(2));
+ TreeNodeWithValue<int>* f3 = new TreeNodeWithValue<int>(3);
+ root.Add(2, f3);
+ TreeNodeWithValue<int>* f4 = new TreeNodeWithValue<int>(4);
+ f3->Add(0, f4);
+ f4->Add(0, new TreeNodeWithValue<int>(5));
+
+ views::TreeNodeIterator<TreeNodeWithValue<int> > iterator(&root);
+ ASSERT_TRUE(iterator.has_next());
+ ASSERT_EQ(root.GetChild(0), iterator.Next());
+
+ ASSERT_TRUE(iterator.has_next());
+ ASSERT_EQ(root.GetChild(1), iterator.Next());
+
+ ASSERT_TRUE(iterator.has_next());
+ ASSERT_EQ(root.GetChild(2), iterator.Next());
+
+ ASSERT_TRUE(iterator.has_next());
+ ASSERT_EQ(f4, iterator.Next());
+
+ ASSERT_TRUE(iterator.has_next());
+ ASSERT_EQ(f4->GetChild(0), iterator.Next());
+
+ ASSERT_FALSE(iterator.has_next());
+}