| 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 parent2; | |
| 177 ViewAndroid child2; | |
| 178 parent2.GetEventForwarder(); | |
| 179 parent2.AddChild(&child2); | |
| 180 EXPECT_DEATH(child2.GetEventForwarder(), "Check failed:"); | |
| 181 | |
| 182 ViewAndroid window; | |
| 183 ViewAndroid wcv1, wcv2; | |
| 184 ViewAndroid rwhv1a, rwhv1b, rwhv2; | |
| 185 wcv1.GetEventForwarder(); | |
| 186 wcv2.GetEventForwarder(); | |
| 187 | |
| 188 window.AddChild(&wcv1); | |
| 189 wcv1.AddChild(&rwhv1a); | |
| 190 wcv1.AddChild(&rwhv1b); | |
| 191 | |
| 192 wcv2.AddChild(&rwhv2); | |
| 193 | |
| 194 // window should be able to add wcv2 since there's only one event forwarder | |
| 195 // in the path window - wcv2* - rwvh2 | |
| 196 window.AddChild(&wcv2); | |
| 197 | |
| 198 // Additional event forwarder will cause failure. | |
| 199 EXPECT_DEATH(rwhv2.GetEventForwarder(), "Check failed:"); | |
| 200 } | |
| 201 | |
| 202 } // namespace ui | 169 } // namespace ui |
| OLD | NEW |