| 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/views/controls/tree/tree_view.h" | 5 #include "ui/views/controls/tree/tree_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 void ExpandOrSelectChild(); | 61 void ExpandOrSelectChild(); |
| 62 int GetRowCount(); | 62 int GetRowCount(); |
| 63 PrefixSelector* selector() { return tree_.selector_.get(); } | 63 PrefixSelector* selector() { return tree_.selector_.get(); } |
| 64 | 64 |
| 65 ui::TreeNodeModel<TestNode > model_; | 65 ui::TreeNodeModel<TestNode > model_; |
| 66 TreeView tree_; | 66 TreeView tree_; |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 std::string InternalNodeAsString(TreeView::InternalNode* node); | 69 std::string InternalNodeAsString(TreeView::InternalNode* node); |
| 70 | 70 |
| 71 TestNode* GetNodeByTitleImpl(TestNode* node, const string16& title); | 71 TestNode* GetNodeByTitleImpl(TestNode* node, const base::string16& title); |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(TreeViewTest); | 73 DISALLOW_COPY_AND_ASSIGN(TreeViewTest); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 TestNode* TreeViewTest::Add(TestNode* parent, | 76 TestNode* TreeViewTest::Add(TestNode* parent, |
| 77 int index, | 77 int index, |
| 78 const std::string& title) { | 78 const std::string& title) { |
| 79 TestNode* new_node = new TestNode; | 79 TestNode* new_node = new TestNode; |
| 80 new_node->SetTitle(ASCIIToUTF16(title)); | 80 new_node->SetTitle(ASCIIToUTF16(title)); |
| 81 model_.Add(parent, new_node, index); | 81 model_.Add(parent, new_node, index); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 111 | 111 |
| 112 void TreeViewTest::ExpandOrSelectChild() { | 112 void TreeViewTest::ExpandOrSelectChild() { |
| 113 tree_.ExpandOrSelectChild(); | 113 tree_.ExpandOrSelectChild(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 int TreeViewTest::GetRowCount() { | 116 int TreeViewTest::GetRowCount() { |
| 117 return tree_.GetRowCount(); | 117 return tree_.GetRowCount(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 TestNode* TreeViewTest::GetNodeByTitleImpl(TestNode* node, | 120 TestNode* TreeViewTest::GetNodeByTitleImpl(TestNode* node, |
| 121 const string16& title) { | 121 const base::string16& title) { |
| 122 if (node->GetTitle() == title) | 122 if (node->GetTitle() == title) |
| 123 return node; | 123 return node; |
| 124 for (int i = 0; i < node->child_count(); ++i) { | 124 for (int i = 0; i < node->child_count(); ++i) { |
| 125 TestNode* child = GetNodeByTitleImpl(node->GetChild(i), title); | 125 TestNode* child = GetNodeByTitleImpl(node->GetChild(i), title); |
| 126 if (child) | 126 if (child) |
| 127 return child; | 127 return child; |
| 128 } | 128 } |
| 129 return NULL; | 129 return NULL; |
| 130 } | 130 } |
| 131 | 131 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 tree_.SetSelectedNode(GetNodeByTitle("root")); | 411 tree_.SetSelectedNode(GetNodeByTitle("root")); |
| 412 ExpandOrSelectChild(); | 412 ExpandOrSelectChild(); |
| 413 tree_.SetEditable(true); | 413 tree_.SetEditable(true); |
| 414 tree_.StartEditing(GetNodeByTitle("a")); | 414 tree_.StartEditing(GetNodeByTitle("a")); |
| 415 tree_.editor()->SetText(ASCIIToUTF16("a changed")); | 415 tree_.editor()->SetText(ASCIIToUTF16("a changed")); |
| 416 tree_.OnDidChangeFocus(NULL, NULL); | 416 tree_.OnDidChangeFocus(NULL, NULL); |
| 417 EXPECT_TRUE(GetNodeByTitle("a changed") != NULL); | 417 EXPECT_TRUE(GetNodeByTitle("a changed") != NULL); |
| 418 } | 418 } |
| 419 | 419 |
| 420 } // namespace views | 420 } // namespace views |
| OLD | NEW |