mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-05-13 11:40:42 +00:00
mock camera focal length for integration tests
This commit is contained in:
parent
10794258b8
commit
1a7f9165b9
4 changed files with 43 additions and 16 deletions
|
@ -64,7 +64,7 @@ void testE2E(String description) {
|
||||||
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('50mm'), 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();
|
||||||
|
@ -77,7 +77,7 @@ void testE2E(String description) {
|
||||||
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('135mm'), 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();
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
import 'e2e_test.dart';
|
import 'e2e_test.dart';
|
||||||
import 'metering_screen_layout_test.dart';
|
import 'metering_screen_layout_test.dart';
|
||||||
import 'purchases_test.dart';
|
import 'purchases_test.dart';
|
||||||
|
import 'utils/platform_channel_mock.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
setUpAll(() {
|
||||||
|
mockCameraFocalLength();
|
||||||
|
});
|
||||||
|
|
||||||
|
tearDownAll(() {
|
||||||
|
mockCameraFocalLength();
|
||||||
|
});
|
||||||
|
|
||||||
testPurchases('Purchase & refund premium features');
|
testPurchases('Purchase & refund premium features');
|
||||||
testToggleLayoutFeatures('Toggle metering screen layout features');
|
testToggleLayoutFeatures('Toggle metering screen layout features');
|
||||||
testE2E('e2e');
|
testE2E('e2e');
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:light_sensor/light_sensor.dart';
|
import 'package:light_sensor/light_sensor.dart';
|
||||||
|
import 'package:lightmeter/data/camera_info_service.dart';
|
||||||
|
|
||||||
void setLightSensorAvilability({required bool hasSensor}) {
|
void setLightSensorAvilability({required bool hasSensor}) {
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
|
@ -57,3 +59,26 @@ void resetLightSensorStreamHandler() {
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mockCameraFocalLength() {
|
||||||
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
|
CameraInfoService.cameraInfoPlatformChannel,
|
||||||
|
(methodCall) async {
|
||||||
|
switch (methodCall.method) {
|
||||||
|
case "mainCameraEfl":
|
||||||
|
return Platform.isAndroid
|
||||||
|
? 24.0 // Pixel 6
|
||||||
|
: 26.0; // iPhone 13 Pro
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetCameraFocalLength() {
|
||||||
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
|
CameraInfoService.cameraInfoPlatformChannel,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import 'dart:io';
|
||||||
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:integration_test/integration_test.dart';
|
||||||
import 'package:lightmeter/data/camera_info_service.dart';
|
|
||||||
import 'package:lightmeter/data/models/camera_feature.dart';
|
import 'package:lightmeter/data/models/camera_feature.dart';
|
||||||
import 'package:lightmeter/data/models/ev_source_type.dart';
|
import 'package:lightmeter/data/models/ev_source_type.dart';
|
||||||
import 'package:lightmeter/data/models/exposure_pair.dart';
|
import 'package:lightmeter/data/models/exposure_pair.dart';
|
||||||
|
@ -29,6 +28,7 @@ import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
import '../integration_test/mocks/paid_features_mock.dart';
|
import '../integration_test/mocks/paid_features_mock.dart';
|
||||||
|
import '../integration_test/utils/platform_channel_mock.dart';
|
||||||
import '../integration_test/utils/widget_tester_actions.dart';
|
import '../integration_test/utils/widget_tester_actions.dart';
|
||||||
import 'models/screenshot_args.dart';
|
import 'models/screenshot_args.dart';
|
||||||
|
|
||||||
|
@ -96,19 +96,11 @@ void main() {
|
||||||
|
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
if (Platform.isAndroid) await binding.convertFlutterSurfaceToImage();
|
if (Platform.isAndroid) await binding.convertFlutterSurfaceToImage();
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
mockCameraFocalLength();
|
||||||
CameraInfoService.cameraInfoPlatformChannel,
|
});
|
||||||
(methodCall) async {
|
|
||||||
switch (methodCall.method) {
|
tearDownAll(() {
|
||||||
case "mainCameraEfl":
|
resetCameraFocalLength();
|
||||||
return Platform.isAndroid
|
|
||||||
? 24.0 // Pixel 6
|
|
||||||
: 26.0; // iPhone 13 Pro
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Generates several screenshots with the light theme
|
/// Generates several screenshots with the light theme
|
||||||
|
|
Loading…
Reference in a new issue