| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/events/gesture_detection/motion_event_buffer.h" | 10 #include "ui/events/gesture_detection/motion_event_buffer.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 base::TimeTicks max_event_time = | 171 base::TimeTicks max_event_time = |
| 172 event_time + base::TimeDelta::FromSecondsD(0.5f); | 172 event_time + base::TimeDelta::FromSecondsD(0.5f); |
| 173 const size_t min_expected_events = | 173 const size_t min_expected_events = |
| 174 static_cast<size_t>((max_event_time - flush_time) / | 174 static_cast<size_t>((max_event_time - flush_time) / |
| 175 std::max(event_time_delta, flush_time_delta)); | 175 std::max(event_time_delta, flush_time_delta)); |
| 176 | 176 |
| 177 MotionEventBuffer buffer(this, true); | 177 MotionEventBuffer buffer(this, true); |
| 178 | 178 |
| 179 gfx::Vector2dF velocity(33.f, -11.f); | 179 gfx::Vector2dF velocity(33.f, -11.f); |
| 180 gfx::PointF position(17.f, 42.f); | 180 gfx::PointF position(17.f, 42.f); |
| 181 scoped_ptr<MotionEvent> last_flushed_event; | 181 std::unique_ptr<MotionEvent> last_flushed_event; |
| 182 size_t events = 0; | 182 size_t events = 0; |
| 183 float last_dx = 0, last_dy = 0; | 183 float last_dx = 0, last_dy = 0; |
| 184 base::TimeDelta last_dt; | 184 base::TimeDelta last_dt; |
| 185 while (event_time < max_event_time) { | 185 while (event_time < max_event_time) { |
| 186 position += gfx::ScaleVector2d(velocity, event_time_delta.InSecondsF()); | 186 position += gfx::ScaleVector2d(velocity, event_time_delta.InSecondsF()); |
| 187 MockMotionEvent move( | 187 MockMotionEvent move( |
| 188 MotionEvent::ACTION_MOVE, event_time, position.x(), position.y()); | 188 MotionEvent::ACTION_MOVE, event_time, position.x(), position.y()); |
| 189 buffer.OnMotionEvent(move); | 189 buffer.OnMotionEvent(move); |
| 190 event_time += event_time_delta; | 190 event_time += event_time_delta; |
| 191 | 191 |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 TEST_F(MotionEventBufferTest, Resampling150to60) { | 866 TEST_F(MotionEventBufferTest, Resampling150to60) { |
| 867 base::TimeDelta flush_time_delta = | 867 base::TimeDelta flush_time_delta = |
| 868 base::TimeDelta::FromMillisecondsD(1000. / 60.); | 868 base::TimeDelta::FromMillisecondsD(1000. / 60.); |
| 869 base::TimeDelta event_time_delta = | 869 base::TimeDelta event_time_delta = |
| 870 base::TimeDelta::FromMillisecondsD(1000. / 150.); | 870 base::TimeDelta::FromMillisecondsD(1000. / 150.); |
| 871 | 871 |
| 872 RunResample(flush_time_delta, event_time_delta); | 872 RunResample(flush_time_delta, event_time_delta); |
| 873 } | 873 } |
| 874 | 874 |
| 875 } // namespace ui | 875 } // namespace ui |
| OLD | NEW |