| 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/base/accelerators/accelerator.h" |
| 20 #include "ui/views/controls/webview/webview.h" | 20 #include "ui/views/controls/webview/webview.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 #if defined(OS_MACOSX) |
| 25 const ui::EventFlags kPlatformModifier = ui::EF_COMMAND_DOWN; |
| 26 #else |
| 27 const ui::EventFlags kPlatformModifier = ui::EF_CONTROL_DOWN; |
| 28 #endif // OS_MACOSX |
| 29 |
| 24 // Tab strip bounds depend on the window frame sizes. | 30 // Tab strip bounds depend on the window frame sizes. |
| 25 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { | 31 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { |
| 26 gfx::Rect tabstrip_bounds( | 32 gfx::Rect tabstrip_bounds( |
| 27 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip())); | 33 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip())); |
| 28 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 34 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); |
| 29 views::View::ConvertPointToTarget(browser_view->parent(), | 35 views::View::ConvertPointToTarget(browser_view->parent(), |
| 30 browser_view, | 36 browser_view, |
| 31 &tabstrip_origin); | 37 &tabstrip_origin); |
| 32 return tabstrip_origin; | 38 return tabstrip_origin; |
| 33 } | 39 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 browser_view()->GetIndexOf(top_container)); | 165 browser_view()->GetIndexOf(top_container)); |
| 160 | 166 |
| 161 BookmarkBarView::DisableAnimationsForTesting(false); | 167 BookmarkBarView::DisableAnimationsForTesting(false); |
| 162 } | 168 } |
| 163 | 169 |
| 164 // Test that repeated accelerators are processed or ignored depending on the | 170 // Test that repeated accelerators are processed or ignored depending on the |
| 165 // commands that they refer to. The behavior for different commands is dictated | 171 // commands that they refer to. The behavior for different commands is dictated |
| 166 // by IsCommandRepeatable() in chrome/browser/ui/views/accelerator_table.h. | 172 // by IsCommandRepeatable() in chrome/browser/ui/views/accelerator_table.h. |
| 167 TEST_F(BrowserViewTest, RepeatedAccelerators) { | 173 TEST_F(BrowserViewTest, RepeatedAccelerators) { |
| 168 // A non-repeated Ctrl-L accelerator should be processed. | 174 // A non-repeated Ctrl-L accelerator should be processed. |
| 169 const ui::Accelerator kLocationAccel(ui::VKEY_L, ui::EF_CONTROL_DOWN); | 175 const ui::Accelerator kLocationAccel(ui::VKEY_L, kPlatformModifier); |
| 170 EXPECT_TRUE(browser_view()->AcceleratorPressed(kLocationAccel)); | 176 EXPECT_TRUE(browser_view()->AcceleratorPressed(kLocationAccel)); |
| 171 | 177 |
| 172 // If the accelerator is repeated, it should be ignored. | 178 // If the accelerator is repeated, it should be ignored. |
| 173 const ui::Accelerator kLocationRepeatAccel( | 179 const ui::Accelerator kLocationRepeatAccel( |
| 174 ui::VKEY_L, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT); | 180 ui::VKEY_L, kPlatformModifier | ui::EF_IS_REPEAT); |
| 175 EXPECT_FALSE(browser_view()->AcceleratorPressed(kLocationRepeatAccel)); | 181 EXPECT_FALSE(browser_view()->AcceleratorPressed(kLocationRepeatAccel)); |
| 176 | 182 |
| 177 // A repeated Ctrl-Tab accelerator should be processed. | 183 // A repeated Ctrl-Tab accelerator should be processed. |
| 178 const ui::Accelerator kNextTabRepeatAccel( | 184 const ui::Accelerator kNextTabRepeatAccel( |
| 179 ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT); | 185 ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT); |
| 180 EXPECT_TRUE(browser_view()->AcceleratorPressed(kNextTabRepeatAccel)); | 186 EXPECT_TRUE(browser_view()->AcceleratorPressed(kNextTabRepeatAccel)); |
| 181 } | 187 } |
| 182 | 188 |
| 183 class BrowserViewHostedAppTest : public TestWithBrowserView { | 189 class BrowserViewHostedAppTest : public TestWithBrowserView { |
| 184 public: | 190 public: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 215 header_offset.y(); | 221 header_offset.y(); |
| 216 | 222 |
| 217 // The web contents should be flush with the bottom of the header. | 223 // The web contents should be flush with the bottom of the header. |
| 218 EXPECT_EQ(bottom_of_header, contents_container->y()); | 224 EXPECT_EQ(bottom_of_header, contents_container->y()); |
| 219 | 225 |
| 220 // The find bar should overlap the 1px header/web-contents separator at the | 226 // The find bar should overlap the 1px header/web-contents separator at the |
| 221 // bottom of the header. | 227 // bottom of the header. |
| 222 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(), | 228 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(), |
| 223 browser_view()->frame()->GetTopInset(false)); | 229 browser_view()->frame()->GetTopInset(false)); |
| 224 } | 230 } |
| OLD | NEW |