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

Side by Side Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 2880043002: Implement touch exploration touch typing (Closed)
Patch Set: Remove observer. Created 3 years, 6 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 <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 184
185 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) { 185 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) {
186 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location); 186 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location);
187 } 187 }
188 188
189 void SetExcludeBounds(const gfx::Rect& bounds) { 189 void SetExcludeBounds(const gfx::Rect& bounds) {
190 touch_exploration_controller_->SetExcludeBounds(bounds); 190 touch_exploration_controller_->SetExcludeBounds(bounds);
191 } 191 }
192 192
193 void SetLiftActivationBounds(const gfx::Rect& bounds) {
194 touch_exploration_controller_->SetLiftActivationBounds(bounds);
195 }
196
193 private: 197 private:
194 std::unique_ptr<TouchExplorationController> touch_exploration_controller_; 198 std::unique_ptr<TouchExplorationController> touch_exploration_controller_;
195 199
196 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi); 200 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi);
197 }; 201 };
198 202
199 class TouchExplorationTest : public aura::test::AuraTestBase { 203 class TouchExplorationTest : public aura::test::AuraTestBase {
200 public: 204 public:
201 TouchExplorationTest() : simulated_clock_(nullptr) {} 205 TouchExplorationTest() : simulated_clock_(nullptr) {}
202 ~TouchExplorationTest() override {} 206 ~TouchExplorationTest() override {}
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 base::TimeTicks Now() { return ui::EventTimeForNow(); } 410 base::TimeTicks Now() { return ui::EventTimeForNow(); }
407 411
408 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) { 412 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) {
409 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location); 413 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location);
410 } 414 }
411 415
412 void SetExcludeBounds(const gfx::Rect& bounds) { 416 void SetExcludeBounds(const gfx::Rect& bounds) {
413 touch_exploration_controller_->SetExcludeBounds(bounds); 417 touch_exploration_controller_->SetExcludeBounds(bounds);
414 } 418 }
415 419
420 void SetLiftActivationBounds(const gfx::Rect& bounds) {
421 touch_exploration_controller_->SetLiftActivationBounds(bounds);
422 }
423
416 std::unique_ptr<test::EventGenerator> generator_; 424 std::unique_ptr<test::EventGenerator> generator_;
417 ui::GestureDetector::Config gesture_detector_config_; 425 ui::GestureDetector::Config gesture_detector_config_;
418 // Owned by |ui|. 426 // Owned by |ui|.
419 base::SimpleTestTickClock* simulated_clock_; 427 base::SimpleTestTickClock* simulated_clock_;
420 MockTouchExplorationControllerDelegate delegate_; 428 MockTouchExplorationControllerDelegate delegate_;
421 429
422 private: 430 private:
423 EventCapturer event_capturer_; 431 EventCapturer event_capturer_;
424 std::unique_ptr<TouchExplorationControllerTestApi> 432 std::unique_ptr<TouchExplorationControllerTestApi>
425 touch_exploration_controller_; 433 touch_exploration_controller_;
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 generator_->ReleaseTouchId(0); 1977 generator_->ReleaseTouchId(0);
1970 AdvanceSimulatedTimePastTapDelay(); 1978 AdvanceSimulatedTimePastTapDelay();
1971 EXPECT_TRUE(IsInNoFingersDownState()); 1979 EXPECT_TRUE(IsInNoFingersDownState());
1972 1980
1973 ASSERT_EQ(1U, GetCapturedEvents().size()); 1981 ASSERT_EQ(1U, GetCapturedEvents().size());
1974 EXPECT_EQ(ui::ET_MOUSE_MOVED, GetCapturedEvents()[0]->type()); 1982 EXPECT_EQ(ui::ET_MOUSE_MOVED, GetCapturedEvents()[0]->type());
1975 ClearCapturedEvents(); 1983 ClearCapturedEvents();
1976 } 1984 }
1977 } 1985 }
1978 1986
1987 TEST_F(TouchExplorationTest, SingleTapInLiftActivationArea) {
1988 SwitchTouchExplorationMode(true);
1989
1990 gfx::Rect window = BoundsOfRootWindowInDIP();
1991 gfx::Rect lift_activation = window;
1992 lift_activation.Inset(0, 0, 0, 30);
1993 SetLiftActivationBounds(lift_activation);
1994
1995 // Tap at one location, and get tap and mouse move events.
1996 gfx::Point tap_location = lift_activation.CenterPoint();
1997
1998 // The user has to have previously selected something.
1999 SetTouchAccessibilityAnchorPoint(tap_location);
2000
2001 generator_->set_current_location(tap_location);
2002 generator_->PressTouchId(1);
2003 generator_->ReleaseTouchId(1);
2004 AdvanceSimulatedTimePastTapDelay();
2005
2006 const EventList& captured_events = GetCapturedEvents();
2007 ASSERT_EQ(3U, captured_events.size());
2008 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
2009 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
2010 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[2]->type());
2011 ClearCapturedEvents();
2012
2013 gfx::Point out_tap_location(tap_location.x(), lift_activation.bottom() + 20);
2014 SetTouchAccessibilityAnchorPoint(out_tap_location);
2015 generator_->set_current_location(out_tap_location);
2016 generator_->PressTouchId(1);
2017 generator_->ReleaseTouchId(1);
2018 AdvanceSimulatedTimePastTapDelay();
2019
2020 const EventList& out_captured_events = GetCapturedEvents();
2021 ASSERT_EQ(1U, out_captured_events.size());
2022 EXPECT_EQ(ui::ET_MOUSE_MOVED, out_captured_events[0]->type());
2023 }
2024
2025 TEST_F(TouchExplorationTest, TouchExploreLiftInLiftActivationArea) {
2026 SwitchTouchExplorationMode(true);
2027
2028 gfx::Rect window = BoundsOfRootWindowInDIP();
2029 gfx::Rect lift_activation = window;
2030 lift_activation.Inset(0, 0, 0, 30);
2031 SetLiftActivationBounds(lift_activation);
2032
2033 // Explore at one location, and get tap and mouse move events.
2034 gfx::Point tap_location = lift_activation.CenterPoint();
2035 EnterTouchExplorationModeAtLocation(tap_location);
2036 ClearCapturedEvents();
2037
2038 // A touch release should trigger a tap.
2039 ui::TouchEvent touch_explore_release(
2040 ui::ET_TOUCH_RELEASED, tap_location, Now(),
2041 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
2042 generator_->Dispatch(&touch_explore_release);
2043 AdvanceSimulatedTimePastTapDelay();
2044
2045 const EventList& captured_events = GetCapturedEvents();
2046 ASSERT_EQ(3U, captured_events.size());
2047 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
2048 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
2049 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[2]->type());
2050 ClearCapturedEvents();
2051
2052 // Touch explore inside the activation bounds, but lift outside.
2053 gfx::Point out_tap_location(tap_location.x(), lift_activation.bottom() + 20);
2054 SetTouchAccessibilityAnchorPoint(out_tap_location);
2055 EnterTouchExplorationModeAtLocation(tap_location);
2056 ClearCapturedEvents();
2057 ui::TouchEvent out_touch_explore_release(
2058 ui::ET_TOUCH_RELEASED, out_tap_location, Now(),
2059 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
2060 generator_->Dispatch(&out_touch_explore_release);
2061 AdvanceSimulatedTimePastTapDelay();
2062
2063 const EventList& out_captured_events = GetCapturedEvents();
2064 ASSERT_EQ(1U, out_captured_events.size());
2065 EXPECT_EQ(ui::ET_MOUSE_MOVED, out_captured_events[0]->type());
2066 }
2067
1979 } // namespace ui 2068 } // namespace ui
OLDNEW
« ash/ash_touch_exploration_manager_chromeos.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