Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix bugs about "!" on null value, and return null value
  • Loading branch information
fzyzcjy committed Mar 6, 2021
commit 68458a88a558f6dff3765bb3cba65da885df32e9
2 changes: 1 addition & 1 deletion flutter/test/sentry_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void main() {
_channel.setMockMethodCallHandler(
(MethodCall methodCall) async => <String, dynamic>{},
);
when(transport.send(any!))
when(transport.send(any))
.thenAnswer((realInvocation) => Future.value(SentryId.newId()));
});

Expand Down
12 changes: 6 additions & 6 deletions flutter/test/sentry_navigator_observer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void main() {

group('SentryNavigatorObserver', () {
PageRoute route(RouteSettings? settings) => PageRouteBuilder<void>(
pageBuilder: ((_, __, ___) => null) as Widget Function(BuildContext, Animation<double>, Animation<double>),
pageBuilder: (_, __, ___) => Container(),
settings: settings,
);

Expand All @@ -153,7 +153,7 @@ void main() {
observer.didPush(route(to), route(previous));

final dynamic breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.single as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.single as Breadcrumb;
expect(
breadcrumb.data,
RouteObserverBreadcrumb(
Expand All @@ -174,7 +174,7 @@ void main() {
observer.didPush(route(to), route(previous));

final dynamic breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.single as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.single as Breadcrumb;
expect(
breadcrumb.data,
RouteObserverBreadcrumb(
Expand All @@ -195,7 +195,7 @@ void main() {
observer.didReplace(newRoute: to, oldRoute: previous);

final dynamic breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.single as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.single as Breadcrumb;
expect(
breadcrumb.data,
RouteObserverBreadcrumb(
Expand All @@ -206,7 +206,7 @@ void main() {

test('No RouteSettings', () {
PageRoute route() => PageRouteBuilder<void>(
pageBuilder: ((_, __, ___) => null) as Widget Function(BuildContext, Animation<double>, Animation<double>),
pageBuilder: (_, __, ___) => Container(),
);

final hub = MockHub();
Expand All @@ -218,7 +218,7 @@ void main() {
observer.didPop(to, previous);

final dynamic breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.single as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.single as Breadcrumb;
expect(
breadcrumb.data,
RouteObserverBreadcrumb(
Expand Down
26 changes: 13 additions & 13 deletions flutter/test/widgets_binding_observer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void main() {
.handlePlatformMessage('flutter/system', message, (_) {});

final breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.single as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.single as Breadcrumb;

expect(
breadcrumb.message,
Expand Down Expand Up @@ -70,7 +70,7 @@ void main() {
await WidgetsBinding.instance!.defaultBinaryMessenger
.handlePlatformMessage('flutter/system', message, (_) {});

verifyNever(hub.addBreadcrumb(captureAny!));
verifyNever(hub.addBreadcrumb(captureAny));

WidgetsBinding.instance!.removeObserver(observer);
});
Expand Down Expand Up @@ -100,7 +100,7 @@ void main() {
await sendLifecycle('paused');

var breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.last as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.last as Breadcrumb;
expect(breadcrumb.category, 'app.lifecycle');
expect(breadcrumb.type, 'navigation');
expect(breadcrumb.data, mapForLifecycle('paused'));
Expand All @@ -110,7 +110,7 @@ void main() {
await sendLifecycle('resumed');

breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.last as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.last as Breadcrumb;
expect(breadcrumb.category, 'app.lifecycle');
expect(breadcrumb.type, 'navigation');
expect(breadcrumb.data, mapForLifecycle('resumed'));
Expand All @@ -120,7 +120,7 @@ void main() {
await sendLifecycle('inactive');

breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.last as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.last as Breadcrumb;
expect(breadcrumb.category, 'app.lifecycle');
expect(breadcrumb.type, 'navigation');
expect(breadcrumb.data, mapForLifecycle('inactive'));
Expand All @@ -130,7 +130,7 @@ void main() {
await sendLifecycle('detached');

breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.last as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.last as Breadcrumb;
expect(breadcrumb.category, 'app.lifecycle');
expect(breadcrumb.type, 'navigation');
expect(breadcrumb.data, mapForLifecycle('detached'));
Expand Down Expand Up @@ -158,7 +158,7 @@ void main() {

await sendLifecycle('paused');

verifyNever(hub.addBreadcrumb(captureAny!));
verifyNever(hub.addBreadcrumb(captureAny));

WidgetsBinding.instance!.removeObserver(observer);
});
Expand All @@ -177,7 +177,7 @@ void main() {
window.onMetricsChanged!();

final breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.single as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.single as Breadcrumb;

expect(breadcrumb.message, 'Screen size changed');
expect(breadcrumb.category, 'device.screen');
Expand Down Expand Up @@ -206,7 +206,7 @@ void main() {

window.onMetricsChanged!();

verifyNever(hub.addBreadcrumb(captureAny!));
verifyNever(hub.addBreadcrumb(captureAny));

WidgetsBinding.instance!.removeObserver(observer);
});
Expand All @@ -229,7 +229,7 @@ void main() {
brightness == Brightness.dark ? 'dark' : 'light';

final breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.single as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.single as Breadcrumb;

expect(breadcrumb.message,
'Platform brightness was changed to $brightnessDescription.');
Expand Down Expand Up @@ -258,7 +258,7 @@ void main() {

window.onPlatformBrightnessChanged!();

verifyNever(hub.addBreadcrumb(captureAny!));
verifyNever(hub.addBreadcrumb(captureAny));

WidgetsBinding.instance!.removeObserver(observer);
});
Expand All @@ -280,7 +280,7 @@ void main() {
final newTextScaleFactor = WidgetsBinding.instance!.window.textScaleFactor;

final breadcrumb =
verify(hub.addBreadcrumb(captureAny!)).captured.single as Breadcrumb;
verify(hub.addBreadcrumb(captureAny)).captured.single as Breadcrumb;

expect(breadcrumb.message,
'Text scale factor changed to $newTextScaleFactor.');
Expand All @@ -306,7 +306,7 @@ void main() {

window.onTextScaleFactorChanged!();

verifyNever(hub.addBreadcrumb(captureAny!));
verifyNever(hub.addBreadcrumb(captureAny));

WidgetsBinding.instance!.removeObserver(observer);
});
Expand Down