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

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

Issue 10949005: Fix toolbar keyboard accessibility on Views (alternative impl). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test on linux_chromeos Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.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/views/toolbar_view.h"
6
7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/browser_command_controller.h"
11 #include "chrome/browser/ui/view_ids.h"
12 #include "chrome/browser/ui/views/frame/browser_view.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "ui/views/focus/focus_manager.h"
15 #include "ui/views/view.h"
16 #include "ui/views/widget/widget.h"
17
18 namespace {
19
20 class ToolbarViewTest : public InProcessBrowserTest {
21 public:
22 ToolbarViewTest() {}
23
24 private:
25 DISALLOW_COPY_AND_ASSIGN(ToolbarViewTest);
26 };
27
28 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, ToolbarCycleFocus) {
29 gfx::NativeWindow window = browser()->window()->GetNativeWindow();
30 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
31 views::FocusManager* focus_manager = widget->GetFocusManager();
32 CommandUpdater* updater = browser()->command_controller()->command_updater();
33
34 // Send focus to the toolbar as if the user pressed Alt+Shift+T.
35 updater->ExecuteCommand(IDC_FOCUS_TOOLBAR);
36
37 views::View* first_view = focus_manager->GetFocusedView();
38 std::vector<int> ids;
39
40 // Press Tab to cycle through all of the controls in the toolbar until
41 // we end up back where we started.
42 bool found_reload = false;
43 bool found_location_bar = false;
44 bool found_app_menu = false;
45 const views::View* view = NULL;
46 while (view != first_view) {
47 focus_manager->AdvanceFocus(false);
48 view = focus_manager->GetFocusedView();
49 ids.push_back(view->id());
50 if (view->id() == VIEW_ID_RELOAD_BUTTON)
51 found_reload = true;
52 if (view->id() == VIEW_ID_APP_MENU)
53 found_app_menu = true;
54 if (view->id() == VIEW_ID_LOCATION_BAR || view->id() == VIEW_ID_OMNIBOX)
55 found_location_bar = true;
56 if (ids.size() > 100)
57 GTEST_FAIL() << "Tabbed 100 times, still haven't cycled back!";
58 }
59
60 // Make sure we found a few key items.
61 ASSERT_TRUE(found_reload);
62 ASSERT_TRUE(found_app_menu);
63 ASSERT_TRUE(found_location_bar);
64
65 // Now press Shift-Tab to cycle backwards.
66 std::vector<int> reverse_ids;
67 view = NULL;
68 while (view != first_view) {
69 focus_manager->AdvanceFocus(true);
70 view = focus_manager->GetFocusedView();
71 reverse_ids.push_back(view->id());
72 if (reverse_ids.size() > 100)
73 GTEST_FAIL() << "Tabbed 100 times, still haven't cycled back!";
74 }
75
76 // Assert that the views were focused in exactly the reverse order.
77 // The sequences should be the same length, and the last element will
78 // be the same, and the others are reverse.
79 ASSERT_EQ(ids.size(), reverse_ids.size());
80 size_t count = ids.size();
81 for (size_t i = 0; i < count - 1; i++)
82 EXPECT_EQ(ids[i], reverse_ids[count - 2 - i]);
83 }
84
85 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698