Skip to content

Running "flutter run" for a widget test has inconsistent MediaQuery.of(context).size #21729

@etiennedm

Description

@etiennedm

Steps to Reproduce

  1. Clone https://gitlab.com/etiennedm/flutter-test-issue.git
  2. Run app, tap button, it will show "Screen size is XxY"
  3. Run test with flutter run test/widget_test.dart, it will output the same screen size. Moreover now the bottom squares are not showing.

So the issue is that when running a test with flutter run it seems like a MediaQuery.of(context).size is returning the actual size as seen by the test environment and not by the running widget. Is that the expected behavior?

screenshot_1536753923
screenshot_1536754018

[✓] Flutter (Channel dev, v0.8.1, on Linux, locale en_US.UTF-8)
    • Flutter version 0.8.1 at /home/edemaricourt/dev/perso/flutter/flutter
    • Framework revision 0235ec59d1 (5 days ago), 2018-09-06 20:23:13 -0700
    • Engine revision 9b297b3b51
    • Dart version 2.1.0-dev.3.1.flutter-760a9690c2

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
    • Android SDK at /home/edemaricourt/Android/Sdk
    • Android NDK at /home/edemaricourt/Android/Sdk/ndk-bundle
    • Platform android-28, build-tools 28.0.1
    • ANDROID_HOME = /home/edemaricourt/Android/Sdk
    • Java binary at: /home/edemaricourt/software/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] Android Studio (version 3.1)
    • Android Studio at /home/edemaricourt/software/android-studio
    • Flutter plugin version 26.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] VS Code (version 1.27.1)
    • VS Code at /usr/share/code
    • Flutter extension version 2.18.0

[✓] Connected devices (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our tests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions