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

Unified Diff: chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc

Issue 1216053013: [Extension Toolbar Redesign] Wants to act treatment, redux - left click (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_action_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc
diff --git a/chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc b/chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc
index d724a4f6528bc4f9d33118ed8c41610db4aff5e4..2b29250f106703419d0a81dba0d8e3064c8138eb 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc
@@ -64,6 +64,33 @@ class TestToolbarActionViewDelegate : public ToolbarActionView::Delegate {
DISALLOW_COPY_AND_ASSIGN(TestToolbarActionViewDelegate);
};
+class OpenMenuListener : public views::ContextMenuController {
+ public:
+ explicit OpenMenuListener(views::View* view)
+ : view_(view),
+ opened_menu_(false) {
+ view_->set_context_menu_controller(this);
+ }
+ ~OpenMenuListener() override {
+ view_->set_context_menu_controller(nullptr);
+ }
+
+ void ShowContextMenuForView(views::View* source,
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) override {
+ opened_menu_ = true;
+ };
+
+ bool opened_menu() const { return opened_menu_; }
+
+ private:
+ views::View* view_;
+
+ bool opened_menu_;
+
+ DISALLOW_COPY_AND_ASSIGN(OpenMenuListener);
+};
+
} // namespace
class ToolbarActionViewUnitTest : public views::ViewsTestBase {
@@ -169,6 +196,19 @@ TEST_F(ToolbarActionViewUnitTest, BasicToolbarActionViewTest) {
controller.SetEnabled(true);
EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
+ // Ensure that clicking on an otherwise-disabled action optionally opens the
+ // context menu.
+ controller.SetDisabledClickOpensMenu(true);
+ controller.SetEnabled(false);
+ EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
+ int old_execute_action_count = controller.execute_action_count();
+ {
+ OpenMenuListener menu_listener(&view);
+ view.Activate();
+ EXPECT_TRUE(menu_listener.opened_menu());
+ EXPECT_EQ(old_execute_action_count, controller.execute_action_count());
+ }
+
// Ensure that the button's want-to-run state reflects that of the controller.
controller.SetWantsToRun(true);
EXPECT_TRUE(view.wants_to_run_for_testing());
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_action_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698