media_query_test.dart 26.2 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
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
// @dart = 2.8

7
import 'dart:ui' show Brightness;
8
import 'package:flutter/foundation.dart';
9 10 11 12
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';

void main() {
13 14 15
  testWidgets('MediaQuery does not have a default', (WidgetTester tester) async {
    bool tested = false;
    await tester.pumpWidget(
16
      Builder(
17 18 19
        builder: (BuildContext context) {
          tested = true;
          MediaQuery.of(context); // should throw
20
          return Container();
21 22
        },
      ),
23 24
    );
    expect(tested, isTrue);
25 26 27
    final dynamic exception = tester.takeException();
    expect(exception, isNotNull);
    expect(exception ,isFlutterError);
28
    final FlutterError error = exception as FlutterError;
29
    expect(error.diagnostics.length, 3);
Dan Field's avatar
Dan Field committed
30
    expect(error.diagnostics.last, isA<DiagnosticsProperty<Element>>());
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
    expect(
      error.toStringDeep(),
      equalsIgnoringHashCodes(
        'FlutterError\n'
        '   MediaQuery.of() called with a context that does not contain a\n'
        '   MediaQuery.\n'
        '   No MediaQuery ancestor could be found starting from the context\n'
        '   that was passed to MediaQuery.of(). This can happen because you\n'
        '   do not have a WidgetsApp or MaterialApp widget (those widgets\n'
        '   introduce a MediaQuery), or it can happen if the context you use\n'
        '   comes from a widget above those widgets.\n'
        '   The context used was:\n'
        '     Builder\n',
      ),
    );
46
  });
47

48 49
  testWidgets('MediaQuery defaults to null', (WidgetTester tester) async {
    bool tested = false;
50
    await tester.pumpWidget(
51
      Builder(
52
        builder: (BuildContext context) {
53 54 55
          final MediaQueryData data = MediaQuery.of(context, nullOk: true);
          expect(data, isNull);
          tested = true;
56
          return Container();
57 58
        },
      ),
59
    );
60 61
    expect(tested, isTrue);
  });
62

63
  testWidgets('MediaQueryData is sane', (WidgetTester tester) async {
64
    final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
65 66
    expect(data, hasOneLineDescription);
    expect(data.hashCode, equals(data.copyWith().hashCode));
67
    expect(data.size, equals(WidgetsBinding.instance.window.physicalSize / WidgetsBinding.instance.window.devicePixelRatio));
68 69 70
    expect(data.accessibleNavigation, false);
    expect(data.invertColors, false);
    expect(data.disableAnimations, false);
71
    expect(data.boldText, false);
72
    expect(data.highContrast, false);
73
    expect(data.platformBrightness, Brightness.light);
74
  });
75 76

  testWidgets('MediaQueryData.copyWith defaults to source', (WidgetTester tester) async {
77
    final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
78 79 80 81 82
    final MediaQueryData copied = data.copyWith();
    expect(copied.size, data.size);
    expect(copied.devicePixelRatio, data.devicePixelRatio);
    expect(copied.textScaleFactor, data.textScaleFactor);
    expect(copied.padding, data.padding);
83
    expect(copied.viewPadding, data.viewPadding);
84
    expect(copied.viewInsets, data.viewInsets);
85
    expect(copied.systemGestureInsets, data.systemGestureInsets);
86
    expect(copied.alwaysUse24HourFormat, data.alwaysUse24HourFormat);
87 88 89
    expect(copied.accessibleNavigation, data.accessibleNavigation);
    expect(copied.invertColors, data.invertColors);
    expect(copied.disableAnimations, data.disableAnimations);
90
    expect(copied.boldText, data.boldText);
91
    expect(copied.highContrast, data.highContrast);
92
    expect(copied.platformBrightness, data.platformBrightness);
93 94 95
  });

  testWidgets('MediaQuery.copyWith copies specified values', (WidgetTester tester) async {
96 97 98 99 100 101 102 103 104 105
    // Random and unique double values are used to ensure that the correct
    // values are copied over exactly
    const Size customSize = Size(3.14, 2.72);
    const double customDevicePixelRatio = 1.41;
    const double customTextScaleFactor = 1.62;
    const EdgeInsets customPadding = EdgeInsets.all(9.10938);
    const EdgeInsets customViewPadding = EdgeInsets.all(11.24031);
    const EdgeInsets customViewInsets = EdgeInsets.all(1.67262);
    const EdgeInsets customSystemGestureInsets = EdgeInsets.all(1.5556);

106
    final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
107
    final MediaQueryData copied = data.copyWith(
108 109 110 111 112 113 114
      size: customSize,
      devicePixelRatio: customDevicePixelRatio,
      textScaleFactor: customTextScaleFactor,
      padding: customPadding,
      viewPadding: customViewPadding,
      viewInsets: customViewInsets,
      systemGestureInsets: customSystemGestureInsets,
115
      alwaysUse24HourFormat: true,
116 117 118
      accessibleNavigation: true,
      invertColors: true,
      disableAnimations: true,
119
      boldText: true,
120
      highContrast: true,
121
      platformBrightness: Brightness.dark,
122
    );
123 124 125 126 127 128 129
    expect(copied.size, customSize);
    expect(copied.devicePixelRatio, customDevicePixelRatio);
    expect(copied.textScaleFactor, customTextScaleFactor);
    expect(copied.padding, customPadding);
    expect(copied.viewPadding, customViewPadding);
    expect(copied.viewInsets, customViewInsets);
    expect(copied.systemGestureInsets, customSystemGestureInsets);
130
    expect(copied.alwaysUse24HourFormat, true);
131 132 133
    expect(copied.accessibleNavigation, true);
    expect(copied.invertColors, true);
    expect(copied.disableAnimations, true);
134
    expect(copied.boldText, true);
135
    expect(copied.highContrast, true);
136
    expect(copied.platformBrightness, Brightness.dark);
137
  });
138

139 140 141 142 143
  testWidgets('MediaQuery.removePadding removes specified padding', (WidgetTester tester) async {
    const Size size = Size(2.0, 4.0);
    const double devicePixelRatio = 2.0;
    const double textScaleFactor = 1.2;
    const EdgeInsets padding = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
144
    const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
145 146 147 148 149 150 151 152 153 154
    const EdgeInsets viewInsets = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);

    MediaQueryData unpadded;
    await tester.pumpWidget(
      MediaQuery(
        data: const MediaQueryData(
          size: size,
          devicePixelRatio: devicePixelRatio,
          textScaleFactor: textScaleFactor,
          padding: padding,
155
          viewPadding: viewPadding,
156 157 158 159 160 161
          viewInsets: viewInsets,
          alwaysUse24HourFormat: true,
          accessibleNavigation: true,
          invertColors: true,
          disableAnimations: true,
          boldText: true,
162
          highContrast: true,
163 164 165 166 167 168 169 170 171 172 173 174 175
        ),
        child: Builder(
          builder: (BuildContext context) {
            return MediaQuery.removePadding(
              context: context,
              removeLeft: true,
              removeTop: true,
              removeRight: true,
              removeBottom: true,
              child: Builder(
                builder: (BuildContext context) {
                  unpadded = MediaQuery.of(context);
                  return Container();
176
                },
177 178 179 180
              ),
            );
          },
        ),
181
      ),
182 183 184 185 186 187
    );

    expect(unpadded.size, size);
    expect(unpadded.devicePixelRatio, devicePixelRatio);
    expect(unpadded.textScaleFactor, textScaleFactor);
    expect(unpadded.padding, EdgeInsets.zero);
188
    expect(unpadded.viewPadding, viewInsets);
189 190 191 192 193 194
    expect(unpadded.viewInsets, viewInsets);
    expect(unpadded.alwaysUse24HourFormat, true);
    expect(unpadded.accessibleNavigation, true);
    expect(unpadded.invertColors, true);
    expect(unpadded.disableAnimations, true);
    expect(unpadded.boldText, true);
195
    expect(unpadded.highContrast, true);
196
  });
