@@ -21,26 +21,38 @@ void main() async {
21
21
print (batteryLevel);
22
22
});
23
23
24
- // A more complicated plugin
25
- //
26
- test ('Test StandardMethodCodec array of map' , () async {
24
+ group ('Complex plugin' , () {
27
25
const platform_complex_structure =
28
26
const MethodChannel ('instance.id/go/data' );
29
27
30
- final List <dynamic > result = await platform_complex_structure.invokeMethod (
31
- 'getData' , "HelloFromDart" ); // passing "HelloFromDart" as an argument
32
- expect (result, [
33
- {"instanceid" : 1023 , "pcbackup" : "test" , "brbackup" : "test2" },
34
- {"instanceid" : 1024 , "pcbackup" : "test" , "brbackup" : "test2" },
35
- {"instanceid" : 1056 , "pcbackup" : "coucou" , "brbackup" : "coucou2" },
36
- {"instanceid" : 3322 , "pcbackup" : "finaly" , "brbackup" : "finaly2" }
37
- ]);
38
-
39
- // golang can return the random methodName
40
- final String methodName = 'test/' + new Random ().nextInt (100000 ).toString ();
41
- final String resultPathPrefix =
42
- await platform_complex_structure.invokeMethod (methodName);
43
- expect (resultPathPrefix, methodName);
28
+ // A more complicated plugin
29
+ test ('Test StandardMethodCodec array of map' , () async {
30
+ final List <dynamic > result =
31
+ await platform_complex_structure.invokeMethod ('getData' ,
32
+ "HelloFromDart" ); // passing "HelloFromDart" as an argument
33
+ expect (result, [
34
+ {"instanceid" : 1023 , "pcbackup" : "test" , "brbackup" : "test2" },
35
+ {"instanceid" : 1024 , "pcbackup" : "test" , "brbackup" : "test2" },
36
+ {"instanceid" : 1056 , "pcbackup" : "coucou" , "brbackup" : "coucou2" },
37
+ {"instanceid" : 3322 , "pcbackup" : "finaly" , "brbackup" : "finaly2" }
38
+ ]);
39
+
40
+ // golang can return the random methodName
41
+ final String methodName =
42
+ 'test/' + new Random ().nextInt (100000 ).toString ();
43
+ final String resultPathPrefix =
44
+ await platform_complex_structure.invokeMethod (methodName);
45
+ expect (resultPathPrefix, methodName);
46
+ });
47
+
48
+ test ('Custom errors' , () async {
49
+ var matcher = predicate (
50
+ (e) => e is PlatformException && e.code == "customErrorCode" );
51
+ expect (
52
+ platform_complex_structure.invokeMethod ('getError' ),
53
+ throwsA (matcher),
54
+ );
55
+ });
44
56
});
45
57
46
58
tearDownAll (() async {
0 commit comments