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

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: update comment in test 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 dictated
168 // by chrome::IsCommandRepeatable() in
169 // chrome/browser/ui/views/accelerator_table.h.
170 TEST_F(BrowserViewTest, RepeatedAccelerators) {
171 // A non-repeated Ctrl-L accelerator should be processed.
172 const ui::Accelerator kLocationAccel(ui::VKEY_L, ui::EF_CONTROL_DOWN);
173 EXPECT_TRUE(browser_view()->AcceleratorPressed(kLocationAccel));
174
175 // If the accelerator is repeated, it should be ignored.
176 const ui::Accelerator kLocationRepeatAccel(
177 ui::VKEY_L, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT);
178 EXPECT_FALSE(browser_view()->AcceleratorPressed(kLocationRepeatAccel));
179
180 // A repeated Ctrl-Tab accelerator should be processed.
181 const ui::Accelerator kNextTabRepeatAccel(
182 ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT);
183 EXPECT_TRUE(browser_view()->AcceleratorPressed(kNextTabRepeatAccel));
184 }
185
165 class BrowserViewHostedAppTest : public TestWithBrowserView { 186 class BrowserViewHostedAppTest : public TestWithBrowserView {
166 public: 187 public:
167 BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {} 188 BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {}
168 ~BrowserViewHostedAppTest() override {} 189 ~BrowserViewHostedAppTest() override {}
169 190
170 private: 191 private:
171 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest); 192 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest);
172 }; 193 };
173 194
174 // Test basic layout for hosted apps. 195 // Test basic layout for hosted apps.
(...skipping 22 matching lines...) Expand all
197 header_offset.y(); 218 header_offset.y();
198 219
199 // The web contents should be flush with the bottom of the header. 220 // The web contents should be flush with the bottom of the header.
200 EXPECT_EQ(bottom_of_header, contents_container->y()); 221 EXPECT_EQ(bottom_of_header, contents_container->y());
201 222
202 // The find bar should overlap the 1px header/web-contents separator at the 223 // The find bar should overlap the 1px header/web-contents separator at the
203 // bottom of the header. 224 // bottom of the header.
204 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(), 225 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(),
205 browser_view()->frame()->GetTopInset(false)); 226 browser_view()->frame()->GetTopInset(false));
206 } 227 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | ui/base/accelerators/accelerator_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698