Unverified Commit 7bc02037 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Re-land Local & Pre-Submit Support for Skia Gold (#43371)

parent 4bd5eb59
65bd07204149c4f7612bbf179cf088a2d69ca549
......@@ -45,7 +45,7 @@ void main() {
await expectLater(
find.byKey(key),
matchesGoldenFile('activityIndicator.paused.light.png', version: 0),
matchesGoldenFile('activityIndicator.paused.light.png'),
);
await tester.pumpWidget(
......@@ -65,7 +65,7 @@ void main() {
await expectLater(
find.byKey(key),
matchesGoldenFile('activityIndicator.paused.dark.png', version: 0),
matchesGoldenFile('activityIndicator.paused.dark.png'),
);
});
......
......@@ -922,10 +922,7 @@ void main() {
await expectLater(
find.byType(CupertinoDatePicker),
matchesGoldenFile(
'date_picker_test.datetime.initial.png',
version: 2,
),
matchesGoldenFile('date_picker_test.datetime.initial.png'),
);
// Slightly drag the hour component to make the current hour off-center.
......@@ -934,10 +931,7 @@ void main() {
await expectLater(
find.byType(CupertinoDatePicker),
matchesGoldenFile(
'date_picker_test.datetime.drag.png',
version: 2,
),
matchesGoldenFile('date_picker_test.datetime.drag.png'),
);
});
});
......@@ -971,10 +965,7 @@ void main() {
await expectLater(
find.byType(CupertinoTimerPicker),
matchesGoldenFile(
'timer_picker_test.datetime.initial.png',
version: 1,
),
matchesGoldenFile('timer_picker_test.datetime.initial.png'),
);
// Slightly drag the minute component to make the current minute off-center.
......@@ -983,10 +974,7 @@ void main() {
await expectLater(
find.byType(CupertinoTimerPicker),
matchesGoldenFile(
'timer_picker_test.datetime.drag.png',
version: 1,
),
matchesGoldenFile('timer_picker_test.datetime.drag.png'),
);
});
......
......@@ -820,10 +820,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary).last,
matchesGoldenFile(
'nav_bar_test.standard_title.png',
version: 2,
),
matchesGoldenFile('nav_bar_test.standard_title.png'),
);
},
);
......@@ -854,10 +851,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary).last,
matchesGoldenFile(
'nav_bar_test.large_title.png',
version: 2,
),
matchesGoldenFile('nav_bar_test.large_title.png'),
);
},
);
......
......@@ -1414,10 +1414,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'segmented_control_test.0.png',
version: 0,
),
matchesGoldenFile('segmented_control_test.0.png'),
);
});
......@@ -1455,10 +1452,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'segmented_control_test.1.png',
version: 0,
),
matchesGoldenFile('segmented_control_test.1.png'),
);
});
}
......@@ -542,10 +542,7 @@ void main() {
await expectLater(
find.byKey(switchKey),
matchesGoldenFile(
'switch.tap.off.png',
version: 1,
),
matchesGoldenFile('switch.tap.off.png'),
);
await tester.tap(find.byKey(switchKey));
......@@ -556,19 +553,13 @@ void main() {
await tester.pump(const Duration(milliseconds: 60));
await expectLater(
find.byKey(switchKey),
matchesGoldenFile(
'switch.tap.turningOn.png',
version: 1,
),
matchesGoldenFile('switch.tap.turningOn.png'),
);
await tester.pumpAndSettle();
await expectLater(
find.byKey(switchKey),
matchesGoldenFile(
'switch.tap.on.png',
version: 1,
),
matchesGoldenFile('switch.tap.on.png'),
);
});
......@@ -604,10 +595,7 @@ void main() {
await expectLater(
find.byKey(switchKey),
matchesGoldenFile(
'switch.tap.off.dark.png',
version: 0,
),
matchesGoldenFile('switch.tap.off.dark.png'),
);
await tester.tap(find.byKey(switchKey));
......@@ -616,10 +604,7 @@ void main() {
await tester.pumpAndSettle();
await expectLater(
find.byKey(switchKey),
matchesGoldenFile(
'switch.tap.on.dark.png',
version: 0,
),
matchesGoldenFile('switch.tap.on.dark.png'),
);
});
}
......@@ -503,10 +503,7 @@ void main() {
await expectLater(
find.byKey(const ValueKey<int>(1)),
matchesGoldenFile(
'text_field_cursor_test.cupertino.0.png',
version: 3,
),
matchesGoldenFile('text_field_cursor_test.cupertino.0.png'),
);
});
......@@ -536,10 +533,7 @@ void main() {
debugDefaultTargetPlatformOverride = null;
await expectLater(
find.byKey(const ValueKey<int>(1)),
matchesGoldenFile(
'text_field_cursor_test.cupertino.1.png',
version: 3,
),
matchesGoldenFile('text_field_cursor_test.cupertino.1.png'),
);
});
......@@ -3042,10 +3036,7 @@ void main() {
await expectLater(
find.byKey(const ValueKey<int>(1)),
matchesGoldenFile(
'text_field_test.disabled.png',
version: 1,
),
matchesGoldenFile('text_field_test.disabled.png'),
);
});
......
......@@ -71,19 +71,13 @@ void main() {
await pump(FloatingActionButtonLocation.endDocked);
await expectLater(
find.byKey(key),
matchesGoldenFile(
'bottom_app_bar.custom_shape.1.png',
version: null,
),
matchesGoldenFile('bottom_app_bar.custom_shape.1.png'),
);
await pump(FloatingActionButtonLocation.centerDocked);
await tester.pumpAndSettle();
await expectLater(
find.byKey(key),
matchesGoldenFile(
'bottom_app_bar.custom_shape.2.png',
version: null,
),
matchesGoldenFile('bottom_app_bar.custom_shape.2.png'),
);
}, skip: isBrowser);
......
......@@ -80,10 +80,7 @@ void main() {
await expectLater(
find.byKey(_painterKey),
matchesGoldenFile(
'bottom_app_bar_theme.custom_shape.png',
version: null,
),
matchesGoldenFile('bottom_app_bar_theme.custom_shape.png'),
);
}, skip: isBrowser);
......
......@@ -1426,10 +1426,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 30));
await expectLater(
find.byType(BottomNavigationBar),
matchesGoldenFile(
'bottom_navigation_bar.shifting_transition.$pump.png',
version: 2,
),
matchesGoldenFile('bottom_navigation_bar.shifting_transition.$pump.png'),
);
}
}, skip: isBrowser);
......
......@@ -137,10 +137,7 @@ void main() {
await expectLater(
find.byKey(painterKey),
matchesGoldenFile(
'card_theme.custom_shape.png',
version: null,
),
matchesGoldenFile('card_theme.custom_shape.png'),
);
}, skip: isBrowser);
}
......
......@@ -130,10 +130,7 @@ void main() {
await expectLater(
find.byKey(_painterKey),
matchesGoldenFile(
'dialog_theme.dialog_with_custom_border.png',
version: null,
),
matchesGoldenFile('dialog_theme.dialog_with_custom_border.png'),
);
}, skip: isBrowser);
......
......@@ -227,10 +227,7 @@ void main() {
assert(tester.renderObject(buttonFinder).attached);
await expectLater(
find.ancestor(of: buttonFinder, matching: find.byType(RepaintBoundary)).first,
matchesGoldenFile(
'dropdown_test.default.png',
version: 0,
),
matchesGoldenFile('dropdown_test.default.png'),
);
}, skip: isBrowser);
......@@ -242,10 +239,7 @@ void main() {
assert(tester.renderObject(buttonFinder).attached);
await expectLater(
find.ancestor(of: buttonFinder, matching: find.byType(RepaintBoundary)).first,
matchesGoldenFile(
'dropdown_test.expanded.png',
version: 0,
),
matchesGoldenFile('dropdown_test.expanded.png'),
);
}, skip: isBrowser);
......
......@@ -740,10 +740,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 1000));
await expectLater(
find.byKey(key),
matchesGoldenFile(
'floating_action_button_test.clip.png',
version: 2,
),
matchesGoldenFile('floating_action_button_test.clip.png'),
);
});
......
......@@ -2960,19 +2960,13 @@ void main() {
await tester.pumpWidget(buildFrame(TextDirection.ltr));
await expectLater(
find.byType(InputDecorator),
matchesGoldenFile(
'input_decorator.outline_icon_label.ltr.png',
version: null,
),
matchesGoldenFile('input_decorator.outline_icon_label.ltr.png'),
);
await tester.pumpWidget(buildFrame(TextDirection.rtl));
await expectLater(
find.byType(InputDecorator),
matchesGoldenFile(
'input_decorator.outline_icon_label.rtl.png',
version: null,
),
matchesGoldenFile('input_decorator.outline_icon_label.rtl.png'),
);
},
);
......
......@@ -715,10 +715,7 @@ void main() {
await expectLater(
find.byKey(painterKey),
matchesGoldenFile(
'material.border_paint_above.png',
version: null,
),
matchesGoldenFile('material.border_paint_above.png'),
);
}, skip: isBrowser);
......@@ -758,10 +755,7 @@ void main() {
await expectLater(
find.byKey(painterKey),
matchesGoldenFile(
'material.border_paint_below.png',
version: null,
),
matchesGoldenFile('material.border_paint_below.png'),
);
}, skip: isBrowser);
});
......
......@@ -276,10 +276,7 @@ void main() {
await tester.pumpAndSettle();
await expectLater(
find.byKey(painterKey),
matchesGoldenFile(
'radio.ink_ripple.png',
version: null,
),
matchesGoldenFile('radio.ink_ripple.png'),
);
}, skip: isBrowser);
}
......
......@@ -267,10 +267,7 @@ void main() {
await expectLater(
find.byKey(_painterKey),
matchesGoldenFile(
'tab_bar_theme.tab_indicator_size_tab.png',
version: null,
),
matchesGoldenFile('tab_bar_theme.tab_indicator_size_tab.png'),
);
}, skip: isBrowser);
......@@ -281,10 +278,7 @@ void main() {
await expectLater(
find.byKey(_painterKey),
matchesGoldenFile(
'tab_bar_theme.tab_indicator_size_label.png',
version: null,
),
matchesGoldenFile('tab_bar_theme.tab_indicator_size_label.png'),
);
}, skip: isBrowser);
......@@ -300,10 +294,7 @@ void main() {
await expectLater(
find.byKey(_painterKey),
matchesGoldenFile(
'tab_bar_theme.custom_tab_indicator.png',
version: null,
),
matchesGoldenFile('tab_bar_theme.custom_tab_indicator.png'),
);
}, skip: isBrowser);
......@@ -319,10 +310,7 @@ void main() {
await expectLater(
find.byKey(_painterKey),
matchesGoldenFile(
'tab_bar_theme.beveled_rect_indicator.png',
version: null,
),
matchesGoldenFile('tab_bar_theme.beveled_rect_indicator.png'),
);
}, skip: isBrowser);
}
......@@ -412,10 +412,7 @@ void main() {
await expectLater(
find.byKey(const ValueKey<int>(1)),
matchesGoldenFile(
'text_field_cursor_test.material.0.png',
version: 0,
),
matchesGoldenFile('text_field_cursor_test.material.0.png'),
);
});
......@@ -444,10 +441,7 @@ void main() {
debugDefaultTargetPlatformOverride = null;
await expectLater(
find.byKey(const ValueKey<int>(1)),
matchesGoldenFile(
'text_field_cursor_test.material.1.png',
version: 0,
),
matchesGoldenFile('text_field_cursor_test.material.1.png'),
);
});
......@@ -498,10 +492,7 @@ void main() {
await expectLater(
// The toolbar exists in the Overlay above the MaterialApp.
find.byType(Overlay),
matchesGoldenFile(
'text_field_opacity_test.0.png',
version: 3,
),
matchesGoldenFile('text_field_opacity_test.0.png'),
);
}, skip: isBrowser);
......
......@@ -71,10 +71,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'continuous_rectangle_border.golden_test_even_radii.png',
version: null,
),
matchesGoldenFile('continuous_rectangle_border.golden_test_even_radii.png'),
);
}, skip: isBrowser);
......@@ -95,10 +92,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'continuous_rectangle_border.golden_test_varying_radii.png',
version: null,
),
matchesGoldenFile('continuous_rectangle_border.golden_test_varying_radii.png'),
);
}, skip: isBrowser);
......@@ -116,10 +110,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'continuous_rectangle_border.golden_test_large_radii.png',
version: null,
),
matchesGoldenFile('continuous_rectangle_border.golden_test_large_radii.png'),
);
}, skip: isBrowser);
......
......@@ -806,7 +806,10 @@ void main() {
),
),
));
await expectLater(find.byKey(painterKey), matchesGoldenFile(goldenName));
await expectLater(
find.byKey(painterKey),
matchesGoldenFile(goldenName),
);
}
testWidgets('Gradients - 45 degrees', (WidgetTester tester) async {
......
......@@ -49,10 +49,7 @@ void main() {
await expectLater(
find.byType(RichText),
matchesGoldenFile(
'localized_fonts.rich_text.styled_text_span.png',
version: null,
),
matchesGoldenFile('localized_fonts.rich_text.styled_text_span.png'),
);
},
skip: isBrowser, // TODO(yjbanov): implement goldens on the Web: https://github.com/flutter/flutter/issues/40297
......@@ -104,10 +101,7 @@ void main() {
await expectLater(
find.byType(Row),
matchesGoldenFile(
'localized_fonts.text_ambient_locale.chars.png',
version: null,
),
matchesGoldenFile('localized_fonts.text_ambient_locale.chars.png'),
);
},
skip: isBrowser, // TODO(yjbanov): implement goldens on the Web: https://github.com/flutter/flutter/issues/40297
......@@ -151,10 +145,7 @@ void main() {
await expectLater(
find.byType(Row),
matchesGoldenFile(
'localized_fonts.text_explicit_locale.chars.png',
version: null,
),
matchesGoldenFile('localized_fonts.text_explicit_locale.chars.png'),
);
},
skip: isBrowser, // TODO(yjbanov): implement goldens on the Web: https://github.com/flutter/flutter/issues/40297
......
......@@ -43,10 +43,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'backdrop_filter_test.cull_rect.png',
version: 1,
),
matchesGoldenFile('backdrop_filter_test.cull_rect.png'),
);
}, skip: isBrowser);
}
......@@ -381,10 +381,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.ClipRect.png',
version: 1,
),
matchesGoldenFile('clip.ClipRect.png'),
);
}, skip: isBrowser);
......@@ -424,10 +421,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.ClipRectOverlay.png',
version: 1,
),
matchesGoldenFile('clip.ClipRectOverlay.png'),
);
}, skip: isBrowser);
......@@ -476,10 +470,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.ClipRRect.png',
version: 1,
),
matchesGoldenFile('clip.ClipRRect.png'),
);
}, skip: isBrowser);
......@@ -522,10 +513,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.ClipOval.png',
version: 1,
),
matchesGoldenFile('clip.ClipOval.png'),
);
}, skip: isBrowser);
......@@ -573,10 +561,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.ClipPath.png',
version: 1,
),
matchesGoldenFile('clip.ClipPath.png'),
);
}, skip: isBrowser);
......@@ -621,10 +606,7 @@ void main() {
await tester.pumpWidget(genPhysicalModel(Clip.antiAlias));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.PhysicalModel.antiAlias.png',
version: 1,
),
matchesGoldenFile('clip.PhysicalModel.antiAlias.png'),
);
}, skip: isBrowser);
......@@ -632,10 +614,7 @@ void main() {
await tester.pumpWidget(genPhysicalModel(Clip.hardEdge));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.PhysicalModel.hardEdge.png',
version: 1,
),
matchesGoldenFile('clip.PhysicalModel.hardEdge.png'),
);
}, skip: isBrowser);
......@@ -645,10 +624,7 @@ void main() {
await tester.pumpWidget(genPhysicalModel(Clip.antiAliasWithSaveLayer));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.PhysicalModel.antiAliasWithSaveLayer.png',
version: null,
),
matchesGoldenFile('clip.PhysicalModel.antiAliasWithSaveLayer.png'),
);
}, skip: isBrowser);
......@@ -690,10 +666,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.PhysicalModel.default.png',
version: 1,
),
matchesGoldenFile('clip.PhysicalModel.default.png'),
);
}, skip: isBrowser);
......@@ -742,10 +715,7 @@ void main() {
await tester.pumpWidget(genPhysicalShape(Clip.antiAlias));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.PhysicalShape.antiAlias.png',
version: 1,
),
matchesGoldenFile('clip.PhysicalShape.antiAlias.png'),
);
}, skip: isBrowser);
......@@ -753,10 +723,7 @@ void main() {
await tester.pumpWidget(genPhysicalShape(Clip.hardEdge));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.PhysicalShape.hardEdge.png',
version: 1,
),
matchesGoldenFile('clip.PhysicalShape.hardEdge.png'),
);
}, skip: isBrowser);
......@@ -764,10 +731,7 @@ void main() {
await tester.pumpWidget(genPhysicalShape(Clip.antiAliasWithSaveLayer));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.PhysicalShape.antiAliasWithSaveLayer.png',
version: null,
),
matchesGoldenFile('clip.PhysicalShape.antiAliasWithSaveLayer.png'),
);
}, skip: isBrowser);
......@@ -813,10 +777,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'clip.PhysicalShape.default.png',
version: 1,
),
matchesGoldenFile('clip.PhysicalShape.default.png'),
);
}, skip: isBrowser);
......
......@@ -18,10 +18,7 @@ void main() {
);
await expectLater(
find.byType(ColorFiltered),
matchesGoldenFile(
'color_filter_red.png',
version: 1,
),
matchesGoldenFile('color_filter_red.png'),
);
});
......@@ -58,10 +55,7 @@ void main() {
);
await expectLater(
find.byType(ColorFiltered),
matchesGoldenFile(
'color_filter_sepia.png',
version: 1,
),
matchesGoldenFile('color_filter_sepia.png'),
);
});
......
......@@ -90,10 +90,7 @@ void main() {
await expectLater(
find.byKey(const ValueKey<int>(1)),
matchesGoldenFile(
'editable_text_test.0.png',
version: 3,
),
matchesGoldenFile('editable_text_test.0.png'),
);
});
......@@ -144,10 +141,7 @@ void main() {
await expectLater(
find.byKey(const ValueKey<int>(1)),
matchesGoldenFile(
'editable_text_test.1.png',
version: 3,
),
matchesGoldenFile('editable_text_test.1.png'),
);
});
......@@ -797,10 +791,7 @@ void main() {
await expectLater(
find.byKey(const ValueKey<int>(1)),
matchesGoldenFile(
'editable_text_test.2.png',
version: 0,
),
matchesGoldenFile('editable_text_test.2.png'),
);
debugDefaultTargetPlatformOverride = null;
});
......
......@@ -20,10 +20,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'invert_colors_test.0.png',
version: null,
),
matchesGoldenFile('invert_colors_test.0.png'),
);
}, skip: isBrowser);
......@@ -41,10 +38,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'invert_colors_test.1.png',
version: null,
),
matchesGoldenFile('invert_colors_test.1.png'),
);
}, skip: isBrowser);
}
......
......@@ -535,10 +535,7 @@ void main() {
await expectLater(
find.byKey(const Key('list_wheel_scroll_view')),
matchesGoldenFile(
'list_wheel_scroll_view.center_child.magnified.png',
version: null,
),
matchesGoldenFile('list_wheel_scroll_view.center_child.magnified.png'),
);
}, skip: isBrowser);
......@@ -592,10 +589,7 @@ void main() {
await expectLater(
find.byKey(const Key('list_wheel_scroll_view')),
matchesGoldenFile(
'list_wheel_scroll_view.curved_wheel.left.png',
version: null,
),
matchesGoldenFile('list_wheel_scroll_view.curved_wheel.left.png'),
);
}, skip: isBrowser);
......
......@@ -178,10 +178,7 @@ void main() {
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'opacity_test.offset.png',
version: 1,
),
matchesGoldenFile('opacity_test.offset.png'),
);
}, skip: isBrowser);
......
......@@ -110,10 +110,7 @@ void main() {
expect(exception.diagnostics.first.toString(), startsWith('A RenderFlex overflowed by '));
await expectLater(
find.byKey(key),
matchesGoldenFile(
'physical_model_overflow.png',
version: null,
),
matchesGoldenFile('physical_model_overflow.png'),
);
}, skip: isBrowser);
......
......@@ -23,20 +23,14 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'shadow.BoxDecoration.disabled.png',
version: null,
),
matchesGoldenFile('shadow.BoxDecoration.disabled.png'),
);
debugDisableShadows = false;
tester.binding.reassembleApplication();
await tester.pump();
await expectLater(
find.byType(Container),
matchesGoldenFile(
'shadow.BoxDecoration.enabled.png',
version: null,
),
matchesGoldenFile('shadow.BoxDecoration.enabled.png'),
);
debugDisableShadows = true;
}, skip: isBrowser);
......@@ -62,10 +56,7 @@ void main() {
await tester.pumpWidget(build(elevation));
await expectLater(
find.byType(Container),
matchesGoldenFile(
'shadow.ShapeDecoration.$elevation.png',
version: null,
),
matchesGoldenFile('shadow.ShapeDecoration.$elevation.png'),
);
}
debugDisableShadows = true;
......@@ -92,20 +83,14 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'shadow.PhysicalModel.disabled.png',
version: null,
),
matchesGoldenFile('shadow.PhysicalModel.disabled.png'),
);
debugDisableShadows = false;
tester.binding.reassembleApplication();
await tester.pump();
await expectLater(
find.byType(Container),
matchesGoldenFile(
'shadow.PhysicalModel.enabled.png',
version: null,
),
matchesGoldenFile('shadow.PhysicalModel.enabled.png'),
);
debugDisableShadows = true;
}, skip: isBrowser);
......@@ -135,10 +120,7 @@ void main() {
await tester.pumpWidget(build(elevation.toDouble()));
await expectLater(
find.byType(Container),
matchesGoldenFile(
'shadow.PhysicalShape.$elevation.png',
version: 1,
),
matchesGoldenFile('shadow.PhysicalShape.$elevation.png'),
);
}
debugDisableShadows = true;
......
......@@ -30,10 +30,7 @@ void main() {
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.Centered.png',
version: null,
),
matchesGoldenFile('text_golden.Centered.png'),
);
await tester.pumpWidget(
......@@ -57,10 +54,7 @@ void main() {
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.Centered.wrap.png',
version: null,
),
matchesGoldenFile('text_golden.Centered.wrap.png'),
);
});
......@@ -91,10 +85,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'text_golden.Foreground.gradient.png',
version: null,
),
matchesGoldenFile('text_golden.Foreground.gradient.png'),
);
await tester.pumpWidget(
......@@ -116,10 +107,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'text_golden.Foreground.stroke.png',
version: null,
),
matchesGoldenFile('text_golden.Foreground.stroke.png'),
);
await tester.pumpWidget(
......@@ -142,10 +130,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'text_golden.Foreground.stroke_and_gradient.png',
version: null,
),
matchesGoldenFile('text_golden.Foreground.stroke_and_gradient.png'),
);
});
......@@ -195,10 +180,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile(
'text_golden.Background.png',
version: null,
),
matchesGoldenFile('text_golden.Background.png'),
);
});
......@@ -234,10 +216,7 @@ void main() {
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile(
'text_golden.Fade.png',
version: 1,
),
matchesGoldenFile('text_golden.Fade.png'),
);
});
......@@ -262,10 +241,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.StrutDefault.png',
version: null,
),
matchesGoldenFile('text_golden.StrutDefault.png'),
);
});
......@@ -292,10 +268,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.Strut.1.png',
version: 1,
),
matchesGoldenFile('text_golden.Strut.1.png'),
);
});
......@@ -323,10 +296,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.Strut.2.png',
version: 1,
),
matchesGoldenFile('text_golden.Strut.2.png'),
);
});
......@@ -377,10 +347,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.Strut.3.png',
version: 1,
),
matchesGoldenFile('text_golden.Strut.3.png'),
);
});
......@@ -415,10 +382,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.Strut.4.png',
version: 1,
),
matchesGoldenFile('text_golden.Strut.4.png'),
);
});
......@@ -469,10 +433,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.StrutForce.1.png',
version: 1,
),
matchesGoldenFile('text_golden.StrutForce.1.png'),
);
});
......@@ -510,10 +471,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.Decoration.1.png',
version: 0,
),
matchesGoldenFile('text_golden.Decoration.1.png'),
);
});
......@@ -552,10 +510,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.DecorationThickness.1.png',
version: 1,
),
matchesGoldenFile('text_golden.DecorationThickness.1.png'),
);
});
......@@ -649,10 +604,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidget.1.png',
version: 1,
),
matchesGoldenFile('text_golden.TextInlineWidget.1.png'),
);
});
......@@ -697,10 +649,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidget.2.png',
version: 2,
),
matchesGoldenFile('text_golden.TextInlineWidget.2.png'),
);
});
......@@ -829,10 +778,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidgetNest.1.png',
version: 3,
),
matchesGoldenFile('text_golden.TextInlineWidgetNest.1.png'),
);
});
......@@ -939,10 +885,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidgetBaseline.1.png',
version: 1,
),
matchesGoldenFile('text_golden.TextInlineWidgetBaseline.1.png'),
);
});
......@@ -1049,10 +992,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidgetAboveBaseline.1.png',
version: 1,
),
matchesGoldenFile('text_golden.TextInlineWidgetAboveBaseline.1.png'),
);
});
......@@ -1159,10 +1099,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidgetBelowBaseline.1.png',
version: 1,
),
matchesGoldenFile('text_golden.TextInlineWidgetBelowBaseline.1.png'),
);
});
......@@ -1269,10 +1206,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidgetTop.1.png',
version: 1,
),
matchesGoldenFile('text_golden.TextInlineWidgetTop.1.png'),
);
});
......@@ -1379,10 +1313,7 @@ void main() {
);
await expectLater(
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidgetMiddle.1.png',
version: 1,
),
matchesGoldenFile('text_golden.TextInlineWidgetMiddle.1.png'),
);
});
}
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Json response template for Skia Gold expectations request:
/// https://flutter-gold.skia.org/json/expectations/commit/HEAD
String rawExpectationsTemplate() {
return '''
{
"md5": "a7489b00e03a1846e43500b7c14dd7b0",
"master": {
"flutter.golden_test.1": {
"55109a4bed52acc780530f7a9aeff6c0": 1
},
"flutter.golden_test.3": {
"87cb35131e6ad4b57d4d09d59ae743c3": 1,
"dc94eb2c39c0c8ae11a4efd090b72f94": 1,
"f2583c9003978a06b7888878bdc089e2": 1
},
"flutter.golden_test.2": {
"eb03a5e3114c9ecad5e4f1178f285a49": 1,
"f14631979de24fca6e14ad247d5f2bd6": 1
}
}
}
''';
}
/// Decoded json response template for Skia Gold expectations request:
/// https://flutter-gold.skia.org/json/expectations/commit/HEAD
Map<String, List<String>> expectationsTemplate() {
return <String, List<String>>{
'flutter.golden_test.1': <String>[
'55109a4bed52acc780530f7a9aeff6c0'
],
'flutter.golden_test.3': <String>[
'87cb35131e6ad4b57d4d09d59ae743c3',
'dc94eb2c39c0c8ae11a4efd090b72f94',
'f2583c9003978a06b7888878bdc089e2',
],
'flutter.golden_test.2': <String>[
'eb03a5e3114c9ecad5e4f1178f285a49',
'f14631979de24fca6e14ad247d5f2bd6',
],
};
}
/// Json response template for Skia Gold digest request:
/// https://flutter-gold.skia.org/json/details?test=[testName]&digest=[expectation]
String digestResponseTemplate({
String testName = 'flutter.golden_test.1',
String expectation = '55109a4bed52acc780530f7a9aeff6c0',
String platform = 'macos',
String status = 'positive',
}) {
return '''
{
"digest": {
"test": "$testName",
"digest": "$expectation",
"status": "$status",
"paramset": {
"Platform": [
"$platform"
],
"ext": [
"png"
],
"name": [
"$testName"
],
"source_type": [
"flutter"
]
},
"traces": {
"tileSize": 200,
"traces": [
{
"data": [
{
"x": 0,
"y": 0,
"s": 0
},
{
"x": 1,
"y": 0,
"s": 0
},
{
"x": 199,
"y": 0,
"s": 0
}
],
"label": ",Platform=$platform,name=$testName,source_type=flutter,",
"params": {
"Platform": "$platform",
"ext": "png",
"name": "$testName",
"source_type": "flutter"
}
}
],
"digests": [
{
"digest": "$expectation",
"status": "$status"
}
]
},
"closestRef": "pos",
"refDiffs": {
"neg": null,
"pos": {
"numDiffPixels": 999,
"pixelDiffPercent": 0.4995,
"maxRGBADiffs": [
86,
86,
86,
0
],
"dimDiffer": false,
"diffs": {
"combined": 0.381955,
"percent": 0.4995,
"pixel": 999
},
"digest": "aa748136c70cefdda646df5be0ae189d",
"status": "positive",
"paramset": {
"Platform": [
"macos"
],
"ext": [
"png"
],
"name": [
"$testName"
],
"source_type": [
"flutter"
]
},
"n": 197
}
}
},
"commits": [
{
"commit_time": 1568069344,
"hash": "399bb04e2de41665320d3c888f40af6d8bc734a2",
"author": "Contributor A (contributorA@getMail.com)"
},
{
"commit_time": 1568078053,
"hash": "0f365d3add253a65e5e5af1024f56c6169bf9739",
"author": "Contributor B (contributorB@getMail.com)"
},
{
"commit_time": 1569353925,
"hash": "81e693a7fe3b808cc9ae2bb3a2cbe404e67ec773",
"author": "Contributor C (contributorC@getMail.com)"
}
]
}
''';
}
/// Json response template for Skia Gold ignore request:
/// https://flutter-gold.skia.org/json/ignores
String ignoreResponseTemplate({
String pullRequestNumber = '0000',
String testName = 'flutter.golden_test.1',
}) {
return '''
[
{
"id": "7579425228619212078",
"name": "contributor@getMail.com",
"updatedBy": "contributor@getMail.com",
"expires": "2019-09-06T21:28:18.815336Z",
"query": "ext=png&name=$testName",
"note": "https://github.com/flutter/flutter/pull/$pullRequestNumber"
}
]
''';
}
/// Json response template for Skia Gold image request:
/// https://flutter-gold.skia.org/img/images/[imageHash].png
List<List<int>> imageResponseTemplate() {
return <List<int>>[
<int>[137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73,
72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0, 0, 0, 31, 21, 196, 137, 0],
<int>[0, 0, 11, 73, 68, 65, 84, 120, 1, 99, 97, 0, 2, 0,
0, 25, 0, 5, 144, 240, 54, 245, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96,
130],
];
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io' as io;
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
// If you are here trying to figure out how to use golden files in the Flutter
// repo itself, consider reading this wiki page:
// https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package%3Aflutter
const String _kFlutterRootKey = 'FLUTTER_ROOT';
/// A base class that provides shared information to the
/// [FlutterGoldenFileComparator] as well as the [SkiaGoldClient] and
/// [GoldensRepositoryClient].
abstract class GoldensClient {
/// Creates a handle to the local environment of golden file images.
GoldensClient({
this.fs = const LocalFileSystem(),
this.platform = const LocalPlatform(),
this.process = const LocalProcessManager(),
});
/// The file system to use for storing the local clone of the repository.
///
/// This is useful in tests, where a local file system (the default) can
/// be replaced by a memory file system.
final FileSystem fs;
/// A wrapper for the [dart:io.Platform] API.
///
/// This is useful in tests, where the system platform (the default) can
/// be replaced by a mock platform instance.
final Platform platform;
/// A controller for launching subprocesses.
///
/// This is useful in tests, where the real process manager (the default)
/// can be replaced by a mock process manager that doesn't really create
/// subprocesses.
final ProcessManager process;
/// The local [Directory] where the Flutter repository is hosted.
///
/// Uses the [fs] file system.
Directory get flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]);
/// The local [Directory] where the goldens files are located.
///
/// Uses the [fs] file system.
Directory get comparisonRoot => flutterRoot.childDirectory(fs.path.join('bin', 'cache', 'pkg', 'goldens'));
}
/// A class that represents a clone of the https://github.com/flutter/goldens
/// repository, nested within the `bin/cache` directory of the caller's Flutter
/// repository.
class GoldensRepositoryClient extends GoldensClient {
GoldensRepositoryClient({
FileSystem fs = const LocalFileSystem(),
ProcessManager process = const LocalProcessManager(),
Platform platform = const LocalPlatform(),
}) : super(
fs: fs,
process: process,
platform: platform,
);
RandomAccessFile _lock;
/// Prepares the local clone of the `flutter/goldens` repository for golden
/// file testing.
///
/// This ensures that the goldens repository has been cloned into its
/// expected location within `bin/cache` and that it is synced to the Git
/// revision specified in `bin/internal/goldens.version`.
///
/// While this is preparing the repository, it obtains a file lock such that
/// [GoldensClient] instances in other processes or isolates will not
/// duplicate the work that this is doing.
Future<void> prepare() async {
final String goldensCommit = await _getGoldensCommit();
String currentCommit = await _getCurrentCommit();
if (currentCommit != goldensCommit) {
await _obtainLock();
try {
// Check the current commit again now that we have the lock.
currentCommit = await _getCurrentCommit();
if (currentCommit != goldensCommit) {
if (currentCommit == null) {
await _initRepository();
}
await _checkCanSync();
await _syncTo(goldensCommit);
}
} finally {
await _releaseLock();
}
}
}
Future<String> _getCurrentCommit() async {
if (!comparisonRoot.existsSync()) {
return null;
} else {
final io.ProcessResult revParse = await process.run(
<String>['git', 'rev-parse', 'HEAD'],
workingDirectory: comparisonRoot.path,
);
return revParse.exitCode == 0 ? revParse.stdout.trim() : null;
}
}
Future<String> _getGoldensCommit() async {
final File versionFile = flutterRoot.childFile(fs.path.join('bin', 'internal', 'goldens.version'));
return (await versionFile.readAsString()).trim();
}
Future<void> _initRepository() async {
await comparisonRoot.create(recursive: true);
await _runCommands(
<String>[
'git init',
'git remote add upstream https://github.com/flutter/goldens.git',
'git remote set-url --push upstream git@github.com:flutter/goldens.git',
],
workingDirectory: comparisonRoot,
);
}
Future<void> _checkCanSync() async {
final io.ProcessResult result = await process.run(
<String>['git', 'status', '--porcelain'],
workingDirectory: comparisonRoot.path,
);
if (result.stdout.trim().isNotEmpty) {
final StringBuffer buf = StringBuffer()
..writeln('flutter_goldens git checkout at ${comparisonRoot.path} has local changes and cannot be synced.')
..writeln('To reset your client to a clean state, and lose any local golden test changes:')
..writeln('cd ${comparisonRoot.path}')
..writeln('git reset --hard HEAD')
..writeln('git clean -x -d -f -f');
throw NonZeroExitCode(1, buf.toString());
}
}
Future<void> _syncTo(String commit) async {
await _runCommands(
<String>[
'git pull upstream master',
'git fetch upstream $commit',
'git reset --hard FETCH_HEAD',
],
workingDirectory: comparisonRoot,
);
}
Future<void> _runCommands(
List<String> commands, {
Directory workingDirectory,
}) async {
for (String command in commands) {
final List<String> parts = command.split(' ');
final io.ProcessResult result = await process.run(
parts,
workingDirectory: workingDirectory?.path,
);
if (result.exitCode != 0) {
throw NonZeroExitCode(result.exitCode, result.stderr);
}
}
}
Future<void> _obtainLock() async {
final File lockFile = flutterRoot.childFile(fs.path.join('bin', 'cache', 'goldens.lockfile'));
await lockFile.create(recursive: true);
_lock = await lockFile.open(mode: io.FileMode.write);
await _lock.lock(io.FileLock.blockingExclusive);
}
Future<void> _releaseLock() async {
await _lock.close();
_lock = null;
}
}
/// Exception that signals a process' exit with a non-zero exit code.
class NonZeroExitCode implements Exception {
/// Create an exception that represents a non-zero exit code.
///
/// The first argument must be non-zero.
const NonZeroExitCode(this.exitCode, this.stderr) : assert(exitCode != 0);
/// The code that the process will signal to the operating system.
///
/// By definition, this is not zero.
final int exitCode;
/// The message to show on standard error.
final String stderr;
@override
String toString() {
return 'Exit code $exitCode: $stderr';
}
}
......@@ -15,8 +15,8 @@ import 'goldens.dart';
/// The default [GoldenFileComparator] implementation for `flutter test`.
///
/// The term __golden file__ refers to a master image that is considered the true
/// rendering of a given widget, state, application, or other visual
/// The term __golden file__ refers to a master image that is considered the
/// true rendering of a given widget, state, application, or other visual
/// representation you have chosen to capture. This comparator loads golden
/// files from the local file system, treating the golden key as a relative
/// path from the test file's directory.
......@@ -53,7 +53,7 @@ import 'goldens.dart';
/// implements.
/// * [matchesGoldenFile], the function from [flutter_test] that invokes the
/// comparator.
class LocalFileComparator extends GoldenFileComparator {
class LocalFileComparator extends GoldenFileComparator with LocalComparisonOutput {
/// Creates a new [LocalFileComparator] for the specified [testFile].
///
/// Golden file keys will be interpreted as file paths relative to the
......@@ -90,24 +90,18 @@ class LocalFileComparator extends GoldenFileComparator {
Future<bool> compare(Uint8List imageBytes, Uri golden) async {
final File goldenFile = _getGoldenFile(golden);
if (!goldenFile.existsSync()) {
throw test_package.TestFailure('Could not be compared against non-existent file: "$golden"');
throw test_package.TestFailure(
'Could not be compared against non-existent file: "$golden"'
);
}
final List<int> goldenBytes = await goldenFile.readAsBytes();
final ComparisonResult result = GoldenFileComparator.compareLists(imageBytes, goldenBytes);
final ComparisonResult result = GoldenFileComparator.compareLists(
imageBytes,
goldenBytes,
);
if (!result.passed) {
String additionalFeedback = '';
if (result.diffs != null) {
additionalFeedback = '\nFailure feedback can be found at ${path.join(basedir.path, 'failures')}';
final Map<String, Object> diffs = result.diffs;
diffs.forEach((String name, Object untypedImage) {
final Image image = untypedImage;
final File output = _getFailureFile(name, golden);
output.parent.createSync(recursive: true);
output.writeAsBytesSync(encodePng(image));
});
}
throw test_package.TestFailure('Golden "$golden": ${result.error}$additionalFeedback');
generateFailureOutput(result, golden, basedir);
}
return result.passed;
}
......@@ -122,16 +116,50 @@ class LocalFileComparator extends GoldenFileComparator {
File _getGoldenFile(Uri golden) {
return File(_path.join(_path.fromUri(basedir), _path.fromUri(golden.path)));
}
}
/// A class for use in golden file comparators that run locally and provide
/// output.
class LocalComparisonOutput {
/// Writes out diffs from the [ComparisonResult] of a golden file test.
///
/// Will throw an error if a null result is provided.
void generateFailureOutput(
ComparisonResult result,
Uri golden,
Uri basedir, {
String key = '',
}) {
String additionalFeedback = '';
if (result.diffs != null) {
additionalFeedback = '\nFailure feedback can be found at '
'${path.join(basedir.path, 'failures')}';
final Map<String, Image> diffs = result.diffs;
diffs.forEach((String name, Image image) {
final File output = getFailureFile(
key.isEmpty ? name : name + '_' + key,
golden,
basedir,
);
output.parent.createSync(recursive: true);
output.writeAsBytesSync(encodePng(image));
});
}
throw test_package.TestFailure(
'Golden "$golden": ${result.error}$additionalFeedback'
);
}
File _getFailureFile(String failure, Uri golden) {
/// Returns the appropriate file for a given diff from a [ComparisonResult].
File getFailureFile(String failure, Uri golden, Uri basedir) {
final String fileName = golden.pathSegments[0];
final String testName = fileName.split(path.extension(fileName))[0]
+ '_'
+ failure
+ '.png';
return File(_path.join(
_path.fromUri(basedir),
_path.fromUri(Uri.parse('failures/$testName')),
return File(path.join(
path.fromUri(basedir),
path.fromUri(Uri.parse('failures/$testName')),
));
}
}
......@@ -203,7 +231,9 @@ ComparisonResult compareLists(List<int> test, List<int> master) {
if (pixelDiffCount > 0) {
return ComparisonResult(
passed: false,
error: 'Pixel test failed, ${((pixelDiffCount/totalPixels) * 100).toStringAsFixed(2)}% diff detected.',
error: 'Pixel test failed, '
'${((pixelDiffCount/totalPixels) * 100).toStringAsFixed(2)}% '
'diff detected.',
diffs: diffs,
);
}
......
......@@ -303,9 +303,7 @@ Matcher coversSameAreaAs(Path expectedPath, { @required Rect areaToCompare, int
/// The [key] may be either a [Uri] or a [String] representation of a URI.
///
/// The [version] is a number that can be used to differentiate historical
/// golden files. This parameter is optional. Version numbers are used in golden
/// file tests for package:flutter. You can learn more about these tests
/// [here](https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter).
/// golden files. This parameter is optional.
///
/// This is an asynchronous matcher, meaning that callers should use
/// [expectLater] when using this matcher and await the future returned by
......@@ -336,8 +334,11 @@ Matcher coversSameAreaAs(Path expectedPath, { @required Rect areaToCompare, int
///
/// await expectLater(
/// imageFuture,
/// matchesGoldenFile('save.png'),
/// );
/// matchesGoldenFile(
/// 'save.png',
/// version: 2,
/// ),
/// );
///
/// await expectLater(
/// find.byType(MyWidget),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment