diff options
author | kpschoedel <kpschoedel@chromium.org> | 2015-08-12 08:42:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-12 15:42:43 +0000 |
commit | 27b64e16d428d6d16dae0fb50bc9e54fe411364c (patch) | |
tree | 273f5cc009b41d4df4a1b10f067ccf55a02ad46d /ash | |
parent | 536630f43e6c768babb27867cc1eb5396c8ec146 (diff) | |
download | chromium_src-27b64e16d428d6d16dae0fb50bc9e54fe411364c.zip chromium_src-27b64e16d428d6d16dae0fb50bc9e54fe411364c.tar.gz chromium_src-27b64e16d428d6d16dae0fb50bc9e54fe411364c.tar.bz2 |
Enable sticky key unit tests under Ozone.
Review URL: https://codereview.chromium.org/1272383005
Cr-Commit-Position: refs/heads/master@{#343023}
Diffstat (limited to 'ash')
-rw-r--r-- | ash/BUILD.gn | 4 | ||||
-rw-r--r-- | ash/ash.gyp | 5 | ||||
-rw-r--r-- | ash/sticky_keys/sticky_keys_unittest.cc | 63 |
3 files changed, 56 insertions, 16 deletions
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 4c8a695..2f53cce 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn @@ -371,8 +371,8 @@ test("ash_unittests") { #['OS=="linux" and component=="shared_library" and use_allocator!="none"', { # ldflags = "-rdynamic" - if (!is_chromeos || use_ozone) { - sources -= [ "sticky_keys/sticky_keys_unittest.cc" ] # crbug.com/354035 + if (!is_chromeos) { + sources -= [ "sticky_keys/sticky_keys_unittest.cc" ] } } diff --git a/ash/ash.gyp b/ash/ash.gyp index 8e20050..ca194f3 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -1227,11 +1227,6 @@ 'ldflags': ['-rdynamic'], }, }], - ['use_ozone==1', { - 'sources!': [ - 'sticky_keys/sticky_keys_unittest.cc', # crbug.com/354035 - ], - }], ], }, { diff --git a/ash/sticky_keys/sticky_keys_unittest.cc b/ash/sticky_keys/sticky_keys_unittest.cc index e00c9dc..87d3206 100644 --- a/ash/sticky_keys/sticky_keys_unittest.cc +++ b/ash/sticky_keys/sticky_keys_unittest.cc @@ -4,11 +4,6 @@ #include "ash/sticky_keys/sticky_keys_controller.h" -#include <X11/Xlib.h> -#undef None -#undef Bool -#undef RootWindow - #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "base/bind.h" @@ -18,14 +13,23 @@ #include "ui/aura/window_tree_host.h" #include "ui/events/event_source.h" #include "ui/events/event_utils.h" + +#if defined(USE_X11) +#include <X11/Xlib.h> +#undef None +#undef Bool +#undef RootWindow #include "ui/events/test/events_test_utils_x11.h" +#endif // USE_X11 namespace ash { namespace { +#if defined(USE_X11) // The device id of the test touchpad device. const unsigned int kTouchPadDeviceId = 1; +#endif } // namespace @@ -43,7 +47,9 @@ class StickyKeysTest : public test::AshTestBase { target_ = CreateTestWindowInShellWithId(0); root_window_ = target_->GetRootWindow(); +#if defined(USE_X11) ui::SetUpTouchPadForTest(kTouchPadDeviceId); +#endif } void TearDown() override { test::AshTestBase::TearDown(); } @@ -56,9 +62,12 @@ class StickyKeysTest : public test::AshTestBase { } ui::KeyEvent* GenerateKey(ui::EventType type, ui::KeyboardCode code) { +#if defined(USE_X11) scoped_xevent_.InitKeyEvent(type, code, 0); - ui::KeyEvent* event = new ui::KeyEvent(scoped_xevent_); - return event; + return new ui::KeyEvent(scoped_xevent_); +#else + return GenerateSynthesizedKeyEvent(type, code); +#endif } // Creates a mouse event backed by a native XInput2 generic button event. @@ -71,16 +80,20 @@ class StickyKeysTest : public test::AshTestBase { // The |location| should be in physical pixels. ui::MouseEvent* GenerateMouseEventAt(ui::EventType type, const gfx::Point& location) { +#if defined(USE_X11) scoped_xevent_.InitGenericButtonEvent( kTouchPadDeviceId, type, location, 0); - ui::MouseEvent* event = new ui::MouseEvent(scoped_xevent_); - return event; + return new ui::MouseEvent(scoped_xevent_); +#else + return GenerateSynthesizedMouseEventAt(type, location); +#endif } ui::MouseWheelEvent* GenerateMouseWheelEvent(int wheel_delta) { +#if defined(USE_X11) EXPECT_NE(0, wheel_delta); scoped_xevent_.InitGenericMouseWheelEvent( kTouchPadDeviceId, wheel_delta, 0); @@ -88,9 +101,13 @@ class StickyKeysTest : public test::AshTestBase { ui::Event::DispatcherApi dispatcher(event); dispatcher.set_target(target_); return event; +#else + return GenerateSynthesizedMouseWheelEvent(wheel_delta); +#endif } ui::ScrollEvent* GenerateScrollEvent(int scroll_delta) { +#if defined(USE_X11) scoped_xevent_.InitScrollEvent(kTouchPadDeviceId, // deviceid 0, // x_offset scroll_delta, // y_offset @@ -101,10 +118,23 @@ class StickyKeysTest : public test::AshTestBase { ui::Event::DispatcherApi dispatcher(event); dispatcher.set_target(target_); return event; +#else + ui::ScrollEvent* event = new ui::ScrollEvent( + ui::ET_SCROLL, gfx::Point(0, 0), ui::EventTimeForNow(), ui::EF_NONE, + 0, // x_offset + scroll_delta, // y_offset + 0, // x_offset_ordinal + scroll_delta, // y_offset_ordinal + 2); // finger_count + ui::Event::DispatcherApi dispatcher(event); + dispatcher.set_target(target_); + return event; +#endif } ui::ScrollEvent* GenerateFlingScrollEvent(int fling_delta, bool is_cancel) { +#if defined(USE_X11) scoped_xevent_.InitFlingScrollEvent( kTouchPadDeviceId, // deviceid 0, // x_velocity @@ -116,6 +146,19 @@ class StickyKeysTest : public test::AshTestBase { ui::Event::DispatcherApi dispatcher(event); dispatcher.set_target(target_); return event; +#else + ui::ScrollEvent* event = new ui::ScrollEvent( + is_cancel ? ui::ET_SCROLL_FLING_CANCEL : ui::ET_SCROLL_FLING_START, + gfx::Point(0, 0), ui::EventTimeForNow(), ui::EF_NONE, + 0, // x_velocity + fling_delta, // y_velocity + 0, // x_velocity_ordinal + fling_delta, // y_velocity_ordinal + 11); // finger_count + ui::Event::DispatcherApi dispatcher(event); + dispatcher.set_target(target_); + return event; +#endif } // Creates a synthesized KeyEvent that is not backed by a native event. @@ -192,8 +235,10 @@ class StickyKeysTest : public test::AshTestBase { // The root window of |target_|. Not owned. aura::Window* root_window_; +#if defined(USE_X11) // Used to construct the various X events. ui::ScopedXI2Event scoped_xevent_; +#endif DISALLOW_COPY_AND_ASSIGN(StickyKeysTest); }; |