OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "chrome/test/menu_model_test.h" | |
6 #include "testing/gtest/include/gtest/gtest.h" | |
7 | |
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 | |
10 // match the number of times the delegate is called to ensure every item works. | |
11 void MenuModelTest::CountEnabledExecutable(ui::MenuModel* model, | |
12 int* count) { | |
13 for (int i = 0; i < model->GetItemCount(); ++i) { | |
14 ui::MenuModel::ItemType type = model->GetTypeAt(i); | |
15 switch (type) { | |
16 case ui::MenuModel::TYPE_SEPARATOR: | |
17 continue; | |
18 case ui::MenuModel::TYPE_SUBMENU: | |
19 CountEnabledExecutable(model->GetSubmenuModelAt(i), count); | |
20 break; | |
21 case ui::MenuModel::TYPE_COMMAND: | |
22 case ui::MenuModel::TYPE_CHECK: | |
23 case ui::MenuModel::TYPE_RADIO: | |
24 model->IsEnabledAt(i); // Check if it's enabled (ignore answer). | |
25 model->ActivatedAt(i); // Execute it. | |
26 (*count)++; // Increment the count of executable items seen. | |
27 break; | |
28 default: | |
29 FAIL(); // Ensure every case is tested. | |
30 } | |
31 } | |
32 } | |
OLD | NEW |