| Flutter macOS Embedder |

Classes | Functions | Variables
FlutterMutatorViewTest.mm File Reference
`#import <OCMock/OCMock.h>`
`#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMutatorView.h"`
`#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h"`
`#include "third_party/googletest/googletest/include/gtest/gtest.h"`
`#import "flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h"`

Go to the source code of this file.

## Classes
category | FlutterMutatorView(Private)
class | FlutterCursorCoordinatorTest

## Functions
| TEST (FlutterMutatorViewTest, BasicFrameIsCorrect)
| TEST (FlutterMutatorViewTest, ClipsToBounds)
| TEST (FlutterMutatorViewTest, TransformedFrameIsCorrect)
| TEST (FlutterMutatorViewTest, FrameWithLooseClipIsCorrect)
| TEST (FlutterMutatorViewTest, FrameWithTightClipIsCorrect)
| TEST (FlutterMutatorViewTest, FrameWithTightClipAndTransformIsCorrect)
| TEST (FlutterMutatorViewTest, RoundRectClipsToSimpleRectangle)
| TEST (FlutterMutatorViewTest, ViewsSetIsFlipped)
| TEST (FlutterMutatorViewTest, RectsClipsToPathWhenRotated)
| TEST (FlutterMutatorViewTest, RoundRectClipsToPath)
| TEST (FlutterMutatorViewTest, PathClipViewsAreAddedAndRemoved)
| TEST (FlutterMutatorViewTest, HitTestIgnoreRegion)
| TEST (FlutterMutatorViewTest, ReparentingPlatformView)
| TEST (FlutterMutatorViewTest, CursorCoordinator)

## Variables
static constexpr float | kMaxErr = 1e-10

## Function Documentation

## ◆ TEST() [1/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | BasicFrameIsCorrect |
| ) |  |

Definition at line 63 of file FlutterMutatorViewTest.mm.

63 {
64 NSView* platformView = [[NSView alloc] init];
65 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
66
67 EXPECT_EQ(mutatorView.platformView, platformView);
68
69 std::vector<FlutterPlatformViewMutation> mutations{
70 {
71 .type = kFlutterPlatformViewMutationTypeTransformation,
72 .transformation =
73 FlutterTransformation{
74 .scaleX = 1,
75 .transX = 100,
76 .scaleY = 1,
77 .transY = 50,
78 },
79 },
80 };
81
82 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
83
84 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(100, 50, 30, 20)));
85 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
86 EXPECT_EQ(mutatorView.pathClipViews.count, 0ull);
87 EXPECT_NE(mutatorView.platformViewContainer, nil);
88 }

References FlutterMutatorView::platformView.

## ◆ TEST() [2/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | ClipsToBounds |
| ) |  |

Definition at line 90 of file FlutterMutatorViewTest.mm.

90 {
91 NSView* platformView = [[NSView alloc] init];
92 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
93 EXPECT_TRUE(mutatorView.clipsToBounds);
94 }

## ◆ TEST() [3/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | CursorCoordinator |
| ) |  |

Definition at line 730 of file FlutterMutatorViewTest.mm.

730 {
731 [[[FlutterCursorCoordinatorTest alloc] init] testCoordinatorEventWithinFlutterContent];
732 [[[FlutterCursorCoordinatorTest alloc] init] testCoordinatorEventOutsideFlutterContent];
733 }

## ◆ TEST() [4/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | FrameWithLooseClipIsCorrect |
| ) |  |

Definition at line 144 of file FlutterMutatorViewTest.mm.

144 {
145 NSView* platformView = [[NSView alloc] init];
146 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
147
148 EXPECT_EQ(mutatorView.platformView, platformView);
149
150 std::vector<FlutterPlatformViewMutation> mutations{
151 {
152 .type = kFlutterPlatformViewMutationTypeClipRect,
153 .clip_rect = FlutterRect{80, 40, 200, 100},
154 },
155 {
156 .type = kFlutterPlatformViewMutationTypeTransformation,
157 .transformation =
158 FlutterTransformation{
159 .scaleX = 1,
160 .transX = 100,
161 .scaleY = 1,
162 .transY = 50,
163 },
164 },
165 };
166
167 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
168
169 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(100, 50, 30, 20)));
170 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
171 }

