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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" | 10 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Model shouldn't have URL anymore. | 115 // Model shouldn't have URL anymore. |
116 ASSERT_FALSE(model_->IsBookmarked(url)); | 116 ASSERT_FALSE(model_->IsBookmarked(url)); |
117 } | 117 } |
118 | 118 |
119 // Tests open all on a folder with a couple of bookmarks. | 119 // Tests open all on a folder with a couple of bookmarks. |
120 TEST_F(BookmarkContextMenuControllerTest, OpenAll) { | 120 TEST_F(BookmarkContextMenuControllerTest, OpenAll) { |
121 const BookmarkNode* folder = model_->GetBookmarkBarNode()->GetChild(1); | 121 const BookmarkNode* folder = model_->GetBookmarkBarNode()->GetChild(1); |
122 bookmark_utils::OpenAll( | 122 bookmark_utils::OpenAll( |
123 NULL, profile_.get(), &navigator_, folder, NEW_FOREGROUND_TAB); | 123 NULL, profile_.get(), &navigator_, folder, NEW_FOREGROUND_TAB); |
124 | 124 |
125 // Should have navigated to F1's children. | 125 // Should have navigated to F1's child, but not F11's child. |
126 ASSERT_EQ(static_cast<size_t>(2), navigator_.urls_.size()); | 126 ASSERT_EQ(static_cast<size_t>(1), navigator_.urls_.size()); |
127 ASSERT_TRUE(folder->GetChild(0)->GetURL() == navigator_.urls_[0]); | 127 ASSERT_TRUE(folder->GetChild(0)->GetURL() == navigator_.urls_[0]); |
128 ASSERT_TRUE(folder->GetChild(1)->GetChild(0)->GetURL() == | |
129 navigator_.urls_[1]); | |
130 } | 128 } |
131 | 129 |
132 // Tests the enabled state of the menus when supplied an empty vector. | 130 // Tests the enabled state of the menus when supplied an empty vector. |
133 TEST_F(BookmarkContextMenuControllerTest, EmptyNodes) { | 131 TEST_F(BookmarkContextMenuControllerTest, EmptyNodes) { |
134 BookmarkContextMenuController controller( | 132 BookmarkContextMenuController controller( |
135 NULL, NULL, profile_.get(), NULL, model_->other_node(), | 133 NULL, NULL, profile_.get(), NULL, model_->other_node(), |
136 std::vector<const BookmarkNode*>()); | 134 std::vector<const BookmarkNode*>()); |
137 EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 135 EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
138 EXPECT_FALSE( | 136 EXPECT_FALSE( |
139 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 137 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 model_->GetBookmarkBarNode()->GetChild(1)->GetURL()); | 305 model_->GetBookmarkBarNode()->GetChild(1)->GetURL()); |
308 | 306 |
309 controller.reset(new BookmarkContextMenuController( | 307 controller.reset(new BookmarkContextMenuController( |
310 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); | 308 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); |
311 // Cut the URL. | 309 // Cut the URL. |
312 controller->ExecuteCommand(IDC_CUT); | 310 controller->ExecuteCommand(IDC_CUT); |
313 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(0)->is_url()); | 311 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(0)->is_url()); |
314 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(1)->is_folder()); | 312 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(1)->is_folder()); |
315 ASSERT_EQ(old_count, model_->GetBookmarkBarNode()->child_count()); | 313 ASSERT_EQ(old_count, model_->GetBookmarkBarNode()->child_count()); |
316 } | 314 } |
OLD | NEW |