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

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: Created 4 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
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 5945bf3420219729677285331c487ea4611d92ed..1940e91ff683ef57292e6a6e40c4d7271537d3c9 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/single_split_view.h"
#include "ui/views/controls/webview/webview.h"
@@ -163,6 +164,24 @@ 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-T accelerator should be processed.
+ ui::Accelerator new_tab_accel(ui::VKEY_T, ui::EF_CONTROL_DOWN);
+ EXPECT_TRUE(browser_view()->AcceleratorPressed(new_tab_accel));
+
+ // If the accelerator is repeated, it should be ignored.
+ new_tab_accel.set_is_repeat(true);
+ EXPECT_FALSE(browser_view()->AcceleratorPressed(new_tab_accel));
+
+ // A repeated Ctrl-Tab accelerator should be processed.
+ ui::Accelerator next_tab_accel(ui::VKEY_TAB, ui::EF_CONTROL_DOWN);
+ next_tab_accel.set_is_repeat(true);
+ EXPECT_TRUE(browser_view()->AcceleratorPressed(next_tab_accel));
+}
+
class BrowserViewHostedAppTest : public TestWithBrowserView {
public:
BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {}

Powered by Google App Engine
This is Rietveld 408576698