| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h" | 13 #include "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h" |
| 14 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/testing_profile.h" | 15 #include "chrome/test/testing_profile.h" |
| 14 #include "content/browser/browser_thread.h" | 16 #include "content/browser/browser_thread.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 18 |
| 17 using base::Time; | 19 using base::Time; |
| 18 using base::TimeDelta; | 20 using base::TimeDelta; |
| 19 | 21 |
| 20 // Base class for bookmark editor tests. Creates a BookmarkModel and populates | 22 // Base class for bookmark editor tests. Creates a BookmarkModel and populates |
| 21 // it with test data. | 23 // it with test data. |
| 22 class BookmarkEditorViewTest : public testing::Test { | 24 class BookmarkEditorViewTest : public testing::Test { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 127 } |
| 126 | 128 |
| 127 scoped_ptr<BookmarkEditorView> editor_; | 129 scoped_ptr<BookmarkEditorView> editor_; |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 // Makes sure the tree model matches that of the bookmark bar model. | 132 // Makes sure the tree model matches that of the bookmark bar model. |
| 131 TEST_F(BookmarkEditorViewTest, ModelsMatch) { | 133 TEST_F(BookmarkEditorViewTest, ModelsMatch) { |
| 132 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), | 134 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), |
| 133 BookmarkEditorView::SHOW_TREE); | 135 BookmarkEditorView::SHOW_TREE); |
| 134 BookmarkEditorView::EditorNode* editor_root = editor_tree_model()->GetRoot(); | 136 BookmarkEditorView::EditorNode* editor_root = editor_tree_model()->GetRoot(); |
| 135 // The root should have two children, one for the bookmark bar node, | 137 // The root should have two or three children: bookmark bar, other bookmarks |
| 136 // the other for the 'other bookmarks' folder. | 138 // and conditionally synced bookmarks. |
| 137 ASSERT_EQ(2, editor_root->child_count()); | 139 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 140 switches::kEnableSyncedBookmarksFolder)) { |
| 141 ASSERT_EQ(3, editor_root->child_count()); |
| 142 } else { |
| 143 ASSERT_EQ(2, editor_root->child_count()); |
| 144 } |
| 138 | 145 |
| 139 BookmarkEditorView::EditorNode* bb_node = editor_root->GetChild(0); | 146 BookmarkEditorView::EditorNode* bb_node = editor_root->GetChild(0); |
| 140 // The root should have 2 nodes: folder F1 and F2. | 147 // The root should have 2 nodes: folder F1 and F2. |
| 141 ASSERT_EQ(2, bb_node->child_count()); | 148 ASSERT_EQ(2, bb_node->child_count()); |
| 142 ASSERT_EQ(ASCIIToUTF16("F1"), bb_node->GetChild(0)->GetTitle()); | 149 ASSERT_EQ(ASCIIToUTF16("F1"), bb_node->GetChild(0)->GetTitle()); |
| 143 ASSERT_EQ(ASCIIToUTF16("F2"), bb_node->GetChild(1)->GetTitle()); | 150 ASSERT_EQ(ASCIIToUTF16("F2"), bb_node->GetChild(1)->GetTitle()); |
| 144 | 151 |
| 145 // F1 should have one child, F11 | 152 // F1 should have one child, F11 |
| 146 ASSERT_EQ(1, bb_node->GetChild(0)->child_count()); | 153 ASSERT_EQ(1, bb_node->GetChild(0)->child_count()); |
| 147 ASSERT_EQ(ASCIIToUTF16("F11"), bb_node->GetChild(0)->GetChild(0)->GetTitle()); | 154 ASSERT_EQ(ASCIIToUTF16("F11"), bb_node->GetChild(0)->GetChild(0)->GetTitle()); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); | 364 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); |
| 358 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle()); | 365 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle()); |
| 359 // The node should have one child. | 366 // The node should have one child. |
| 360 ASSERT_EQ(1, new_node->child_count()); | 367 ASSERT_EQ(1, new_node->child_count()); |
| 361 const BookmarkNode* new_child = new_node->GetChild(0); | 368 const BookmarkNode* new_child = new_node->GetChild(0); |
| 362 // Make sure the child url/title match. | 369 // Make sure the child url/title match. |
| 363 EXPECT_EQ(BookmarkNode::URL, new_child->type()); | 370 EXPECT_EQ(BookmarkNode::URL, new_child->type()); |
| 364 EXPECT_EQ(WideToUTF16Hack(details.urls[0].second), new_child->GetTitle()); | 371 EXPECT_EQ(WideToUTF16Hack(details.urls[0].second), new_child->GetTitle()); |
| 365 EXPECT_EQ(details.urls[0].first, new_child->GetURL()); | 372 EXPECT_EQ(details.urls[0].first, new_child->GetURL()); |
| 366 } | 373 } |
| OLD | NEW |