@@ -2455,125 +2455,6 @@ - (void)testHasFirstResponderInViewHierarchySubtree_descendantViewBecomesFirstRe
2455
2455
XCTAssertFalse (view.flt_hasFirstResponderInViewHierarchySubtree );
2456
2456
}
2457
2457
2458
- - (void )testFlutterClippingMaskViewPoolReuseViewsAfterRecycle {
2459
- FlutterClippingMaskViewPool* pool =
2460
- [[[FlutterClippingMaskViewPool alloc ] initWithCapacity: 2 ] autorelease ];
2461
- FlutterClippingMaskView* view1 = [pool getMaskViewWithFrame: CGRectZero ];
2462
- FlutterClippingMaskView* view2 = [pool getMaskViewWithFrame: CGRectZero ];
2463
- [pool recycleMaskViews ];
2464
- CGRect newRect = CGRectMake (0 , 0 , 10 , 10 );
2465
- FlutterClippingMaskView* view3 = [pool getMaskViewWithFrame: newRect];
2466
- FlutterClippingMaskView* view4 = [pool getMaskViewWithFrame: newRect];
2467
- XCTAssertEqual (view1, view3);
2468
- XCTAssertEqual (view2, view4);
2469
- XCTAssertTrue (CGRectEqualToRect (view3.frame , newRect));
2470
- XCTAssertTrue (CGRectEqualToRect (view4.frame , newRect));
2471
- }
2472
-
2473
- - (void )testFlutterClippingMaskViewPoolAllocsNewMaskViewsAfterReachingCapacity {
2474
- FlutterClippingMaskViewPool* pool =
2475
- [[[FlutterClippingMaskViewPool alloc ] initWithCapacity: 2 ] autorelease ];
2476
- FlutterClippingMaskView* view1 = [pool getMaskViewWithFrame: CGRectZero ];
2477
- FlutterClippingMaskView* view2 = [pool getMaskViewWithFrame: CGRectZero ];
2478
- FlutterClippingMaskView* view3 = [pool getMaskViewWithFrame: CGRectZero ];
2479
- XCTAssertNotEqual (view1, view3);
2480
- XCTAssertNotEqual (view2, view3);
2481
- }
2482
-
2483
- - (void )testMaskViewsReleasedWhenPoolIsReleased {
2484
- UIView* retainedView;
2485
- @autoreleasepool {
2486
- FlutterClippingMaskViewPool* pool =
2487
- [[[FlutterClippingMaskViewPool alloc ] initWithCapacity: 2 ] autorelease ];
2488
- FlutterClippingMaskView* view = [pool getMaskViewWithFrame: CGRectZero ];
2489
- retainedView = [view retain ];
2490
- XCTAssertGreaterThan (retainedView.retainCount , 1u );
2491
- }
2492
- // The only retain left is our manual retain called inside the autorelease pool, meaning the
2493
- // maskViews are dealloc'd.
2494
- XCTAssertEqual (retainedView.retainCount , 1u );
2495
- }
2496
-
2497
- - (void )testClipMaskViewIsReused {
2498
- flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate;
2499
- auto thread_task_runner = CreateNewThread (" FlutterPlatformViewsTest" );
2500
- flutter::TaskRunners runners (/* label=*/ self.name .UTF8String ,
2501
- /* platform=*/ thread_task_runner,
2502
- /* raster=*/ thread_task_runner,
2503
- /* ui=*/ thread_task_runner,
2504
- /* io=*/ thread_task_runner);
2505
- auto flutterPlatformViewsController = std::make_shared<flutter::FlutterPlatformViewsController>();
2506
- auto platform_view = std::make_unique<flutter::PlatformViewIOS>(
2507
- /* delegate=*/ mock_delegate,
2508
- /* rendering_api=*/ flutter::IOSRenderingAPI::kSoftware ,
2509
- /* platform_views_controller=*/ flutterPlatformViewsController,
2510
- /* task_runners=*/ runners);
2511
-
2512
- FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
2513
- [[FlutterPlatformViewsTestMockFlutterPlatformFactory new ] autorelease ];
2514
- flutterPlatformViewsController->RegisterViewFactory (
2515
- factory, @" MockFlutterPlatformView" ,
2516
- FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
2517
- FlutterResult result = ^(id result) {
2518
- };
2519
- flutterPlatformViewsController->OnMethodCall (
2520
- [FlutterMethodCall
2521
- methodCallWithMethodName: @" create"
2522
- arguments: @{@" id" : @1 , @" viewType" : @" MockFlutterPlatformView" }],
2523
- result);
2524
-
2525
- XCTAssertNotNil (gMockPlatformView );
2526
- UIView* mockFlutterView = [[[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , 10 , 10 )] autorelease ];
2527
- flutterPlatformViewsController->SetFlutterView (mockFlutterView);
2528
- // Create embedded view params
2529
- flutter::MutatorsStack stack1;
2530
- // Layer tree always pushes a screen scale factor to the stack
2531
- SkMatrix screenScaleMatrix =
2532
- SkMatrix::Scale ([UIScreen mainScreen ].scale , [UIScreen mainScreen ].scale );
2533
- stack1.PushTransform (screenScaleMatrix);
2534
- // Push a clip rect
2535
- SkRect rect = SkRect::MakeXYWH (2 , 2 , 3 , 3 );
2536
- stack1.PushClipRect (rect);
2537
-
2538
- auto embeddedViewParams1 = std::make_unique<flutter::EmbeddedViewParams>(
2539
- screenScaleMatrix, SkSize::Make (10 , 10 ), stack1);
2540
-
2541
- flutter::MutatorsStack stack2;
2542
- auto embeddedViewParams2 = std::make_unique<flutter::EmbeddedViewParams>(
2543
- screenScaleMatrix, SkSize::Make (10 , 10 ), stack2);
2544
-
2545
- flutterPlatformViewsController->PrerollCompositeEmbeddedView (1 , std::move (embeddedViewParams1));
2546
- flutterPlatformViewsController->CompositeEmbeddedView (1 );
2547
- UIView* childClippingView1 = gMockPlatformView .superview .superview ;
2548
- UIView* maskView1 = childClippingView1.maskView ;
2549
- XCTAssertNotNil (maskView1);
2550
-
2551
- // Composite a new frame.
2552
- auto embeddedViewParams3 = std::make_unique<flutter::EmbeddedViewParams>(
2553
- screenScaleMatrix, SkSize::Make (10 , 10 ), stack2);
2554
- flutterPlatformViewsController->PrerollCompositeEmbeddedView (1 , std::move (embeddedViewParams3));
2555
- flutterPlatformViewsController->CompositeEmbeddedView (1 );
2556
- childClippingView1 = gMockPlatformView .superview .superview ;
2557
-
2558
- // This overrides gMockPlatformView to point to the newly created platform view.
2559
- flutterPlatformViewsController->OnMethodCall (
2560
- [FlutterMethodCall
2561
- methodCallWithMethodName: @" create"
2562
- arguments: @{@" id" : @2 , @" viewType" : @" MockFlutterPlatformView" }],
2563
- result);
2564
-
2565
- auto embeddedViewParams4 = std::make_unique<flutter::EmbeddedViewParams>(
2566
- screenScaleMatrix, SkSize::Make (10 , 10 ), stack1);
2567
- flutterPlatformViewsController->PrerollCompositeEmbeddedView (2 , std::move (embeddedViewParams4));
2568
- flutterPlatformViewsController->CompositeEmbeddedView (2 );
2569
- UIView* childClippingView2 = gMockPlatformView .superview .superview ;
2570
-
2571
- UIView* maskView2 = childClippingView2.maskView ;
2572
- XCTAssertEqual (maskView1, maskView2);
2573
- XCTAssertNotNil (childClippingView2.maskView );
2574
- XCTAssertNil (childClippingView1.maskView );
2575
- }
2576
-
2577
2458
// Return true if a correct visual effect view is found. It also implies all the validation in this
2578
2459
// method passes.
2579
2460
//
0 commit comments