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

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

Issue 8695005: Move accelerator related files to ui/base/accelerators (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.h ('k') | ui/aura_shell/shell_accelerator_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_TEST_BASE_MENU_MODEL_TEST_H_ 5 #ifndef CHROME_TEST_BASE_MENU_MODEL_TEST_H_
6 #define CHROME_TEST_BASE_MENU_MODEL_TEST_H_ 6 #define CHROME_TEST_BASE_MENU_MODEL_TEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include "ui/base/models/accelerator.h" 9 #include "ui/base/accelerators/accelerator.h"
10 #include "ui/base/models/simple_menu_model.h" 10 #include "ui/base/models/simple_menu_model.h"
11 11
12 // 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
13 // testing::Test to provide some extra functionality for testing menu models. 13 // testing::Test to provide some extra functionality for testing menu models.
14 class MenuModelTest { 14 class MenuModelTest {
15 public: 15 public:
16 MenuModelTest() { } 16 MenuModelTest() {}
17 virtual ~MenuModelTest() { } 17 virtual ~MenuModelTest() {}
18 18
19 protected: 19 protected:
20 // 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
21 // to make sure things are hooked up properly. 21 // to make sure things are hooked up properly.
22 class Delegate : public ui::SimpleMenuModel::Delegate, 22 class Delegate : public ui::SimpleMenuModel::Delegate,
23 public ui::AcceleratorProvider { 23 public ui::AcceleratorProvider {
24 public: 24 public:
25 Delegate() : execute_count_(0), enable_count_(0) { } 25 Delegate() : execute_count_(0), enable_count_(0) {}
26 26
27 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { 27 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE {
28 return false; 28 return false;
29 } 29 }
30 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { 30 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE {
31 ++enable_count_; 31 ++enable_count_;
32 return true; 32 return true;
33 } 33 }
34 virtual bool GetAcceleratorForCommandId( 34 virtual bool GetAcceleratorForCommandId(
35 int command_id, 35 int command_id,
36 ui::Accelerator* accelerator) OVERRIDE { return false; } 36 ui::Accelerator* accelerator) OVERRIDE { return false; }
37 virtual void ExecuteCommand(int command_id) OVERRIDE { ++execute_count_; } 37 virtual void ExecuteCommand(int command_id) OVERRIDE { ++execute_count_; }
38 38
39 int execute_count_; 39 int execute_count_;
40 mutable int enable_count_; 40 mutable int enable_count_;
41 }; 41 };
42 42
43 // Recursively checks the enabled state and executes a command on every item 43 // Recursively checks the enabled state and executes a command on every item
44 // that's not a separator or a submenu parent item. The returned count should 44 // that's not a separator or a submenu parent item. The returned count should
45 // match the number of times the delegate is called to ensure every item 45 // match the number of times the delegate is called to ensure every item
46 // works. 46 // works.
47 void CountEnabledExecutable(ui::MenuModel* model, int* count); 47 void CountEnabledExecutable(ui::MenuModel* model, int* count);
48 48
49 Delegate delegate_; 49 Delegate delegate_;
50 }; 50 };
51 51
52 #endif // CHROME_TEST_BASE_MENU_MODEL_TEST_H_ 52 #endif // CHROME_TEST_BASE_MENU_MODEL_TEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.h ('k') | ui/aura_shell/shell_accelerator_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698