diff options
-rw-r--r-- | app/tree_node_model.h | 11 | ||||
-rw-r--r-- | app/tree_node_model_unittest.cc | 62 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_editor_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_editor_view.h | 3 |
5 files changed, 45 insertions, 38 deletions
diff --git a/app/tree_node_model.h b/app/tree_node_model.h index b294911..83e55c9 100644 --- a/app/tree_node_model.h +++ b/app/tree_node_model.h @@ -38,9 +38,10 @@ // The following example creates a TreeNode with two children and then // creates a TreeNodeModel from it: // -// TreeNodeWithValue<int> root = new TreeNodeWithValue<int>(0, L"root"); -// root.add(new TreeNodeWithValue<int>(1, L"child 1")); -// root.add(new TreeNodeWithValue<int>(1, L"child 2")); +// TreeNodeWithValue<int> root = +// new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0); +// root.add(new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1)); +// root.add(new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 1)); // TreeNodeModel<TreeNodeWithValue<int>>* model = // new TreeNodeModel<TreeNodeWithValue<int>>(root); // @@ -210,9 +211,9 @@ class TreeNodeWithValue : public TreeNode< TreeNodeWithValue<ValueType> > { TreeNodeWithValue() { } explicit TreeNodeWithValue(const ValueType& value) - : ParentType(std::wstring()), value(value) { } + : ParentType(string16()), value(value) { } - TreeNodeWithValue(const std::wstring& title, const ValueType& value) + TreeNodeWithValue(const string16& title, const ValueType& value) : ParentType(title), value(value) { } ValueType value; diff --git a/app/tree_node_model_unittest.cc b/app/tree_node_model_unittest.cc index e615c81..17592495 100644 --- a/app/tree_node_model_unittest.cc +++ b/app/tree_node_model_unittest.cc @@ -4,6 +4,7 @@ #include "app/tree_node_model.h" #include "base/string16.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" @@ -57,29 +58,29 @@ class TreeNodeModelTest : public testing::Test, public TreeModelObserver { // +-- child2 TEST_F(TreeNodeModelTest, AddNode) { TreeNodeWithValue<int>* root = - new TreeNodeWithValue<int>(L"root", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0); TreeNodeModel<TreeNodeWithValue<int> > model(root); model.AddObserver(this); ClearCounts(); // Create the first root child. TreeNodeWithValue<int>* child1 = - new TreeNodeWithValue<int>(L"child 1", 1); + new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1); model.Add(root, 0, child1); AssertObserverCount(1, 0, 0); // Add two nodes under the |child1|. TreeNodeWithValue<int>* foo1 = - new TreeNodeWithValue<int>(L"foo1", 3); + new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 3); TreeNodeWithValue<int>* foo2 = - new TreeNodeWithValue<int>(L"foo2", 4); + new TreeNodeWithValue<int>(ASCIIToUTF16("foo2"), 4); child1->Add(0, foo1); child1->Add(1, foo2); // Create the second root child. TreeNodeWithValue<int>* child2 = - new TreeNodeWithValue<int>(L"child 2", 2); + new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 2); root->Add(1, child2); // Check if there is two nodes under the root. @@ -96,14 +97,14 @@ TEST_F(TreeNodeModelTest, AddNode) { // and notifying the observers. TEST_F(TreeNodeModelTest, RemoveNode) { TreeNodeWithValue<int>* root = - new TreeNodeWithValue<int>(L"root", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0); TreeNodeModel<TreeNodeWithValue<int> > model(root); model.AddObserver(this); ClearCounts(); // Create the first child node. TreeNodeWithValue<int>* child1 = - new TreeNodeWithValue<int>(L"child 1", 1); + new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1); // And add it to the root node. root->Add(0, child1); @@ -130,23 +131,26 @@ TEST_F(TreeNodeModelTest, RemoveNode) { // +-------|-- child2 TEST_F(TreeNodeModelTest, RemoveAllNodes) { TreeNodeWithValue<int>* root = - new TreeNodeWithValue<int>(L"root", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0); TreeNodeModel<TreeNodeWithValue<int> > model(root); model.AddObserver(this); ClearCounts(); // Create the first child node. TreeNodeWithValue<int>* child1 = - new TreeNodeWithValue<int>(L"child 1", 1); + new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1); model.Add(root, 0, child1); TreeNodeWithValue<int>* foo1 = - new TreeNodeWithValue<int>(L"foo1", 2); + new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 2); model.Add(child1, 0, foo1); // Add some nodes to |foo1|. - for (int i = 0; i < 3; ++i) - model.Add(foo1, i, new TreeNodeWithValue<int>(L"child" + i, i)); + for (int i = 0; i < 3; ++i) { + model.Add(foo1, i, + new TreeNodeWithValue<int>(ASCIIToUTF16("child") + + base::IntToString16(i), i)); + } ASSERT_EQ(3, model.GetChildCount(foo1)); @@ -167,21 +171,21 @@ TEST_F(TreeNodeModelTest, RemoveAllNodes) { // +-- child2 TEST_F(TreeNodeModelTest, IndexOfChild) { TreeNodeWithValue<int>* root = - new TreeNodeWithValue<int>(L"root", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0); TreeNodeModel<TreeNodeWithValue<int> > model(root); model.AddObserver(this); ClearCounts(); TreeNodeWithValue<int>* child1 = - new TreeNodeWithValue<int>(L"child 1", 1); + new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 1); model.Add(root, 0, child1); TreeNodeWithValue<int>* child2 = - new TreeNodeWithValue<int>(L"child 2", 2); + new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 2); model.Add(root, 1, child2); TreeNodeWithValue<int>* foo1 = - new TreeNodeWithValue<int>(L"foo1", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 0); model.Add(child1, 0, foo1); ASSERT_EQ(0, model.IndexOfChild(root, child1)); @@ -197,15 +201,15 @@ TEST_F(TreeNodeModelTest, IndexOfChild) { // |-- child2 TEST_F(TreeNodeModelTest, HasAncestor) { TreeNodeWithValue<int>* root = - new TreeNodeWithValue<int>(L"root", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0); TreeNodeModel<TreeNodeWithValue<int> > model(root); TreeNodeWithValue<int>* child1 = - new TreeNodeWithValue<int>(L"child 1", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 0); model.Add(root, 0, child1); TreeNodeWithValue<int>* child2 = - new TreeNodeWithValue<int>(L"child 2", 1); + new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 1); model.Add(root, 1, child2); ASSERT_TRUE(root->HasAncestor(root)); @@ -234,25 +238,25 @@ TEST_F(TreeNodeModelTest, HasAncestor) { // under the specifed node correctly. The count should include the node it self. TEST_F(TreeNodeModelTest, GetTotalNodeCount) { TreeNodeWithValue<int>* root = - new TreeNodeWithValue<int>(L"root", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0); TreeNodeModel<TreeNodeWithValue<int> > model(root); TreeNodeWithValue<int>* child1 = - new TreeNodeWithValue<int>(L"child1", 1); + new TreeNodeWithValue<int>(ASCIIToUTF16("child1"), 1); TreeNodeWithValue<int>* child2 = - new TreeNodeWithValue<int>(L"child2", 2); + new TreeNodeWithValue<int>(ASCIIToUTF16("child2"), 2); TreeNodeWithValue<int>* child3 = - new TreeNodeWithValue<int>(L"child3", 3); + new TreeNodeWithValue<int>(ASCIIToUTF16("child3"), 3); TreeNodeWithValue<int>* foo1 = - new TreeNodeWithValue<int>(L"foo1", 4); + new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 4); TreeNodeWithValue<int>* foo2 = - new TreeNodeWithValue<int>(L"foo2", 5); + new TreeNodeWithValue<int>(ASCIIToUTF16("foo2"), 5); TreeNodeWithValue<int>* foo3 = - new TreeNodeWithValue<int>(L"foo3", 6); + new TreeNodeWithValue<int>(ASCIIToUTF16("foo3"), 6); TreeNodeWithValue<int>* foo4 = - new TreeNodeWithValue<int>(L"foo4", 7); + new TreeNodeWithValue<int>(ASCIIToUTF16("foo4"), 7); TreeNodeWithValue<int>* bar1 = - new TreeNodeWithValue<int>(L"bar1", 8); + new TreeNodeWithValue<int>(ASCIIToUTF16("bar1"), 8); model.Add(root, 0, child1); model.Add(child1, 0, child2); @@ -275,7 +279,7 @@ TEST_F(TreeNodeModelTest, GetTotalNodeCount) { // also makes sure the node is properly renamed. TEST_F(TreeNodeModelTest, SetTitle) { TreeNodeWithValue<int>* root = - new TreeNodeWithValue<int>(L"root", 0); + new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0); TreeNodeModel<TreeNodeWithValue<int> > model(root); model.AddObserver(this); ClearCounts(); diff --git a/chrome/browser/bookmarks/bookmark_model_unittest.cc b/chrome/browser/bookmarks/bookmark_model_unittest.cc index 5c788e2..37fcb01 100644 --- a/chrome/browser/bookmarks/bookmark_model_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_model_unittest.cc @@ -573,7 +573,7 @@ static void PopulateNodeImpl(const std::vector<std::string>& description, // in debugging. static int next_group_id = 1; TestNode* new_node = - new TestNode(UTF16ToWideHack(base::IntToString16(next_group_id++)), + new TestNode(base::IntToString16(next_group_id++), BookmarkNode::FOLDER); parent->Add(parent->GetChildCount(), new_node); PopulateNodeImpl(description, index, new_node); @@ -588,7 +588,7 @@ static void PopulateNodeImpl(const std::vector<std::string>& description, DCHECK(element.find('[') == std::string::npos); DCHECK(element.find(']') == std::string::npos); parent->Add(parent->GetChildCount(), - new TestNode(UTF8ToWide(element), BookmarkNode::URL)); + new TestNode(UTF8ToUTF16(element), BookmarkNode::URL)); } } } diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc index 7428905..61475f2 100644 --- a/chrome/browser/views/bookmark_editor_view.cc +++ b/chrome/browser/views/bookmark_editor_view.cc @@ -450,7 +450,8 @@ void BookmarkEditorView::NewGroup() { BookmarkEditorView::EditorNode* BookmarkEditorView::AddNewGroup( EditorNode* parent) { EditorNode* new_node = new EditorNode(); - new_node->SetTitle(l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME)); + new_node->SetTitle( + l10n_util::GetStringUTF16(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME)); new_node->value = 0; // new_node is now owned by parent. tree_model_->Add(parent, parent->GetChildCount(), new_node); diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h index 29c2530..6b11439 100644 --- a/chrome/browser/views/bookmark_editor_view.h +++ b/chrome/browser/views/bookmark_editor_view.h @@ -8,6 +8,7 @@ #include "app/menus/simple_menu_model.h" #include "app/tree_node_model.h" +#include "base/string16.h" #include "chrome/browser/bookmarks/bookmark_editor.h" #include "chrome/browser/bookmarks/bookmark_model_observer.h" #include "views/controls/button/button.h" @@ -59,7 +60,7 @@ class BookmarkEditorView : public BookmarkEditor, : TreeNodeModel<EditorNode>(root) {} virtual void SetTitle(TreeModelNode* node, - const std::wstring& title) { + const string16& title) { if (!title.empty()) TreeNodeModel::SetTitle(node, title); } |