References FlutterMutatorView::platformView.

## ◆ TEST() [5/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | FrameWithTightClipAndTransformIsCorrect |
| ) |  |

Definition at line 208 of file FlutterMutatorViewTest.mm.

208 {
209 NSView* platformView = [[NSView alloc] init];
210 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
211 NSView* mutatorViewParent = [[NSView alloc] init];
212 mutatorViewParent.wantsLayer = YES;
213 mutatorViewParent.layer.contentsScale = 2.0;
214 [mutatorViewParent addSubview:mutatorView];
215
216 std::vector<FlutterPlatformViewMutation> mutations{
217 {
218 .type = kFlutterPlatformViewMutationTypeTransformation,
219 .transformation =
220 FlutterTransformation{
221 .scaleX = 2,
222 .scaleY = 2,
223 },
224 },
225 {
226 .type = kFlutterPlatformViewMutationTypeClipRect,
227 .clip_rect = FlutterRect{80, 40, 200, 100},
228 },
229 {
230 .type = kFlutterPlatformViewMutationTypeClipRect,
231 .clip_rect = FlutterRect{110, 55, 120, 65},
232 },
233 {
234 .type = kFlutterPlatformViewMutationTypeTransformation,
235 .transformation =
236 FlutterTransformation{
237 .scaleX = 1,
238 .transX = 100,
239 .scaleY = 1,
240 .transY = 50,
241 },
242 },
243 {
244 .type = kFlutterPlatformViewMutationTypeTransformation,
245 .transformation =
246 FlutterTransformation{
247 .scaleX = 1.5,
248 .transX = -7.5,
249 .scaleY = 1.5,
250 .transY = -5,
251 },
252 },
253 };
254
255 ApplyFlutterLayer(mutatorView, FlutterSize{30 * 2, 20 * 2}, mutations);
256
257 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(110, 55, 10, 10)));
258 EXPECT_TRUE(
259 CGRectEqualToRect(mutatorView.subviews.firstObject.frame, CGRectMake(-17.5, -10, 45, 30)));
260 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
261 }

## ◆ TEST() [6/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | FrameWithTightClipIsCorrect |
| ) |  |

Definition at line 173 of file FlutterMutatorViewTest.mm.

173 {
174 NSView* platformView = [[NSView alloc] init];
175 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
176
177 EXPECT_EQ(mutatorView.platformView, platformView);
178
179 std::vector<FlutterPlatformViewMutation> mutations{
180 {
181 .type = kFlutterPlatformViewMutationTypeClipRect,
182 .clip_rect = FlutterRect{80, 40, 200, 100},
183 },
184 {
185 .type = kFlutterPlatformViewMutationTypeClipRect,
186 .clip_rect = FlutterRect{110, 55, 120, 65},
187 },
188 {
189 .type = kFlutterPlatformViewMutationTypeTransformation,
190 .transformation =
191 FlutterTransformation{
192 .scaleX = 1,
193 .transX = 100,
194 .scaleY = 1,
195 .transY = 50,
196 },
197 },
198 };
199
200 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
201
202 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(110, 55, 10, 10)));
203 EXPECT_TRUE(
204 CGRectEqualToRect(mutatorView.subviews.firstObject.frame, CGRectMake(-10, -5, 30, 20)));
205 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
206 }

References FlutterMutatorView::platformView.

## ◆ TEST() [7/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | HitTestIgnoreRegion |
| ) |  |

Definition at line 538 of file FlutterMutatorViewTest.mm.

