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

Code before:
            (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 (suggestion):
Instead of "outer" and "inner" terminology, can we use more obvious/relevant terms? Like 'initial'/'first' for 'outer' or 'final'/'second'/'reclamped' for 'inner' etc? To make it obvious that this is clamping an already clamped textscaler.

Code after:
            (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 {
    final TextScaler defaultScaler = MediaQueryData.fromView(tester.view).textScaler;
    final TextScaler clampedScaler = defaultScaler.clamp(minScaleFactor: 1, maxScaleFactor: 5);