• Swiftaxe's avatar
    Animation controller test (#88251) · fe337dca
    Swiftaxe authored
    Co-authored-by: 's avatarAlexander 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.
    fe337dca
animation_controller_test.dart 36.8 KB