| Index: ash/sticky_keys/sticky_keys_unittest.cc
|
| diff --git a/ash/sticky_keys/sticky_keys_unittest.cc b/ash/sticky_keys/sticky_keys_unittest.cc
|
| index 4593c86a04f6c4fd060efa78c43918b01d5321f0..8ae0a1d402f5da4b5334a72fae940d49a0c2c4b6 100644
|
| --- a/ash/sticky_keys/sticky_keys_unittest.cc
|
| +++ b/ash/sticky_keys/sticky_keys_unittest.cc
|
| @@ -245,38 +245,26 @@
|
| }
|
|
|
| // Creates a synthesized MouseEvent that is not backed by a native event.
|
| - ui::MouseEvent* GenerateSynthesizedMouseEventAt(ui::EventType event_type,
|
| - const gfx::Point& location) {
|
| - ui::MouseEvent* event = new ui::MouseEvent(event_type,
|
| - location,
|
| - location,
|
| - ui::EF_LEFT_MOUSE_BUTTON,
|
| - ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent* GenerateSynthesizedMouseEvent(bool is_button_press) {
|
| + ui::MouseEvent* event = new ui::MouseEvent(
|
| + is_button_press ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED,
|
| + gfx::Point(0, 0),
|
| + gfx::Point(0, 0),
|
| + ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::EF_LEFT_MOUSE_BUTTON);
|
| ui::Event::DispatcherApi dispatcher(event);
|
| dispatcher.set_target(target_);
|
| return event;
|
| }
|
|
|
| - // Creates a synthesized mouse press or release event.
|
| - ui::MouseEvent* GenerateSynthesizedMouseClickEvent(
|
| - bool is_button_press,
|
| - const gfx::Point& location) {
|
| - return GenerateSynthesizedMouseEventAt(
|
| - is_button_press ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED,
|
| - location);
|
| - }
|
| -
|
| // Creates a synthesized ET_MOUSE_MOVED event.
|
| - ui::MouseEvent* GenerateSynthesizedMouseMoveEvent(
|
| - const gfx::Point& location) {
|
| - return GenerateSynthesizedMouseEventAt(ui::ET_MOUSE_MOVED, location);
|
| - }
|
| -
|
| - // Creates a synthesized MouseWHeel event.
|
| - ui::MouseWheelEvent* GenerateSynthesizedMouseWheelEvent(int wheel_delta) {
|
| - scoped_ptr<ui::MouseEvent> mev(
|
| - GenerateSynthesizedMouseEventAt(ui::ET_MOUSEWHEEL, gfx::Point(0, 0)));
|
| - ui::MouseWheelEvent* event = new ui::MouseWheelEvent(*mev, 0, wheel_delta);
|
| + ui::MouseEvent* GenerateSynthesizedMouseEvent(int x, int y) {
|
| + ui::MouseEvent* event = new ui::MouseEvent(
|
| + ui::ET_MOUSE_MOVED,
|
| + gfx::Point(x, y),
|
| + gfx::Point(x, y),
|
| + ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::EF_LEFT_MOUSE_BUTTON);
|
| ui::Event::DispatcherApi dispatcher(event);
|
| dispatcher.set_target(target_);
|
| return event;
|
| @@ -503,9 +491,9 @@
|
| // Press ctrl and handle mouse move events.
|
| kev.reset(GenerateKey(true, ui::VKEY_CONTROL));
|
| sticky_key.HandleKeyEvent(kev.get());
|
| - mev.reset(GenerateSynthesizedMouseMoveEvent(gfx::Point(0, 0)));
|
| + mev.reset(GenerateSynthesizedMouseEvent(0, 0));
|
| sticky_key.HandleMouseEvent(mev.get());
|
| - mev.reset(GenerateSynthesizedMouseMoveEvent(gfx::Point(100, 100)));
|
| + mev.reset(GenerateSynthesizedMouseEvent(100, 100));
|
| sticky_key.HandleMouseEvent(mev.get());
|
|
|
| // Sticky keys should be enabled afterwards.
|
| @@ -801,12 +789,12 @@
|
| EXPECT_EQ(STICKY_KEY_STATE_ENABLED, sticky_key.current_state());
|
|
|
| scoped_ptr<ui::MouseEvent> mev;
|
| - mev.reset(GenerateSynthesizedMouseClickEvent(true, gfx::Point(0, 0)));
|
| + mev.reset(GenerateSynthesizedMouseEvent(true));
|
| sticky_key.HandleMouseEvent(mev.get());
|
| EXPECT_TRUE(mev->flags() & ui::EF_CONTROL_DOWN);
|
| EXPECT_EQ(STICKY_KEY_STATE_ENABLED, sticky_key.current_state());
|
|
|
| - mev.reset(GenerateSynthesizedMouseClickEvent(false, gfx::Point(0, 0)));
|
| + mev.reset(GenerateSynthesizedMouseEvent(false));
|
| sticky_key.HandleMouseEvent(mev.get());
|
| EXPECT_TRUE(mev->flags() & ui::EF_CONTROL_DOWN);
|
| EXPECT_EQ(STICKY_KEY_STATE_DISABLED, sticky_key.current_state());
|
| @@ -848,21 +836,6 @@
|
| EXPECT_EQ(ui::VKEY_C,
|
| static_cast<ui::KeyEvent*>(events[0])->key_code());
|
| EXPECT_FALSE(events[0]->flags() & ui::EF_CONTROL_DOWN);
|
| -
|
| - // Test that synthesized key events are dispatched correctly.
|
| - SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL);
|
| - buffer.PopEvents(&events);
|
| - scoped_ptr<ui::KeyEvent> kev;
|
| - kev.reset(GenerateSynthesizedKeyEvent(true, ui::VKEY_K));
|
| - dispatcher->OnEventFromSource(kev.get());
|
| - buffer.PopEvents(&events);
|
| - EXPECT_EQ(2u, events.size());
|
| - EXPECT_EQ(ui::ET_KEY_PRESSED, events[0]->type());
|
| - EXPECT_EQ(ui::VKEY_K, static_cast<ui::KeyEvent*>(events[0])->key_code());
|
| - EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN);
|
| - EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type());
|
| - EXPECT_EQ(ui::VKEY_CONTROL,
|
| - static_cast<ui::KeyEvent*>(events[1])->key_code());
|
|
|
| Shell::GetInstance()->RemovePreTargetHandler(&buffer);
|
| }
|
| @@ -917,21 +890,6 @@
|
| EXPECT_EQ(ui::VKEY_CONTROL,
|
| static_cast<ui::KeyEvent*>(events[1])->key_code());
|
|
|
| - // Test synthesized mouse events are dispatched correctly.
|
| - SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL);
|
| - buffer.PopEvents(&events);
|
| - ev.reset(GenerateSynthesizedMouseClickEvent(false, physical_location));
|
| - dispatcher->OnEventFromSource(ev.get());
|
| - buffer.PopEvents(&events);
|
| - EXPECT_EQ(2u, events.size());
|
| - EXPECT_EQ(ui::ET_MOUSE_RELEASED, events[0]->type());
|
| - EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN);
|
| - EXPECT_EQ(dip_location.ToString(),
|
| - static_cast<ui::MouseEvent*>(events[0])->location().ToString());
|
| - EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type());
|
| - EXPECT_EQ(ui::VKEY_CONTROL,
|
| - static_cast<ui::KeyEvent*>(events[1])->key_code());
|
| -
|
| Shell::GetInstance()->RemovePreTargetHandler(&buffer);
|
| }
|
|
|
| @@ -986,23 +944,6 @@
|
| EXPECT_EQ(ui::VKEY_CONTROL,
|
| static_cast<ui::KeyEvent*>(events[1])->key_code());
|
|
|
| - // Test synthesized mouse wheel events are dispatched correctly.
|
| - SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL);
|
| - buffer.PopEvents(&events);
|
| - ev.reset(
|
| - GenerateSynthesizedMouseWheelEvent(ui::MouseWheelEvent::kWheelDelta));
|
| - dispatcher->OnEventFromSource(ev.get());
|
| - buffer.PopEvents(&events);
|
| - EXPECT_EQ(2u, events.size());
|
| - EXPECT_TRUE(events[0]->IsMouseWheelEvent());
|
| - EXPECT_EQ(ui::MouseWheelEvent::kWheelDelta / scale_factor,
|
| - static_cast<ui::MouseWheelEvent*>(events[0])->y_offset());
|
| - EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN);
|
| - EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN);
|
| - EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type());
|
| - EXPECT_EQ(ui::VKEY_CONTROL,
|
| - static_cast<ui::KeyEvent*>(events[1])->key_code());
|
| -
|
| Shell::GetInstance()->RemovePreTargetHandler(&buffer);
|
| }
|
|
|
|
|