// 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 root; root.Add(0, new TreeNodeWithValue(1)); root.Add(1, new TreeNodeWithValue(2)); TreeNodeWithValue* f3 = new TreeNodeWithValue(3); root.Add(2, f3); TreeNodeWithValue* f4 = new TreeNodeWithValue(4); f3->Add(0, f4); f4->Add(0, new TreeNodeWithValue(5)); views::TreeNodeIterator > 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()); }