mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 00:10:47 +00:00
0c58134733
* removed redundant `UserPreferencesService` from `MeteringBloc` * wip * post-merge fixes * `MeasureEvent` tests * `MeasureEvent` tests revision * `MeasureEvent` tests added timeout * added stubs for other `MeteringBloc` events * rewritten `MeteringBloc` logic * wip * `IsoChangedEvent` tests * refined `IsoChangedEvent` tests * `NdChangedEvent` tests * `FilmChangedEvent` tests * `MeteringCommunicationBloc` tests * added test run to ci * overriden `==` for `MeasuredState` * `LuxMeteringEvent` tests * refined `LuxMeteringEvent` tests * rename * wip * wip * `InitializeEvent`/`DeinitializeEvent` tests * clamp minZoomLevel * fixed `MeteringCommunicationBloc` tests * wip * `ZoomChangedEvent` tests * `ExposureOffsetChangedEvent`/`ExposureOffsetResetEvent` tests * renamed test groups * added test coverage script * improved `CameraContainerBloc` test coverage * `EquipmentProfileChangedEvent` tests * verify response vibration * fixed running all tests * `MeteringCommunicationBloc` equality tests * `CameraContainerBloc` equality tests * removed generated code from coverage * `MeteringScreenLayoutFeature` tests * `SupportedLocale` tests * `Film` tests * `CaffeineService` tests * `UserPreferencesService` tests (wip) * `LightSensorService` tests (wip) * `migrateOldKeys()` tests * ignore currently unused getters & setters * gradle upgrade * `reset(sharedPreferences);` calls count * typo
76 lines
2.3 KiB
Dart
76 lines
2.3 KiB
Dart
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:lightmeter/data/caffeine_service.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
late CaffeineService service;
|
|
|
|
const methodChannel = MethodChannel('com.vodemn.lightmeter/keepScreenOn');
|
|
Future<Object?>? methodCallSuccessHandler(MethodCall methodCall) async {
|
|
switch (methodCall.method) {
|
|
case "isKeepScreenOn":
|
|
return true;
|
|
case "setKeepScreenOn":
|
|
return methodCall.arguments as bool;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
setUp(() {
|
|
service = const CaffeineService();
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(methodChannel, methodCallSuccessHandler);
|
|
});
|
|
|
|
tearDown(() {
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(methodChannel, null);
|
|
});
|
|
|
|
group(
|
|
'isKeepScreenOn()',
|
|
() {
|
|
test('true', () async {
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(methodChannel, null);
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(methodChannel, (methodCall) async {
|
|
switch (methodCall.method) {
|
|
case "isKeepScreenOn":
|
|
return true;
|
|
default:
|
|
return null;
|
|
}
|
|
});
|
|
expectLater(service.isKeepScreenOn(), completion(true));
|
|
});
|
|
|
|
test('false', () async {
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(methodChannel, null);
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(methodChannel, (methodCall) async {
|
|
switch (methodCall.method) {
|
|
case "isKeepScreenOn":
|
|
return false;
|
|
default:
|
|
return null;
|
|
}
|
|
});
|
|
expectLater(service.isKeepScreenOn(), completion(false));
|
|
});
|
|
},
|
|
);
|
|
|
|
group(
|
|
'keepScreenOn()',
|
|
() {
|
|
test('true', () async => expectLater(service.keepScreenOn(true), completion(true)));
|
|
|
|
test('false', () async => expectLater(service.keepScreenOn(false), completion(false)));
|
|
},
|
|
);
|
|
}
|