Chromium Code Reviews| Index: chrome/browser/chromeos/accessibility/sticky_keys_browsertest.cc |
| diff --git a/chrome/browser/chromeos/accessibility/sticky_keys_browsertest.cc b/chrome/browser/chromeos/accessibility/sticky_keys_browsertest.cc |
| index 0d2a6b6d5adbe6a8a0c8e08a10085458c008a9c2..0f0ac5b2583be64febad2fafe94d2f9e6169e49c 100644 |
| --- a/chrome/browser/chromeos/accessibility/sticky_keys_browsertest.cc |
| +++ b/chrome/browser/chromeos/accessibility/sticky_keys_browsertest.cc |
| @@ -21,6 +21,7 @@ |
| #include "chrome/test/base/interactive_test_utils.h" |
| #include "ui/aura/window_event_dispatcher.h" |
| #include "ui/events/keycodes/keyboard_codes.h" |
| +#include "ui/events/test/event_generator.h" |
| #include "ui/gfx/native_widget_types.h" |
| namespace chromeos { |
| @@ -54,7 +55,16 @@ class StickyKeysBrowserTest : public InProcessBrowserTest { |
| false)); // command |
| } |
| + ui::test::EventGenerator& GetEventGenerator() { |
|
dmazzoni
2014/11/20 21:32:38
Please just move this to SetUp
afakhry
2014/11/21 02:15:03
Moved to SetUpOnMainThread() since SetUp() caused
afakhry
2014/11/21 02:15:03
Done.
|
| + if (!event_generator_) { |
| + event_generator_.reset( |
| + new ui::test::EventGenerator(browser()->window()->GetNativeWindow())); |
| + } |
| + return *event_generator_.get(); |
| + } |
| + |
| content::NotificationRegistrar registrar_; |
| + scoped_ptr<ui::test::EventGenerator> event_generator_; |
| DISALLOW_COPY_AND_ASSIGN(StickyKeysBrowserTest); |
| }; |
| @@ -153,10 +163,20 @@ IN_PROC_BROWSER_TEST_F(StickyKeysBrowserTest, SearchLeftOmnibox) { |
| // Give the omnibox focus. |
| omnibox->ShowURL(); |
| + ui::test::EventGenerator& generator = GetEventGenerator(); |
| + |
| + // Make sure that the AppList is not erronously displayed and the omnibox |
| + // doesn't lost focus |
| + EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| + EXPECT_TRUE(omnibox->GetNativeView()->HasFocus()); |
| + |
| // Type 'foo'. |
| - SendKeyPress(ui::VKEY_F); |
| - SendKeyPress(ui::VKEY_O); |
| - SendKeyPress(ui::VKEY_O); |
| + generator.PressKey(ui::VKEY_F, ui::EF_NONE); |
|
dmazzoni
2014/11/20 21:32:38
Just call generator_.PressKey, then there's no nee
|
| + generator.ReleaseKey(ui::VKEY_F, ui::EF_NONE); |
| + generator.PressKey(ui::VKEY_O, ui::EF_NONE); |
| + generator.ReleaseKey(ui::VKEY_O, ui::EF_NONE); |
| + generator.PressKey(ui::VKEY_O, ui::EF_NONE); |
| + generator.ReleaseKey(ui::VKEY_O, ui::EF_NONE); |
| // Verify the location of the caret. |
| size_t start, end; |
| @@ -164,9 +184,17 @@ IN_PROC_BROWSER_TEST_F(StickyKeysBrowserTest, SearchLeftOmnibox) { |
| ASSERT_EQ(3U, start); |
| ASSERT_EQ(3U, end); |
| + EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| + EXPECT_TRUE(omnibox->GetNativeView()->HasFocus()); |
| + |
| // Hit Home by sequencing Search (left Windows) and Left (arrow). |
| - SendKeyPress(ui::VKEY_LWIN); |
| - SendKeyPress(ui::VKEY_LEFT); |
| + generator.PressKey(ui::VKEY_LWIN, ui::EF_NONE); |
| + generator.ReleaseKey(ui::VKEY_LWIN, ui::EF_NONE); |
| + generator.PressKey(ui::VKEY_LEFT, ui::EF_NONE); |
| + generator.ReleaseKey(ui::VKEY_LEFT, ui::EF_NONE); |
| + |
| + EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| + EXPECT_TRUE(omnibox->GetNativeView()->HasFocus()); |
| // Verify caret moved to the beginning. |
| omnibox->GetSelectionBounds(&start, &end); |