-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
343 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.7.8 | ||
1.7.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:sourdoc/constants/locale.dart' as locale; | ||
import 'package:sourdoc/widgets/home_page.dart'; | ||
|
||
void expectCalculatorValues({ | ||
required String temperatureUnit, | ||
required String temperature, | ||
required String weight, | ||
required String hydration, | ||
required String saltLevel, | ||
required String flour, | ||
required String water, | ||
required String levain, | ||
required String salt, | ||
required String inoculation, | ||
required String rise, | ||
}) { | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is SegmentedButton && | ||
widget.selected.contains(temperatureUnit)), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is TextField && | ||
widget.decoration!.prefixText == | ||
'${locale.inputPrefixTemperature}:' && | ||
widget.controller!.text == temperature), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is TextField && | ||
widget.decoration!.prefixText == '${locale.inputPrefixWeight}:' && | ||
widget.controller!.text == weight), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is TextField && | ||
widget.decoration!.prefixText == '${locale.inputPrefixHydration}:' && | ||
widget.controller!.text == hydration), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is TextField && | ||
widget.decoration!.prefixText == '${locale.inputPrefixSalt}:' && | ||
widget.controller!.text == saltLevel), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is Text && | ||
widget.semanticsLabel == locale.variableLabelFlour && | ||
widget.data == flour), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is Text && | ||
widget.semanticsLabel == locale.variableLabelWater && | ||
widget.data == water), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is Text && | ||
widget.semanticsLabel == locale.variableLabelLevain && | ||
widget.data == levain), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is Text && | ||
widget.semanticsLabel == locale.variableLabelSalt && | ||
widget.data == salt), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is Text && | ||
widget.semanticsLabel == locale.variableLabelInoculation && | ||
widget.data == inoculation), | ||
findsOneWidget); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is Text && | ||
widget.semanticsLabel == locale.variableLabelDoughRise && | ||
widget.data == rise), | ||
findsOneWidget); | ||
} | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('HomePage', () { | ||
testWidgets('should load initial default values', (tester) async { | ||
await tester.pumpWidget(const MaterialApp(home: HomePage())); | ||
await tester.pumpAndSettle(); | ||
|
||
expectCalculatorValues( | ||
temperatureUnit: 'ºC', | ||
temperature: '22', | ||
weight: '700', | ||
hydration: '70', | ||
saltLevel: '2', | ||
flour: '366.5g', | ||
water: '256.5g', | ||
levain: '69.6g', | ||
salt: '7.3g', | ||
inoculation: '19%', | ||
rise: '50%'); | ||
}); | ||
|
||
testWidgets('should switch to farenheit', (tester) async { | ||
await tester.pumpWidget(const MaterialApp(home: HomePage())); | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.tap(find.byTooltip(locale.degreesFarenheit)); | ||
await tester.pumpAndSettle(); | ||
|
||
expectCalculatorValues( | ||
temperatureUnit: 'ºF', | ||
temperature: '71.6', | ||
weight: '700', | ||
hydration: '70', | ||
saltLevel: '2', | ||
flour: '366.5g', | ||
water: '256.5g', | ||
levain: '69.6g', | ||
salt: '7.3g', | ||
inoculation: '19%', | ||
rise: '50%'); | ||
}); | ||
|
||
testWidgets('should update values based on ambient temperature', | ||
(tester) async { | ||
await tester.pumpWidget(const MaterialApp(home: HomePage())); | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.enterText( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is TextField && | ||
widget.decoration!.prefixText == | ||
'${locale.inputPrefixTemperature}:'), | ||
'80'); | ||
await tester.pumpAndSettle(); | ||
|
||
expectCalculatorValues( | ||
temperatureUnit: 'ºF', | ||
temperature: '80', | ||
weight: '700', | ||
hydration: '70', | ||
saltLevel: '2', | ||
flour: '375.7g', | ||
water: '263.0g', | ||
levain: '53.8g', | ||
salt: '7.5g', | ||
inoculation: '14%', | ||
rise: '25%'); | ||
}); | ||
|
||
testWidgets('should update values based on target bread weight', | ||
(tester) async { | ||
await tester.pumpWidget(const MaterialApp(home: HomePage())); | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.enterText( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is TextField && | ||
widget.decoration!.prefixText == '${locale.inputPrefixWeight}:'), | ||
'1350'); | ||
await tester.pumpAndSettle(); | ||
|
||
expectCalculatorValues( | ||
temperatureUnit: 'ºF', | ||
temperature: '80', | ||
weight: '1350', | ||
hydration: '70', | ||
saltLevel: '2', | ||
flour: '724.5g', | ||
water: '507.2g', | ||
levain: '103.8g', | ||
salt: '14.5g', | ||
inoculation: '14%', | ||
rise: '25%'); | ||
}); | ||
|
||
testWidgets('should update values based on hydration level', | ||
(tester) async { | ||
await tester.pumpWidget(const MaterialApp(home: HomePage())); | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.enterText( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is TextField && | ||
widget.decoration!.prefixText == | ||
'${locale.inputPrefixHydration}:'), | ||
'85'); | ||
await tester.pumpAndSettle(); | ||
|
||
expectCalculatorValues( | ||
temperatureUnit: 'ºF', | ||
temperature: '80', | ||
weight: '1350', | ||
hydration: '85', | ||
saltLevel: '2', | ||
flour: '670.5g', | ||
water: '570.0g', | ||
levain: '96.1g', | ||
salt: '13.4g', | ||
inoculation: '14%', | ||
rise: '25%'); | ||
}); | ||
|
||
testWidgets('should update values based on salt level', (tester) async { | ||
await tester.pumpWidget(const MaterialApp(home: HomePage())); | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.enterText( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is TextField && | ||
widget.decoration!.prefixText == '${locale.inputPrefixSalt}:'), | ||
'2.5'); | ||
await tester.pumpAndSettle(); | ||
|
||
expectCalculatorValues( | ||
temperatureUnit: 'ºF', | ||
temperature: '80', | ||
weight: '1350', | ||
hydration: '85', | ||
saltLevel: '2.5', | ||
flour: '668.9g', | ||
water: '568.5g', | ||
levain: '95.9g', | ||
salt: '16.7g', | ||
inoculation: '14%', | ||
rise: '25%'); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.