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

Side by Side Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 429633002: Added multi-finger gestures to touch_exploration_controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passthrough
Patch Set: check closures exist before running 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/chromeos/touch_exploration_controller.h" 5 #include "ui/chromeos/touch_exploration_controller.h"
6 6
7 #include "base/test/simple_test_tick_clock.h" 7 #include "base/test/simple_test_tick_clock.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
10 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 // gesture is completed, enter touch exploration. 1109 // gesture is completed, enter touch exploration.
1110 TEST_F(TouchExplorationTest, EnterGestureInProgressState) { 1110 TEST_F(TouchExplorationTest, EnterGestureInProgressState) {
1111 SwitchTouchExplorationMode(true); 1111 SwitchTouchExplorationMode(true);
1112 EXPECT_FALSE(IsInTouchToMouseMode()); 1112 EXPECT_FALSE(IsInTouchToMouseMode());
1113 EXPECT_FALSE(IsInGestureInProgressState()); 1113 EXPECT_FALSE(IsInGestureInProgressState());
1114 1114
1115 float distance = gesture_detector_config_.touch_slop + 1; 1115 float distance = gesture_detector_config_.touch_slop + 1;
1116 ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 1), 0, Now()); 1116 ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 1), 0, Now());
1117 gfx::Point second_location(distance / 2, 1); 1117 gfx::Point second_location(distance / 2, 1);
1118 gfx::Point third_location(distance, 1); 1118 gfx::Point third_location(distance, 1);
1119 gfx::Point touch_exploration_location(20, 21);
1119 1120
1120 generator_->Dispatch(&first_press); 1121 generator_->Dispatch(&first_press);
1121 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 1122 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1122 // Since we are not out of the touch slop yet, we should not be in gesture in 1123 // Since we are not out of the touch slop yet, we should not be in gesture in
1123 // progress. 1124 // progress.
1124 generator_->MoveTouch(second_location); 1125 generator_->MoveTouch(second_location);
1125 EXPECT_FALSE(IsInTouchToMouseMode()); 1126 EXPECT_FALSE(IsInTouchToMouseMode());
1126 EXPECT_FALSE(IsInGestureInProgressState()); 1127 EXPECT_FALSE(IsInGestureInProgressState());
1127 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 1128 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1128 1129
1129 // Once we are out of slop, we should be in GestureInProgress. 1130 // Once we are out of slop, we should be in GestureInProgress.
1130 generator_->MoveTouch(third_location); 1131 generator_->MoveTouch(third_location);
1131 EXPECT_TRUE(IsInGestureInProgressState()); 1132 EXPECT_TRUE(IsInGestureInProgressState());
1132 EXPECT_FALSE(IsInTouchToMouseMode()); 1133 EXPECT_FALSE(IsInTouchToMouseMode());
1133 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); 1134 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1134 ASSERT_EQ(0U, captured_events.size()); 1135 ASSERT_EQ(0U, captured_events.size());
1135 1136
1136 // Exit out of gesture mode once grace period is over and enter touch 1137 // Exit out of gesture mode once grace period is over and enter touch
1137 // exploration. 1138 // exploration. There should be a move when entering touch exploration and
1139 // also for the touch move.
1138 AdvanceSimulatedTimePastTapDelay(); 1140 AdvanceSimulatedTimePastTapDelay();
1139 ASSERT_EQ(1U, captured_events.size()); 1141 generator_->MoveTouch(touch_exploration_location);
1142 ASSERT_EQ(2U, captured_events.size());
1140 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type()); 1143 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type());
1144 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type());
1141 EXPECT_TRUE(IsInTouchToMouseMode()); 1145 EXPECT_TRUE(IsInTouchToMouseMode());
1142 EXPECT_FALSE(IsInGestureInProgressState()); 1146 EXPECT_FALSE(IsInGestureInProgressState());
1143 } 1147 }
1144 1148
1145 // A swipe+direction gesture should trigger a Shift+Search+Direction 1149 // A swipe+direction gesture should trigger a Shift+Search+Direction
1146 // keyboard event. 1150 // keyboard event.
1147 TEST_F(TouchExplorationTest, GestureSwipe) { 1151 TEST_F(TouchExplorationTest, GestureSwipe) {
1148 SwitchTouchExplorationMode(true); 1152 SwitchTouchExplorationMode(true);
1149 std::vector<ui::KeyboardCode> directions; 1153 std::vector<ui::KeyboardCode> directions;
1150 directions.push_back(ui::VKEY_RIGHT); 1154 directions.push_back(ui::VKEY_RIGHT);
1151 directions.push_back(ui::VKEY_LEFT); 1155 directions.push_back(ui::VKEY_LEFT);
1152 directions.push_back(ui::VKEY_UP); 1156 directions.push_back(ui::VKEY_UP);
1153 directions.push_back(ui::VKEY_DOWN); 1157 directions.push_back(ui::VKEY_DOWN);
1154 1158
1155 for (std::vector<ui::KeyboardCode>::const_iterator it = directions.begin(); 1159 // This value was taken from gesture_recognizer_unittest.cc in a swipe
1156 it != directions.end(); 1160 // detector test, since it seems to be about the right amount to get a swipe.
1157 ++it) { 1161 const int kSteps = 15;
1158 int x = 30;
1159 int y = 31;
1160 ui::TouchEvent origin(ui::ET_TOUCH_PRESSED, gfx::Point(x, y), 0, Now());
1161 generator_->Dispatch(&origin);
1162 1162
1163 ui::KeyboardCode direction = *it; 1163 // There are gestures supported with up to four fingers.
1164 float distance = gesture_detector_config_.touch_slop + 1; 1164 for (int num_fingers = 1; num_fingers <= 4; num_fingers++) {
1165 scoped_ptr<gfx::Point> swipe; 1165 std::vector<gfx::Point> start_points;
1166 switch (direction) { 1166 for(int j = 0; j < num_fingers; j++){
1167 case ui::VKEY_RIGHT: 1167 start_points.push_back(gfx::Point(j * 10 + 100, j * 10 + 200));
1168 swipe.reset(new gfx::Point(x + distance, y));
1169 break;
1170 case ui::VKEY_LEFT:
1171 swipe.reset(new gfx::Point(x - distance, y));
1172 break;
1173 case ui::VKEY_UP:
1174 swipe.reset(new gfx::Point(x, y - distance));
1175 break;
1176 case ui::VKEY_DOWN:
1177 swipe.reset(new gfx::Point(x, y + distance));
1178 break;
1179 default:
1180 return;
1181 } 1168 }
1169 gfx::Point* start_points_array = &start_points[0];
1170 const float distance = gesture_detector_config_.touch_slop + 1;
1171 // Iterate through each swipe direction for this number of fingers.
1172 for (std::vector<ui::KeyboardCode>::const_iterator it = directions.begin();
1173 it != directions.end();
1174 ++it) {
1175 int move_x = 0;
1176 int move_y = 0;
1177 ui::KeyboardCode direction = *it;
1178 switch (direction) {
1179 case ui::VKEY_RIGHT:
1180 move_x = distance;
1181 break;
1182 case ui::VKEY_LEFT:
1183 move_x = 0 - distance;
1184 break;
1185 case ui::VKEY_UP:
1186 move_y = 0 - distance;
1187 break;
1188 case ui::VKEY_DOWN:
1189 move_y = distance;
1190 break;
1191 default:
1192 return;
1193 }
1182 1194
1183 // A swipe is made when a fling starts 1195 // A swipe is made when a fling starts
1184 float delta_time = 1196 float delta_time =
1185 distance / gesture_detector_config_.maximum_fling_velocity; 1197 distance / gesture_detector_config_.maximum_fling_velocity;
1186 simulated_clock_->Advance(base::TimeDelta::FromSecondsD(delta_time)); 1198 // delta_time is in seconds, so we convert to ms.
1187 generator_->MoveTouch(*swipe); 1199 int delta_time_ms = floor(delta_time * 1000);
1188 EXPECT_TRUE(IsInGestureInProgressState()); 1200 generator_->GestureMultiFingerScroll(num_fingers,
1189 EXPECT_FALSE(IsInTouchToMouseMode()); 1201 start_points_array,
1190 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); 1202 delta_time_ms,
1191 ASSERT_EQ(0U, captured_events.size()); 1203 kSteps,
1192 generator_->ReleaseTouch(); 1204 move_x * 2,
1205 move_y * 2);
1193 1206
1194 // The swipe registered and sent the appropriate key events. 1207 // The swipe registered and sent the appropriate key events.
1195 AssertDirectionalNavigationEvents(captured_events, direction); 1208 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1196 EXPECT_TRUE(IsInNoFingersDownState()); 1209 if (num_fingers == 1)
1197 EXPECT_FALSE(IsInTouchToMouseMode()); 1210 AssertDirectionalNavigationEvents(captured_events, direction);
1198 EXPECT_FALSE(IsInGestureInProgressState()); 1211 else {
1199 ClearCapturedEvents(); 1212 // Most of the time this is 2 right now, but two of the two finger
1213 // swipes are mapped to chromevox commands which dispatch 6 key events,
1214 // and these will probably be remapped a lot as we're developing.
1215 ASSERT_GE(captured_events.size(), 2U);
1216 std::vector<ui::Event>::size_type i;
1217 for (i = 0; i != captured_events.size(); i++) {
1218 EXPECT_TRUE(captured_events[i]->IsKeyEvent());
1219 }
1220 }
1221 EXPECT_TRUE(IsInNoFingersDownState());
1222 EXPECT_FALSE(IsInTouchToMouseMode());
1223 EXPECT_FALSE(IsInGestureInProgressState());
1224 ClearCapturedEvents();
1225 }
1200 } 1226 }
1201 } 1227 }
1202 1228
1203 // Since there are so many permutations, this test is too slow in debug 1229 // Since there are so many permutations, this test is too slow in debug
1204 // mode, so it will only be run in release mode. 1230 // mode, so it will only be run in release mode.
1205 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) 1231 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
1206 #define MAYBE_AllFingerPermutations AllFingerPermutations 1232 #define MAYBE_AllFingerPermutations AllFingerPermutations
1207 #else 1233 #else
1208 #define MAYBE_AllFingerPermutations DISABLED_AllFingerPermutations 1234 #define MAYBE_AllFingerPermutations DISABLED_AllFingerPermutations
1209 #endif 1235 #endif
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 generator_->ReleaseTouchId(j); 1336 generator_->ReleaseTouchId(j);
1311 fingers_pressed[j] = false; 1337 fingers_pressed[j] = false;
1312 } 1338 }
1313 } 1339 }
1314 AdvanceSimulatedTimePastPotentialTapDelay(); 1340 AdvanceSimulatedTimePastPotentialTapDelay();
1315 EXPECT_TRUE(IsInNoFingersDownState()); 1341 EXPECT_TRUE(IsInNoFingersDownState());
1316 ClearCapturedEvents(); 1342 ClearCapturedEvents();
1317 } 1343 }
1318 } 1344 }
1319 1345
1320 // With the simple swipe gestures, if additional fingers are added, then the 1346 // With the simple swipe gestures, if additional fingers are added and the tap
1321 // state should change to the wait for one finger state. 1347 // timer times out, then the state should change to the wait for one finger
1348 // state.
1322 TEST_F(TouchExplorationTest, GestureAddedFinger) { 1349 TEST_F(TouchExplorationTest, GestureAddedFinger) {
1323 SwitchTouchExplorationMode(true); 1350 SwitchTouchExplorationMode(true);
1324 EXPECT_FALSE(IsInTouchToMouseMode()); 1351 EXPECT_FALSE(IsInTouchToMouseMode());
1325 EXPECT_FALSE(IsInGestureInProgressState()); 1352 EXPECT_FALSE(IsInGestureInProgressState());
1326 1353
1327 float distance = gesture_detector_config_.touch_slop + 1; 1354 float distance = gesture_detector_config_.touch_slop + 1;
1328 ui::TouchEvent first_press( 1355 ui::TouchEvent first_press(
1329 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 0, Now()); 1356 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 0, Now());
1330 generator_->Dispatch(&first_press); 1357 generator_->Dispatch(&first_press);
1331 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 1358 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1332 gfx::Point second_location(100 + distance, 200); 1359 gfx::Point second_location(100 + distance, 200);
1333 generator_->MoveTouch(second_location); 1360 generator_->MoveTouch(second_location);
1334 EXPECT_TRUE(IsInGestureInProgressState()); 1361 EXPECT_TRUE(IsInGestureInProgressState());
1335 EXPECT_FALSE(IsInTouchToMouseMode()); 1362 EXPECT_FALSE(IsInTouchToMouseMode());
1336 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); 1363 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1337 ASSERT_EQ(0U, captured_events.size()); 1364 ASSERT_EQ(0U, captured_events.size());
1338 1365
1339 // Generate a second press that should prevent gestures from continuing to 1366 // Generate a second press, but time out past the gesture period so that
1340 // go through. 1367 // gestures are prevented from continuing to go through.
1341 ui::TouchEvent second_press( 1368 ui::TouchEvent second_press(
1342 ui::ET_TOUCH_PRESSED, gfx::Point(20, 21), 1, Now()); 1369 ui::ET_TOUCH_PRESSED, gfx::Point(20, 21), 1, Now());
1343 generator_->Dispatch(&second_press); 1370 generator_->Dispatch(&second_press);
1371 AdvanceSimulatedTimePastTapDelay();
1344 EXPECT_FALSE(IsInGestureInProgressState()); 1372 EXPECT_FALSE(IsInGestureInProgressState());
1345 EXPECT_FALSE(IsInTouchToMouseMode()); 1373 EXPECT_FALSE(IsInTouchToMouseMode());
1346 ASSERT_EQ(0U, captured_events.size()); 1374 ASSERT_EQ(0U, captured_events.size());
1347 } 1375 }
1348 1376
1349 TEST_F(TouchExplorationTest, EnterSlideGestureState) { 1377 TEST_F(TouchExplorationTest, EnterSlideGestureState) {
1350 SwitchTouchExplorationMode(true); 1378 SwitchTouchExplorationMode(true);
1351 EXPECT_FALSE(IsInTouchToMouseMode()); 1379 EXPECT_FALSE(IsInTouchToMouseMode());
1352 EXPECT_FALSE(IsInGestureInProgressState()); 1380 EXPECT_FALSE(IsInGestureInProgressState());
1353 1381
1354 int window_right = BoundsOfRootWindowInDIP().right(); 1382 int window_right = BoundsOfRootWindowInDIP().right();
1355 float distance = gesture_detector_config_.touch_slop + 1; 1383 float distance = gesture_detector_config_.touch_slop + 1;
1356 ui::TouchEvent first_press( 1384 ui::TouchEvent first_press(
1357 ui::ET_TOUCH_PRESSED, gfx::Point(window_right, 1), 0, Now()); 1385 ui::ET_TOUCH_PRESSED, gfx::Point(window_right, 1), 0, Now());
1358 gfx::Point second_location(window_right, 1 + distance / 2); 1386 gfx::Point second_location(window_right, 1 + distance / 2);
1359 gfx::Point third_location(window_right, 1 + distance); 1387 gfx::Point third_location(window_right, 1 + distance);
1388 gfx::Point fourth_location(window_right, 35);
1360 1389
1361 generator_->Dispatch(&first_press); 1390 generator_->Dispatch(&first_press);
1362 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 1391 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1363 1392
1364 // Since we haven't moved past slop yet, we should not be in slide gesture. 1393 // Since we haven't moved past slop yet, we should not be in slide gesture.
1365 generator_->MoveTouch(second_location); 1394 generator_->MoveTouch(second_location);
1366 EXPECT_FALSE(IsInTouchToMouseMode()); 1395 EXPECT_FALSE(IsInTouchToMouseMode());
1367 EXPECT_FALSE(IsInGestureInProgressState()); 1396 EXPECT_FALSE(IsInGestureInProgressState());
1368 EXPECT_FALSE(IsInSlideGestureState()); 1397 EXPECT_FALSE(IsInSlideGestureState());
1369 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 1398 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1370 1399
1371 // Once we are out of slop, we should be in slide gesture since we are along 1400 // Once we are out of slop, we should be in slide gesture since we are along
1372 // the edge of the screen. 1401 // the edge of the screen.
1373 generator_->MoveTouch(third_location); 1402 generator_->MoveTouch(third_location);
1374 EXPECT_FALSE(IsInGestureInProgressState()); 1403 EXPECT_FALSE(IsInGestureInProgressState());
1375 EXPECT_TRUE(IsInSlideGestureState()); 1404 EXPECT_TRUE(IsInSlideGestureState());
1376 EXPECT_FALSE(IsInTouchToMouseMode()); 1405 EXPECT_FALSE(IsInTouchToMouseMode());
1406
1407 // Now that we are in slide gesture, we can adjust the volume.
1408 generator_->MoveTouch(fourth_location);
1377 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); 1409 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1378 ASSERT_EQ(0U, captured_events.size()); 1410 ASSERT_EQ(0U, captured_events.size());
1379 1411
1380 // Since we are at the right edge of the screen, but the sound timer has not 1412 // Since we are at the right edge of the screen, but the sound timer has not
1381 // elapsed, there should have two sounds that fired and two volume 1413 // elapsed, there should have been a sound that fired and a volume
1382 // changes (one for each movement). 1414 // change.
1383 size_t num_adjust_sounds = delegate_.NumAdjustSounds(); 1415 size_t num_adjust_sounds = delegate_.NumAdjustSounds();
1384 ASSERT_EQ(2U, num_adjust_sounds); 1416 ASSERT_EQ(1U, num_adjust_sounds);
1385 ASSERT_EQ(2U, delegate_.VolumeChanges().size()); 1417 ASSERT_EQ(1U, delegate_.VolumeChanges().size());
1386 1418
1387 // Exit out of slide gesture once touch is lifted, but not before even if the 1419 // Exit out of slide gesture once touch is lifted, but not before even if the
1388 // grace period is over. 1420 // grace period is over.
1389
1390 AdvanceSimulatedTimePastPotentialTapDelay(); 1421 AdvanceSimulatedTimePastPotentialTapDelay();
1391 ASSERT_EQ(0U, captured_events.size()); 1422 ASSERT_EQ(0U, captured_events.size());
1392 EXPECT_FALSE(IsInTouchToMouseMode()); 1423 EXPECT_FALSE(IsInTouchToMouseMode());
1393 EXPECT_FALSE(IsInGestureInProgressState()); 1424 EXPECT_FALSE(IsInGestureInProgressState());
1394 EXPECT_TRUE(IsInSlideGestureState()); 1425 EXPECT_TRUE(IsInSlideGestureState());
1395 1426
1396 generator_->ReleaseTouch(); 1427 generator_->ReleaseTouch();
1397 ASSERT_EQ(0U, captured_events.size()); 1428 ASSERT_EQ(0U, captured_events.size());
1398 EXPECT_FALSE(IsInTouchToMouseMode()); 1429 EXPECT_FALSE(IsInTouchToMouseMode());
1399 EXPECT_FALSE(IsInGestureInProgressState()); 1430 EXPECT_FALSE(IsInGestureInProgressState());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 // If the slide gesture begins within the boundaries and then moves 1472 // If the slide gesture begins within the boundaries and then moves
1442 // SlopDistanceFromEdge there should still be a sound change. If the finger 1473 // SlopDistanceFromEdge there should still be a sound change. If the finger
1443 // moves into the center screen, there should no longer be a sound change but it 1474 // moves into the center screen, there should no longer be a sound change but it
1444 // should still be in slide gesture. If the finger moves back into the edges 1475 // should still be in slide gesture. If the finger moves back into the edges
1445 // without lifting, it should start changing sound again. 1476 // without lifting, it should start changing sound again.
1446 TEST_F(TouchExplorationTest, TestingBoundaries) { 1477 TEST_F(TouchExplorationTest, TestingBoundaries) {
1447 SwitchTouchExplorationMode(true); 1478 SwitchTouchExplorationMode(true);
1448 1479
1449 gfx::Rect window = BoundsOfRootWindowInDIP(); 1480 gfx::Rect window = BoundsOfRootWindowInDIP();
1450 gfx::Point initial_press(window.right() - GetMaxDistanceFromEdge() / 2, 1); 1481 gfx::Point initial_press(window.right() - GetMaxDistanceFromEdge() / 2, 1);
1482
1483 gfx::Point center_screen(window.right() / 2, window.bottom() / 2);
1484
1451 ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, initial_press, 0, Now()); 1485 ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, initial_press, 0, Now());
1452 gfx::Point touch_move(initial_press.x() + gesture_detector_config_.touch_slop, 1486 generator_->Dispatch(&first_press);
1453 1); 1487 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1488 EXPECT_FALSE(IsInGestureInProgressState());
1489 EXPECT_FALSE(IsInSlideGestureState());
1490 EXPECT_FALSE(IsInTouchToMouseMode());
1491
1492 // Move past the touch slop to begin slide gestures.
1493 // + slop + 1 to actually leave slop.
1494 gfx::Point touch_move(
1495 initial_press.x(),
1496 initial_press.y() + gesture_detector_config_.touch_slop + 1);
1497 generator_->MoveTouch(touch_move);
1498 EXPECT_FALSE(IsInGestureInProgressState());
1499 EXPECT_TRUE(IsInSlideGestureState());
1500 EXPECT_FALSE(IsInTouchToMouseMode());
1501 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1502
1503 // Move the touch into slop boundaries. It should still be in slide gestures
1504 // and adjust the volume.
1454 gfx::Point into_slop_boundaries( 1505 gfx::Point into_slop_boundaries(
1455 window.right() - GetSlopDistanceFromEdge() / 2, 1); 1506 window.right() - GetSlopDistanceFromEdge() / 2, 1);
1456 gfx::Point center_screen(window.right() / 2, window.bottom() / 2);
1457
1458 generator_->Dispatch(&first_press);
1459 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1460
1461 generator_->MoveTouch(touch_move);
1462 EXPECT_FALSE(IsInTouchToMouseMode());
1463 EXPECT_FALSE(IsInGestureInProgressState());
1464 EXPECT_FALSE(IsInSlideGestureState());
1465 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1466
1467 // Move the touch into slop boundaries. It should stil be in slide gestures
1468 // and adjust the volume.
1469 generator_->MoveTouch(into_slop_boundaries); 1507 generator_->MoveTouch(into_slop_boundaries);
1470 EXPECT_FALSE(IsInGestureInProgressState()); 1508 EXPECT_FALSE(IsInGestureInProgressState());
1471 EXPECT_TRUE(IsInSlideGestureState()); 1509 EXPECT_TRUE(IsInSlideGestureState());
1472 EXPECT_FALSE(IsInTouchToMouseMode()); 1510 EXPECT_FALSE(IsInTouchToMouseMode());
1473 1511
1474 // The sound is rate limiting so it only activates every 150ms. 1512 // The sound is rate limiting so it only activates every 150ms.
1475 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200)); 1513 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1476 1514
1477 size_t num_adjust_sounds = delegate_.NumAdjustSounds(); 1515 size_t num_adjust_sounds = delegate_.NumAdjustSounds();
1478 ASSERT_EQ(2U, num_adjust_sounds); 1516 ASSERT_EQ(1U, num_adjust_sounds);
1479 ASSERT_EQ(2U, delegate_.VolumeChanges().size()); 1517 ASSERT_EQ(1U, delegate_.VolumeChanges().size());
1480 1518
1481 // Move the touch into the center of the window. It should still be in slide 1519 // Move the touch into the center of the window. It should still be in slide
1482 // gestures, but there should not be anymore volume adjustments. 1520 // gestures, but there should not be anymore volume adjustments.
1483 generator_->MoveTouch(center_screen); 1521 generator_->MoveTouch(center_screen);
1484 EXPECT_FALSE(IsInGestureInProgressState()); 1522 EXPECT_FALSE(IsInGestureInProgressState());
1485 EXPECT_TRUE(IsInSlideGestureState()); 1523 EXPECT_TRUE(IsInSlideGestureState());
1486 EXPECT_FALSE(IsInTouchToMouseMode()); 1524 EXPECT_FALSE(IsInTouchToMouseMode());
1487 1525
1488 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200)); 1526 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1489 num_adjust_sounds = delegate_.NumAdjustSounds(); 1527 num_adjust_sounds = delegate_.NumAdjustSounds();
1490 ASSERT_EQ(2U, num_adjust_sounds); 1528 ASSERT_EQ(1U, num_adjust_sounds);
1491 ASSERT_EQ(2U, delegate_.VolumeChanges().size()); 1529 ASSERT_EQ(1U, delegate_.VolumeChanges().size());
1492 1530
1493 // Move the touch back into slop edge distance and volume should be changing 1531 // Move the touch back into slop edge distance and volume should be changing
1494 // again. 1532 // again, one volume change for each new move.
1495 generator_->MoveTouch(into_slop_boundaries); 1533 generator_->MoveTouch(into_slop_boundaries);
1496 EXPECT_FALSE(IsInGestureInProgressState()); 1534 EXPECT_FALSE(IsInGestureInProgressState());
1497 EXPECT_TRUE(IsInSlideGestureState()); 1535 EXPECT_TRUE(IsInSlideGestureState());
1498 EXPECT_FALSE(IsInTouchToMouseMode()); 1536 EXPECT_FALSE(IsInTouchToMouseMode());
1499 1537
1500 generator_->MoveTouch( 1538 generator_->MoveTouch(
1501 gfx::Point(into_slop_boundaries.x() + gesture_detector_config_.touch_slop, 1539 gfx::Point(into_slop_boundaries.x() + gesture_detector_config_.touch_slop,
1502 into_slop_boundaries.y())); 1540 into_slop_boundaries.y()));
1503 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200)); 1541 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1504 1542
1505 num_adjust_sounds = delegate_.NumAdjustSounds(); 1543 num_adjust_sounds = delegate_.NumAdjustSounds();
1506 ASSERT_EQ(3U, num_adjust_sounds); 1544 ASSERT_EQ(2U, num_adjust_sounds);
1507 ASSERT_EQ(3U, delegate_.VolumeChanges().size()); 1545 ASSERT_EQ(3U, delegate_.VolumeChanges().size());
1508 1546
1509 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); 1547 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1510 ASSERT_EQ(0U, captured_events.size()); 1548 ASSERT_EQ(0U, captured_events.size());
1511 1549
1512 generator_->ReleaseTouch(); 1550 generator_->ReleaseTouch();
1513 } 1551 }
1514 1552
1515 // Even if the gesture starts within bounds, if it has not moved past slop 1553 // Even if the gesture starts within bounds, if it has not moved past slop
1516 // within the grace period, it should go to touch exploration. 1554 // within the grace period, it should go to touch exploration.
(...skipping 12 matching lines...) Expand all
1529 EXPECT_FALSE(IsInSlideGestureState()); 1567 EXPECT_FALSE(IsInSlideGestureState());
1530 EXPECT_FALSE(IsInTouchToMouseMode()); 1568 EXPECT_FALSE(IsInTouchToMouseMode());
1531 1569
1532 AdvanceSimulatedTimePastTapDelay(); 1570 AdvanceSimulatedTimePastTapDelay();
1533 EXPECT_FALSE(IsInGestureInProgressState()); 1571 EXPECT_FALSE(IsInGestureInProgressState());
1534 EXPECT_FALSE(IsInSlideGestureState()); 1572 EXPECT_FALSE(IsInSlideGestureState());
1535 EXPECT_TRUE(IsInTouchToMouseMode()); 1573 EXPECT_TRUE(IsInTouchToMouseMode());
1536 } 1574 }
1537 1575
1538 } // namespace ui 1576 } // namespace ui
OLDNEW
« ui/chromeos/touch_exploration_controller.cc ('K') | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698