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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/layout_constants.h" 10 #include "chrome/browser/ui/layout_constants.h"
11 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 11 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
12 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 12 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
13 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" 13 #include "chrome/browser/ui/views/frame/test_with_browser_view.h"
14 #include "chrome/browser/ui/views/frame/top_container_view.h" 14 #include "chrome/browser/ui/views/frame/top_container_view.h"
15 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 15 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
16 #include "chrome/browser/ui/views/tabs/tab_strip.h" 16 #include "chrome/browser/ui/views/tabs/tab_strip.h"
17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "ui/base/accelerators/accelerator.h"
19 #include "ui/views/controls/webview/webview.h" 20 #include "ui/views/controls/webview/webview.h"
20 21
21 namespace { 22 namespace {
22 23
23 // Tab strip bounds depend on the window frame sizes. 24 // Tab strip bounds depend on the window frame sizes.
24 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { 25 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) {
25 gfx::Rect tabstrip_bounds( 26 gfx::Rect tabstrip_bounds(
26 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip())); 27 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip()));
27 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 28 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
28 views::View::ConvertPointToTarget(browser_view->parent(), 29 views::View::ConvertPointToTarget(browser_view->parent(),
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EXPECT_FALSE(bookmark_bar->visible()); 156 EXPECT_FALSE(bookmark_bar->visible());
156 EXPECT_FALSE(bookmark_bar->IsDetached()); 157 EXPECT_FALSE(bookmark_bar->IsDetached());
157 EXPECT_EQ(top_container, bookmark_bar->parent()); 158 EXPECT_EQ(top_container, bookmark_bar->parent());
158 // Top container is still third from front. 159 // Top container is still third from front.
159 EXPECT_EQ(browser_view()->child_count() - 3, 160 EXPECT_EQ(browser_view()->child_count() - 3,
160 browser_view()->GetIndexOf(top_container)); 161 browser_view()->GetIndexOf(top_container));
161 162
162 BookmarkBarView::DisableAnimationsForTesting(false); 163 BookmarkBarView::DisableAnimationsForTesting(false);
163 } 164 }
164 165
166 // Test that repeated accelerators are processed or ignored depending on the
167 // commands that they refer to. The behavior for different commands is specified
168 // by GetRepeatableCommandIds() in chrome/browser/ui/views/accelerator_table.h.
169 TEST_F(BrowserViewTest, RepeatedAccelerators) {
170 // A non-repeated Ctrl-L accelerator should be processed.
171 const ui::Accelerator kLocationAccel(ui::VKEY_L, ui::EF_CONTROL_DOWN);
172 EXPECT_TRUE(browser_view()->AcceleratorPressed(kLocationAccel));
173
174 // If the accelerator is repeated, it should be ignored.
175 const ui::Accelerator kLocationRepeatAccel(
176 ui::VKEY_L, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT);
177 EXPECT_FALSE(browser_view()->AcceleratorPressed(kLocationRepeatAccel));
178
179 // A repeated Ctrl-Tab accelerator should be processed.
180 const ui::Accelerator kNextTabRepeatAccel(
181 ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT);
182 EXPECT_TRUE(browser_view()->AcceleratorPressed(kNextTabRepeatAccel));
183 }
184
165 class BrowserViewHostedAppTest : public TestWithBrowserView { 185 class BrowserViewHostedAppTest : public TestWithBrowserView {
166 public: 186 public:
167 BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {} 187 BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {}
168 ~BrowserViewHostedAppTest() override {} 188 ~BrowserViewHostedAppTest() override {}
169 189
170 private: 190 private:
171 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest); 191 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest);
172 }; 192 };
173 193
174 // Test basic layout for hosted apps. 194 // Test basic layout for hosted apps.
(...skipping 22 matching lines...) Expand all
197 header_offset.y(); 217 header_offset.y();
198 218
199 // The web contents should be flush with the bottom of the header. 219 // The web contents should be flush with the bottom of the header.
200 EXPECT_EQ(bottom_of_header, contents_container->y()); 220 EXPECT_EQ(bottom_of_header, contents_container->y());
201 221
202 // The find bar should overlap the 1px header/web-contents separator at the 222 // The find bar should overlap the 1px header/web-contents separator at the
203 // bottom of the header. 223 // bottom of the header.
204 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(), 224 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(),
205 browser_view()->frame()->GetTopInset(false)); 225 browser_view()->frame()->GetTopInset(false));
206 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698