Skip to content

Commit

Permalink
Unlooping Golden File Tests (flutter#51883)
Browse files Browse the repository at this point in the history
  • Loading branch information
fluttergithubbot authored Mar 4, 2020
1 parent 0b8129d commit b0381df
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 60 deletions.
35 changes: 19 additions & 16 deletions packages/flutter/test/material/bottom_navigation_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1404,12 +1404,11 @@ void main() {
expect(tester.widget<Material>(backgroundMaterial).color, Colors.green);
});

testWidgets('BottomNavigationBar shifting backgroundColor with transition', (WidgetTester tester) async {
group('BottomNavigationBar shifting backgroundColor with transition', () {
// Regression test for: https://github.com/flutter/flutter/issues/22226

int _currentIndex = 0;
await tester.pumpWidget(
MaterialApp(
Widget runTest() {
int _currentIndex = 0;
return MaterialApp(
home: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Scaffold(
Expand Down Expand Up @@ -1439,19 +1438,23 @@ void main() {
);
},
),
),
);

await tester.tap(find.text('Green'));

for (int pump = 0; pump < 8; pump++) {
await tester.pump(const Duration(milliseconds: 30));
await expectLater(
find.byType(BottomNavigationBar),
matchesGoldenFile('bottom_navigation_bar.shifting_transition.$pump.png'),
);
}
}, skip: isBrowser);
for (int pump = 1; pump < 9; pump++) {
testWidgets('pump $pump', (WidgetTester tester) async {
await tester.pumpWidget(runTest());
await tester.tap(find.text('Green'));

for (int i = 0; i < pump; i++) {
await tester.pump(const Duration(milliseconds: 30));
}
await expectLater(
find.byType(BottomNavigationBar),
matchesGoldenFile('bottom_navigation_bar.shifting_transition.${pump - 1}.png'),
);
}, skip: isBrowser); // TODO(yjbanov): web does not support golden tests yet: https://github.com/flutter/flutter/issues/40297
}
});

testWidgets('BottomNavigationBar item title should not be nullable', (WidgetTester tester) async {
expect(() {
Expand Down
8 changes: 4 additions & 4 deletions packages/flutter/test/material/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,10 @@ void main() {

await expectLater(
find.byType(TextField),
matchesGoldenFile('text_field_cursor_width_test.0.0.png', version: 0),
matchesGoldenFile('text_field_cursor_width_test.0.png'),
);
EditableText.debugDeterministicCursor = false;
}, skip: !isLinux);
});

testWidgets('cursor layout has correct radius', (WidgetTester tester) async {
EditableText.debugDeterministicCursor = true;
Expand All @@ -703,10 +703,10 @@ void main() {

await expectLater(
find.byType(TextField),
matchesGoldenFile('text_field_cursor_width_test.1.0.png', version: 0),
matchesGoldenFile('text_field_cursor_width_test.1.png'),
);
EditableText.debugDeterministicCursor = false;
}, skip: !isLinux);
});

testWidgets('Overflowing a line with spaces stops the cursor at the end', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController();
Expand Down
16 changes: 10 additions & 6 deletions packages/flutter/test/painting/gradient_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -813,17 +813,21 @@ void main() {
);
}

testWidgets('Gradients - 45 degrees', (WidgetTester tester) async {
group('Gradients - 45 degrees', () {
for (final Gradient gradient in gradients45) {
await runTest(tester, gradient, 45);
testWidgets('$gradient', (WidgetTester tester) async {
await runTest(tester, gradient, 45);
}, skip: isBrowser); // TODO(yjbanov): web does not support golden tests yet: https://github.com/flutter/flutter/issues/40297
}
}, skip: isBrowser); // TODO(yjbanov): web does not support golden tests yet: https://github.com/flutter/flutter/issues/40297
});

testWidgets('Gradients - 90 degrees', (WidgetTester tester) async {
group('Gradients - 90 degrees', () {
for (final Gradient gradient in gradients90) {
await runTest(tester, gradient, 90);
testWidgets('$gradient', (WidgetTester tester) async {
await runTest(tester, gradient, 90);
}, skip: isBrowser); // TODO(yjbanov): web does not support golden tests yet: https://github.com/flutter/flutter/issues/40297
}
}, skip: isBrowser); // TODO(yjbanov): web does not support golden tests yet: https://github.com/flutter/flutter/issues/40297
});
});
}

Expand Down
74 changes: 40 additions & 34 deletions packages/flutter/test/widgets/shadow_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ void main() {
debugDisableShadows = true;
});

testWidgets('Shadows on ShapeDecoration', (WidgetTester tester) async {
debugDisableShadows = false;
group('Shadows on ShapeDecoration', () {
Widget build(int elevation) {
return Center(
child: RepaintBoundary(
Expand All @@ -57,13 +56,16 @@ void main() {
);
}
for (final int elevation in kElevationToShadow.keys) {
await tester.pumpWidget(build(elevation));
await expectLater(
find.byType(Container),
matchesGoldenFile('shadow.ShapeDecoration.$elevation.png'),
);
testWidgets('elevation $elevation', (WidgetTester tester) async {
debugDisableShadows = false;
await tester.pumpWidget(build(elevation));
await expectLater(
find.byType(Container),
matchesGoldenFile('shadow.ShapeDecoration.$elevation.png'),
);
debugDisableShadows = true;
});
}
debugDisableShadows = true;
});

testWidgets('Shadows with PhysicalLayer', (WidgetTester tester) async {
Expand Down Expand Up @@ -99,34 +101,38 @@ void main() {
debugDisableShadows = true;
});

for (final int elevation in kElevationToShadow.keys) {
testWidgets('Shadows with PhysicalShape $elevation', (WidgetTester tester) async {
debugDisableShadows = false;
Widget build(double elevation) {
return Center(
child: RepaintBoundary(
child: Container(
padding: const EdgeInsets.all(150.0),
color: Colors.yellow[200],
child: PhysicalShape(
color: Colors.green[900],
clipper: ShapeBorderClipper(shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(20.0))),
elevation: elevation,
child: const SizedBox(
height: 100.0,
width: 100.0,
),
group('Shadows with PhysicalShape', () {
Widget build(double elevation) {
return Center(
child: RepaintBoundary(
child: Container(
padding: const EdgeInsets.all(150.0),
color: Colors.yellow[200],
child: PhysicalShape(
color: Colors.green[900],
clipper: ShapeBorderClipper(shape: BeveledRectangleBorder(
borderRadius: BorderRadius.circular(20.0))),
elevation: elevation,
child: const SizedBox(
height: 100.0,
width: 100.0,
),
),
),
);
}
await tester.pumpWidget(build(elevation.toDouble()));
await expectLater(
find.byType(Container),
matchesGoldenFile('shadow.PhysicalShape.$elevation.png'),
),
);
debugDisableShadows = true;
});
}
}

for (final int elevation in kElevationToShadow.keys) {
testWidgets('elevation $elevation', (WidgetTester tester) async {
debugDisableShadows = false;
await tester.pumpWidget(build(elevation.toDouble()));
await expectLater(
find.byType(Container),
matchesGoldenFile('shadow.PhysicalShape.$elevation.png'),
);
debugDisableShadows = true;
});
}
});
}

0 comments on commit b0381df

Please sign in to comment.