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

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

Issue 10962048: Fix toolbar keyboard accessibility if bookmarks bar is shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile errors 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') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/toolbar_view.h" 5 #include "chrome/browser/ui/views/toolbar_view.h"
6 6
7 #include "base/utf_string_conversions.h"
7 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
11 #include "chrome/browser/bookmarks/bookmark_utils.h"
8 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/browser_command_controller.h" 14 #include "chrome/browser/ui/browser_command_controller.h"
11 #include "chrome/browser/ui/view_ids.h" 15 #include "chrome/browser/ui/view_ids.h"
12 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
13 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
14 #include "ui/views/focus/focus_manager.h" 18 #include "ui/views/focus/focus_manager.h"
15 #include "ui/views/view.h" 19 #include "ui/views/view.h"
16 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
17 21
18 namespace { 22 namespace {
19 23
20 class ToolbarViewTest : public InProcessBrowserTest { 24 class ToolbarViewTest : public InProcessBrowserTest {
21 public: 25 public:
22 ToolbarViewTest() {} 26 ToolbarViewTest() {}
23 27
28 void RunToolbarCycleFocusTest();
29
24 private: 30 private:
25 DISALLOW_COPY_AND_ASSIGN(ToolbarViewTest); 31 DISALLOW_COPY_AND_ASSIGN(ToolbarViewTest);
26 }; 32 };
27 33
28 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, ToolbarCycleFocus) { 34 void ToolbarViewTest::RunToolbarCycleFocusTest() {
29 gfx::NativeWindow window = browser()->window()->GetNativeWindow(); 35 gfx::NativeWindow window = browser()->window()->GetNativeWindow();
30 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); 36 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
31 views::FocusManager* focus_manager = widget->GetFocusManager(); 37 views::FocusManager* focus_manager = widget->GetFocusManager();
32 CommandUpdater* updater = browser()->command_controller()->command_updater(); 38 CommandUpdater* updater = browser()->command_controller()->command_updater();
33 39
34 // Send focus to the toolbar as if the user pressed Alt+Shift+T. 40 // Send focus to the toolbar as if the user pressed Alt+Shift+T.
35 updater->ExecuteCommand(IDC_FOCUS_TOOLBAR); 41 updater->ExecuteCommand(IDC_FOCUS_TOOLBAR);
36 42
37 views::View* first_view = focus_manager->GetFocusedView(); 43 views::View* first_view = focus_manager->GetFocusedView();
38 std::vector<int> ids; 44 std::vector<int> ids;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 81
76 // Assert that the views were focused in exactly the reverse order. 82 // Assert that the views were focused in exactly the reverse order.
77 // The sequences should be the same length, and the last element will 83 // The sequences should be the same length, and the last element will
78 // be the same, and the others are reverse. 84 // be the same, and the others are reverse.
79 ASSERT_EQ(ids.size(), reverse_ids.size()); 85 ASSERT_EQ(ids.size(), reverse_ids.size());
80 size_t count = ids.size(); 86 size_t count = ids.size();
81 for (size_t i = 0; i < count - 1; i++) 87 for (size_t i = 0; i < count - 1; i++)
82 EXPECT_EQ(ids[i], reverse_ids[count - 2 - i]); 88 EXPECT_EQ(ids[i], reverse_ids[count - 2 - i]);
83 } 89 }
84 90
91 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, ToolbarCycleFocus) {
92 RunToolbarCycleFocusTest();
93 }
94
95 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, PRE_ToolbarCycleFocusWithBookmarkBar) {
sky 2012/09/24 14:05:32 Why does this need to be a separate test?
dmazzoni 2012/09/24 16:58:23 See "span a restart" in in_process_browser_test.h
96 // Specifically test for the case where the bookmark bar is open, with
97 // a focusable bookmark button, when the browser window opens. This
98 // "PRE" method runs first to show the bar and add the bookmark, then
99 // the test below runs with the same profile.
100
101 CommandUpdater* updater = browser()->command_controller()->command_updater();
102 updater->ExecuteCommand(IDC_SHOW_BOOKMARK_BAR);
103
104 BookmarkModel* model =
105 BookmarkModelFactory::GetForProfile(browser()->profile());
106 bookmark_utils::AddIfNotBookmarked(
107 model, GURL("http://foo.com"), ASCIIToUTF16("Foo"));
108 }
109
110 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, ToolbarCycleFocusWithBookmarkBar) {
111 // See PRE_ToolbarCycleFocusWithBookmarkBar, above.
112 RunToolbarCycleFocusTest();
113 }
114
85 } // namespace 115 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698