summaryrefslogtreecommitdiffstats
path: root/ui/chromeos
diff options
context:
space:
mode:
authortdresser@chromium.org <tdresser@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-28 21:27:04 +0000
committertdresser@chromium.org <tdresser@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-28 21:27:04 +0000
commitc9f38d1df2bf4eedf86ba1c9ce54fc1e7316dab2 (patch)
tree8c460fe571f80573e490e7147aaf995ca19af5b4 /ui/chromeos
parent31339076da909609961bb8cdac546fc2646cca4d (diff)
downloadchromium_src-c9f38d1df2bf4eedf86ba1c9ce54fc1e7316dab2.zip
chromium_src-c9f38d1df2bf4eedf86ba1c9ce54fc1e7316dab2.tar.gz
chromium_src-c9f38d1df2bf4eedf86ba1c9ce54fc1e7316dab2.tar.bz2
Fix Touch Exploration tests so they don't break eager gesture detection.
Eager gesture detection is a little bit stricter about requiring a valid event stream. The touch exploration tests give the gesture detector an invalid event stream in a few places. BUG=398106 Review URL: https://codereview.chromium.org/428673002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/chromeos')
-rw-r--r--ui/chromeos/touch_exploration_controller.cc7
-rw-r--r--ui/chromeos/touch_exploration_controller.h4
-rw-r--r--ui/chromeos/touch_exploration_controller_unittest.cc24
3 files changed, 13 insertions, 22 deletions
diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc
index 166db54..01e3d54 100644
--- a/ui/chromeos/touch_exploration_controller.cc
+++ b/ui/chromeos/touch_exploration_controller.cc
@@ -33,7 +33,6 @@ TouchExplorationController::TouchExplorationController(
: root_window_(root_window),
delegate_(delegate),
state_(NO_FINGERS_DOWN),
- event_handler_for_testing_(NULL),
gesture_provider_(this),
prev_state_(NO_FINGERS_DOWN),
VLOG_on_(true) {
@@ -595,13 +594,13 @@ void TouchExplorationController::OnTapTimerFired() {
case GESTURE_IN_PROGRESS:
// Discard any pending gestures.
delete gesture_provider_.GetAndResetPendingGestures();
- EnterTouchToMouseMode();
state_ = TOUCH_EXPLORATION;
VLOG_STATE();
break;
default:
return;
}
+ EnterTouchToMouseMode();
scoped_ptr<ui::Event> mouse_move =
CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags());
DispatchEvent(mouse_move.get());
@@ -609,10 +608,6 @@ void TouchExplorationController::OnTapTimerFired() {
}
void TouchExplorationController::DispatchEvent(ui::Event* event) {
- if (event_handler_for_testing_) {
- event_handler_for_testing_->OnEvent(event);
- return;
- }
ui::EventDispatchDetails result ALLOW_UNUSED =
root_window_->GetHost()->dispatcher()->OnEventFromSource(event);
}
diff --git a/ui/chromeos/touch_exploration_controller.h b/ui/chromeos/touch_exploration_controller.h
index 12f0bfa..8c50f3e 100644
--- a/ui/chromeos/touch_exploration_controller.h
+++ b/ui/chromeos/touch_exploration_controller.h
@@ -361,10 +361,6 @@ class UI_CHROMEOS_EXPORT TouchExplorationController
// A timer to fire an indicating sound when sliding to change volume.
base::RepeatingTimer<TouchExplorationController> sound_timer_;
- // For testing only, an event handler to use for generated events
- // outside of the normal event rewriting flow.
- ui::EventHandler* event_handler_for_testing_;
-
// A default gesture detector config, so we can share the same
// timeout and pixel slop constants.
ui::GestureDetector::Config gesture_detector_config_;
diff --git a/ui/chromeos/touch_exploration_controller_unittest.cc b/ui/chromeos/touch_exploration_controller_unittest.cc
index 0da7268..15aa868 100644
--- a/ui/chromeos/touch_exploration_controller_unittest.cc
+++ b/ui/chromeos/touch_exploration_controller_unittest.cc
@@ -112,12 +112,6 @@ class TouchExplorationControllerTestApi {
}
}
- void SetEventHandlerForTesting(
- ui::EventHandler* event_handler_for_testing) {
- touch_exploration_controller_->event_handler_for_testing_ =
- event_handler_for_testing;
- }
-
bool IsInNoFingersDownStateForTesting() const {
return touch_exploration_controller_->state_ ==
touch_exploration_controller_->NO_FINGERS_DOWN;
@@ -250,8 +244,6 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
touch_exploration_controller_.reset(
new ui::TouchExplorationControllerTestApi(
new TouchExplorationController(root_window(), &delegate_)));
- touch_exploration_controller_->SetEventHandlerForTesting(
- &event_capturer_);
cursor_client()->ShowCursor();
cursor_client()->DisableMouseEvents();
}
@@ -1107,11 +1099,19 @@ TEST_F(TouchExplorationTest, TwoToOneFingerRelaseFirst) {
// Placing three fingers should start passthrough, and all fingers should
// continue to be passed through until the last one is released.
TEST_F(TouchExplorationTest, Passthrough) {
- std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
+ SwitchTouchExplorationMode(true);
+ std::vector<ui::LocatedEvent*> captured_events;
gfx::Point first_touch_location = gfx::Point(11,12);
+ ui::TouchEvent first_touch_press(
+ ui::ET_TOUCH_PRESSED, first_touch_location, 0, Now());
+ generator_->Dispatch(&first_touch_press);
+
gfx::Point second_touch_location = gfx::Point(21, 22);
- EnterTwoToOne(first_touch_location, second_touch_location);
+ ui::TouchEvent second_touch_press(
+ ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
+ generator_->Dispatch(&second_touch_press);
+
captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(captured_events.size(), 1u);
@@ -1121,7 +1121,7 @@ TEST_F(TouchExplorationTest, Passthrough) {
generator_->Dispatch(&third_touch_press);
captured_events = GetCapturedLocatedEvents();
// Now all fingers are registered as pressed.
- ASSERT_EQ(captured_events.size(), 3u);
+ ASSERT_EQ(3u, captured_events.size());
ClearCapturedEvents();
// All fingers should be passed through.
@@ -1138,7 +1138,7 @@ TEST_F(TouchExplorationTest, Passthrough) {
generator_->Dispatch(&second_touch_first_move);
generator_->Dispatch(&third_touch_first_move);
captured_events = GetCapturedLocatedEvents();
- ASSERT_EQ(captured_events.size(), 3u);
+ ASSERT_EQ(3u, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type());
EXPECT_EQ(first_touch_location, captured_events[0]->location());
EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[1]->type());