197

198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
  testWidgets('MediaQuery.removePadding only removes specified padding', (WidgetTester tester) async {
    const Size size = Size(2.0, 4.0);
    const double devicePixelRatio = 2.0;
    const double textScaleFactor = 1.2;
    const EdgeInsets padding = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
    const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
    const EdgeInsets viewInsets = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);

    MediaQueryData unpadded;
    await tester.pumpWidget(
      MediaQuery(
        data: const MediaQueryData(
          size: size,
          devicePixelRatio: devicePixelRatio,
          textScaleFactor: textScaleFactor,
          padding: padding,
          viewPadding: viewPadding,
          viewInsets: viewInsets,
          alwaysUse24HourFormat: true,
          accessibleNavigation: true,
          invertColors: true,
          disableAnimations: true,
          boldText: true,
221
          highContrast: true,
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
        ),
        child: Builder(
          builder: (BuildContext context) {
            return MediaQuery.removePadding(
              removeTop: true,
              context: context,
              child: Builder(
                builder: (BuildContext context) {
                  unpadded = MediaQuery.of(context);
                  return Container();
                },
              ),
            );
          },
        ),
      ),
    );

    expect(unpadded.size, size);
    expect(unpadded.devicePixelRatio, devicePixelRatio);
    expect(unpadded.textScaleFactor, textScaleFactor);
    expect(unpadded.padding, padding.copyWith(top: 0));
    expect(unpadded.viewPadding, viewPadding.copyWith(top: viewInsets.top));
    expect(unpadded.viewInsets, viewInsets);
    expect(unpadded.alwaysUse24HourFormat, true);
    expect(unpadded.accessibleNavigation, true);
    expect(unpadded.invertColors, true);
    expect(unpadded.disableAnimations, true);
    expect(unpadded.boldText, true);
251
    expect(unpadded.highContrast, true);
252 253
  });

