From da152dcd370a0497e5733ec3a7b1004805ca1ee5 Mon Sep 17 00:00:00 2001 From: Vadim Date: Sun, 9 Jul 2023 13:37:53 +0200 Subject: [PATCH] added `Stream.empty()` tests --- lib/data/light_sensor_service.dart | 7 ++++++- test/data/light_sensor_service_test.dart | 12 ++++++++++++ test/data/volume_events_service_test.dart | 14 +++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/data/light_sensor_service.dart b/lib/data/light_sensor_service.dart index 2fc94c5..c837dde 100644 --- a/lib/data/light_sensor_service.dart +++ b/lib/data/light_sensor_service.dart @@ -17,5 +17,10 @@ class LightSensorService { } } - Stream luxStream() => LightSensor.lightSensorStream; + Stream luxStream() { + if (!localPlatform.isAndroid) { + return const Stream.empty(); + } + return LightSensor.lightSensorStream; + } } diff --git a/test/data/light_sensor_service_test.dart b/test/data/light_sensor_service_test.dart index f30bf11..d29b50f 100644 --- a/test/data/light_sensor_service_test.dart +++ b/test/data/light_sensor_service_test.dart @@ -83,4 +83,16 @@ void main() { }); }, ); + + group('luxStream', () { + // test('Android', () async { + // when(() => localPlatform.isAndroid).thenReturn(true); + // expect(service.luxStream(), const Stream.empty()); + // }); + + test('iOS', () async { + when(() => localPlatform.isAndroid).thenReturn(false); + expect(service.luxStream(), const Stream.empty()); + }); + }); } diff --git a/test/data/volume_events_service_test.dart b/test/data/volume_events_service_test.dart index a6f5ae7..f9ef3d6 100644 --- a/test/data/volume_events_service_test.dart +++ b/test/data/volume_events_service_test.dart @@ -11,7 +11,7 @@ void main() { late _MockLocalPlatform localPlatform; late VolumeEventsService service; - + Future? methodCallSuccessHandler(MethodCall methodCall) async { switch (methodCall.method) { case "setVolumeHandling": @@ -58,4 +58,16 @@ void main() { expectLater(service.setVolumeHandling(false), completion(false)); }); }); + + group('volumeButtonsEventStream', () { + // test('Android', () async { + // when(() => localPlatform.isAndroid).thenReturn(true); + // expect(service.volumeButtonsEventStream(), const Stream.empty()); + // }); + + test('iOS', () async { + when(() => localPlatform.isAndroid).thenReturn(false); + expect(service.volumeButtonsEventStream(), const Stream.empty()); + }); + }); }