mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-05-11 18:50:42 +00:00
Compare commits
No commits in common. "4da29f4569efecf9fb429e6179136e66450a4b56" and "d2a21d0e68429e4a5f2a1fb9c9d2352eac824119" have entirely different histories.
4da29f4569
...
d2a21d0e68
2 changed files with 98 additions and 134 deletions
|
@ -2,7 +2,6 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
|
||||||
import 'package:lightmeter/data/models/ev_source_type.dart';
|
import 'package:lightmeter/data/models/ev_source_type.dart';
|
||||||
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
||||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||||
|
@ -54,115 +53,110 @@ void testE2E(String description) {
|
||||||
customFilms: {},
|
customFilms: {},
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
/// Create Praktica + Zenitar profile from scratch
|
||||||
/// Create Praktica + Zenitar profile from scratch
|
await tester.openSettings();
|
||||||
await tester.openSettings();
|
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
||||||
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
await tester.tap(find.byIcon(Icons.add_outlined).first);
|
||||||
await tester.tap(find.byIcon(Icons.add_outlined).first);
|
await tester.pumpAndSettle();
|
||||||
await tester.pumpAndSettle();
|
await tester.enterProfileName(mockEquipmentProfiles[0].name);
|
||||||
await tester.enterProfileName(mockEquipmentProfiles[0].name);
|
await tester.setIsoValues(mockEquipmentProfiles[0].isoValues);
|
||||||
await tester.setIsoValues(mockEquipmentProfiles[0].isoValues);
|
await tester.setNdValues(mockEquipmentProfiles[0].ndValues);
|
||||||
await tester.setNdValues(mockEquipmentProfiles[0].ndValues);
|
await tester.setApertureValues(mockEquipmentProfiles[0].apertureValues);
|
||||||
await tester.setApertureValues(mockEquipmentProfiles[0].apertureValues);
|
await tester.setShutterSpeedValues(mockEquipmentProfiles[0].shutterSpeedValues);
|
||||||
await tester.setShutterSpeedValues(mockEquipmentProfiles[0].shutterSpeedValues);
|
await tester.setZoomValue(mockEquipmentProfiles[0].lensZoom);
|
||||||
await tester.setZoomValue(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 - B'), findsOneWidget);
|
||||||
expect(find.text('1/1000 - B'), findsOneWidget);
|
await tester.saveEdits();
|
||||||
await tester.saveEdits();
|
|
||||||
|
|
||||||
/// Create Praktica + Jupiter profile from Zenitar profile
|
/// Create Praktica + Jupiter profile from Zenitar profile
|
||||||
await tester.tap(find.byIcon(Icons.edit_outlined));
|
await tester.tap(find.byIcon(Icons.edit_outlined));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.byIcon(Icons.copy_outlined).first);
|
await tester.tap(find.byIcon(Icons.copy_outlined).first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.enterProfileName(mockEquipmentProfiles[1].name);
|
await tester.enterProfileName(mockEquipmentProfiles[1].name);
|
||||||
await tester.setApertureValues(mockEquipmentProfiles[1].apertureValues);
|
await tester.setApertureValues(mockEquipmentProfiles[1].apertureValues);
|
||||||
await tester.setZoomValue(mockEquipmentProfiles[1].lensZoom);
|
await tester.setZoomValue(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 - B'), findsNWidgets(1));
|
expect(find.text('1/1000 - B'), findsNWidgets(1));
|
||||||
await tester.saveEdits();
|
await tester.saveEdits();
|
||||||
|
|
||||||
/// Verify that both profiles were added and leave to the main screen
|
/// Verify that both profiles were added and leave to the main screen
|
||||||
expect(find.text(mockEquipmentProfiles[0].name), findsOneWidget);
|
expect(find.text(mockEquipmentProfiles[0].name), findsOneWidget);
|
||||||
expect(find.text(mockEquipmentProfiles[1].name), findsOneWidget);
|
expect(find.text(mockEquipmentProfiles[1].name), findsOneWidget);
|
||||||
await tester.navigatorPop();
|
await tester.navigatorPop();
|
||||||
await tester.navigatorPop();
|
await tester.navigatorPop();
|
||||||
|
|
||||||
/// Select some initial settings according to the selected gear and film
|
/// Select some initial settings according to the selected gear and film
|
||||||
/// Then take a photo and verify, that exposure pairs range and EV matches the selected settings
|
/// Then take a photo and verify, that exposure pairs range and EV matches the selected settings
|
||||||
await tester.openPickerAndSelect<EquipmentProfilePicker, EquipmentProfile>(mockEquipmentProfiles[0].name);
|
await tester.openPickerAndSelect<EquipmentProfilePicker, EquipmentProfile>(mockEquipmentProfiles[0].name);
|
||||||
await tester.openPickerAndSelect<FilmPicker, Film>(mockFilms[0].name);
|
await tester.openPickerAndSelect<FilmPicker, Film>(mockFilms[0].name);
|
||||||
await tester.openPickerAndSelect<IsoValuePicker, IsoValue>('400');
|
await tester.openPickerAndSelect<IsoValuePicker, IsoValue>('400');
|
||||||
expectPickerTitle<EquipmentProfilePicker>(mockEquipmentProfiles[0].name);
|
expectPickerTitle<EquipmentProfilePicker>(mockEquipmentProfiles[0].name);
|
||||||
expectPickerTitle<FilmPicker>(mockFilms[0].name);
|
expectPickerTitle<FilmPicker>(mockFilms[0].name);
|
||||||
expectPickerTitle<IsoValuePicker>('400');
|
expectPickerTitle<IsoValuePicker>('400');
|
||||||
await tester.takePhoto();
|
await tester.takePhoto();
|
||||||
await _expectMeteringState(
|
await _expectMeteringState(
|
||||||
tester,
|
tester,
|
||||||
equipmentProfile: mockEquipmentProfiles[0],
|
equipmentProfile: mockEquipmentProfiles[0],
|
||||||
film: mockFilms[0],
|
film: mockFilms[0],
|
||||||
fastest: 'f/1.8 - 1/400',
|
fastest: 'f/1.8 - 1/400',
|
||||||
slowest: 'f/16 - 1/5',
|
slowest: 'f/16 - 1/5',
|
||||||
iso: '400',
|
iso: '400',
|
||||||
nd: 'None',
|
nd: 'None',
|
||||||
ev: mockPhotoEv100 + 2,
|
ev: mockPhotoEv100 + 2,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Add ND to shoot another scene
|
/// Add ND to shoot another scene
|
||||||
await tester.openPickerAndSelect<NdValuePicker, NdValue>('2');
|
await tester.openPickerAndSelect<NdValuePicker, NdValue>('2');
|
||||||
await _expectMeteringStateAndMeasure(
|
await _expectMeteringStateAndMeasure(
|
||||||
tester,
|
tester,
|
||||||
equipmentProfile: mockEquipmentProfiles[0],
|
equipmentProfile: mockEquipmentProfiles[0],
|
||||||
film: mockFilms[0],
|
film: mockFilms[0],
|
||||||
fastest: 'f/1.8 - 1/200',
|
fastest: 'f/1.8 - 1/200',
|
||||||
slowest: 'f/16 - 1/2.5',
|
slowest: 'f/16 - 1/2.5',
|
||||||
iso: '400',
|
iso: '400',
|
||||||
nd: '2',
|
nd: '2',
|
||||||
ev: mockPhotoEv100 + 2 - 1,
|
ev: mockPhotoEv100 + 2 - 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Select another lens without ND
|
/// Select another lens without ND
|
||||||
await tester.openPickerAndSelect<EquipmentProfilePicker, EquipmentProfile>(mockEquipmentProfiles[1].name);
|
await tester.openPickerAndSelect<EquipmentProfilePicker, EquipmentProfile>(mockEquipmentProfiles[1].name);
|
||||||
await tester.openPickerAndSelect<NdValuePicker, NdValue>('None');
|
await tester.openPickerAndSelect<NdValuePicker, NdValue>('None');
|
||||||
await _expectMeteringStateAndMeasure(
|
await _expectMeteringStateAndMeasure(
|
||||||
tester,
|
tester,
|
||||||
equipmentProfile: mockEquipmentProfiles[1],
|
equipmentProfile: mockEquipmentProfiles[1],
|
||||||
film: mockFilms[0],
|
film: mockFilms[0],
|
||||||
fastest: 'f/3.5 - 1/100',
|
fastest: 'f/3.5 - 1/100',
|
||||||
slowest: 'f/22 - 1/2.5',
|
slowest: 'f/22 - 1/2.5',
|
||||||
iso: '400',
|
iso: '400',
|
||||||
nd: 'None',
|
nd: 'None',
|
||||||
ev: mockPhotoEv100 + 2,
|
ev: mockPhotoEv100 + 2,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Set another film and another ISO
|
/// Set another film and another ISO
|
||||||
await tester.openPickerAndSelect<IsoValuePicker, IsoValue>('200');
|
await tester.openPickerAndSelect<IsoValuePicker, IsoValue>('200');
|
||||||
await tester.openPickerAndSelect<FilmPicker, Film>(mockFilms[1].name);
|
await tester.openPickerAndSelect<FilmPicker, Film>(mockFilms[1].name);
|
||||||
await _expectMeteringStateAndMeasure(
|
await _expectMeteringStateAndMeasure(
|
||||||
tester,
|
tester,
|
||||||
equipmentProfile: mockEquipmentProfiles[1],
|
equipmentProfile: mockEquipmentProfiles[1],
|
||||||
film: mockFilms[1],
|
film: mockFilms[1],
|
||||||
fastest: 'f/3.5 - 1/50',
|
fastest: 'f/3.5 - 1/50',
|
||||||
slowest: 'f/22 - 1/1.3',
|
slowest: 'f/22 - 1/1.3',
|
||||||
iso: '200',
|
iso: '200',
|
||||||
nd: 'None',
|
nd: 'None',
|
||||||
ev: mockPhotoEv100 + 1,
|
ev: mockPhotoEv100 + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Delete profile
|
/// Delete profile
|
||||||
await tester.openSettings();
|
await tester.openSettings();
|
||||||
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
||||||
await tester.tap(find.byIcon(Icons.edit_outlined).first);
|
await tester.tap(find.byIcon(Icons.edit_outlined).first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.deleteEdits();
|
await tester.deleteEdits();
|
||||||
expect(find.text(mockEquipmentProfiles[0].name), findsNothing);
|
expect(find.text(mockEquipmentProfiles[0].name), findsNothing);
|
||||||
expect(find.text(mockEquipmentProfiles[1].name), findsOneWidget);
|
expect(find.text(mockEquipmentProfiles[1].name), findsOneWidget);
|
||||||
} on TestFailure catch (_) {
|
|
||||||
await tester._takeScreenshot('screenshot_e2e');
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -355,10 +349,3 @@ void expectMeasureButton(double ev) {
|
||||||
matching: find.text('${ev.toStringAsFixed(1)}\n${S.current.ev}'),
|
matching: find.text('${ev.toStringAsFixed(1)}\n${S.current.ev}'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
extension on WidgetTester {
|
|
||||||
Future<void> _takeScreenshot(String name) async {
|
|
||||||
await IntegrationTestWidgetsFlutterBinding.instance.takeScreenshot(name);
|
|
||||||
await pumpAndSettle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,28 +1,5 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:integration_test/integration_test_driver_extended.dart';
|
import 'package:integration_test/integration_test_driver_extended.dart';
|
||||||
import 'package:uuid/v4.dart';
|
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
await integrationDriver(
|
await integrationDriver();
|
||||||
onScreenshot: (name, bytes, [_]) async {
|
|
||||||
final id = const UuidV4().generate();
|
|
||||||
final path = 'e2e_diagnostics/screenshot_$id.png';
|
|
||||||
final file = await File(path).create(recursive: true);
|
|
||||||
file.writeAsBytesSync(bytes);
|
|
||||||
|
|
||||||
final result = await Process.run(
|
|
||||||
"curl",
|
|
||||||
[
|
|
||||||
"-F",
|
|
||||||
'file=@${file.path}',
|
|
||||||
"https://shot.withfra.me/new",
|
|
||||||
],
|
|
||||||
);
|
|
||||||
stdout.write(result.stdout);
|
|
||||||
stderr.write(result.stderr);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue