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

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

Issue 385073009: Side Slide Gestures for Accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Comments 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 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 }; 65 };
66 66
67 int Factorial(int n) { 67 int Factorial(int n) {
68 if (n <= 0) 68 if (n <= 0)
69 return 0; 69 return 0;
70 if (n == 1) 70 if (n == 1)
71 return 1; 71 return 1;
72 return n * Factorial(n - 1); 72 return n * Factorial(n - 1);
73 } 73 }
74 74
75 class MockTouchExplorationControllerDelegate
76 : public ui::TouchExplorationControllerDelegate {
77 public:
78 virtual void PlayVolumeAdjustSound() OVERRIDE {
79 ++num_times_adjust_sound_played_;
80 }
81 virtual void SetOutputLevel(int volume) OVERRIDE {
82 volume_changes_.push_back(volume);
83 }
84
85 const std::vector<float> VolumeChanges() { return volume_changes_; }
86 const size_t NumAdjustSounds() { return num_times_adjust_sound_played_; }
87
88 private:
89 std::vector<float> volume_changes_;
90 size_t num_times_adjust_sound_played_ = 0;
91 };
92
75 } // namespace 93 } // namespace
76 94
77 class TouchExplorationControllerTestApi { 95 class TouchExplorationControllerTestApi {
78 public: 96 public:
79 TouchExplorationControllerTestApi( 97 TouchExplorationControllerTestApi(
80 TouchExplorationController* touch_exploration_controller) { 98 TouchExplorationController* touch_exploration_controller) {
81 touch_exploration_controller_.reset(touch_exploration_controller); 99 touch_exploration_controller_.reset(touch_exploration_controller);
82 } 100 }
83 101
84 void CallTapTimerNowForTesting() { 102 void CallTapTimerNowForTesting() {
(...skipping 18 matching lines...) Expand all
103 bool IsInNoFingersDownStateForTesting() const { 121 bool IsInNoFingersDownStateForTesting() const {
104 return touch_exploration_controller_->state_ == 122 return touch_exploration_controller_->state_ ==
105 touch_exploration_controller_->NO_FINGERS_DOWN; 123 touch_exploration_controller_->NO_FINGERS_DOWN;
106 } 124 }
107 125
108 bool IsInGestureInProgressStateForTesting() const { 126 bool IsInGestureInProgressStateForTesting() const {
109 return touch_exploration_controller_->state_ == 127 return touch_exploration_controller_->state_ ==
110 touch_exploration_controller_->GESTURE_IN_PROGRESS; 128 touch_exploration_controller_->GESTURE_IN_PROGRESS;
111 } 129 }
112 130
131 bool IsInSlideGestureStateForTesting() const {
132 return touch_exploration_controller_->state_ ==
133 touch_exploration_controller_->SLIDE_GESTURE;
134 }
135
136 gfx::Rect BoundsOfRootWindowInDIPForTesting() const {
137 return touch_exploration_controller_->root_window_->GetBoundsInScreen();
138 }
139
113 // VLOGs should be suppressed in tests that generate a lot of logs, 140 // VLOGs should be suppressed in tests that generate a lot of logs,
114 // for example permutations of nine touch events. 141 // for example permutations of nine touch events.
115 void SuppressVLOGsForTesting(bool suppress) { 142 void SuppressVLOGsForTesting(bool suppress) {
116 touch_exploration_controller_->VLOG_on_ = !suppress; 143 touch_exploration_controller_->VLOG_on_ = !suppress;
117 } 144 }
118 145
119 private: 146 private:
120 scoped_ptr<TouchExplorationController> touch_exploration_controller_; 147 scoped_ptr<TouchExplorationController> touch_exploration_controller_;
121 148
122 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi); 149 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 232 }
206 233
207 void SuppressVLOGs(bool suppress) { 234 void SuppressVLOGs(bool suppress) {
208 touch_exploration_controller_->SuppressVLOGsForTesting(suppress); 235 touch_exploration_controller_->SuppressVLOGsForTesting(suppress);
209 } 236 }
210 237
211 void SwitchTouchExplorationMode(bool on) { 238 void SwitchTouchExplorationMode(bool on) {
212 if (!on && touch_exploration_controller_.get()) { 239 if (!on && touch_exploration_controller_.get()) {
213 touch_exploration_controller_.reset(); 240 touch_exploration_controller_.reset();
214 } else if (on && !touch_exploration_controller_.get()) { 241 } else if (on && !touch_exploration_controller_.get()) {
215 touch_exploration_controller_.reset(new TouchExplorationControllerTestApi( 242 touch_exploration_controller_.reset(
216 new ui::TouchExplorationController(root_window()))); 243 new ui::TouchExplorationControllerTestApi(
244 new TouchExplorationController(root_window(), &delegate_)));
217 touch_exploration_controller_->SetEventHandlerForTesting( 245 touch_exploration_controller_->SetEventHandlerForTesting(
218 &event_capturer_); 246 &event_capturer_);
219 cursor_client()->ShowCursor(); 247 cursor_client()->ShowCursor();
220 cursor_client()->DisableMouseEvents(); 248 cursor_client()->DisableMouseEvents();
221 } 249 }
222 } 250 }
223 251
224 void EnterTouchExplorationModeAtLocation(gfx::Point tap_location) { 252 void EnterTouchExplorationModeAtLocation(gfx::Point tap_location) {
225 ui::TouchEvent touch_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now()); 253 ui::TouchEvent touch_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now());
226 generator_->Dispatch(&touch_press); 254 generator_->Dispatch(&touch_press);
(...skipping 22 matching lines...) Expand all
249 277
250 bool IsInNoFingersDownState() { 278 bool IsInNoFingersDownState() {
251 return touch_exploration_controller_->IsInNoFingersDownStateForTesting(); 279 return touch_exploration_controller_->IsInNoFingersDownStateForTesting();
252 } 280 }
253 281
254 bool IsInGestureInProgressState() { 282 bool IsInGestureInProgressState() {
255 return touch_exploration_controller_ 283 return touch_exploration_controller_
256 ->IsInGestureInProgressStateForTesting(); 284 ->IsInGestureInProgressStateForTesting();
257 } 285 }
258 286
287 bool IsInSlideGestureState() {
288 return touch_exploration_controller_->IsInSlideGestureStateForTesting();
289 }
290
291 gfx::Rect BoundsOfRootWindowInDIP() {
292 return touch_exploration_controller_->BoundsOfRootWindowInDIPForTesting();
293 }
294
259 base::TimeDelta Now() { 295 base::TimeDelta Now() {
260 // This is the same as what EventTimeForNow() does, but here we do it 296 // This is the same as what EventTimeForNow() does, but here we do it
261 // with our simulated clock. 297 // with our simulated clock.
262 return base::TimeDelta::FromInternalValue( 298 return base::TimeDelta::FromInternalValue(
263 simulated_clock_->NowTicks().ToInternalValue()); 299 simulated_clock_->NowTicks().ToInternalValue());
264 } 300 }
265 301
266 scoped_ptr<aura::test::EventGenerator> generator_; 302 scoped_ptr<aura::test::EventGenerator> generator_;
267 ui::GestureDetector::Config gesture_detector_config_; 303 ui::GestureDetector::Config gesture_detector_config_;
268 // Owned by |generator_|. 304 // Owned by |generator_|.
269 base::SimpleTestTickClock* simulated_clock_; 305 base::SimpleTestTickClock* simulated_clock_;
306 MockTouchExplorationControllerDelegate delegate_;
270 307
271 private: 308 private:
272 EventCapturer event_capturer_; 309 EventCapturer event_capturer_;
273 scoped_ptr<TouchExplorationControllerTestApi> 310 scoped_ptr<TouchExplorationControllerTestApi>
274 touch_exploration_controller_; 311 touch_exploration_controller_;
275 scoped_ptr<aura::test::TestCursorClient> cursor_client_; 312 scoped_ptr<aura::test::TestCursorClient> cursor_client_;
276 313
277 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest); 314 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest);
278 }; 315 };
279 316
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type()); 540 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type());
504 EXPECT_TRUE(IsInNoFingersDownState()); 541 EXPECT_TRUE(IsInNoFingersDownState());
505 } 542 }
506 543
507 // If an event is received after the double-tap timeout has elapsed, but 544 // If an event is received after the double-tap timeout has elapsed, but
508 // before the timer has fired, a mouse move should still be generated. 545 // before the timer has fired, a mouse move should still be generated.
509 TEST_F(TouchExplorationTest, TimerFiresLateDuringTouchExploration) { 546 TEST_F(TouchExplorationTest, TimerFiresLateDuringTouchExploration) {
510 SwitchTouchExplorationMode(true); 547 SwitchTouchExplorationMode(true);
511 548
512 // Send a press, then add another finger after the double-tap timeout. 549 // Send a press, then add another finger after the double-tap timeout.
550 generator_->MoveTouch(gfx::Point(100, 200));
aboxhall 2014/07/22 17:20:42 Perhaps move this above the preceding comment and
lisayin 2014/07/22 18:06:26 Done.
513 generator_->PressTouchId(1); 551 generator_->PressTouchId(1);
514 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000)); 552 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000));
515 generator_->PressTouchId(2); 553 generator_->PressTouchId(2);
516 std::vector<ui::LocatedEvent*> events = 554 std::vector<ui::LocatedEvent*> events =
517 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); 555 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
518 ASSERT_EQ(1U, events.size()); 556 ASSERT_EQ(1U, events.size());
519 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); 557 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
520 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); 558 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
521 559
522 generator_->ReleaseTouchId(2); 560 generator_->ReleaseTouchId(2);
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 } 1388 }
1351 1389
1352 // With the simple swipe gestures, if additional fingers are added, then the 1390 // With the simple swipe gestures, if additional fingers are added, then the
1353 // state should change to passthrough. 1391 // state should change to passthrough.
1354 TEST_F(TouchExplorationTest, FromGestureToPassthrough) { 1392 TEST_F(TouchExplorationTest, FromGestureToPassthrough) {
1355 SwitchTouchExplorationMode(true); 1393 SwitchTouchExplorationMode(true);
1356 EXPECT_FALSE(IsInTouchToMouseMode()); 1394 EXPECT_FALSE(IsInTouchToMouseMode());
1357 EXPECT_FALSE(IsInGestureInProgressState()); 1395 EXPECT_FALSE(IsInGestureInProgressState());
1358 1396
1359 float distance = gesture_detector_config_.touch_slop + 1; 1397 float distance = gesture_detector_config_.touch_slop + 1;
1360 ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 1), 0, Now()); 1398 ui::TouchEvent first_press(
1399 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 0, Now());
1361 generator_->Dispatch(&first_press); 1400 generator_->Dispatch(&first_press);
1362 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 1401 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1363 gfx::Point second_location(distance, 1); 1402 gfx::Point second_location(100 + distance, 200);
1364 generator_->MoveTouch(second_location); 1403 generator_->MoveTouch(second_location);
1365 EXPECT_TRUE(IsInGestureInProgressState()); 1404 EXPECT_TRUE(IsInGestureInProgressState());
1366 EXPECT_FALSE(IsInTouchToMouseMode()); 1405 EXPECT_FALSE(IsInTouchToMouseMode());
1367 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); 1406 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1368 ASSERT_EQ(0U, captured_events.size()); 1407 ASSERT_EQ(0U, captured_events.size());
1369 1408
1370 // Generate a second press that should go through as is. 1409 // Generate a second press that should go through as is.
1371 ui::TouchEvent second_press( 1410 ui::TouchEvent second_press(
1372 ui::ET_TOUCH_PRESSED, gfx::Point(20, 21), 1, Now()); 1411 ui::ET_TOUCH_PRESSED, gfx::Point(20, 21), 1, Now());
1373 generator_->Dispatch(&second_press); 1412 generator_->Dispatch(&second_press);
1374 EXPECT_FALSE(IsInGestureInProgressState()); 1413 EXPECT_FALSE(IsInGestureInProgressState());
1375 EXPECT_FALSE(IsInTouchToMouseMode()); 1414 EXPECT_FALSE(IsInTouchToMouseMode());
1376 std::vector<ui::LocatedEvent*> captured_located_events = 1415 std::vector<ui::LocatedEvent*> captured_located_events =
1377 GetCapturedLocatedEvents(); 1416 GetCapturedLocatedEvents();
1378 ASSERT_EQ(1U, captured_events.size()); 1417 ASSERT_EQ(1U, captured_events.size());
1379 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_located_events[0], &second_press); 1418 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_located_events[0], &second_press);
1380 ClearCapturedEvents(); 1419 ClearCapturedEvents();
1381 1420
1382 // The rest of the events should occur in passthrough. 1421 // The rest of the events should occur in passthrough.
1383 generator_->ReleaseTouchId(0); 1422 generator_->ReleaseTouchId(0);
1384 ASSERT_EQ(1U, captured_events.size()); 1423 ASSERT_EQ(1U, captured_events.size());
1385 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type()); 1424 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type());
1386 ClearCapturedEvents(); 1425 ClearCapturedEvents();
1387 generator_->ReleaseTouchId(1); 1426 generator_->ReleaseTouchId(1);
1388 ASSERT_EQ(0U, captured_events.size()); 1427 ASSERT_EQ(0U, captured_events.size());
1389 } 1428 }
1390 1429
1430 TEST_F(TouchExplorationTest, EnterSlideGestureState) {
1431 SwitchTouchExplorationMode(true);
1432 EXPECT_FALSE(IsInTouchToMouseMode());
1433 EXPECT_FALSE(IsInGestureInProgressState());
1434
1435 gfx::Rect window = BoundsOfRootWindowInDIP();
1436 float distance = gesture_detector_config_.touch_slop + 1;
1437 ui::TouchEvent first_press(
1438 ui::ET_TOUCH_PRESSED, gfx::Point(window.right(), 1), 0, Now());
1439 gfx::Point second_location(window.right(), 1 + distance / 2);
1440 gfx::Point third_location(window.right(), 1 + distance);
1441
1442 generator_->Dispatch(&first_press);
1443 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1444
1445 // Since we haven't moved past slop yet, we should not be in slide gesture.
1446 generator_->MoveTouch(second_location);
1447 EXPECT_FALSE(IsInTouchToMouseMode());
1448 EXPECT_FALSE(IsInGestureInProgressState());
1449 EXPECT_FALSE(IsInSlideGestureState());
1450 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1451
1452 // Once we are out of slop, we should be in slide gesture since we are along
1453 // the edge of the screen.
1454 generator_->MoveTouch(third_location);
1455 EXPECT_FALSE(IsInGestureInProgressState());
1456 EXPECT_TRUE(IsInSlideGestureState());
1457 EXPECT_FALSE(IsInTouchToMouseMode());
1458 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1459 ASSERT_EQ(0U, captured_events.size());
1460
1461 // Since we are at the right edge of the screen, but the sound timer has not
1462 // elapsed, there should have two sounds that fired and two volume
aboxhall 2014/07/22 17:20:42 So the move within the slop region generates a vol
lisayin 2014/07/22 18:06:26 The slop region is an additional grace area so tha
1463 // changes (one for each movement).
1464 size_t num_adjust_sounds = delegate_.NumAdjustSounds();
1465 ASSERT_EQ(2U, num_adjust_sounds);
1466 ASSERT_EQ(2U, delegate_.VolumeChanges().size());
1467
1468 // Exit out of slide gesture once touch is lifted, but not before even if the
1469 // grace period is over.
1470
1471 AdvanceSimulatedTimePastPotentialTapDelay();
1472 ASSERT_EQ(0U, captured_events.size());
1473 EXPECT_FALSE(IsInTouchToMouseMode());
1474 EXPECT_FALSE(IsInGestureInProgressState());
1475 EXPECT_TRUE(IsInSlideGestureState());
1476
1477 generator_->ReleaseTouch();
1478 ASSERT_EQ(0U, captured_events.size());
1479 EXPECT_FALSE(IsInTouchToMouseMode());
1480 EXPECT_FALSE(IsInGestureInProgressState());
1481 EXPECT_FALSE(IsInSlideGestureState());
1482 }
1483
1484 // If a press + move occurred outside the boundaries, but within the slop
1485 // boundaries and then moved into the boundaries of an edge, there still should
1486 // not be a slide gesture.
1487 TEST_F(TouchExplorationTest, AvoidEnteringSlideGesture) {
1488 SwitchTouchExplorationMode(true);
1489
1490 // DO SOMETHING TO MAKE THESE CONSTANTS ACCESSIBLE FROM ORIGINAL FILE
dmazzoni 2014/07/22 17:14:55 Define the constants you need in the TouchExplorat
lisayin 2014/07/22 18:06:26 Done.
1491 const float kMaxDistanceFromEdge = 75;
1492 const float kSlopDistanceFromEdge = kMaxDistanceFromEdge + 40;
1493
1494 gfx::Rect window = BoundsOfRootWindowInDIP();
1495 float distance = gesture_detector_config_.touch_slop + 1;
1496 ui::TouchEvent first_press(
1497 ui::ET_TOUCH_PRESSED,
1498 gfx::Point(window.right() - kSlopDistanceFromEdge, 1),
1499 0,
1500 Now());
1501 gfx::Point out_of_slop(window.right() - kSlopDistanceFromEdge + distance, 1);
1502 gfx::Point into_boundaries(window.right() - kMaxDistanceFromEdge / 2, 1);
1503
1504 generator_->Dispatch(&first_press);
1505 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1506
1507 generator_->MoveTouch(out_of_slop);
1508 EXPECT_FALSE(IsInTouchToMouseMode());
1509 EXPECT_TRUE(IsInGestureInProgressState());
1510 EXPECT_FALSE(IsInSlideGestureState());
1511 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1512
1513 // Since we did not start moving while in the boundaries, we should not be in
1514 // slide gestures.
1515 generator_->MoveTouch(into_boundaries);
1516 EXPECT_TRUE(IsInGestureInProgressState());
1517 EXPECT_FALSE(IsInSlideGestureState());
1518 EXPECT_FALSE(IsInTouchToMouseMode());
1519 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1520 ASSERT_EQ(0U, captured_events.size());
1521
1522 generator_->ReleaseTouch();
1523 }
1524
1525 // If the slide gesture begins within the boundaries and then moves
1526 // SlopDistanceFromEdge there should still be a sound change. If the finger
1527 // moves into the center screen, there should no longer be a sound change but it
1528 // should still be in slide gesture. If the finger moves back into the edges
1529 // without lifting, it should start changing sound again.
1530 TEST_F(TouchExplorationTest, TestingBoundaries) {
1531 SwitchTouchExplorationMode(true);
1532
1533 const float kMaxDistanceFromEdge = 75;
1534 const float kSlopDistanceFromEdge = kMaxDistanceFromEdge + 40;
1535
1536 gfx::Rect window = BoundsOfRootWindowInDIP();
1537 gfx::Point initial_press(window.right() - kMaxDistanceFromEdge / 2, 1);
1538 ui::TouchEvent first_press(
1539 ui::ET_TOUCH_PRESSED,
1540 initial_press,
1541 0,
1542 Now());
1543 gfx::Point touch_move(initial_press.x() + gesture_detector_config_.touch_slop,
1544 1);
1545 gfx::Point into_slop_boundaries(window.right() - kSlopDistanceFromEdge / 2,
1546 1);
1547 gfx::Point center_screen(window.right() / 2, window.bottom() / 2);
1548
1549 generator_->Dispatch(&first_press);
1550 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1551
1552 generator_->MoveTouch(touch_move);
1553 EXPECT_FALSE(IsInTouchToMouseMode());
1554 EXPECT_FALSE(IsInGestureInProgressState());
1555 EXPECT_FALSE(IsInSlideGestureState());
1556 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1557
1558 // Move the touch into slop boundaries. It should stil be in slide gestures
1559 // and adjust the volume.
1560 generator_->MoveTouch(into_slop_boundaries);
1561 EXPECT_FALSE(IsInGestureInProgressState());
1562 EXPECT_TRUE(IsInSlideGestureState());
1563 EXPECT_FALSE(IsInTouchToMouseMode());
1564
1565 // The sound is rate limiting so it only activates every 150ms.
1566 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1567
1568 size_t num_adjust_sounds = delegate_.NumAdjustSounds();
1569 ASSERT_EQ(2U, num_adjust_sounds);
1570 ASSERT_EQ(2U, delegate_.VolumeChanges().size());
1571
1572 // Move the touch into the center of the window. It should still be in slide
1573 // gestures, but there should not be anymore volume adjustments.
1574 generator_->MoveTouch(center_screen);
1575 EXPECT_FALSE(IsInGestureInProgressState());
1576 EXPECT_TRUE(IsInSlideGestureState());
1577 EXPECT_FALSE(IsInTouchToMouseMode());
1578
1579 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1580 num_adjust_sounds = delegate_.NumAdjustSounds();
1581 ASSERT_EQ(2U, num_adjust_sounds);
1582 ASSERT_EQ(2U, delegate_.VolumeChanges().size());
1583
1584 // Move the touch back into slop edge distance and volume should be changing
1585 // again.
1586 generator_->MoveTouch(into_slop_boundaries);
1587 EXPECT_FALSE(IsInGestureInProgressState());
1588 EXPECT_TRUE(IsInSlideGestureState());
1589 EXPECT_FALSE(IsInTouchToMouseMode());
1590
1591 generator_->MoveTouch(
1592 gfx::Point(into_slop_boundaries.x() + gesture_detector_config_.touch_slop,
1593 into_slop_boundaries.y()));
1594 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1595
1596 num_adjust_sounds = delegate_.NumAdjustSounds();
1597 ASSERT_EQ(3U, num_adjust_sounds);
1598 ASSERT_EQ(3U, delegate_.VolumeChanges().size());
1599
1600 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1601 ASSERT_EQ(0U, captured_events.size());
1602
1603 generator_->ReleaseTouch();
1604 }
1605
1606 // Even if the gesture starts within bounds, if it has not moved past slop
1607 // within the grace period, it should go to touch exploration.
1608 TEST_F(TouchExplorationTest, InBoundariesTouchExploration) {
1609 SwitchTouchExplorationMode(true);
1610
1611 const float kMaxDistanceFromEdge = 75;
1612
1613 gfx::Rect window = BoundsOfRootWindowInDIP();
1614 gfx::Point initial_press(window.right() - kMaxDistanceFromEdge / 2, 1);
1615 ui::TouchEvent first_press(
1616 ui::ET_TOUCH_PRESSED,
1617 initial_press,
1618 0,
1619 Now());
1620 generator_->Dispatch(&first_press);
1621 EXPECT_FALSE(IsInGestureInProgressState());
1622 EXPECT_FALSE(IsInSlideGestureState());
1623 EXPECT_FALSE(IsInTouchToMouseMode());
1624
1625 AdvanceSimulatedTimePastTapDelay();
1626 EXPECT_FALSE(IsInGestureInProgressState());
1627 EXPECT_FALSE(IsInSlideGestureState());
1628 EXPECT_TRUE(IsInTouchToMouseMode());
1629 }
1630
1391 } // namespace ui 1631 } // 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