| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "ui/android/event_forwarder.h" | 6 #include "ui/android/event_forwarder.h" |
| 7 #include "ui/android/view_android.h" | 7 #include "ui/android/view_android.h" |
| 8 #include "ui/android/view_client.h" | 8 #include "ui/android/view_client.h" |
| 9 #include "ui/events/android/motion_event_android.h" | 9 #include "ui/events/android/motion_event_android.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 void Reset() { | 46 void Reset() { |
| 47 client1_.Reset(); | 47 client1_.Reset(); |
| 48 client2_.Reset(); | 48 client2_.Reset(); |
| 49 client3_.Reset(); | 49 client3_.Reset(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void GenerateTouchEventAt(float x, float y) { | 52 void GenerateTouchEventAt(float x, float y) { |
| 53 ui::MotionEventAndroid::Pointer pointer0(0, x, y, 0, 0, 0, 0, 0); | 53 ui::MotionEventAndroid::Pointer pointer0(0, x, y, 0, 0, 0, 0, 0); |
| 54 ui::MotionEventAndroid::Pointer pointer1(0, 0, 0, 0, 0, 0, 0, 0); | 54 ui::MotionEventAndroid::Pointer pointer1(0, 0, 0, 0, 0, 0, 0, 0); |
| 55 ui::MotionEventAndroid event(1.f, nullptr, JavaParamRef<jobject>(nullptr), | 55 ui::MotionEventAndroid event(nullptr, JavaParamRef<jobject>(nullptr), 1.f, |
| 56 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, &pointer0, | 56 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, |
| 57 &pointer1); | 57 &pointer0, &pointer1); |
| 58 root_.OnTouchEvent(event, false); | 58 root_.OnTouchEvent(event, false); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ExpectHit(const TestViewClient& hitClient) { | 61 void ExpectHit(const TestViewClient& hitClient) { |
| 62 TestViewClient* clients[3] = {&client1_, &client2_, &client3_}; | 62 TestViewClient* clients[3] = {&client1_, &client2_, &client3_}; |
| 63 for (auto* client : clients) { | 63 for (auto* client : clients) { |
| 64 if (&hitClient == client) | 64 if (&hitClient == client) |
| 65 EXPECT_TRUE(client->EventHandled()); | 65 EXPECT_TRUE(client->EventHandled()); |
| 66 else | 66 else |
| 67 EXPECT_FALSE(client->EventHandled()); | 67 EXPECT_FALSE(client->EventHandled()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 GenerateTouchEventAt(40, 60); | 160 GenerateTouchEventAt(40, 60); |
| 161 EXPECT_TRUE(client1_.EventCalled()); | 161 EXPECT_TRUE(client1_.EventCalled()); |
| 162 ExpectHit(client2_); | 162 ExpectHit(client2_); |
| 163 | 163 |
| 164 GenerateTouchEventAt(100, 70); | 164 GenerateTouchEventAt(100, 70); |
| 165 EXPECT_TRUE(client1_.EventCalled()); | 165 EXPECT_TRUE(client1_.EventCalled()); |
| 166 ExpectHit(client3_); | 166 ExpectHit(client3_); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace ui | 169 } // namespace ui |
| OLD | NEW |