OLD | NEW |
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 "content/browser/renderer_host/input/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
| 12 #include <tuple> |
12 | 13 |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/location.h" | 15 #include "base/location.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
20 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 21 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
21 #include "content/browser/renderer_host/input/input_router_client.h" | 22 #include "content/browser/renderer_host/input/input_router_client.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 CHECK(event); | 84 CHECK(event); |
84 event->type = type; | 85 event->type = type; |
85 return *event; | 86 return *event; |
86 } | 87 } |
87 | 88 |
88 template<typename MSG_T, typename ARG_T1> | 89 template<typename MSG_T, typename ARG_T1> |
89 void ExpectIPCMessageWithArg1(const IPC::Message* msg, const ARG_T1& arg1) { | 90 void ExpectIPCMessageWithArg1(const IPC::Message* msg, const ARG_T1& arg1) { |
90 ASSERT_EQ(MSG_T::ID, msg->type()); | 91 ASSERT_EQ(MSG_T::ID, msg->type()); |
91 typename MSG_T::Schema::Param param; | 92 typename MSG_T::Schema::Param param; |
92 ASSERT_TRUE(MSG_T::Read(msg, ¶m)); | 93 ASSERT_TRUE(MSG_T::Read(msg, ¶m)); |
93 EXPECT_EQ(arg1, base::get<0>(param)); | 94 EXPECT_EQ(arg1, std::get<0>(param)); |
94 } | 95 } |
95 | 96 |
96 template<typename MSG_T, typename ARG_T1, typename ARG_T2> | 97 template<typename MSG_T, typename ARG_T1, typename ARG_T2> |
97 void ExpectIPCMessageWithArg2(const IPC::Message* msg, | 98 void ExpectIPCMessageWithArg2(const IPC::Message* msg, |
98 const ARG_T1& arg1, | 99 const ARG_T1& arg1, |
99 const ARG_T2& arg2) { | 100 const ARG_T2& arg2) { |
100 ASSERT_EQ(MSG_T::ID, msg->type()); | 101 ASSERT_EQ(MSG_T::ID, msg->type()); |
101 typename MSG_T::Schema::Param param; | 102 typename MSG_T::Schema::Param param; |
102 ASSERT_TRUE(MSG_T::Read(msg, ¶m)); | 103 ASSERT_TRUE(MSG_T::Read(msg, ¶m)); |
103 EXPECT_EQ(arg1, base::get<0>(param)); | 104 EXPECT_EQ(arg1, std::get<0>(param)); |
104 EXPECT_EQ(arg2, base::get<1>(param)); | 105 EXPECT_EQ(arg2, std::get<1>(param)); |
105 } | 106 } |
106 | 107 |
107 #if defined(USE_AURA) | 108 #if defined(USE_AURA) |
108 bool TouchEventsAreEquivalent(const ui::TouchEvent& first, | 109 bool TouchEventsAreEquivalent(const ui::TouchEvent& first, |
109 const ui::TouchEvent& second) { | 110 const ui::TouchEvent& second) { |
110 if (first.type() != second.type()) | 111 if (first.type() != second.type()) |
111 return false; | 112 return false; |
112 if (first.location() != second.location()) | 113 if (first.location() != second.location()) |
113 return false; | 114 return false; |
114 if (first.touch_id() != second.touch_id()) | 115 if (first.touch_id() != second.touch_id()) |
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 InputRouterImplTest::SetUp(); | 1919 InputRouterImplTest::SetUp(); |
1919 input_router_->SetDeviceScaleFactor(2.f); | 1920 input_router_->SetDeviceScaleFactor(2.f); |
1920 } | 1921 } |
1921 | 1922 |
1922 template <typename T> | 1923 template <typename T> |
1923 const T* GetSentWebInputEvent() const { | 1924 const T* GetSentWebInputEvent() const { |
1924 EXPECT_EQ(1u, process_->sink().message_count()); | 1925 EXPECT_EQ(1u, process_->sink().message_count()); |
1925 | 1926 |
1926 InputMsg_HandleInputEvent::Schema::Param param; | 1927 InputMsg_HandleInputEvent::Schema::Param param; |
1927 InputMsg_HandleInputEvent::Read(process_->sink().GetMessageAt(0), ¶m); | 1928 InputMsg_HandleInputEvent::Read(process_->sink().GetMessageAt(0), ¶m); |
1928 return static_cast<const T*>(base::get<0>(param)); | 1929 return static_cast<const T*>(std::get<0>(param)); |
1929 } | 1930 } |
1930 | 1931 |
1931 template <typename T> | 1932 template <typename T> |
1932 const T* GetFilterWebInputEvent() const { | 1933 const T* GetFilterWebInputEvent() const { |
1933 return static_cast<const T*>(client_->last_filter_event()); | 1934 return static_cast<const T*>(client_->last_filter_event()); |
1934 } | 1935 } |
1935 | 1936 |
1936 private: | 1937 private: |
1937 DISALLOW_COPY_AND_ASSIGN(InputRouterImplScaleEventTest); | 1938 DISALLOW_COPY_AND_ASSIGN(InputRouterImplScaleEventTest); |
1938 }; | 1939 }; |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); | 2327 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); |
2327 | 2328 |
2328 const WebGestureEvent* filter_event = | 2329 const WebGestureEvent* filter_event = |
2329 GetFilterWebInputEvent<WebGestureEvent>(); | 2330 GetFilterWebInputEvent<WebGestureEvent>(); |
2330 TestLocationInFilterEvent(filter_event, orig); | 2331 TestLocationInFilterEvent(filter_event, orig); |
2331 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); | 2332 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); |
2332 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); | 2333 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); |
2333 } | 2334 } |
2334 | 2335 |
2335 } // namespace content | 2336 } // namespace content |
OLD | NEW |