| 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/memory/scoped_ptr.h" | 5 #include "ui/events/gestures/gesture_provider_aura.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 6 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/events/event_utils.h" | 11 #include "ui/events/event_utils.h" |
| 9 #include "ui/events/gestures/gesture_provider_aura.h" | |
| 10 | 12 |
| 11 namespace ui { | 13 namespace ui { |
| 12 | 14 |
| 13 class GestureProviderAuraTest : public testing::Test, | 15 class GestureProviderAuraTest : public testing::Test, |
| 14 public GestureProviderAuraClient { | 16 public GestureProviderAuraClient { |
| 15 public: | 17 public: |
| 16 GestureProviderAuraTest() {} | 18 GestureProviderAuraTest() {} |
| 17 | 19 |
| 18 ~GestureProviderAuraTest() override {} | 20 ~GestureProviderAuraTest() override {} |
| 19 | 21 |
| 20 void OnGestureEvent(GestureConsumer* raw_input_consumer, | 22 void OnGestureEvent(GestureConsumer* raw_input_consumer, |
| 21 GestureEvent* event) override {} | 23 GestureEvent* event) override {} |
| 22 | 24 |
| 23 void SetUp() override { | 25 void SetUp() override { |
| 24 consumer_.reset(new GestureConsumer()); | 26 consumer_.reset(new GestureConsumer()); |
| 25 provider_.reset(new GestureProviderAura(consumer_.get(), this)); | 27 provider_.reset(new GestureProviderAura(consumer_.get(), this)); |
| 26 } | 28 } |
| 27 | 29 |
| 28 void TearDown() override { provider_.reset(); } | 30 void TearDown() override { provider_.reset(); } |
| 29 | 31 |
| 30 GestureProviderAura* provider() { return provider_.get(); } | 32 GestureProviderAura* provider() { return provider_.get(); } |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 scoped_ptr<GestureConsumer> consumer_; | 35 std::unique_ptr<GestureConsumer> consumer_; |
| 34 scoped_ptr<GestureProviderAura> provider_; | 36 std::unique_ptr<GestureProviderAura> provider_; |
| 35 base::MessageLoopForUI message_loop_; | 37 base::MessageLoopForUI message_loop_; |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) { | 40 TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) { |
| 39 base::TimeDelta time = ui::EventTimeForNow(); | 41 base::TimeDelta time = ui::EventTimeForNow(); |
| 40 TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, time); | 42 TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, time); |
| 41 EXPECT_TRUE(provider()->OnTouchEvent(&press1)); | 43 EXPECT_TRUE(provider()->OnTouchEvent(&press1)); |
| 42 | 44 |
| 43 time += base::TimeDelta::FromMilliseconds(10); | 45 time += base::TimeDelta::FromMilliseconds(10); |
| 44 TouchEvent press2(ET_TOUCH_PRESSED, gfx::Point(30, 40), 0, time); | 46 TouchEvent press2(ET_TOUCH_PRESSED, gfx::Point(30, 40), 0, time); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 time += base::TimeDelta::FromMilliseconds(10); | 115 time += base::TimeDelta::FromMilliseconds(10); |
| 114 TouchEvent move0_4(ET_TOUCH_MOVED, gfx::Point(), 0, kTouchId0, time, kRadiusX, | 116 TouchEvent move0_4(ET_TOUCH_MOVED, gfx::Point(), 0, kTouchId0, time, kRadiusX, |
| 115 kRadiusY + 1, kAngle, kForce); | 117 kRadiusY + 1, kAngle, kForce); |
| 116 move0_4.set_location_f(gfx::PointF(70, 75.1f)); | 118 move0_4.set_location_f(gfx::PointF(70, 75.1f)); |
| 117 move0_4.set_root_location_f(gfx::PointF(70, 75.1f)); | 119 move0_4.set_root_location_f(gfx::PointF(70, 75.1f)); |
| 118 } | 120 } |
| 119 | 121 |
| 120 // TODO(jdduke): Test whether event marked as scroll trigger. | 122 // TODO(jdduke): Test whether event marked as scroll trigger. |
| 121 | 123 |
| 122 } // namespace ui | 124 } // namespace ui |
| OLD | NEW |