vendredi 29 novembre 2019

How to check font text on Flutter golden test

I'm making a package for vertical Mongolian text. I have a custom widget that needs a special font to display. I'm trying to write a test that shows the Mongolian text has rendered correctly.

On the emulator it looks like this:

But the golden file looks like this:

I can't verify that the Mongolian is getting rendered correctly if the golden test is just giving me tofu.

This is my test:

testWidgets('MongolText renders font', (WidgetTester tester) async {

  await tester.pumpWidget(
    MaterialApp(
      home: Scaffold(
          appBar: AppBar(title: Text('My App')),
          body: Stack(
            children: <Widget>[
              Center(
                child: MongolText('ᠮᠣᠩᠭᠣᠯ'),
              ),
            ],
          )
      ),
    ),
  );

  await tester.pumpAndSettle();

  await expectLater(
    find.byType(MaterialApp),
    matchesGoldenFile('golden-file.png'),
  );
});

Is there any way to fix this?

I've read these two articles about golden tests:

Aucun commentaire:

Enregistrer un commentaire