Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Unified Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 372173002: Revert of Swipe Gestures for Accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gesture-vlogs
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/chromeos/touch_exploration_controller_unittest.cc
diff --git a/ui/chromeos/touch_exploration_controller_unittest.cc b/ui/chromeos/touch_exploration_controller_unittest.cc
index 3d0fbb69a86ad8052e03d58260c7a46c4ef879e1..10da4b1f3a7f5a272d86d88d1a10daae2f1d1e22 100644
--- a/ui/chromeos/touch_exploration_controller_unittest.cc
+++ b/ui/chromeos/touch_exploration_controller_unittest.cc
@@ -13,7 +13,6 @@
#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
-#include "ui/events/gestures/gesture_provider_aura.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
@@ -21,7 +20,7 @@
namespace ui {
namespace {
-// Records all mouse, touch, gesture, and key events.
+// Records all mouse and touch events.
class EventCapturer : public ui::EventHandler {
public:
EventCapturer() {}
@@ -38,11 +37,6 @@
} else if (event->IsTouchEvent()) {
events_.push_back(
new ui::TouchEvent(static_cast<ui::TouchEvent&>(*event)));
- } else if (event->IsGestureEvent()) {
- events_.push_back(
- new ui::GestureEvent(static_cast<ui::GestureEvent&>(*event)));
- } else if (event->IsKeyEvent()) {
- events_.push_back(new ui::KeyEvent(static_cast<ui::KeyEvent&>(*event)));
} else {
return;
}
@@ -53,11 +47,12 @@
// exit early with a sensible error rather than letting the test time out.
ASSERT_LT(events_.size(), 100u);
}
-
- const ScopedVector<ui::Event>& captured_events() const { return events_; }
+ const ScopedVector<ui::LocatedEvent>& captured_events() const {
+ return events_;
+ }
private:
- ScopedVector<ui::Event> events_;
+ ScopedVector<ui::LocatedEvent> events_;
DISALLOW_COPY_AND_ASSIGN(EventCapturer);
};
@@ -66,10 +61,8 @@
class TouchExplorationTest : public aura::test::AuraTestBase {
public:
- TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) {
- // Tests fail if time is ever 0.
- simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
- }
+ TouchExplorationTest()
+ : simulated_clock_(new base::SimpleTestTickClock()) {}
virtual ~TouchExplorationTest() {}
virtual void SetUp() OVERRIDE {
@@ -95,39 +88,16 @@
protected:
aura::client::CursorClient* cursor_client() { return cursor_client_.get(); }
- const ScopedVector<ui::Event>& GetCapturedEvents() {
+ const ScopedVector<ui::LocatedEvent>& GetCapturedEvents() {
return event_capturer_.captured_events();
}
- std::vector<ui::LocatedEvent*> GetCapturedLocatedEvents() {
- const ScopedVector<ui::Event>& all_events = GetCapturedEvents();
- std::vector<ui::LocatedEvent*> located_events;
- for (size_t i = 0; i < all_events.size(); ++i) {
- if (all_events[i]->IsMouseEvent() ||
- all_events[i]->IsTouchEvent() ||
- all_events[i]->IsGestureEvent()) {
- located_events.push_back(static_cast<ui::LocatedEvent*>(all_events[i]));
- }
- }
- return located_events;
- }
-
- std::vector<ui::Event*> GetCapturedEventsOfType(int type) {
- const ScopedVector<ui::Event>& all_events = GetCapturedEvents();
- std::vector<ui::Event*> events;
+ std::vector<ui::LocatedEvent*> GetCapturedEventsOfType(int type) {
+ const ScopedVector<ui::LocatedEvent>& all_events = GetCapturedEvents();
+ std::vector<ui::LocatedEvent*> events;
for (size_t i = 0; i < all_events.size(); ++i) {
if (type == all_events[i]->type())
events.push_back(all_events[i]);
- }
- return events;
- }
-
- std::vector<ui::LocatedEvent*> GetCapturedLocatedEventsOfType(int type) {
- std::vector<ui::LocatedEvent*> located_events = GetCapturedLocatedEvents();
- std::vector<ui::LocatedEvent*> events;
- for (size_t i = 0; i < located_events.size(); ++i) {
- if (type == located_events[i]->type())
- events.push_back(located_events[i]);
}
return events;
}
@@ -182,11 +152,6 @@
bool IsInNoFingersDownState() {
return touch_exploration_controller_->IsInNoFingersDownStateForTesting();
- }
-
- bool IsInGestureInProgressState() {
- return touch_exploration_controller_
- ->IsInGestureInProgressStateForTesting();
}
base::TimeDelta Now() {
@@ -236,56 +201,15 @@
EXPECT_EQ(mouse_event1->flags(), mouse_event2->flags());
}
-// Executes a number of assertions to confirm that |e1| and |e2| are key events
-// and are equal to each other.
-void ConfirmEventsAreKeyAndEqual(ui::Event* e1, ui::Event* e2) {
- ASSERT_TRUE(e1->IsKeyEvent());
- ASSERT_TRUE(e2->IsKeyEvent());
- ui::KeyEvent* key_event1 = static_cast<ui::KeyEvent*>(e1);
- ui::KeyEvent* key_event2 = static_cast<ui::KeyEvent*>(e2);
- EXPECT_EQ(key_event1->type(), key_event2->type());
- EXPECT_EQ(key_event1->key_code(), key_event2->key_code());
- EXPECT_EQ(key_event1->code(), key_event2->code());
- EXPECT_EQ(key_event1->flags(), key_event2->flags());
-}
-
#define CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(e1, e2) \
ASSERT_NO_FATAL_FAILURE(ConfirmEventsAreTouchAndEqual(e1, e2))
#define CONFIRM_EVENTS_ARE_MOUSE_AND_EQUAL(e1, e2) \
ASSERT_NO_FATAL_FAILURE(ConfirmEventsAreMouseAndEqual(e1, e2))
-
-#define CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(e1, e2) \
- ASSERT_NO_FATAL_FAILURE(ConfirmEventsAreKeyAndEqual(e1, e2))
// TODO(mfomitchev): Need to investigate why we don't get mouse enter/exit
// events when running these tests as part of ui_unittests. We do get them when
// the tests are run as part of ash unit tests.
-
-// If a swipe has been successfully completed, then six key events will be
-// dispatched that correspond to shift+search+direction
-void AssertDirectionalNavigationEvents(const ScopedVector<ui::Event>& events,
- ui::KeyboardCode direction) {
- ASSERT_EQ(6U, events.size());
- ui::KeyEvent shift_pressed(
- ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN, false);
- ui::KeyEvent search_pressed(
- ui::ET_KEY_PRESSED, ui::VKEY_LWIN, ui::EF_SHIFT_DOWN, false);
- ui::KeyEvent direction_pressed(
- ui::ET_KEY_PRESSED, direction, ui::EF_SHIFT_DOWN, false);
- ui::KeyEvent direction_released(
- ui::ET_KEY_RELEASED, direction, ui::EF_SHIFT_DOWN, false);
- ui::KeyEvent search_released(
- ui::ET_KEY_RELEASED, VKEY_LWIN, ui::EF_SHIFT_DOWN, false);
- ui::KeyEvent shift_released(
- ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE, false);
- CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&shift_pressed, events[0]);
- CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&search_pressed, events[1]);
- CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&direction_pressed, events[2]);
- CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&direction_released, events[3]);
- CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&search_released, events[4]);
- CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&shift_released, events[5]);
-}
TEST_F(TouchExplorationTest, EntersTouchToMouseModeAfterPressAndDelay) {
SwitchTouchExplorationMode(true);
@@ -307,7 +231,6 @@
EXPECT_FALSE(IsInTouchToMouseMode());
generator_->MoveTouch(gfx::Point(11, 12 + half_slop));
EXPECT_FALSE(IsInTouchToMouseMode());
- AdvanceSimulatedTimePastTapDelay();
generator_->MoveTouch(gfx::Point(11 + slop + 1, 12));
EXPECT_TRUE(IsInTouchToMouseMode());
}
@@ -321,7 +244,7 @@
AdvanceSimulatedTimePastTapDelay();
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
EXPECT_EQ(location, events[0]->location());
@@ -351,7 +274,7 @@
AdvanceSimulatedTimePastTapDelay();
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(4U, events.size());
EXPECT_EQ(location_start, events[0]->location());
@@ -396,7 +319,7 @@
generator_->Dispatch(&touch_move);
EXPECT_TRUE(cursor_client()->IsCursorVisible());
EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled());
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(1u, captured_events.size());
CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch_move);
ClearCapturedEvents();
@@ -405,8 +328,7 @@
generator_->PressTouchId(2);
AdvanceSimulatedTimePastTapDelay();
EXPECT_TRUE(IsInTouchToMouseMode());
- captured_events = GetCapturedLocatedEvents();
- std::vector<ui::LocatedEvent*>::const_iterator it;
+ ScopedVector<ui::LocatedEvent>::const_iterator it;
for (it = captured_events.begin(); it != captured_events.end(); ++it) {
if ((*it)->type() == ui::ET_MOUSE_MOVED)
break;
@@ -420,7 +342,6 @@
1,
Now());
generator_->Dispatch(&touch_release);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(1u, captured_events.size());
CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch_release);
ClearCapturedEvents();
@@ -429,7 +350,7 @@
generator_->MoveTouchId(gfx::Point(13, 14), 2);
generator_->ReleaseTouchId(2);
AdvanceSimulatedTimePastTapDelay();
- captured_events = GetCapturedLocatedEvents();
+
ASSERT_EQ(2u, captured_events.size());
EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type());
EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type());
@@ -446,7 +367,7 @@
simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000));
generator_->PressTouchId(2);
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
@@ -479,7 +400,7 @@
AdvanceSimulatedTimePastTapDelay();
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(2U, events.size());
EXPECT_EQ(location0, events[0]->location());
EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
@@ -503,7 +424,7 @@
AdvanceSimulatedTimePastTapDelay();
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
EXPECT_EQ(tap_location, events[0]->location());
@@ -521,7 +442,7 @@
generator_->PressTouch();
generator_->ReleaseTouch();
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(2U, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
EXPECT_EQ(tap_location, captured_events[0]->location());
@@ -544,7 +465,7 @@
AdvanceSimulatedTimePastTapDelay();
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
EXPECT_EQ(tap_location, events[0]->location());
@@ -566,7 +487,7 @@
simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
generator_->ReleaseTouch();
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(2U, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
EXPECT_EQ(tap_location, captured_events[0]->location());
@@ -588,8 +509,6 @@
gfx::Point initial_location(11, 12);
generator_->set_current_location(initial_location);
generator_->PressTouch();
- AdvanceSimulatedTimePastTapDelay();
- ClearCapturedEvents();
// Move to another location for single tap
gfx::Point tap_location(22, 23);
@@ -604,7 +523,7 @@
generator_->PressTouch();
generator_->ReleaseTouch();
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(4U, captured_events.size());
EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type());
EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type());
@@ -630,7 +549,7 @@
generator_->PressTouch();
generator_->ReleaseTouch();
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(0U, captured_events.size());
}
@@ -645,7 +564,7 @@
// Tap and hold at one location, and get a mouse move event in touch explore.
EnterTouchExplorationModeAtLocation(initial_touch_location);
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
EXPECT_EQ(initial_touch_location, events[0]->location());
@@ -660,13 +579,12 @@
ui::TouchEvent split_tap_press(
ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
generator_->Dispatch(&split_tap_press);
- EXPECT_FALSE(IsInGestureInProgressState());
ui::TouchEvent split_tap_release(
ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
generator_->Dispatch(&split_tap_release);
EXPECT_FALSE(IsInNoFingersDownState());
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(2U, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
EXPECT_EQ(initial_touch_location, captured_events[0]->location());
@@ -688,7 +606,7 @@
EnterTouchExplorationModeAtLocation(initial_touch_location);
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
ClearCapturedEvents();
@@ -708,7 +626,7 @@
generator_->Dispatch(&split_tap_release);
EXPECT_TRUE(IsInNoFingersDownState());
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(2U, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
EXPECT_EQ(initial_touch_location, captured_events[0]->location());
@@ -728,7 +646,7 @@
// Tap and hold at one location, and get a mouse move event in touch explore.
EnterTouchExplorationModeAtLocation(initial_touch_location);
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
ClearCapturedEvents();
@@ -746,7 +664,7 @@
generator_->Dispatch(&split_tap_release);
EXPECT_FALSE(IsInNoFingersDownState());
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(2U, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
EXPECT_EQ(initial_touch_location, captured_events[0]->location());
@@ -772,7 +690,7 @@
// Tap and hold at one location, and get a mouse move event in touch explore.
EnterTouchExplorationModeAtLocation(initial_touch_location);
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
ClearCapturedEvents();
@@ -793,7 +711,7 @@
generator_->Dispatch(&split_tap_release);
EXPECT_TRUE(IsInTouchToMouseMode());
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(2U, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
EXPECT_EQ(initial_touch_location, captured_events[0]->location());
@@ -815,7 +733,7 @@
EnterTouchExplorationModeAtLocation(initial_touch_location);
std::vector<ui::LocatedEvent*> events =
- GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
+ GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
ASSERT_EQ(1U, events.size());
EXPECT_EQ(initial_touch_location, events[0]->location());
@@ -847,7 +765,7 @@
ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now());
generator_->Dispatch(&third_tap_release);
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(2U, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
EXPECT_EQ(initial_touch_location, captured_events[0]->location());
@@ -867,7 +785,7 @@
gfx::Point first_touch_location = gfx::Point(7, 7);
gfx::Point second_touch_location = gfx::Point(10, 11);
EnterTwoToOne(first_touch_location, second_touch_location);
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(captured_events.size(), 1u);
ClearCapturedEvents();
@@ -879,7 +797,6 @@
1,
Now());
generator_->Dispatch(&second_touch_move);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(1u, captured_events.size());
ClearCapturedEvents();
@@ -887,8 +804,7 @@
// finger is touching.
gfx::Point first_touch_move_location = gfx::Point(15, 16);
generator_->MoveTouchId(first_touch_move_location, 0);
- captured_events = GetCapturedLocatedEvents();
- EXPECT_EQ(0u, captured_events.size());
+ EXPECT_EQ(0u, GetCapturedEvents().size());
EXPECT_TRUE(cursor_client()->IsCursorVisible());
EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled());
@@ -898,7 +814,6 @@
ui::ET_TOUCH_RELEASED, second_touch_move_location, 1, Now());
generator_->Dispatch(&second_touch_release);
EXPECT_FALSE(IsInTouchToMouseMode());
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 1u);
ClearCapturedEvents();
@@ -910,7 +825,7 @@
ui::TouchEvent first_touch_release(
ui::ET_TOUCH_RELEASED, first_touch_move_location, 0, Now());
generator_->Dispatch(&first_touch_release);
- captured_events = GetCapturedLocatedEvents();
+
ASSERT_EQ(captured_events.size(), 0u);
EXPECT_TRUE(IsInNoFingersDownState());
}
@@ -921,7 +836,7 @@
gfx::Point first_touch_location = gfx::Point(11,12);
gfx::Point second_touch_location = gfx::Point(21, 22);
EnterTwoToOne(first_touch_location, second_touch_location);
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
ASSERT_EQ(captured_events.size(), 1u);
ClearCapturedEvents();
@@ -932,7 +847,6 @@
ui::TouchEvent first_touch_release(
ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now());
generator_->Dispatch(&first_touch_release);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 1u);
ClearCapturedEvents();
@@ -944,7 +858,7 @@
ui::TouchEvent second_touch_release(
ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
generator_->Dispatch(&second_touch_release);
- captured_events = GetCapturedLocatedEvents();
+
ASSERT_EQ(captured_events.size(), 0u);
EXPECT_TRUE(IsInNoFingersDownState());
}
@@ -952,19 +866,17 @@
// Placing three fingers should start passthrough, and all fingers should
// continue to be passed through until the last one is released.
TEST_F(TouchExplorationTest, Passthrough) {
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
gfx::Point first_touch_location = gfx::Point(11,12);
gfx::Point second_touch_location = gfx::Point(21, 22);
EnterTwoToOne(first_touch_location, second_touch_location);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 1u);
gfx::Point third_touch_location = gfx::Point(31, 32);
ui::TouchEvent third_touch_press(
ui::ET_TOUCH_PRESSED, third_touch_location, 2, Now());
generator_->Dispatch(&third_touch_press);
- captured_events = GetCapturedLocatedEvents();
// Now all fingers are registered as pressed.
ASSERT_EQ(captured_events.size(), 3u);
ClearCapturedEvents();
@@ -982,7 +894,6 @@
generator_->Dispatch(&first_touch_first_move);
generator_->Dispatch(&second_touch_first_move);
generator_->Dispatch(&third_touch_first_move);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 3u);
EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type());
EXPECT_EQ(first_touch_location, captured_events[0]->location());
@@ -997,7 +908,6 @@
ui::TouchEvent third_touch_release(
ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now());
generator_->Dispatch(&third_touch_release);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 1u);
ClearCapturedEvents();
first_touch_location = gfx::Point(15, 16);
@@ -1008,7 +918,6 @@
ui::ET_TOUCH_MOVED, second_touch_location, 1, Now());
generator_->Dispatch(&first_touch_second_move);
generator_->Dispatch(&second_touch_second_move);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 2u);
EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type());
EXPECT_EQ(first_touch_location, captured_events[0]->location());
@@ -1021,14 +930,12 @@
ui::TouchEvent second_touch_release(
ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
generator_->Dispatch(&second_touch_release);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 1u);
ClearCapturedEvents();
first_touch_location = gfx::Point(17, 18);
ui::TouchEvent first_touch_third_move(
ui::ET_TOUCH_MOVED, first_touch_location, 0, Now());
generator_->Dispatch(&first_touch_third_move);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 1u);
EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type());
EXPECT_EQ(first_touch_location, captured_events[0]->location());
@@ -1037,145 +944,8 @@
ui::TouchEvent first_touch_release(
ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now());
generator_->Dispatch(&first_touch_release);
- captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 1u);
EXPECT_TRUE(IsInNoFingersDownState());
}
-// Finger must have moved more than slop, faster than the minimum swipe
-// velocity, and before the tap timer fires in order to enter
-// GestureInProgress state. Otherwise, if the tap timer fires before the a
-// gesture is completed, enter touch exploration.
-TEST_F(TouchExplorationTest, EnterGestureInProgressState) {
- SwitchTouchExplorationMode(true);
- EXPECT_FALSE(IsInTouchToMouseMode());
- EXPECT_FALSE(IsInGestureInProgressState());
-
- float distance = gesture_detector_config_.touch_slop + 1;
- ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 1), 0, Now());
- gfx::Point second_location(distance / 2, 1);
- gfx::Point third_location(distance, 1);
-
- generator_->Dispatch(&first_press);
- simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
- // Since we are not out of the touch slop yet, we should not be in gesture in
- // progress.
- generator_->MoveTouch(second_location);
- EXPECT_FALSE(IsInTouchToMouseMode());
- EXPECT_FALSE(IsInGestureInProgressState());
- simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
-
- // Once we are out of slop, we should be in GestureInProgress.
- generator_->MoveTouch(third_location);
- EXPECT_TRUE(IsInGestureInProgressState());
- EXPECT_FALSE(IsInTouchToMouseMode());
- const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
- ASSERT_EQ(0U, captured_events.size());
-
- // Exit out of gesture mode once grace period is over and enter touch
- // exploration.
- AdvanceSimulatedTimePastTapDelay();
- ASSERT_EQ(1U, captured_events.size());
- EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type());
- EXPECT_TRUE(IsInTouchToMouseMode());
- EXPECT_FALSE(IsInGestureInProgressState());
-}
-
-// A swipe+direction gesture should trigger a Shift+Search+Direction
-// keyboard event.
-TEST_F(TouchExplorationTest, GestureSwipe) {
- SwitchTouchExplorationMode(true);
- std::vector<ui::KeyboardCode> directions;
- directions.push_back(ui::VKEY_RIGHT);
- directions.push_back(ui::VKEY_LEFT);
- directions.push_back(ui::VKEY_UP);
- directions.push_back(ui::VKEY_DOWN);
-
- for (std::vector<ui::KeyboardCode>::const_iterator it = directions.begin();
- it != directions.end();
- ++it) {
- int x = 30;
- int y = 31;
- ui::TouchEvent origin(ui::ET_TOUCH_PRESSED, gfx::Point(x, y), 0, Now());
- generator_->Dispatch(&origin);
-
- ui::KeyboardCode direction = *it;
- float distance = gesture_detector_config_.touch_slop + 1;
- scoped_ptr<gfx::Point> swipe;
- switch (direction) {
- case ui::VKEY_RIGHT:
- swipe.reset(new gfx::Point(x + distance, y));
- break;
- case ui::VKEY_LEFT:
- swipe.reset(new gfx::Point(x - distance, y));
- break;
- case ui::VKEY_UP:
- swipe.reset(new gfx::Point(x, y - distance));
- break;
- case ui::VKEY_DOWN:
- swipe.reset(new gfx::Point(x, y + distance));
- break;
- default:
- return;
- }
-
- // A swipe is made when a fling starts
- float delta_time =
- distance / gesture_detector_config_.maximum_fling_velocity;
- simulated_clock_->Advance(base::TimeDelta::FromSecondsD(delta_time));
- generator_->MoveTouch(*swipe);
- EXPECT_TRUE(IsInGestureInProgressState());
- EXPECT_FALSE(IsInTouchToMouseMode());
- const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
- ASSERT_EQ(0U, captured_events.size());
- generator_->ReleaseTouch();
-
- // The swipe registered and sent the appropriate key events.
- AssertDirectionalNavigationEvents(captured_events, direction);
- EXPECT_TRUE(IsInNoFingersDownState());
- EXPECT_FALSE(IsInTouchToMouseMode());
- EXPECT_FALSE(IsInGestureInProgressState());
- ClearCapturedEvents();
- }
-}
-
-// With the simple swipe gestures, if additional fingers are added, then the
-// state should change to passthrough.
-TEST_F(TouchExplorationTest, FromGestureToPassthrough) {
- SwitchTouchExplorationMode(true);
- EXPECT_FALSE(IsInTouchToMouseMode());
- EXPECT_FALSE(IsInGestureInProgressState());
-
- float distance = gesture_detector_config_.touch_slop + 1;
- ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 1), 0, Now());
- generator_->Dispatch(&first_press);
- simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
- gfx::Point second_location(distance, 1);
- generator_->MoveTouch(second_location);
- EXPECT_TRUE(IsInGestureInProgressState());
- EXPECT_FALSE(IsInTouchToMouseMode());
- const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
- ASSERT_EQ(0U, captured_events.size());
-
- // Generate a second press that should go through as is.
- ui::TouchEvent second_press(
- ui::ET_TOUCH_PRESSED, gfx::Point(20, 21), 1, Now());
- generator_->Dispatch(&second_press);
- EXPECT_FALSE(IsInGestureInProgressState());
- EXPECT_FALSE(IsInTouchToMouseMode());
- std::vector<ui::LocatedEvent*> captured_located_events =
- GetCapturedLocatedEvents();
- ASSERT_EQ(1U, captured_events.size());
- CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_located_events[0], &second_press);
- ClearCapturedEvents();
-
- // The rest of the events should occur in passthrough.
- generator_->ReleaseTouchId(0);
- ASSERT_EQ(1U, captured_events.size());
- EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type());
- ClearCapturedEvents();
- generator_->ReleaseTouchId(1);
- ASSERT_EQ(0U, captured_events.size());
-}
-
} // namespace ui
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698