Skip to content

Commit

Permalink
[flutter_local_notifications] format enums.dart and add testing relat…
Browse files Browse the repository at this point in the history
…ed info (#465)

* format enums.dart file

* format enums.dart

* add info related to FlutterLocalNotificationsPlugin.private()
  • Loading branch information
MaikuB authored Feb 1, 2020
1 parent af67dec commit 63e3ac0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
7 changes: 7 additions & 0 deletions flutter_local_notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion flutter_local_notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
2 changes: 1 addition & 1 deletion flutter_local_notifications/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 63e3ac0

Please sign in to comment.