testGoldensBothDirections function

void testGoldensBothDirections(
  1. String description,
  2. Widget build(), {
  3. required String name,
  4. Size size = const Size(400, 200),
})

Compares build against golden files in both text directions.

Files are named <name>.ltr.png and <name>.rtl.png. The Arabic font is loaded and set as the default text style, and the widget is sized to size.

Implementation

void testGoldensBothDirections(
  String description,
  Widget Function() build, {
  required String name,
  Size size = const Size(400, 200),
}) {
  for (final direction in TextDirection.values) {
    testWidgets('$description (${direction.name})', (tester) async {
      await loadArabicFont();
      await tester.binding.setSurfaceSize(size);
      addTearDown(() => tester.binding.setSurfaceSize(null));
      await pumpRtl(
        tester,
        RepaintBoundary(
          child: ColoredBox(
            color: const Color(0xFFFFFFFF),
            child: DefaultTextStyle(
              style: const TextStyle(
                fontFamily: arabicTestFontFamily,
                fontSize: 24,
                color: Color(0xFF000000),
              ),
              child: build(),
            ),
          ),
        ),
        textDirection: direction,
      );
      await expectLater(
        find.byType(RepaintBoundary).first,
        matchesGoldenFile('goldens/$name.${direction.name}.png'),
      );
    });
  }
}