254
  testWidgets('MediaQuery.removeViewInsets removes specified viewInsets', (WidgetTester tester) async {
255
    const Size size = Size(2.0, 4.0);
256 257
    const double devicePixelRatio = 2.0;
    const double textScaleFactor = 1.2;
258
    const EdgeInsets padding = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);
259
    const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
260
    const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
261 262 263

    MediaQueryData unpadded;
    await tester.pumpWidget(
264
      MediaQuery(
265 266 267 268 269
        data: const MediaQueryData(
          size: size,
          devicePixelRatio: devicePixelRatio,
          textScaleFactor: textScaleFactor,
          padding: padding,
270
          viewPadding: viewPadding,
271 272
          viewInsets: viewInsets,
          alwaysUse24HourFormat: true,
273 274 275
          accessibleNavigation: true,
          invertColors: true,
          disableAnimations: true,
276
          boldText: true,
277
          highContrast: true,
278
        ),
279
        child: Builder(
280
          builder: (BuildContext context) {
281
            return MediaQuery.removeViewInsets(
282 283 284 285 286
              context: context,
              removeLeft: true,
              removeTop: true,
              removeRight: true,
              removeBottom: true,
287
              child: Builder(
288 289
                builder: (BuildContext context) {
                  unpadded = MediaQuery.of(context);
290
                  return Container();
291
                },
292 293 294 295
              ),
            );
          },
        ),
296
      ),
297 298 299 300 301 302
    );

    expect(unpadded.size, size);
    expect(unpadded.devicePixelRatio, devicePixelRatio);
    expect(unpadded.textScaleFactor, textScaleFactor);
    expect(unpadded.padding, padding);
303
    expect(unpadded.viewPadding, padding);
304 305
    expect(unpadded.viewInsets, EdgeInsets.zero);
    expect(unpadded.alwaysUse24HourFormat, true);
306 307 308
    expect(unpadded.accessibleNavigation, true);
    expect(unpadded.invertColors, true);
    expect(unpadded.disableAnimations, true);
309
    expect(unpadded.boldText, true);
310
    expect(unpadded.highContrast, true);
311
  });
312

313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
  testWidgets('MediaQuery.removeViewInsets removes only specified viewInsets', (WidgetTester tester) async {
    const Size size = Size(2.0, 4.0);
    const double devicePixelRatio = 2.0;
    const double textScaleFactor = 1.2;
    const EdgeInsets padding = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);
    const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
    const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);

    MediaQueryData unpadded;
    await tester.pumpWidget(
      MediaQuery(
        data: const MediaQueryData(
          size: size,
          devicePixelRatio: devicePixelRatio,
          textScaleFactor: textScaleFactor,
          padding: padding,
          viewPadding: viewPadding,
          viewInsets: viewInsets,
          alwaysUse24HourFormat: true,
          accessibleNavigation: true,
          invertColors: true,
          disableAnimations: true,
          boldText: true,
336
          highContrast: true,
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
        ),
        child: Builder(
          builder: (BuildContext context) {
            return MediaQuery.removeViewInsets(
              context: context,
              removeBottom: true,
              child: Builder(
                builder: (BuildContext context) {
                  unpadded = MediaQuery.of(context);
                  return Container();
                },
              ),
            );
          },
        ),
      ),
    );

    expect(unpadded.size, size);
    expect(unpadded.devicePixelRatio, devicePixelRatio);
    expect(unpadded.textScaleFactor, textScaleFactor);
    expect(unpadded.padding, padding);
    expect(unpadded.viewPadding, viewPadding.copyWith(bottom: 8));
    expect(unpadded.viewInsets, viewInsets.copyWith(bottom: 0));
    expect(unpadded.alwaysUse24HourFormat, true);
    expect(unpadded.accessibleNavigation, true);
    expect(unpadded.invertColors, true);
    expect(unpadded.disableAnimations, true);
    expect(unpadded.boldText, true);
