Skip to content

Commit 67ee79b

Browse files
committed
Seems the rendering is not that equal after all...
Also add a constant device size for all goldens
1 parent 4920c2a commit 67ee79b

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

test/nutrition/nutritional_plan_screen_test.dart

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
import 'dart:io';
20+
1921
import 'package:drift/native.dart';
2022
import 'package:flutter/material.dart';
2123
import 'package:flutter_test/flutter_test.dart';
@@ -92,10 +94,12 @@ void main() {
9294
await tester.tap(find.byType(TextButton));
9395
await tester.pumpAndSettle();
9496

95-
await expectLater(
96-
find.byType(NutritionalPlanScreen),
97-
matchesGoldenFile('goldens/nutritional_plan_1_default_view.png'),
98-
);
97+
if (Platform.isLinux) {
98+
await expectLater(
99+
find.byType(NutritionalPlanScreen),
100+
matchesGoldenFile('goldens/nutritional_plan_1_default_view.png'),
101+
);
102+
}
99103

100104
// Default view shows plan description, info button, and no ingredients
101105
expect(find.text('Less fat, more protein'), findsOneWidget);
@@ -109,10 +113,12 @@ void main() {
109113
await tester.tap(infoOutlineButtons.first); // 2nd button shows up also, but is off-screen
110114
await tester.pumpAndSettle();
111115

112-
await expectLater(
113-
find.byType(NutritionalPlanScreen),
114-
matchesGoldenFile('goldens/nutritional_plan_2_one_meal_with_ingredients.png'),
115-
);
116+
if (Platform.isLinux) {
117+
await expectLater(
118+
find.byType(NutritionalPlanScreen),
119+
matchesGoldenFile('goldens/nutritional_plan_2_one_meal_with_ingredients.png'),
120+
);
121+
}
116122

117123
// Ingredients show up now
118124
expect(find.text('100g Water'), findsOneWidget);
@@ -131,10 +137,13 @@ void main() {
131137

132138
await tester.tap(infoOutlineButtons.first);
133139
await tester.pumpAndSettle();
134-
await expectLater(
135-
find.byType(MaterialApp),
136-
matchesGoldenFile('goldens/nutritional_plan_3_both_meals_with_ingredients.png'),
137-
);
140+
141+
if (Platform.isLinux) {
142+
await expectLater(
143+
find.byType(MaterialApp),
144+
matchesGoldenFile('goldens/nutritional_plan_3_both_meals_with_ingredients.png'),
145+
);
146+
}
138147

139148
expect(find.byIcon(Icons.info_outline), findsOneWidget);
140149
expect(find.byIcon(Icons.info), findsNWidgets(2));
2.46 KB
Loading

test/workout/routine_logs_screen_test.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
import 'dart:io';
20+
1921
import 'package:clock/clock.dart';
2022
import 'package:flutter/material.dart';
2123
import 'package:flutter_test/flutter_test.dart';
@@ -70,13 +72,20 @@ void main() {
7072
testWidgets(
7173
'Smoke test the widgets on the routine logs screen',
7274
(WidgetTester tester) async {
75+
tester.view.physicalSize = const Size(500, 1000);
76+
tester.view.devicePixelRatio = 1.0; // Ensure correct pixel ratio
77+
7378
await withClock(Clock.fixed(DateTime(2025, 3, 29)), () async {
7479
await tester.pumpWidget(renderWidget());
7580
await tester.tap(find.byType(TextButton));
7681
await tester.pumpAndSettle();
7782

78-
await expectLater(find.byType(WorkoutLogsScreen),
79-
matchesGoldenFile('goldens/routine_logs_screen_detail.png'));
83+
if (Platform.isLinux) {
84+
await expectLater(
85+
find.byType(WorkoutLogsScreen),
86+
matchesGoldenFile('goldens/routine_logs_screen_detail.png'),
87+
);
88+
}
8089

8190
expect(find.text('Training logs'), findsOneWidget);
8291
expect(find.byType(WorkoutLogCalendar), findsOneWidget);

test/workout/routine_screen_test.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,18 @@ void main() {
7272
testWidgets(
7373
'Test the widgets on the routine screen',
7474
(WidgetTester tester) async {
75+
tester.view.physicalSize = const Size(500, 1000);
76+
tester.view.devicePixelRatio = 1.0; // Ensure correct pixel ratio
77+
7578
await tester.pumpWidget(renderWidget());
7679
await tester.tap(find.byType(TextButton));
7780
await tester.pumpAndSettle();
7881

7982
if (Platform.isLinux) {
8083
await expectLater(
81-
find.byType(MaterialApp), matchesGoldenFile('goldens/routine_logs_screen_detail.png'));
84+
find.byType(MaterialApp),
85+
matchesGoldenFile('goldens/routine_logs_screen_detail.png'),
86+
);
8287
}
8388

8489
expect(find.text('3 day workout'), findsOneWidget);

0 commit comments

Comments
 (0)