| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/find_bar/find_bar_controller.h" | 5 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // First we navigate to any page. | 37 // First we navigate to any page. |
| 38 ui_test_utils::NavigateToURL(browser(), GetURL(kSimple)); | 38 ui_test_utils::NavigateToURL(browser(), GetURL(kSimple)); |
| 39 | 39 |
| 40 gfx::NativeWindow window = browser()->window()->GetNativeWindow(); | 40 gfx::NativeWindow window = browser()->window()->GetNativeWindow(); |
| 41 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 41 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 42 views::FocusManager* focus_manager = widget->GetFocusManager(); | 42 views::FocusManager* focus_manager = widget->GetFocusManager(); |
| 43 | 43 |
| 44 // See where Escape is registered. | 44 // See where Escape is registered. |
| 45 ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE); | 45 ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE); |
| 46 ui::AcceleratorTarget* old_target = | 46 ui::AcceleratorTarget* old_target = |
| 47 focus_manager->GetCurrentTargetForAccelerator(escape); | 47 focus_manager->GetTargetForAccelerator(escape); |
| 48 EXPECT_TRUE(old_target != NULL); | 48 EXPECT_TRUE(old_target != NULL); |
| 49 | 49 |
| 50 chrome::ShowFindBar(browser()); | 50 chrome::ShowFindBar(browser()); |
| 51 | 51 |
| 52 // Our Find bar should be the new target. | 52 // Our Find bar should be the new target. |
| 53 ui::AcceleratorTarget* new_target = | 53 ui::AcceleratorTarget* new_target = |
| 54 focus_manager->GetCurrentTargetForAccelerator(escape); | 54 focus_manager->GetTargetForAccelerator(escape); |
| 55 | 55 |
| 56 EXPECT_TRUE(new_target != NULL); | 56 EXPECT_TRUE(new_target != NULL); |
| 57 EXPECT_NE(new_target, old_target); | 57 EXPECT_NE(new_target, old_target); |
| 58 | 58 |
| 59 // Close the Find box. | 59 // Close the Find box. |
| 60 browser()->GetFindBarController()->EndFindSession( | 60 browser()->GetFindBarController()->EndFindSession( |
| 61 FindBarController::kKeepSelectionOnPage, | 61 FindBarController::kKeepSelectionOnPage, |
| 62 FindBarController::kKeepResultsInFindBox); | 62 FindBarController::kKeepResultsInFindBox); |
| 63 | 63 |
| 64 // The accelerator for Escape should be back to what it was before. | 64 // The accelerator for Escape should be back to what it was before. |
| 65 EXPECT_EQ(old_target, | 65 EXPECT_EQ(old_target, focus_manager->GetTargetForAccelerator(escape)); |
| 66 focus_manager->GetCurrentTargetForAccelerator(escape)); | |
| 67 | 66 |
| 68 // Show find bar again with animation on, and the target should be on | 67 // Show find bar again with animation on, and the target should be on |
| 69 // find bar. | 68 // find bar. |
| 70 chrome::DisableFindBarAnimationsDuringTesting(false); | 69 chrome::DisableFindBarAnimationsDuringTesting(false); |
| 71 chrome::ShowFindBar(browser()); | 70 chrome::ShowFindBar(browser()); |
| 72 EXPECT_EQ(new_target, | 71 EXPECT_EQ(new_target, focus_manager->GetTargetForAccelerator(escape)); |
| 73 focus_manager->GetCurrentTargetForAccelerator(escape)); | |
| 74 } | 72 } |
| 75 | 73 |
| 76 } // namespace | 74 } // namespace |
| OLD | NEW |