| 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 b00814b1eb6efc7f6d197292016f8956e693d1a7..6f75a6772fd486bd0d4c8ee9906e47536a062a5f 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 PlayEarCon() OVERRIDE {
|
| + }
|
|
|
| const std::vector<float> VolumeChanges() { return volume_changes_; }
|
| const size_t NumAdjustSounds() { return num_times_adjust_sound_played_; }
|
| @@ -105,6 +107,12 @@ class TouchExplorationControllerTestApi {
|
| touch_exploration_controller_->OnTapTimerFired();
|
| }
|
|
|
| + void CallLongPressTimerNowForTesting() {
|
| + DCHECK(touch_exploration_controller_->long_press_timer_.IsRunning());
|
| + touch_exploration_controller_->long_press_timer_.Stop();
|
| + touch_exploration_controller_->OnLongPressTimerFired();
|
| + }
|
| +
|
| void CallTapTimerNowIfRunningForTesting() {
|
| if (touch_exploration_controller_->tap_timer_.IsRunning()) {
|
| touch_exploration_controller_->tap_timer_.Stop();
|
| @@ -133,6 +141,11 @@ class TouchExplorationControllerTestApi {
|
| touch_exploration_controller_->SLIDE_GESTURE;
|
| }
|
|
|
| + bool IsInCornerPassthroughStateForTesting() const {
|
| + return touch_exploration_controller_->state_ ==
|
| + touch_exploration_controller_->CORNER_PASSTHROUGH;
|
| + }
|
| +
|
| gfx::Rect BoundsOfRootWindowInDIPForTesting() const {
|
| return touch_exploration_controller_->root_window_->GetBoundsInScreen();
|
| }
|
| @@ -234,6 +247,11 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
|
| touch_exploration_controller_->CallTapTimerNowForTesting();
|
| }
|
|
|
| + void AdvanceSimulatedTimePastLongPressDelay() {
|
| + simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000));
|
| + touch_exploration_controller_->CallLongPressTimerNowForTesting();
|
| + }
|
| +
|
| void AdvanceSimulatedTimePastPotentialTapDelay() {
|
| simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000));
|
| touch_exploration_controller_->CallTapTimerNowIfRunningForTesting();
|
| @@ -275,11 +293,50 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
|
| generator_->Dispatch(&second_touch_press);
|
| }
|
|
|
| + // Checks that Corner Passthrough is working. Assumes that corner is the
|
| + // bottom
|
| + // left corner or the bottom right corner.
|
| + void AssertCornerPassthroughWorking(gfx::Point corner,
|
| + gfx::Point passthrough) {
|
| + ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, corner, 0, Now());
|
| + generator_->Dispatch(&first_press);
|
| +
|
| + AdvanceSimulatedTimePastLongPressDelay();
|
| + EXPECT_FALSE(IsInGestureInProgressState());
|
| + EXPECT_FALSE(IsInSlideGestureState());
|
| + EXPECT_FALSE(IsInTouchToMouseMode());
|
| + EXPECT_TRUE(IsInCornerPassthroughState());
|
| +
|
| + // The following events should be passed through.
|
| + ui::TouchEvent passthrough_press(
|
| + ui::ET_TOUCH_PRESSED, passthrough, 1, Now());
|
| + generator_->Dispatch(&passthrough_press);
|
| + generator_->ReleaseTouchId(1);
|
| + generator_->PressTouchId(1);
|
| + EXPECT_FALSE(IsInGestureInProgressState());
|
| + EXPECT_FALSE(IsInSlideGestureState());
|
| + EXPECT_TRUE(IsInCornerPassthroughState());
|
| +
|
| + std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
|
| + ASSERT_EQ(3U, captured_events.size());
|
| + EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
|
| + EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
|
| + EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type());
|
| + generator_->ReleaseTouchId(1);
|
| + ClearCapturedEvents();
|
| +
|
| + generator_->ReleaseTouchId(0);
|
| + captured_events = GetCapturedLocatedEvents();
|
| + ASSERT_EQ(0U, captured_events.size());
|
| + EXPECT_FALSE(IsInTouchToMouseMode());
|
| + EXPECT_FALSE(IsInCornerPassthroughState());
|
| + ClearCapturedEvents();
|
| + }
|
| +
|
| bool IsInTouchToMouseMode() {
|
| aura::client::CursorClient* cursor_client =
|
| aura::client::GetCursorClient(root_window());
|
| - return cursor_client &&
|
| - cursor_client->IsMouseEventsEnabled() &&
|
| + return cursor_client && cursor_client->IsMouseEventsEnabled() &&
|
| !cursor_client->IsCursorVisible();
|
| }
|
|
|
| @@ -296,11 +353,16 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
|
| return touch_exploration_controller_->IsInSlideGestureStateForTesting();
|
| }
|
|
|
| + bool IsInCornerPassthroughState() {
|
| + return touch_exploration_controller_
|
| + ->IsInCornerPassthroughStateForTesting();
|
| + }
|
| +
|
| gfx::Rect BoundsOfRootWindowInDIP() {
|
| return touch_exploration_controller_->BoundsOfRootWindowInDIPForTesting();
|
| }
|
|
|
| - float GetMaxDistanceFromEdge() const{
|
| + float GetMaxDistanceFromEdge() const {
|
| return touch_exploration_controller_->GetMaxDistanceFromEdge();
|
| }
|
|
|
| @@ -1634,4 +1696,26 @@ TEST_F(TouchExplorationTest, InBoundariesTouchExploration) {
|
| EXPECT_TRUE(IsInTouchToMouseMode());
|
| }
|
|
|
| +// Corner passthrough should turn on if the user first holds down on either the
|
| +// right or left corner past a delay and then places a finger anywhere else on
|
| +// the screen.
|
| +TEST_F(TouchExplorationTest, ActivateLeftCornerPassthrough) {
|
| + SwitchTouchExplorationMode(true);
|
| +
|
| + gfx::Rect window = BoundsOfRootWindowInDIP();
|
| + gfx::Point left_corner(10, window.bottom() - GetMaxDistanceFromEdge() / 2);
|
| + gfx::Point passthrough(window.right() / 2, window.bottom() / 2);
|
| + AssertCornerPassthroughWorking(left_corner, passthrough);
|
| +}
|
| +
|
| +TEST_F(TouchExplorationTest, ActivateRightCornerPassthrough) {
|
| + SwitchTouchExplorationMode(true);
|
| +
|
| + gfx::Rect window = BoundsOfRootWindowInDIP();
|
| + gfx::Point right_corner(window.right() - GetMaxDistanceFromEdge() / 2,
|
| + window.bottom() - GetMaxDistanceFromEdge() / 2);
|
| + gfx::Point passthrough(window.right() / 2, window.bottom() / 2);
|
| + AssertCornerPassthroughWorking(right_corner, passthrough);
|
| +}
|
| +
|
| } // namespace ui
|
|
|