| 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 "base/test/gtest_util.h" |
| 5 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "ui/android/event_forwarder.h" | 7 #include "ui/android/event_forwarder.h" |
| 7 #include "ui/android/view_android.h" | 8 #include "ui/android/view_android.h" |
| 8 #include "ui/android/view_client.h" | 9 #include "ui/android/view_client.h" |
| 9 #include "ui/events/android/motion_event_android.h" | 10 #include "ui/events/android/motion_event_android.h" |
| 10 | 11 |
| 11 namespace ui { | 12 namespace ui { |
| 12 | 13 |
| 13 using base::android::JavaParamRef; | 14 using base::android::JavaParamRef; |
| 14 | 15 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 client1_.SetHandleEvent(false); | 160 client1_.SetHandleEvent(false); |
| 160 GenerateTouchEventAt(40, 60); | 161 GenerateTouchEventAt(40, 60); |
| 161 EXPECT_TRUE(client1_.EventCalled()); | 162 EXPECT_TRUE(client1_.EventCalled()); |
| 162 ExpectHit(client2_); | 163 ExpectHit(client2_); |
| 163 | 164 |
| 164 GenerateTouchEventAt(100, 70); | 165 GenerateTouchEventAt(100, 70); |
| 165 EXPECT_TRUE(client1_.EventCalled()); | 166 EXPECT_TRUE(client1_.EventCalled()); |
| 166 ExpectHit(client3_); | 167 ExpectHit(client3_); |
| 167 } | 168 } |
| 168 | 169 |
| 170 TEST(ViewAndroidTest, ChecksMultipleEventForwarders) { |
| 171 ViewAndroid parent; |
| 172 ViewAndroid child; |
| 173 parent.GetEventForwarder(); |
| 174 child.GetEventForwarder(); |
| 175 EXPECT_DCHECK_DEATH(parent.AddChild(&child)); |
| 176 |
| 177 ViewAndroid parent2; |
| 178 ViewAndroid child2; |
| 179 parent2.GetEventForwarder(); |
| 180 parent2.AddChild(&child2); |
| 181 EXPECT_DCHECK_DEATH(child2.GetEventForwarder()); |
| 182 |
| 183 ViewAndroid window; |
| 184 ViewAndroid wcv1, wcv2; |
| 185 ViewAndroid rwhv1a, rwhv1b, rwhv2; |
| 186 wcv1.GetEventForwarder(); |
| 187 wcv2.GetEventForwarder(); |
| 188 |
| 189 window.AddChild(&wcv1); |
| 190 wcv1.AddChild(&rwhv1a); |
| 191 wcv1.AddChild(&rwhv1b); |
| 192 |
| 193 wcv2.AddChild(&rwhv2); |
| 194 |
| 195 // window should be able to add wcv2 since there's only one event forwarder |
| 196 // in the path window - wcv2* - rwvh2 |
| 197 window.AddChild(&wcv2); |
| 198 |
| 199 // Additional event forwarder will cause failure. |
| 200 EXPECT_DCHECK_DEATH(rwhv2.GetEventForwarder()); |
| 201 } |
| 202 |
| 169 } // namespace ui | 203 } // namespace ui |
| OLD | NEW |