mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 15:00:40 +00:00
fixed integration tests
This commit is contained in:
parent
c7af27e7cf
commit
8b9a3f660b
5 changed files with 22 additions and 15 deletions
|
@ -44,7 +44,7 @@ void testE2E(String description) {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
description,
|
description,
|
||||||
(tester) async {
|
(tester) async {
|
||||||
await tester.pumpApplication(equipmentProfiles: [], films: []);
|
await tester.pumpApplication(equipmentProfiles: [], filmsInUse: []);
|
||||||
|
|
||||||
/// Create Praktica + Zenitar profile from scratch
|
/// Create Praktica + Zenitar profile from scratch
|
||||||
await tester.openSettings();
|
await tester.openSettings();
|
||||||
|
@ -60,7 +60,7 @@ void testE2E(String description) {
|
||||||
await tester.setZoomValue(0, mockEquipmentProfiles[0].lensZoom);
|
await tester.setZoomValue(0, mockEquipmentProfiles[0].lensZoom);
|
||||||
expect(find.text('x1.91'), findsOneWidget);
|
expect(find.text('x1.91'), findsOneWidget);
|
||||||
expect(find.text('f/1.7 - f/16'), findsOneWidget);
|
expect(find.text('f/1.7 - f/16'), findsOneWidget);
|
||||||
expect(find.text('1/1000 - 16"'), findsOneWidget);
|
expect(find.text('1/1000 - B'), findsOneWidget);
|
||||||
|
|
||||||
/// Create Praktica + Jupiter profile from Zenitar profile
|
/// Create Praktica + Jupiter profile from Zenitar profile
|
||||||
await tester.tap(find.byIcon(Icons.copy).first);
|
await tester.tap(find.byIcon(Icons.copy).first);
|
||||||
|
@ -71,7 +71,7 @@ void testE2E(String description) {
|
||||||
await tester.setZoomValue(1, mockEquipmentProfiles[1].lensZoom);
|
await tester.setZoomValue(1, mockEquipmentProfiles[1].lensZoom);
|
||||||
expect(find.text('x5.02'), findsOneWidget);
|
expect(find.text('x5.02'), findsOneWidget);
|
||||||
expect(find.text('f/3.5 - f/22'), findsOneWidget);
|
expect(find.text('f/3.5 - f/22'), findsOneWidget);
|
||||||
expect(find.text('1/1000 - 16"'), findsNWidgets(2));
|
expect(find.text('1/1000 - B'), findsNWidgets(2));
|
||||||
await tester.navigatorPop();
|
await tester.navigatorPop();
|
||||||
|
|
||||||
/// Select some films
|
/// Select some films
|
||||||
|
|
|
@ -10,18 +10,21 @@ class _MockIAPStorageService extends Mock implements IAPStorageService {}
|
||||||
class MockIAPProviders extends StatefulWidget {
|
class MockIAPProviders extends StatefulWidget {
|
||||||
final List<EquipmentProfile>? equipmentProfiles;
|
final List<EquipmentProfile>? equipmentProfiles;
|
||||||
final String selectedEquipmentProfileId;
|
final String selectedEquipmentProfileId;
|
||||||
final List<Film>? films;
|
final List<Film> availableFilms;
|
||||||
|
final List<Film> filmsInUse;
|
||||||
final Film selectedFilm;
|
final Film selectedFilm;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
const MockIAPProviders({
|
const MockIAPProviders({
|
||||||
this.equipmentProfiles = const [],
|
this.equipmentProfiles = const [],
|
||||||
this.selectedEquipmentProfileId = '',
|
this.selectedEquipmentProfileId = '',
|
||||||
this.films = mockFilms,
|
List<Film>? availableFilms,
|
||||||
|
List<Film>? filmsInUse,
|
||||||
this.selectedFilm = const Film.other(),
|
this.selectedFilm = const Film.other(),
|
||||||
required this.child,
|
required this.child,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
}) : availableFilms = availableFilms ?? mockFilms,
|
||||||
|
filmsInUse = filmsInUse ?? mockFilms;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MockIAPProviders> createState() => _MockIAPProvidersState();
|
State<MockIAPProviders> createState() => _MockIAPProvidersState();
|
||||||
|
@ -36,7 +39,7 @@ class _MockIAPProvidersState extends State<MockIAPProviders> {
|
||||||
mockIAPStorageService = _MockIAPStorageService();
|
mockIAPStorageService = _MockIAPStorageService();
|
||||||
when(() => mockIAPStorageService.equipmentProfiles).thenReturn(widget.equipmentProfiles ?? mockEquipmentProfiles);
|
when(() => mockIAPStorageService.equipmentProfiles).thenReturn(widget.equipmentProfiles ?? mockEquipmentProfiles);
|
||||||
when(() => mockIAPStorageService.selectedEquipmentProfileId).thenReturn(widget.selectedEquipmentProfileId);
|
when(() => mockIAPStorageService.selectedEquipmentProfileId).thenReturn(widget.selectedEquipmentProfileId);
|
||||||
when(() => mockIAPStorageService.filmsInUse).thenReturn(widget.films ?? mockFilms);
|
when(() => mockIAPStorageService.filmsInUse).thenReturn(widget.filmsInUse);
|
||||||
when(() => mockIAPStorageService.selectedFilm).thenReturn(widget.selectedFilm);
|
when(() => mockIAPStorageService.selectedFilm).thenReturn(widget.selectedFilm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +49,7 @@ class _MockIAPProvidersState extends State<MockIAPProviders> {
|
||||||
storageService: mockIAPStorageService,
|
storageService: mockIAPStorageService,
|
||||||
child: FilmsProvider(
|
child: FilmsProvider(
|
||||||
storageService: mockIAPStorageService,
|
storageService: mockIAPStorageService,
|
||||||
availableFilms: widget.films ?? mockFilms,
|
availableFilms: widget.availableFilms,
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -78,7 +81,7 @@ final mockEquipmentProfiles = [
|
||||||
],
|
],
|
||||||
shutterSpeedValues: ShutterSpeedValue.values.sublist(
|
shutterSpeedValues: ShutterSpeedValue.values.sublist(
|
||||||
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)),
|
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)),
|
||||||
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(16, false, StopType.full)) + 1,
|
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1, false, StopType.full)) + 1,
|
||||||
),
|
),
|
||||||
isoValues: const [
|
isoValues: const [
|
||||||
IsoValue(50, StopType.full),
|
IsoValue(50, StopType.full),
|
||||||
|
@ -108,7 +111,7 @@ final mockEquipmentProfiles = [
|
||||||
],
|
],
|
||||||
shutterSpeedValues: ShutterSpeedValue.values.sublist(
|
shutterSpeedValues: ShutterSpeedValue.values.sublist(
|
||||||
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)),
|
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)),
|
||||||
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(16, false, StopType.full)) + 1,
|
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1, false, StopType.full)) + 1,
|
||||||
),
|
),
|
||||||
isoValues: const [
|
isoValues: const [
|
||||||
IsoValue(50, StopType.full),
|
IsoValue(50, StopType.full),
|
||||||
|
|
|
@ -22,7 +22,8 @@ extension WidgetTesterCommonActions on WidgetTester {
|
||||||
IAPProductStatus productStatus = IAPProductStatus.purchased,
|
IAPProductStatus productStatus = IAPProductStatus.purchased,
|
||||||
List<EquipmentProfile>? equipmentProfiles,
|
List<EquipmentProfile>? equipmentProfiles,
|
||||||
String selectedEquipmentProfileId = '',
|
String selectedEquipmentProfileId = '',
|
||||||
List<Film>? films,
|
List<Film>? availableFilms,
|
||||||
|
List<Film>? filmsInUse,
|
||||||
Film selectedFilm = const Film.other(),
|
Film selectedFilm = const Film.other(),
|
||||||
}) async {
|
}) async {
|
||||||
await pumpWidget(
|
await pumpWidget(
|
||||||
|
@ -33,7 +34,8 @@ extension WidgetTesterCommonActions on WidgetTester {
|
||||||
child: MockIAPProviders(
|
child: MockIAPProviders(
|
||||||
equipmentProfiles: equipmentProfiles,
|
equipmentProfiles: equipmentProfiles,
|
||||||
selectedEquipmentProfileId: selectedEquipmentProfileId,
|
selectedEquipmentProfileId: selectedEquipmentProfileId,
|
||||||
films: films,
|
availableFilms: availableFilms,
|
||||||
|
filmsInUse: filmsInUse,
|
||||||
selectedFilm: selectedFilm,
|
selectedFilm: selectedFilm,
|
||||||
child: const Application(),
|
child: const Application(),
|
||||||
),
|
),
|
||||||
|
|
|
@ -72,7 +72,8 @@ void main() {
|
||||||
testWidgets('Generate light theme screenshots', (tester) async {
|
testWidgets('Generate light theme screenshots', (tester) async {
|
||||||
mockSharedPrefs(ThemeType.light, lightThemeColor);
|
mockSharedPrefs(ThemeType.light, lightThemeColor);
|
||||||
await tester.pumpApplication(
|
await tester.pumpApplication(
|
||||||
films: [_mockFilm],
|
availableFilms: [_mockFilm],
|
||||||
|
filmsInUse: [_mockFilm],
|
||||||
selectedFilm: _mockFilm,
|
selectedFilm: _mockFilm,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -115,7 +116,8 @@ void main() {
|
||||||
(tester) async {
|
(tester) async {
|
||||||
mockSharedPrefs(ThemeType.dark, darkThemeColor);
|
mockSharedPrefs(ThemeType.dark, darkThemeColor);
|
||||||
await tester.pumpApplication(
|
await tester.pumpApplication(
|
||||||
films: [_mockFilm],
|
availableFilms: [_mockFilm],
|
||||||
|
filmsInUse: [_mockFilm],
|
||||||
selectedFilm: _mockFilm,
|
selectedFilm: _mockFilm,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ class _GoldenTestApplicationMockState extends State<GoldenTestApplicationMock> {
|
||||||
child: MockIAPProviders(
|
child: MockIAPProviders(
|
||||||
equipmentProfiles: mockEquipmentProfiles,
|
equipmentProfiles: mockEquipmentProfiles,
|
||||||
selectedEquipmentProfileId: mockEquipmentProfiles.first.id,
|
selectedEquipmentProfileId: mockEquipmentProfiles.first.id,
|
||||||
films: films,
|
selectedFilm: mockFilms.first,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
|
Loading…
Reference in a new issue