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

Unified Diff: chrome/browser/ui/views/frame/browser_view_unittest.cc

Issue 2128243003: Make most browser accelerators not repeat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use set and fix tests Created 4 years, 3 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
Index: chrome/browser/ui/views/frame/browser_view_unittest.cc
diff --git a/chrome/browser/ui/views/frame/browser_view_unittest.cc b/chrome/browser/ui/views/frame/browser_view_unittest.cc
index 11c644827a37f97ba4729c4221b120802bd5f44d..ee63412e1b212aa878478f5dbb90a6472f08de18 100644
--- a/chrome/browser/ui/views/frame/browser_view_unittest.cc
+++ b/chrome/browser/ui/views/frame/browser_view_unittest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/common/url_constants.h"
+#include "ui/base/accelerators/accelerator.h"
#include "ui/views/controls/webview/webview.h"
namespace {
@@ -162,6 +163,25 @@ TEST_F(BrowserViewTest, BrowserViewLayout) {
BookmarkBarView::DisableAnimationsForTesting(false);
}
+// Test that repeated accelerators are processed or ignored depending on the
+// commands that they refer to. The behavior for different commands is specified
+// by GetRepeatableCommandIds() in chrome/browser/ui/views/accelerator_table.h.
+TEST_F(BrowserViewTest, RepeatedAccelerators) {
+ // A non-repeated Ctrl-L accelerator should be processed.
+ const ui::Accelerator kLocationAccel(ui::VKEY_L, ui::EF_CONTROL_DOWN);
+ EXPECT_TRUE(browser_view()->AcceleratorPressed(kLocationAccel));
+
+ // If the accelerator is repeated, it should be ignored.
+ const ui::Accelerator kLocationRepeatAccel(
+ ui::VKEY_L, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT);
+ EXPECT_FALSE(browser_view()->AcceleratorPressed(kLocationRepeatAccel));
+
+ // A repeated Ctrl-Tab accelerator should be processed.
+ const ui::Accelerator kNextTabRepeatAccel(
+ ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT);
+ EXPECT_TRUE(browser_view()->AcceleratorPressed(kNextTabRepeatAccel));
+}
+
class BrowserViewHostedAppTest : public TestWithBrowserView {
public:
BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {}

Powered by Google App Engine
This is Rietveld 408576698