366
    expect(unpadded.highContrast, true);
367 368
  });

369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
  testWidgets('MediaQuery.removeViewPadding removes specified viewPadding', (WidgetTester tester) async {
    const Size size = Size(2.0, 4.0);
    const double devicePixelRatio = 2.0;
    const double textScaleFactor = 1.2;
    const EdgeInsets padding = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);
    const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
    const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);

    MediaQueryData unpadded;
    await tester.pumpWidget(
      MediaQuery(
        data: const MediaQueryData(
          size: size,
          devicePixelRatio: devicePixelRatio,
          textScaleFactor: textScaleFactor,
          padding: padding,
385
          viewPadding: viewPadding,
386 387 388 389 390 391
          viewInsets: viewInsets,
          alwaysUse24HourFormat: true,
          accessibleNavigation: true,
          invertColors: true,
          disableAnimations: true,
          boldText: true,
392
          highContrast: true,
393 394 395 396 397 398 399 400 401 402 403 404 405
        ),
        child: Builder(
          builder: (BuildContext context) {
            return MediaQuery.removeViewPadding(
              context: context,
              removeLeft: true,
              removeTop: true,
              removeRight: true,
              removeBottom: true,
              child: Builder(
                builder: (BuildContext context) {
                  unpadded = MediaQuery.of(context);
                  return Container();
406
                },
407 408 409 410
              ),
            );
          },
        ),
411
      ),
412 413 414 415 416 417 418 419 420 421 422 423 424
    );

    expect(unpadded.size, size);
    expect(unpadded.devicePixelRatio, devicePixelRatio);
    expect(unpadded.textScaleFactor, textScaleFactor);
    expect(unpadded.padding, EdgeInsets.zero);
    expect(unpadded.viewPadding, EdgeInsets.zero);
    expect(unpadded.viewInsets, viewInsets);
    expect(unpadded.alwaysUse24HourFormat, true);
    expect(unpadded.accessibleNavigation, true);
    expect(unpadded.invertColors, true);
    expect(unpadded.disableAnimations, true);
    expect(unpadded.boldText, true);
425
    expect(unpadded.highContrast, true);
426 427
  });

428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
  testWidgets('MediaQuery.removeViewPadding removes only specified viewPadding', (WidgetTester tester) async {
    const Size size = Size(2.0, 4.0);
    const double devicePixelRatio = 2.0;
    const double textScaleFactor = 1.2;
    const EdgeInsets padding = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);
    const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
    const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);

    MediaQueryData unpadded;
    await tester.pumpWidget(
      MediaQuery(
        data: const MediaQueryData(
          size: size,
          devicePixelRatio: devicePixelRatio,
          textScaleFactor: textScaleFactor,
          padding: padding,
          viewPadding: viewPadding,
          viewInsets: viewInsets,
          alwaysUse24HourFormat: true,
          accessibleNavigation: true,
          invertColors: true,
          disableAnimations: true,
          boldText: true,
451
          highContrast: true,
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
        ),
        child: Builder(
          builder: (BuildContext context) {
            return MediaQuery.removeViewPadding(
              context: context,
              removeLeft: true,
              child: Builder(
                builder: (BuildContext context) {
                  unpadded = MediaQuery.of(context);
                  return Container();
                },
              ),
            );
          },
        ),
      ),
    );

    expect(unpadded.size, size);
    expect(unpadded.devicePixelRatio, devicePixelRatio);
    expect(unpadded.textScaleFactor, textScaleFactor);
    expect(unpadded.padding, padding.copyWith(left: 0));
    expect(unpadded.viewPadding, viewPadding.copyWith(left: 0));
    expect(unpadded.viewInsets, viewInsets);
    expect(unpadded.alwaysUse24HourFormat, true);
    expect(unpadded.accessibleNavigation, true);
    expect(unpadded.invertColors, true);
    expect(unpadded.disableAnimations, true);
    expect(unpadded.boldText, true);
