@@ -31,27 +31,27 @@ void main() {
31
31
// This ensures that setAppStartInfo has been called, which happens asynchronously
32
32
// in a post-frame callback. Waiting here prevents race conditions in subsequent tests
33
33
// that might depend on or modify the app start info.
34
- await NativeAppStartIntegration .getAppStartInfo ();
34
+ await fixture.sut .getAppStartInfo ();
35
35
}
36
36
37
37
group ('$NativeAppStartIntegration ' , () {
38
38
late Fixture fixture;
39
39
40
40
setUp (() {
41
41
fixture = Fixture ();
42
+ fixture.options.addIntegration (fixture.sut);
43
+
42
44
setupMocks (fixture);
43
45
when (fixture.binding.fetchNativeAppStart ()).thenAnswer ((_) async =>
44
46
NativeAppStart (
45
47
appStartTime: 0 ,
46
48
pluginRegistrationTime: 10 ,
47
49
isColdStart: true ,
48
50
nativeSpanTimes: {}));
49
- NativeAppStartIntegration .clearAppStartInfo ();
50
51
});
51
52
52
53
test ('native app start measurement added to first transaction' , () async {
53
- NativeAppStartIntegration .appStartEnd =
54
- DateTime .fromMillisecondsSinceEpoch (10 );
54
+ fixture.sut.appStartEnd = DateTime .fromMillisecondsSinceEpoch (10 );
55
55
56
56
await registerIntegration (fixture);
57
57
final tracer = fixture.createTracer ();
@@ -68,8 +68,7 @@ void main() {
68
68
69
69
test ('native app start measurement not added to following transactions' ,
70
70
() async {
71
- NativeAppStartIntegration .appStartEnd =
72
- DateTime .fromMillisecondsSinceEpoch (10 );
71
+ fixture.sut.appStartEnd = DateTime .fromMillisecondsSinceEpoch (10 );
73
72
74
73
await registerIntegration (fixture);
75
74
final tracer = fixture.createTracer ();
@@ -86,8 +85,7 @@ void main() {
86
85
});
87
86
88
87
test ('measurements appended' , () async {
89
- NativeAppStartIntegration .appStartEnd =
90
- DateTime .fromMillisecondsSinceEpoch (10 );
88
+ fixture.sut.appStartEnd = DateTime .fromMillisecondsSinceEpoch (10 );
91
89
final measurement = SentryMeasurement .warmAppStart (Duration (seconds: 1 ));
92
90
93
91
await registerIntegration (fixture);
@@ -107,8 +105,7 @@ void main() {
107
105
});
108
106
109
107
test ('native app start measurement not added if more than 60s' , () async {
110
- NativeAppStartIntegration .appStartEnd =
111
- DateTime .fromMillisecondsSinceEpoch (60001 );
108
+ fixture.sut.appStartEnd = DateTime .fromMillisecondsSinceEpoch (60001 );
112
109
113
110
await registerIntegration (fixture);
114
111
final tracer = fixture.createTracer ();
@@ -123,11 +120,10 @@ void main() {
123
120
124
121
test ('native app start integration is called and sets app start info' ,
125
122
() async {
126
- NativeAppStartIntegration .appStartEnd =
127
- DateTime .fromMillisecondsSinceEpoch (10 );
123
+ fixture.sut.appStartEnd = DateTime .fromMillisecondsSinceEpoch (10 );
128
124
129
125
await registerIntegration (fixture);
130
- final appStartInfo = await NativeAppStartIntegration .getAppStartInfo ();
126
+ final appStartInfo = await fixture.sut .getAppStartInfo ();
131
127
expect (appStartInfo? .start, DateTime .fromMillisecondsSinceEpoch (0 ));
132
128
expect (appStartInfo? .end, DateTime .fromMillisecondsSinceEpoch (10 ));
133
129
});
@@ -157,6 +153,7 @@ void main() {
157
153
fixture = Fixture (
158
154
frameCallbackTimeout: NativeAppStartIntegration .timeoutDuration +
159
155
const Duration (seconds: 5 ));
156
+ fixture.options.addIntegration (fixture.sut);
160
157
fixture.options.autoAppStart = false ;
161
158
162
159
await registerIntegration (fixture);
@@ -179,7 +176,9 @@ void main() {
179
176
fixture.options.autoAppStart = false ;
180
177
181
178
await registerIntegration (fixture);
182
- SentryFlutter .setAppStartEnd (DateTime .fromMillisecondsSinceEpoch (10 ));
179
+
180
+ fixture.sut.appStartEnd = DateTime .fromMillisecondsSinceEpoch (10 );
181
+ // SentryFlutter.setAppStartEnd(DateTime.fromMillisecondsSinceEpoch(10));
183
182
184
183
final tracer = fixture.createTracer ();
185
184
final transaction = SentryTransaction (tracer);
@@ -192,7 +191,7 @@ void main() {
192
191
expect (measurement.value, 10 );
193
192
expect (measurement.unit, DurationSentryMeasurementUnit .milliSecond);
194
193
195
- final appStartInfo = await NativeAppStartIntegration .getAppStartInfo ();
194
+ final appStartInfo = await fixture.sut .getAppStartInfo ();
196
195
197
196
final appStartSpan = enriched.spans.firstWhereOrNull ((element) =>
198
197
element.context.description == appStartInfo! .appStartTypeDescription);
@@ -260,10 +259,8 @@ void main() {
260
259
261
260
setUp (() async {
262
261
fixture = Fixture ();
263
- NativeAppStartIntegration .clearAppStartInfo ();
264
-
265
- NativeAppStartIntegration .appStartEnd =
266
- DateTime .fromMillisecondsSinceEpoch (50 );
262
+ fixture.options.addIntegration (fixture.sut);
263
+ fixture.sut.appStartEnd = DateTime .fromMillisecondsSinceEpoch (50 );
267
264
268
265
// dartLoadingEnd needs to be set after engine end (see MockNativeChannel)
269
266
SentryFlutter .sentrySetupStartTime =
@@ -281,7 +278,7 @@ void main() {
281
278
enriched =
282
279
await processor.apply (transaction, Hint ()) as SentryTransaction ;
283
280
284
- final appStartInfo = await NativeAppStartIntegration .getAppStartInfo ();
281
+ final appStartInfo = await fixture.sut .getAppStartInfo ();
285
282
286
283
coldStartSpan = enriched.spans.firstWhereOrNull ((element) =>
287
284
element.context.description == appStartInfo? .appStartTypeDescription);
@@ -395,8 +392,7 @@ void main() {
395
392
final engineReadyEndtime = DateTime .fromMillisecondsSinceEpoch (
396
393
appStartInfoSrc.pluginRegistrationTime.toInt ())
397
394
.toUtc ();
398
- expect (coldStartSpan? .endTimestamp,
399
- NativeAppStartIntegration .appStartEnd? .toUtc ());
395
+ expect (coldStartSpan? .endTimestamp, fixture.sut.appStartEnd? .toUtc ());
400
396
expect (pluginRegistrationSpan? .endTimestamp, engineReadyEndtime);
401
397
expect (sentrySetupSpan? .endTimestamp,
402
398
SentryFlutter .sentrySetupStartTime? .toUtc ());
@@ -415,7 +411,6 @@ class Fixture extends IntegrationTestFixture<NativeAppStartIntegration> {
415
411
FakeFrameCallbackHandler (
416
412
finishAfterDuration: frameCallbackTimeout ??
417
413
const Duration (milliseconds: 50 )))) {
418
- NativeAppStartIntegration .reset ();
419
414
hub = MockHub ();
420
415
// ignore: invalid_use_of_internal_member
421
416
when (hub.options).thenReturn (options);
0 commit comments