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

Side by Side Diff: chrome/test/interactive_ui/keyboard_access_uitest.cc

Issue 6246001: Move app/key* to ui/base/keycodes/* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/keyboard_codes.h"
6 #include "chrome/test/automation/browser_proxy.h" 5 #include "chrome/test/automation/browser_proxy.h"
7 #include "chrome/test/automation/tab_proxy.h" 6 #include "chrome/test/automation/tab_proxy.h"
8 #include "chrome/test/automation/window_proxy.h" 7 #include "chrome/test/automation/window_proxy.h"
9 #include "chrome/test/ui/ui_test.h" 8 #include "chrome/test/ui/ui_test.h"
10 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "ui/base/keycodes/keyboard_codes.h"
11 #include "views/event.h" 11 #include "views/event.h"
12 12
13 // This functionality currently works on Windows and on Linux when 13 // This functionality currently works on Windows and on Linux when
14 // toolkit_views is defined (i.e. for Chrome OS). It's not needed 14 // toolkit_views is defined (i.e. for Chrome OS). It's not needed
15 // on the Mac, and it's not yet implemented on Linux. 15 // on the Mac, and it's not yet implemented on Linux.
16 #if defined(TOOLKIT_VIEWS) 16 #if defined(TOOLKIT_VIEWS)
17 17
18 namespace { 18 namespace {
19 19
20 class KeyboardAccessTest : public UITest { 20 class KeyboardAccessTest : public UITest {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // The initial tab index should be 0. 53 // The initial tab index should be 0.
54 int tab_index = -1; 54 int tab_index = -1;
55 ASSERT_TRUE(browser->GetActiveTabIndex(&tab_index)); 55 ASSERT_TRUE(browser->GetActiveTabIndex(&tab_index));
56 ASSERT_EQ(0, tab_index); 56 ASSERT_EQ(0, tab_index);
57 57
58 // Get the focused view ID, then press a key to activate the 58 // Get the focused view ID, then press a key to activate the
59 // page menu, then wait until the focused view changes. 59 // page menu, then wait until the focused view changes.
60 int original_view_id = -1; 60 int original_view_id = -1;
61 ASSERT_TRUE(window->GetFocusedViewID(&original_view_id)); 61 ASSERT_TRUE(window->GetFocusedViewID(&original_view_id));
62 62
63 app::KeyboardCode menu_key = 63 ui::KeyboardCode menu_key =
64 alternate_key_sequence ? app::VKEY_MENU : app::VKEY_F10; 64 alternate_key_sequence ? ui::VKEY_MENU : ui::VKEY_F10;
65 #if defined(OS_CHROMEOS) 65 #if defined(OS_CHROMEOS)
66 // Chrome OS has different function key accelerators, so we always use the 66 // Chrome OS has different function key accelerators, so we always use the
67 // menu key there. 67 // menu key there.
68 menu_key = app::VKEY_MENU; 68 menu_key = ui::VKEY_MENU;
69 #endif 69 #endif
70 ASSERT_TRUE(window->SimulateOSKeyPress(menu_key, modifiers)); 70 ASSERT_TRUE(window->SimulateOSKeyPress(menu_key, modifiers));
71 71
72 if (modifiers) { 72 if (modifiers) {
73 // Verify Chrome does not move the view focus. We should not move the view 73 // Verify Chrome does not move the view focus. We should not move the view
74 // focus when typing a menu key with modifier keys, such as shift keys or 74 // focus when typing a menu key with modifier keys, such as shift keys or
75 // control keys. 75 // control keys.
76 int new_view_id = -1; 76 int new_view_id = -1;
77 ASSERT_TRUE(window->GetFocusedViewID(&new_view_id)); 77 ASSERT_TRUE(window->GetFocusedViewID(&new_view_id));
78 ASSERT_EQ(original_view_id, new_view_id); 78 ASSERT_EQ(original_view_id, new_view_id);
79 return; 79 return;
80 } 80 }
81 81
82 int new_view_id = -1; 82 int new_view_id = -1;
83 ASSERT_TRUE(window->WaitForFocusedViewIDToChange( 83 ASSERT_TRUE(window->WaitForFocusedViewIDToChange(
84 original_view_id, &new_view_id)); 84 original_view_id, &new_view_id));
85 85
86 ASSERT_TRUE(browser->StartTrackingPopupMenus()); 86 ASSERT_TRUE(browser->StartTrackingPopupMenus());
87 87
88 if (alternate_key_sequence) 88 if (alternate_key_sequence)
89 ASSERT_TRUE(window->SimulateOSKeyPress(app::VKEY_DOWN, 0)); 89 ASSERT_TRUE(window->SimulateOSKeyPress(ui::VKEY_DOWN, 0));
90 else 90 else
91 ASSERT_TRUE(window->SimulateOSKeyPress(app::VKEY_RETURN, 0)); 91 ASSERT_TRUE(window->SimulateOSKeyPress(ui::VKEY_RETURN, 0));
92 92
93 // Wait until the popup menu actually opens. 93 // Wait until the popup menu actually opens.
94 ASSERT_TRUE(browser->WaitForPopupMenuToOpen()); 94 ASSERT_TRUE(browser->WaitForPopupMenuToOpen());
95 95
96 // Press DOWN to select the first item, then RETURN to select it. 96 // Press DOWN to select the first item, then RETURN to select it.
97 ASSERT_TRUE(window->SimulateOSKeyPress(app::VKEY_DOWN, 0)); 97 ASSERT_TRUE(window->SimulateOSKeyPress(ui::VKEY_DOWN, 0));
98 ASSERT_TRUE(window->SimulateOSKeyPress(app::VKEY_RETURN, 0)); 98 ASSERT_TRUE(window->SimulateOSKeyPress(ui::VKEY_RETURN, 0));
99 99
100 // Wait for the new tab to appear. 100 // Wait for the new tab to appear.
101 ASSERT_TRUE(browser->WaitForTabCountToBecome(2)); 101 ASSERT_TRUE(browser->WaitForTabCountToBecome(2));
102 102
103 // Make sure that the new tab index is 1. 103 // Make sure that the new tab index is 1.
104 ASSERT_TRUE(browser->GetActiveTabIndex(&tab_index)); 104 ASSERT_TRUE(browser->GetActiveTabIndex(&tab_index));
105 ASSERT_EQ(1, tab_index); 105 ASSERT_EQ(1, tab_index);
106 } 106 }
107 107
108 // Disabled, http://crbug.com/62310. 108 // Disabled, http://crbug.com/62310.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 ASSERT_TRUE(browser->GetTabCount(&tab_count)); 146 ASSERT_TRUE(browser->GetTabCount(&tab_count));
147 ASSERT_EQ(tab_count, 2); 147 ASSERT_EQ(tab_count, 2);
148 148
149 int active_tab = 0; 149 int active_tab = 0;
150 ASSERT_TRUE(browser->GetActiveTabIndex(&active_tab)); 150 ASSERT_TRUE(browser->GetActiveTabIndex(&active_tab));
151 ASSERT_EQ(active_tab, 1); 151 ASSERT_EQ(active_tab, 1);
152 152
153 scoped_refptr<WindowProxy> window(browser->GetWindow()); 153 scoped_refptr<WindowProxy> window(browser->GetWindow());
154 ASSERT_TRUE(window); 154 ASSERT_TRUE(window);
155 ASSERT_TRUE(window->SimulateOSKeyPress( 155 ASSERT_TRUE(window->SimulateOSKeyPress(
156 app::VKEY_TAB, views::Event::EF_CONTROL_DOWN)); 156 ui::VKEY_TAB, views::Event::EF_CONTROL_DOWN));
157 ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, action_max_timeout_ms())); 157 ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, action_max_timeout_ms()));
158 158
159 #if !defined(OS_MACOSX) // see BrowserWindowCocoa::GetCommandId 159 #if !defined(OS_MACOSX) // see BrowserWindowCocoa::GetCommandId
160 ASSERT_TRUE(browser->ActivateTab(1)); 160 ASSERT_TRUE(browser->ActivateTab(1));
161 ASSERT_TRUE(window->SimulateOSKeyPress( 161 ASSERT_TRUE(window->SimulateOSKeyPress(
162 app::VKEY_F4, views::Event::EF_CONTROL_DOWN)); 162 ui::VKEY_F4, views::Event::EF_CONTROL_DOWN));
163 ASSERT_TRUE(browser->WaitForTabCountToBecome(1)); 163 ASSERT_TRUE(browser->WaitForTabCountToBecome(1));
164 #endif 164 #endif
165 } 165 }
166 166
167 } // namespace 167 } // namespace
168 168
169 #endif // defined(TOOLKIT_VIEWS) 169 #endif // defined(TOOLKIT_VIEWS)
OLDNEW
« no previous file with comments | « chrome/test/automation/window_proxy.cc ('k') | chrome/test/interactive_ui/npapi_interactive_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698