OLD | NEW |
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/single_split_view.h" | 20 #include "ui/views/controls/single_split_view.h" |
20 #include "ui/views/controls/webview/webview.h" | 21 #include "ui/views/controls/webview/webview.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Tab strip bounds depend on the window frame sizes. | 25 // Tab strip bounds depend on the window frame sizes. |
25 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { | 26 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { |
26 gfx::Rect tabstrip_bounds( | 27 gfx::Rect tabstrip_bounds( |
27 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip())); | 28 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip())); |
28 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 29 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 EXPECT_FALSE(bookmark_bar->visible()); | 157 EXPECT_FALSE(bookmark_bar->visible()); |
157 EXPECT_FALSE(bookmark_bar->IsDetached()); | 158 EXPECT_FALSE(bookmark_bar->IsDetached()); |
158 EXPECT_EQ(top_container, bookmark_bar->parent()); | 159 EXPECT_EQ(top_container, bookmark_bar->parent()); |
159 // Top container is still third from front. | 160 // Top container is still third from front. |
160 EXPECT_EQ(browser_view()->child_count() - 3, | 161 EXPECT_EQ(browser_view()->child_count() - 3, |
161 browser_view()->GetIndexOf(top_container)); | 162 browser_view()->GetIndexOf(top_container)); |
162 | 163 |
163 BookmarkBarView::DisableAnimationsForTesting(false); | 164 BookmarkBarView::DisableAnimationsForTesting(false); |
164 } | 165 } |
165 | 166 |
| 167 // Test that repeated accelerators are processed or ignored depending on the |
| 168 // commands that they refer to. The behavior for different commands is specified |
| 169 // by GetRepeatableCommandIds() in chrome/browser/ui/views/accelerator_table.h. |
| 170 TEST_F(BrowserViewTest, RepeatedAccelerators) { |
| 171 // A non-repeated Ctrl-T accelerator should be processed. |
| 172 ui::Accelerator new_tab_accel(ui::VKEY_T, ui::EF_CONTROL_DOWN); |
| 173 EXPECT_TRUE(browser_view()->AcceleratorPressed(new_tab_accel)); |
| 174 |
| 175 // If the accelerator is repeated, it should be ignored. |
| 176 new_tab_accel.set_is_repeat(true); |
| 177 EXPECT_FALSE(browser_view()->AcceleratorPressed(new_tab_accel)); |
| 178 |
| 179 // A repeated Ctrl-Tab accelerator should be processed. |
| 180 ui::Accelerator next_tab_accel(ui::VKEY_TAB, ui::EF_CONTROL_DOWN); |
| 181 next_tab_accel.set_is_repeat(true); |
| 182 EXPECT_TRUE(browser_view()->AcceleratorPressed(next_tab_accel)); |
| 183 } |
| 184 |
166 class BrowserViewHostedAppTest : public TestWithBrowserView { | 185 class BrowserViewHostedAppTest : public TestWithBrowserView { |
167 public: | 186 public: |
168 BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {} | 187 BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {} |
169 ~BrowserViewHostedAppTest() override {} | 188 ~BrowserViewHostedAppTest() override {} |
170 | 189 |
171 private: | 190 private: |
172 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest); | 191 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest); |
173 }; | 192 }; |
174 | 193 |
175 // Test basic layout for hosted apps. | 194 // Test basic layout for hosted apps. |
(...skipping 22 matching lines...) Expand all Loading... |
198 header_offset.y(); | 217 header_offset.y(); |
199 | 218 |
200 // 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. |
201 EXPECT_EQ(bottom_of_header, contents_container->y()); | 220 EXPECT_EQ(bottom_of_header, contents_container->y()); |
202 | 221 |
203 // 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 |
204 // bottom of the header. | 223 // bottom of the header. |
205 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(), | 224 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(), |
206 browser_view()->frame()->GetTopInset(false)); | 225 browser_view()->frame()->GetTopInset(false)); |
207 } | 226 } |
OLD | NEW |