538 {
539 NSView* platformView = [[NSView alloc] init];
540 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
541 ApplyFlutterLayer(mutatorView, FlutterSize{100, 100}, {});
542 EXPECT_EQ([mutatorView hitTest:NSMakePoint(10, 10)], platformView);
543 EXPECT_EQ([mutatorView hitTest:NSMakePoint(50, 10)], platformView);
544
545 [mutatorView resetHitTestRegion];
546 [mutatorView addHitTestIgnoreRegion:CGRectMake(0, 0, 50, 50)];
547 [mutatorView addHitTestIgnoreRegion:CGRectMake(50, 50, 50, 50)];
548
549 EXPECT_EQ([mutatorView hitTest:NSMakePoint(10, 10)], nil);
550 EXPECT_EQ([mutatorView hitTest:NSMakePoint(49, 10)], nil);
551 EXPECT_EQ([mutatorView hitTest:NSMakePoint(10, 49)], nil);
552 EXPECT_EQ([mutatorView hitTest:NSMakePoint(50, 50)], nil);
553 EXPECT_EQ([mutatorView hitTest:NSMakePoint(50, 10)], platformView);
554 EXPECT_EQ([mutatorView hitTest:NSMakePoint(10, 50)], platformView);
555
556 [mutatorView resetHitTestRegion];
557 EXPECT_EQ([mutatorView hitTest:NSMakePoint(10, 10)], platformView);
558 EXPECT_EQ([mutatorView hitTest:NSMakePoint(49, 10)], platformView);
559 EXPECT_EQ([mutatorView hitTest:NSMakePoint(10, 49)], platformView);
560 EXPECT_EQ([mutatorView hitTest:NSMakePoint(50, 50)], platformView);
561 EXPECT_EQ([mutatorView hitTest:NSMakePoint(50, 10)], platformView);
562 EXPECT_EQ([mutatorView hitTest:NSMakePoint(10, 50)], platformView);
563 }

References FlutterMutatorView::addHitTestIgnoreRegion:, and FlutterMutatorView::resetHitTestRegion.

## ◆ TEST() [8/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | PathClipViewsAreAddedAndRemoved |
| ) |  |

Definition at line 415 of file FlutterMutatorViewTest.mm.

