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

Side by Side Diff: chrome/browser/ui/views/find_bar_controller_interactive_uitest.cc

Issue 1622433002: views: Remove unused GetCurrentTargetForAccelerator from FocusManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge Created 4 years, 8 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
« no previous file with comments | « ash/accelerators/focus_manager_factory.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
6
7 #include "base/files/file_path.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h"
14 #include "ui/base/accelerators/accelerator.h"
15 #include "ui/views/focus/focus_manager.h"
16 #include "ui/views/widget/widget.h"
17 #include "url/gurl.h"
18
19 namespace {
20
21 const char kSimple[] = "simple.html";
22
23 GURL GetURL(const std::string& filename) {
24 return ui_test_utils::GetTestUrl(base::FilePath().AppendASCII("find_in_page"),
25 base::FilePath().AppendASCII(filename));
26 }
27
28 class FindBarControllerTest : public InProcessBrowserTest {
29 public:
30 FindBarControllerTest() {
31 chrome::DisableFindBarAnimationsDuringTesting(true);
32 }
33 };
34
35 // Make sure Find box grabs the Esc accelerator and restores it again.
36 IN_PROC_BROWSER_TEST_F(FindBarControllerTest, AcceleratorRestoring) {
37 // First we navigate to any page.
38 ui_test_utils::NavigateToURL(browser(), GetURL(kSimple));
39
40 gfx::NativeWindow window = browser()->window()->GetNativeWindow();
41 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
42 views::FocusManager* focus_manager = widget->GetFocusManager();
43
44 // See where Escape is registered.
45 ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE);
46 ui::AcceleratorTarget* old_target =
47 focus_manager->GetCurrentTargetForAccelerator(escape);
48 EXPECT_TRUE(old_target != NULL);
49
50 chrome::ShowFindBar(browser());
51
52 // Our Find bar should be the new target.
53 ui::AcceleratorTarget* new_target =
54 focus_manager->GetCurrentTargetForAccelerator(escape);
55
56 EXPECT_TRUE(new_target != NULL);
57 EXPECT_NE(new_target, old_target);
58
59 // Close the Find box.
60 browser()->GetFindBarController()->EndFindSession(
61 FindBarController::kKeepSelectionOnPage,
62 FindBarController::kKeepResultsInFindBox);
63
64 // The accelerator for Escape should be back to what it was before.
65 EXPECT_EQ(old_target,
66 focus_manager->GetCurrentTargetForAccelerator(escape));
67
68 // Show find bar again with animation on, and the target should be on
69 // find bar.
70 chrome::DisableFindBarAnimationsDuringTesting(false);
71 chrome::ShowFindBar(browser());
72 EXPECT_EQ(new_target,
73 focus_manager->GetCurrentTargetForAccelerator(escape));
74 }
75
76 } // namespace
OLDNEW
« no previous file with comments | « ash/accelerators/focus_manager_factory.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698