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/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 // Recursively checks the enabled state and executes a command on every item | 8 // Recursively checks the enabled state and executes a command on every item |
9 // that's not a separator or a submenu parent item. The returned count should | 9 // that's not a separator or a submenu parent item. The returned count should |
10 // match the number of times the delegate is called to ensure every item works. | 10 // match the number of times the delegate is called to ensure every item works. |
11 void MenuModelTest::CountEnabledExecutable(ui::MenuModel* model, | 11 void MenuModelTest::CountEnabledExecutable(ui::MenuModel* model, |
12 int* count) { | 12 int* count) { |
13 for (int i = 0; i < model->GetItemCount(); ++i) { | 13 for (int i = 0; i < model->GetItemCount(); ++i) { |
14 ui::MenuModel::ItemType type = model->GetTypeAt(i); | 14 ui::MenuModel::ItemType type = model->GetTypeAt(i); |
15 switch (type) { | 15 switch (type) { |
16 case ui::MenuModel::TYPE_SEPARATOR: | 16 case ui::MenuModel::TYPE_SEPARATOR: |
17 continue; | 17 continue; |
18 case ui::MenuModel::TYPE_SUBMENU: | 18 case ui::MenuModel::TYPE_SUBMENU: |
19 CountEnabledExecutable(model->GetSubmenuModelAt(i), count); | 19 CountEnabledExecutable(model->GetSubmenuModelAt(i), count); |
20 break; | 20 break; |
21 case ui::MenuModel::TYPE_COMMAND: | 21 case ui::MenuModel::TYPE_COMMAND: |
22 case ui::MenuModel::TYPE_CHECK: | 22 case ui::MenuModel::TYPE_CHECK: |
23 case ui::MenuModel::TYPE_RADIO: | 23 case ui::MenuModel::TYPE_RADIO: |
24 model->IsEnabledAt(i); // Check if it's enabled (ignore answer). | 24 model->IsEnabledAt(i); // Check if it's enabled (ignore answer). |
25 model->ActivatedAt(i); // Execute it. | 25 model->ActivatedAt(i); // Execute it. |
26 (*count)++; // Increment the count of executable items seen. | 26 (*count)++; // Increment the count of executable items seen. |
27 break; | 27 break; |
28 default: | 28 default: |
29 FAIL(); // Ensure every case is tested. | 29 FAIL(); // Ensure every case is tested. |
30 } | 30 } |
31 } | 31 } |
32 } | 32 } |
OLD | NEW |