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

Side by Side Diff: chrome/browser/app_menu_model_unittest.cc

Issue 482006: Make a shared app menu model and update win and mac to use it. Remove the NSM... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years 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
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 #include "chrome/browser/app_menu_model.h"
6
7 #include "base/logging.h"
8 #include "chrome/test/browser_with_test_window_test.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 // A menu delegate that counts the number of times certain things are called
12 // to make sure things are hooked up properly.
13 class Delegate : public menus::SimpleMenuModel::Delegate {
14 public:
15 Delegate() : execute_count_(0), enable_count_(0) { }
16
17 virtual bool IsCommandIdChecked(int command_id) const { return false; }
18 virtual bool IsCommandIdEnabled(int command_id) const {
19 ++enable_count_;
20 return true;
21 }
22 virtual bool GetAcceleratorForCommandId(
23 int command_id,
24 menus::Accelerator* accelerator) { return false; }
25 virtual void ExecuteCommand(int command_id) { ++execute_count_; }
26
27 int execute_count_;
28 mutable int enable_count_;
29 };
30
31 class AppMenuModelTest : public BrowserWithTestWindowTest {
32 };
33
34 TEST_F(AppMenuModelTest, Basics) {
35 Delegate delegate;
36 AppMenuModel model(&delegate, browser());
37
38 // Verify it has items. The number varies by platform, so we don't check
39 // the exact number.
40 EXPECT_GT(model.GetItemCount(), 5);
41
42 // Execute a couple of the items and make sure it gets back to our delegate.
43 model.ActivatedAt(0);
44 EXPECT_TRUE(model.IsEnabledAt(0));
45 model.ActivatedAt(3);
46 EXPECT_TRUE(model.IsEnabledAt(4));
47 EXPECT_EQ(delegate.execute_count_, 2);
48 EXPECT_EQ(delegate.enable_count_, 2);
49
50 delegate.execute_count_ = 0;
51 delegate.enable_count_ = 0;
52 }
OLDNEW
« no previous file with comments | « chrome/browser/app_menu_model.cc ('k') | chrome/browser/autocomplete/autocomplete_edit_view_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698