diff options
author | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-11 01:46:41 +0000 |
---|---|---|
committer | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-11 01:46:41 +0000 |
commit | e4292a236a7cfec76c4a4aa8c7d765a2d81b1920 (patch) | |
tree | 8e712428c8f80353d94763b0a542e452ba066116 /chrome/browser/browser_keyevents_browsertest.cc | |
parent | baa364ac46720022e435a3f8ec091509a10ec141 (diff) | |
download | chromium_src-e4292a236a7cfec76c4a4aa8c7d765a2d81b1920.zip chromium_src-e4292a236a7cfec76c4a4aa8c7d765a2d81b1920.tar.gz chromium_src-e4292a236a7cfec76c4a4aa8c7d765a2d81b1920.tar.bz2 |
Fix flaky BrowserKeyEventsTest.ReservedAccelerators on Windows (hopefully)
According to the log, the flakiness may be caused by http://crbug.com/65375. But I can't reproduce it manually on my local Windows 7 workstation. This CL just uses the same test flow as Mac port to try to avoid flakiness. The FLAKY label is not removed in case the test will still be flaky.
BUG=65847
TEST=The test should not flaky on Windows.
Review URL: http://codereview.chromium.org/5746002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_keyevents_browsertest.cc')
-rw-r--r-- | chrome/browser/browser_keyevents_browsertest.cc | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/chrome/browser/browser_keyevents_browsertest.cc b/chrome/browser/browser_keyevents_browsertest.cc index fd6c1af..e682058 100644 --- a/chrome/browser/browser_keyevents_browsertest.cc +++ b/chrome/browser/browser_keyevents_browsertest.cc @@ -649,47 +649,29 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, FLAKY_ReservedAccelerators) { ASSERT_EQ(1, browser()->tab_count()); +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) + static const KeyEventTestData kTestCtrlOrCmdT = { #if defined(OS_WIN) || defined(TOOLKIT_VIEWS) - static const KeyEventTestData kTestCtrlT = { app::VKEY_T, true, false, false, false, true, false, false, false, 1, { "D 17 0 true false false false" } - }; - - // Press Ctrl+T, which will open a new tab. It cannot be suppressed. - EXPECT_NO_FATAL_FAILURE(TestKeyEvent(0, kTestCtrlT)); - EXPECT_EQ(2, browser()->tab_count()); - browser()->SelectNumberedTab(0); - ASSERT_EQ(0, browser()->selected_index()); - - int result_length; - ASSERT_NO_FATAL_FAILURE(GetResultLength(0, &result_length)); - EXPECT_EQ(1, result_length); - - ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); - - // Reserved accelerators can't be suppressed. - ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(0, true)); - // Press Ctrl+W, which will close the tab. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - browser(), app::VKEY_W, true, false, false, false)); - EXPECT_EQ(1, browser()->tab_count()); -#elif defined(OS_MACOSX) - static const KeyEventTestData kTestCmdT = { +#else // OS_MACOSX app::VKEY_T, false, false, false, true, true, false, false, false, 1, { "D 91 0 false false false true" } +#endif }; ui_test_utils::WindowedNotificationObserver wait_for_new_tab( NotificationType::TAB_PARENTED, NotificationService::AllSources()); - // Press Cmd+T, which will open a new tab. It cannot be suppressed. - EXPECT_NO_FATAL_FAILURE(TestKeyEvent(0, kTestCmdT)); + // Press Ctrl/Cmd+T, which will open a new tab. It cannot be suppressed. + EXPECT_NO_FATAL_FAILURE(TestKeyEvent(0, kTestCtrlOrCmdT)); - wait_for_new_tab.WaitFor(Source<NavigationController>( - &browser()->GetTabContentsAt(1)->controller())); + ASSERT_NO_FATAL_FAILURE( + wait_for_new_tab.WaitFor(Source<NavigationController>( + &browser()->GetTabContentsAt(1)->controller()))); int result_length; ASSERT_NO_FATAL_FAILURE(GetResultLength(0, &result_length)); @@ -710,9 +692,21 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, FLAKY_ReservedAccelerators) { // Reserved accelerators can't be suppressed. ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(1, true)); - // Press Cmd+W, which will close the tab. + ui_test_utils::WindowedNotificationObserver wait_for_tab_closed( + NotificationType::TAB_CLOSED, Source<NavigationController>( + &browser()->GetTabContentsAt(1)->controller())); + + // Press Ctrl/Cmd+W, which will close the tab. +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) + ASSERT_TRUE(ui_test_utils::SendKeyPressSync( + browser(), app::VKEY_W, true, false, false, false)); +#else // OS_MACOSX ASSERT_TRUE(ui_test_utils::SendKeyPressSync( browser(), app::VKEY_W, false, false, false, true)); +#endif + + ASSERT_NO_FATAL_FAILURE(wait_for_tab_closed.Wait()); + EXPECT_EQ(1, browser()->tab_count()); #elif defined(TOOLKIT_GTK) // Ctrl-[a-z] are not treated as reserved accelerators on GTK. |