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

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: Fixed TouchExploration Not Turning On 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }; 64 };
65 65
66 int Factorial(int n) { 66 int Factorial(int n) {
67 if (n <= 0) 67 if (n <= 0)
68 return 0; 68 return 0;
69 if (n == 1) 69 if (n == 1)
70 return 1; 70 return 1;
71 return n * Factorial(n - 1); 71 return n * Factorial(n - 1);
72 } 72 }
73 73
74 class MockTouchExplorationControllerDelegate
75 : public ui::TouchExplorationControllerDelegate {
76 public:
77 virtual void PlayVolumeAdjustSound() OVERRIDE {
78 ++num_times_adjust_sound_played_;
79 }
80 virtual void SetOutputLevel(int volume) OVERRIDE {
81 volume_changes_.push_back(volume);
82 }
83
84 const std::vector<float> VolumeChanges() { return volume_changes_; }
85 const size_t NumAdjustSounds() { return num_times_adjust_sound_played_; }
86
87 private:
88 std::vector<float> volume_changes_;
89 size_t num_times_adjust_sound_played_ = 0;
90 };
91
74 } // namespace 92 } // namespace
75 93
76 class TouchExplorationTest : public aura::test::AuraTestBase { 94 class TouchExplorationTest : public aura::test::AuraTestBase {
77 public: 95 public:
78 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { 96 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) {
79 // Tests fail if time is ever 0. 97 // Tests fail if time is ever 0.
80 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 98 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
81 } 99 }
82 virtual ~TouchExplorationTest() {} 100 virtual ~TouchExplorationTest() {}
83 101
84 virtual void SetUp() OVERRIDE { 102 virtual void SetUp() OVERRIDE {
85 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone) 103 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone)
86 gfx::GLSurface::InitializeOneOffForTests(); 104 gfx::GLSurface::InitializeOneOffForTests();
87 aura::test::AuraTestBase::SetUp(); 105 aura::test::AuraTestBase::SetUp();
106 delegate_ = new MockTouchExplorationControllerDelegate();
James Cook 2014/07/21 21:05:35 I think this causes a memory leak. delegate_ shoul
lisayin 2014/07/22 16:22:47 Done.
88 cursor_client_.reset(new aura::test::TestCursorClient(root_window())); 107 cursor_client_.reset(new aura::test::TestCursorClient(root_window()));
89 root_window()->AddPreTargetHandler(&event_capturer_); 108 root_window()->AddPreTargetHandler(&event_capturer_);
90 generator_.reset(new aura::test::EventGenerator(root_window())); 109 generator_.reset(new aura::test::EventGenerator(root_window()));
91 // The generator takes ownership of the clock. 110 // The generator takes ownership of the clock.
92 generator_->SetTickClock(scoped_ptr<base::TickClock>(simulated_clock_)); 111 generator_->SetTickClock(scoped_ptr<base::TickClock>(simulated_clock_));
93 cursor_client()->ShowCursor(); 112 cursor_client()->ShowCursor();
94 cursor_client()->DisableMouseEvents(); 113 cursor_client()->DisableMouseEvents();
95 } 114 }
96 115
97 virtual void TearDown() OVERRIDE { 116 virtual void TearDown() OVERRIDE {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 176
158 void SuppressVLOGs(bool suppress) { 177 void SuppressVLOGs(bool suppress) {
159 touch_exploration_controller_->SuppressVLOGsForTesting(suppress); 178 touch_exploration_controller_->SuppressVLOGsForTesting(suppress);
160 } 179 }
161 180
162 void SwitchTouchExplorationMode(bool on) { 181 void SwitchTouchExplorationMode(bool on) {
163 if (!on && touch_exploration_controller_.get()) { 182 if (!on && touch_exploration_controller_.get()) {
164 touch_exploration_controller_.reset(); 183 touch_exploration_controller_.reset();
165 } else if (on && !touch_exploration_controller_.get()) { 184 } else if (on && !touch_exploration_controller_.get()) {
166 touch_exploration_controller_.reset( 185 touch_exploration_controller_.reset(
167 new ui::TouchExplorationController(root_window())); 186 new ui::TouchExplorationController(root_window(), delegate_));
168 touch_exploration_controller_->SetEventHandlerForTesting( 187 touch_exploration_controller_->SetEventHandlerForTesting(
169 &event_capturer_); 188 &event_capturer_);
170 cursor_client()->ShowCursor(); 189 cursor_client()->ShowCursor();
171 cursor_client()->DisableMouseEvents(); 190 cursor_client()->DisableMouseEvents();
172 } 191 }
173 } 192 }
174 193
175 void EnterTouchExplorationModeAtLocation(gfx::Point tap_location) { 194 void EnterTouchExplorationModeAtLocation(gfx::Point tap_location) {
176 ui::TouchEvent touch_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now()); 195 ui::TouchEvent touch_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now());
177 generator_->Dispatch(&touch_press); 196 generator_->Dispatch(&touch_press);
(...skipping 22 matching lines...) Expand all
200 219
201 bool IsInNoFingersDownState() { 220 bool IsInNoFingersDownState() {
202 return touch_exploration_controller_->IsInNoFingersDownStateForTesting(); 221 return touch_exploration_controller_->IsInNoFingersDownStateForTesting();
203 } 222 }
204 223
205 bool IsInGestureInProgressState() { 224 bool IsInGestureInProgressState() {
206 return touch_exploration_controller_ 225 return touch_exploration_controller_
207 ->IsInGestureInProgressStateForTesting(); 226 ->IsInGestureInProgressStateForTesting();
208 } 227 }
209 228
229 bool IsInSlideGestureState() {
230 return touch_exploration_controller_->IsInSlideGestureStateForTesting();
231 }
232
233 gfx::Rect BoundsOfRootWindowInDIP() {
234 return touch_exploration_controller_->BoundsOfRootWindowInDIPForTesting();
235 }
236
210 base::TimeDelta Now() { 237 base::TimeDelta Now() {
211 // This is the same as what EventTimeForNow() does, but here we do it 238 // This is the same as what EventTimeForNow() does, but here we do it
212 // with our simulated clock. 239 // with our simulated clock.
213 return base::TimeDelta::FromInternalValue( 240 return base::TimeDelta::FromInternalValue(
214 simulated_clock_->NowTicks().ToInternalValue()); 241 simulated_clock_->NowTicks().ToInternalValue());
215 } 242 }
216 243
217 scoped_ptr<aura::test::EventGenerator> generator_; 244 scoped_ptr<aura::test::EventGenerator> generator_;
218 ui::GestureDetector::Config gesture_detector_config_; 245 ui::GestureDetector::Config gesture_detector_config_;
219 // Owned by |generator_|. 246 // Owned by |generator_|.
220 base::SimpleTestTickClock* simulated_clock_; 247 base::SimpleTestTickClock* simulated_clock_;
248 MockTouchExplorationControllerDelegate* delegate_;
221 249
222 private: 250 private:
223 EventCapturer event_capturer_; 251 EventCapturer event_capturer_;
224 scoped_ptr<ui::TouchExplorationController> touch_exploration_controller_; 252 scoped_ptr<ui::TouchExplorationController> touch_exploration_controller_;
225 scoped_ptr<aura::test::TestCursorClient> cursor_client_; 253 scoped_ptr<aura::test::TestCursorClient> cursor_client_;
226 254
227 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest); 255 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest);
228 }; 256 };
229 257
230 // Executes a number of assertions to confirm that |e1| and |e2| are touch 258 // Executes a number of assertions to confirm that |e1| and |e2| are touch
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type()); 481 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type());
454 EXPECT_TRUE(IsInNoFingersDownState()); 482 EXPECT_TRUE(IsInNoFingersDownState());
455 } 483 }
456 484
457 // If an event is received after the double-tap timeout has elapsed, but 485 // If an event is received after the double-tap timeout has elapsed, but
458 // before the timer has fired, a mouse move should still be generated. 486 // before the timer has fired, a mouse move should still be generated.
459 TEST_F(TouchExplorationTest, TimerFiresLateDuringTouchExploration) { 487 TEST_F(TouchExplorationTest, TimerFiresLateDuringTouchExploration) {
460 SwitchTouchExplorationMode(true); 488 SwitchTouchExplorationMode(true);
461 489
462 // Send a press, then add another finger after the double-tap timeout. 490 // Send a press, then add another finger after the double-tap timeout.
491 generator_->MoveTouch(gfx::Point(100, 200));
463 generator_->PressTouchId(1); 492 generator_->PressTouchId(1);
464 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000)); 493 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000));
465 generator_->PressTouchId(2); 494 generator_->PressTouchId(2);
466 std::vector<ui::LocatedEvent*> events = 495 std::vector<ui::LocatedEvent*> events =
467 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); 496 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
468 ASSERT_EQ(1U, events.size()); 497 ASSERT_EQ(1U, events.size());
469 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); 498 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
470 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); 499 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
471 500
472 generator_->ReleaseTouchId(2); 501 generator_->ReleaseTouchId(2);
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 } 1329 }
1301 1330
1302 // With the simple swipe gestures, if additional fingers are added, then the 1331 // With the simple swipe gestures, if additional fingers are added, then the
1303 // state should change to passthrough. 1332 // state should change to passthrough.
1304 TEST_F(TouchExplorationTest, FromGestureToPassthrough) { 1333 TEST_F(TouchExplorationTest, FromGestureToPassthrough) {
1305 SwitchTouchExplorationMode(true); 1334 SwitchTouchExplorationMode(true);
1306 EXPECT_FALSE(IsInTouchToMouseMode()); 1335 EXPECT_FALSE(IsInTouchToMouseMode());
1307 EXPECT_FALSE(IsInGestureInProgressState()); 1336 EXPECT_FALSE(IsInGestureInProgressState());
1308 1337
1309 float distance = gesture_detector_config_.touch_slop + 1; 1338 float distance = gesture_detector_config_.touch_slop + 1;
1310 ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 1), 0, Now()); 1339 ui::TouchEvent first_press(
1340 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 0, Now());
1311 generator_->Dispatch(&first_press); 1341 generator_->Dispatch(&first_press);
1312 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 1342 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1313 gfx::Point second_location(distance, 1); 1343 gfx::Point second_location(100 + distance, 200);
1314 generator_->MoveTouch(second_location); 1344 generator_->MoveTouch(second_location);
1315 EXPECT_TRUE(IsInGestureInProgressState()); 1345 EXPECT_TRUE(IsInGestureInProgressState());
1316 EXPECT_FALSE(IsInTouchToMouseMode()); 1346 EXPECT_FALSE(IsInTouchToMouseMode());
1317 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); 1347 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1318 ASSERT_EQ(0U, captured_events.size()); 1348 ASSERT_EQ(0U, captured_events.size());
1319 1349
1320 // Generate a second press that should go through as is. 1350 // Generate a second press that should go through as is.
1321 ui::TouchEvent second_press( 1351 ui::TouchEvent second_press(
1322 ui::ET_TOUCH_PRESSED, gfx::Point(20, 21), 1, Now()); 1352 ui::ET_TOUCH_PRESSED, gfx::Point(20, 21), 1, Now());
1323 generator_->Dispatch(&second_press); 1353 generator_->Dispatch(&second_press);
1324 EXPECT_FALSE(IsInGestureInProgressState()); 1354 EXPECT_FALSE(IsInGestureInProgressState());
1325 EXPECT_FALSE(IsInTouchToMouseMode()); 1355 EXPECT_FALSE(IsInTouchToMouseMode());
1326 std::vector<ui::LocatedEvent*> captured_located_events = 1356 std::vector<ui::LocatedEvent*> captured_located_events =
1327 GetCapturedLocatedEvents(); 1357 GetCapturedLocatedEvents();
1328 ASSERT_EQ(1U, captured_events.size()); 1358 ASSERT_EQ(1U, captured_events.size());
1329 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_located_events[0], &second_press); 1359 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_located_events[0], &second_press);
1330 ClearCapturedEvents(); 1360 ClearCapturedEvents();
1331 1361
1332 // The rest of the events should occur in passthrough. 1362 // The rest of the events should occur in passthrough.
1333 generator_->ReleaseTouchId(0); 1363 generator_->ReleaseTouchId(0);
1334 ASSERT_EQ(1U, captured_events.size()); 1364 ASSERT_EQ(1U, captured_events.size());
1335 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type()); 1365 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type());
1336 ClearCapturedEvents(); 1366 ClearCapturedEvents();
1337 generator_->ReleaseTouchId(1); 1367 generator_->ReleaseTouchId(1);
1338 ASSERT_EQ(0U, captured_events.size()); 1368 ASSERT_EQ(0U, captured_events.size());
1339 } 1369 }
1340 1370
1371 TEST_F(TouchExplorationTest, EnterSlideGestureState) {
1372 SwitchTouchExplorationMode(true);
1373 EXPECT_FALSE(IsInTouchToMouseMode());
1374 EXPECT_FALSE(IsInGestureInProgressState());
1375
1376 gfx::Rect window = BoundsOfRootWindowInDIP();
1377 float distance = gesture_detector_config_.touch_slop + 1;
1378 ui::TouchEvent first_press(
1379 ui::ET_TOUCH_PRESSED, gfx::Point(window.right(), 1), 0, Now());
1380 gfx::Point second_location(window.right(), 1 + distance / 2);
1381 gfx::Point third_location(window.right(), 1 + distance);
1382
1383 generator_->Dispatch(&first_press);
1384 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1385
1386 // Since we haven't moved past slop yet, we should not be in slide gesture.
1387 generator_->MoveTouch(second_location);
1388 EXPECT_FALSE(IsInTouchToMouseMode());
1389 EXPECT_FALSE(IsInGestureInProgressState());
1390 EXPECT_FALSE(IsInSlideGestureState());
1391 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1392
1393 // Once we are out of slop, we should be in slide gesture since we are along
1394 // the edge of the screen.
1395 generator_->MoveTouch(third_location);
1396 EXPECT_FALSE(IsInGestureInProgressState());
1397 EXPECT_TRUE(IsInSlideGestureState());
1398 EXPECT_FALSE(IsInTouchToMouseMode());
1399 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1400 ASSERT_EQ(0U, captured_events.size());
1401
1402 // Since we are at the right edge of the screen, but the sound timer has not
1403 // elapsed, there should have two sounds that fired and two volume
1404 // changes (one for each movement).
1405 size_t num_adjust_sounds = delegate_->NumAdjustSounds();
1406 ASSERT_EQ(2U, num_adjust_sounds);
1407 ASSERT_EQ(2U, delegate_->VolumeChanges().size());
1408
1409 // Exit out of slide gesture once touch is lifted, but not before even if the
1410 // grace period is over.
1411
1412 AdvanceSimulatedTimePastPotentialTapDelay();
1413 ASSERT_EQ(0U, captured_events.size());
1414 EXPECT_FALSE(IsInTouchToMouseMode());
1415 EXPECT_FALSE(IsInGestureInProgressState());
1416 EXPECT_TRUE(IsInSlideGestureState());
1417
1418 generator_->ReleaseTouch();
1419 ASSERT_EQ(0U, captured_events.size());
1420 EXPECT_FALSE(IsInTouchToMouseMode());
1421 EXPECT_FALSE(IsInGestureInProgressState());
1422 EXPECT_FALSE(IsInSlideGestureState());
1423 }
1424
1425 // If a press + move occurred outside the boundaries, but within the slop
1426 // boundaries and then moved into the boundaries of an edge, there still should
1427 // not be a slide gesture.
1428 TEST_F(TouchExplorationTest, AvoidEnteringSlideGesture) {
1429 SwitchTouchExplorationMode(true);
1430
1431 // DO SOMETHING TO MAKE THESE CONSTANTS ACCESSIBLE FROM ORIGINAL FILE
1432 const float kMaxDistanceFromEdge = 75;
1433 const float kSlopDistanceFromEdge = kMaxDistanceFromEdge + 40;
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,
1439 gfx::Point(window.right() - kSlopDistanceFromEdge, 1),
1440 0,
1441 Now());
1442 gfx::Point out_of_slop(window.right() - kSlopDistanceFromEdge + distance, 1);
1443 gfx::Point into_boundaries(window.right() - kMaxDistanceFromEdge / 2, 1);
1444
1445 generator_->Dispatch(&first_press);
1446 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1447
1448 generator_->MoveTouch(out_of_slop);
1449 EXPECT_FALSE(IsInTouchToMouseMode());
1450 EXPECT_TRUE(IsInGestureInProgressState());
1451 EXPECT_FALSE(IsInSlideGestureState());
1452 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1453
1454 // Since we did not start moving while in the boundaries, we should not be in
1455 // slide gestures.
1456 generator_->MoveTouch(into_boundaries);
1457 EXPECT_TRUE(IsInGestureInProgressState());
1458 EXPECT_FALSE(IsInSlideGestureState());
1459 EXPECT_FALSE(IsInTouchToMouseMode());
1460 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1461 ASSERT_EQ(0U, captured_events.size());
1462
1463 generator_->ReleaseTouch();
1464 }
1465
1466 // If the slide gesture begins within the boundaries and then moves
1467 // SlopDistanceFromEdge there should still be a sound change. If the finger
1468 // moves into the center screen, there should no longer be a sound change but it
1469 // should still be in slide gesture. If the finger moves back into the edges
1470 // without lifting, it should start changing sound again.
1471 TEST_F(TouchExplorationTest, TestingBoundaries) {
1472 SwitchTouchExplorationMode(true);
1473
1474 const float kMaxDistanceFromEdge = 75;
1475 const float kSlopDistanceFromEdge = kMaxDistanceFromEdge + 40;
1476
1477 gfx::Rect window = BoundsOfRootWindowInDIP();
1478 gfx::Point initial_press(window.right() - kMaxDistanceFromEdge / 2, 1);
1479 ui::TouchEvent first_press(
1480 ui::ET_TOUCH_PRESSED,
1481 initial_press,
1482 0,
1483 Now());
1484 gfx::Point touch_move(initial_press.x() + gesture_detector_config_.touch_slop,
1485 1);
1486 gfx::Point into_slop_boundaries(window.right() - kSlopDistanceFromEdge / 2,
1487 1);
1488 gfx::Point center_screen(window.right() / 2, window.bottom() / 2);
1489
1490 generator_->Dispatch(&first_press);
1491 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1492
1493 generator_->MoveTouch(touch_move);
1494 EXPECT_FALSE(IsInTouchToMouseMode());
1495 EXPECT_FALSE(IsInGestureInProgressState());
1496 EXPECT_FALSE(IsInSlideGestureState());
1497 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
1498
1499 // Move the touch into slop boundaries. It should stil be in slide gestures
1500 // and adjust the volume.
1501 generator_->MoveTouch(into_slop_boundaries);
1502 EXPECT_FALSE(IsInGestureInProgressState());
1503 EXPECT_TRUE(IsInSlideGestureState());
1504 EXPECT_FALSE(IsInTouchToMouseMode());
1505
1506 // The sound is rate limiting so it only activates every 150ms.
1507 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1508
1509 size_t num_adjust_sounds = delegate_->NumAdjustSounds();
1510 ASSERT_EQ(2U, num_adjust_sounds);
1511 ASSERT_EQ(2U, delegate_->VolumeChanges().size());
1512
1513 // Move the touch into the center of the window. It should still be in slide
1514 // gestures, but there should not be anymore volume adjustments.
1515 generator_->MoveTouch(center_screen);
1516 EXPECT_FALSE(IsInGestureInProgressState());
1517 EXPECT_TRUE(IsInSlideGestureState());
1518 EXPECT_FALSE(IsInTouchToMouseMode());
1519
1520 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1521 num_adjust_sounds = delegate_->NumAdjustSounds();
1522 ASSERT_EQ(2U, num_adjust_sounds);
1523 ASSERT_EQ(2U, delegate_->VolumeChanges().size());
1524
1525 // Move the touch back into slop edge distance and volume should be changing
1526 // again.
1527 generator_->MoveTouch(into_slop_boundaries);
1528 EXPECT_FALSE(IsInGestureInProgressState());
1529 EXPECT_TRUE(IsInSlideGestureState());
1530 EXPECT_FALSE(IsInTouchToMouseMode());
1531
1532 generator_->MoveTouch(
1533 gfx::Point(into_slop_boundaries.x() + gesture_detector_config_.touch_slop,
1534 into_slop_boundaries.y()));
1535 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
1536
1537 num_adjust_sounds = delegate_->NumAdjustSounds();
1538 ASSERT_EQ(3U, num_adjust_sounds);
1539 ASSERT_EQ(3U, delegate_->VolumeChanges().size());
1540
1541 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1542 ASSERT_EQ(0U, captured_events.size());
1543
1544 generator_->ReleaseTouch();
1545 }
1546
1547 // Even if the gesture starts within bounds, if it has not moved past slop
1548 // within the grace period, it should go to touch exploration.
1549 TEST_F(TouchExplorationTest, InBoundariesTouchExploration) {
1550 SwitchTouchExplorationMode(true);
1551
1552 const float kMaxDistanceFromEdge = 75;
1553
1554 gfx::Rect window = BoundsOfRootWindowInDIP();
1555 gfx::Point initial_press(window.right() - kMaxDistanceFromEdge / 2, 1);
1556 ui::TouchEvent first_press(
1557 ui::ET_TOUCH_PRESSED,
1558 initial_press,
1559 0,
1560 Now());
1561 generator_->Dispatch(&first_press);
1562 EXPECT_FALSE(IsInGestureInProgressState());
1563 EXPECT_FALSE(IsInSlideGestureState());
1564 EXPECT_FALSE(IsInTouchToMouseMode());
1565
1566 AdvanceSimulatedTimePastTapDelay();
1567 EXPECT_FALSE(IsInGestureInProgressState());
1568 EXPECT_FALSE(IsInSlideGestureState());
1569 EXPECT_TRUE(IsInTouchToMouseMode());
1570 }
1571
1341 } // namespace ui 1572 } // namespace ui
OLDNEW
« ui/chromeos/touch_exploration_controller.h ('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