Commit 947b1a56 authored by pkasting@chromium.org's avatar pkasting@chromium.org

Add back a test lost in r37819, because it had been at the bottom of an unrelated file.

BUG=none
TEST=Test passes
Review URL: http://codereview.chromium.org/3029038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54204 0039d316-1c4b-4281-b951-d872f2087c98
parent 901baddf
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "chrome/test/automation/window_proxy.h" #include "chrome/test/automation/window_proxy.h"
#include "chrome/test/ui/ui_test.h" #include "chrome/test/ui/ui_test.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "views/event.h"
// This functionality currently works on Windows and on Linux when // This functionality currently works on Windows and on Linux when
// toolkit_views is defined (i.e. for Chrome OS). It's not needed // toolkit_views is defined (i.e. for Chrome OS). It's not needed
...@@ -24,8 +25,8 @@ class KeyboardAccessTest : public UITest { ...@@ -24,8 +25,8 @@ class KeyboardAccessTest : public UITest {
} }
// Use the keyboard to select "New Tab" from the app menu. // Use the keyboard to select "New Tab" from the app menu.
// This test depends on the fact that there are two menus and that // This test depends on the fact that there is one menu and that
// New Tab is the first item in the app menu. If the menus change, // New Tab is the first item in the menu. If the menus change,
// this test will need to be changed to reflect that. // this test will need to be changed to reflect that.
// //
// If alternate_key_sequence is true, use "Alt" instead of "F10" to // If alternate_key_sequence is true, use "Alt" instead of "F10" to
...@@ -101,6 +102,39 @@ TEST_F(KeyboardAccessTest, TestAltMenuKeyboardAccess) { ...@@ -101,6 +102,39 @@ TEST_F(KeyboardAccessTest, TestAltMenuKeyboardAccess) {
TestMenuKeyboardAccess(true); TestMenuKeyboardAccess(true);
} }
TEST_F(KeyboardAccessTest, ReserveKeyboardAccelerators) {
const std::string kBadPage =
"<html><script>"
"document.onkeydown = function() {"
" event.preventDefault();"
" return false;"
"}"
"</script></html>";
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
ASSERT_TRUE(browser);
browser->AppendTab(GURL("data:text/html," + kBadPage));
int tab_count = 0;
ASSERT_TRUE(browser->GetTabCount(&tab_count));
ASSERT_EQ(tab_count, 2);
int active_tab = 0;
ASSERT_TRUE(browser->GetActiveTabIndex(&active_tab));
ASSERT_EQ(active_tab, 1);
scoped_refptr<WindowProxy> window(browser->GetWindow());
ASSERT_TRUE(window);
ASSERT_TRUE(window->SimulateOSKeyPress(
base::VKEY_TAB, views::Event::EF_CONTROL_DOWN));
ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, action_max_timeout_ms()));
#if !defined(OS_MACOSX) // see BrowserWindowCocoa::GetCommandId
ASSERT_TRUE(browser->ActivateTab(1));
ASSERT_TRUE(window->SimulateOSKeyPress(
base::VKEY_F4, views::Event::EF_CONTROL_DOWN));
ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms()));
#endif
}
} // namespace } // namespace
#endif // defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_VIEWS)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment