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

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

Issue 10855075: Clean-up inline members of nested classes (chrome/) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months 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/test/base/menu_model_test.h ('k') | no next file » | 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 #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
9 bool MenuModelTest::Delegate::IsCommandIdChecked(int command_id) const {
10 return false;
11 }
12
13 bool MenuModelTest::Delegate::IsCommandIdEnabled(int command_id) const {
14 ++enable_count_;
15 return true;
16 }
17
18 bool MenuModelTest::Delegate::GetAcceleratorForCommandId(
19 int command_id,
20 ui::Accelerator* accelerator) {
21 return false;
22 }
23
24 void MenuModelTest::Delegate::ExecuteCommand(int command_id) {
25 ++execute_count_;
26 }
27
8 // 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
9 // 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
10 // 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.
11 void MenuModelTest::CountEnabledExecutable(ui::MenuModel* model, 31 void MenuModelTest::CountEnabledExecutable(ui::MenuModel* model,
12 int* count) { 32 int* count) {
13 for (int i = 0; i < model->GetItemCount(); ++i) { 33 for (int i = 0; i < model->GetItemCount(); ++i) {
14 ui::MenuModel::ItemType type = model->GetTypeAt(i); 34 ui::MenuModel::ItemType type = model->GetTypeAt(i);
15 switch (type) { 35 switch (type) {
16 case ui::MenuModel::TYPE_SEPARATOR: 36 case ui::MenuModel::TYPE_SEPARATOR:
17 continue; 37 continue;
18 case ui::MenuModel::TYPE_SUBMENU: 38 case ui::MenuModel::TYPE_SUBMENU:
19 CountEnabledExecutable(model->GetSubmenuModelAt(i), count); 39 CountEnabledExecutable(model->GetSubmenuModelAt(i), count);
20 break; 40 break;
21 case ui::MenuModel::TYPE_COMMAND: 41 case ui::MenuModel::TYPE_COMMAND:
22 case ui::MenuModel::TYPE_CHECK: 42 case ui::MenuModel::TYPE_CHECK:
23 case ui::MenuModel::TYPE_RADIO: 43 case ui::MenuModel::TYPE_RADIO:
24 model->IsEnabledAt(i); // Check if it's enabled (ignore answer). 44 model->IsEnabledAt(i); // Check if it's enabled (ignore answer).
25 model->ActivatedAt(i); // Execute it. 45 model->ActivatedAt(i); // Execute it.
26 (*count)++; // Increment the count of executable items seen. 46 (*count)++; // Increment the count of executable items seen.
27 break; 47 break;
28 default: 48 default:
29 FAIL(); // Ensure every case is tested. 49 FAIL(); // Ensure every case is tested.
30 } 50 }
31 } 51 }
32 } 52 }
OLDNEW
« no previous file with comments | « chrome/test/base/menu_model_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698