Compare commits
1 commit
450b613a99
...
852e74f8cf
Author | SHA1 | Date | |
---|---|---|---|
![]() |
852e74f8cf |
|
@ -64,7 +64,7 @@ void testE2E(String description) {
|
|||
await tester.setApertureValues(mockEquipmentProfiles[0].apertureValues);
|
||||
await tester.setShutterSpeedValues(mockEquipmentProfiles[0].shutterSpeedValues);
|
||||
await tester.setZoomValue(mockEquipmentProfiles[0].lensZoom);
|
||||
expect(find.text('50mm'), findsOneWidget);
|
||||
expect(find.text('x1.91'), findsOneWidget);
|
||||
expect(find.text('f/1.7 - f/16'), findsOneWidget);
|
||||
expect(find.text('1/1000 - B'), findsOneWidget);
|
||||
await tester.saveEdits();
|
||||
|
@ -77,7 +77,7 @@ void testE2E(String description) {
|
|||
await tester.enterProfileName(mockEquipmentProfiles[1].name);
|
||||
await tester.setApertureValues(mockEquipmentProfiles[1].apertureValues);
|
||||
await tester.setZoomValue(mockEquipmentProfiles[1].lensZoom);
|
||||
expect(find.text('135mm'), findsOneWidget);
|
||||
expect(find.text('x5.02'), findsOneWidget);
|
||||
expect(find.text('f/3.5 - f/22'), findsOneWidget);
|
||||
expect(find.text('1/1000 - B'), findsNWidgets(1));
|
||||
await tester.saveEdits();
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import 'e2e_test.dart';
|
||||
import 'metering_screen_layout_test.dart';
|
||||
import 'purchases_test.dart';
|
||||
import 'utils/platform_channel_mock.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUpAll(() {
|
||||
mockCameraFocalLength();
|
||||
});
|
||||
|
||||
tearDownAll(() {
|
||||
mockCameraFocalLength();
|
||||
});
|
||||
|
||||
testPurchases('Purchase & refund premium features');
|
||||
testToggleLayoutFeatures('Toggle metering screen layout features');
|
||||
testE2E('e2e');
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:light_sensor/light_sensor.dart';
|
||||
import 'package:lightmeter/data/camera_info_service.dart';
|
||||
|
||||
void setLightSensorAvilability({required bool hasSensor}) {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
|
@ -59,26 +57,3 @@ void resetLightSensorStreamHandler() {
|
|||
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,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ class CameraInfoService {
|
|||
|
||||
const CameraInfoService();
|
||||
|
||||
// TODO: fix focal length for iOS screenshots
|
||||
// TODO: fix integration test (find 1.91x)
|
||||
Future<int?> mainCameraEfl() async {
|
||||
final focalLength = await cameraInfoPlatformChannel.invokeMethod<double?>('mainCameraEfl');
|
||||
return focalLength?.round();
|
||||
|
|
|
@ -7,20 +7,8 @@ enum CameraFeature {
|
|||
typedef CameraFeaturesConfig = Map<CameraFeature, bool>;
|
||||
|
||||
extension CameraFeaturesConfigJson on CameraFeaturesConfig {
|
||||
static CameraFeaturesConfig fromJson(Map<String, dynamic> data) {
|
||||
MapEntry<CameraFeature, bool> valueOrBool(CameraFeature feature, {bool defaultValue = true}) => MapEntry(
|
||||
feature,
|
||||
data[feature.name] as bool? ?? defaultValue,
|
||||
);
|
||||
|
||||
return Map.fromEntries(
|
||||
[
|
||||
valueOrBool(CameraFeature.spotMetering),
|
||||
valueOrBool(CameraFeature.histogram, defaultValue: false),
|
||||
valueOrBool(CameraFeature.showFocalLength),
|
||||
],
|
||||
);
|
||||
}
|
||||
static CameraFeaturesConfig fromJson(Map<String, dynamic> data) =>
|
||||
<CameraFeature, bool>{for (final f in CameraFeature.values) f: data[f.name] as bool? ?? false};
|
||||
|
||||
Map<String, dynamic> toJson() => map((key, value) => MapEntry(key.name, value));
|
||||
}
|
||||
|
|
|
@ -94,16 +94,34 @@ class UserPreferencesService {
|
|||
set showEv100(bool value) => _sharedPreferences.setBool(showEv100Key, value);
|
||||
|
||||
MeteringScreenLayoutConfig get meteringScreenLayout {
|
||||
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey) ?? '{}';
|
||||
return MeteringScreenLayoutConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
||||
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey);
|
||||
if (configJson != null) {
|
||||
return MeteringScreenLayoutConfigJson.fromJson(
|
||||
json.decode(configJson) as Map<String, dynamic>,
|
||||
);
|
||||
} else {
|
||||
return {
|
||||
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
||||
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
||||
MeteringScreenLayoutFeature.filmPicker: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
set meteringScreenLayout(MeteringScreenLayoutConfig value) =>
|
||||
_sharedPreferences.setString(meteringScreenLayoutKey, json.encode(value.toJson()));
|
||||
|
||||
CameraFeaturesConfig get cameraFeatures {
|
||||
final configJson = _sharedPreferences.getString(cameraFeaturesKey) ?? '{}';
|
||||
return CameraFeaturesConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
||||
final configJson = _sharedPreferences.getString(cameraFeaturesKey);
|
||||
if (configJson != null) {
|
||||
return CameraFeaturesConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
||||
} else {
|
||||
return {
|
||||
CameraFeature.spotMetering: false,
|
||||
CameraFeature.histogram: false,
|
||||
CameraFeature.showFocalLength: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
set cameraFeatures(CameraFeaturesConfig value) =>
|
||||
|
|
|
@ -75,4 +75,6 @@ class MeteringInteractor {
|
|||
Future<bool> hasAmbientLightSensor() async => _lightSensorService.hasSensor();
|
||||
|
||||
Stream<int> luxStream() => _lightSensorService.luxStream();
|
||||
|
||||
void setCameraFocalLength(int focalLength) => _userPreferencesService.cameraFocalLength = focalLength;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_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/ev_source_type.dart';
|
||||
import 'package:lightmeter/data/models/exposure_pair.dart';
|
||||
|
@ -28,7 +29,6 @@ import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
|||
import 'package:shared_preferences/shared_preferences.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 'models/screenshot_args.dart';
|
||||
|
||||
|
@ -96,11 +96,19 @@ void main() {
|
|||
|
||||
setUpAll(() async {
|
||||
if (Platform.isAndroid) await binding.convertFlutterSurfaceToImage();
|
||||
mockCameraFocalLength();
|
||||
});
|
||||
|
||||
tearDownAll(() {
|
||||
resetCameraFocalLength();
|
||||
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;
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
/// Generates several screenshots with the light theme
|
||||
|
|
Before Width: | Height: | Size: 348 KiB After Width: | Height: | Size: 348 KiB |
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 159 KiB |
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 181 KiB |
Before Width: | Height: | Size: 347 KiB After Width: | Height: | Size: 347 KiB |
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 169 KiB |
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 148 KiB |
Before Width: | Height: | Size: 511 KiB After Width: | Height: | Size: 511 KiB |
Before Width: | Height: | Size: 224 KiB After Width: | Height: | Size: 224 KiB |
Before Width: | Height: | Size: 253 KiB After Width: | Height: | Size: 254 KiB |
Before Width: | Height: | Size: 504 KiB After Width: | Height: | Size: 505 KiB |
Before Width: | Height: | Size: 239 KiB After Width: | Height: | Size: 238 KiB |
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 207 KiB |
|
@ -22,13 +22,13 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('Legacy', () {
|
||||
test('Legacy (no spotMetering & histogram)', () {
|
||||
expect(
|
||||
CameraFeaturesConfigJson.fromJson({}),
|
||||
{
|
||||
CameraFeature.spotMetering: true,
|
||||
CameraFeature.spotMetering: false,
|
||||
CameraFeature.histogram: false,
|
||||
CameraFeature.showFocalLength: true,
|
||||
CameraFeature.showFocalLength: false,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@ -40,12 +40,10 @@ void main() {
|
|||
{
|
||||
CameraFeature.spotMetering: true,
|
||||
CameraFeature.histogram: true,
|
||||
CameraFeature.showFocalLength: true,
|
||||
}.toJson(),
|
||||
{
|
||||
'spotMetering': true,
|
||||
'histogram': true,
|
||||
'showFocalLength': true,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -270,9 +270,9 @@ void main() {
|
|||
expect(
|
||||
service.cameraFeatures,
|
||||
{
|
||||
CameraFeature.spotMetering: true,
|
||||
CameraFeature.spotMetering: false,
|
||||
CameraFeature.histogram: false,
|
||||
CameraFeature.showFocalLength: true,
|
||||
CameraFeature.showFocalLength: false,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@ -285,7 +285,7 @@ void main() {
|
|||
{
|
||||
CameraFeature.spotMetering: false,
|
||||
CameraFeature.histogram: true,
|
||||
CameraFeature.showFocalLength: true,
|
||||
CameraFeature.showFocalLength: false,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|