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

Side by Side Diff: chrome/test/menu_model_test.h

Issue 3163023: Clean up the WrenchMenuModel so that it uses SimpleMenu::Delegate. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix stray rb Created 10 years, 4 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_TEST_MENU_MODEL_TEST_H_ 5 #ifndef CHROME_TEST_MENU_MODEL_TEST_H_
6 #define CHROME_TEST_MENU_MODEL_TEST_H_ 6 #define CHROME_TEST_MENU_MODEL_TEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include "app/menus/accelerator.h"
9 #include "app/menus/simple_menu_model.h" 10 #include "app/menus/simple_menu_model.h"
10 11
11 // A mix-in class to be used in addition to something that derrives from 12 // A mix-in class to be used in addition to something that derrives from
12 // testing::Test to provide some extra functionality for testing menu models. 13 // testing::Test to provide some extra functionality for testing menu models.
13 class MenuModelTest { 14 class MenuModelTest {
14 public: 15 public:
15 MenuModelTest() { } 16 MenuModelTest() { }
16 virtual ~MenuModelTest() { } 17 virtual ~MenuModelTest() { }
17 18
18 protected: 19 protected:
19 // A menu delegate that counts the number of times certain things are called 20 // A menu delegate that counts the number of times certain things are called
20 // to make sure things are hooked up properly. 21 // to make sure things are hooked up properly.
21 class Delegate : public menus::SimpleMenuModel::Delegate { 22 class Delegate : public menus::SimpleMenuModel::Delegate,
23 public menus::AcceleratorProvider {
22 public: 24 public:
23 Delegate() : execute_count_(0), enable_count_(0) { } 25 Delegate() : execute_count_(0), enable_count_(0) { }
24 26
25 virtual bool IsCommandIdChecked(int command_id) const { return false; } 27 virtual bool IsCommandIdChecked(int command_id) const { return false; }
26 virtual bool IsCommandIdEnabled(int command_id) const { 28 virtual bool IsCommandIdEnabled(int command_id) const {
27 ++enable_count_; 29 ++enable_count_;
28 return true; 30 return true;
29 } 31 }
30 virtual bool GetAcceleratorForCommandId( 32 virtual bool GetAcceleratorForCommandId(
31 int command_id, 33 int command_id,
32 menus::Accelerator* accelerator) { return false; } 34 menus::Accelerator* accelerator) { return false; }
33 virtual void ExecuteCommand(int command_id) { ++execute_count_; } 35 virtual void ExecuteCommand(int command_id) { ++execute_count_; }
34 36
35 int execute_count_; 37 int execute_count_;
36 mutable int enable_count_; 38 mutable int enable_count_;
37 }; 39 };
38 40
39 // Recursively checks the enabled state and executes a command on every item 41 // Recursively checks the enabled state and executes a command on every item
40 // that's not a separator or a submenu parent item. The returned count should 42 // that's not a separator or a submenu parent item. The returned count should
41 // match the number of times the delegate is called to ensure every item 43 // match the number of times the delegate is called to ensure every item
42 // works. 44 // works.
43 void CountEnabledExecutable(menus::MenuModel* model, int* count); 45 void CountEnabledExecutable(menus::MenuModel* model, int* count);
44 46
45 Delegate delegate_; 47 Delegate delegate_;
46 }; 48 };
47 49
48 #endif // CHROME_TEST_MENU_MODEL_TEST_H_ 50 #endif // CHROME_TEST_MENU_MODEL_TEST_H_
OLDNEW
« chrome/browser/wrench_menu_model.cc ('K') | « chrome/browser/wrench_menu_model_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698