415 {
416 NSView* platformView = [[NSView alloc] init];
417 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
418
419 std::vector<FlutterPlatformViewMutation> mutations{
420 {
421 .type = kFlutterPlatformViewMutationTypeTransformation,
422 .transformation =
423 FlutterTransformation{
424 .scaleX = 1,
425 .transX = 100,
426 .scaleY = 1,
427 .transY = 50,
428 },
429 },
430 };
431
432 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
433
434 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(100, 50, 30, 20)));
435 EXPECT_EQ(mutatorView.pathClipViews.count, 0ull);
436
437 std::vector<FlutterPlatformViewMutation> mutations2{
438 {
439 .type = kFlutterPlatformViewMutationTypeClipRoundedRect,
440 .clip_rounded_rect =
441 FlutterRoundedRect{
442 .rect = FlutterRect{110, 60, 150, 150},
443 .upper_left_corner_radius = FlutterSize{10, 10},
444 .upper_right_corner_radius = FlutterSize{10, 10},
445 .lower_right_corner_radius = FlutterSize{10, 10},
446 .lower_left_corner_radius = FlutterSize{10, 10},
447 },
448 },
449 {
450 .type = kFlutterPlatformViewMutationTypeTransformation,
451 .transformation =
452 FlutterTransformation{
453 .scaleX = 1,
454 .transX = 100,
455 .scaleY = 1,
456 .transY = 50,
457 },
458 },
459 };
460
461 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations2);
462
463 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(110, 60, 20, 10)));
464 EXPECT_TRUE(
465 CGRectEqualToRect(mutatorView.subviews.firstObject.frame, CGRectMake(-10, -10, 30, 20)));
466 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
467 EXPECT_EQ(mutatorView.pathClipViews.count, 1ul);
468
469 EXPECT_EQ(platformView.superview, mutatorView.platformViewContainer);
470 EXPECT_EQ(mutatorView.platformViewContainer.superview, mutatorView.pathClipViews[0]);
471 EXPECT_EQ(mutatorView.pathClipViews[0].superview, mutatorView);
472
473 std::vector<FlutterPlatformViewMutation> mutations3{
474 {
475 .type = kFlutterPlatformViewMutationTypeClipRoundedRect,
476 .clip_rounded_rect =
477 FlutterRoundedRect{
478 .rect = FlutterRect{110, 55, 150, 150},
479 .upper_left_corner_radius = FlutterSize{10, 10},
480 .upper_right_corner_radius = FlutterSize{10, 10},
481 .lower_right_corner_radius = FlutterSize{10, 10},
482 .lower_left_corner_radius = FlutterSize{10, 10},
483 },
484 },
485 {
486 .type = kFlutterPlatformViewMutationTypeClipRoundedRect,
487 .clip_rounded_rect =
488 FlutterRoundedRect{
489 .rect = FlutterRect{30, 30, 120, 65},
490 .upper_left_corner_radius = FlutterSize{10, 10},
491 .upper_right_corner_radius = FlutterSize{10, 10},
492 .lower_right_corner_radius = FlutterSize{10, 10},
493 .lower_left_corner_radius = FlutterSize{10, 10},
494 },
495 },
496 {
497 .type = kFlutterPlatformViewMutationTypeTransformation,
498 .transformation =
499 FlutterTransformation{
500 .scaleX = 1,
501 .transX = 100,
502 .scaleY = 1,
503 .transY = 50,
504 },
505 },
506 };
507
508 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations3);
509
510 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(110, 55, 10, 10)));
511 EXPECT_TRUE(
512 CGRectEqualToRect(mutatorView.subviews.firstObject.frame, CGRectMake(-10, -5, 30, 20)));
513 EXPECT_EQ(mutatorView.pathClipViews.count, 2ul);
514
515 EXPECT_EQ(platformView.superview, mutatorView.platformViewContainer);
516 EXPECT_EQ(mutatorView.platformViewContainer.superview, mutatorView.pathClipViews[1]);
517 EXPECT_EQ(mutatorView.pathClipViews[1].superview, mutatorView.pathClipViews[0]);
518 EXPECT_EQ(mutatorView.pathClipViews[0].superview, mutatorView);
519
520 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations2);
521
522 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(110, 60, 20, 10)));
523 EXPECT_TRUE(
524 CGRectEqualToRect(mutatorView.subviews.firstObject.frame, CGRectMake(-10, -10, 30, 20)));
525 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
526 EXPECT_EQ(mutatorView.pathClipViews.count, 1ul);
527
528 EXPECT_EQ(platformView.superview, mutatorView.platformViewContainer);
529 EXPECT_EQ(mutatorView.platformViewContainer.superview, mutatorView.pathClipViews[0]);
530 EXPECT_EQ(mutatorView.pathClipViews[0].superview, mutatorView);
531
532 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
533
534 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(100, 50, 30, 20)));
535 EXPECT_EQ(mutatorView.pathClipViews.count, 0ull);
536 }

## ◆ TEST() [9/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | RectsClipsToPathWhenRotated |
| ) |  |

Definition at line 340 of file FlutterMutatorViewTest.mm.

340 {
341 NSView* platformView = [[NSView alloc] init];
342 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
343 std::vector<FlutterPlatformViewMutation> mutations{
344 {
345 .type = kFlutterPlatformViewMutationTypeTransformation,
346 // Roation M_PI / 8
347 .transformation =
348 FlutterTransformation{
349 .scaleX = 0.9238795325112867,
350 .skewX = -0.3826834323650898,
351 .skewY = 0.3826834323650898,
352 .scaleY = 0.9238795325112867,
353 },
354 },
355 {
356 .type = kFlutterPlatformViewMutationTypeClipRect,
357 .clip_rect = FlutterRect{110, 60, 150, 150},
358 },
359 {
360 .type = kFlutterPlatformViewMutationTypeTransformation,
361 .transformation =
362 FlutterTransformation{
363 .scaleX = 1,
364 .transX = 100,
365 .scaleY = 1,
366 .transY = 50,
367 },
368 },
369 };
370 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
371 EXPECT_EQ(mutatorView.pathClipViews.count, 1ul);
372 EXPECT_NEAR(mutatorView.platformViewContainer.frame.size.width, 35.370054622640396, kMaxErr);
373 EXPECT_NEAR(mutatorView.platformViewContainer.frame.size.height, 29.958093621178421, kMaxErr);
374 }

References kMaxErr.

## ◆ TEST() [10/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | ReparentingPlatformView |
| ) |  |

Definition at line 565 of file FlutterMutatorViewTest.mm.

