| 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 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // Model shouldn't have URL anymore. | 120 // Model shouldn't have URL anymore. |
| 121 ASSERT_FALSE(model_->IsBookmarked(url)); | 121 ASSERT_FALSE(model_->IsBookmarked(url)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Tests open all on a folder with a couple of bookmarks. | 124 // Tests open all on a folder with a couple of bookmarks. |
| 125 TEST_F(BookmarkContextMenuTest, OpenAll) { | 125 TEST_F(BookmarkContextMenuTest, OpenAll) { |
| 126 const BookmarkNode* folder = model_->GetBookmarkBarNode()->GetChild(1); | 126 const BookmarkNode* folder = model_->GetBookmarkBarNode()->GetChild(1); |
| 127 bookmark_utils::OpenAll( | 127 bookmark_utils::OpenAll( |
| 128 NULL, profile_.get(), &navigator_, folder, NEW_FOREGROUND_TAB); | 128 NULL, profile_.get(), &navigator_, folder, NEW_FOREGROUND_TAB); |
| 129 | 129 |
| 130 // Should have navigated to F1's children. | 130 // Should have navigated to F1's child but not F11's child. |
| 131 ASSERT_EQ(static_cast<size_t>(2), navigator_.urls_.size()); | 131 ASSERT_EQ(static_cast<size_t>(1), navigator_.urls_.size()); |
| 132 ASSERT_TRUE(folder->GetChild(0)->GetURL() == navigator_.urls_[0]); | 132 ASSERT_TRUE(folder->GetChild(0)->GetURL() == navigator_.urls_[0]); |
| 133 ASSERT_TRUE(folder->GetChild(1)->GetChild(0)->GetURL() == | |
| 134 navigator_.urls_[1]); | |
| 135 } | 133 } |
| 136 | 134 |
| 137 // Tests the enabled state of the menus when supplied an empty vector. | 135 // Tests the enabled state of the menus when supplied an empty vector. |
| 138 TEST_F(BookmarkContextMenuTest, EmptyNodes) { | 136 TEST_F(BookmarkContextMenuTest, EmptyNodes) { |
| 139 BookmarkContextMenu controller( | 137 BookmarkContextMenu controller( |
| 140 NULL, profile_.get(), NULL, model_->other_node(), | 138 NULL, profile_.get(), NULL, model_->other_node(), |
| 141 std::vector<const BookmarkNode*>()); | 139 std::vector<const BookmarkNode*>()); |
| 142 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 140 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
| 143 EXPECT_FALSE( | 141 EXPECT_FALSE( |
| 144 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 142 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
| (...skipping 162 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 BookmarkContextMenu( | 307 controller.reset(new BookmarkContextMenu( |
| 310 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); | 308 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 |