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 #import <AppKit/AppKit.h> | 5 #import <AppKit/AppKit.h> |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 NSMenuItem* AddTestMenuItem(NSMenu *menu, NSString *title, SEL selector) { | 83 NSMenuItem* AddTestMenuItem(NSMenu *menu, NSString *title, SEL selector) { |
84 NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title action:NULL | 84 NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title action:NULL |
85 keyEquivalent:@""] autorelease]; | 85 keyEquivalent:@""] autorelease]; |
86 if (selector) | 86 if (selector) |
87 [item setAction:selector]; | 87 [item setAction:selector]; |
88 [menu addItem:item]; | 88 [menu addItem:item]; |
89 return item; | 89 return item; |
90 } | 90 } |
91 scoped_ptr<TestBookmarkMenuBridge> bridge_; | 91 std::unique_ptr<TestBookmarkMenuBridge> bridge_; |
92 }; | 92 }; |
93 | 93 |
94 TEST_F(BookmarkMenuBridgeTest, TestBookmarkMenuAutoSeparator) { | 94 TEST_F(BookmarkMenuBridgeTest, TestBookmarkMenuAutoSeparator) { |
95 BookmarkModel* model = bridge_->GetBookmarkModel(); | 95 BookmarkModel* model = bridge_->GetBookmarkModel(); |
96 bridge_->BookmarkModelLoaded(model, false); | 96 bridge_->BookmarkModelLoaded(model, false); |
97 NSMenu* menu = bridge_->menu_; | 97 NSMenu* menu = bridge_->menu_; |
98 bridge_->UpdateMenu(menu); | 98 bridge_->UpdateMenu(menu); |
99 // The bare menu after loading used to have a separator and an | 99 // The bare menu after loading used to have a separator and an |
100 // "Other Bookmarks" submenu, but we no longer show those items if the | 100 // "Other Bookmarks" submenu, but we no longer show those items if the |
101 // "Other Bookmarks" submenu would be empty. | 101 // "Other Bookmarks" submenu would be empty. |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 EXPECT_TRUE([item image]); | 392 EXPECT_TRUE([item image]); |
393 | 393 |
394 model->SetTitle(node, ASCIIToUTF16("New Title")); | 394 model->SetTitle(node, ASCIIToUTF16("New Title")); |
395 | 395 |
396 item = [menu itemWithTitle:@"Test Item"]; | 396 item = [menu itemWithTitle:@"Test Item"]; |
397 EXPECT_FALSE(item); | 397 EXPECT_FALSE(item); |
398 item = [menu itemWithTitle:@"New Title"]; | 398 item = [menu itemWithTitle:@"New Title"]; |
399 EXPECT_TRUE(item); | 399 EXPECT_TRUE(item); |
400 } | 400 } |
401 | 401 |
OLD | NEW |