565 {
566 NSView* platformView = [[NSView alloc] init];
567 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
568 ApplyFlutterLayer(mutatorView, FlutterSize{100, 100}, {});
569 EXPECT_TRUE(platformView.superview == mutatorView.platformViewContainer);
570 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 100, 100)));
571
572 // Reparent platform view and replace it with placeholder (mimicking WKWebKit going full screen)
573 NSView* newParent = [[NSView alloc] init];
574 [newParent addSubview:platformView];
575 platformView.frame = CGRectMake(10, 10, 200, 200);
576
577 NSView* placeholderView = [[NSView alloc] init];
578 [mutatorView.platformViewContainer addSubview:placeholderView];
579 ApplyFlutterLayer(mutatorView, FlutterSize{100, 100}, {});
580
581 // Platform view should not be touched but the replacement view should be properly positioned.
582 EXPECT_TRUE(platformView.superview == newParent);
583 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(10, 10, 200, 200)));
584 EXPECT_TRUE(CGRectEqualToRect(placeholderView.frame, CGRectMake(0, 0, 100, 100)));
585 }

## ◆ TEST() [11/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | RoundRectClipsToPath |
| ) |  |

Definition at line 376 of file FlutterMutatorViewTest.mm.

376 {
377 NSView* platformView = [[NSView alloc] init];
378 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
379
380 std::vector<FlutterPlatformViewMutation> mutations{
381 {
382 .type = kFlutterPlatformViewMutationTypeClipRoundedRect,
383 .clip_rounded_rect =
384 FlutterRoundedRect{
385 .rect = FlutterRect{110, 60, 150, 150},
386 .upper_left_corner_radius = FlutterSize{10, 10},
387 .upper_right_corner_radius = FlutterSize{10, 10},
388 .lower_right_corner_radius = FlutterSize{10, 10},
389 .lower_left_corner_radius = FlutterSize{10, 10},
390 },
391 },
392 {
393 .type = kFlutterPlatformViewMutationTypeTransformation,
394 .transformation =
395 FlutterTransformation{
396 .scaleX = 1,
397 .transX = 100,
398 .scaleY = 1,
399 .transY = 50,
400 },
401 },
402 };
403
404 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
405
406 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(110, 60, 20, 10)));
407 EXPECT_TRUE(
408 CGRectEqualToRect(mutatorView.subviews.firstObject.frame, CGRectMake(-10, -10, 30, 20)));
409 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
410 EXPECT_EQ(mutatorView.pathClipViews.count, 1ul);
411 ExpectTransform3DEqual(mutatorView.pathClipViews.firstObject.layer.mask.transform,
412 CATransform3DMakeTranslation(-100, -50, 0));
413 }

## ◆ TEST() [12/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | RoundRectClipsToSimpleRectangle |
| ) |  |

Definition at line 264 of file FlutterMutatorViewTest.mm.

264 {
265 NSView* platformView = [[NSView alloc] init];
266 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
267
268 std::vector<FlutterPlatformViewMutation> mutations{
269 {
270 .type = kFlutterPlatformViewMutationTypeClipRoundedRect,
271 .clip_rounded_rect =
272 FlutterRoundedRect{
273 .rect = FlutterRect{110, 30, 120, 90},
274 .upper_left_corner_radius = FlutterSize{10, 10},
275 .upper_right_corner_radius = FlutterSize{10, 10},
276 .lower_right_corner_radius = FlutterSize{10, 10},
277 .lower_left_corner_radius = FlutterSize{10, 10},
278 },
279 },
280 {
281 .type = kFlutterPlatformViewMutationTypeTransformation,
282 .transformation =
283 FlutterTransformation{
284 .scaleX = 1,
285 .transX = 100,
286 .scaleY = 1,
287 .transY = 50,
288 },
289 },
290 };
291
292 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
293
294 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(110, 50, 10, 20)));
295 EXPECT_TRUE(
296 CGRectEqualToRect(mutatorView.subviews.firstObject.frame, CGRectMake(-10, 0, 30, 20)));
297 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
298 EXPECT_EQ(mutatorView.pathClipViews.count, 0ul);
299 }

