@@ -6,6 +6,7 @@ import 'package:sentry_flutter/sentry_flutter.dart';
66import 'package:sentry_flutter/src/integrations/integrations.dart' ;
77import 'package:sentry_flutter/src/integrations/screenshot_integration.dart' ;
88import 'package:sentry_flutter/src/renderer/renderer.dart' ;
9+ import 'package:sentry_flutter/src/sentry_native.dart' ;
910import 'package:sentry_flutter/src/version.dart' ;
1011import 'mocks.dart' ;
1112import 'mocks.mocks.dart' ;
@@ -46,17 +47,23 @@ void main() {
4647 group ('Test platform integrations' , () {
4748 setUp (() async {
4849 await Sentry .close ();
50+ final sentryNative = SentryNative ();
51+ sentryNative.nativeChannel = null ;
52+ sentryNative.reset ();
4953 });
5054
5155 test ('Android' , () async {
5256 List <Integration > integrations = [];
5357 Transport transport = MockTransport ();
5458
59+ SentryFlutterOptions ? sentryFlutterOptions;
60+
5561 await SentryFlutter .init (
5662 (options) async {
5763 options.dsn = fakeDsn;
5864 integrations = options.integrations;
5965 transport = options.transport;
66+ sentryFlutterOptions = options;
6067 },
6168 appRunner: appRunner,
6269 packageLoader: loadTestPackage,
@@ -68,6 +75,9 @@ void main() {
6875 hasFileSystemTransport: true ,
6976 );
7077
78+ testScopeObserver (
79+ options: sentryFlutterOptions! , expectedHasNativeScopeObserver: true );
80+
7181 testConfiguration (
7282 integrations: integrations,
7383 shouldHaveIntegrations: [
@@ -86,18 +96,22 @@ void main() {
8696 beforeIntegration: WidgetsFlutterBindingIntegration ,
8797 afterIntegration: OnErrorIntegration );
8898
99+ expect (SentryNative ().nativeChannel, isNotNull);
100+
89101 await Sentry .close ();
90102 }, testOn: 'vm' );
91103
92104 test ('iOS' , () async {
93105 List <Integration > integrations = [];
94106 Transport transport = MockTransport ();
107+ SentryFlutterOptions ? sentryFlutterOptions;
95108
96109 await SentryFlutter .init (
97110 (options) async {
98111 options.dsn = fakeDsn;
99112 integrations = options.integrations;
100113 transport = options.transport;
114+ sentryFlutterOptions = options;
101115 },
102116 appRunner: appRunner,
103117 packageLoader: loadTestPackage,
@@ -109,6 +123,9 @@ void main() {
109123 hasFileSystemTransport: true ,
110124 );
111125
126+ testScopeObserver (
127+ options: sentryFlutterOptions! , expectedHasNativeScopeObserver: true );
128+
112129 testConfiguration (
113130 integrations: integrations,
114131 shouldHaveIntegrations: [
@@ -125,18 +142,22 @@ void main() {
125142 beforeIntegration: WidgetsFlutterBindingIntegration ,
126143 afterIntegration: OnErrorIntegration );
127144
145+ expect (SentryNative ().nativeChannel, isNotNull);
146+
128147 await Sentry .close ();
129148 }, testOn: 'vm' );
130149
131150 test ('macOS' , () async {
132151 List <Integration > integrations = [];
133152 Transport transport = MockTransport ();
153+ SentryFlutterOptions ? sentryFlutterOptions;
134154
135155 await SentryFlutter .init (
136156 (options) async {
137157 options.dsn = fakeDsn;
138158 integrations = options.integrations;
139159 transport = options.transport;
160+ sentryFlutterOptions = options;
140161 },
141162 appRunner: appRunner,
142163 packageLoader: loadTestPackage,
@@ -148,6 +169,9 @@ void main() {
148169 hasFileSystemTransport: true ,
149170 );
150171
172+ testScopeObserver (
173+ options: sentryFlutterOptions! , expectedHasNativeScopeObserver: true );
174+
151175 testConfiguration (
152176 integrations: integrations,
153177 shouldHaveIntegrations: [
@@ -164,18 +188,22 @@ void main() {
164188 beforeIntegration: WidgetsFlutterBindingIntegration ,
165189 afterIntegration: OnErrorIntegration );
166190
191+ expect (SentryNative ().nativeChannel, isNotNull);
192+
167193 await Sentry .close ();
168194 }, testOn: 'vm' );
169195
170196 test ('Windows' , () async {
171197 List <Integration > integrations = [];
172198 Transport transport = MockTransport ();
199+ SentryFlutterOptions ? sentryFlutterOptions;
173200
174201 await SentryFlutter .init (
175202 (options) async {
176203 options.dsn = fakeDsn;
177204 integrations = options.integrations;
178205 transport = options.transport;
206+ sentryFlutterOptions = options;
179207 },
180208 appRunner: appRunner,
181209 packageLoader: loadTestPackage,
@@ -187,6 +215,10 @@ void main() {
187215 hasFileSystemTransport: false ,
188216 );
189217
218+ testScopeObserver (
219+ options: sentryFlutterOptions! ,
220+ expectedHasNativeScopeObserver: false );
221+
190222 testConfiguration (
191223 integrations: integrations,
192224 shouldHaveIntegrations: [
@@ -205,18 +237,22 @@ void main() {
205237 beforeIntegration: WidgetsFlutterBindingIntegration ,
206238 afterIntegration: OnErrorIntegration );
207239
240+ expect (SentryNative ().nativeChannel, isNull);
241+
208242 await Sentry .close ();
209243 }, testOn: 'vm' );
210244
211245 test ('Linux' , () async {
212246 List <Integration > integrations = [];
213247 Transport transport = MockTransport ();
248+ SentryFlutterOptions ? sentryFlutterOptions;
214249
215250 await SentryFlutter .init (
216251 (options) async {
217252 options.dsn = fakeDsn;
218253 integrations = options.integrations;
219254 transport = options.transport;
255+ sentryFlutterOptions = options;
220256 },
221257 appRunner: appRunner,
222258 packageLoader: loadTestPackage,
@@ -228,6 +264,10 @@ void main() {
228264 hasFileSystemTransport: false ,
229265 );
230266
267+ testScopeObserver (
268+ options: sentryFlutterOptions! ,
269+ expectedHasNativeScopeObserver: false );
270+
231271 testConfiguration (
232272 integrations: integrations,
233273 shouldHaveIntegrations: [
@@ -246,18 +286,22 @@ void main() {
246286 beforeIntegration: WidgetsFlutterBindingIntegration ,
247287 afterIntegration: OnErrorIntegration );
248288
289+ expect (SentryNative ().nativeChannel, isNull);
290+
249291 await Sentry .close ();
250292 }, testOn: 'vm' );
251293
252294 test ('Web' , () async {
253295 List <Integration > integrations = [];
254296 Transport transport = MockTransport ();
297+ SentryFlutterOptions ? sentryFlutterOptions;
255298
256299 await SentryFlutter .init (
257300 (options) async {
258301 options.dsn = fakeDsn;
259302 integrations = options.integrations;
260303 transport = options.transport;
304+ sentryFlutterOptions = options;
261305 },
262306 appRunner: appRunner,
263307 packageLoader: loadTestPackage,
@@ -272,6 +316,10 @@ void main() {
272316 hasFileSystemTransport: false ,
273317 );
274318
319+ testScopeObserver (
320+ options: sentryFlutterOptions! ,
321+ expectedHasNativeScopeObserver: false );
322+
275323 testConfiguration (
276324 integrations: integrations,
277325 shouldHaveIntegrations: platformAgnosticIntegrations,
@@ -288,6 +336,8 @@ void main() {
288336 beforeIntegration: RunZonedGuardedIntegration ,
289337 afterIntegration: WidgetsFlutterBindingIntegration );
290338
339+ expect (SentryNative ().nativeChannel, isNull);
340+
291341 await Sentry .close ();
292342 });
293343
0 commit comments