summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_menu_model_unittest.cc
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-15 17:11:30 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-15 17:11:30 +0000
commitb694453d2397cb3886e4fb59bfdefb55c9f9081e (patch)
tree2c3c730e61bb6731bf9c4eb8a8adb17e4efc4887 /chrome/browser/app_menu_model_unittest.cc
parent3cd1f6b0d74cb2f546b430f49af1a91ef951ce95 (diff)
downloadchromium_src-b694453d2397cb3886e4fb59bfdefb55c9f9081e.zip
chromium_src-b694453d2397cb3886e4fb59bfdefb55c9f9081e.tar.gz
chromium_src-b694453d2397cb3886e4fb59bfdefb55c9f9081e.tar.bz2
Make a shared app menu model and update win and mac to use it. Remove the NSMenu from Toolbar.xib.
BUG=22646 TEST=the app menu works as it used to. Review URL: http://codereview.chromium.org/482006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34561 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/app_menu_model_unittest.cc')
-rw-r--r--chrome/browser/app_menu_model_unittest.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/chrome/browser/app_menu_model_unittest.cc b/chrome/browser/app_menu_model_unittest.cc
new file mode 100644
index 0000000..b354292
--- /dev/null
+++ b/chrome/browser/app_menu_model_unittest.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "chrome/browser/app_menu_model.h"
+
+#include "base/logging.h"
+#include "chrome/test/browser_with_test_window_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// A menu delegate that counts the number of times certain things are called
+// to make sure things are hooked up properly.
+class Delegate : public menus::SimpleMenuModel::Delegate {
+ public:
+ Delegate() : execute_count_(0), enable_count_(0) { }
+
+ virtual bool IsCommandIdChecked(int command_id) const { return false; }
+ virtual bool IsCommandIdEnabled(int command_id) const {
+ ++enable_count_;
+ return true;
+ }
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ menus::Accelerator* accelerator) { return false; }
+ virtual void ExecuteCommand(int command_id) { ++execute_count_; }
+
+ int execute_count_;
+ mutable int enable_count_;
+};
+
+class AppMenuModelTest : public BrowserWithTestWindowTest {
+};
+
+TEST_F(AppMenuModelTest, Basics) {
+ Delegate delegate;
+ AppMenuModel model(&delegate, browser());
+
+ // Verify it has items. The number varies by platform, so we don't check
+ // the exact number.
+ EXPECT_GT(model.GetItemCount(), 5);
+
+ // Execute a couple of the items and make sure it gets back to our delegate.
+ model.ActivatedAt(0);
+ EXPECT_TRUE(model.IsEnabledAt(0));
+ model.ActivatedAt(3);
+ EXPECT_TRUE(model.IsEnabledAt(4));
+ EXPECT_EQ(delegate.execute_count_, 2);
+ EXPECT_EQ(delegate.enable_count_, 2);
+
+ delegate.execute_count_ = 0;
+ delegate.enable_count_ = 0;
+}