diff --git a/flutter/lib/src/native/c/sentry_native.dart b/flutter/lib/src/native/c/sentry_native.dart index 6534890fc..da466c7f1 100644 --- a/flutter/lib/src/native/c/sentry_native.dart +++ b/flutter/lib/src/native/c/sentry_native.dart @@ -19,8 +19,7 @@ class SentryNative with SentryNativeSafeInvoker implements SentryNativeBinding { final SentryFlutterOptions options; @visibleForTesting - static late final native = - binding.SentryNative(DynamicLibrary.open('sentry.dll')); + static final native = binding.SentryNative(DynamicLibrary.open('sentry.dll')); @visibleForTesting static String? crashpadPath; @@ -338,7 +337,7 @@ binding.sentry_value_u? dynamicToNativeValue( extension on String { binding.sentry_value_u toNativeValue() { - final cValue = this.toNativeUtf8(); + final cValue = toNativeUtf8(); final result = SentryNative.native.value_new_string(cValue.cast()); malloc.free(cValue); return result; @@ -348,7 +347,7 @@ extension on String { extension on int { binding.sentry_value_u toNativeValue() { if (this > 0x7FFFFFFF) { - return this.toString().toNativeValue(); + return toString().toNativeValue(); } else { return SentryNative.native.value_new_int32(this); } diff --git a/flutter/lib/src/native/c/utils.dart b/flutter/lib/src/native/c/utils.dart index b3f3ef5e4..34786404e 100644 --- a/flutter/lib/src/native/c/utils.dart +++ b/flutter/lib/src/native/c/utils.dart @@ -4,7 +4,7 @@ import 'package:ffi/ffi.dart'; /// Creates and collects native pointers that need to be freed. class FreeableFactory { - List _allocated = []; + final _allocated = []; Pointer str(String? dartString) { if (dartString == null) { diff --git a/flutter/test/integrations/native_sdk_integration_test.dart b/flutter/test/integrations/native_sdk_integration_test.dart index 42008efda..8645a80aa 100644 --- a/flutter/test/integrations/native_sdk_integration_test.dart +++ b/flutter/test/integrations/native_sdk_integration_test.dart @@ -15,8 +15,8 @@ void main() { setUp(() { fixture = IntegrationTestFixture(NativeSdkIntegration.new); - when(fixture.binding.init(any)).thenReturn(() {}); - when(fixture.binding.close()).thenReturn(() {}); + when(fixture.binding.init(any)).thenReturn(null); + when(fixture.binding.close()).thenReturn(null); }); test('adds integration', () async { diff --git a/flutter/test/native_scope_observer_test.dart b/flutter/test/native_scope_observer_test.dart index ea0cfbf42..e22136bc1 100644 --- a/flutter/test/native_scope_observer_test.dart +++ b/flutter/test/native_scope_observer_test.dart @@ -18,7 +18,7 @@ void main() { }); test('addBreadcrumbCalls', () async { - when(mock.addBreadcrumb(any)).thenReturn(() {}); + when(mock.addBreadcrumb(any)).thenReturn(null); final breadcrumb = Breadcrumb(); await sut.addBreadcrumb(breadcrumb); @@ -26,14 +26,14 @@ void main() { }); test('clearBreadcrumbsCalls', () async { - when(mock.clearBreadcrumbs()).thenReturn(() {}); + when(mock.clearBreadcrumbs()).thenReturn(null); await sut.clearBreadcrumbs(); verify(mock.clearBreadcrumbs()).called(1); }); test('removeContextsCalls', () async { - when(mock.removeContexts(any)).thenReturn(() {}); + when(mock.removeContexts(any)).thenReturn(null); await sut.removeContexts('fixture-key'); expect( @@ -41,42 +41,42 @@ void main() { }); test('removeExtraCalls', () async { - when(mock.removeExtra(any)).thenReturn(() {}); + when(mock.removeExtra(any)).thenReturn(null); await sut.removeExtra('fixture-key'); expect(verify(mock.removeExtra(captureAny)).captured.single, 'fixture-key'); }); test('removeTagCalls', () async { - when(mock.removeTag(any)).thenReturn(() {}); + when(mock.removeTag(any)).thenReturn(null); await sut.removeTag('fixture-key'); expect(verify(mock.removeTag(captureAny)).captured.single, 'fixture-key'); }); test('setContextsCalls', () async { - when(mock.setContexts(any, any)).thenReturn(() {}); + when(mock.setContexts(any, any)).thenReturn(null); await sut.setContexts('fixture-key', 'fixture-value'); verify(mock.setContexts('fixture-key', 'fixture-value')).called(1); }); test('setExtraCalls', () async { - when(mock.setExtra(any, any)).thenReturn(() {}); + when(mock.setExtra(any, any)).thenReturn(null); await sut.setExtra('fixture-key', 'fixture-value'); verify(mock.setExtra('fixture-key', 'fixture-value')).called(1); }); test('setTagCalls', () async { - when(mock.setTag(any, any)).thenReturn(() {}); + when(mock.setTag(any, any)).thenReturn(null); await sut.setTag('fixture-key', 'fixture-value'); verify(mock.setTag('fixture-key', 'fixture-value')).called(1); }); test('setUserCalls', () async { - when(mock.setUser(any)).thenReturn(() {}); + when(mock.setUser(any)).thenReturn(null); final user = SentryUser(id: 'foo bar'); await sut.setUser(user); diff --git a/flutter/test/profiling_test.dart b/flutter/test/profiling_test.dart index a2a0bbb86..510daac9f 100644 --- a/flutter/test/profiling_test.dart +++ b/flutter/test/profiling_test.dart @@ -68,7 +68,7 @@ void main() { }); test('dispose() calls native discard() exactly once', () async { - when(mock.discardProfiler(any)).thenReturn(() {}); + when(mock.discardProfiler(any)).thenReturn(null); sut.dispose(); sut.dispose(); // Additional calls must not have an effect. diff --git a/flutter/test/sentry_native/sentry_native_test_ffi.dart b/flutter/test/sentry_native/sentry_native_test_ffi.dart index 49edb5f66..988e32181 100644 --- a/flutter/test/sentry_native/sentry_native_test_ffi.dart +++ b/flutter/test/sentry_native/sentry_native_test_ffi.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:ffi/ffi.dart'; -import 'package:file/memory.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:sentry/src/platform/platform.dart' as platform; import 'package:sentry_flutter/sentry_flutter.dart'; @@ -41,8 +40,7 @@ void main() { options = SentryFlutterOptions(dsn: fakeDsn) // ignore: invalid_use_of_internal_member ..automatedTestMode = true - ..debug = true - ..fileSystem = MemoryFileSystem.test(); + ..debug = true; sut = createBinding(options) as SentryNative; }); @@ -226,31 +224,6 @@ void main() { (File file) => file.existsSync(), ); }); - - test('getAppDebugImage returns app.so debug image', () async { - await options.fileSystem.directory('/path/to/data').create(recursive: true); - await options.fileSystem - .file('/path/to/data/app.so') - .writeAsString('12345'); - - final image = await sut.getAppDebugImage( - SentryStackTrace( - frames: [], - // ignore: invalid_use_of_internal_member - buildId: '4c6950bd9e9cc9839071742a7295c09e', - // ignore: invalid_use_of_internal_member - baseAddr: '0x123', - ), - [DebugImage(type: 'pe', codeFile: '/path/to/application.exe')], - ); - - expect(image, isNotNull); - expect(image!.codeFile, '/path/to/data/app.so'); - expect(image.codeId, '4c6950bd9e9cc9839071742a7295c09e'); - expect(image.debugId, 'bd50694c9c9e83c99071742a7295c09e'); - expect(image.imageAddr, '0x123'); - expect(image.imageSize, 5); - }); } /// Runs [command] with command's stdout and stderr being forwrarded to @@ -319,7 +292,7 @@ bool _builtVersionIsExpected(String cmakeBuildDir, String buildOutputDir) { .any((name) => !File('$buildOutputDir/$name').existsSync()); } -late final _configuredSentryNativeVersion = +final _configuredSentryNativeVersion = File('$repoRootDir/sentry-native/CMakeCache.txt') .readAsLinesSync() .map((line) => line.startsWith('version=') ? line.substring(8) : null)