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

Unified Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 466653002: Revert of Added multi-finger gestures to touch_exploration_controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passthrough
Patch Set: Created 6 years, 4 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 e8ffdc13bfcb397fe82860fcb052246cf71d3fcd..ffe4d090b8b3ce8779e8785a3c7ba77a58577ead 100644
--- a/ui/chromeos/touch_exploration_controller_unittest.cc
+++ b/ui/chromeos/touch_exploration_controller_unittest.cc
@@ -1108,7 +1108,6 @@
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);
- gfx::Point touch_exploration_location(20, 21);
generator_->Dispatch(&first_press);
simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
@@ -1127,13 +1126,10 @@
ASSERT_EQ(0U, captured_events.size());
// Exit out of gesture mode once grace period is over and enter touch
- // exploration. There should be a move when entering touch exploration and
- // also for the touch move.
- AdvanceSimulatedTimePastTapDelay();
- generator_->MoveTouch(touch_exploration_location);
- ASSERT_EQ(2U, captured_events.size());
+ // exploration.
+ AdvanceSimulatedTimePastTapDelay();
+ ASSERT_EQ(1U, captured_events.size());
EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type());
- EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type());
EXPECT_TRUE(IsInTouchToMouseMode());
EXPECT_FALSE(IsInGestureInProgressState());
}
@@ -1148,73 +1144,51 @@
directions.push_back(ui::VKEY_UP);
directions.push_back(ui::VKEY_DOWN);
- // This value was taken from gesture_recognizer_unittest.cc in a swipe
- // detector test, since it seems to be about the right amount to get a swipe.
- const int kSteps = 15;
-
- // There are gestures supported with up to four fingers.
- for (int num_fingers = 1; num_fingers <= 4; num_fingers++) {
- std::vector<gfx::Point> start_points;
- for(int j = 0; j < num_fingers; j++){
- start_points.push_back(gfx::Point(j * 10 + 100, j * 10 + 200));
+ 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;
}
- gfx::Point* start_points_array = &start_points[0];
- const float distance = gesture_detector_config_.touch_slop + 1;
- // Iterate through each swipe direction for this number of fingers.
- for (std::vector<ui::KeyboardCode>::const_iterator it = directions.begin();
- it != directions.end();
- ++it) {
- int move_x = 0;
- int move_y = 0;
- ui::KeyboardCode direction = *it;
- switch (direction) {
- case ui::VKEY_RIGHT:
- move_x = distance;
- break;
- case ui::VKEY_LEFT:
- move_x = 0 - distance;
- break;
- case ui::VKEY_UP:
- move_y = 0 - distance;
- break;
- case ui::VKEY_DOWN:
- move_y = distance;
- break;
- default:
- return;
- }
-
- // A swipe is made when a fling starts
- float delta_time =
- distance / gesture_detector_config_.maximum_fling_velocity;
- // delta_time is in seconds, so we convert to ms.
- int delta_time_ms = floor(delta_time * 1000);
- generator_->GestureMultiFingerScroll(num_fingers,
- start_points_array,
- delta_time_ms,
- kSteps,
- move_x * 2,
- move_y * 2);
-
- // The swipe registered and sent the appropriate key events.
- const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
- if (num_fingers == 1)
- AssertDirectionalNavigationEvents(captured_events, direction);
- else {
- // Most of the time this is 2 right now, but two of the two finger
- // swipes are mapped to chromevox commands which dispatch 6 key events,
- // and these will probably be remapped a lot as we're developing.
- ASSERT_GE(captured_events.size(), 2U);
- std::vector<ui::Event>::size_type i;
- for (i = 0; i != captured_events.size(); i++) {
- EXPECT_TRUE(captured_events[i]->IsKeyEvent());
- }
- }
- EXPECT_TRUE(IsInNoFingersDownState());
- EXPECT_FALSE(IsInTouchToMouseMode());
- EXPECT_FALSE(IsInGestureInProgressState());
- ClearCapturedEvents();
- }
+
+ // 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();
}
}
@@ -1335,9 +1309,8 @@
}
}
-// With the simple swipe gestures, if additional fingers are added and the tap
-// timer times out, then the state should change to the wait for one finger
-// state.
+// With the simple swipe gestures, if additional fingers are added, then the
+// state should change to the wait for one finger state.
TEST_F(TouchExplorationTest, GestureAddedFinger) {
SwitchTouchExplorationMode(true);
EXPECT_FALSE(IsInTouchToMouseMode());
@@ -1355,12 +1328,11 @@
const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
ASSERT_EQ(0U, captured_events.size());
- // Generate a second press, but time out past the gesture period so that
- // gestures are prevented from continuing to go through.
+ // Generate a second press that should prevent gestures from continuing to
+ // go through.
ui::TouchEvent second_press(
ui::ET_TOUCH_PRESSED, gfx::Point(20, 21), 1, Now());
generator_->Dispatch(&second_press);
- AdvanceSimulatedTimePastTapDelay();
EXPECT_FALSE(IsInGestureInProgressState());
EXPECT_FALSE(IsInTouchToMouseMode());
ASSERT_EQ(0U, captured_events.size());
@@ -1377,7 +1349,6 @@
ui::ET_TOUCH_PRESSED, gfx::Point(window_right, 1), 0, Now());
gfx::Point second_location(window_right, 1 + distance / 2);
gfx::Point third_location(window_right, 1 + distance);
- gfx::Point fourth_location(window_right, 35);
generator_->Dispatch(&first_press);
simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
@@ -1395,21 +1366,19 @@
EXPECT_FALSE(IsInGestureInProgressState());
EXPECT_TRUE(IsInSlideGestureState());
EXPECT_FALSE(IsInTouchToMouseMode());
-
- // Now that we are in slide gesture, we can adjust the volume.
- generator_->MoveTouch(fourth_location);
const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
ASSERT_EQ(0U, captured_events.size());
// Since we are at the right edge of the screen, but the sound timer has not
- // elapsed, there should have been a sound that fired and a volume
- // change.
+ // elapsed, there should have two sounds that fired and two volume
+ // changes (one for each movement).
size_t num_adjust_sounds = delegate_.NumAdjustSounds();
- ASSERT_EQ(1U, num_adjust_sounds);
- ASSERT_EQ(1U, delegate_.VolumeChanges().size());
+ ASSERT_EQ(2U, num_adjust_sounds);
+ ASSERT_EQ(2U, delegate_.VolumeChanges().size());
// Exit out of slide gesture once touch is lifted, but not before even if the
// grace period is over.
+
AdvanceSimulatedTimePastPotentialTapDelay();
ASSERT_EQ(0U, captured_events.size());
EXPECT_FALSE(IsInTouchToMouseMode());
@@ -1471,31 +1440,24 @@
gfx::Rect window = BoundsOfRootWindowInDIP();
gfx::Point initial_press(window.right() - GetMaxDistanceFromEdge() / 2, 1);
-
+ ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, initial_press, 0, Now());
+ gfx::Point touch_move(initial_press.x() + gesture_detector_config_.touch_slop,
+ 1);
+ gfx::Point into_slop_boundaries(
+ window.right() - GetSlopDistanceFromEdge() / 2, 1);
gfx::Point center_screen(window.right() / 2, window.bottom() / 2);
- ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, initial_press, 0, Now());
generator_->Dispatch(&first_press);
simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
+
+ generator_->MoveTouch(touch_move);
+ EXPECT_FALSE(IsInTouchToMouseMode());
EXPECT_FALSE(IsInGestureInProgressState());
EXPECT_FALSE(IsInSlideGestureState());
- EXPECT_FALSE(IsInTouchToMouseMode());
-
- // Move past the touch slop to begin slide gestures.
- // + slop + 1 to actually leave slop.
- gfx::Point touch_move(
- initial_press.x(),
- initial_press.y() + gesture_detector_config_.touch_slop + 1);
- generator_->MoveTouch(touch_move);
- EXPECT_FALSE(IsInGestureInProgressState());
- EXPECT_TRUE(IsInSlideGestureState());
- EXPECT_FALSE(IsInTouchToMouseMode());
simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
- // Move the touch into slop boundaries. It should still be in slide gestures
+ // Move the touch into slop boundaries. It should stil be in slide gestures
// and adjust the volume.
- gfx::Point into_slop_boundaries(
- window.right() - GetSlopDistanceFromEdge() / 2, 1);
generator_->MoveTouch(into_slop_boundaries);
EXPECT_FALSE(IsInGestureInProgressState());
EXPECT_TRUE(IsInSlideGestureState());
@@ -1505,8 +1467,8 @@
simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
size_t num_adjust_sounds = delegate_.NumAdjustSounds();
- ASSERT_EQ(1U, num_adjust_sounds);
- ASSERT_EQ(1U, delegate_.VolumeChanges().size());
+ ASSERT_EQ(2U, num_adjust_sounds);
+ ASSERT_EQ(2U, delegate_.VolumeChanges().size());
// Move the touch into the center of the window. It should still be in slide
// gestures, but there should not be anymore volume adjustments.
@@ -1517,11 +1479,11 @@
simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
num_adjust_sounds = delegate_.NumAdjustSounds();
- ASSERT_EQ(1U, num_adjust_sounds);
- ASSERT_EQ(1U, delegate_.VolumeChanges().size());
+ ASSERT_EQ(2U, num_adjust_sounds);
+ ASSERT_EQ(2U, delegate_.VolumeChanges().size());
// Move the touch back into slop edge distance and volume should be changing
- // again, one volume change for each new move.
+ // again.
generator_->MoveTouch(into_slop_boundaries);
EXPECT_FALSE(IsInGestureInProgressState());
EXPECT_TRUE(IsInSlideGestureState());
@@ -1533,7 +1495,7 @@
simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
num_adjust_sounds = delegate_.NumAdjustSounds();
- ASSERT_EQ(2U, num_adjust_sounds);
+ ASSERT_EQ(3U, num_adjust_sounds);
ASSERT_EQ(3U, delegate_.VolumeChanges().size());
const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
« 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