diff --git a/test/model/binding.dart b/test/model/binding.dart index 11035efdbe..fce29028ac 100644 --- a/test/model/binding.dart +++ b/test/model/binding.dart @@ -192,7 +192,7 @@ class TestZulipBinding extends ZulipBinding { FakeFlutterLocalNotificationsPlugin? _notifPlugin; @override - FlutterLocalNotificationsPlugin get notif { + FakeFlutterLocalNotificationsPlugin get notif { return (_notifPlugin ??= FakeFlutterLocalNotificationsPlugin()); } } @@ -214,13 +214,6 @@ class FakeFlutterLocalNotificationsPlugin extends Fake implements FlutterLocalNo DidReceiveNotificationResponseCallback? onDidReceiveNotificationResponse; DidReceiveBackgroundNotificationResponseCallback? onDidReceiveBackgroundNotificationResponse; - FlutterLocalNotificationsPlatform? _platform; - - List<( - int id, String? title, String? body, - NotificationDetails? notificationDetails, {String? payload} - )> showCalls = []; - @override Future initialize( InitializationSettings initializationSettings, { @@ -234,6 +227,8 @@ class FakeFlutterLocalNotificationsPlugin extends Fake implements FlutterLocalNo return true; } + FlutterLocalNotificationsPlatform? _platform; + @override T? resolvePlatformSpecificImplementation() { // This follows the logic of the base class's implementation, @@ -260,14 +255,30 @@ class FakeFlutterLocalNotificationsPlugin extends Fake implements FlutterLocalNo } } + /// Consume the log of calls made to [show]. + /// + /// This returns a list of the arguments to all calls made + /// to [show] since the last call to this method. + List takeShowCalls() { + final result = _showCalls; + _showCalls = []; + return result; + } + List _showCalls = []; + @override Future show(int id, String? title, String? body, NotificationDetails? notificationDetails, {String? payload}) async { assert(initializationSettings != null); - showCalls.add((id, title, body, notificationDetails, payload: payload)); + _showCalls.add((id, title, body, notificationDetails, payload: payload)); } } +typedef FlutterLocalNotificationsPluginShowCall = ( + int id, String? title, String? body, + NotificationDetails? notificationDetails, {String? payload} +); + class FakeAndroidFlutterLocalNotificationsPlugin extends Fake implements AndroidFlutterLocalNotificationsPlugin { List createdChannels = [];