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 "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 EXPECT_TRUE( | 253 EXPECT_TRUE( |
254 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 254 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
255 EXPECT_TRUE( | 255 EXPECT_TRUE( |
256 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 256 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
257 } | 257 } |
258 | 258 |
259 // Tests the enabled state of open incognito. | 259 // Tests the enabled state of open incognito. |
260 TEST_F(BookmarkContextMenuTest, DisableIncognito) { | 260 TEST_F(BookmarkContextMenuTest, DisableIncognito) { |
261 std::vector<const BookmarkNode*> nodes; | 261 std::vector<const BookmarkNode*> nodes; |
262 nodes.push_back(model_->bookmark_bar_node()->GetChild(0)); | 262 nodes.push_back(model_->bookmark_bar_node()->GetChild(0)); |
| 263 TestingProfile::Builder builder; |
| 264 builder.SetIncognito(); |
| 265 scoped_ptr<TestingProfile> incognito_ = builder.Build().Pass(); |
| 266 incognito_->SetOriginalProfile(profile_.get()); |
263 BookmarkContextMenu controller( | 267 BookmarkContextMenu controller( |
264 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false); | 268 NULL, NULL, incognito_.get(), NULL, nodes[0]->parent(), nodes, false); |
265 profile_->set_incognito(true); | |
266 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_INCOGNITO)); | 269 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_INCOGNITO)); |
267 EXPECT_FALSE( | 270 EXPECT_FALSE( |
268 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 271 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
269 } | 272 } |
270 | 273 |
271 // Tests that you can't remove/edit when showing the other node. | 274 // Tests that you can't remove/edit when showing the other node. |
272 TEST_F(BookmarkContextMenuTest, DisabledItemsWithOtherNode) { | 275 TEST_F(BookmarkContextMenuTest, DisabledItemsWithOtherNode) { |
273 std::vector<const BookmarkNode*> nodes; | 276 std::vector<const BookmarkNode*> nodes; |
274 nodes.push_back(model_->other_node()); | 277 nodes.push_back(model_->other_node()); |
275 BookmarkContextMenu controller( | 278 BookmarkContextMenu controller( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 ASSERT_EQ(bb_node->GetChild(0)->url(), bb_node->GetChild(1)->url()); | 321 ASSERT_EQ(bb_node->GetChild(0)->url(), bb_node->GetChild(1)->url()); |
319 | 322 |
320 controller.reset(new BookmarkContextMenu( | 323 controller.reset(new BookmarkContextMenu( |
321 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); | 324 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); |
322 // Cut the URL. | 325 // Cut the URL. |
323 controller->ExecuteCommand(IDC_CUT, 0); | 326 controller->ExecuteCommand(IDC_CUT, 0); |
324 ASSERT_TRUE(bb_node->GetChild(0)->is_url()); | 327 ASSERT_TRUE(bb_node->GetChild(0)->is_url()); |
325 ASSERT_TRUE(bb_node->GetChild(1)->is_folder()); | 328 ASSERT_TRUE(bb_node->GetChild(1)->is_folder()); |
326 ASSERT_EQ(old_count, bb_node->child_count()); | 329 ASSERT_EQ(old_count, bb_node->child_count()); |
327 } | 330 } |
OLD | NEW |