diff options
author | Iain Merrick <husky@google.com> | 2010-10-19 14:37:37 +0100 |
---|---|---|
committer | Iain Merrick <husky@google.com> | 2010-10-19 14:37:37 +0100 |
commit | 3345a6884c488ff3a535c2c9acdd33d74b37e311 (patch) | |
tree | 7784b988ef1698cb6967ea1bdf07616237716c6c /chrome/browser/wrench_menu_model_unittest.cc | |
parent | efc8475837ec58186051f23bb03542620424f6ce (diff) | |
download | external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.zip external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.gz external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.bz2 |
Merge Chromium at 7.0.540.0 : Initial merge by git
Not including third_party/icu as it contains huge data files that break Gerrit, and aren't actually used.
Change-Id: I428a386e70f3b58cacd28677b8cfda282e891e15
Diffstat (limited to 'chrome/browser/wrench_menu_model_unittest.cc')
-rw-r--r-- | chrome/browser/wrench_menu_model_unittest.cc | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/chrome/browser/wrench_menu_model_unittest.cc b/chrome/browser/wrench_menu_model_unittest.cc index 2b50bb0..c539cee 100644 --- a/chrome/browser/wrench_menu_model_unittest.cc +++ b/chrome/browser/wrench_menu_model_unittest.cc @@ -4,19 +4,57 @@ #include "chrome/browser/wrench_menu_model.h" -#include "base/logging.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/test/browser_with_test_window_test.h" #include "chrome/test/menu_model_test.h" +#include "chrome/test/testing_profile.h" #include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest.h" class WrenchMenuModelTest : public BrowserWithTestWindowTest, - public MenuModelTest { + public menus::AcceleratorProvider { + public: + // Don't handle accelerators. + virtual bool GetAcceleratorForCommandId( + int command_id, + menus::Accelerator* accelerator) { return false; } +}; + +// Copies parts of MenuModelTest::Delegate and combines them with the +// WrenchMenuModel since WrenchMenuModel is now a SimpleMenuModel::Delegate and +// not derived from SimpleMenuModel. +class TestWrenchMenuModel : public WrenchMenuModel { + public: + TestWrenchMenuModel(menus::AcceleratorProvider* provider, + Browser* browser) + : WrenchMenuModel(provider, browser), + execute_count_(0), + checked_count_(0), + enable_count_(0) { + } + + // Testing overrides to menus::SimpleMenuModel::Delegate: + virtual bool IsCommandIdChecked(int command_id) const { + bool val = WrenchMenuModel::IsCommandIdChecked(command_id); + if (val) + checked_count_++; + return val; + } + + virtual bool IsCommandIdEnabled(int command_id) const { + ++enable_count_; + return true; + } + + virtual void ExecuteCommand(int command_id) { ++execute_count_; } + + int execute_count_; + mutable int checked_count_; + mutable int enable_count_; }; TEST_F(WrenchMenuModelTest, Basics) { - WrenchMenuModel model(&delegate_, browser()); + TestWrenchMenuModel model(this, browser()); int itemCount = model.GetItemCount(); // Verify it has items. The number varies by platform, so we don't check @@ -31,11 +69,11 @@ TEST_F(WrenchMenuModelTest, Basics) { // Make sure to use the index that is not separator in all configurations. model.ActivatedAt(2); EXPECT_TRUE(model.IsEnabledAt(2)); - EXPECT_EQ(delegate_.execute_count_, 2); - EXPECT_EQ(delegate_.enable_count_, 2); + EXPECT_EQ(model.execute_count_, 2); + EXPECT_EQ(model.enable_count_, 2); - delegate_.execute_count_ = 0; - delegate_.enable_count_ = 0; + model.execute_count_ = 0; + model.enable_count_ = 0; // Choose something from the tools submenu and make sure it makes it back to // the delegate as well. Use the first submenu as the tools one. @@ -52,8 +90,8 @@ TEST_F(WrenchMenuModelTest, Basics) { EXPECT_GT(toolsModel->GetItemCount(), 2); toolsModel->ActivatedAt(2); EXPECT_TRUE(toolsModel->IsEnabledAt(2)); - EXPECT_EQ(delegate_.execute_count_, 1); - EXPECT_EQ(delegate_.enable_count_, 1); + EXPECT_EQ(model.execute_count_, 1); + EXPECT_EQ(model.enable_count_, 1); } class EncodingMenuModelTest : public BrowserWithTestWindowTest, |