| 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 42616f7a7e0e856fba47f262495a54c0c2d0f3bd..81dbb6c7cea6760d7ff9a7dc8dcda78a1f36e3a5 100644
|
| --- a/ui/chromeos/touch_exploration_controller_unittest.cc
|
| +++ b/ui/chromeos/touch_exploration_controller_unittest.cc
|
| @@ -180,6 +180,10 @@ class TouchExplorationControllerTestApi {
|
| touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location);
|
| }
|
|
|
| + void SetExcludeBounds(const gfx::Rect& bounds) {
|
| + touch_exploration_controller_->SetExcludeBounds(bounds);
|
| + }
|
| +
|
| private:
|
| std::unique_ptr<TouchExplorationController> touch_exploration_controller_;
|
|
|
| @@ -392,6 +396,10 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
|
| touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location);
|
| }
|
|
|
| + void SetExcludeBounds(const gfx::Rect& bounds) {
|
| + touch_exploration_controller_->SetExcludeBounds(bounds);
|
| + }
|
| +
|
| std::unique_ptr<test::EventGenerator> generator_;
|
| ui::GestureDetector::Config gesture_detector_config_;
|
| // Owned by |ui|.
|
| @@ -1819,4 +1827,99 @@ TEST_F(TouchExplorationTest, ExitEarconPlays) {
|
| }
|
| }
|
|
|
| +TEST_F(TouchExplorationTest, ExclusionArea) {
|
| + SwitchTouchExplorationMode(true);
|
| +
|
| + gfx::Rect window = BoundsOfRootWindowInDIP();
|
| + gfx::Rect exclude = window;
|
| + exclude.Inset(0, 0, 0, 30);
|
| + SetExcludeBounds(exclude);
|
| +
|
| + gfx::Point in_pt = exclude.CenterPoint();
|
| + gfx::Point in_mv_pt(in_pt.x(), (in_pt.y() + exclude.bottom()) / 2);
|
| + gfx::Point out_pt(in_pt.x(), exclude.bottom() + 20);
|
| + gfx::Point out_mv_pt(in_pt.x(), exclude.bottom() + 10);
|
| +
|
| + // Complete motion in exclusion bounds is passed-through unchanged.
|
| + {
|
| + generator_->set_current_location(in_pt);
|
| + generator_->PressTouchId(0);
|
| + AdvanceSimulatedTimePastPotentialTapDelay();
|
| + generator_->MoveTouchId(in_mv_pt, 0);
|
| + generator_->ReleaseTouchId(0);
|
| + EXPECT_TRUE(IsInNoFingersDownState());
|
| + const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
|
| + ASSERT_EQ(3U, captured_events.size());
|
| + EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
|
| + EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[1]->type());
|
| + EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[2]->type());
|
| + ClearCapturedEvents();
|
| + }
|
| +
|
| + // Motion starting in exclusion bounds is fully passed-through.
|
| + {
|
| + generator_->set_current_location(in_pt);
|
| + generator_->PressTouchId(0);
|
| + AdvanceSimulatedTimePastPotentialTapDelay();
|
| + generator_->MoveTouchId(out_mv_pt, 0);
|
| + generator_->ReleaseTouchId(0);
|
| + EXPECT_TRUE(IsInNoFingersDownState());
|
| + const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
|
| + ASSERT_EQ(3U, captured_events.size());
|
| + EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
|
| + EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[1]->type());
|
| + EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[2]->type());
|
| + ClearCapturedEvents();
|
| + }
|
| +
|
| + // Complete motion outside exclusion is rewritten.
|
| + {
|
| + generator_->set_current_location(out_pt);
|
| + generator_->PressTouchId(0);
|
| + AdvanceSimulatedTimePastTapDelay();
|
| + generator_->MoveTouchId(out_mv_pt, 0);
|
| + generator_->ReleaseTouchId(0);
|
| + AdvanceSimulatedTimePastTapDelay();
|
| + EXPECT_TRUE(IsInNoFingersDownState());
|
| + const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
|
| + ASSERT_EQ(3U, captured_events.size());
|
| + for (ui::Event* e : captured_events) {
|
| + EXPECT_EQ(ui::ET_MOUSE_MOVED, e->type());
|
| + }
|
| + ClearCapturedEvents();
|
| + }
|
| +
|
| + // For a motion starting outside: outside events are rewritten, inside
|
| + // events are discarded unless they end the motion.
|
| + {
|
| + // finger 0 down outside, moves inside.
|
| + generator_->set_current_location(out_pt);
|
| + generator_->PressTouchId(0);
|
| + AdvanceSimulatedTimePastTapDelay();
|
| + generator_->MoveTouchId(out_mv_pt, 0);
|
| + generator_->MoveTouchId(in_mv_pt, 0);
|
| + ASSERT_EQ(2U, GetCapturedEvents().size());
|
| + for (ui::Event* e : GetCapturedEvents()) {
|
| + EXPECT_EQ(ui::ET_MOUSE_MOVED, e->type());
|
| + }
|
| + ClearCapturedEvents();
|
| +
|
| + // finger 1 down inside, moves outside
|
| + generator_->set_current_location(in_pt);
|
| + generator_->PressTouchId(1);
|
| + generator_->MoveTouchId(out_mv_pt, 1);
|
| + generator_->ReleaseTouchId(1);
|
| + ASSERT_EQ(0U, GetCapturedEvents().size());
|
| + EXPECT_FALSE(IsInNoFingersDownState());
|
| +
|
| + generator_->ReleaseTouchId(0);
|
| + AdvanceSimulatedTimePastTapDelay();
|
| + EXPECT_TRUE(IsInNoFingersDownState());
|
| +
|
| + ASSERT_EQ(1U, GetCapturedEvents().size());
|
| + EXPECT_EQ(ui::ET_MOUSE_MOVED, GetCapturedEvents()[0]->type());
|
| + ClearCapturedEvents();
|
| + }
|
| +}
|
| +
|
| } // namespace ui
|
|
|