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 #include "chrome/test/base/menu_model_test.h" | 5 #include "chrome/test/base/menu_model_test.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 | 8 |
9 bool MenuModelTest::Delegate::IsCommandIdChecked(int command_id) const { | 9 bool MenuModelTest::Delegate::IsCommandIdChecked(int command_id) const { |
10 return false; | 10 return false; |
11 } | 11 } |
12 | 12 |
13 bool MenuModelTest::Delegate::IsCommandIdEnabled(int command_id) const { | 13 bool MenuModelTest::Delegate::IsCommandIdEnabled(int command_id) const { |
14 ++enable_count_; | 14 ++enable_count_; |
15 return true; | 15 return true; |
16 } | 16 } |
17 | 17 |
18 bool MenuModelTest::Delegate::GetAcceleratorForCommandId( | 18 bool MenuModelTest::Delegate::GetAcceleratorForCommandId( |
19 int command_id, | 19 int command_id, |
20 ui::Accelerator* accelerator) { | 20 ui::Accelerator* accelerator) const { |
21 return false; | 21 return false; |
22 } | 22 } |
23 | 23 |
24 void MenuModelTest::Delegate::ExecuteCommand(int command_id, int event_flags) { | 24 void MenuModelTest::Delegate::ExecuteCommand(int command_id, int event_flags) { |
25 ++execute_count_; | 25 ++execute_count_; |
26 } | 26 } |
27 | 27 |
28 // Recursively checks the enabled state and executes a command on every item | 28 // Recursively checks the enabled state and executes a command on every item |
29 // that's not a separator or a submenu parent item. The returned count should | 29 // that's not a separator or a submenu parent item. The returned count should |
30 // match the number of times the delegate is called to ensure every item works. | 30 // match the number of times the delegate is called to ensure every item works. |
(...skipping 12 matching lines...) Expand all Loading... |
43 case ui::MenuModel::TYPE_RADIO: | 43 case ui::MenuModel::TYPE_RADIO: |
44 model->IsEnabledAt(i); // Check if it's enabled (ignore answer). | 44 model->IsEnabledAt(i); // Check if it's enabled (ignore answer). |
45 model->ActivatedAt(i); // Execute it. | 45 model->ActivatedAt(i); // Execute it. |
46 (*count)++; // Increment the count of executable items seen. | 46 (*count)++; // Increment the count of executable items seen. |
47 break; | 47 break; |
48 default: | 48 default: |
49 FAIL(); // Ensure every case is tested. | 49 FAIL(); // Ensure every case is tested. |
50 } | 50 } |
51 } | 51 } |
52 } | 52 } |
OLD | NEW |