diff --git a/example/integration_test/main_test.dart b/example/integration_test/main_test.dart new file mode 100644 index 0000000..67a299e --- /dev/null +++ b/example/integration_test/main_test.dart @@ -0,0 +1,136 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_volume_controller/flutter_volume_controller.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:flutter/material.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + setUp(() { + runApp(const MaterialApp()); + }); + + testWidgets('should get volume', (tester) async { + final volume = await FlutterVolumeController.getVolume(); + expect(volume, isNotNull); + }); + + testWidgets('should set volume', (tester) async { + const List targets = [1.0, 0.0]; + + for (final target in targets) { + await FlutterVolumeController.setVolume(target); + await _insertDelay(); + + final actual = await FlutterVolumeController.getVolume(); + expect(actual, target); + } + }); + + testWidgets('should raise volume', (tester) async { + const before = 0.2; + + await FlutterVolumeController.setVolume(before); + await _insertDelay(); + + await FlutterVolumeController.raiseVolume(0.5); + await _insertDelay(); + + final actual = await FlutterVolumeController.getVolume(); + expect(actual, greaterThan(before)); + }); + + testWidgets('should lower volume', (tester) async { + const before = 0.8; + + await FlutterVolumeController.setVolume(before); + await _insertDelay(); + + await FlutterVolumeController.lowerVolume(0.5); + await _insertDelay(); + + final actual = await FlutterVolumeController.getVolume(); + expect(actual, lessThan(before)); + }); + + testWidgets('should get mute', (tester) async { + final isMuted = await FlutterVolumeController.getMute(); + expect(isMuted, isNotNull); + }); + + testWidgets('should set mute', (tester) async { + const List targets = [true, false]; + + for (final target in targets) { + await FlutterVolumeController.setMute(target); + await _insertDelay(); + + final actual = await FlutterVolumeController.getMute(); + expect(actual, target); + } + }); + + testWidgets('should toggle mute', (tester) async { + const target = true; + + await FlutterVolumeController.setMute(!target); + await _insertDelay(); + + await FlutterVolumeController.toggleMute(); + await _insertDelay(); + + final actual = await FlutterVolumeController.getMute(); + expect(actual, target); + }); + + /// TODO: add test for [FlutterVolumeController.setAndroidAudioStream]. + + /// TODO: add test for [FlutterVolumeController.setIOSAudioSessionCategory]. + + testWidgets('should receive volume event after adding listener', + (tester) async { + final List targets = [0.0, 1.0, 0.0, 1.0, 0.0]; + final List actual = []; + + await FlutterVolumeController.setVolume(targets[0]); + await _insertDelay(); + + FlutterVolumeController.addListener(actual.add); + + for (final target in targets) { + await FlutterVolumeController.setVolume(target); + await _insertDelay(); + } + + expect(actual, targets); + }); + + testWidgets('should receive no new volume event after removing listener', + (tester) async { + final List targets = [0.0, 1.0, 0.0]; + final List actual = []; + + await FlutterVolumeController.setVolume(targets[0]); + await _insertDelay(); + + FlutterVolumeController.addListener(actual.add); + + for (final target in targets) { + await FlutterVolumeController.setVolume(target); + await _insertDelay(); + } + + expect(actual, targets); + + FlutterVolumeController.removeListener(); + + await FlutterVolumeController.setVolume(1.0); + await _insertDelay(); + + expect(actual, targets); + }); +} + +Future _insertDelay() async { + await Future.delayed(const Duration(milliseconds: 50)); +} diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 3ea5c2e..5ce0006 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2,20 +2,26 @@ PODS: - Flutter (1.0.0) - flutter_volume_controller (0.0.1): - Flutter + - integration_test (0.0.1): + - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`) + - integration_test (from `.symlinks/plugins/integration_test/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter flutter_volume_controller: :path: ".symlinks/plugins/flutter_volume_controller/ios" + integration_test: + :path: ".symlinks/plugins/integration_test/ios" SPEC CHECKSUMS: Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_volume_controller: e4d5832f08008180f76e30faf671ffd5a425e529 + integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5 PODFILE CHECKSUM: ec7bdfce9f82e8314b94d9cd1cfee2974a0e1c97 diff --git a/example/macos/Podfile b/example/macos/Podfile index dade8df..049abe2 100644 --- a/example/macos/Podfile +++ b/example/macos/Podfile @@ -1,4 +1,4 @@ -platform :osx, '10.11' +platform :osx, '10.14' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index bdef080..d75c6d7 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -15,8 +15,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: flutter_volume_controller: 25d09126b0d695560f11c80b1311d5063fed882f - FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 + FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 -PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c +PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 -COCOAPODS: 1.11.3 +COCOAPODS: 1.11.2 diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index dcc5f92..d50b7af 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -273,6 +273,7 @@ }; 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -404,7 +405,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -483,7 +484,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -530,7 +531,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/example/pubspec.lock b/example/pubspec.lock index 518f65a..b9876ef 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + sha256: "80e5141fafcb3361653ce308776cfd7d45e6e9fbb429e14eec571382c0c5fecb" + url: "https://pub.dev" + source: hosted + version: "3.3.2" async: dependency: transitive description: @@ -41,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.0" + crypto: + dependency: transitive + description: + name: crypto + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" + source: hosted + version: "3.0.2" cupertino_icons: dependency: "direct main" description: @@ -57,11 +73,24 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_lints: dependency: "direct dev" description: @@ -90,6 +119,16 @@ packages: relative: true source: path version: "1.2.3" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" js: dependency: transitive description: @@ -138,6 +177,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.2" + platform: + dependency: transitive + description: + name: platform + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" sky_engine: dependency: transitive description: flutter @@ -175,6 +230,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + sync_http: + dependency: transitive + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.dev" + source: hosted + version: "0.3.1" term_glyph: dependency: transitive description: @@ -191,6 +254,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.16" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" + source: hosted + version: "1.3.1" vector_math: dependency: transitive description: @@ -199,6 +270,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: e7fb6c2282f7631712b69c19d1bff82f3767eea33a2321c14fa59ad67ea391c7 + url: "https://pub.dev" + source: hosted + version: "9.4.0" + webdriver: + dependency: transitive + description: + name: webdriver + sha256: ef67178f0cc7e32c1494645b11639dd1335f1d18814aa8435113a92e9ef9d841 + url: "https://pub.dev" + source: hosted + version: "3.0.1" sdks: dart: ">=2.18.0 <3.0.0" flutter: ">=2.8.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9a8a94d..e4dabc6 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -35,6 +35,9 @@ dev_dependencies: flutter_test: sdk: flutter + integration_test: + sdk: flutter + # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your