This extracts the sample code out from the API doc comments, and places them in separate files on disk, allowing running of the examples locally, testing them, and building of slightly larger examples.
Co-authored-by: Alexander Dahlberg <alexander.dahlberg@sigma.se>
This PR fixed the problem that prevented platform_channel_test.dart being shuffled. Part of #85160.
A couple of tests sets up callbacks through setMethodCallHandler() that gets unresolved and breaks other tests.
This PR clears those callbacks by passing null to setMethodCallHandler.
This PR fixed the problem that has prevented app_overrides_test.dart being shuffled. Part of #85160.
This test is testing WidgetsApp.showPerformanceOverlayOverride and WidgetsApp.debugAllowBannerOverride.
The problem: There was a strong dependecy to the default ordering of the tests. The value of showPerformanceOverlayOverride or debugAllowBannerOverride was expected to be the value that was set in previous test.
The fix: Make the values be set to default values after each test:
WidgetsApp.showPerformanceOverlayOverride=false
WidgetsApp.debugAllowBannerOverride=true
Set the expected value at the start of the test, if the default value is not expected.
Co-authored-by: Alexander Dahlberg <alexander.dahlberg@sigma.se>
This PR fixed the problem that has prevented scheduler_test.dart being shuffled. Part of #85160.
One test schedules a task, but events are locked so the scheduled task does not execute and this messes up other tests.
This PR adds a teardown that executes the scheduled task after the test, when events are unlocked.
Fixes test/painting/image_stream_test.dart of #85160
The problem: The timeDilation was changed to 2.0 but not restored. The changed timeDilation carried on to following tests which messed up some of them when using test ordering seed 456.
The Fix: Restore timeDilation to 1.0 at the end of test.
Fixes test/gestures/long_press_test.dart of #85160
The LongPressGestureRecognizer in test 'non-allowed pointer does not inadvertently reset the recognizer' was not disposed breaking a lot of other tests.
Co-authored-by: Alexander Dahlberg <alexander.dahlberg@sigma.se>
The TapGestureRecognizer in the test named 'TapGestureRecognizer _sentTapDown toString' was not disposed, which was breaking a couple of other tests.
This worked fine when not shuffling the tests as the test was executed last.
Co-authored-by: Alexander Dahlberg <alexander.dahlberg@sigma.se>
Fixes test/animation/animation_controller_test.dart in #85160
Problem:
The test 'animateTo can deal with duration == Duration.Zero' was failing with the following error:
Expected: <0>
Actual: <5>
Expected no animation.
package:test_api expect
package:flutter_test/src/widget_tester.dart 484:3 expect
test/animation/animation_controller_test.dart 511:5 main.
Following line finds 5 transientCallbacks scheduled, while expecting zero, if shuffled with seed 123:
expect(SchedulerBinding.instance!.transientCallbackCount, equals(0), reason: 'Expected no animation.');
This is caused by some other test leaving transientCallbacks scheduled.
Fix:
By disposing the AnimationController after each test, the transientCallbacks get cleaned up.
I chose to dispose all controllers in every test, to make sure there is no risk of leaks.