Repository: flutter/flutter
File: packages/flutter/test/painting/text_scaler_test.dart (Dart)

Code before:
        throwsA(
          isA<AssertionError>().having(
            (AssertionError error) => error.toString(),
            'message',
            contains('maxScaleFactor >= minScaleFactor'),
          ),
        ),
      );
    });
  });

  group('SystemTextScaler', () {
    testWidgets('equality', (WidgetTester tester) async {
      addTearDown(() => tester.platformDispatcher.clearAllTestValues());

      tester.platformDispatcher.textScaleFactorTestValue = 123;
      final TextScaler scaler1 = MediaQueryData.fromView(tester.view).textScaler;
      tester.platformDispatcher.textScaleFactorTestValue = 345;
      final TextScaler scaler2 = MediaQueryData.fromView(tester.view).textScaler;
      tester.platformDispatcher.textScaleFactorTestValue = 123;
      final TextScaler scaler3 = MediaQueryData.fromView(tester.view).textScaler;
      expect(scaler1, scaler3);
      expect(scaler1, isNot(scaler2));
    });

    testWidgets('clamping', (WidgetTester tester) async {
      final TextScaler defaultScaler = MediaQueryData.fromView(tester.view).textScaler;
      final TextScaler outerClampedScaler = defaultScaler.clamp(
        minScaleFactor: 1,
        maxScaleFactor: 1.5,
      );
      final TextScaler innerClampedScaler = outerClampedScaler.clamp(
        minScaleFactor: 0.5,
        maxScaleFactor: 1,
      );

      // Ignore outer clamping
      expect(innerClampedScaler, defaultScaler.clamp(minScaleFactor: 0.5, maxScaleFactor: 1));
    });
  });
}


Review comment (bug):
Rename the test to make it easier to debug in the future. Maybe to something like "Initial clamping bounds are ignored when re-clamped".

Code after:
        throwsA(
          isA<AssertionError>().having(
            (AssertionError error) => error.toString(),
            'message',
            contains('maxScaleFactor >= minScaleFactor'),
          ),
        ),
      );
    });
  });

  group('SystemTextScaler', () {
    testWidgets('equality', (WidgetTester tester) async {
      addTearDown(() => tester.platformDispatcher.clearAllTestValues());

      tester.platformDispatcher.textScaleFactorTestValue = 123;
      final TextScaler scaler1 = MediaQueryData.fromView(tester.view).textScaler;
      tester.platformDispatcher.textScaleFactorTestValue = 345;
      final TextScaler scaler2 = MediaQueryData.fromView(tester.view).textScaler;
      tester.platformDispatcher.textScaleFactorTestValue = 123;
      final TextScaler scaler3 = MediaQueryData.fromView(tester.view).textScaler;
      expect(scaler1, scaler3);
      expect(scaler1, isNot(scaler2));
    });

    testWidgets('Reclamping', (WidgetTester tester) async {
      final TextScaler defaultScaler = MediaQueryData.fromView(tester.view).textScaler;

      // Does not raise maxScale > minScale
      final TextScaler scaler1 = defaultScaler.clamp(minScaleFactor: 1, maxScaleFactor: 1.5);
      final TextScaler scaler2 = scaler1.clamp(minScaleFactor: 0.5, maxScaleFactor: 1);
      expect(scaler2, TextScaler.noScaling);

      // No overlap, first scaler < second scaler. uses new minScale of last clamp
      final TextScaler scaler3 = defaultScaler.clamp(minScaleFactor: 1, maxScaleFactor: 2);
      final TextScaler scaler4 = scaler3.clamp(minScaleFactor: 3, maxScaleFactor: 4);
      expect(scaler4, const TextScaler.linear(3));

      // No overlap, first scaler > second scaler. uses new maxScale of last clamp
      final TextScaler scaler5 = defaultScaler.clamp(minScaleFactor: 5, maxScaleFactor: 6);
      final TextScaler scaler6 = scaler5.clamp(minScaleFactor: 3, maxScaleFactor: 4);
      expect(scaler6, const TextScaler.linear(4));

      // Overlap, combine clamps
      final TextScaler scaler7 = defaultScaler.clamp(minScaleFactor: 1, maxScaleFactor: 3);
      final TextScaler scaler8 = scaler7.clamp(minScaleFactor: 2, maxScaleFactor: 4);
      expect(scaler8, defaultScaler.clamp(minScaleFactor: 2, maxScaleFactor: 3));
    });
  });

  testWidgets('ClampedScaler asserts', (WidgetTester tester) async {