481
    expect(unpadded.highContrast, true);
482 483
  });

484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
  testWidgets('MediaQuery.textScaleFactorOf', (WidgetTester tester) async {
    double outsideTextScaleFactor;
    double insideTextScaleFactor;

    await tester.pumpWidget(
      Builder(
        builder: (BuildContext context) {
          outsideTextScaleFactor = MediaQuery.textScaleFactorOf(context);
          return MediaQuery(
            data: const MediaQueryData(
              textScaleFactor: 4.0,
            ),
            child: Builder(
              builder: (BuildContext context) {
                insideTextScaleFactor = MediaQuery.textScaleFactorOf(context);
                return Container();
              },
            ),
          );
        },
      ),
    );

    expect(outsideTextScaleFactor, 1.0);
    expect(insideTextScaleFactor, 4.0);
  });
510

511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
  testWidgets('MediaQuery.platformBrightnessOf', (WidgetTester tester) async {
    Brightness outsideBrightness;
    Brightness insideBrightness;

    await tester.pumpWidget(
      Builder(
        builder: (BuildContext context) {
          outsideBrightness = MediaQuery.platformBrightnessOf(context);
          return MediaQuery(
            data: const MediaQueryData(
              platformBrightness: Brightness.dark,
            ),
            child: Builder(
              builder: (BuildContext context) {
                insideBrightness = MediaQuery.platformBrightnessOf(context);
                return Container();
              },
            ),
          );
        },
      ),
    );

    expect(outsideBrightness, Brightness.light);
    expect(insideBrightness, Brightness.dark);
  });

538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
  testWidgets('MediaQuery.highContrastOf', (WidgetTester tester) async {
    bool outsideHighContrast;
    bool insideHighContrast;

    await tester.pumpWidget(
      Builder(
        builder: (BuildContext context) {
          outsideHighContrast = MediaQuery.highContrastOf(context);
          return MediaQuery(
            data: const MediaQueryData(
              highContrast: true,
            ),
            child: Builder(
              builder: (BuildContext context) {
                insideHighContrast = MediaQuery.highContrastOf(context);
                return Container();
              },
            ),
          );
        },
      ),
    );

    expect(outsideHighContrast, false);
    expect(insideHighContrast, true);
  });

565 566 567 568 569
  testWidgets('MediaQuery.boldTextOverride', (WidgetTester tester) async {
    bool outsideBoldTextOverride;
    bool insideBoldTextOverride;

    await tester.pumpWidget(
570
      Builder(
571 572
        builder: (BuildContext context) {
          outsideBoldTextOverride = MediaQuery.boldTextOverride(context);
573
          return MediaQuery(
574 575 576
            data: const MediaQueryData(
              boldText: true,
            ),
577
            child: Builder(
578 579
              builder: (BuildContext context) {
                insideBoldTextOverride = MediaQuery.boldTextOverride(context);
580
                return Container();
581 582 583 584 585 586 587 588 589 590
              },
            ),
          );
        },
      ),
    );

    expect(outsideBoldTextOverride, false);
    expect(insideBoldTextOverride, true);
  });
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745

  test('size parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(size: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('size != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('devicePixelRatio parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(devicePixelRatio: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('devicePixelRatio != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('textScaleFactor parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(textScaleFactor: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('textScaleFactor != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('platformBrightness parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(platformBrightness: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('platformBrightness != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('padding parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(padding: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('padding != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('viewInsets parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(viewInsets: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('viewInsets != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('systemGestureInsets parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(systemGestureInsets: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('systemGestureInsets != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('viewPadding parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(viewPadding: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('viewPadding != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('alwaysUse24HourFormat parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(alwaysUse24HourFormat: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('alwaysUse24HourFormat != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('accessibleNavigation parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(accessibleNavigation: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('accessibleNavigation != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('invertColors parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(invertColors: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('invertColors != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('highContrast parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(highContrast: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('highContrast != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('disableAnimations parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(disableAnimations: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('disableAnimations != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

  test('boldText parameter in MediaQueryData cannot be null', () {
    try {
      MediaQueryData(boldText: null);
    } on AssertionError catch (error) {
      expect(error.toString(), contains('boldText != null'));
      expect(error.toString(), contains('is not true'));
      return;
    }
    fail('The assert was never called when it should have been');
  });

746
}