我正在为移动应用程序进行抖动控件测试,其中一个页面包含一个饼图。我需要为此饼图创建窗口小部件测试,然后将其与黄金图像进行比较,以查看该饼图是否按预期工作。但是我找不到任何地方如何为饼图创建窗口小部件测试。我也无法在金色图像上捕获实际的饼图,而其余所有元素都显示在金色图像上。
我为整个页面创建了窗口小部件测试和金色图像,它能够捕获所有内容,但不能捕获饼图。
饼图代码:
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),
),
),
小部件测试代码:
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');