forked from Rexios80/packages_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_tests.dart
810 lines (677 loc) · 26.4 KB
/
core_tests.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:pigeon/pigeon.dart';
enum AnEnum {
one,
two,
three,
fortyTwo,
fourHundredTwentyTwo,
}
/// A class containing all supported types.
class AllTypes {
AllTypes({
this.aBool = false,
this.anInt = 0,
this.anInt64 = 0,
this.aDouble = 0,
required this.aByteArray,
required this.a4ByteArray,
required this.a8ByteArray,
required this.aFloatArray,
this.list = const <Object?>[],
this.aMap = const <String?, Object?>{},
this.anEnum = AnEnum.one,
this.aString = '',
this.anObject = 0,
});
bool aBool;
int anInt;
int anInt64;
double aDouble;
Uint8List aByteArray;
Int32List a4ByteArray;
Int64List a8ByteArray;
Float64List aFloatArray;
// This name is in a different format than the others to ensure that name
// collision with the work 'list' doesn't occur in the generated files.
// ignore: always_specify_types, strict_raw_type
List list;
// ignore: always_specify_types, strict_raw_type
Map aMap;
AnEnum anEnum;
String aString;
Object anObject;
}
/// A class containing all supported nullable types.
@SwiftClass()
class AllNullableTypes {
AllNullableTypes(
this.aNullableBool,
this.aNullableInt,
this.aNullableInt64,
this.aNullableDouble,
this.aNullableByteArray,
this.aNullable4ByteArray,
this.aNullable8ByteArray,
this.aNullableFloatArray,
this.aNullableList,
this.aNullableMap,
this.nullableNestedList,
this.nullableMapWithAnnotations,
this.nullableMapWithObject,
this.aNullableEnum,
this.aNullableString,
this.aNullableObject,
this.allNullableTypes,
);
bool? aNullableBool;
int? aNullableInt;
int? aNullableInt64;
double? aNullableDouble;
Uint8List? aNullableByteArray;
Int32List? aNullable4ByteArray;
Int64List? aNullable8ByteArray;
Float64List? aNullableFloatArray;
// ignore: always_specify_types, strict_raw_type
List? aNullableList;
// ignore: always_specify_types, strict_raw_type
Map? aNullableMap;
List<List<bool?>?>? nullableNestedList;
Map<String?, String?>? nullableMapWithAnnotations;
Map<String?, Object?>? nullableMapWithObject;
AnEnum? aNullableEnum;
String? aNullableString;
Object? aNullableObject;
AllNullableTypes? allNullableTypes;
}
/// The primary purpose for this class is to ensure coverage of Swift structs
/// with nullable items, as the primary [AllNullableTypes] class is being used to
/// test Swift classes.
class AllNullableTypesWithoutRecursion {
AllNullableTypesWithoutRecursion(
this.aNullableBool,
this.aNullableInt,
this.aNullableInt64,
this.aNullableDouble,
this.aNullableByteArray,
this.aNullable4ByteArray,
this.aNullable8ByteArray,
this.aNullableFloatArray,
this.aNullableList,
this.aNullableMap,
this.nullableNestedList,
this.nullableMapWithAnnotations,
this.nullableMapWithObject,
this.aNullableEnum,
this.aNullableString,
this.aNullableObject,
);
bool? aNullableBool;
int? aNullableInt;
int? aNullableInt64;
double? aNullableDouble;
Uint8List? aNullableByteArray;
Int32List? aNullable4ByteArray;
Int64List? aNullable8ByteArray;
Float64List? aNullableFloatArray;
// ignore: always_specify_types, strict_raw_type
List? aNullableList;
// ignore: always_specify_types, strict_raw_type
Map? aNullableMap;
List<List<bool?>?>? nullableNestedList;
Map<String?, String?>? nullableMapWithAnnotations;
Map<String?, Object?>? nullableMapWithObject;
AnEnum? aNullableEnum;
String? aNullableString;
Object? aNullableObject;
}
/// A class for testing nested class handling.
///
/// This is needed to test nested nullable and non-nullable classes,
/// `AllNullableTypes` is non-nullable here as it is easier to instantiate
/// than `AllTypes` when testing doesn't require both (ie. testing null classes).
class AllClassesWrapper {
AllClassesWrapper(this.allNullableTypes,
this.allNullableTypesWithoutRecursion, this.allTypes);
AllNullableTypes allNullableTypes;
AllNullableTypesWithoutRecursion? allNullableTypesWithoutRecursion;
AllTypes? allTypes;
}
/// The core interface that each host language plugin must implement in
/// platform_test integration tests.
@HostApi()
abstract class HostIntegrationCoreApi {
// ========== Synchronous method tests ==========
/// A no-op function taking no arguments and returning no value, to sanity
/// test basic calling.
void noop();
/// Returns the passed object, to test serialization and deserialization.
@ObjCSelector('echoAllTypes:')
@SwiftFunction('echo(_:)')
AllTypes echoAllTypes(AllTypes everything);
/// Returns an error, to test error handling.
Object? throwError();
/// Returns an error from a void function, to test error handling.
void throwErrorFromVoid();
/// Returns a Flutter error, to test error handling.
Object? throwFlutterError();
/// Returns passed in int.
@ObjCSelector('echoInt:')
@SwiftFunction('echo(_:)')
int echoInt(int anInt);
/// Returns passed in double.
@ObjCSelector('echoDouble:')
@SwiftFunction('echo(_:)')
double echoDouble(double aDouble);
/// Returns the passed in boolean.
@ObjCSelector('echoBool:')
@SwiftFunction('echo(_:)')
bool echoBool(bool aBool);
/// Returns the passed in string.
@ObjCSelector('echoString:')
@SwiftFunction('echo(_:)')
String echoString(String aString);
/// Returns the passed in Uint8List.
@ObjCSelector('echoUint8List:')
@SwiftFunction('echo(_:)')
Uint8List echoUint8List(Uint8List aUint8List);
/// Returns the passed in generic Object.
@ObjCSelector('echoObject:')
@SwiftFunction('echo(_:)')
Object echoObject(Object anObject);
/// Returns the passed list, to test serialization and deserialization.
@ObjCSelector('echoList:')
@SwiftFunction('echo(_:)')
List<Object?> echoList(List<Object?> list);
/// Returns the passed map, to test serialization and deserialization.
@ObjCSelector('echoMap:')
@SwiftFunction('echo(_:)')
Map<String?, Object?> echoMap(Map<String?, Object?> aMap);
/// Returns the passed map to test nested class serialization and deserialization.
@ObjCSelector('echoClassWrapper:')
@SwiftFunction('echo(_:)')
AllClassesWrapper echoClassWrapper(AllClassesWrapper wrapper);
/// Returns the passed enum to test serialization and deserialization.
@ObjCSelector('echoEnum:')
@SwiftFunction('echo(_:)')
AnEnum echoEnum(AnEnum anEnum);
/// Returns the default string.
@ObjCSelector('echoNamedDefaultString:')
@SwiftFunction('echoNamedDefault(_:)')
String echoNamedDefaultString({String aString = 'default'});
/// Returns passed in double.
@ObjCSelector('echoOptionalDefaultDouble:')
@SwiftFunction('echoOptionalDefault(_:)')
double echoOptionalDefaultDouble([double aDouble = 3.14]);
/// Returns passed in int.
@ObjCSelector('echoRequiredInt:')
@SwiftFunction('echoRequired(_:)')
int echoRequiredInt({required int anInt});
// ========== Synchronous nullable method tests ==========
/// Returns the passed object, to test serialization and deserialization.
@ObjCSelector('echoAllNullableTypes:')
@SwiftFunction('echo(_:)')
AllNullableTypes? echoAllNullableTypes(AllNullableTypes? everything);
/// Returns the passed object, to test serialization and deserialization.
@ObjCSelector('echoAllNullableTypesWithoutRecursion:')
@SwiftFunction('echo(_:)')
AllNullableTypesWithoutRecursion? echoAllNullableTypesWithoutRecursion(
AllNullableTypesWithoutRecursion? everything);
/// Returns the inner `aString` value from the wrapped object, to test
/// sending of nested objects.
@ObjCSelector('extractNestedNullableStringFrom:')
@SwiftFunction('extractNestedNullableString(from:)')
String? extractNestedNullableString(AllClassesWrapper wrapper);
/// Returns the inner `aString` value from the wrapped object, to test
/// sending of nested objects.
@ObjCSelector('createNestedObjectWithNullableString:')
@SwiftFunction('createNestedObject(with:)')
AllClassesWrapper createNestedNullableString(String? nullableString);
/// Returns passed in arguments of multiple types.
@ObjCSelector('sendMultipleNullableTypesABool:anInt:aString:')
@SwiftFunction('sendMultipleNullableTypes(aBool:anInt:aString:)')
AllNullableTypes sendMultipleNullableTypes(
bool? aNullableBool, int? aNullableInt, String? aNullableString);
/// Returns passed in arguments of multiple types.
@ObjCSelector('sendMultipleNullableTypesWithoutRecursionABool:anInt:aString:')
@SwiftFunction(
'sendMultipleNullableTypesWithoutRecursion(aBool:anInt:aString:)')
AllNullableTypesWithoutRecursion sendMultipleNullableTypesWithoutRecursion(
bool? aNullableBool, int? aNullableInt, String? aNullableString);
/// Returns passed in int.
@ObjCSelector('echoNullableInt:')
@SwiftFunction('echo(_:)')
int? echoNullableInt(int? aNullableInt);
/// Returns passed in double.
@ObjCSelector('echoNullableDouble:')
@SwiftFunction('echo(_:)')
double? echoNullableDouble(double? aNullableDouble);
/// Returns the passed in boolean.
@ObjCSelector('echoNullableBool:')
@SwiftFunction('echo(_:)')
bool? echoNullableBool(bool? aNullableBool);
/// Returns the passed in string.
@ObjCSelector('echoNullableString:')
@SwiftFunction('echo(_:)')
String? echoNullableString(String? aNullableString);
/// Returns the passed in Uint8List.
@ObjCSelector('echoNullableUint8List:')
@SwiftFunction('echo(_:)')
Uint8List? echoNullableUint8List(Uint8List? aNullableUint8List);
/// Returns the passed in generic Object.
@ObjCSelector('echoNullableObject:')
@SwiftFunction('echo(_:)')
Object? echoNullableObject(Object? aNullableObject);
/// Returns the passed list, to test serialization and deserialization.
@ObjCSelector('echoNullableList:')
@SwiftFunction('echoNullable(_:)')
List<Object?>? echoNullableList(List<Object?>? aNullableList);
/// Returns the passed map, to test serialization and deserialization.
@ObjCSelector('echoNullableMap:')
@SwiftFunction('echoNullable(_:)')
Map<String?, Object?>? echoNullableMap(Map<String?, Object?>? aNullableMap);
@ObjCSelector('echoNullableEnum:')
@SwiftFunction('echoNullable(_:)')
AnEnum? echoNullableEnum(AnEnum? anEnum);
/// Returns passed in int.
@ObjCSelector('echoOptionalNullableInt:')
@SwiftFunction('echoOptional(_:)')
int? echoOptionalNullableInt([int? aNullableInt]);
/// Returns the passed in string.
@ObjCSelector('echoNamedNullableString:')
@SwiftFunction('echoNamed(_:)')
String? echoNamedNullableString({String? aNullableString});
// ========== Asynchronous method tests ==========
/// A no-op function taking no arguments and returning no value, to sanity
/// test basic asynchronous calling.
@async
void noopAsync();
/// Returns passed in int asynchronously.
@async
@ObjCSelector('echoAsyncInt:')
@SwiftFunction('echoAsync(_:)')
int echoAsyncInt(int anInt);
/// Returns passed in double asynchronously.
@async
@ObjCSelector('echoAsyncDouble:')
@SwiftFunction('echoAsync(_:)')
double echoAsyncDouble(double aDouble);
/// Returns the passed in boolean asynchronously.
@async
@ObjCSelector('echoAsyncBool:')
@SwiftFunction('echoAsync(_:)')
bool echoAsyncBool(bool aBool);
/// Returns the passed string asynchronously.
@async
@ObjCSelector('echoAsyncString:')
@SwiftFunction('echoAsync(_:)')
String echoAsyncString(String aString);
/// Returns the passed in Uint8List asynchronously.
@async
@ObjCSelector('echoAsyncUint8List:')
@SwiftFunction('echoAsync(_:)')
Uint8List echoAsyncUint8List(Uint8List aUint8List);
/// Returns the passed in generic Object asynchronously.
@async
@ObjCSelector('echoAsyncObject:')
@SwiftFunction('echoAsync(_:)')
Object echoAsyncObject(Object anObject);
/// Returns the passed list, to test asynchronous serialization and deserialization.
@async
@ObjCSelector('echoAsyncList:')
@SwiftFunction('echoAsync(_:)')
List<Object?> echoAsyncList(List<Object?> list);
/// Returns the passed map, to test asynchronous serialization and deserialization.
@async
@ObjCSelector('echoAsyncMap:')
@SwiftFunction('echoAsync(_:)')
Map<String?, Object?> echoAsyncMap(Map<String?, Object?> aMap);
/// Returns the passed enum, to test asynchronous serialization and deserialization.
@async
@ObjCSelector('echoAsyncEnum:')
@SwiftFunction('echoAsync(_:)')
AnEnum echoAsyncEnum(AnEnum anEnum);
/// Responds with an error from an async function returning a value.
@async
Object? throwAsyncError();
/// Responds with an error from an async void function.
@async
void throwAsyncErrorFromVoid();
/// Responds with a Flutter error from an async function returning a value.
@async
Object? throwAsyncFlutterError();
/// Returns the passed object, to test async serialization and deserialization.
@async
@ObjCSelector('echoAsyncAllTypes:')
@SwiftFunction('echoAsync(_:)')
AllTypes echoAsyncAllTypes(AllTypes everything);
/// Returns the passed object, to test serialization and deserialization.
@async
@ObjCSelector('echoAsyncNullableAllNullableTypes:')
@SwiftFunction('echoAsync(_:)')
AllNullableTypes? echoAsyncNullableAllNullableTypes(
AllNullableTypes? everything);
/// Returns the passed object, to test serialization and deserialization.
@async
@ObjCSelector('echoAsyncNullableAllNullableTypesWithoutRecursion:')
@SwiftFunction('echoAsync(_:)')
AllNullableTypesWithoutRecursion?
echoAsyncNullableAllNullableTypesWithoutRecursion(
AllNullableTypesWithoutRecursion? everything);
/// Returns passed in int asynchronously.
@async
@ObjCSelector('echoAsyncNullableInt:')
@SwiftFunction('echoAsyncNullable(_:)')
int? echoAsyncNullableInt(int? anInt);
/// Returns passed in double asynchronously.
@async
@ObjCSelector('echoAsyncNullableDouble:')
@SwiftFunction('echoAsyncNullable(_:)')
double? echoAsyncNullableDouble(double? aDouble);
/// Returns the passed in boolean asynchronously.
@async
@ObjCSelector('echoAsyncNullableBool:')
@SwiftFunction('echoAsyncNullable(_:)')
bool? echoAsyncNullableBool(bool? aBool);
/// Returns the passed string asynchronously.
@async
@ObjCSelector('echoAsyncNullableString:')
@SwiftFunction('echoAsyncNullable(_:)')
String? echoAsyncNullableString(String? aString);
/// Returns the passed in Uint8List asynchronously.
@async
@ObjCSelector('echoAsyncNullableUint8List:')
@SwiftFunction('echoAsyncNullable(_:)')
Uint8List? echoAsyncNullableUint8List(Uint8List? aUint8List);
/// Returns the passed in generic Object asynchronously.
@async
@ObjCSelector('echoAsyncNullableObject:')
@SwiftFunction('echoAsyncNullable(_:)')
Object? echoAsyncNullableObject(Object? anObject);
/// Returns the passed list, to test asynchronous serialization and deserialization.
@async
@ObjCSelector('echoAsyncNullableList:')
@SwiftFunction('echoAsyncNullable(_:)')
List<Object?>? echoAsyncNullableList(List<Object?>? list);
/// Returns the passed map, to test asynchronous serialization and deserialization.
@async
@ObjCSelector('echoAsyncNullableMap:')
@SwiftFunction('echoAsyncNullable(_:)')
Map<String?, Object?>? echoAsyncNullableMap(Map<String?, Object?>? aMap);
/// Returns the passed enum, to test asynchronous serialization and deserialization.
@async
@ObjCSelector('echoAsyncNullableEnum:')
@SwiftFunction('echoAsyncNullable(_:)')
AnEnum? echoAsyncNullableEnum(AnEnum? anEnum);
// ========== Flutter API test wrappers ==========
@async
void callFlutterNoop();
@async
Object? callFlutterThrowError();
@async
void callFlutterThrowErrorFromVoid();
@async
@ObjCSelector('callFlutterEchoAllTypes:')
@SwiftFunction('callFlutterEcho(_:)')
AllTypes callFlutterEchoAllTypes(AllTypes everything);
@async
@ObjCSelector('callFlutterEchoAllNullableTypes:')
@SwiftFunction('callFlutterEcho(_:)')
AllNullableTypes? callFlutterEchoAllNullableTypes(
AllNullableTypes? everything);
@async
@ObjCSelector('callFlutterSendMultipleNullableTypesABool:anInt:aString:')
@SwiftFunction('callFlutterSendMultipleNullableTypes(aBool:anInt:aString:)')
AllNullableTypes callFlutterSendMultipleNullableTypes(
bool? aNullableBool, int? aNullableInt, String? aNullableString);
@async
@ObjCSelector('callFlutterEchoAllNullableTypesWithoutRecursion:')
@SwiftFunction('callFlutterEcho(_:)')
AllNullableTypesWithoutRecursion?
callFlutterEchoAllNullableTypesWithoutRecursion(
AllNullableTypesWithoutRecursion? everything);
@async
@ObjCSelector(
'callFlutterSendMultipleNullableTypesWithoutRecursionABool:anInt:aString:')
@SwiftFunction(
'callFlutterSendMultipleNullableTypesWithoutRecursion(aBool:anInt:aString:)')
AllNullableTypesWithoutRecursion
callFlutterSendMultipleNullableTypesWithoutRecursion(
bool? aNullableBool, int? aNullableInt, String? aNullableString);
@async
@ObjCSelector('callFlutterEchoBool:')
@SwiftFunction('callFlutterEcho(_:)')
bool callFlutterEchoBool(bool aBool);
@async
@ObjCSelector('callFlutterEchoInt:')
@SwiftFunction('callFlutterEcho(_:)')
int callFlutterEchoInt(int anInt);
@async
@ObjCSelector('callFlutterEchoDouble:')
@SwiftFunction('callFlutterEcho(_:)')
double callFlutterEchoDouble(double aDouble);
@async
@ObjCSelector('callFlutterEchoString:')
@SwiftFunction('callFlutterEcho(_:)')
String callFlutterEchoString(String aString);
@async
@ObjCSelector('callFlutterEchoUint8List:')
@SwiftFunction('callFlutterEcho(_:)')
Uint8List callFlutterEchoUint8List(Uint8List list);
@async
@ObjCSelector('callFlutterEchoList:')
@SwiftFunction('callFlutterEcho(_:)')
List<Object?> callFlutterEchoList(List<Object?> list);
@async
@ObjCSelector('callFlutterEchoMap:')
@SwiftFunction('callFlutterEcho(_:)')
Map<String?, Object?> callFlutterEchoMap(Map<String?, Object?> aMap);
@async
@ObjCSelector('callFlutterEchoEnum:')
@SwiftFunction('callFlutterEcho(_:)')
AnEnum callFlutterEchoEnum(AnEnum anEnum);
@async
@ObjCSelector('callFlutterEchoNullableBool:')
@SwiftFunction('callFlutterEchoNullable(_:)')
bool? callFlutterEchoNullableBool(bool? aBool);
@async
@ObjCSelector('callFlutterEchoNullableInt:')
@SwiftFunction('callFlutterEchoNullable(_:)')
int? callFlutterEchoNullableInt(int? anInt);
@async
@ObjCSelector('callFlutterEchoNullableDouble:')
@SwiftFunction('callFlutterEchoNullable(_:)')
double? callFlutterEchoNullableDouble(double? aDouble);
@async
@ObjCSelector('callFlutterEchoNullableString:')
@SwiftFunction('callFlutterEchoNullable(_:)')
String? callFlutterEchoNullableString(String? aString);
@async
@ObjCSelector('callFlutterEchoNullableUint8List:')
@SwiftFunction('callFlutterEchoNullable(_:)')
Uint8List? callFlutterEchoNullableUint8List(Uint8List? list);
@async
@ObjCSelector('callFlutterEchoNullableList:')
@SwiftFunction('callFlutterEchoNullable(_:)')
List<Object?>? callFlutterEchoNullableList(List<Object?>? list);
@async
@ObjCSelector('callFlutterEchoNullableMap:')
@SwiftFunction('callFlutterEchoNullable(_:)')
Map<String?, Object?>? callFlutterEchoNullableMap(
Map<String?, Object?>? aMap);
@async
@ObjCSelector('callFlutterEchoNullableEnum:')
@SwiftFunction('callFlutterNullableEcho(_:)')
AnEnum? callFlutterEchoNullableEnum(AnEnum? anEnum);
@async
@ObjCSelector('callFlutterSmallApiEchoString:')
@SwiftFunction('callFlutterSmallApiEcho(_:)')
String callFlutterSmallApiEchoString(String aString);
}
/// The core interface that the Dart platform_test code implements for host
/// integration tests to call into.
@FlutterApi()
abstract class FlutterIntegrationCoreApi {
/// A no-op function taking no arguments and returning no value, to sanity
/// test basic calling.
void noop();
/// Responds with an error from an async function returning a value.
Object? throwError();
/// Responds with an error from an async void function.
void throwErrorFromVoid();
/// Returns the passed object, to test serialization and deserialization.
@ObjCSelector('echoAllTypes:')
@SwiftFunction('echo(_:)')
AllTypes echoAllTypes(AllTypes everything);
/// Returns the passed object, to test serialization and deserialization.
@ObjCSelector('echoAllNullableTypes:')
@SwiftFunction('echoNullable(_:)')
AllNullableTypes? echoAllNullableTypes(AllNullableTypes? everything);
/// Returns passed in arguments of multiple types.
///
/// Tests multiple-arity FlutterApi handling.
@ObjCSelector('sendMultipleNullableTypesABool:anInt:aString:')
@SwiftFunction('sendMultipleNullableTypes(aBool:anInt:aString:)')
AllNullableTypes sendMultipleNullableTypes(
bool? aNullableBool, int? aNullableInt, String? aNullableString);
/// Returns the passed object, to test serialization and deserialization.
@ObjCSelector('echoAllNullableTypesWithoutRecursion:')
@SwiftFunction('echoNullable(_:)')
AllNullableTypesWithoutRecursion? echoAllNullableTypesWithoutRecursion(
AllNullableTypesWithoutRecursion? everything);
/// Returns passed in arguments of multiple types.
///
/// Tests multiple-arity FlutterApi handling.
@ObjCSelector('sendMultipleNullableTypesWithoutRecursionABool:anInt:aString:')
@SwiftFunction(
'sendMultipleNullableTypesWithoutRecursion(aBool:anInt:aString:)')
AllNullableTypesWithoutRecursion sendMultipleNullableTypesWithoutRecursion(
bool? aNullableBool, int? aNullableInt, String? aNullableString);
// ========== Non-nullable argument/return type tests ==========
/// Returns the passed boolean, to test serialization and deserialization.
@ObjCSelector('echoBool:')
@SwiftFunction('echo(_:)')
bool echoBool(bool aBool);
/// Returns the passed int, to test serialization and deserialization.
@ObjCSelector('echoInt:')
@SwiftFunction('echo(_:)')
int echoInt(int anInt);
/// Returns the passed double, to test serialization and deserialization.
@ObjCSelector('echoDouble:')
@SwiftFunction('echo(_:)')
double echoDouble(double aDouble);
/// Returns the passed string, to test serialization and deserialization.
@ObjCSelector('echoString:')
@SwiftFunction('echo(_:)')
String echoString(String aString);
/// Returns the passed byte list, to test serialization and deserialization.
@ObjCSelector('echoUint8List:')
@SwiftFunction('echo(_:)')
Uint8List echoUint8List(Uint8List list);
/// Returns the passed list, to test serialization and deserialization.
@ObjCSelector('echoList:')
@SwiftFunction('echo(_:)')
List<Object?> echoList(List<Object?> list);
/// Returns the passed map, to test serialization and deserialization.
@ObjCSelector('echoMap:')
@SwiftFunction('echo(_:)')
Map<String?, Object?> echoMap(Map<String?, Object?> aMap);
/// Returns the passed enum to test serialization and deserialization.
@ObjCSelector('echoEnum:')
@SwiftFunction('echo(_:)')
AnEnum echoEnum(AnEnum anEnum);
// ========== Nullable argument/return type tests ==========
/// Returns the passed boolean, to test serialization and deserialization.
@ObjCSelector('echoNullableBool:')
@SwiftFunction('echoNullable(_:)')
bool? echoNullableBool(bool? aBool);
/// Returns the passed int, to test serialization and deserialization.
@ObjCSelector('echoNullableInt:')
@SwiftFunction('echoNullable(_:)')
int? echoNullableInt(int? anInt);
/// Returns the passed double, to test serialization and deserialization.
@ObjCSelector('echoNullableDouble:')
@SwiftFunction('echoNullable(_:)')
double? echoNullableDouble(double? aDouble);
/// Returns the passed string, to test serialization and deserialization.
@ObjCSelector('echoNullableString:')
@SwiftFunction('echoNullable(_:)')
String? echoNullableString(String? aString);
/// Returns the passed byte list, to test serialization and deserialization.
@ObjCSelector('echoNullableUint8List:')
@SwiftFunction('echoNullable(_:)')
Uint8List? echoNullableUint8List(Uint8List? list);
/// Returns the passed list, to test serialization and deserialization.
@ObjCSelector('echoNullableList:')
@SwiftFunction('echoNullable(_:)')
List<Object?>? echoNullableList(List<Object?>? list);
/// Returns the passed map, to test serialization and deserialization.
@ObjCSelector('echoNullableMap:')
@SwiftFunction('echoNullable(_:)')
Map<String?, Object?>? echoNullableMap(Map<String?, Object?>? aMap);
/// Returns the passed enum to test serialization and deserialization.
@ObjCSelector('echoNullableEnum:')
@SwiftFunction('echoNullable(_:)')
AnEnum? echoNullableEnum(AnEnum? anEnum);
// ========== Async tests ==========
// These are minimal since async FlutterApi only changes Dart generation.
// Currently they aren't integration tested, but having them here ensures
// analysis coverage.
/// A no-op function taking no arguments and returning no value, to sanity
/// test basic asynchronous calling.
@async
void noopAsync();
/// Returns the passed in generic Object asynchronously.
@async
@ObjCSelector('echoAsyncString:')
@SwiftFunction('echoAsync(_:)')
String echoAsyncString(String aString);
}
/// An API that can be implemented for minimal, compile-only tests.
//
// This is also here to test that multiple host APIs can be generated
// successfully in all languages (e.g., in Java where it requires having a
// wrapper class).
@HostApi()
abstract class HostTrivialApi {
void noop();
}
/// A simple API implemented in some unit tests.
//
// This is separate from HostIntegrationCoreApi to avoid having to update a
// lot of unit tests every time we add something to the integration test API.
// TODO(stuartmorgan): Restructure the unit tests to reduce the number of
// different APIs we define.
@HostApi()
abstract class HostSmallApi {
@async
@ObjCSelector('echoString:')
String echo(String aString);
@async
void voidVoid();
}
/// A simple API called in some unit tests.
//
// This is separate from FlutterIntegrationCoreApi to allow for incrementally
// moving from the previous fragmented unit test structure to something more
// unified.
// TODO(stuartmorgan): Restructure the unit tests to reduce the number of
// different APIs we define.
@FlutterApi()
abstract class FlutterSmallApi {
@ObjCSelector('echoWrappedList:')
@SwiftFunction('echo(_:)')
TestMessage echoWrappedList(TestMessage msg);
@ObjCSelector('echoString:')
@SwiftFunction('echo(string:)')
String echoString(String aString);
}
/// A data class containing a List, used in unit tests.
// TODO(stuartmorgan): Evaluate whether these unit tests are still useful; see
// TODOs above about restructuring.
class TestMessage {
// ignore: always_specify_types, strict_raw_type
List? testList;
}