| Index: chrome/browser/ui/toolbar/component_toolbar_actions_browsertest.cc
|
| diff --git a/chrome/browser/ui/toolbar/component_toolbar_actions_browsertest.cc b/chrome/browser/ui/toolbar/component_toolbar_actions_browsertest.cc
|
| index 4979ecf9d43af4b9fae9368f42ff20749bfac1a7..307a74dc612521899696e644ff88076593da5f21 100644
|
| --- a/chrome/browser/ui/toolbar/component_toolbar_actions_browsertest.cc
|
| +++ b/chrome/browser/ui/toolbar/component_toolbar_actions_browsertest.cc
|
| @@ -4,77 +4,18 @@
|
|
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/extensions/browser_action_test_util.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
|
| +#include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h"
|
| #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "extensions/common/feature_switch.h"
|
| -#include "grit/theme_resources.h"
|
| -#include "ui/base/resource/resource_bundle.h"
|
| -#include "ui/gfx/image/image.h"
|
| -#include "ui/gfx/image/image_skia.h"
|
|
|
| namespace {
|
|
|
| const char kMockId[] = "mock_action";
|
|
|
| -class MockComponentAction : public ToolbarActionViewController {
|
| - public:
|
| - MockComponentAction() : click_count_(0u), id_(kMockId) {}
|
| - ~MockComponentAction() override {}
|
| -
|
| - // ToolbarActionButtonController:
|
| - const std::string& GetId() const override { return id_; }
|
| - void SetDelegate(ToolbarActionViewDelegate* delegate) override {}
|
| - gfx::Image GetIcon(content::WebContents* web_contents) override {
|
| - return ui::ResourceBundle::GetSharedInstance().GetImageNamed(
|
| - IDR_BROWSER_ACTION);
|
| - }
|
| - gfx::ImageSkia GetIconWithBadge() override {
|
| - return *GetIcon(nullptr).ToImageSkia();
|
| - }
|
| - base::string16 GetActionName() const override {
|
| - return base::ASCIIToUTF16("Component Action");
|
| - }
|
| - base::string16 GetAccessibleName(content::WebContents* web_contents)
|
| - const override {
|
| - return GetActionName();
|
| - }
|
| - base::string16 GetTooltip(content::WebContents* web_contents)
|
| - const override {
|
| - return GetActionName();
|
| - }
|
| - bool IsEnabled(content::WebContents* web_contents) const override {
|
| - return true;
|
| - }
|
| - bool WantsToRun(content::WebContents* web_contents) const override {
|
| - return false;
|
| - }
|
| - bool HasPopup(content::WebContents* web_contents) const override {
|
| - return true;
|
| - }
|
| - void HidePopup() override {}
|
| - gfx::NativeView GetPopupNativeView() override { return nullptr; }
|
| - ui::MenuModel* GetContextMenu() override { return nullptr; }
|
| - bool CanDrag() const override { return false; }
|
| - bool IsMenuRunning() const override { return false; }
|
| - bool ExecuteAction(bool by_user) override {
|
| - ++click_count_;
|
| - return false;
|
| - }
|
| - void UpdateState() override {}
|
| -
|
| - size_t click_count() const { return click_count_; }
|
| -
|
| - private:
|
| - size_t click_count_;
|
| - std::string id_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(MockComponentAction);
|
| -};
|
| -
|
| class MockComponentToolbarActionsFactory
|
| : public ComponentToolbarActionsFactory {
|
| public:
|
| @@ -85,13 +26,13 @@ class MockComponentToolbarActionsFactory
|
| ScopedVector<ToolbarActionViewController> GetComponentToolbarActions()
|
| override;
|
|
|
| - const std::vector<MockComponentAction*>& weak_actions() const {
|
| + const std::vector<TestToolbarActionViewController*>& weak_actions() const {
|
| return weak_actions_;
|
| }
|
|
|
| private:
|
| // A (weak) set of all created actions.
|
| - std::vector<MockComponentAction*> weak_actions_;
|
| + std::vector<TestToolbarActionViewController*> weak_actions_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(MockComponentToolbarActionsFactory);
|
| };
|
| @@ -107,7 +48,8 @@ MockComponentToolbarActionsFactory::~MockComponentToolbarActionsFactory() {
|
| ScopedVector<ToolbarActionViewController>
|
| MockComponentToolbarActionsFactory::GetComponentToolbarActions() {
|
| ScopedVector<ToolbarActionViewController> component_actions;
|
| - MockComponentAction* action = new MockComponentAction();
|
| + TestToolbarActionViewController* action =
|
| + new TestToolbarActionViewController(kMockId);
|
| component_actions.push_back(action);
|
| weak_actions_.push_back(action);
|
| return component_actions.Pass();
|
| @@ -152,14 +94,14 @@ IN_PROC_BROWSER_TEST_F(ComponentToolbarActionsBrowserTest,
|
| EXPECT_EQ(kMockId, browser_actions_bar.GetExtensionId(0));
|
|
|
| // There should only have been one created component action.
|
| - const std::vector<MockComponentAction*> weak_actions =
|
| + const std::vector<TestToolbarActionViewController*>& weak_actions =
|
| mock_factory()->weak_actions();
|
| ASSERT_EQ(1u, weak_actions.size());
|
| - MockComponentAction* mock_component_action = weak_actions[0];
|
| + TestToolbarActionViewController* mock_component_action = weak_actions[0];
|
| ASSERT_TRUE(mock_component_action);
|
|
|
| // Test that clicking on the component action works.
|
| - EXPECT_EQ(0u, mock_component_action->click_count());
|
| + EXPECT_EQ(0, mock_component_action->execute_action_count());
|
| browser_actions_bar.Press(0);
|
| - EXPECT_EQ(1u, mock_component_action->click_count());
|
| + EXPECT_EQ(1, mock_component_action->execute_action_count());
|
| }
|
|
|