Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Oct 2, 2024
1 parent 3bd5c5d commit b17e607
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
9 changes: 2 additions & 7 deletions flutter/lib/src/navigation/sentry_navigator_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,8 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
_timeToDisplayTracker?.clear();

DateTime timestamp = _hub.options.clock();
_finishAndStartTTIDTracking(route, timestamp);
}

Future<void> _finishAndStartTTIDTracking(
Route<dynamic>? route, DateTime timestamp) async {
await _finishTimeToDisplayTracking(endTimestamp: timestamp);
await _startTimeToDisplayTracking(route, timestamp);
_finishTimeToDisplayTracking(endTimestamp: timestamp);
_startTimeToDisplayTracking(route, timestamp);
}

@override
Expand Down
25 changes: 18 additions & 7 deletions flutter/test/sentry_navigator_observer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ void main() {
expect(scope.span, null);
});

verify(span.finish()).called(2);
verify(span.finish(endTimestamp: captureAnyNamed('endTimestamp')))
.called(2);
});

test('didPop finishes transaction', () async {
Expand All @@ -344,7 +345,8 @@ void main() {
expect(scope.span, null);
});

verify(span.finish()).called(1);
verify(span.finish(endTimestamp: captureAnyNamed('endTimestamp')))
.called(1);
});

test('multiple didPop only finish transaction once', () async {
Expand Down Expand Up @@ -373,7 +375,8 @@ void main() {
expect(scope.span, null);
});

verify(span.finish()).called(1);
verify(span.finish(endTimestamp: captureAnyNamed('endTimestamp')))
.called(1);
});

test(
Expand Down Expand Up @@ -413,9 +416,13 @@ void main() {

await Future<void>.delayed(const Duration(milliseconds: 100));

verify(mockChildA.finish(status: SpanStatus.deadlineExceeded()))
verify(mockChildA.finish(
endTimestamp: captureAnyNamed('endTimestamp'),
status: SpanStatus.deadlineExceeded()))
.called(1);
verify(mockChildB.finish(status: SpanStatus.deadlineExceeded()))
verify(mockChildB.finish(
endTimestamp: captureAnyNamed('endTimestamp'),
status: SpanStatus.deadlineExceeded()))
.called(1);
});

Expand Down Expand Up @@ -456,9 +463,13 @@ void main() {

await Future<void>.delayed(const Duration(milliseconds: 100));

verify(mockChildA.finish(status: SpanStatus.deadlineExceeded()))
verify(mockChildA.finish(
endTimestamp: captureAnyNamed('endTimestamp'),
status: SpanStatus.deadlineExceeded()))
.called(1);
verify(mockChildB.finish(status: SpanStatus.deadlineExceeded()))
verify(mockChildB.finish(
endTimestamp: captureAnyNamed('endTimestamp'),
status: SpanStatus.deadlineExceeded()))
.called(1);
});

Expand Down

0 comments on commit b17e607

Please sign in to comment.