Repository: flutter/flutter
File: packages/flutter/test/material/app_bar_test.dart (Dart)

Code before:
      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));
      await gesture.up();
      await tester.pumpAndSettle();

      expect(getAppBarBackgroundColor(tester), defaultColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);
    });

    testWidgets('backgroundColor animation', (WidgetTester tester) async {
      await tester.pumpWidget(
        buildAppBar(contentHeight: 1200.0, surfaceTintColor: Colors.transparent),
      );

      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);

      TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));
      await gesture.moveBy(const Offset(0.0, -kToolbarHeight));
      await gesture.up();
      await tester.pump();

      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);
      await tester.pumpAndSettle();
      expect(getAppBarAnimatedBackgroundColor(tester), scrolledColor);

      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));
      await gesture.up();
      await tester.pump();

      expect(getAppBarAnimatedBackgroundColor(tester), scrolledColor);
      await tester.pumpAndSettle();
      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);
    });

    testWidgets('backgroundColor with FlexibleSpace', (WidgetTester tester) async {
      await tester.pumpWidget(buildAppBar(contentHeight: 1200.0, includeFlexibleSpace: true));

      expect(getAppBarBackgroundColor(tester), defaultColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);

      TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));
      await gesture.moveBy(const Offset(0.0, -kToolbarHeight));
      await gesture.up();
      await tester.pumpAndSettle();

      expect(getAppBarBackgroundColor(tester), scrolledColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);

      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));

Review comment (suggestion):
I don't think this test case verifies the feature. It only verifies the starting color and ending color, while you're trying to verify that there's a smooth animation in between. I recommend going without `pumpAndSettle` but `pump`ing a time instead, and it should result in a intermediate color.

Code after:
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);

      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));
      await gesture.up();
      await tester.pumpAndSettle();

      expect(getAppBarBackgroundColor(tester), defaultColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);
    });

    testWidgets('backgroundColor animation', (WidgetTester tester) async {
      await tester.pumpWidget(
        buildAppBar(contentHeight: 1200.0, scrolledUnderElevation: 0, animateColor: true),
      );

      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);

      TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));
      await gesture.moveBy(const Offset(0.0, -kToolbarHeight));
      await gesture.up();
      await tester.pump();

      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);
      await tester.pumpAndSettle();
      expect(getAppBarAnimatedBackgroundColor(tester), scrolledColor);

      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));
      await gesture.up();
      await tester.pump();

      expect(getAppBarAnimatedBackgroundColor(tester), scrolledColor);

      // Check intermediate color values.
      await tester.pump(const Duration(milliseconds: 50));
      expect(getAppBarAnimatedBackgroundColor(tester), isSameColorAs(const Color(0xFF00C33C)));
      await tester.pump(const Duration(milliseconds: 50));
      expect(getAppBarAnimatedBackgroundColor(tester), isSameColorAs(const Color(0xFF0039C6)));

      await tester.pumpAndSettle();
      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);
    });

    testWidgets('backgroundColor with FlexibleSpace', (WidgetTester tester) async {
      await tester.pumpWidget(buildAppBar(contentHeight: 1200.0, includeFlexibleSpace: true));

      expect(getAppBarBackgroundColor(tester), defaultColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);

      TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));