jeudi 29 août 2019

Is there a way to do flutter widget test on pie-carts?

I am doing a flutter widget test for a mobile app , one of the page contains a pie-chart. I need to create the widget test for this pie-chart and later compare it with the golden image to see that the pie-chart is working as expected. But i could not find anywhere how to create a widget test for the pie-chart. I am also not able to capture the actual pie-chart on the golden image , whereas rest all elements are being displayed on the golden image.

I have created the widget test and golden image for the whole page and it is able to capture everything but not the pie-chart.

Code for pie-chart :

return Container(
  height: 175.0,
  child: Stack(
    children: <Widget>[
      // container for the pie chart
      Container(
        key: const Key('graphFigure'),
        child: charts.PieChart<String>(
          pieChartData,
          animate: true,
          // arcWidth variable decides with size of the pie pieces in the chart
          defaultRenderer:
              charts.ArcRendererConfig(arcWidth: AppDimen.graphArcWidth),
        ),
      ),

code for widget test :

final Finder graphFigure = find.byKey(Key('graphFigure'));
  final Finder irpercentageValueInGraph = find.byKey(Key('percentageValueInGraph'));
  final Finder pcSignInGraph = find.byKey(Key('percentageSignInGraph'));

expect(getGraphFigure(), findsOneWidget, reason: 'The Pie Chart is not visible');
expect(getIRPercentageValueInGraph(), findsOneWidget, reason: 'The In Range percentage value inside the graph not visible');
expect(getPcSignInGraph(), findsOneWidget, reason: 'Percentage sign inside the graph not visible');

Aucun commentaire:

Enregistrer un commentaire