| 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/android/window_android.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 |
| 15 class TestViewClient : public ViewClient { | 16 class TestViewClient : public ViewClient { |
| 16 public: | 17 public: |
| 17 TestViewClient() : handle_event_(true), called_(false) {} | 18 TestViewClient() : handle_event_(true), called_(false) {} |
| 18 | 19 |
| (...skipping 140 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, AddChildChecksMultipleEventForwarders) { |
| 171 ViewAndroid view1; |
| 172 ViewAndroid view2; |
| 173 view1.GetEventForwarder(); |
| 174 view2.GetEventForwarder(); |
| 175 EXPECT_DEATH(view1.AddChild(&view2), "Check failed:"); |
| 176 |
| 177 WindowAndroid* window = WindowAndroid::CreateForTesting(); |
| 178 view2.RemoveFromParent(); |
| 179 window->AddChild(&view1); |
| 180 window->AddChild(&view2); |
| 181 window->Destroy(nullptr, nullptr); |
| 182 } |
| 183 |
| 169 } // namespace ui | 184 } // namespace ui |
| OLD | NEW |