transform_test.dart 21.4 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
Hixie's avatar
Hixie committed
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8
// This file is run as part of a reduced test set in CI on Mac and Windows
// machines.
@Tags(<String>['reduced-test-set'])

9
import 'dart:math' as math;
10
import 'dart:ui' as ui;
11

12
import 'package:flutter/rendering.dart';
13
import 'package:flutter/widgets.dart';
14
import 'package:flutter_test/flutter_test.dart';
15
import 'package:vector_math/vector_math_64.dart';
16 17

void main() {
18
  testWidgets('Transform origin', (WidgetTester tester) async {
19
    bool didReceiveTap = false;
20
    await tester.pumpWidget(
21
      Directionality(
22
        textDirection: TextDirection.ltr,
23
        child: Stack(
24
          children: <Widget>[
25
            Positioned(
26 27
              top: 100.0,
              left: 100.0,
28
              child: Container(
29 30 31 32
                width: 100.0,
                height: 100.0,
                color: const Color(0xFF0000FF),
              ),
33
            ),
34
            Positioned(
35 36
              top: 100.0,
              left: 100.0,
37
              child: SizedBox(
38 39
                width: 100.0,
                height: 100.0,
40 41
                child: Transform(
                  transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0),
42
                  origin: const Offset(100.0, 50.0),
43
                  child: GestureDetector(
44 45 46
                    onTap: () {
                      didReceiveTap = true;
                    },
47
                    child: Container(
48 49
                      color: const Color(0xFF00FFFF),
                    ),
50 51 52 53
                  ),
                ),
              ),
            ),
54 55
          ],
        ),
56
      ),
57
    );
58

59
    expect(didReceiveTap, isFalse);
60
    await tester.tapAt(const Offset(110.0, 110.0));
61
    expect(didReceiveTap, isFalse);
62
    await tester.tapAt(const Offset(190.0, 150.0));
63
    expect(didReceiveTap, isTrue);
64
  });
Hixie's avatar
Hixie committed
65

66
  testWidgets('Transform alignment', (WidgetTester tester) async {
67
    bool didReceiveTap = false;
68
    await tester.pumpWidget(
69
      Directionality(
70
        textDirection: TextDirection.ltr,
71
        child: Stack(
72
          children: <Widget>[
73
            Positioned(
74 75
              top: 100.0,
              left: 100.0,
76
              child: Container(
77 78 79 80
                width: 100.0,
                height: 100.0,
                color: const Color(0xFF0000FF),
              ),
81
            ),
82
            Positioned(
83 84
              top: 100.0,
              left: 100.0,
85
              child: SizedBox(
86 87
                width: 100.0,
                height: 100.0,
88 89
                child: Transform(
                  transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0),
90
                  alignment: Alignment.centerRight,
91
                  child: GestureDetector(
92 93 94
                    onTap: () {
                      didReceiveTap = true;
                    },
95
                    child: Container(
96 97
                      color: const Color(0xFF00FFFF),
                    ),
98 99 100 101
                  ),
                ),
              ),
            ),
102 103
          ],
        ),
104
      ),
105
    );
Hixie's avatar
Hixie committed
106

107
    expect(didReceiveTap, isFalse);
108
    await tester.tapAt(const Offset(110.0, 110.0));
109
    expect(didReceiveTap, isFalse);
110
    await tester.tapAt(const Offset(190.0, 150.0));
111
    expect(didReceiveTap, isTrue);
Hixie's avatar
Hixie committed
112 113
  });

