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

Unified Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 2378773011: Only exclude workarea from touch-exploration with active shell-surface (Closed)
Patch Set: CL comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
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..0c7c4601cf7c4db5715987fa668f94db00dea230 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,83 @@ 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);
+
+ // Motion starting in exclusion bounds is passed-through unchanged.
+ {
+ 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
« 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