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 ffe4d090b8b3ce8779e8785a3c7ba77a58577ead..651f45ca03d82a012d624e1908f415fd762d83f9 100644 |
--- a/ui/chromeos/touch_exploration_controller_unittest.cc |
+++ b/ui/chromeos/touch_exploration_controller_unittest.cc |
@@ -81,6 +81,8 @@ class MockTouchExplorationControllerDelegate |
virtual void SetOutputLevel(int volume) OVERRIDE { |
volume_changes_.push_back(volume); |
} |
+ virtual void SilenceSpokenFeedback() OVERRIDE { |
+ } |
const std::vector<float> VolumeChanges() { return volume_changes_; } |
const size_t NumAdjustSounds() { return num_times_adjust_sound_played_; } |
@@ -127,6 +129,11 @@ class TouchExplorationControllerTestApi { |
touch_exploration_controller_->SLIDE_GESTURE; |
} |
+ bool IsInTwoFingerTapStateForTesting() const { |
+ return touch_exploration_controller_->state_ == |
+ touch_exploration_controller_->TWO_FINGER_TAP; |
+ } |
+ |
gfx::Rect BoundsOfRootWindowInDIPForTesting() const { |
return touch_exploration_controller_->root_window_->GetBoundsInScreen(); |
} |
@@ -287,6 +294,10 @@ class TouchExplorationTest : public aura::test::AuraTestBase { |
return touch_exploration_controller_->IsInSlideGestureStateForTesting(); |
} |
+ bool IsInTwoFingerTapState() { |
+ return touch_exploration_controller_->IsInTwoFingerTapStateForTesting(); |
+ } |
+ |
gfx::Rect BoundsOfRootWindowInDIP() { |
return touch_exploration_controller_->BoundsOfRootWindowInDIPForTesting(); |
} |
@@ -1527,4 +1538,76 @@ TEST_F(TouchExplorationTest, InBoundariesTouchExploration) { |
EXPECT_TRUE(IsInTouchToMouseMode()); |
} |
+TEST_F(TouchExplorationTest, TwoFingerTap) { |
+ SwitchTouchExplorationMode(true); |
+ |
+ generator_->PressTouchId(1); |
+ EXPECT_FALSE(IsInTwoFingerTapState()); |
+ |
+ generator_->PressTouchId(2); |
+ EXPECT_TRUE(IsInTwoFingerTapState()); |
+ |
+ const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); |
+ ASSERT_EQ(0U, captured_events.size()); |
+ |
+ generator_->ReleaseTouchId(1); |
+ generator_->ReleaseTouchId(2); |
+ |
+ // Two key events should have been sent to silence the feedback. |
+ ASSERT_EQ(2U, captured_events.size()); |
+} |
+ |
+TEST_F(TouchExplorationTest, TwoFingerTapWithDelay) { |
+ SwitchTouchExplorationMode(true); |
+ |
+ generator_->PressTouchId(1); |
+ EXPECT_FALSE(IsInTwoFingerTapState()); |
+ |
+ // If the second finger is placed before the delay, then a two finger tap is |
+ // still sent. |
+ simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); |
+ |
+ generator_->PressTouchId(2); |
+ EXPECT_TRUE(IsInTwoFingerTapState()); |
+ |
+ const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); |
+ ASSERT_EQ(0U, captured_events.size()); |
+ |
+ generator_->ReleaseTouchId(1); |
+ generator_->ReleaseTouchId(2); |
+ |
+ // Two key events should have been sent to silence the feedback. |
+ ASSERT_EQ(2U, captured_events.size()); |
+ ClearCapturedEvents(); |
+ |
+ generator_->PressTouchId(1); |
+ EXPECT_FALSE(IsInTwoFingerTapState()); |
+ |
+ // If the second finger is placed after the delay, then a two finger tap is |
+ // not made. |
+ simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(100)); |
+ |
+ generator_->PressTouchId(2); |
+ EXPECT_FALSE(IsInTwoFingerTapState()); |
+ |
+ ASSERT_EQ(0U, captured_events.size()); |
+} |
+ |
+TEST_F(TouchExplorationTest, TwoFingerTapAndHold) { |
+ SwitchTouchExplorationMode(true); |
+ |
+ generator_->PressTouchId(1); |
+ EXPECT_FALSE(IsInTwoFingerTapState()); |
+ |
+ generator_->PressTouchId(2); |
+ EXPECT_TRUE(IsInTwoFingerTapState()); |
+ |
+ const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); |
+ ASSERT_EQ(0U, captured_events.size()); |
+ |
+ AdvanceSimulatedTimePastTapDelay(); |
+ // Since the tap delay has elapsed, it should no longer be in two finger tap. |
+ EXPECT_FALSE(IsInTwoFingerTapState()); |
+} |
+ |
} // namespace ui |