From b02442cfff5473935a5bcd7edab7379f87be0216 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 17 Dec 2020 10:49:19 -0800 Subject: [PATCH 1/3] update tests --- .../ios/framework/Source/FlutterEngineTest.mm | 14 +- .../Source/FlutterPlatformViewsTest.mm | 262 ++++++++++-------- 2 files changed, 153 insertions(+), 123 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm index dd63da24de014..d30ae907c6a55 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -102,13 +102,13 @@ - (void)testRunningInitialRouteSendsNavigationMessage { message:encodedSetInitialRouteMethod]); } -- (void)testPlatformViewsControllerRenderingMetalBackend { - FlutterEngine* engine = [[FlutterEngine alloc] init]; - [engine run]; - flutter::IOSRenderingAPI renderingApi = [engine platformViewsRenderingAPI]; - - XCTAssertEqual(renderingApi, flutter::IOSRenderingAPI::kMetal); -} +//- (void)testPlatformViewsControllerRenderingMetalBackend { +// FlutterEngine* engine = [[FlutterEngine alloc] init]; +// [engine run]; +// flutter::IOSRenderingAPI renderingApi = [engine platformViewsRenderingAPI]; +// +// XCTAssertEqual(renderingApi, flutter::IOSRenderingAPI::kMetal); +//} - (void)testPlatformViewsControllerRenderingSoftware { auto settings = FLTDefaultSettingsForBundle(); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index 877320c4f6e3e..293d0cdd02a56 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -621,15 +621,15 @@ - (void)testSetFlutterViewControllerAfterCreateCanStillDispatchTouchEvents { } // Before setting flutter view controller, events are not dispatched. - NSSet* touches1 = OCMClassMock([NSSet class]); - UIEvent* event1 = OCMClassMock([UIEvent class]); - UIViewController* mockFlutterViewContoller = OCMClassMock([UIViewController class]); + NSSet* touches1 = [[[NSSet alloc] init] autorelease]; + id event1 = OCMClassMock([UIEvent class]); + id mockFlutterViewContoller = OCMClassMock([UIViewController class]); [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; OCMReject([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); // Set flutter view controller allows events to be dispatched. - NSSet* touches2 = OCMClassMock([NSSet class]); - UIEvent* event2 = OCMClassMock([UIEvent class]); + NSSet* touches2 = [[[NSSet alloc] init] autorelease]; + id event2 = OCMClassMock([UIEvent class]); flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); [forwardGectureRecognizer touchesBegan:touches2 withEvent:event2]; OCMVerify([mockFlutterViewContoller touchesBegan:touches2 withEvent:event2]); @@ -681,146 +681,176 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu break; } } - UIViewController* mockFlutterViewContoller = OCMClassMock([UIViewController class]); + id mockFlutterViewContoller = OCMClassMock([UIViewController class]); { // ***** Sequence 1, finishing touch event with touchEnded ***** // - + id event = OCMClassMock([UIEvent class]); flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); - NSSet* touches1 = OCMClassMock([NSSet class]); - UIEvent* event1 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; - OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); + NSSet* touches1 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesBegan:touches1 withEvent:event]; + OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event]); flutterPlatformViewsController->SetFlutterViewController(nil); // Allow the touch events to finish - NSSet* touches2 = OCMClassMock([NSSet class]); - UIEvent* event2 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesMoved:touches2 withEvent:event2]; - OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event2]); + NSSet* touches2 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesMoved:touches2 withEvent:event]; + OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event]); - NSSet* touches3 = OCMClassMock([NSSet class]); - UIEvent* event3 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesEnded:touches3 withEvent:event3]; - OCMVerify([mockFlutterViewContoller touchesEnded:touches3 withEvent:event3]); + NSSet* touches3 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesEnded:touches3 withEvent:event]; + OCMVerify([mockFlutterViewContoller touchesEnded:touches3 withEvent:event]); // Now the 2nd touch sequence should not be allowed. - NSSet* touches4 = OCMClassMock([NSSet class]); - UIEvent* event4 = OCMClassMock([UIEvent class]); - mockFlutterViewContoller = OCMClassMock([UIViewController class]); - [forwardGectureRecognizer touchesBegan:touches4 withEvent:event4]; - OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event4]); - - NSSet* touches5 = OCMClassMock([NSSet class]); - UIEvent* event5 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesEnded:touches5 withEvent:event5]; - OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event5]); + NSSet* touches4 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesBegan:touches4 withEvent:event]; + OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event]); + + NSSet* touches5 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesEnded:touches5 withEvent:event]; + OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event]); } { // ***** Sequence 2, finishing touch event with touchCancelled ***** // + id event = OCMClassMock([UIEvent class]); flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); - NSSet* touches1 = OCMClassMock([NSSet class]); - UIEvent* event1 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; - OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); + NSSet* touches1 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesBegan:touches1 withEvent:event]; + OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event]); flutterPlatformViewsController->SetFlutterViewController(nil); // Allow the touch events to finish - NSSet* touches2 = OCMClassMock([NSSet class]); - UIEvent* event2 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesMoved:touches2 withEvent:event2]; - OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event2]); + NSSet* touches2 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesMoved:touches2 withEvent:event]; + OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event]); - NSSet* touches3 = OCMClassMock([NSSet class]); - UIEvent* event3 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesCancelled:touches3 withEvent:event3]; - OCMVerify([mockFlutterViewContoller touchesCancelled:touches3 withEvent:event3]); + NSSet* touches3 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesCancelled:touches3 withEvent:event]; + OCMVerify([mockFlutterViewContoller touchesCancelled:touches3 withEvent:event]); // Now the 2nd touch sequence should not be allowed. - NSSet* touches4 = OCMClassMock([NSSet class]); - UIEvent* event4 = OCMClassMock([UIEvent class]); - mockFlutterViewContoller = OCMClassMock([UIViewController class]); - [forwardGectureRecognizer touchesBegan:touches4 withEvent:event4]; - OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event4]); - - NSSet* touches5 = OCMClassMock([NSSet class]); - UIEvent* event5 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesEnded:touches5 withEvent:event5]; - OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event5]); + NSSet* touches4 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesBegan:touches4 withEvent:event]; + OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event]); + + NSSet* touches5 = [[[NSSet alloc] init] autorelease]; + [forwardGectureRecognizer touchesEnded:touches5 withEvent:event]; + OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event]); } - { - // ***** Sequence 3, multile touches in one sequence with setting flutter view controllers in - // between ***** // - flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); + flutterPlatformViewsController->Reset(); +} - NSSet* touches1 = OCMClassMock([NSSet class]); - OCMStub([touches1 count]).andReturn(1); - UIEvent* event1 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; - OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); - - UIViewController* mockFlutterViewContoller2 = OCMClassMock([UIViewController class]); - flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller2); - - // Touch events should still send to the old FlutterViewController if FlutterViewController - // is updated in between. - NSSet* touches2 = OCMClassMock([NSSet class]); - OCMStub([touches2 count]).andReturn(1); - UIEvent* event2 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesBegan:touches2 withEvent:event2]; - OCMVerify([mockFlutterViewContoller touchesBegan:touches2 withEvent:event2]); - OCMReject([mockFlutterViewContoller2 touchesBegan:touches2 withEvent:event2]); - - NSSet* touches3 = OCMClassMock([NSSet class]); - OCMStub([touches3 count]).andReturn(1); - UIEvent* event3 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesMoved:touches3 withEvent:event3]; - OCMVerify([mockFlutterViewContoller touchesMoved:touches3 withEvent:event3]); - OCMReject([mockFlutterViewContoller2 touchesMoved:touches3 withEvent:event3]); - - NSSet* touches4 = OCMClassMock([NSSet class]); - OCMStub([touches4 count]).andReturn(1); - UIEvent* event4 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesEnded:touches4 withEvent:event4]; - OCMVerify([mockFlutterViewContoller touchesEnded:touches4 withEvent:event4]); - OCMReject([mockFlutterViewContoller2 touchesEnded:touches4 withEvent:event4]); - - NSSet* touches5 = OCMClassMock([NSSet class]); - OCMStub([touches5 count]).andReturn(1); - UIEvent* event5 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesEnded:touches5 withEvent:event5]; - OCMVerify([mockFlutterViewContoller touchesEnded:touches5 withEvent:event5]); - OCMReject([mockFlutterViewContoller2 touchesEnded:touches5 withEvent:event5]); - - // Now the 2nd touch sequence should go to the new FlutterViewController - - NSSet* touches6 = OCMClassMock([NSSet class]); - OCMStub([touches6 count]).andReturn(1); - UIEvent* event6 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesBegan:touches6 withEvent:event6]; - OCMVerify([mockFlutterViewContoller2 touchesBegan:touches6 withEvent:event6]); - OCMReject([mockFlutterViewContoller touchesBegan:touches6 withEvent:event6]); +- (void) + testSetFlutterViewControllerInTheMiddleOfTouchEventAllowsTheNewControllerToHandleSecondTouchSequence { + flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate; + auto thread_task_runner = CreateNewThread("FlutterPlatformViewsTest"); + flutter::TaskRunners runners(/*label=*/self.name.UTF8String, + /*platform=*/thread_task_runner, + /*raster=*/thread_task_runner, + /*ui=*/thread_task_runner, + /*io=*/thread_task_runner); + auto flutterPlatformViewsController = std::make_shared(); + auto platform_view = std::make_unique( + /*delegate=*/mock_delegate, + /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, + /*platform_views_controller=*/flutterPlatformViewsController, + /*task_runners=*/runners); - // Allow the touch events to finish - NSSet* touches7 = OCMClassMock([NSSet class]); - OCMStub([touches7 count]).andReturn(1); - UIEvent* event7 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesMoved:touches7 withEvent:event7]; - OCMVerify([mockFlutterViewContoller2 touchesMoved:touches7 withEvent:event7]); - OCMReject([mockFlutterViewContoller touchesMoved:touches7 withEvent:event7]); - - NSSet* touches8 = OCMClassMock([NSSet class]); - OCMStub([touches8 count]).andReturn(1); - UIEvent* event8 = OCMClassMock([UIEvent class]); - [forwardGectureRecognizer touchesEnded:touches8 withEvent:event8]; - OCMVerify([mockFlutterViewContoller2 touchesEnded:touches8 withEvent:event8]); - OCMReject([mockFlutterViewContoller touchesEnded:touches8 withEvent:event8]); + FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = + [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; + flutterPlatformViewsController->RegisterViewFactory( + factory, @"MockFlutterPlatformView", + FlutterPlatformViewGestureRecognizersBlockingPolicyEager); + FlutterResult result = ^(id result) { + }; + flutterPlatformViewsController->OnMethodCall( + [FlutterMethodCall + methodCallWithMethodName:@"create" + arguments:@{@"id" : @2, @"viewType" : @"MockFlutterPlatformView"}], + result); + + XCTAssertNotNil(gMockPlatformView); + + // Find touch inteceptor view + UIView* touchInteceptorView = gMockPlatformView; + while (touchInteceptorView != nil && + ![touchInteceptorView isKindOfClass:[FlutterTouchInterceptingView class]]) { + touchInteceptorView = touchInteceptorView.superview; + } + XCTAssertNotNil(touchInteceptorView); + + // Find ForwardGestureRecognizer + UIGestureRecognizer* forwardGectureRecognizer = nil; + for (UIGestureRecognizer* gestureRecognizer in touchInteceptorView.gestureRecognizers) { + if ([gestureRecognizer isKindOfClass:NSClassFromString(@"ForwardingGestureRecognizer")]) { + forwardGectureRecognizer = gestureRecognizer; + break; + } } + id mockFlutterViewContoller = OCMClassMock([UIViewController class]); + + flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); + + // The touches in this sequence requires 1 touch object, we always create the NSSet with one item. + NSSet* touches1 = [NSSet setWithObject:@1]; + id event1 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; + OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); + + UIViewController* mockFlutterViewContoller2 = OCMClassMock([UIViewController class]); + flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller2); + + // Touch events should still send to the old FlutterViewController if FlutterViewController + // is updated in between. + NSSet* touches2 = [NSSet setWithObject:@1]; + id event2 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesBegan:touches2 withEvent:event2]; + OCMVerify([mockFlutterViewContoller touchesBegan:touches2 withEvent:event2]); + OCMReject([mockFlutterViewContoller2 touchesBegan:touches2 withEvent:event2]); + + NSSet* touches3 = [NSSet setWithObject:@1]; + id event3 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesMoved:touches3 withEvent:event3]; + OCMVerify([mockFlutterViewContoller touchesMoved:touches3 withEvent:event3]); + OCMReject([mockFlutterViewContoller2 touchesMoved:touches3 withEvent:event3]); + + NSSet* touches4 = [NSSet setWithObject:@1]; + id event4 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesEnded:touches4 withEvent:event4]; + OCMVerify([mockFlutterViewContoller touchesEnded:touches4 withEvent:event4]); + OCMReject([mockFlutterViewContoller2 touchesEnded:touches4 withEvent:event4]); + + NSSet* touches5 = [NSSet setWithObject:@1]; + id event5 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesEnded:touches5 withEvent:event5]; + OCMVerify([mockFlutterViewContoller touchesEnded:touches5 withEvent:event5]); + OCMReject([mockFlutterViewContoller2 touchesEnded:touches5 withEvent:event5]); + + // Now the 2nd touch sequence should go to the new FlutterViewController + + NSSet* touches6 = [NSSet setWithObject:@1]; + id event6 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesBegan:touches6 withEvent:event6]; + OCMVerify([mockFlutterViewContoller2 touchesBegan:touches6 withEvent:event6]); + OCMReject([mockFlutterViewContoller touchesBegan:touches6 withEvent:event6]); + + // Allow the touch events to finish + NSSet* touches7 = [NSSet setWithObject:@1]; + id event7 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesMoved:touches7 withEvent:event7]; + OCMVerify([mockFlutterViewContoller2 touchesMoved:touches7 withEvent:event7]); + OCMReject([mockFlutterViewContoller touchesMoved:touches7 withEvent:event7]); + + NSSet* touches8 = [NSSet setWithObject:@1]; + id event8 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesEnded:touches8 withEvent:event8]; + OCMVerify([mockFlutterViewContoller2 touchesEnded:touches8 withEvent:event8]); + OCMReject([mockFlutterViewContoller touchesEnded:touches8 withEvent:event8]); flutterPlatformViewsController->Reset(); } From 354e2bba282fa37574f763b804e0417e8346f409 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 17 Dec 2020 14:47:26 -0800 Subject: [PATCH 2/3] cleanup --- .../ios/framework/Source/FlutterEngineTest.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm index d30ae907c6a55..dd63da24de014 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -102,13 +102,13 @@ - (void)testRunningInitialRouteSendsNavigationMessage { message:encodedSetInitialRouteMethod]); } -//- (void)testPlatformViewsControllerRenderingMetalBackend { -// FlutterEngine* engine = [[FlutterEngine alloc] init]; -// [engine run]; -// flutter::IOSRenderingAPI renderingApi = [engine platformViewsRenderingAPI]; -// -// XCTAssertEqual(renderingApi, flutter::IOSRenderingAPI::kMetal); -//} +- (void)testPlatformViewsControllerRenderingMetalBackend { + FlutterEngine* engine = [[FlutterEngine alloc] init]; + [engine run]; + flutter::IOSRenderingAPI renderingApi = [engine platformViewsRenderingAPI]; + + XCTAssertEqual(renderingApi, flutter::IOSRenderingAPI::kMetal); +} - (void)testPlatformViewsControllerRenderingSoftware { auto settings = FLTDefaultSettingsForBundle(); From ac46d59328b9a43f759f74ad1fb9918808797262 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 17 Dec 2020 16:02:21 -0800 Subject: [PATCH 3/3] revert unified event --- .../Source/FlutterPlatformViewsTest.mm | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index 293d0cdd02a56..f8b5e4ebc3e7b 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -684,62 +684,70 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu id mockFlutterViewContoller = OCMClassMock([UIViewController class]); { // ***** Sequence 1, finishing touch event with touchEnded ***** // - id event = OCMClassMock([UIEvent class]); flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); NSSet* touches1 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesBegan:touches1 withEvent:event]; - OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event]); + id event1 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; + OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); flutterPlatformViewsController->SetFlutterViewController(nil); // Allow the touch events to finish NSSet* touches2 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesMoved:touches2 withEvent:event]; - OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event]); + id event2 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesMoved:touches2 withEvent:event2]; + OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event2]); NSSet* touches3 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesEnded:touches3 withEvent:event]; - OCMVerify([mockFlutterViewContoller touchesEnded:touches3 withEvent:event]); + id event3 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesEnded:touches3 withEvent:event3]; + OCMVerify([mockFlutterViewContoller touchesEnded:touches3 withEvent:event3]); // Now the 2nd touch sequence should not be allowed. NSSet* touches4 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesBegan:touches4 withEvent:event]; - OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event]); + id event4 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesBegan:touches4 withEvent:event4]; + OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event4]); NSSet* touches5 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesEnded:touches5 withEvent:event]; - OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event]); + id event5 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesEnded:touches5 withEvent:event5]; + OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event5]); } { // ***** Sequence 2, finishing touch event with touchCancelled ***** // - id event = OCMClassMock([UIEvent class]); flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); NSSet* touches1 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesBegan:touches1 withEvent:event]; - OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event]); + id event1 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; + OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); flutterPlatformViewsController->SetFlutterViewController(nil); // Allow the touch events to finish NSSet* touches2 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesMoved:touches2 withEvent:event]; - OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event]); + id event2 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesMoved:touches2 withEvent:event2]; + OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event2]); NSSet* touches3 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesCancelled:touches3 withEvent:event]; - OCMVerify([mockFlutterViewContoller touchesCancelled:touches3 withEvent:event]); + id event3 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesCancelled:touches3 withEvent:event3]; + OCMVerify([mockFlutterViewContoller touchesCancelled:touches3 withEvent:event3]); // Now the 2nd touch sequence should not be allowed. NSSet* touches4 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesBegan:touches4 withEvent:event]; - OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event]); + id event4 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesBegan:touches4 withEvent:event4]; + OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event4]); NSSet* touches5 = [[[NSSet alloc] init] autorelease]; - [forwardGectureRecognizer touchesEnded:touches5 withEvent:event]; - OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event]); + id event5 = OCMClassMock([UIEvent class]); + [forwardGectureRecognizer touchesEnded:touches5 withEvent:event5]; + OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event5]); } flutterPlatformViewsController->Reset();