## ◆ TEST() [13/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | TransformedFrameIsCorrect |
| ) |  |

Definition at line 96 of file FlutterMutatorViewTest.mm.

96 {
97 NSView* platformView = [[NSView alloc] init];
98 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
99 NSView* mutatorViewParent = [[NSView alloc] init];
100 mutatorViewParent.wantsLayer = YES;
101 mutatorViewParent.layer.contentsScale = 2.0;
102 [mutatorViewParent addSubview:mutatorView];
103
104 std::vector<FlutterPlatformViewMutation> mutations{
105 {
106 .type = kFlutterPlatformViewMutationTypeTransformation,
107 .transformation =
108 FlutterTransformation{
109 .scaleX = 2,
110 .scaleY = 2,
111 },
112 },
113 {
114 .type = kFlutterPlatformViewMutationTypeTransformation,
115 .transformation =
116 FlutterTransformation{
117 .scaleX = 1,
118 .transX = 100,
119 .scaleY = 1,
120 .transY = 50,
121 },
122 },
123 {
124 .type = kFlutterPlatformViewMutationTypeTransformation,
125 .transformation =
126 FlutterTransformation{
127 .scaleX = 1.5,
128 .transX = -7.5,
129 .scaleY = 1.5,
130 .transY = -5,
131 },
132 },
133 };
134
135 // PlatformView size form engine comes in physical pixels
136 ApplyFlutterLayer(mutatorView, FlutterSize{30 * 2, 20 * 2}, mutations);
137 EXPECT_TRUE(CGRectEqualToRect(mutatorView.frame, CGRectMake(92.5, 45, 45, 30)));
138 EXPECT_TRUE(CGRectEqualToRect(platformView.frame, CGRectMake(0, 0, 30, 20)));
139
140 ExpectTransform3DEqual(mutatorView.platformViewContainer.layer.sublayerTransform,
141 CATransform3DMakeScale(1.5, 1.5, 1));
142 }

## ◆ TEST() [14/14]

TEST | ( | FlutterMutatorViewTest | ,
|  | ViewsSetIsFlipped |
| ) |  |

Definition at line 304 of file FlutterMutatorViewTest.mm.

304 {
305 NSView* platformView = [[NSView alloc] init];
306 FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
307
308 std::vector<FlutterPlatformViewMutation> mutations{
309 {
310 .type = kFlutterPlatformViewMutationTypeClipRoundedRect,
311 .clip_rounded_rect =
312 FlutterRoundedRect{
313 .rect = FlutterRect{110, 60, 150, 150},
314 .upper_left_corner_radius = FlutterSize{10, 10},
315 .upper_right_corner_radius = FlutterSize{10, 10},
316 .lower_right_corner_radius = FlutterSize{10, 10},
317 .lower_left_corner_radius = FlutterSize{10, 10},
318 },
319 },
320 {
321 .type = kFlutterPlatformViewMutationTypeTransformation,
322 .transformation =
323 FlutterTransformation{
324 .scaleX = 1,
325 .transX = 100,
326 .scaleY = 1,
327 .transY = 50,
328 },
329 },
330 };
331
332 ApplyFlutterLayer(mutatorView, FlutterSize{30, 20}, mutations);
333
334 EXPECT_TRUE(mutatorView.isFlipped);
335 ASSERT_EQ(mutatorView.pathClipViews.count, 1ul);
336 EXPECT_TRUE(mutatorView.pathClipViews.firstObject.isFlipped);
337 EXPECT_TRUE(mutatorView.platformViewContainer.isFlipped);
338 }

## Variable Documentation

## ◆ kMaxErr

constexpr float kMaxErr = 1e-10
| staticconstexpr

Definition at line 20 of file FlutterMutatorViewTest.mm.

Referenced by TEST().

FlutterMutatorView
Definition: FlutterMutatorView.h:63
FlutterMutatorView::platformView
NSView * platformView
Returns wrapped platform view.
Definition: FlutterMutatorView.h:72
kMaxErr
static constexpr float kMaxErr
Definition: FlutterMutatorViewTest.mm:20
FlutterCursorCoordinatorTest
Definition: FlutterMutatorViewTest.mm:587