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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/events/gesture_detection/motion_event_buffer.h" | 9 #include "ui/events/gesture_detection/motion_event_buffer.h" |
10 #include "ui/events/test/mock_motion_event.h" | 10 #include "ui/events/test/mock_motion_event.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #define EXPECT_EVENT_HISTORY_EQ(A, I, B) \ | 34 #define EXPECT_EVENT_HISTORY_EQ(A, I, B) \ |
35 { \ | 35 { \ |
36 SCOPED_TRACE(testing::Message()); \ | 36 SCOPED_TRACE(testing::Message()); \ |
37 ExpectEqualsHistoryIndex((A), (I), (B)); \ | 37 ExpectEqualsHistoryIndex((A), (I), (B)); \ |
38 } | 38 } |
39 | 39 |
40 class MotionEventBufferTest : public testing::Test, | 40 class MotionEventBufferTest : public testing::Test, |
41 public MotionEventBufferClient { | 41 public MotionEventBufferClient { |
42 public: | 42 public: |
43 MotionEventBufferTest() : needs_flush_(false) {} | 43 MotionEventBufferTest() : needs_flush_(false) {} |
44 virtual ~MotionEventBufferTest() {} | 44 ~MotionEventBufferTest() override {} |
45 | 45 |
46 // MotionEventBufferClient implementation. | 46 // MotionEventBufferClient implementation. |
47 virtual void ForwardMotionEvent(const MotionEvent& event) override { | 47 void ForwardMotionEvent(const MotionEvent& event) override { |
48 forwarded_events_.push_back(event.Clone().release()); | 48 forwarded_events_.push_back(event.Clone().release()); |
49 } | 49 } |
50 | 50 |
51 virtual void SetNeedsFlush() override { needs_flush_ = true; } | 51 void SetNeedsFlush() override { needs_flush_ = true; } |
52 | 52 |
53 bool GetAndResetNeedsFlush() { | 53 bool GetAndResetNeedsFlush() { |
54 bool needs_flush = needs_flush_; | 54 bool needs_flush = needs_flush_; |
55 needs_flush_ = false; | 55 needs_flush_ = false; |
56 return needs_flush; | 56 return needs_flush; |
57 } | 57 } |
58 | 58 |
59 ScopedVector<MotionEvent> GetAndResetForwardedEvents() { | 59 ScopedVector<MotionEvent> GetAndResetForwardedEvents() { |
60 ScopedVector<MotionEvent> forwarded_events; | 60 ScopedVector<MotionEvent> forwarded_events; |
61 forwarded_events.swap(forwarded_events_); | 61 forwarded_events.swap(forwarded_events_); |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 TEST_F(MotionEventBufferTest, Resampling150to60) { | 862 TEST_F(MotionEventBufferTest, Resampling150to60) { |
863 base::TimeDelta flush_time_delta = | 863 base::TimeDelta flush_time_delta = |
864 base::TimeDelta::FromMillisecondsD(1000. / 60.); | 864 base::TimeDelta::FromMillisecondsD(1000. / 60.); |
865 base::TimeDelta event_time_delta = | 865 base::TimeDelta event_time_delta = |
866 base::TimeDelta::FromMillisecondsD(1000. / 150.); | 866 base::TimeDelta::FromMillisecondsD(1000. / 150.); |
867 | 867 |
868 RunResample(flush_time_delta, event_time_delta); | 868 RunResample(flush_time_delta, event_time_delta); |
869 } | 869 } |
870 | 870 |
871 } // namespace ui | 871 } // namespace ui |
OLD | NEW |