From 63e3ac0f287664cfa4a40327a86fdb5b5e45d99c Mon Sep 17 00:00:00 2001 From: Michael Bui <25263378+MaikuB@users.noreply.github.com> Date: Sat, 1 Feb 2020 21:37:31 +1100 Subject: [PATCH] [flutter_local_notifications] format enums.dart and add testing related info (#465) * format enums.dart file * format enums.dart * add info related to FlutterLocalNotificationsPlugin.private() --- flutter_local_notifications/CHANGELOG.md | 7 +++++++ flutter_local_notifications/README.md | 2 +- .../lib/src/flutter_local_notifications_plugin.dart | 8 ++++++++ .../lib/src/platform_specifics/android/enums.dart | 11 ++++++++++- flutter_local_notifications/pubspec.yaml | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/flutter_local_notifications/CHANGELOG.md b/flutter_local_notifications/CHANGELOG.md index b0d36dae5..3c3153982 100644 --- a/flutter_local_notifications/CHANGELOG.md +++ b/flutter_local_notifications/CHANGELOG.md @@ -1,3 +1,9 @@ +# [1.1.5+1] +* No function changes. Fixed a reported formatting issue. +* Mention removal of named constructor argument in 1.1.0 changelog entry +* Add API docs to `FlutterLocalNotificationsPlugin.private()` on how it could be used for testing +* Update notes on testing to mention that the `FlutterLocalNotificationsPlugin.private()` named constructor may be of use + # [1.1.5] * [Android] minor optimisation on scheduling related code so that `Gson` instance is reused instead of being rebuilt each time * Changed plugin to require 1.12.3+hotfix.5 or greater since pub has issues resolving 1.12.3+hotfix.6 @@ -25,6 +31,7 @@ *Note*: this may have inadvertently broke some tests for users as the plugin now checks which platform the plugin is executing code on and would throw an `UnimplementedError` since neither iOS or Android can be detected. Another issue is that `NotificationAppLaunchDetails` was no longer exposed via the main plugin. Please upgrade to 1.1.3 to have both of these issues fixed * **BREAKING CHANGE** Plugin callbacks are no longer publicly accessible * **BREAKING CHANGE** [iOS] Local notifications that launched the app should now only be processed by the plugin if they were created by the plugin. +* **BREAKING CHANGE** `MethodChannel` argument has been removed from the named constructor that was visible for testing purposes # [1.0.0] * **BREAKING CHANGE** [iOS] Added checks to ensure callbacks are only invoked for notifications originating from the plugin to improve compatibility with other notification plugins. diff --git a/flutter_local_notifications/README.md b/flutter_local_notifications/README.md index d75283ef6..c3c1d7675 100644 --- a/flutter_local_notifications/README.md +++ b/flutter_local_notifications/README.md @@ -420,4 +420,4 @@ https://developer.apple.com/documentation/usernotifications/unnotificationsound? ## Testing -As the plugin class is not static, it is possible to mock and verify it's behaviour when writing tests as part of your application. Check the source code for a sample test suite can be found at _test/flutter_local_notifications_test.dart_ that demonstrates how this can be done. If you decide to use the plugin class directly as part of your tests, note that the methods will be mostly a no-op and methods that return data will return default values. Part of this is because the plugin detects if you're running on a supported plugin to determine which platform implementation of the plugin should be used. If it's neither Android or iOS, then it defaults to the aforementioned behaviour to reduce friction when writing tests. If this not desired then consider using mocks. +As the plugin class is not static, it is possible to mock and verify it's behaviour when writing tests as part of your application. Check the source code for a sample test suite can be found at _test/flutter_local_notifications_test.dart_ that demonstrates how this can be done. If you decide to use the plugin class directly as part of your tests, note that the methods will be mostly a no-op and methods that return data will return default values. Part of this is because the plugin detects if you're running on a supported plugin to determine which platform implementation of the plugin should be used. If it's neither Android or iOS, then it defaults to the aforementioned behaviour to reduce friction when writing tests. If this not desired then consider using mocks. Note there is also a [named constructor](https://pub.dev/documentation/flutter_local_notifications/latest/flutter_local_notifications/FlutterLocalNotificationsPlugin/FlutterLocalNotificationsPlugin.private.html) that can be used to pass the platform for the plugin to resolve the desired platform-specific implementation. diff --git a/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart b/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart index ed8583e80..169cda77d 100644 --- a/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart +++ b/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart @@ -15,6 +15,14 @@ import 'types.dart'; class FlutterLocalNotificationsPlugin { factory FlutterLocalNotificationsPlugin() => _instance; + /// Used internally for creating the appropriate platform-specific implementation of the plugin. + /// This can be used for tests as well. For example, the following code + /// + /// ``` + /// FlutterLocalNotificationsPlugin.private(FakePlatform(operatingSystem: 'android')) + /// ``` + /// + /// could be used in a test needs the plugin to use Android implementation @visibleForTesting FlutterLocalNotificationsPlugin.private(Platform platform) : _platform = platform { diff --git a/flutter_local_notifications/lib/src/platform_specifics/android/enums.dart b/flutter_local_notifications/lib/src/platform_specifics/android/enums.dart index 7f3e4d685..07ec6d7d8 100644 --- a/flutter_local_notifications/lib/src/platform_specifics/android/enums.dart +++ b/flutter_local_notifications/lib/src/platform_specifics/android/enums.dart @@ -5,7 +5,14 @@ enum BitmapSource { Drawable, FilePath } enum IconSource { Drawable, FilePath, ContentUri } /// The available notification styles on Android -enum AndroidNotificationStyle { Default, BigPicture, BigText, Inbox, Messaging, Media } +enum AndroidNotificationStyle { + Default, + BigPicture, + BigText, + Inbox, + Messaging, + Media +} /// The available actions for managing notification channels. /// [CreateIfNotExists]: will create a channel if it doesn't exist @@ -52,8 +59,10 @@ enum GroupAlertBehavior { All, Summary, Children } enum NotificationVisibility { /// Show this notification on all lockscreens, but conceal sensitive or private information on secure lockscreens. Private, + /// Show this notification in its entirety on all lockscreens. Public, + /// Do not reveal any part of this notification on a secure lockscreen. Secret, } diff --git a/flutter_local_notifications/pubspec.yaml b/flutter_local_notifications/pubspec.yaml index 31f0e651a..ebced1494 100644 --- a/flutter_local_notifications/pubspec.yaml +++ b/flutter_local_notifications/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_local_notifications description: A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform. -version: 1.1.5 +version: 1.1.5+1 homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications dependencies: