Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(919)

Side by Side Diff: ui/base/cocoa/menu_controller_unittest.mm

Issue 623293004: replace OVERRIDE and FINAL with override and final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 21 matching lines...) Expand all
32 class Delegate : public SimpleMenuModel::Delegate { 32 class Delegate : public SimpleMenuModel::Delegate {
33 public: 33 public:
34 Delegate() 34 Delegate()
35 : execute_count_(0), 35 : execute_count_(0),
36 enable_count_(0), 36 enable_count_(0),
37 menu_to_close_(nil), 37 menu_to_close_(nil),
38 did_show_(false), 38 did_show_(false),
39 did_close_(false) { 39 did_close_(false) {
40 } 40 }
41 41
42 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { 42 virtual bool IsCommandIdChecked(int command_id) const override {
43 return false; 43 return false;
44 } 44 }
45 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { 45 virtual bool IsCommandIdEnabled(int command_id) const override {
46 ++enable_count_; 46 ++enable_count_;
47 return true; 47 return true;
48 } 48 }
49 virtual bool GetAcceleratorForCommandId( 49 virtual bool GetAcceleratorForCommandId(
50 int command_id, 50 int command_id,
51 Accelerator* accelerator) OVERRIDE { return false; } 51 Accelerator* accelerator) override { return false; }
52 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { 52 virtual void ExecuteCommand(int command_id, int event_flags) override {
53 ++execute_count_; 53 ++execute_count_;
54 } 54 }
55 55
56 virtual void MenuWillShow(SimpleMenuModel* /*source*/) OVERRIDE { 56 virtual void MenuWillShow(SimpleMenuModel* /*source*/) override {
57 EXPECT_FALSE(did_show_); 57 EXPECT_FALSE(did_show_);
58 EXPECT_FALSE(did_close_); 58 EXPECT_FALSE(did_close_);
59 did_show_ = true; 59 did_show_ = true;
60 NSArray* modes = [NSArray arrayWithObjects:NSEventTrackingRunLoopMode, 60 NSArray* modes = [NSArray arrayWithObjects:NSEventTrackingRunLoopMode,
61 NSDefaultRunLoopMode, 61 NSDefaultRunLoopMode,
62 nil]; 62 nil];
63 [menu_to_close_ performSelector:@selector(cancelTracking) 63 [menu_to_close_ performSelector:@selector(cancelTracking)
64 withObject:nil 64 withObject:nil
65 afterDelay:0.1 65 afterDelay:0.1
66 inModes:modes]; 66 inModes:modes];
67 } 67 }
68 68
69 virtual void MenuClosed(SimpleMenuModel* /*source*/) OVERRIDE { 69 virtual void MenuClosed(SimpleMenuModel* /*source*/) override {
70 EXPECT_TRUE(did_show_); 70 EXPECT_TRUE(did_show_);
71 EXPECT_FALSE(did_close_); 71 EXPECT_FALSE(did_close_);
72 did_close_ = true; 72 did_close_ = true;
73 } 73 }
74 74
75 int execute_count_; 75 int execute_count_;
76 mutable int enable_count_; 76 mutable int enable_count_;
77 // The menu on which to call |-cancelTracking| after a short delay in 77 // The menu on which to call |-cancelTracking| after a short delay in
78 // MenuWillShow. 78 // MenuWillShow.
79 NSMenu* menu_to_close_; 79 NSMenu* menu_to_close_;
80 bool did_show_; 80 bool did_show_;
81 bool did_close_; 81 bool did_close_;
82 }; 82 };
83 83
84 // Just like Delegate, except the items are treated as "dynamic" so updates to 84 // Just like Delegate, except the items are treated as "dynamic" so updates to
85 // the label/icon in the model are reflected in the menu. 85 // the label/icon in the model are reflected in the menu.
86 class DynamicDelegate : public Delegate { 86 class DynamicDelegate : public Delegate {
87 public: 87 public:
88 DynamicDelegate() {} 88 DynamicDelegate() {}
89 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE { 89 virtual bool IsItemForCommandIdDynamic(int command_id) const override {
90 return true; 90 return true;
91 } 91 }
92 virtual base::string16 GetLabelForCommandId(int command_id) const OVERRIDE { 92 virtual base::string16 GetLabelForCommandId(int command_id) const override {
93 return label_; 93 return label_;
94 } 94 }
95 virtual bool GetIconForCommandId( 95 virtual bool GetIconForCommandId(
96 int command_id, 96 int command_id,
97 gfx::Image* icon) const OVERRIDE { 97 gfx::Image* icon) const override {
98 if (icon_.IsEmpty()) { 98 if (icon_.IsEmpty()) {
99 return false; 99 return false;
100 } else { 100 } else {
101 *icon = icon_; 101 *icon = icon_;
102 return true; 102 return true;
103 } 103 }
104 } 104 }
105 void SetDynamicLabel(base::string16 label) { label_ = label; } 105 void SetDynamicLabel(base::string16 label) { label_ = label; }
106 void SetDynamicIcon(const gfx::Image& icon) { icon_ = icon; } 106 void SetDynamicIcon(const gfx::Image& icon) { icon_ = icon; }
107 107
108 private: 108 private:
109 base::string16 label_; 109 base::string16 label_;
110 gfx::Image icon_; 110 gfx::Image icon_;
111 }; 111 };
112 112
113 // Menu model that returns a gfx::FontList object for one of the items in the 113 // Menu model that returns a gfx::FontList object for one of the items in the
114 // menu. 114 // menu.
115 class FontListMenuModel : public SimpleMenuModel { 115 class FontListMenuModel : public SimpleMenuModel {
116 public: 116 public:
117 FontListMenuModel(SimpleMenuModel::Delegate* delegate, 117 FontListMenuModel(SimpleMenuModel::Delegate* delegate,
118 const gfx::FontList* font_list, int index) 118 const gfx::FontList* font_list, int index)
119 : SimpleMenuModel(delegate), 119 : SimpleMenuModel(delegate),
120 font_list_(font_list), 120 font_list_(font_list),
121 index_(index) { 121 index_(index) {
122 } 122 }
123 virtual ~FontListMenuModel() {} 123 virtual ~FontListMenuModel() {}
124 virtual const gfx::FontList* GetLabelFontListAt(int index) const OVERRIDE { 124 virtual const gfx::FontList* GetLabelFontListAt(int index) const override {
125 return (index == index_) ? font_list_ : NULL; 125 return (index == index_) ? font_list_ : NULL;
126 } 126 }
127 127
128 private: 128 private:
129 const gfx::FontList* font_list_; 129 const gfx::FontList* font_list_;
130 const int index_; 130 const int index_;
131 }; 131 };
132 132
133 TEST_F(MenuControllerTest, EmptyMenu) { 133 TEST_F(MenuControllerTest, EmptyMenu) {
134 Delegate delegate; 134 Delegate delegate;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // Pump the task that notifies the delegate. 394 // Pump the task that notifies the delegate.
395 message_loop.RunUntilIdle(); 395 message_loop.RunUntilIdle();
396 396
397 // Expect that the delegate got notified properly. 397 // Expect that the delegate got notified properly.
398 EXPECT_TRUE(delegate.did_close_); 398 EXPECT_TRUE(delegate.did_close_);
399 } 399 }
400 400
401 } // namespace 401 } // namespace
402 402
403 } // namespace ui 403 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/cocoa/controls/hover_image_menu_button_unittest.mm ('k') | ui/base/cursor/cursor_loader_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698