2
2
library flutter_test;
3
3
4
4
import 'dart:convert' ;
5
+
5
6
// backcompatibility for Flutter < 3.3
6
7
// ignore: unnecessary_import
7
8
import 'dart:typed_data' ;
@@ -39,7 +40,7 @@ void main() {
39
40
});
40
41
41
42
test ('$FileSystemTransport returns emptyId if channel throws' , () async {
42
- when (fixture.binding.captureEnvelope (any)).thenThrow (Exception ());
43
+ when (fixture.binding.captureEnvelope (any, false )).thenThrow (Exception ());
43
44
44
45
final transport = fixture.getSut ();
45
46
final event = SentryEvent ();
@@ -56,6 +57,58 @@ void main() {
56
57
expect (SentryId .empty (), sentryId);
57
58
});
58
59
60
+ test (
61
+ 'sets unhandled exception flag in captureEnvelope to true for unhandled exception' ,
62
+ () async {
63
+ final transport = fixture.getSut ();
64
+
65
+ final unhandledException = SentryException (
66
+ mechanism: Mechanism (type: 'UnhandledException' , handled: false ),
67
+ threadId: 99 ,
68
+ type: 'Exception' ,
69
+ value: 'Unhandled exception' ,
70
+ );
71
+ final event = SentryEvent (exceptions: [unhandledException]);
72
+ final sdkVersion =
73
+ SdkVersion (name: 'fixture-sdkName' , version: 'fixture-sdkVersion' );
74
+ final envelope = SentryEnvelope .fromEvent (
75
+ event,
76
+ sdkVersion,
77
+ dsn: fixture.options.dsn,
78
+ );
79
+
80
+ await transport.send (envelope);
81
+
82
+ verify (fixture.binding.captureEnvelope (captureAny, true )).captured.single
83
+ as Uint8List ;
84
+ });
85
+
86
+ test (
87
+ 'sets unhandled exception flag in captureEnvelope to false for handled exception' ,
88
+ () async {
89
+ final transport = fixture.getSut ();
90
+
91
+ final unhandledException = SentryException (
92
+ mechanism: Mechanism (type: 'UnhandledException' , handled: true ),
93
+ threadId: 99 ,
94
+ type: 'Exception' ,
95
+ value: 'Unhandled exception' ,
96
+ );
97
+ final event = SentryEvent (exceptions: [unhandledException]);
98
+ final sdkVersion =
99
+ SdkVersion (name: 'fixture-sdkName' , version: 'fixture-sdkVersion' );
100
+ final envelope = SentryEnvelope .fromEvent (
101
+ event,
102
+ sdkVersion,
103
+ dsn: fixture.options.dsn,
104
+ );
105
+
106
+ await transport.send (envelope);
107
+
108
+ verify (fixture.binding.captureEnvelope (captureAny, false )).captured.single
109
+ as Uint8List ;
110
+ });
111
+
59
112
test ('$FileSystemTransport asserts the event' , () async {
60
113
final transport = fixture.getSut ();
61
114
@@ -70,9 +123,10 @@ void main() {
70
123
);
71
124
await transport.send (envelope);
72
125
73
- final envelopeData = verify (fixture.binding.captureEnvelope (captureAny))
74
- .captured
75
- .single as Uint8List ;
126
+ final envelopeData =
127
+ verify (fixture.binding.captureEnvelope (captureAny, false ))
128
+ .captured
129
+ .single as Uint8List ;
76
130
final envelopeString = utf8.decode (envelopeData);
77
131
final lines = envelopeString.split ('\n ' );
78
132
final envelopeHeader = lines.first;
0 commit comments