Skip to content

Conversation

@gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Aug 27, 2021

Description

This adds a smoke test for every single API example. It also fixes 17 tests that had bugs in them, or were otherwise broken, and even fixes one actual bug in the framework, and one limitation in the framework.

The bug in the framework is that NetworkImage's _loadAsync method had await response.drain<List<int>>();, but if the response is null, it will throw a cryptic exception saying that Null can't be assigned to List<int>. The fix was just to use await response.drain<void>(); instead.

The limitation is that RelativePositionedTransition takes an Animation<Rect> rect parameter, and if you want to use a RectTween with it, the value emitted there is Rect?, and one of the examples was just casting from Animation<Rect> to Animation<Rect?>, which is invalid, so I modified RelativePositionedTransition to take a Rect? and just use Rect.zero if the rect is null.

Epilepsy warning: the following image flickers a lot.

example_smoke.mp4

Related Issues

Tests

  • Add smoke tests for 239 example apps.

@flutter-dashboard flutter-dashboard bot added d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Aug 27, 2021
@google-cla google-cla bot added the cla: yes label Aug 27, 2021
@gspencergoog gspencergoog force-pushed the test_samples branch 2 times, most recently from 778ba40 to d8d07fd Compare August 27, 2021 18:42
@gspencergoog gspencergoog force-pushed the test_samples branch 11 times, most recently from cb0f5df to 56c6ae4 Compare September 1, 2021 20:26
@gspencergoog gspencergoog force-pushed the test_samples branch 7 times, most recently from 149dfaf to ea09a18 Compare September 9, 2021 17:40
@gspencergoog gspencergoog force-pushed the test_samples branch 10 times, most recently from 4644b71 to aa9b7e5 Compare September 23, 2021 22:26
@gspencergoog gspencergoog force-pushed the test_samples branch 2 times, most recently from 179d984 to a2b3a97 Compare September 24, 2021 16:32
@gspencergoog gspencergoog marked this pull request as ready for review September 24, 2021 16:33
@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 24, 2021
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about exitCode. Is this equivalent to exit(4);?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, except that it allows for a clean shutdown. If you call exit(4), then if the main is wrapped (e.g. in an integration test) then the test shutdown doesn't occur cleanly (it just exits the app immediately), and not all results are reported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the glob and path separator work on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in git it does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, so the glob is expanded by git?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after confirming test coverage, but I think since the sample code tests exposed those issues, I am guessing they provide test coverage

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this can be updated further

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good point. Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test for this? Or does the sample code test cover it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There wasn't a test. This failed because List<int> wasn't castable to Null, and if there isn't anything to drain, it tries to do that (the docs say "The [futureValue] must not be omitted if null is not assignable to [E].", and it was omitting the return value). The example smoke test doesn't cover this, I just found it when I was playing with one of the examples.

I modified the Fake implementation in image_provider_network_image_test.dart to mirror the implementation in Stream (since the fake "implements" it, not derives from it) to make sure that NetworkImage always passes something to drain. It fails before, and passes now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, does this need a test? Or does the sample code test ensure this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test for this, which needed to be done, since there wasn't any test at all for RelativePositionedTransition. The test uses a RectTween, which is an Animation<Rect?>, so it exercises this issue.

This was just a null-saftey conversion error: it's silly to not be able to use a RectTween with this. Probably happened because there was no test at all.

@gspencergoog gspencergoog merged commit ab2b085 into flutter:master Sep 28, 2021
@gspencergoog gspencergoog deleted the test_samples branch September 28, 2021 16:32
clocksmith pushed a commit to clocksmith/flutter that referenced this pull request Oct 29, 2021
…r#89021)

This adds a smoke test for every single API example. It also fixes 17 tests that had bugs in them, or were otherwise broken, and even fixes one actual bug in the framework, and one limitation in the framework.

The bug in the framework is that NetworkImage's _loadAsync method had await response.drain<List<int>>();, but if the response is null, it will throw a cryptic exception saying that Null can't be assigned to List<int>. The fix was just to use await response.drain<void>(); instead.

The limitation is that RelativePositionedTransition takes an Animation<Rect> rect parameter, and if you want to use a RectTween with it, the value emitted there is Rect?, and one of the examples was just casting from Animation<Rect> to Animation<Rect?>, which is invalid, so I modified RelativePositionedTransition to take a Rect? and just use Rect.zero if the rect is null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MaterialStateOutlinedBorder interactive app is broken

3 participants