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

import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
7
import 'package:flutter_test/flutter_test.dart';
8
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
9 10

void main() {
11 12
  // DOWN (default)

13
  testWidgetsWithLeakTracking('Column with one flexible child', (WidgetTester tester) async {
14 15 16 17
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
18 19 20 21

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // Default is MainAxisAlignment.start so children so the children's
    // top edges should be at 0, 100, 500, child2's height should be 400.
22
    await tester.pumpWidget(const Center(
23
      child: Column(
24
        key: columnKey,
25
        children: <Widget>[
26 27 28
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          Expanded(child: SizedBox(key: child1Key, width: 100.0, height: 100.0)),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
29 30
        ],
      ),
31 32 33 34 35 36 37 38 39 40 41 42
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
43
    boxParentData = renderBox.parentData! as BoxParentData;
44 45 46 47 48
    expect(boxParentData.offset.dy, equals(0.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(400.0));
49
    boxParentData = renderBox.parentData! as BoxParentData;
50 51 52 53 54
    expect(boxParentData.offset.dy, equals(100.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
55
    boxParentData = renderBox.parentData! as BoxParentData;
56 57 58
    expect(boxParentData.offset.dy, equals(500.0));
  });

59
  testWidgetsWithLeakTracking('Column with default main axis parameters', (WidgetTester tester) async {
60 61 62 63
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
64 65 66 67

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // Default is MainAxisAlignment.start so children so the children's
    // top edges should be at 0, 100, 200
68
    await tester.pumpWidget(const Center(
69
      child: Column(
70
        key: columnKey,
71
        children: <Widget>[
72 73 74
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
75 76
        ],
      ),
77 78 79 80 81 82 83 84 85 86 87 88
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
89
    boxParentData = renderBox.parentData! as BoxParentData;
90 91 92 93 94
    expect(boxParentData.offset.dy, equals(0.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
95
    boxParentData = renderBox.parentData! as BoxParentData;
96 97 98 99 100
    expect(boxParentData.offset.dy, equals(100.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
101
    boxParentData = renderBox.parentData! as BoxParentData;
102 103 104
    expect(boxParentData.offset.dy, equals(200.0));
  });

105
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.center', (WidgetTester tester) async {
106 107 108
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
109 110 111

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x100 children's top edges should be at 200, 300
112
    await tester.pumpWidget(const Center(
113
      child: Column(
114 115
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.center,
116
        children: <Widget>[
117 118
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
119 120
        ],
      ),
121 122 123 124 125 126 127 128 129 130 131 132
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
133
    boxParentData = renderBox.parentData! as BoxParentData;
134 135 136 137 138
    expect(boxParentData.offset.dy, equals(200.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
139
    boxParentData = renderBox.parentData! as BoxParentData;
140 141 142
    expect(boxParentData.offset.dy, equals(300.0));
  });

143
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.end', (WidgetTester tester) async {
144 145 146 147
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
148 149 150

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x100 children's top edges should be at 300, 400, 500.
151
    await tester.pumpWidget(const Center(
152
      child: Column(
153 154
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.end,
155
        children: <Widget>[
156 157 158
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
159 160
        ],
      ),
161 162 163 164 165 166 167 168 169 170 171 172
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
173
    boxParentData = renderBox.parentData! as BoxParentData;
174 175 176 177 178
    expect(boxParentData.offset.dy, equals(300.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
179
    boxParentData = renderBox.parentData! as BoxParentData;
180 181 182 183 184
    expect(boxParentData.offset.dy, equals(400.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
185
    boxParentData = renderBox.parentData! as BoxParentData;
186 187 188
    expect(boxParentData.offset.dy, equals(500.0));
  });

189
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
190 191 192 193
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
194 195 196

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x100 children's top edges should be at 0, 250, 500
197
    await tester.pumpWidget(const Center(
198
      child: Column(
199 200
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
201
        children: <Widget>[
202 203 204
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
205 206
        ],
      ),
207 208 209 210 211 212 213 214 215 216 217 218
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
219
    boxParentData = renderBox.parentData! as BoxParentData;
220 221 222 223 224
    expect(boxParentData.offset.dy, equals(0.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
225
    boxParentData = renderBox.parentData! as BoxParentData;
226 227 228 229 230
    expect(boxParentData.offset.dy, equals(250.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
231
    boxParentData = renderBox.parentData! as BoxParentData;
232 233 234
    expect(boxParentData.offset.dy, equals(500.0));
  });

235
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
236 237 238 239 240
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
    const Key child3Key = Key('child3');
241 242 243

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x100 children's top edges should be at 25, 175, 325, 475
244
    await tester.pumpWidget(const Center(
245
      child: Column(
246 247
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.spaceAround,
248
        children: <Widget>[
249 250 251 252
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
          SizedBox(key: child3Key, width: 100.0, height: 100.0),
253 254
        ],
      ),
255 256 257 258 259 260 261 262 263 264 265 266
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
267
    boxParentData = renderBox.parentData! as BoxParentData;
268 269 270 271 272
    expect(boxParentData.offset.dy, equals(25.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
273
    boxParentData = renderBox.parentData! as BoxParentData;
274 275 276 277 278
    expect(boxParentData.offset.dy, equals(175.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
279
    boxParentData = renderBox.parentData! as BoxParentData;
280 281 282 283 284
    expect(boxParentData.offset.dy, equals(325.0));

    renderBox = tester.renderObject(find.byKey(child3Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
285
    boxParentData = renderBox.parentData! as BoxParentData;
286 287 288
    expect(boxParentData.offset.dy, equals(475.0));
  });

289
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
290 291 292 293
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
294 295 296

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x20 children's top edges should be at 135, 290, 445
297
    await tester.pumpWidget(const Center(
298
      child: Column(
299 300
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
301
        children: <Widget>[
302 303 304
          SizedBox(key: child0Key, width: 100.0, height: 20.0),
          SizedBox(key: child1Key, width: 100.0, height: 20.0),
          SizedBox(key: child2Key, width: 100.0, height: 20.0),
305 306
        ],
      ),
307 308 309 310 311 312 313 314 315 316 317 318
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(20.0));
319
    boxParentData = renderBox.parentData! as BoxParentData;
320 321 322 323 324
    expect(boxParentData.offset.dy, equals(135.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(20.0));
325
    boxParentData = renderBox.parentData! as BoxParentData;
326 327 328 329 330
    expect(boxParentData.offset.dy, equals(290.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(20.0));
331
    boxParentData = renderBox.parentData! as BoxParentData;
332 333 334
    expect(boxParentData.offset.dy, equals(445.0));
  });

335
  testWidgetsWithLeakTracking('Column and MainAxisSize.min', (WidgetTester tester) async {
336
    const Key flexKey = Key('flexKey');
337 338

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
339
    await tester.pumpWidget(const Center(
340
      child: Column(
341
        key: flexKey,
342
        children: <Widget>[
343 344
          SizedBox(width: 100.0, height: 100.0),
          SizedBox(width: 100.0, height: 150.0),
345 346
        ],
      ),
347 348 349 350 351 352
    ));
    RenderBox renderBox = tester.renderObject(find.byKey(flexKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    // Column with MainAxisSize.min without flexible children shrink wraps.
353
    await tester.pumpWidget(const Center(
354
      child: Column(
355 356
        key: flexKey,
        mainAxisSize: MainAxisSize.min,
357
        children: <Widget>[
358 359
          SizedBox(width: 100.0, height: 100.0),
          SizedBox(width: 100.0, height: 150.0),
360 361
        ],
      ),
362 363 364 365 366 367
    ));
    renderBox = tester.renderObject(find.byKey(flexKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(250.0));
  });

368
  testWidgetsWithLeakTracking('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
369
    const Key childKey = Key('childKey');
370

371
    await tester.pumpWidget(const Center(
372
      child: SizedBox.shrink(
373
        child: Column(
374
          mainAxisSize: MainAxisSize.min,
375
          children: <Widget>[
376
            SizedBox(
377 378
              key: childKey,
              width: 100.0,
379 380 381 382 383
              height: 100.0,
            ),
          ],
        ),
      ),
384 385
    ));

386
    final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
387 388 389
    expect(renderBox.size.width, equals(0.0));
    expect(renderBox.size.height, equals(100.0));
  });
390 391 392 393


  // UP

394
  testWidgetsWithLeakTracking('Column with one flexible child', (WidgetTester tester) async {
395 396 397 398
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
399 400 401 402

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // Default is MainAxisAlignment.start so children so the children's
    // bottom edges should be at 0, 100, 500 from bottom, child2's height should be 400.
403
    await tester.pumpWidget(const Center(
404
      child: Column(
405 406
        key: columnKey,
        verticalDirection: VerticalDirection.up,
407
        children: <Widget>[
408 409 410
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          Expanded(child: SizedBox(key: child1Key, width: 100.0, height: 100.0)),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
411 412
        ],
      ),
413 414 415 416 417 418 419 420 421 422 423 424
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
425
    boxParentData = renderBox.parentData! as BoxParentData;
426 427 428 429 430
    expect(boxParentData.offset.dy, equals(500.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(400.0));
431
    boxParentData = renderBox.parentData! as BoxParentData;
432 433 434 435 436
    expect(boxParentData.offset.dy, equals(100.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
437
    boxParentData = renderBox.parentData! as BoxParentData;
438 439 440
    expect(boxParentData.offset.dy, equals(0.0));
  });

441
  testWidgetsWithLeakTracking('Column with default main axis parameters', (WidgetTester tester) async {
442 443 444 445
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
446 447 448 449

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // Default is MainAxisAlignment.start so children so the children's
    // bottom edges should be at 0, 100, 200 from bottom
450
    await tester.pumpWidget(const Center(
451
      child: Column(
452 453
        key: columnKey,
        verticalDirection: VerticalDirection.up,
454
        children: <Widget>[
455 456 457
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
458 459
        ],
      ),
460 461 462 463 464 465 466 467 468 469 470 471
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
472
    boxParentData = renderBox.parentData! as BoxParentData;
473 474 475 476 477
    expect(boxParentData.offset.dy, equals(500.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
478
    boxParentData = renderBox.parentData! as BoxParentData;
479 480 481 482 483
    expect(boxParentData.offset.dy, equals(400.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
484
    boxParentData = renderBox.parentData! as BoxParentData;
485 486 487
    expect(boxParentData.offset.dy, equals(300.0));
  });

488
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.center', (WidgetTester tester) async {
489 490 491
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
492 493 494

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x100 children's bottom edges should be at 200, 300 from bottom
495
    await tester.pumpWidget(const Center(
496
      child: Column(
497 498 499
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.center,
        verticalDirection: VerticalDirection.up,
500
        children: <Widget>[
501 502
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
503 504
        ],
      ),
505 506 507 508 509 510 511 512 513 514 515 516
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
517
    boxParentData = renderBox.parentData! as BoxParentData;
518 519 520 521 522
    expect(boxParentData.offset.dy, equals(300.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
523
    boxParentData = renderBox.parentData! as BoxParentData;
524 525 526
    expect(boxParentData.offset.dy, equals(200.0));
  });

527
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.end', (WidgetTester tester) async {
528 529 530 531
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
532 533 534

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x100 children's bottom edges should be at 300, 400, 500 from bottom.
535
    await tester.pumpWidget(const Center(
536
      child: Column(
537 538 539
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.end,
        verticalDirection: VerticalDirection.up,
540
        children: <Widget>[
541 542 543
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
544 545
        ],
      ),
546 547 548 549 550 551 552 553 554 555 556 557
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
558
    boxParentData = renderBox.parentData! as BoxParentData;
559 560 561 562 563
    expect(boxParentData.offset.dy, equals(200.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
564
    boxParentData = renderBox.parentData! as BoxParentData;
565 566 567 568 569
    expect(boxParentData.offset.dy, equals(100.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
570
    boxParentData = renderBox.parentData! as BoxParentData;
571 572 573
    expect(boxParentData.offset.dy, equals(0.0));
  });

574
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
575 576 577 578
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
579 580 581

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x100 children's bottom edges should be at 0, 250, 500 from bottom
582
    await tester.pumpWidget(const Center(
583
      child: Column(
584 585 586
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        verticalDirection: VerticalDirection.up,
587
        children: <Widget>[
588 589 590
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
591 592
        ],
      ),
593 594 595 596 597 598 599 600 601 602 603 604
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
605
    boxParentData = renderBox.parentData! as BoxParentData;
606 607 608 609 610
    expect(boxParentData.offset.dy, equals(500.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
611
    boxParentData = renderBox.parentData! as BoxParentData;
612 613 614 615 616
    expect(boxParentData.offset.dy, equals(250.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
617
    boxParentData = renderBox.parentData! as BoxParentData;
618 619 620
    expect(boxParentData.offset.dy, equals(0.0));
  });

621
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
622 623 624 625 626
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
    const Key child3Key = Key('child3');
627 628 629

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x100 children's bottom edges should be at 25, 175, 325, 475 from bottom
630
    await tester.pumpWidget(const Center(
631
      child: Column(
632 633 634
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        verticalDirection: VerticalDirection.up,
635
        children: <Widget>[
636 637 638 639
          SizedBox(key: child0Key, width: 100.0, height: 100.0),
          SizedBox(key: child1Key, width: 100.0, height: 100.0),
          SizedBox(key: child2Key, width: 100.0, height: 100.0),
          SizedBox(key: child3Key, width: 100.0, height: 100.0),
640 641
        ],
      ),
642 643 644 645 646 647 648 649 650 651 652 653
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
654
    boxParentData = renderBox.parentData! as BoxParentData;
655 656 657 658 659
    expect(boxParentData.offset.dy, equals(500.0 - 25.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
660
    boxParentData = renderBox.parentData! as BoxParentData;
661 662 663 664 665
    expect(boxParentData.offset.dy, equals(500.0 - 175.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
666
    boxParentData = renderBox.parentData! as BoxParentData;
667 668 669 670 671
    expect(boxParentData.offset.dy, equals(500.0 - 325.0));

    renderBox = tester.renderObject(find.byKey(child3Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(100.0));
672
    boxParentData = renderBox.parentData! as BoxParentData;
673 674 675
    expect(boxParentData.offset.dy, equals(500.0 - 475.0));
  });

676
  testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
677 678 679 680
    const Key columnKey = Key('column');
    const Key child0Key = Key('child0');
    const Key child1Key = Key('child1');
    const Key child2Key = Key('child2');
681 682 683

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
    // The 100x20 children's bottom edges should be at 135, 290, 445 from bottom
684
    await tester.pumpWidget(const Center(
685
      child: Column(
686 687 688
        key: columnKey,
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        verticalDirection: VerticalDirection.up,
689
        children: <Widget>[
690 691 692
          SizedBox(key: child0Key, width: 100.0, height: 20.0),
          SizedBox(key: child1Key, width: 100.0, height: 20.0),
          SizedBox(key: child2Key, width: 100.0, height: 20.0),
693 694
        ],
      ),
695 696 697 698 699 700 701 702 703 704 705 706
    ));

    RenderBox renderBox;
    BoxParentData boxParentData;

    renderBox = tester.renderObject(find.byKey(columnKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    renderBox = tester.renderObject(find.byKey(child0Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(20.0));
707
    boxParentData = renderBox.parentData! as BoxParentData;
708 709 710 711 712
    expect(boxParentData.offset.dy, equals(600.0 - 135.0 - 20.0));

    renderBox = tester.renderObject(find.byKey(child1Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(20.0));
713
    boxParentData = renderBox.parentData! as BoxParentData;
714 715 716 717 718
    expect(boxParentData.offset.dy, equals(600.0 - 290.0 - 20.0));

    renderBox = tester.renderObject(find.byKey(child2Key));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(20.0));
719
    boxParentData = renderBox.parentData! as BoxParentData;
720 721 722
    expect(boxParentData.offset.dy, equals(600.0 - 445.0 - 20.0));
  });

723
  testWidgetsWithLeakTracking('Column and MainAxisSize.min', (WidgetTester tester) async {
724
    const Key flexKey = Key('flexKey');
725 726

    // Default is MainAxisSize.max so the Column should be as high as the test: 600.
727
    await tester.pumpWidget(const Center(
728
      child: Column(
729 730
        key: flexKey,
        verticalDirection: VerticalDirection.up,
731
        children: <Widget>[
732 733
          SizedBox(width: 100.0, height: 100.0),
          SizedBox(width: 100.0, height: 150.0),
734 735
        ],
      ),
736 737 738 739 740 741
    ));
    RenderBox renderBox = tester.renderObject(find.byKey(flexKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(600.0));

    // Column with MainAxisSize.min without flexible children shrink wraps.
742
    await tester.pumpWidget(const Center(
743
      child: Column(
744 745 746
        key: flexKey,
        mainAxisSize: MainAxisSize.min,
        verticalDirection: VerticalDirection.up,
747
        children: <Widget>[
748 749
          SizedBox(width: 100.0, height: 100.0),
          SizedBox(width: 100.0, height: 150.0),
750 751
        ],
      ),
752 753 754 755 756 757
    ));
    renderBox = tester.renderObject(find.byKey(flexKey));
    expect(renderBox.size.width, equals(100.0));
    expect(renderBox.size.height, equals(250.0));
  });

758
  testWidgetsWithLeakTracking('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
759
    const Key childKey = Key('childKey');
760

761
    await tester.pumpWidget(const Center(
762
      child: SizedBox.shrink(
763
        child: Column(
764 765
          mainAxisSize: MainAxisSize.min,
          verticalDirection: VerticalDirection.up,
766
          children: <Widget>[
767
            SizedBox(
768 769
              key: childKey,
              width: 100.0,
770 771 772 773 774
              height: 100.0,
            ),
          ],
        ),
      ),
775 776 777 778 779 780
    ));

    final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
    expect(renderBox.size.width, equals(0.0));
    expect(renderBox.size.height, equals(100.0));
  });
781
}