Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / chrome / test / base / menu_model_test.h
blob8133485736c2a8e4b2f135c51dbfb6beed1ed7b4
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
3 // found in the LICENSE file.
5 #ifndef CHROME_TEST_BASE_MENU_MODEL_TEST_H_
6 #define CHROME_TEST_BASE_MENU_MODEL_TEST_H_
8 #include "ui/base/accelerators/accelerator.h"
9 #include "ui/base/models/simple_menu_model.h"
11 // 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 class MenuModelTest {
14 public:
15 MenuModelTest() {}
16 virtual ~MenuModelTest() {}
18 protected:
19 // A menu delegate that counts the number of times certain things are called
20 // to make sure things are hooked up properly.
21 class Delegate : public ui::SimpleMenuModel::Delegate,
22 public ui::AcceleratorProvider {
23 public:
24 Delegate() : execute_count_(0), enable_count_(0) {}
26 bool IsCommandIdChecked(int command_id) const override;
27 bool IsCommandIdEnabled(int command_id) const override;
28 bool GetAcceleratorForCommandId(int command_id,
29 ui::Accelerator* accelerator) override;
30 void ExecuteCommand(int command_id, int event_flags) override;
32 int execute_count_;
33 mutable int enable_count_;
36 // Recursively checks the enabled state and executes a command on every item
37 // that's not a separator or a submenu parent item. The returned count should
38 // match the number of times the delegate is called to ensure every item
39 // works.
40 void CountEnabledExecutable(ui::MenuModel* model, int* count);
42 Delegate delegate_;
45 #endif // CHROME_TEST_BASE_MENU_MODEL_TEST_H_