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

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/renderer_host/input/synthetic_gesture.h" 8 #include "content/browser/renderer_host/input/synthetic_gesture.h"
9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" 9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 void DispatchInputEventToPlatform(const WebInputEvent& event) override { 157 void DispatchInputEventToPlatform(const WebInputEvent& event) override {
158 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type)); 158 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
159 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); 159 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
160 ASSERT_EQ(touch_event.touchesLength, 1U); 160 ASSERT_EQ(touch_event.touchesLength, 1U);
161 161
162 if (!started_) { 162 if (!started_) {
163 ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart); 163 ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart);
164 start_.SetPoint(touch_event.touches[0].position.x, 164 start_.SetPoint(touch_event.touches[0].position.x,
165 touch_event.touches[0].position.y); 165 touch_event.touches[0].position.y);
166 last_touch_point_ = start_; 166 last_touch_point_ = gfx::PointF(start_);
167 started_ = true; 167 started_ = true;
168 } else { 168 } else {
169 ASSERT_NE(touch_event.type, WebInputEvent::TouchStart); 169 ASSERT_NE(touch_event.type, WebInputEvent::TouchStart);
170 ASSERT_NE(touch_event.type, WebInputEvent::TouchCancel); 170 ASSERT_NE(touch_event.type, WebInputEvent::TouchCancel);
171 171
172 gfx::PointF touch_point(touch_event.touches[0].position.x, 172 gfx::PointF touch_point(touch_event.touches[0].position.x,
173 touch_event.touches[0].position.y); 173 touch_event.touches[0].position.y);
174 gfx::Vector2dF delta = touch_point - last_touch_point_; 174 gfx::Vector2dF delta = touch_point - last_touch_point_;
175 total_abs_move_distance_length_ += delta.Length(); 175 total_abs_move_distance_length_ += delta.Length();
176 176
177 if (touch_event.type == WebInputEvent::TouchEnd) 177 if (touch_event.type == WebInputEvent::TouchEnd)
178 start_to_end_distance_ = touch_point - start_; 178 start_to_end_distance_ = touch_point - gfx::PointF(start_);
179 179
180 last_touch_point_ = touch_point; 180 last_touch_point_ = touch_point;
181 } 181 }
182 } 182 }
183 183
184 protected: 184 protected:
185 gfx::Point start_; 185 gfx::Point start_;
186 gfx::PointF last_touch_point_; 186 gfx::PointF last_touch_point_;
187 bool started_; 187 bool started_;
188 }; 188 };
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 EXPECT_TRUE(tap_target->GestureFinished()); 1416 EXPECT_TRUE(tap_target->GestureFinished());
1417 EXPECT_EQ(tap_target->position(), params.position); 1417 EXPECT_EQ(tap_target->position(), params.position);
1418 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); 1418 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
1419 EXPECT_GE(GetTotalTime(), 1419 EXPECT_GE(GetTotalTime(),
1420 base::TimeDelta::FromMilliseconds(params.duration_ms)); 1420 base::TimeDelta::FromMilliseconds(params.duration_ms));
1421 } 1421 }
1422 1422
1423 } // namespace 1423 } // namespace
1424 1424
1425 } // namespace content 1425 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698