| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 client1_.SetHandleEvent(false); | 159 client1_.SetHandleEvent(false); |
| 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 TEST(ViewAndroidTest, ChecksMultipleEventForwarders) { |
| 170 ViewAndroid parent; |
| 171 ViewAndroid child; |
| 172 parent.GetEventForwarder(); |
| 173 child.GetEventForwarder(); |
| 174 EXPECT_DEATH(parent.AddChild(&child), "Check failed:"); |
| 175 |
| 176 ViewAndroid window; |
| 177 ViewAndroid wcv1, wcv2; |
| 178 ViewAndroid rwhv1a, rwhv1b, rwhv2; |
| 179 wcv1.GetEventForwarder(); |
| 180 wcv1.GetEventForwarder(); |
| 181 |
| 182 window.AddChild(&wcv1); |
| 183 wcv1.AddChild(&rwhv1a); |
| 184 wcv1.AddChild(&rwhv1b); |
| 185 wcv2.AddChild(&rwhv2); |
| 186 |
| 187 // window can add wcv2 since there's only one event forwarder at wcv2 |
| 188 // in the path window - wcv2 - rwvh2 |
| 189 window.AddChild(&wcv2); |
| 190 |
| 191 // Both wcv1 & rwhv1 have event forwarders in the path window - wcv1 - rwhv1a. |
| 192 EXPECT_DEATH(rwhv1a.GetEventForwarder(), "Check failed:"); |
| 193 } |
| 194 |
| 169 } // namespace ui | 195 } // namespace ui |
| OLD | NEW |