@@ -4,6 +4,7 @@ import 'package:checks/checks.dart';
4
4
import 'package:file_picker/file_picker.dart' ;
5
5
import 'package:flutter_checks/flutter_checks.dart' ;
6
6
import 'package:http/http.dart' as http;
7
+ import 'package:flutter/services.dart' ;
7
8
import 'package:flutter/material.dart' ;
8
9
import 'package:flutter_test/flutter_test.dart' ;
9
10
import 'package:image_picker/image_picker.dart' ;
@@ -330,6 +331,26 @@ void main() {
330
331
// [TextEditingController.selection]. Still, we expect no
331
332
// "typing started" request if the text remains the same.
332
333
});
334
+
335
+ testWidgets ('unfocusing app stops typing notification' , (tester) async {
336
+ Future <void > setAppLifeCycleState (AppLifecycleState state) async {
337
+ // While this state lives on [ServicesBinding], testWidgets resets it
338
+ // for us when the test ends:
339
+ // https://github.com/flutter/flutter/blob/c78c166e3ecf963ca29ed503e710fd3c71eda5c9/packages/flutter_test/lib/src/binding.dart#L1189
340
+ final ByteData ? message = const StringCodec ().encodeMessage (state.toString ());
341
+ await tester.binding.defaultBinaryMessenger
342
+ .handlePlatformMessage ('flutter/lifecycle' , message, (_) {});
343
+ }
344
+
345
+ await prepareComposeBox (tester, narrow: narrow, account: account);
346
+
347
+ await checkStartTyping (tester, narrow);
348
+
349
+ connection.prepare (json: {});
350
+ setAppLifeCycleState (AppLifecycleState .paused);
351
+ await tester.pump (Duration .zero);
352
+ checkTypingRequest (TypingOp .stop, narrow);
353
+ });
333
354
});
334
355
335
356
group ('message-send request response' , () {
0 commit comments