114 115 116 117
  testWidgets('Transform AlignmentDirectional alignment', (WidgetTester tester) async {
    bool didReceiveTap = false;

    Widget buildFrame(TextDirection textDirection, AlignmentGeometry alignment) {
118
      return Directionality(
119
        textDirection: textDirection,
120
        child: Stack(
121
          children: <Widget>[
122
            Positioned(
123 124
              top: 100.0,
              left: 100.0,
125
              child: Container(
126 127 128 129 130
                width: 100.0,
                height: 100.0,
                color: const Color(0xFF0000FF),
              ),
            ),
131
            Positioned(
132 133
              top: 100.0,
              left: 100.0,
134
              child: SizedBox(
135 136
                width: 100.0,
                height: 100.0,
137 138
                child: Transform(
                  transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0),
139
                  alignment: alignment,
140
                  child: GestureDetector(
141 142 143
                    onTap: () {
                      didReceiveTap = true;
                    },
144
                    child: Container(
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
                      color: const Color(0xFF00FFFF),
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      );
    }

    await tester.pumpWidget(buildFrame(TextDirection.ltr, AlignmentDirectional.centerEnd));
    didReceiveTap = false;
    await tester.tapAt(const Offset(110.0, 110.0));
    expect(didReceiveTap, isFalse);
    await tester.tapAt(const Offset(190.0, 150.0));
    expect(didReceiveTap, isTrue);

    await tester.pumpWidget(buildFrame(TextDirection.rtl, AlignmentDirectional.centerStart));
    didReceiveTap = false;
    await tester.tapAt(const Offset(110.0, 110.0));
    expect(didReceiveTap, isFalse);
    await tester.tapAt(const Offset(190.0, 150.0));
    expect(didReceiveTap, isTrue);

    await tester.pumpWidget(buildFrame(TextDirection.ltr, AlignmentDirectional.centerStart));
    didReceiveTap = false;
    await tester.tapAt(const Offset(190.0, 150.0));
    expect(didReceiveTap, isFalse);
    await tester.tapAt(const Offset(110.0, 150.0));
    expect(didReceiveTap, isTrue);

    await tester.pumpWidget(buildFrame(TextDirection.rtl, AlignmentDirectional.centerEnd));
    didReceiveTap = false;
    await tester.tapAt(const Offset(190.0, 150.0));
    expect(didReceiveTap, isFalse);
    await tester.tapAt(const Offset(110.0, 150.0));
    expect(didReceiveTap, isTrue);
  });

185
  testWidgets('Transform offset + alignment', (WidgetTester tester) async {
186
    bool didReceiveTap = false;
187
    await tester.pumpWidget(
188
      Directionality(
189
        textDirection: TextDirection.ltr,
190
        child: Stack(
191
          children: <Widget>[
192
            Positioned(
193 194
              top: 100.0,
              left: 100.0,
195
              child: Container(
196 197 198 199 200
                width: 100.0,
                height: 100.0,
                color: const Color(0xFF0000FF),
              ),
            ),
201
            Positioned(
202 203
              top: 100.0,
              left: 100.0,
204
              child: SizedBox(
205 206
                width: 100.0,
                height: 100.0,
207 208
                child: Transform(
                  transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0),
209
                  origin: const Offset(100.0, 0.0),
210
                  alignment: Alignment.centerLeft,
211
                  child: GestureDetector(
212 213 214
                    onTap: () {
                      didReceiveTap = true;
                    },
215
                    child: Container(
216 217 218
                      color: const Color(0xFF00FFFF),
                    ),
                  ),
219 220 221
                ),
              ),
            ),
222
          ],
223
        ),
224 225
      ),
    );
Hixie's avatar
Hixie committed
226

227
    expect(didReceiveTap, isFalse);
228
    await tester.tapAt(const Offset(110.0, 110.0));
229
    expect(didReceiveTap, isFalse);
230
    await tester.tapAt(const Offset(190.0, 150.0));
231
    expect(didReceiveTap, isTrue);
Hixie's avatar
Hixie committed
232
  });
233 234 235

  testWidgets('Composited transform offset', (WidgetTester tester) async {
    await tester.pumpWidget(
236 237
      Center(
        child: SizedBox(
238 239
          width: 400.0,
          height: 300.0,
240 241 242
          child: ClipRect(
            child: Transform(
              transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0),
243
              child: RepaintBoundary(
244
                child: Container(
245
                  color: const Color(0xFF00FF00),
246 247 248 249 250 251 252 253
                ),
              ),
            ),
          ),
        ),
      ),
    );

254
    final List<Layer> layers = tester.layers
255 256 257
      ..retainWhere((Layer layer) => layer is TransformLayer);
    expect(layers.length, 2);
    // The first transform is from the render view.
258
    final TransformLayer layer = layers[1] as TransformLayer;
259
    final Matrix4 transform = layer.transform!;
260
    expect(transform.getTranslation(), equals(Vector3(100.0, 75.0, 0.0)));
261
  });
262 263 264

  testWidgets('Transform.rotate', (WidgetTester tester) async {
    await tester.pumpWidget(
265
      Transform.rotate(
266
        angle: math.pi / 2.0,
267
        child: RepaintBoundary(child: Container()),
268 269 270 271 272 273 274
      ),
    );

    final List<Layer> layers = tester.layers
      ..retainWhere((Layer layer) => layer is TransformLayer);
    expect(layers.length, 2);
    // The first transform is from the render view.
275
    final TransformLayer layer = layers[1] as TransformLayer;
276
    final Matrix4 transform = layer.transform!;
277 278 279 280 281 282 283
    expect(transform.storage, <dynamic>[
      moreOrLessEquals(0.0), 1.0, 0.0, 0.0,
      -1.0, moreOrLessEquals(0.0), 0.0, 0.0,
      0.0, 0.0, 1.0, 0.0,
      700.0, -100.0, 0.0, 1.0,
    ]);
  });
284 285 286

  testWidgets('applyPaintTransform of Transform in Padding', (WidgetTester tester) async {
    await tester.pumpWidget(
287
      Padding(
288 289 290 291 292 293
        padding: const EdgeInsets.only(
          left: 30.0,
          top: 20.0,
          right: 50.0,
          bottom: 70.0,
        ),
294 295
        child: Transform(
          transform: Matrix4.diagonal3Values(2.0, 2.0, 2.0),
296 297 298 299 300 301
          child: const Placeholder(),
        ),
      ),
    );
    expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(30.0, 20.0));
  });
302 303 304

  testWidgets('Transform.translate', (WidgetTester tester) async {
    await tester.pumpWidget(
305
      Transform.translate(
306
        offset: const Offset(100.0, 50.0),
307
        child: RepaintBoundary(child: Container()),
308 309 310 311 312 313 314 315 316 317 318 319
      ),
    );

    // This should not cause a transform layer to be inserted.
    final List<Layer> layers = tester.layers
      ..retainWhere((Layer layer) => layer is TransformLayer);
    expect(layers.length, 1); // only the render view
    expect(tester.getTopLeft(find.byType(Container)), const Offset(100.0, 50.0));
  });

  testWidgets('Transform.scale', (WidgetTester tester) async {
    await tester.pumpWidget(
320
      Transform.scale(
321
        scale: 2.0,
322
        child: RepaintBoundary(child: Container()),
323 324 325 326 327 328 329
      ),
    );

    final List<Layer> layers = tester.layers
      ..retainWhere((Layer layer) => layer is TransformLayer);
    expect(layers.length, 2);
    // The first transform is from the render view.
330
    final TransformLayer layer = layers[1] as TransformLayer;
331
    final Matrix4 transform = layer.transform!;
332 333 334 335 336 337 338 339
    expect(transform.storage, <dynamic>[
      // These are column-major, not row-major.
      2.0, 0.0, 0.0, 0.0,
      0.0, 2.0, 0.0, 0.0,
      0.0, 0.0, 1.0, 0.0,
      -400.0, -300.0, 0.0, 1.0, // it's 1600x1200, centered in an 800x600 square
    ]);
  });
Emmanuel Garcia's avatar
Emmanuel Garcia committed
340 341

  testWidgets('Translated child into translated box - hit test', (WidgetTester tester) async {
342
    final GlobalKey key1 = GlobalKey();
343
    bool pointerDown = false;
Emmanuel Garcia's avatar
Emmanuel Garcia committed
344
    await tester.pumpWidget(
345
      Transform.translate(
Emmanuel Garcia's avatar
Emmanuel Garcia committed
346
        offset: const Offset(100.0, 50.0),
347
        child: Transform.translate(
Emmanuel Garcia's avatar
Emmanuel Garcia committed
348
          offset: const Offset(1000.0, 1000.0),
349
          child: Listener(
Emmanuel Garcia's avatar
Emmanuel Garcia committed
350
            onPointerDown: (PointerDownEvent event) {
351
              pointerDown = true;
Emmanuel Garcia's avatar
Emmanuel Garcia committed
352
            },
353
            child: Container(
Emmanuel Garcia's avatar
Emmanuel Garcia committed
354 355
              key: key1,
              color: const Color(0xFF000000),
356 357 358
            ),
          ),
        ),
Emmanuel Garcia's avatar
Emmanuel Garcia committed
359 360
      ),
    );
361
    expect(pointerDown, isFalse);
Emmanuel Garcia's avatar
Emmanuel Garcia committed
362
    await tester.tap(find.byKey(key1));
363
    expect(pointerDown, isTrue);
Emmanuel Garcia's avatar
Emmanuel Garcia committed
364
  });
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383

  Widget _generateTransform(bool needsCompositing, double angle) {
    final Widget customPaint = CustomPaint(painter: TestRectPainter());
    return Transform(
      transform: MatrixUtils.createCylindricalProjectionTransform(
        radius: 100,
        angle: angle,
        perspective: 0.003,
      ),
      // A RepaintBoundary child forces the Transform to needsCompositing
      child: needsCompositing ? RepaintBoundary(child: customPaint) : customPaint,
    );
  }

  testWidgets(
    '3D transform renders the same with or without needsCompositing',
    (WidgetTester tester) async {
      for (double angle = 0; angle <= math.pi/4; angle += 0.01) {
        await tester.pumpWidget(RepaintBoundary(child: _generateTransform(true, angle)));
384 385
        final RenderBox renderBox = tester.binding.renderView.child!;
        final OffsetLayer layer = renderBox.debugLayer! as OffsetLayer;
386 387 388 389 390 391
        final ui.Image imageWithCompositing = await layer.toImage(renderBox.paintBounds);

        await tester.pumpWidget(RepaintBoundary(child: _generateTransform(false, angle)));
        await expectLater(find.byType(RepaintBoundary).first, matchesReferenceImage(imageWithCompositing));
      }
    },
392
    skip: isBrowser, // due to https://github.com/flutter/flutter/issues/49857
393
  );
394

395 396 397 398 399
  List<double> extractMatrix(ui.ImageFilter? filter) {
    final List<String> numbers = filter.toString().split('[').last.split(']').first.split(',');
    return numbers.map<double>((String str) => double.parse(str.trim())).toList();
  }

400 401 402 403 404
  testWidgets('Transform.translate with FilterQuality produces filter layer', (WidgetTester tester) async {
    await tester.pumpWidget(
      Transform.translate(
        offset: const Offset(25.0, 25.0),
        filterQuality: FilterQuality.low,
405
        child: const SizedBox(width: 100, height: 100),
406 407 408
      ),
    );
    expect(tester.layers.whereType<ImageFilterLayer>().length, 1);
409 410 411 412 413 414 415
    final ImageFilterLayer layer = tester.layers.whereType<ImageFilterLayer>().first;
    expect(extractMatrix(layer.imageFilter), <double>[
      1.0, 0.0, 0.0, 0.0,
      0.0, 1.0, 0.0, 0.0,
      0.0, 0.0, 1.0, 0.0,
      25.0, 25.0, 0.0, 1.0]
    );
416 417 418 419 420 421 422
  });

  testWidgets('Transform.scale with FilterQuality produces filter layer', (WidgetTester tester) async {
    await tester.pumpWidget(
      Transform.scale(
        scale: 3.14159,
        filterQuality: FilterQuality.low,
423
        child: const SizedBox(width: 100, height: 100),
424 425 426
      ),
    );
    expect(tester.layers.whereType<ImageFilterLayer>().length, 1);
427 428 429 430 431 432 433
    final ImageFilterLayer layer = tester.layers.whereType<ImageFilterLayer>().first;
    expect(extractMatrix(layer.imageFilter), <double>[
      3.14159, 0.0, 0.0, 0.0,
      0.0, 3.14159, 0.0, 0.0,
      0.0, 0.0, 1.0, 0.0,
      -856.636, -642.477, 0.0, 1.0]
    );
434 435 436 437 438 439 440
  });

  testWidgets('Transform.rotate with FilterQuality produces filter layer', (WidgetTester tester) async {
    await tester.pumpWidget(
      Transform.rotate(
        angle: math.pi / 4,
        filterQuality: FilterQuality.low,
441
        child: const SizedBox(width: 100, height: 100),
442 443 444
      ),
    );
    expect(tester.layers.whereType<ImageFilterLayer>().length, 1);
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
    final ImageFilterLayer layer = tester.layers.whereType<ImageFilterLayer>().first;
    expect(extractMatrix(layer.imageFilter), <dynamic>[
      moreOrLessEquals(0.7071067811865476), moreOrLessEquals(0.7071067811865475), 0.0, 0.0,
      moreOrLessEquals(-0.7071067811865475), moreOrLessEquals(0.7071067811865476), 0.0, 0.0,
      0.0, 0.0, 1.0, 0.0,
      moreOrLessEquals(329.28932188134524), moreOrLessEquals(-194.97474683058329), 0.0, 1.0]
    );
  });

  testWidgets('Offset Transform.rotate with FilterQuality produces filter layer', (WidgetTester tester) async {
    await tester.pumpWidget(
      SizedBox(width: 400, height: 400,
        child: Center(
          child: Transform.rotate(
            angle: math.pi / 4,
            filterQuality: FilterQuality.low,
            child: const SizedBox(width: 100, height: 100),
          ),
        ),
      ),
    );
    expect(tester.layers.whereType<ImageFilterLayer>().length, 1);
    final ImageFilterLayer layer = tester.layers.whereType<ImageFilterLayer>().first;
    expect(extractMatrix(layer.imageFilter), <dynamic>[
      moreOrLessEquals(0.7071067811865476), moreOrLessEquals(0.7071067811865475), 0.0, 0.0,
      moreOrLessEquals(-0.7071067811865475), moreOrLessEquals(0.7071067811865476), 0.0, 0.0,
      0.0, 0.0, 1.0, 0.0,
      moreOrLessEquals(329.28932188134524), moreOrLessEquals(-194.97474683058329), 0.0, 1.0]
    );
474 475 476 477 478 479 480
  });

  testWidgets('Transform layers update to match child and filterQuality', (WidgetTester tester) async {
    await tester.pumpWidget(
      Transform.rotate(
        angle: math.pi / 4,
        filterQuality: FilterQuality.low,
481
        child: const SizedBox(width: 100, height: 100),
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
      ),
    );
    expect(tester.layers.whereType<ImageFilterLayer>(), hasLength(1));

    await tester.pumpWidget(
      Transform.rotate(
        angle: math.pi / 4,
        child: const SizedBox(width: 100, height: 100),
      ),
    );
    expect(tester.layers.whereType<ImageFilterLayer>(), isEmpty);

    await tester.pumpWidget(
      Transform.rotate(
        angle: math.pi / 4,
        filterQuality: FilterQuality.low,
      ),
    );
    expect(tester.layers.whereType<ImageFilterLayer>(), isEmpty);

    await tester.pumpWidget(
      Transform.rotate(
        angle: math.pi / 4,
        filterQuality: FilterQuality.low,
506
        child: const SizedBox(width: 100, height: 100),
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
      ),
    );
    expect(tester.layers.whereType<ImageFilterLayer>(), hasLength(1));
  });

  testWidgets('Transform layers with filterQuality golden', (WidgetTester tester) async {
    await tester.pumpWidget(
      Directionality(
        textDirection: TextDirection.ltr,
        child: GridView.count(
          crossAxisCount: 3,
          children: <Widget>[
            Transform.rotate(
              angle: math.pi / 6,
              child: Center(child: Container(width: 100, height: 20, color: const Color(0xffffff00))),
            ),
            Transform.scale(
              scale: 1.5,
              child: Center(child: Container(width: 100, height: 20, color: const Color(0xffffff00))),
            ),
            Transform.translate(
              offset: const Offset(20.0, 60.0),
              child: Center(child: Container(width: 100, height: 20, color: const Color(0xffffff00))),
            ),
            Transform.rotate(
              angle: math.pi / 6,
              filterQuality: FilterQuality.low,
534
              child: Center(child: Container(width: 100, height: 20, color: const Color(0xff00ff00))),
535 536 537 538
            ),
            Transform.scale(
              scale: 1.5,
              filterQuality: FilterQuality.low,
539
              child: Center(child: Container(width: 100, height: 20, color: const Color(0xff00ff00))),
540 541 542 543
            ),
            Transform.translate(
              offset: const Offset(20.0, 60.0),
              filterQuality: FilterQuality.low,
544
              child: Center(child: Container(width: 100, height: 20, color: const Color(0xff00ff00))),
545 546 547 548 549 550 551 552 553 554
            ),
          ],
        ),
      ),
    );
    await expectLater(
      find.byType(GridView),
      matchesGoldenFile('transform_golden.BitmapRotate.png'),
    );
  });
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589

  testWidgets("Transform.scale() does not accept all three 'scale', 'scaleX' and 'scaleY' parameters to be non-null", (WidgetTester tester) async {
    await expectLater(() {
      tester.pumpWidget(Directionality(
          textDirection: TextDirection.ltr,
          child: Center(
            child: Transform.scale(
              scale: 1.0,
              scaleX: 1.0,
              scaleY: 1.0,
              child: const SizedBox(
                height: 100,
                width: 100,
              ),
            ),
          )));
    }, throwsAssertionError);
  });

  testWidgets("Transform.scale() needs at least one of 'scale', 'scaleX' and 'scaleY' to be non-null, otherwise throws AssertionError", (WidgetTester tester) async {
    await expectLater(() {
      tester.pumpWidget(Directionality(
          textDirection: TextDirection.ltr,
          child: Center(
            child: Transform.scale(
              child: const SizedBox(
                height: 100,
                width: 100,
              ),
            ),
          )));
    }, throwsAssertionError);
  });

  testWidgets("Transform.scale() scales widget uniformly with 'scale' parameter", (WidgetTester tester) async {
590 591 592
    const double scale = 1.5;
    const double height = 100;
    const double width = 150;
593 594 595 596 597 598 599
    await tester.pumpWidget(Directionality(
        textDirection: TextDirection.ltr,
        child: SizedBox(
          height: 400,
          width: 400,
          child: Center(
            child: Transform.scale(
600
              scale: scale,
601
              child: Container(
602 603
                height: height,
                width: width,
604 605 606 607 608 609
                decoration: const BoxDecoration(),
              ),
            ),
          ),
        )));

610
    const Size target = Size(width * scale, height * scale);
611

612
    expect(tester.getBottomRight(find.byType(Container)), target.bottomRight(tester.getTopLeft(find.byType(Container))));
613 614 615
  });

  testWidgets("Transform.scale() scales widget according to 'scaleX' and 'scaleY'", (WidgetTester tester) async {
616 617 618 619
    const double scaleX = 1.5;
    const double scaleY = 1.2;
    const double height = 100;
    const double width = 150;
620 621 622 623 624 625 626
    await tester.pumpWidget(Directionality(
        textDirection: TextDirection.ltr,
        child: SizedBox(
          height: 400,
          width: 400,
          child: Center(
            child: Transform.scale(
627 628
              scaleX: scaleX,
              scaleY: scaleY,
629
              child: Container(
630 631
                height: height,
                width: width,
632 633 634 635 636 637
                decoration: const BoxDecoration(),
              ),
            ),
          ),
        )));

638
    const Size target = Size(width * scaleX, height * scaleY);
639

640
    expect(tester.getBottomRight(find.byType(Container)), target.bottomRight(tester.getTopLeft(find.byType(Container))));
641
  });
642 643 644 645 646 647 648 649 650 651 652 653
}

class TestRectPainter extends CustomPainter {
  @override
  void paint(ui.Canvas canvas, ui.Size size) {
    canvas.drawRect(
      const Offset(200, 200) & const Size(10, 10),
      Paint()..color = const Color(0xFFFF0000),
    );
  }
  @override
  bool shouldRepaint(CustomPainter oldDelegate) => true;
654
}