@@ -74,6 +74,9 @@ - (void)checkViewCreatedOnce {
74
74
self.viewCreated = YES;
75
75
}
76
76
77
+ - (void)dealloc {
78
+ gMockPlatformView = nil;
79
+ }
77
80
@end
78
81
79
82
@interface FlutterPlatformViewsTestMockFlutterPlatformFactory
@@ -115,6 +118,10 @@ - (void)checkViewCreatedOnce {
115
118
}
116
119
self.viewCreated = YES;
117
120
}
121
+
122
+ - (void)dealloc {
123
+ gMockPlatformView = nil;
124
+ }
118
125
@end
119
126
120
127
@interface FlutterPlatformViewsTestMockWebViewFactory : NSObject <FlutterPlatformViewFactory>
@@ -167,6 +174,10 @@ - (void)checkViewCreatedOnce {
167
174
}
168
175
self.viewCreated = YES;
169
176
}
177
+
178
+ - (void)dealloc {
179
+ gMockPlatformView = nil;
180
+ }
170
181
@end
171
182
172
183
@interface FlutterPlatformViewsTestMockWrapperWebViewFactory : NSObject <FlutterPlatformViewFactory>
@@ -180,6 +191,49 @@ @implementation FlutterPlatformViewsTestMockWrapperWebViewFactory
180
191
}
181
192
@end
182
193
194
+ @interface FlutterPlatformViewsTestMockNestedWrapperWebView : NSObject <FlutterPlatformView>
195
+ @property(nonatomic, strong) UIView* view;
196
+ @property(nonatomic, assign) BOOL viewCreated;
197
+ @end
198
+
199
+ @implementation FlutterPlatformViewsTestMockNestedWrapperWebView
200
+ - (instancetype)init {
201
+ if (self = [super init]) {
202
+ _view = [[UIView alloc] init];
203
+ UIView* childView = [[UIView alloc] init];
204
+ [_view addSubview:childView];
205
+ [childView addSubview:[[WKWebView alloc] init]];
206
+ gMockPlatformView = _view;
207
+ _viewCreated = NO;
208
+ }
209
+ return self;
210
+ }
211
+
212
+ - (UIView*)view {
213
+ [self checkViewCreatedOnce];
214
+ return _view;
215
+ }
216
+
217
+ - (void)checkViewCreatedOnce {
218
+ if (self.viewCreated) {
219
+ abort();
220
+ }
221
+ self.viewCreated = YES;
222
+ }
223
+ @end
224
+
225
+ @interface FlutterPlatformViewsTestMockNestedWrapperWebViewFactory
226
+ : NSObject <FlutterPlatformViewFactory>
227
+ @end
228
+
229
+ @implementation FlutterPlatformViewsTestMockNestedWrapperWebViewFactory
230
+ - (NSObject<FlutterPlatformView>*)createWithFrame:(CGRect)frame
231
+ viewIdentifier:(int64_t)viewId
232
+ arguments:(id _Nullable)args {
233
+ return [[FlutterPlatformViewsTestMockNestedWrapperWebView alloc] init];
234
+ }
235
+ @end
236
+
183
237
namespace flutter {
184
238
namespace {
185
239
class FlutterPlatformViewsTestMockPlatformViewDelegate : public PlatformView::Delegate {
@@ -3258,6 +3312,67 @@ - (void)testFlutterPlatformViewTouchesEndedOrTouchesCancelledEventDoesNotFailThe
3258
3312
}
3259
3313
}
3260
3314
3315
+ - (void)
3316
+ testFlutterPlatformViewBlockGestureUnderEagerPolicyShouldNotRemoveAndAddBackDelayingRecognizerForNestedWrapperWebView {
3317
+ flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate;
3318
+
3319
+ flutter::TaskRunners runners(/*label=*/self.name.UTF8String,
3320
+ /*platform=*/GetDefaultTaskRunner(),
3321
+ /*raster=*/GetDefaultTaskRunner(),
3322
+ /*ui=*/GetDefaultTaskRunner(),
3323
+ /*io=*/GetDefaultTaskRunner());
3324
+ FlutterPlatformViewsController* flutterPlatformViewsController =
3325
+ [[FlutterPlatformViewsController alloc] init];
3326
+ flutterPlatformViewsController.taskRunner = GetDefaultTaskRunner();
3327
+ auto platform_view = std::make_unique<flutter::PlatformViewIOS>(
3328
+ /*delegate=*/mock_delegate,
3329
+ /*rendering_api=*/mock_delegate.settings_.enable_impeller
3330
+ ? flutter::IOSRenderingAPI::kMetal
3331
+ : flutter::IOSRenderingAPI::kSoftware,
3332
+ /*platform_views_controller=*/flutterPlatformViewsController,
3333
+ /*task_runners=*/runners,
3334
+ /*worker_task_runner=*/nil,
3335
+ /*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
3336
+
3337
+ FlutterPlatformViewsTestMockNestedWrapperWebViewFactory* factory =
3338
+ [[FlutterPlatformViewsTestMockNestedWrapperWebViewFactory alloc] init];
3339
+ [flutterPlatformViewsController
3340
+ registerViewFactory:factory
3341
+ withId:@"MockNestedWrapperWebView"
3342
+ gestureRecognizersBlockingPolicy:FlutterPlatformViewGestureRecognizersBlockingPolicyEager];
3343
+ FlutterResult result = ^(id result) {
3344
+ };
3345
+ [flutterPlatformViewsController
3346
+ onMethodCall:[FlutterMethodCall methodCallWithMethodName:@"create"
3347
+ arguments:@{
3348
+ @"id" : @2,
3349
+ @"viewType" : @"MockNestedWrapperWebView"
3350
+ }]
3351
+ result:result];
3352
+
3353
+ XCTAssertNotNil(gMockPlatformView);
3354
+
3355
+ // Find touch inteceptor view
3356
+ UIView* touchInteceptorView = gMockPlatformView;
3357
+ while (touchInteceptorView != nil &&
3358
+ ![touchInteceptorView isKindOfClass:[FlutterTouchInterceptingView class]]) {
3359
+ touchInteceptorView = touchInteceptorView.superview;
3360
+ }
3361
+ XCTAssertNotNil(touchInteceptorView);
3362
+
3363
+ XCTAssert(touchInteceptorView.gestureRecognizers.count == 2);
3364
+ UIGestureRecognizer* delayingRecognizer = touchInteceptorView.gestureRecognizers[0];
3365
+ UIGestureRecognizer* forwardingRecognizer = touchInteceptorView.gestureRecognizers[1];
3366
+
3367
+ XCTAssert([delayingRecognizer isKindOfClass:[FlutterDelayingGestureRecognizer class]]);
3368
+ XCTAssert([forwardingRecognizer isKindOfClass:[ForwardingGestureRecognizer class]]);
3369
+
3370
+ [(FlutterTouchInterceptingView*)touchInteceptorView blockGesture];
3371
+
3372
+ XCTAssertEqual(touchInteceptorView.gestureRecognizers[0], delayingRecognizer);
3373
+ XCTAssertEqual(touchInteceptorView.gestureRecognizers[1], forwardingRecognizer);
3374
+ }
3375
+
3261
3376
- (void)
3262
3377
testFlutterPlatformViewBlockGestureUnderEagerPolicyShouldNotRemoveAndAddBackDelayingRecognizerForNonWebView {
3263
3378
flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate;
0 commit comments