From fc54e2e06c42fad7f3fcc3ae349a2db78db41f21 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 18 Feb 2025 10:56:51 +0100 Subject: [PATCH 01/16] replace platform checker --- .../load_dart_debug_images_integration.dart | 14 +++-- dart/lib/src/platform/_io_platform.dart | 21 +------- dart/lib/src/platform/_web_platform.dart | 51 +++++++++++++++++- dart/lib/src/platform/platform.dart | 37 +------------ dart/lib/src/platform_checker.dart | 6 +-- dart/lib/src/protocol/sdk_version.dart | 1 + dart/pubspec.yaml | 1 + dart/test/example_web_compile_test.dart | 1 + dart/test/mocks/mock_platform.dart | 41 +++++--------- dart/test/mocks/mock_platform_checker.dart | 2 +- flutter/pubspec.yaml | 2 + flutter/test/mocks.dart | 53 +++++++------------ flutter/test/profiling_test.dart | 2 +- flutter/test/replay/replay_native_test.dart | 2 +- flutter/test/sentry_flutter_test.dart | 16 +++--- flutter/test/sentry_native_channel_test.dart | 8 +-- min_version_test/pubspec.yaml | 1 + 17 files changed, 117 insertions(+), 142 deletions(-) diff --git a/dart/lib/src/load_dart_debug_images_integration.dart b/dart/lib/src/load_dart_debug_images_integration.dart index 4b7a35c39f..c271c6232a 100644 --- a/dart/lib/src/load_dart_debug_images_integration.dart +++ b/dart/lib/src/load_dart_debug_images_integration.dart @@ -1,8 +1,16 @@ import 'dart:typed_data'; - import 'package:meta/meta.dart'; -import '../sentry.dart'; +import 'event_processor.dart'; +import 'hint.dart'; +import 'hub.dart'; +import 'integration.dart'; +import 'protocol/debug_image.dart'; +import 'protocol/debug_meta.dart'; +import 'protocol/sentry_event.dart'; +import 'protocol/sentry_level.dart'; +import 'protocol/sentry_stack_trace.dart'; +import 'sentry_options.dart'; class LoadDartDebugImagesIntegration extends Integration { @override @@ -87,7 +95,7 @@ class LoadImageIntegrationEventProcessor implements EventProcessor { if (platform.isAndroid || platform.isWindows) { type = 'elf'; - debugId = _convertBuildIdToDebugId(stackTrace.buildId!, platform.endian); + debugId = _convertBuildIdToDebugId(stackTrace.buildId!, Endian.host); if (platform.isAndroid) { codeFile = 'libapp.so'; } else if (platform.isWindows) { diff --git a/dart/lib/src/platform/_io_platform.dart b/dart/lib/src/platform/_io_platform.dart index ecc9c2035c..b7316e22ab 100644 --- a/dart/lib/src/platform/_io_platform.dart +++ b/dart/lib/src/platform/_io_platform.dart @@ -1,20 +1,3 @@ -import 'dart:io' as io show Platform; +import 'package:platform/platform.dart'; -import 'platform.dart'; - -const Platform instance = IOPlatform(); - -/// [Platform] implementation that delegates directly to `dart:io`. -class IOPlatform extends Platform { - /// Creates a new [IOPlatform]. - const IOPlatform(); - - @override - String get operatingSystem => io.Platform.operatingSystem; - - @override - String get operatingSystemVersion => io.Platform.operatingSystemVersion; - - @override - String get localHostname => io.Platform.localHostname; -} +const Platform instance = LocalPlatform(); diff --git a/dart/lib/src/platform/_web_platform.dart b/dart/lib/src/platform/_web_platform.dart index 97c05815be..7cbe6f3f79 100644 --- a/dart/lib/src/platform/_web_platform.dart +++ b/dart/lib/src/platform/_web_platform.dart @@ -1,7 +1,6 @@ +import 'package:platform/platform.dart'; import 'package:web/web.dart' as web; -import 'platform.dart'; - const Platform instance = WebPlatform(); /// [Platform] implementation that delegates to `dart:web`. @@ -48,4 +47,52 @@ class WebPlatform extends Platform { } return 'android'; } + + @override + // TODO: implement environment + Map get environment => throw UnimplementedError(); + + @override + // TODO: implement executable + String get executable => throw UnimplementedError(); + + @override + // TODO: implement executableArguments + List get executableArguments => throw UnimplementedError(); + + @override + // TODO: implement localeName + String get localeName => throw UnimplementedError(); + + @override + // TODO: implement numberOfProcessors + int get numberOfProcessors => throw UnimplementedError(); + + @override + // TODO: implement packageConfig + String? get packageConfig => throw UnimplementedError(); + + @override + // TODO: implement pathSeparator + String get pathSeparator => throw UnimplementedError(); + + @override + // TODO: implement resolvedExecutable + String get resolvedExecutable => throw UnimplementedError(); + + @override + // TODO: implement script + Uri get script => throw UnimplementedError(); + + @override + // TODO: implement stdinSupportsAnsi + bool get stdinSupportsAnsi => throw UnimplementedError(); + + @override + // TODO: implement stdoutSupportsAnsi + bool get stdoutSupportsAnsi => throw UnimplementedError(); + + @override + // TODO: implement version + String get version => throw UnimplementedError(); } diff --git a/dart/lib/src/platform/platform.dart b/dart/lib/src/platform/platform.dart index e3d5ae9f32..e0a997de53 100644 --- a/dart/lib/src/platform/platform.dart +++ b/dart/lib/src/platform/platform.dart @@ -1,41 +1,6 @@ -import 'dart:typed_data'; +import 'package:platform/platform.dart'; import '_io_platform.dart' if (dart.library.js_interop) '_web_platform.dart' as platform; const Platform instance = platform.instance; - -abstract class Platform { - const Platform(); - - /// A string (`linux`, `macos`, `windows`, `android`, `ios`, or `fuchsia`) - /// representing the operating system. - String get operatingSystem; - - /// A string representing the version of the operating system or platform. - String get operatingSystemVersion; - - /// Get the local hostname for the system. - String get localHostname; - - /// Endianness of this platform. - Endian get endian => Endian.host; - - /// True if the operating system is Linux. - bool get isLinux => (operatingSystem == 'linux'); - - /// True if the operating system is OS X. - bool get isMacOS => (operatingSystem == 'macos'); - - /// True if the operating system is Windows. - bool get isWindows => (operatingSystem == 'windows'); - - /// True if the operating system is Android. - bool get isAndroid => (operatingSystem == 'android'); - - /// True if the operating system is iOS. - bool get isIOS => (operatingSystem == 'ios'); - - /// True if the operating system is Fuchsia - bool get isFuchsia => (operatingSystem == 'fuchsia'); -} diff --git a/dart/lib/src/platform_checker.dart b/dart/lib/src/platform_checker.dart index 884775a95a..45a835d6ff 100644 --- a/dart/lib/src/platform_checker.dart +++ b/dart/lib/src/platform_checker.dart @@ -1,6 +1,6 @@ import 'dart:async'; - -import 'platform/platform.dart'; +import 'package:platform/platform.dart'; +import 'platform/platform.dart' as pf; /// Helper to check in which environment the library is running. /// The environment checks (release/debug/profile) are mutually exclusive. @@ -8,7 +8,7 @@ class PlatformChecker { static const _jsUtil = 'dart.library.js_util'; PlatformChecker({ - this.platform = instance, + this.platform = pf.instance, bool? isWeb, bool? isRootZone, }) : isWeb = isWeb ?? _isWebWithWasmSupport(), diff --git a/dart/lib/src/protocol/sdk_version.dart b/dart/lib/src/protocol/sdk_version.dart index b915fbdde8..ab87f6495f 100644 --- a/dart/lib/src/protocol/sdk_version.dart +++ b/dart/lib/src/protocol/sdk_version.dart @@ -71,6 +71,7 @@ class SdkVersion { final json = AccessAwareMap(data); final packagesJson = json['packages'] as List?; final integrationsJson = json['integrations'] as List?; + integrationsJson.removeLast() return SdkVersion( name: json['name'], version: json['version'], diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index c87c4d0f88..50da18af3e 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: uuid: '>=3.0.0 <5.0.0' collection: ^1.16.0 web: ^1.1.0 + platform: ^3.1.6 dev_dependencies: build_runner: ^2.3.0 diff --git a/dart/test/example_web_compile_test.dart b/dart/test/example_web_compile_test.dart index 20e2509b6f..12906e2968 100644 --- a/dart/test/example_web_compile_test.dart +++ b/dart/test/example_web_compile_test.dart @@ -48,6 +48,7 @@ void main() { } /// Runs [command] with command's stdout and stderr being forwrarded to +/// /// test runner's respective streams. It buffers stdout and returns it. /// /// Returns [_CommandResult] with exitCode and stdout as a single sting diff --git a/dart/test/mocks/mock_platform.dart b/dart/test/mocks/mock_platform.dart index 21dc234b09..26f6f5c8b5 100644 --- a/dart/test/mocks/mock_platform.dart +++ b/dart/test/mocks/mock_platform.dart @@ -1,40 +1,23 @@ -import 'dart:typed_data'; +import 'package:platform/platform.dart'; -import 'package:sentry/src/platform/platform.dart'; - -import 'no_such_method_provider.dart'; - -class MockPlatform extends Platform with NoSuchMethodProvider { - MockPlatform({String? os, Endian? endian}) - : operatingSystem = os ?? '', - endian = endian ?? Endian.host; - - factory MockPlatform.android() { - return MockPlatform(os: 'android'); +extension MockPlatform on FakePlatform { + static Platform android() { + return FakePlatform(operatingSystem: 'android'); } - factory MockPlatform.iOS() { - return MockPlatform(os: 'ios'); + static Platform iOS() { + return FakePlatform(operatingSystem: 'ios'); } - factory MockPlatform.macOS() { - return MockPlatform(os: 'macos'); + static Platform macOS() { + return FakePlatform(operatingSystem: 'macos'); } - factory MockPlatform.linux() { - return MockPlatform(os: 'linux'); + static Platform linux() { + return FakePlatform(operatingSystem: 'linux'); } - factory MockPlatform.windows() { - return MockPlatform(os: 'windows'); + static Platform windows() { + return FakePlatform(operatingSystem: 'windows'); } - - @override - final String operatingSystem; - - @override - final Endian endian; - - @override - String toString() => operatingSystem; } diff --git a/dart/test/mocks/mock_platform_checker.dart b/dart/test/mocks/mock_platform_checker.dart index efb58d6c7a..8cef300026 100644 --- a/dart/test/mocks/mock_platform_checker.dart +++ b/dart/test/mocks/mock_platform_checker.dart @@ -1,4 +1,4 @@ -import 'package:sentry/src/platform/platform.dart'; +import 'package:platform/platform.dart'; import 'package:sentry/src/platform_checker.dart'; import 'no_such_method_provider.dart'; diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index c311d7c2a6..f638d01b97 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -30,6 +30,7 @@ dependencies: collection: ^1.16.0 web: ^1.1.0 jni: 0.14.0 +# platform: ^3.1.6 dev_dependencies: build_runner: ^2.4.2 @@ -48,6 +49,7 @@ dev_dependencies: ref: 6aa2c2642f507eab3df83373189170797a9fa5e7 jnigen: 0.14.0 + platform: any flutter: plugin: platforms: diff --git a/flutter/test/mocks.dart b/flutter/test/mocks.dart index 3dce2bbb60..b25f3a549b 100644 --- a/flutter/test/mocks.dart +++ b/flutter/test/mocks.dart @@ -6,13 +6,13 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:meta/meta.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:sentry/src/platform/platform.dart'; import 'package:sentry/src/sentry_tracer.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/frames_tracking/sentry_delayed_frames_tracker.dart'; import 'package:sentry_flutter/src/native/sentry_native_binding.dart'; import 'package:sentry_flutter/src/renderer/renderer.dart'; import 'package:sentry_flutter/src/web/sentry_js_binding.dart'; +import 'package:platform/platform.dart'; import 'mocks.mocks.dart'; import 'no_such_method_provider.dart'; @@ -59,43 +59,26 @@ ISentrySpan startTransactionShim( ]) void main() {} -class MockPlatform with NoSuchMethodProvider implements Platform { - const MockPlatform(this.operatingSystem, - {this.operatingSystemVersion = '', this.localHostname = ''}); - - const MockPlatform.android() : this('android'); - const MockPlatform.iOs() : this('ios'); - const MockPlatform.macOs() : this('macos'); - const MockPlatform.windows() : this('windows'); - const MockPlatform.linux() : this('linux'); - const MockPlatform.fuchsia() : this('fuchsia'); - - @override - final String operatingSystem; - - @override - final String operatingSystemVersion; - - @override - final String localHostname; - - @override - bool get isLinux => (operatingSystem == 'linux'); - - @override - bool get isMacOS => (operatingSystem == 'macos'); +extension MockPlatform on FakePlatform { + static Platform android() { + return FakePlatform(operatingSystem: 'android'); + } - @override - bool get isWindows => (operatingSystem == 'windows'); + static Platform iOS() { + return FakePlatform(operatingSystem: 'ios'); + } - @override - bool get isAndroid => (operatingSystem == 'android'); + static Platform macOS() { + return FakePlatform(operatingSystem: 'macos'); + } - @override - bool get isIOS => (operatingSystem == 'ios'); + static Platform linux() { + return FakePlatform(operatingSystem: 'linux'); + } - @override - bool get isFuchsia => (operatingSystem == 'fuchsia'); + static Platform windows() { + return FakePlatform(operatingSystem: 'windows'); + } } class MockPlatformChecker with NoSuchMethodProvider implements PlatformChecker { @@ -105,7 +88,7 @@ class MockPlatformChecker with NoSuchMethodProvider implements PlatformChecker { this.hasNativeIntegration = false, this.isRoot = true, Platform? mockPlatform, - }) : _mockPlatform = mockPlatform ?? MockPlatform(''); + }) : _mockPlatform = mockPlatform ?? FakePlatform(operatingSystem: ''); final MockPlatformCheckerBuildMode buildMode; final bool isWebValue; diff --git a/flutter/test/profiling_test.dart b/flutter/test/profiling_test.dart index fb0c4ce905..775123a8e5 100644 --- a/flutter/test/profiling_test.dart +++ b/flutter/test/profiling_test.dart @@ -20,7 +20,7 @@ void main() { group('$SentryNativeProfilerFactory', () { Hub hubWithSampleRate(double profilesSampleRate) { final o = defaultTestOptions(); - o.platformChecker = getPlatformChecker(platform: MockPlatform.iOs()); + o.platformChecker = getPlatformChecker(platform: MockPlatform.iOS()); o.profilesSampleRate = profilesSampleRate; final hub = MockHub(); diff --git a/flutter/test/replay/replay_native_test.dart b/flutter/test/replay/replay_native_test.dart index cb76cec0e6..715061528c 100644 --- a/flutter/test/replay/replay_native_test.dart +++ b/flutter/test/replay/replay_native_test.dart @@ -28,7 +28,7 @@ void main() { for (final mockPlatform in [ MockPlatform.android(), - MockPlatform.iOs(), + MockPlatform.iOS(), ]) { group('$SentryNativeBinding (${mockPlatform.operatingSystem})', () { late SentryNativeBinding sut; diff --git a/flutter/test/sentry_flutter_test.dart b/flutter/test/sentry_flutter_test.dart index 103e240b70..0c70e6aa39 100644 --- a/flutter/test/sentry_flutter_test.dart +++ b/flutter/test/sentry_flutter_test.dart @@ -4,8 +4,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:platform/platform.dart'; import 'package:sentry/src/dart_exception_type_identifier.dart'; -import 'package:sentry/src/platform/platform.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/file_system_transport.dart'; import 'package:sentry_flutter/src/flutter_exception_type_identifier.dart'; @@ -131,7 +131,7 @@ void main() { late final Transport transport; final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOs())) + defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) ..methodChannel = native.channel; await SentryFlutter.init( @@ -185,7 +185,7 @@ void main() { List integrations = []; Transport transport = MockTransport(); final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.macOs())) + defaultTestOptions(getPlatformChecker(platform: MockPlatform.macOS())) ..methodChannel = native.channel; await SentryFlutter.init( @@ -396,7 +396,7 @@ void main() { List integrations = []; Transport transport = MockTransport(); final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOs())) + defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) ..methodChannel = native.channel; // Tests that iOS || macOS integrations aren't added on a browser which @@ -439,7 +439,7 @@ void main() { List integrations = []; Transport transport = MockTransport(); final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.macOs())) + defaultTestOptions(getPlatformChecker(platform: MockPlatform.macOS())) ..methodChannel = native.channel; // Tests that iOS || macOS integrations aren't added on a browser which @@ -531,7 +531,7 @@ void main() { List integrations = []; final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOs())) + defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) ..methodChannel = native.channel ..rendererWrapper = MockRendererWrapper(FlutterRenderer.skia) ..release = '' @@ -558,7 +558,7 @@ void main() { List integrations = []; final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOs())) + defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) ..rendererWrapper = MockRendererWrapper(FlutterRenderer.canvasKit) ..release = '' ..dist = ''; @@ -584,7 +584,7 @@ void main() { List integrations = []; final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOs())) + defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) ..rendererWrapper = MockRendererWrapper(FlutterRenderer.html) ..release = '' ..dist = ''; diff --git a/flutter/test/sentry_native_channel_test.dart b/flutter/test/sentry_native_channel_test.dart index b041e71105..d4c8217ac0 100644 --- a/flutter/test/sentry_native_channel_test.dart +++ b/flutter/test/sentry_native_channel_test.dart @@ -11,8 +11,8 @@ import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/native/factory.dart'; import 'package:sentry_flutter/src/native/method_channel_helper.dart'; import 'package:sentry_flutter/src/native/sentry_native_binding.dart'; -import 'package:sentry/src/platform/platform.dart' as platform; import 'package:sentry_flutter/src/replay/replay_config.dart'; +import 'package:platform/platform.dart'; import 'mocks.dart'; import 'mocks.mocks.dart'; import 'sentry_flutter_test.dart'; @@ -20,8 +20,8 @@ import 'sentry_flutter_test.dart'; void main() { for (var mockPlatform in [ MockPlatform.android(), - MockPlatform.iOs(), - MockPlatform.macOs() + MockPlatform.iOS(), + MockPlatform.macOS() ]) { group('$SentryNativeBinding', () { late SentryNativeBinding sut; @@ -207,7 +207,7 @@ void main() { if (mockPlatform.isAndroid) { matcher = throwsUnsupportedError; } else if (mockPlatform.isIOS || mockPlatform.isMacOS) { - if (platform.instance.isMacOS) { + if (LocalPlatform().isMacOS) { matcher = throwsA(predicate((e) => e is Exception && e.toString().contains('Failed to load Objective-C class'))); diff --git a/min_version_test/pubspec.yaml b/min_version_test/pubspec.yaml index 49a693a6cb..40bcc4a009 100644 --- a/min_version_test/pubspec.yaml +++ b/min_version_test/pubspec.yaml @@ -35,6 +35,7 @@ dependencies: dio: any # This gets constrained by `sentry_dio` logging: any # This gets constrained by `sentry_logging` + flutter: any dev_dependencies: flutter_test: sdk: flutter From b80690da9b5de0d784c0dd201687c1bc7bd0ce37 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 18 Feb 2025 13:57:12 +0100 Subject: [PATCH 02/16] fixes --- dart/lib/src/protocol/sdk_version.dart | 2 +- flutter/pubspec.yaml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dart/lib/src/protocol/sdk_version.dart b/dart/lib/src/protocol/sdk_version.dart index ab87f6495f..a65e29927c 100644 --- a/dart/lib/src/protocol/sdk_version.dart +++ b/dart/lib/src/protocol/sdk_version.dart @@ -71,7 +71,7 @@ class SdkVersion { final json = AccessAwareMap(data); final packagesJson = json['packages'] as List?; final integrationsJson = json['integrations'] as List?; - integrationsJson.removeLast() + return SdkVersion( name: json['name'], version: json['version'], diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index f638d01b97..e9395bb70a 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -30,7 +30,6 @@ dependencies: collection: ^1.16.0 web: ^1.1.0 jni: 0.14.0 -# platform: ^3.1.6 dev_dependencies: build_runner: ^2.4.2 From f18c72b2f6c98eddbd088f6336bf7bbdd8a8bf64 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Tue, 18 Feb 2025 22:44:49 +0100 Subject: [PATCH 03/16] refactor: cleanup platform mocking --- dart/lib/src/platform/_io_platform.dart | 41 +++++++++- dart/lib/src/platform/_web_platform.dart | 76 ++++--------------- dart/lib/src/platform/mock_platform.dart | 42 ++++++++++ dart/lib/src/platform/platform.dart | 7 +- dart/lib/src/platform/platform_interface.dart | 37 +++++++++ dart/lib/src/platform_checker.dart | 24 ++---- dart/lib/src/sentry.dart | 2 +- dart/lib/src/sentry_client.dart | 7 +- dart/lib/src/sentry_options.dart | 3 +- dart/lib/src/sentry_stack_trace_factory.dart | 3 +- .../http_transport_request_handler.dart | 2 +- dart/pubspec.yaml | 1 - ...ad_dart_debug_images_integration_test.dart | 2 +- dart/test/mocks/mock_platform.dart | 23 ------ dart/test/mocks/mock_platform_checker.dart | 7 +- dart/test/sentry_client_test.dart | 5 +- dart/test/sentry_event_test.dart | 8 +- dart/test/sentry_options_test.dart | 2 +- dart/test/stack_trace_test.dart | 10 ++- file/lib/src/sentry_file_extension.dart | 2 +- file/test/mock_platform_checker.dart | 11 --- file/test/sentry_file_extension_test.dart | 5 +- .../flutter_enricher_event_processor.dart | 4 +- .../screenshot_event_processor.dart | 2 +- flutter/lib/src/profiling.dart | 2 +- flutter/lib/src/sentry_flutter.dart | 13 ++-- .../view_hierarchy_integration.dart | 3 +- ...flutter_enricher_event_processor_test.dart | 13 ++-- .../screenshot_event_processor_test.dart | 6 +- flutter/test/mocks.dart | 31 +------- flutter/test/profiling_test.dart | 1 + flutter/test/replay/replay_native_test.dart | 1 + flutter/test/sentry_flutter_test.dart | 6 +- .../sentry_native/sentry_native_test_ffi.dart | 16 ++-- flutter/test/sentry_native_channel_test.dart | 5 +- 35 files changed, 214 insertions(+), 209 deletions(-) create mode 100644 dart/lib/src/platform/mock_platform.dart create mode 100644 dart/lib/src/platform/platform_interface.dart delete mode 100644 dart/test/mocks/mock_platform.dart delete mode 100644 file/test/mock_platform_checker.dart diff --git a/dart/lib/src/platform/_io_platform.dart b/dart/lib/src/platform/_io_platform.dart index b7316e22ab..b885af28c7 100644 --- a/dart/lib/src/platform/_io_platform.dart +++ b/dart/lib/src/platform/_io_platform.dart @@ -1,3 +1,40 @@ -import 'package:platform/platform.dart'; +export 'platform_interface.dart'; -const Platform instance = LocalPlatform(); +import 'platform_interface.dart'; +import 'dart:io' as io; + +const Platform currentPlatform = IOPlatform(); + +/// [Platform] implementation that delegates directly to `dart:io`. +class IOPlatform extends Platform { + const IOPlatform(); + + @override + OperatingSystem get operatingSystem { + switch (io.Platform.operatingSystem) { + case 'macos': + return OperatingSystem.macos; + case 'windows': + return OperatingSystem.windows; + case 'linux': + return OperatingSystem.linux; + case 'android': + return OperatingSystem.android; + case 'ios': + return OperatingSystem.ios; + case 'fuchsia': + return OperatingSystem.fuchsia; + default: + return OperatingSystem.unknown; + } + } + + @override + String? get operatingSystemVersion => io.Platform.operatingSystemVersion; + + @override + String get localHostname => io.Platform.localHostname; + + @override + bool get isWeb => false; +} diff --git a/dart/lib/src/platform/_web_platform.dart b/dart/lib/src/platform/_web_platform.dart index 7cbe6f3f79..1e2a3cf72c 100644 --- a/dart/lib/src/platform/_web_platform.dart +++ b/dart/lib/src/platform/_web_platform.dart @@ -1,40 +1,36 @@ -import 'package:platform/platform.dart'; +export 'platform_interface.dart'; + import 'package:web/web.dart' as web; +import 'platform_interface.dart'; -const Platform instance = WebPlatform(); +const Platform currentPlatform = WebPlatform(); /// [Platform] implementation that delegates to `dart:web`. class WebPlatform extends Platform { - /// Creates a new [Platform]. const WebPlatform(); @override - String get operatingSystem => _browserPlatform(); - - @override - String get operatingSystemVersion => 'unknown'; + bool get isWeb => true; @override - String get localHostname => web.window.location.hostname; - - String _browserPlatform() { + OperatingSystem get operatingSystem { final navigatorPlatform = web.window.navigator.platform.toLowerCase(); if (navigatorPlatform.startsWith('mac')) { - return 'macos'; + return OperatingSystem.macos; } if (navigatorPlatform.startsWith('win')) { - return 'windows'; + return OperatingSystem.windows; } if (navigatorPlatform.contains('iphone') || navigatorPlatform.contains('ipad') || navigatorPlatform.contains('ipod')) { - return 'ios'; + return OperatingSystem.ios; } if (navigatorPlatform.contains('android')) { - return 'android'; + return OperatingSystem.android; } if (navigatorPlatform.contains('fuchsia')) { - return 'fuchsia'; + return OperatingSystem.fuchsia; } // Since some phones can report a window.navigator.platform as Linux, fall @@ -43,56 +39,14 @@ class WebPlatform extends Platform { // pointing device, then we'll assume desktop linux, and otherwise we'll // assume Android. if (web.window.matchMedia('only screen and (pointer: fine)').matches) { - return 'linux'; + return OperatingSystem.linux; } - return 'android'; + return OperatingSystem.android; } @override - // TODO: implement environment - Map get environment => throw UnimplementedError(); - - @override - // TODO: implement executable - String get executable => throw UnimplementedError(); - - @override - // TODO: implement executableArguments - List get executableArguments => throw UnimplementedError(); - - @override - // TODO: implement localeName - String get localeName => throw UnimplementedError(); - - @override - // TODO: implement numberOfProcessors - int get numberOfProcessors => throw UnimplementedError(); + String? get operatingSystemVersion => null; @override - // TODO: implement packageConfig - String? get packageConfig => throw UnimplementedError(); - - @override - // TODO: implement pathSeparator - String get pathSeparator => throw UnimplementedError(); - - @override - // TODO: implement resolvedExecutable - String get resolvedExecutable => throw UnimplementedError(); - - @override - // TODO: implement script - Uri get script => throw UnimplementedError(); - - @override - // TODO: implement stdinSupportsAnsi - bool get stdinSupportsAnsi => throw UnimplementedError(); - - @override - // TODO: implement stdoutSupportsAnsi - bool get stdoutSupportsAnsi => throw UnimplementedError(); - - @override - // TODO: implement version - String get version => throw UnimplementedError(); + String get localHostname => web.window.location.hostname; } diff --git a/dart/lib/src/platform/mock_platform.dart b/dart/lib/src/platform/mock_platform.dart new file mode 100644 index 0000000000..798b5b0e46 --- /dev/null +++ b/dart/lib/src/platform/mock_platform.dart @@ -0,0 +1,42 @@ +import 'platform.dart'; + +class MockPlatform extends Platform { + @override + final bool isWeb; + + @override + final String localHostname; + + @override + final OperatingSystem operatingSystem; + + @override + final String operatingSystemVersion; + + MockPlatform({ + this.operatingSystem = OperatingSystem.unknown, + this.operatingSystemVersion = '', + this.isWeb = false, + this.localHostname = '', + }); + + factory MockPlatform.android() { + return MockPlatform(operatingSystem: OperatingSystem.android); + } + + factory MockPlatform.iOS() { + return MockPlatform(operatingSystem: OperatingSystem.ios); + } + + factory MockPlatform.macOS() { + return MockPlatform(operatingSystem: OperatingSystem.macos); + } + + factory MockPlatform.linux() { + return MockPlatform(operatingSystem: OperatingSystem.linux); + } + + factory MockPlatform.windows() { + return MockPlatform(operatingSystem: OperatingSystem.windows); + } +} diff --git a/dart/lib/src/platform/platform.dart b/dart/lib/src/platform/platform.dart index e0a997de53..6b6db1ad03 100644 --- a/dart/lib/src/platform/platform.dart +++ b/dart/lib/src/platform/platform.dart @@ -1,6 +1 @@ -import 'package:platform/platform.dart'; - -import '_io_platform.dart' if (dart.library.js_interop) '_web_platform.dart' - as platform; - -const Platform instance = platform.instance; +export '_io_platform.dart' if (dart.library.js_interop) '_web_platform.dart'; diff --git a/dart/lib/src/platform/platform_interface.dart b/dart/lib/src/platform/platform_interface.dart new file mode 100644 index 0000000000..e59e0a5792 --- /dev/null +++ b/dart/lib/src/platform/platform_interface.dart @@ -0,0 +1,37 @@ +abstract class Platform { + const Platform(); + + bool get isWeb; + + bool get isLinux => operatingSystem == OperatingSystem.linux; + + bool get isMacOS => operatingSystem == OperatingSystem.macos; + + bool get isWindows => operatingSystem == OperatingSystem.windows; + + bool get isAndroid => operatingSystem == OperatingSystem.android; + + bool get isIOS => operatingSystem == OperatingSystem.ios; + + bool get isFuchsia => operatingSystem == OperatingSystem.fuchsia; + + /// A string (`linux`, `macos`, `windows`, `android`, `ios`, or `fuchsia`) + /// representing the operating system. + OperatingSystem get operatingSystem; + + /// A string representing the version of the operating system or platform. + String? get operatingSystemVersion; + + /// Get the local hostname for the system. + String get localHostname; +} + +enum OperatingSystem { + android, + fuchsia, + ios, + linux, + macos, + windows, + unknown, +} diff --git a/dart/lib/src/platform_checker.dart b/dart/lib/src/platform_checker.dart index 45a835d6ff..0a743a6570 100644 --- a/dart/lib/src/platform_checker.dart +++ b/dart/lib/src/platform_checker.dart @@ -1,18 +1,15 @@ import 'dart:async'; -import 'package:platform/platform.dart'; -import 'platform/platform.dart' as pf; +import 'platform/platform.dart'; /// Helper to check in which environment the library is running. /// The environment checks (release/debug/profile) are mutually exclusive. +// TODO rename this to `RuntimeChecker` or something similar to better represent what it does. +// TODO move `platform` directly to options - that is what we actually access 99 % of the times in tests and lib. class PlatformChecker { - static const _jsUtil = 'dart.library.js_util'; - PlatformChecker({ - this.platform = pf.instance, - bool? isWeb, + this.platform = currentPlatform, bool? isRootZone, - }) : isWeb = isWeb ?? _isWebWithWasmSupport(), - isRootZone = isRootZone ?? Zone.current == Zone.root; + }) : isRootZone = isRootZone ?? Zone.current == Zone.root; /// Check if running in release/production environment bool isReleaseMode() { @@ -29,7 +26,6 @@ class PlatformChecker { return const bool.fromEnvironment('dart.vm.profile', defaultValue: false); } - final bool isWeb; final bool isRootZone; String get compileMode { @@ -40,21 +36,15 @@ class PlatformChecker { : 'profile'; } + // TODO remove this check - it should be handled by the native integration... also, it's actually always true... /// Indicates whether a native integration is available. bool get hasNativeIntegration => - isWeb || + platform.isWeb || platform.isAndroid || platform.isIOS || platform.isMacOS || platform.isWindows || platform.isLinux; - static bool _isWebWithWasmSupport() { - if (const bool.hasEnvironment(_jsUtil)) { - return const bool.fromEnvironment(_jsUtil); - } - return identical(0, 0.0); - } - final Platform platform; } diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 9660cd3255..20bb748d67 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -87,7 +87,7 @@ class Sentry { _setEnvironmentVariables(options); // Throws when running on the browser - if (!options.platformChecker.isWeb) { + if (!options.platformChecker.platform.isWeb) { // catch any errors that may occur within the entry function, main() // in the ‘root zone’ where all Dart programs start options.addIntegrationByIndex(0, IsolateErrorIntegration()); diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index b5328f1821..bcaafc771c 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -64,7 +64,7 @@ class SentryClient { ); // TODO: Use spotlight integration directly through JS SDK, then we can remove isWeb check final enableFlutterSpotlight = (options.spotlight.enabled && - (options.platformChecker.isWeb || + (options.platformChecker.platform.isWeb || options.platformChecker.platform.isLinux || options.platformChecker.platform.isWindows)); // Spotlight in the Flutter layer is only enabled for Web, Linux and Windows @@ -211,7 +211,8 @@ class SentryClient { environment: event.environment ?? _options.environment, release: event.release ?? _options.release, sdk: event.sdk ?? _options.sdk, - platform: event.platform ?? sdkPlatform(_options.platformChecker.isWeb), + platform: event.platform ?? + sdkPlatform(_options.platformChecker.platform.isWeb), ); if (event is SentryTransaction) { @@ -246,7 +247,7 @@ class SentryClient { SentryThread? sentryThread; - if (!_options.platformChecker.isWeb && + if (!_options.platformChecker.platform.isWeb && isolateName != null && _options.attachThreads) { sentryException = sentryException.copyWith(threadId: isolateId); diff --git a/dart/lib/src/sentry_options.dart b/dart/lib/src/sentry_options.dart index 41fae90eaa..427f96b86b 100644 --- a/dart/lib/src/sentry_options.dart +++ b/dart/lib/src/sentry_options.dart @@ -499,7 +499,8 @@ class SentryOptions { if (checker != null) { platformChecker = checker; } - sdk = SdkVersion(name: sdkName(platformChecker.isWeb), version: sdkVersion); + sdk = SdkVersion( + name: sdkName(platformChecker.platform.isWeb), version: sdkVersion); sdk.addPackage('pub:sentry', sdkVersion); } diff --git a/dart/lib/src/sentry_stack_trace_factory.dart b/dart/lib/src/sentry_stack_trace_factory.dart index 36c93e5fc0..766ce4a4e0 100644 --- a/dart/lib/src/sentry_stack_trace_factory.dart +++ b/dart/lib/src/sentry_stack_trace_factory.dart @@ -127,7 +127,8 @@ class SentryStackTraceFactory { SentryLevel.debug, "Failed to parse stack frame: $member"); } - final platform = _options.platformChecker.isWeb ? 'javascript' : 'dart'; + final platform = + _options.platformChecker.platform.isWeb ? 'javascript' : 'dart'; final fileName = frame.uri.pathSegments.isNotEmpty ? frame.uri.pathSegments.last : null; final abs = '$eventOrigin${_absolutePathForCrashReport(frame)}'; diff --git a/dart/lib/src/transport/http_transport_request_handler.dart b/dart/lib/src/transport/http_transport_request_handler.dart index e30d71570f..fb5db8f1ce 100644 --- a/dart/lib/src/transport/http_transport_request_handler.dart +++ b/dart/lib/src/transport/http_transport_request_handler.dart @@ -19,7 +19,7 @@ class HttpTransportRequestHandler { HttpTransportRequestHandler(this._options, this._requestUri) : _dsn = _options.parsedDsn, _headers = _buildHeaders( - _options.platformChecker.isWeb, + _options.platformChecker.platform.isWeb, _options.sentryClientName, ) { _credentialBuilder = _CredentialBuilder( diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index 50da18af3e..c87c4d0f88 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -26,7 +26,6 @@ dependencies: uuid: '>=3.0.0 <5.0.0' collection: ^1.16.0 web: ^1.1.0 - platform: ^3.1.6 dev_dependencies: build_runner: ^2.3.0 diff --git a/dart/test/load_dart_debug_images_integration_test.dart b/dart/test/load_dart_debug_images_integration_test.dart index 4b1309607d..d172169c1c 100644 --- a/dart/test/load_dart_debug_images_integration_test.dart +++ b/dart/test/load_dart_debug_images_integration_test.dart @@ -5,10 +5,10 @@ import 'dart:async'; import 'package:sentry/sentry.dart'; import 'package:sentry/src/load_dart_debug_images_integration.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry/src/sentry_stack_trace_factory.dart'; import 'package:test/test.dart'; -import 'mocks/mock_platform.dart'; import 'mocks/mock_platform_checker.dart'; import 'test_utils.dart'; diff --git a/dart/test/mocks/mock_platform.dart b/dart/test/mocks/mock_platform.dart deleted file mode 100644 index 26f6f5c8b5..0000000000 --- a/dart/test/mocks/mock_platform.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:platform/platform.dart'; - -extension MockPlatform on FakePlatform { - static Platform android() { - return FakePlatform(operatingSystem: 'android'); - } - - static Platform iOS() { - return FakePlatform(operatingSystem: 'ios'); - } - - static Platform macOS() { - return FakePlatform(operatingSystem: 'macos'); - } - - static Platform linux() { - return FakePlatform(operatingSystem: 'linux'); - } - - static Platform windows() { - return FakePlatform(operatingSystem: 'windows'); - } -} diff --git a/dart/test/mocks/mock_platform_checker.dart b/dart/test/mocks/mock_platform_checker.dart index 8cef300026..d110ba1281 100644 --- a/dart/test/mocks/mock_platform_checker.dart +++ b/dart/test/mocks/mock_platform_checker.dart @@ -1,4 +1,4 @@ -import 'package:platform/platform.dart'; +import 'package:sentry/src/platform/platform.dart'; import 'package:sentry/src/platform_checker.dart'; import 'no_such_method_provider.dart'; @@ -8,7 +8,6 @@ class MockPlatformChecker extends PlatformChecker with NoSuchMethodProvider { this.isDebug = false, this.isProfile = false, this.isRelease = false, - this.isWebValue = false, this.hasNativeIntegration = false, Platform? platform, }) : _platform = platform; @@ -18,7 +17,6 @@ class MockPlatformChecker extends PlatformChecker with NoSuchMethodProvider { final bool isDebug; final bool isProfile; final bool isRelease; - final bool isWebValue; @override bool hasNativeIntegration = false; @@ -32,9 +30,6 @@ class MockPlatformChecker extends PlatformChecker with NoSuchMethodProvider { @override bool isReleaseMode() => isRelease; - @override - bool get isWeb => isWebValue; - @override Platform get platform => _platform ?? super.platform; } diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 21d7be7279..0a1cd462a7 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -6,6 +6,7 @@ import 'package:collection/collection.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry/src/client_reports/discard_reason.dart'; import 'package:sentry/src/client_reports/noop_client_report_recorder.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry/src/sentry_item_type.dart'; import 'package:sentry/src/sentry_stack_trace_factory.dart'; import 'package:sentry/src/sentry_tracer.dart'; @@ -19,7 +20,6 @@ import 'package:test/test.dart'; import 'mocks.dart'; import 'mocks/mock_client_report_recorder.dart'; import 'mocks/mock_hub.dart'; -import 'mocks/mock_platform.dart'; import 'mocks/mock_platform_checker.dart'; import 'mocks/mock_transport.dart'; import 'test_utils.dart'; @@ -1905,7 +1905,8 @@ void main() { test( 'Spotlight enabled should set transport to SpotlightHttpTransport on Web', () async { - fixture.options.platformChecker = MockPlatformChecker(isWebValue: true); + fixture.options.platformChecker = + MockPlatformChecker(platform: MockPlatform(isWeb: true)); fixture.options.spotlight = Spotlight(enabled: true); fixture.getSut(); diff --git a/dart/test/sentry_event_test.dart b/dart/test/sentry_event_test.dart index fe9d3b4d48..8c82415f6a 100644 --- a/dart/test/sentry_event_test.dart +++ b/dart/test/sentry_event_test.dart @@ -135,7 +135,7 @@ void main() { final event = SentryEvent( eventId: SentryId.empty(), timestamp: DateTime.utc(2019), - platform: sdkPlatform(platformChecker.isWeb), + platform: sdkPlatform(platformChecker.platform.isWeb), sdk: SdkVersion( name: 'sentry.dart.flutter', version: '4.3.2', @@ -146,7 +146,7 @@ void main() { ), ); expect(event.toJson(), { - 'platform': platformChecker.isWeb ? 'javascript' : 'other', + 'platform': platformChecker.platform.isWeb ? 'javascript' : 'other', 'event_id': '00000000000000000000000000000000', 'timestamp': '2019-01-01T00:00:00.000Z', 'sdk': { @@ -190,7 +190,7 @@ void main() { SentryEvent( eventId: SentryId.empty(), timestamp: timestamp, - platform: sdkPlatform(platformChecker.isWeb), + platform: sdkPlatform(platformChecker.platform.isWeb), message: SentryMessage( 'test-message 1 2', template: 'test-message %d %d', @@ -239,7 +239,7 @@ void main() { unknown: testUnknown) .toJson(), { - 'platform': platformChecker.isWeb ? 'javascript' : 'other', + 'platform': platformChecker.platform.isWeb ? 'javascript' : 'other', 'event_id': '00000000000000000000000000000000', 'timestamp': '2019-01-01T00:00:00.000Z', 'message': { diff --git a/dart/test/sentry_options_test.dart b/dart/test/sentry_options_test.dart index 9a8bfe5153..32d39dcf97 100644 --- a/dart/test/sentry_options_test.dart +++ b/dart/test/sentry_options_test.dart @@ -98,7 +98,7 @@ void main() { final options = defaultTestOptions(); expect(options.sentryClientName, - '${sdkName(options.platformChecker.isWeb)}/$sdkVersion'); + '${sdkName(options.platformChecker.platform.isWeb)}/$sdkVersion'); }); test('SentryOptions has default idleTimeout', () { diff --git a/dart/test/stack_trace_test.dart b/dart/test/stack_trace_test.dart index 9e38eef032..40e568f2fe 100644 --- a/dart/test/stack_trace_test.dart +++ b/dart/test/stack_trace_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'package:sentry/src/origin.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry/src/sentry_stack_trace_factory.dart'; import 'package:stack_trace/stack_trace.dart'; import 'package:test/test.dart'; @@ -284,13 +285,15 @@ isolate_instructions: 10fa27070, vm_instructions: 10fa21e20 final fixture = Fixture(); // Test for web platform - fixture.options.platformChecker = MockPlatformChecker(isWebValue: true); + fixture.options.platformChecker = + MockPlatformChecker(platform: MockPlatform(isWeb: true)); final webSut = fixture.getSut(); var webFrame = webSut.encodeStackTraceFrame(frame)!; expect(webFrame.platform, 'javascript'); // Test for non-web platform - fixture.options.platformChecker = MockPlatformChecker(isWebValue: false); + fixture.options.platformChecker = + MockPlatformChecker(platform: MockPlatform(isWeb: false)); final nativeFrameBeforeSut = fixture.getSut(); var nativeFrameBefore = nativeFrameBeforeSut.encodeStackTraceFrame(frame)!; @@ -307,7 +310,8 @@ isolate_instructions: 10fa27070, vm_instructions: 10fa21e20 } class Fixture { - final options = defaultTestOptions(MockPlatformChecker(isWebValue: false)); + final options = defaultTestOptions( + MockPlatformChecker(platform: MockPlatform(isWeb: false))); SentryStackTraceFactory getSut({ List inAppIncludes = const [], diff --git a/file/lib/src/sentry_file_extension.dart b/file/lib/src/sentry_file_extension.dart index 2ddb327605..7945954bcb 100644 --- a/file/lib/src/sentry_file_extension.dart +++ b/file/lib/src/sentry_file_extension.dart @@ -30,7 +30,7 @@ extension SentryFileExtension on File { File sentryTrace({@internal Hub? hub}) { final _hub = hub ?? HubAdapter(); - if (_hub.options.platformChecker.isWeb || + if (_hub.options.platformChecker.platform.isWeb || !_hub.options.isTracingEnabled()) { return this; } diff --git a/file/test/mock_platform_checker.dart b/file/test/mock_platform_checker.dart deleted file mode 100644 index 6dd95a5c06..0000000000 --- a/file/test/mock_platform_checker.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'no_such_method_provider.dart'; -import 'package:sentry/src/platform_checker.dart'; - -class MockPlatformChecker extends PlatformChecker with NoSuchMethodProvider { - MockPlatformChecker(this._isWeb); - - final bool _isWeb; - - @override - bool get isWeb => _isWeb; -} diff --git a/file/test/sentry_file_extension_test.dart b/file/test/sentry_file_extension_test.dart index b56ab335be..ab770953b2 100644 --- a/file/test/sentry_file_extension_test.dart +++ b/file/test/sentry_file_extension_test.dart @@ -5,10 +5,10 @@ import 'dart:io'; import 'package:sentry/sentry.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry_file/sentry_file.dart'; import 'package:test/test.dart'; -import 'mock_platform_checker.dart'; import 'mock_sentry_client.dart'; void main() { @@ -55,7 +55,8 @@ class Fixture { bool isWeb = false, }) { options.tracesSampleRate = tracesSampleRate; - options.platformChecker = MockPlatformChecker(isWeb); + options.platformChecker = + PlatformChecker(platform: MockPlatform(isWeb: isWeb)); hub = Hub(options); diff --git a/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart b/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart index 1c5a5faba3..3865e5864a 100644 --- a/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart +++ b/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart @@ -40,7 +40,7 @@ class FlutterEnricherEventProcessor implements EventProcessor { // information available than Flutter. // TODO: while we have a native integration with JS SDK, it's currently opt in and we dont gather contexts yet // so for web it's still better to rely on the information of Flutter. - final device = _hasNativeIntegration && !_checker.isWeb + final device = _hasNativeIntegration && !_checker.platform.isWeb ? null : _getDevice(event.contexts.device); @@ -209,7 +209,7 @@ class FlutterEnricherEventProcessor implements EventProcessor { // See // - https://flutter.dev/docs/testing/build-modes // - https://github.com/flutter/flutter/wiki/Flutter%27s-modes - if (_checker.isWeb) { + if (_checker.platform.isWeb) { if (_checker.isDebugMode()) { compiler = 'dartdevc'; } else if (_checker.isReleaseMode() || _checker.isProfileMode()) { diff --git a/flutter/lib/src/event_processor/screenshot_event_processor.dart b/flutter/lib/src/event_processor/screenshot_event_processor.dart index 2526a19db3..b06cdd96e7 100644 --- a/flutter/lib/src/event_processor/screenshot_event_processor.dart +++ b/flutter/lib/src/event_processor/screenshot_event_processor.dart @@ -92,7 +92,7 @@ class ScreenshotEventProcessor implements EventProcessor { final renderer = _options.rendererWrapper.getRenderer(); - if (_options.platformChecker.isWeb && + if (_options.platformChecker.platform.isWeb && renderer != FlutterRenderer.canvasKit) { _options.logger( SentryLevel.debug, diff --git a/flutter/lib/src/profiling.dart b/flutter/lib/src/profiling.dart index e2bca9af17..6e7c309fcc 100644 --- a/flutter/lib/src/profiling.dart +++ b/flutter/lib/src/profiling.dart @@ -26,7 +26,7 @@ class SentryNativeProfilerFactory implements SentryProfilerFactory { return; } - if (options.platformChecker.isWeb) { + if (options.platformChecker.platform.isWeb) { return; } diff --git a/flutter/lib/src/sentry_flutter.dart b/flutter/lib/src/sentry_flutter.dart index 2bf9de35c4..d78fb35c8d 100644 --- a/flutter/lib/src/sentry_flutter.dart +++ b/flutter/lib/src/sentry_flutter.dart @@ -74,7 +74,7 @@ mixin SentryFlutter { // Flutter Web doesn't capture [Future] errors if using [PlatformDispatcher.onError] and not // the [runZonedGuarded]. // likely due to https://github.com/flutter/flutter/issues/100277 - final isOnErrorSupported = !options.platformChecker.isWeb; + final isOnErrorSupported = !options.platformChecker.platform.isWeb; final bool isRootZone = options.platformChecker.isRootZone; @@ -126,13 +126,13 @@ mixin SentryFlutter { // Not all platforms have a native integration. if (_native != null) { if (_native!.supportsCaptureEnvelope) { - if (options.platformChecker.isWeb) { + if (options.platformChecker.platform.isWeb) { options.transport = JavascriptTransport(_native!, options); } else { options.transport = FileSystemTransport(_native!, options); } } - if (!options.platformChecker.isWeb) { + if (!options.platformChecker.platform.isWeb) { options.addScopeObserver(NativeScopeObserver(_native!)); } } @@ -180,7 +180,7 @@ mixin SentryFlutter { final native = _native; if (native != null) { integrations.add(createSdkIntegration(native)); - if (!platformChecker.isWeb) { + if (!platformChecker.platform.isWeb) { if (native.supportsLoadContexts) { integrations.add(LoadContextsIntegration(native)); } @@ -198,11 +198,12 @@ mixin SentryFlutter { } final renderer = options.rendererWrapper.getRenderer(); - if (!platformChecker.isWeb || renderer == FlutterRenderer.canvasKit) { + if (!platformChecker.platform.isWeb || + renderer == FlutterRenderer.canvasKit) { integrations.add(ScreenshotIntegration()); } - if (platformChecker.isWeb) { + if (platformChecker.platform.isWeb) { integrations.add(ConnectivityIntegration()); } diff --git a/flutter/lib/src/view_hierarchy/view_hierarchy_integration.dart b/flutter/lib/src/view_hierarchy/view_hierarchy_integration.dart index a86f380f08..8d2d9f7b19 100644 --- a/flutter/lib/src/view_hierarchy/view_hierarchy_integration.dart +++ b/flutter/lib/src/view_hierarchy/view_hierarchy_integration.dart @@ -13,7 +13,8 @@ class SentryViewHierarchyIntegration void call(Hub hub, SentryFlutterOptions options) { // View hierarchy is always minified on Web and we don't support // symbolication of source maps for view hierarchy yet. - if (!options.attachViewHierarchy || options.platformChecker.isWeb) { + if (!options.attachViewHierarchy || + options.platformChecker.platform.isWeb) { return; } _options = options; diff --git a/flutter/test/event_processor/flutter_enricher_event_processor_test.dart b/flutter/test/event_processor/flutter_enricher_event_processor_test.dart index 6f82a6e6b2..0ba1b4864e 100644 --- a/flutter/test/event_processor/flutter_enricher_event_processor_test.dart +++ b/flutter/test/event_processor/flutter_enricher_event_processor_test.dart @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/event_processor/flutter_enricher_event_processor.dart'; @@ -223,22 +224,22 @@ void main() { testWidgets('adds correct flutter runtime', (WidgetTester tester) async { final checkerMap = { MockPlatformChecker( - isWebValue: false, + mockPlatform: MockPlatform(isWeb: false), buildMode: MockPlatformCheckerBuildMode.debug): 'Dart VM', MockPlatformChecker( - isWebValue: false, + mockPlatform: MockPlatform(isWeb: false), buildMode: MockPlatformCheckerBuildMode.profile): 'Dart AOT', MockPlatformChecker( - isWebValue: false, + mockPlatform: MockPlatform(isWeb: false), buildMode: MockPlatformCheckerBuildMode.release): 'Dart AOT', MockPlatformChecker( - isWebValue: true, + mockPlatform: MockPlatform(isWeb: true), buildMode: MockPlatformCheckerBuildMode.debug): 'dartdevc', MockPlatformChecker( - isWebValue: true, + mockPlatform: MockPlatform(isWeb: true), buildMode: MockPlatformCheckerBuildMode.profile): 'dart2js', MockPlatformChecker( - isWebValue: true, + mockPlatform: MockPlatform(isWeb: true), buildMode: MockPlatformCheckerBuildMode.release): 'dart2js', }; diff --git a/flutter/test/event_processor/screenshot_event_processor_test.dart b/flutter/test/event_processor/screenshot_event_processor_test.dart index 515def4fe2..31ea8231dc 100644 --- a/flutter/test/event_processor/screenshot_event_processor_test.dart +++ b/flutter/test/event_processor/screenshot_event_processor_test.dart @@ -6,11 +6,12 @@ import 'dart:ui'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry_flutter/src/event_processor/screenshot_event_processor.dart'; import 'package:sentry_flutter/src/renderer/renderer.dart'; -import '../mocks.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +import '../mocks.dart'; import '../replay/replay_test_util.dart'; void main() { @@ -349,7 +350,8 @@ class Fixture { ScreenshotEventProcessor getSut( FlutterRenderer? flutterRenderer, bool isWeb) { options.rendererWrapper = MockRendererWrapper(flutterRenderer); - options.platformChecker = MockPlatformChecker(isWebValue: isWeb); + options.platformChecker = + MockPlatformChecker(mockPlatform: MockPlatform(isWeb: isWeb)); return ScreenshotEventProcessor(options); } } diff --git a/flutter/test/mocks.dart b/flutter/test/mocks.dart index b25f3a549b..7f69f89eba 100644 --- a/flutter/test/mocks.dart +++ b/flutter/test/mocks.dart @@ -12,7 +12,7 @@ import 'package:sentry_flutter/src/frames_tracking/sentry_delayed_frames_tracker import 'package:sentry_flutter/src/native/sentry_native_binding.dart'; import 'package:sentry_flutter/src/renderer/renderer.dart'; import 'package:sentry_flutter/src/web/sentry_js_binding.dart'; -import 'package:platform/platform.dart'; +import 'package:sentry/src/platform/platform.dart'; import 'mocks.mocks.dart'; import 'no_such_method_provider.dart'; @@ -59,39 +59,15 @@ ISentrySpan startTransactionShim( ]) void main() {} -extension MockPlatform on FakePlatform { - static Platform android() { - return FakePlatform(operatingSystem: 'android'); - } - - static Platform iOS() { - return FakePlatform(operatingSystem: 'ios'); - } - - static Platform macOS() { - return FakePlatform(operatingSystem: 'macos'); - } - - static Platform linux() { - return FakePlatform(operatingSystem: 'linux'); - } - - static Platform windows() { - return FakePlatform(operatingSystem: 'windows'); - } -} - class MockPlatformChecker with NoSuchMethodProvider implements PlatformChecker { MockPlatformChecker({ this.buildMode = MockPlatformCheckerBuildMode.debug, - this.isWebValue = false, this.hasNativeIntegration = false, this.isRoot = true, Platform? mockPlatform, - }) : _mockPlatform = mockPlatform ?? FakePlatform(operatingSystem: ''); + }) : _mockPlatform = mockPlatform ?? currentPlatform; final MockPlatformCheckerBuildMode buildMode; - final bool isWebValue; final bool isRoot; final Platform _mockPlatform; @@ -110,9 +86,6 @@ class MockPlatformChecker with NoSuchMethodProvider implements PlatformChecker { @override bool get isRootZone => isRoot; - @override - bool get isWeb => isWebValue; - @override Platform get platform => _mockPlatform; } diff --git a/flutter/test/profiling_test.dart b/flutter/test/profiling_test.dart index 775123a8e5..8d4135e4f0 100644 --- a/flutter/test/profiling_test.dart +++ b/flutter/test/profiling_test.dart @@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/profiling.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'mocks.dart'; import 'mocks.mocks.dart'; import 'sentry_flutter_test.dart'; diff --git a/flutter/test/replay/replay_native_test.dart b/flutter/test/replay/replay_native_test.dart index 715061528c..d763726f77 100644 --- a/flutter/test/replay/replay_native_test.dart +++ b/flutter/test/replay/replay_native_test.dart @@ -8,6 +8,7 @@ import 'dart:async'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/native/factory.dart'; import 'android_replay_recorder_web.dart' // see https://github.com/flutter/flutter/issues/160675 diff --git a/flutter/test/sentry_flutter_test.dart b/flutter/test/sentry_flutter_test.dart index 0c70e6aa39..79599d0adb 100644 --- a/flutter/test/sentry_flutter_test.dart +++ b/flutter/test/sentry_flutter_test.dart @@ -1,10 +1,10 @@ // ignore_for_file: invalid_use_of_internal_member -import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:package_info_plus/package_info_plus.dart'; -import 'package:platform/platform.dart'; +import 'package:sentry/src/platform/platform.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry/src/dart_exception_type_identifier.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/file_system_transport.dart'; @@ -761,12 +761,10 @@ void loadTestPackage() { PlatformChecker getPlatformChecker({ required Platform platform, - bool isWeb = kIsWeb, bool isRootZone = true, }) { final platformChecker = PlatformChecker( platform: platform, - isWeb: isWeb, isRootZone: isRootZone, ); return platformChecker; diff --git a/flutter/test/sentry_native/sentry_native_test_ffi.dart b/flutter/test/sentry_native/sentry_native_test_ffi.dart index 0cdd67ca5f..d500ee1880 100644 --- a/flutter/test/sentry_native/sentry_native_test_ffi.dart +++ b/flutter/test/sentry_native/sentry_native_test_ffi.dart @@ -34,12 +34,13 @@ void main() { setUpAll(() async { late final List expectedDistFiles; if (backend.actualValue == NativeBackend.crashpad) { - expectedDistFiles = platform.instance.isWindows + expectedDistFiles = platform.currentPlatform.isWindows ? ['sentry.dll', 'crashpad_handler.exe', 'crashpad_wer.dll'] : ['libsentry.so', 'crashpad_handler']; } else { - expectedDistFiles = - platform.instance.isWindows ? ['sentry.dll'] : ['libsentry.so']; + expectedDistFiles = platform.currentPlatform.isWindows + ? ['sentry.dll'] + : ['libsentry.so']; } helper = NativeTestHelper( @@ -246,10 +247,11 @@ void main() { test('loadDebugImages', () async { final list = await sut.loadDebugImages(SentryStackTrace(frames: [])); expect(list, isNotEmpty); - expect(list![0].type, platform.instance.isWindows ? 'pe' : 'elf'); + expect( + list![0].type, platform.currentPlatform.isWindows ? 'pe' : 'elf'); expect(list[0].debugId!.length, greaterThan(30)); expect(list[0].debugFile, - platform.instance.isWindows ? isNotEmpty : isNull); + platform.currentPlatform.isWindows ? isNotEmpty : isNull); expect(list[0].imageSize, greaterThan(0)); expect(list[0].imageAddr, startsWith('0x')); expect(list[0].imageAddr?.length, greaterThan(2)); @@ -314,7 +316,7 @@ int main(int argc, char *argv[]) { return 0; } File('$cmakeConfDir/CMakeLists.txt').writeAsStringSync(''' cmake_minimum_required(VERSION 3.14) project(sentry-native-flutter-test) -add_subdirectory(../../../${platform.instance.operatingSystem} plugin) +add_subdirectory(../../../${platform.currentPlatform.operatingSystem.name} plugin) add_executable(\${CMAKE_PROJECT_NAME} main.c) target_link_libraries(\${CMAKE_PROJECT_NAME} PRIVATE sentry_flutter_plugin) @@ -333,7 +335,7 @@ set(CMAKE_INSTALL_PREFIX "${buildOutputDir.replaceAll('\\', '/')}") '--config', 'Release', ]); - if (platform.instance.isLinux && + if (platform.currentPlatform.isLinux && nativeBackend.actualValue == NativeBackend.crashpad) { await _exec('chmod', ['+x', '$buildOutputDir/crashpad_handler']); } diff --git a/flutter/test/sentry_native_channel_test.dart b/flutter/test/sentry_native_channel_test.dart index d4c8217ac0..ced93896f1 100644 --- a/flutter/test/sentry_native_channel_test.dart +++ b/flutter/test/sentry_native_channel_test.dart @@ -7,12 +7,13 @@ import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; +import 'package:sentry/src/platform/platform.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/native/factory.dart'; import 'package:sentry_flutter/src/native/method_channel_helper.dart'; import 'package:sentry_flutter/src/native/sentry_native_binding.dart'; import 'package:sentry_flutter/src/replay/replay_config.dart'; -import 'package:platform/platform.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'mocks.dart'; import 'mocks.mocks.dart'; import 'sentry_flutter_test.dart'; @@ -207,7 +208,7 @@ void main() { if (mockPlatform.isAndroid) { matcher = throwsUnsupportedError; } else if (mockPlatform.isIOS || mockPlatform.isMacOS) { - if (LocalPlatform().isMacOS) { + if (currentPlatform.isMacOS) { matcher = throwsA(predicate((e) => e is Exception && e.toString().contains('Failed to load Objective-C class'))); From a863fae0285fa48b57a63a81ba1a5741de9a4281 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Tue, 18 Feb 2025 22:52:25 +0100 Subject: [PATCH 04/16] cleanup --- dart/lib/src/platform/_io_platform.dart | 5 +-- dart/lib/src/platform/_web_platform.dart | 5 +-- dart/lib/src/platform/platform.dart | 43 ++++++++++++++++++- dart/lib/src/platform/platform_interface.dart | 37 ---------------- 4 files changed, 46 insertions(+), 44 deletions(-) delete mode 100644 dart/lib/src/platform/platform_interface.dart diff --git a/dart/lib/src/platform/_io_platform.dart b/dart/lib/src/platform/_io_platform.dart index b885af28c7..d4808f8fcb 100644 --- a/dart/lib/src/platform/_io_platform.dart +++ b/dart/lib/src/platform/_io_platform.dart @@ -1,8 +1,7 @@ -export 'platform_interface.dart'; - -import 'platform_interface.dart'; import 'dart:io' as io; +import 'platform.dart'; + const Platform currentPlatform = IOPlatform(); /// [Platform] implementation that delegates directly to `dart:io`. diff --git a/dart/lib/src/platform/_web_platform.dart b/dart/lib/src/platform/_web_platform.dart index 1e2a3cf72c..75b250c533 100644 --- a/dart/lib/src/platform/_web_platform.dart +++ b/dart/lib/src/platform/_web_platform.dart @@ -1,7 +1,6 @@ -export 'platform_interface.dart'; - import 'package:web/web.dart' as web; -import 'platform_interface.dart'; + +import 'platform.dart'; const Platform currentPlatform = WebPlatform(); diff --git a/dart/lib/src/platform/platform.dart b/dart/lib/src/platform/platform.dart index 6b6db1ad03..e33c09f73f 100644 --- a/dart/lib/src/platform/platform.dart +++ b/dart/lib/src/platform/platform.dart @@ -1 +1,42 @@ -export '_io_platform.dart' if (dart.library.js_interop) '_web_platform.dart'; +import '_io_platform.dart' if (dart.library.js_interop) '_web_platform.dart' + as platform; + +const Platform currentPlatform = platform.currentPlatform; + +abstract class Platform { + const Platform(); + + bool get isWeb; + + bool get isLinux => operatingSystem == OperatingSystem.linux; + + bool get isMacOS => operatingSystem == OperatingSystem.macos; + + bool get isWindows => operatingSystem == OperatingSystem.windows; + + bool get isAndroid => operatingSystem == OperatingSystem.android; + + bool get isIOS => operatingSystem == OperatingSystem.ios; + + bool get isFuchsia => operatingSystem == OperatingSystem.fuchsia; + + /// A string (`linux`, `macos`, `windows`, `android`, `ios`, or `fuchsia`) + /// representing the operating system. + OperatingSystem get operatingSystem; + + /// A string representing the version of the operating system or platform. + String? get operatingSystemVersion; + + /// Get the local hostname for the system. + String get localHostname; +} + +enum OperatingSystem { + android, + fuchsia, + ios, + linux, + macos, + windows, + unknown, +} diff --git a/dart/lib/src/platform/platform_interface.dart b/dart/lib/src/platform/platform_interface.dart deleted file mode 100644 index e59e0a5792..0000000000 --- a/dart/lib/src/platform/platform_interface.dart +++ /dev/null @@ -1,37 +0,0 @@ -abstract class Platform { - const Platform(); - - bool get isWeb; - - bool get isLinux => operatingSystem == OperatingSystem.linux; - - bool get isMacOS => operatingSystem == OperatingSystem.macos; - - bool get isWindows => operatingSystem == OperatingSystem.windows; - - bool get isAndroid => operatingSystem == OperatingSystem.android; - - bool get isIOS => operatingSystem == OperatingSystem.ios; - - bool get isFuchsia => operatingSystem == OperatingSystem.fuchsia; - - /// A string (`linux`, `macos`, `windows`, `android`, `ios`, or `fuchsia`) - /// representing the operating system. - OperatingSystem get operatingSystem; - - /// A string representing the version of the operating system or platform. - String? get operatingSystemVersion; - - /// Get the local hostname for the system. - String get localHostname; -} - -enum OperatingSystem { - android, - fuchsia, - ios, - linux, - macos, - windows, - unknown, -} From fd173e5e1a5b7393e4f4b41db98ce443935359aa Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 19 Feb 2025 12:42:59 +0100 Subject: [PATCH 05/16] remove fake platform checker --- dart/test/fake_platform_checker.dart | 41 ---------------------------- dart/test/sentry_test.dart | 11 ++++---- 2 files changed, 5 insertions(+), 47 deletions(-) delete mode 100644 dart/test/fake_platform_checker.dart diff --git a/dart/test/fake_platform_checker.dart b/dart/test/fake_platform_checker.dart deleted file mode 100644 index 928a0be2de..0000000000 --- a/dart/test/fake_platform_checker.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:sentry/src/platform_checker.dart'; - -/// Fake class to be used in unit tests for mocking different environments -class FakePlatformChecker extends PlatformChecker { - FakePlatformChecker.releaseMode() { - _releaseMode = true; - _debugMode = false; - _profileMode = false; - } - - FakePlatformChecker.debugMode() { - _releaseMode = false; - _debugMode = true; - _profileMode = false; - } - - FakePlatformChecker.profileMode() { - _releaseMode = false; - _debugMode = false; - _profileMode = true; - } - - late bool _releaseMode; - late bool _debugMode; - late bool _profileMode; - - @override - bool isReleaseMode() { - return _releaseMode; - } - - @override - bool isDebugMode() { - return _debugMode; - } - - @override - bool isProfileMode() { - return _profileMode; - } -} diff --git a/dart/test/sentry_test.dart b/dart/test/sentry_test.dart index 2acc385ce3..4bcd6a7cae 100644 --- a/dart/test/sentry_test.dart +++ b/dart/test/sentry_test.dart @@ -5,7 +5,6 @@ import 'package:sentry/src/dart_exception_type_identifier.dart'; import 'package:sentry/src/event_processor/deduplication_event_processor.dart'; import 'package:test/test.dart'; -import 'fake_platform_checker.dart'; import 'mocks.dart'; import 'mocks/mock_integration.dart'; import 'mocks/mock_platform_checker.dart'; @@ -443,7 +442,7 @@ void main() { }); test('options.environment debug', () async { - final sentryOptions = defaultTestOptions(FakePlatformChecker.debugMode()); + final sentryOptions = defaultTestOptions(MockPlatformChecker(isDebug: true)); await Sentry.init( (options) { options.dsn = fakeDsn; @@ -455,7 +454,7 @@ void main() { }); test('options.environment profile', () async { - final sentryOptions = defaultTestOptions(FakePlatformChecker.profileMode()); + final sentryOptions = defaultTestOptions(MockPlatformChecker(isProfile: true)); await Sentry.init( (options) { @@ -468,7 +467,7 @@ void main() { }); test('options.environment production (defaultEnvironment)', () async { - final sentryOptions = defaultTestOptions(FakePlatformChecker.releaseMode()); + final sentryOptions = defaultTestOptions(MockPlatformChecker(isRelease: true)); await Sentry.init( (options) { options.dsn = fakeDsn; @@ -480,7 +479,7 @@ void main() { }); test('options.logger is set by setting the debug flag', () async { - final sentryOptions = defaultTestOptions(FakePlatformChecker.debugMode()); + final sentryOptions = defaultTestOptions(MockPlatformChecker(isDebug: true)); await Sentry.init( (options) { @@ -507,7 +506,7 @@ void main() { test('throw is handled and logged', () async { // Use release mode in platform checker to avoid additional log final sentryOptions = - defaultTestOptions(FakePlatformChecker.releaseMode()) + defaultTestOptions(MockPlatformChecker(isRelease: true)) ..automatedTestMode = false ..debug = true ..logger = fixture.mockLogger; From d68f74bbdf2fed437fca840ad9cf7d29a81145a6 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 19 Feb 2025 13:12:08 +0100 Subject: [PATCH 06/16] fix: mockplatform should use defaults based on the current platform --- dart/lib/src/platform/_io_platform.dart | 10 ++-------- dart/lib/src/platform/_web_platform.dart | 10 ++-------- dart/lib/src/platform/mock_platform.dart | 22 +++++++++++----------- dart/lib/src/platform/platform.dart | 18 +++--------------- 4 files changed, 18 insertions(+), 42 deletions(-) diff --git a/dart/lib/src/platform/_io_platform.dart b/dart/lib/src/platform/_io_platform.dart index d4808f8fcb..fa8f0f5ea2 100644 --- a/dart/lib/src/platform/_io_platform.dart +++ b/dart/lib/src/platform/_io_platform.dart @@ -2,13 +2,10 @@ import 'dart:io' as io; import 'platform.dart'; -const Platform currentPlatform = IOPlatform(); - /// [Platform] implementation that delegates directly to `dart:io`. -class IOPlatform extends Platform { - const IOPlatform(); +class PlatformBase { + const PlatformBase(); - @override OperatingSystem get operatingSystem { switch (io.Platform.operatingSystem) { case 'macos': @@ -28,12 +25,9 @@ class IOPlatform extends Platform { } } - @override String? get operatingSystemVersion => io.Platform.operatingSystemVersion; - @override String get localHostname => io.Platform.localHostname; - @override bool get isWeb => false; } diff --git a/dart/lib/src/platform/_web_platform.dart b/dart/lib/src/platform/_web_platform.dart index 75b250c533..56325fa25b 100644 --- a/dart/lib/src/platform/_web_platform.dart +++ b/dart/lib/src/platform/_web_platform.dart @@ -2,16 +2,12 @@ import 'package:web/web.dart' as web; import 'platform.dart'; -const Platform currentPlatform = WebPlatform(); - /// [Platform] implementation that delegates to `dart:web`. -class WebPlatform extends Platform { - const WebPlatform(); +class PlatformBase { + const PlatformBase(); - @override bool get isWeb => true; - @override OperatingSystem get operatingSystem { final navigatorPlatform = web.window.navigator.platform.toLowerCase(); if (navigatorPlatform.startsWith('mac')) { @@ -43,9 +39,7 @@ class WebPlatform extends Platform { return OperatingSystem.android; } - @override String? get operatingSystemVersion => null; - @override String get localHostname => web.window.location.hostname; } diff --git a/dart/lib/src/platform/mock_platform.dart b/dart/lib/src/platform/mock_platform.dart index 798b5b0e46..6192a9d31e 100644 --- a/dart/lib/src/platform/mock_platform.dart +++ b/dart/lib/src/platform/mock_platform.dart @@ -2,23 +2,23 @@ import 'platform.dart'; class MockPlatform extends Platform { @override - final bool isWeb; + late final bool isWeb; @override - final String localHostname; + late final OperatingSystem operatingSystem; @override - final OperatingSystem operatingSystem; - - @override - final String operatingSystemVersion; + late final String? operatingSystemVersion; MockPlatform({ - this.operatingSystem = OperatingSystem.unknown, - this.operatingSystemVersion = '', - this.isWeb = false, - this.localHostname = '', - }); + OperatingSystem? operatingSystem, + String? operatingSystemVersion, + bool? isWeb, + }) { + this.isWeb = isWeb ?? super.isWeb; + this.operatingSystem = operatingSystem ?? super.operatingSystem; + this.operatingSystemVersion = operatingSystemVersion ?? super.operatingSystemVersion; + } factory MockPlatform.android() { return MockPlatform(operatingSystem: OperatingSystem.android); diff --git a/dart/lib/src/platform/platform.dart b/dart/lib/src/platform/platform.dart index e33c09f73f..5ff5d54aff 100644 --- a/dart/lib/src/platform/platform.dart +++ b/dart/lib/src/platform/platform.dart @@ -1,13 +1,11 @@ import '_io_platform.dart' if (dart.library.js_interop) '_web_platform.dart' - as platform; + as impl; -const Platform currentPlatform = platform.currentPlatform; +const currentPlatform = Platform(); -abstract class Platform { +class Platform extends impl.PlatformBase { const Platform(); - bool get isWeb; - bool get isLinux => operatingSystem == OperatingSystem.linux; bool get isMacOS => operatingSystem == OperatingSystem.macos; @@ -19,16 +17,6 @@ abstract class Platform { bool get isIOS => operatingSystem == OperatingSystem.ios; bool get isFuchsia => operatingSystem == OperatingSystem.fuchsia; - - /// A string (`linux`, `macos`, `windows`, `android`, `ios`, or `fuchsia`) - /// representing the operating system. - OperatingSystem get operatingSystem; - - /// A string representing the version of the operating system or platform. - String? get operatingSystemVersion; - - /// Get the local hostname for the system. - String get localHostname; } enum OperatingSystem { From 3f9f74907957ffea6fefc7dc2962bafaa9c41a35 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 19 Feb 2025 14:19:31 +0100 Subject: [PATCH 07/16] default to isWeb: false in mockplatform factories --- dart/lib/src/platform/mock_platform.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dart/lib/src/platform/mock_platform.dart b/dart/lib/src/platform/mock_platform.dart index 6192a9d31e..a60af6a4a4 100644 --- a/dart/lib/src/platform/mock_platform.dart +++ b/dart/lib/src/platform/mock_platform.dart @@ -21,22 +21,22 @@ class MockPlatform extends Platform { } factory MockPlatform.android() { - return MockPlatform(operatingSystem: OperatingSystem.android); + return MockPlatform(operatingSystem: OperatingSystem.android, isWeb: false); } factory MockPlatform.iOS() { - return MockPlatform(operatingSystem: OperatingSystem.ios); + return MockPlatform(operatingSystem: OperatingSystem.ios, isWeb: false); } factory MockPlatform.macOS() { - return MockPlatform(operatingSystem: OperatingSystem.macos); + return MockPlatform(operatingSystem: OperatingSystem.macos, isWeb: false); } factory MockPlatform.linux() { - return MockPlatform(operatingSystem: OperatingSystem.linux); + return MockPlatform(operatingSystem: OperatingSystem.linux, isWeb: false); } factory MockPlatform.windows() { - return MockPlatform(operatingSystem: OperatingSystem.windows); + return MockPlatform(operatingSystem: OperatingSystem.windows, isWeb: false); } } From fa462dab2e62df7a86b6a838663e29df3ec21332 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 19 Feb 2025 16:01:03 +0100 Subject: [PATCH 08/16] fix: web tests --- dart/lib/src/platform/mock_platform.dart | 20 +++++++------- flutter/test/sentry_flutter_test.dart | 34 ++++++++++++------------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/dart/lib/src/platform/mock_platform.dart b/dart/lib/src/platform/mock_platform.dart index a60af6a4a4..9402f42a9c 100644 --- a/dart/lib/src/platform/mock_platform.dart +++ b/dart/lib/src/platform/mock_platform.dart @@ -20,23 +20,23 @@ class MockPlatform extends Platform { this.operatingSystemVersion = operatingSystemVersion ?? super.operatingSystemVersion; } - factory MockPlatform.android() { - return MockPlatform(operatingSystem: OperatingSystem.android, isWeb: false); + factory MockPlatform.android({bool isWeb = false}) { + return MockPlatform(operatingSystem: OperatingSystem.android, isWeb: isWeb); } - factory MockPlatform.iOS() { - return MockPlatform(operatingSystem: OperatingSystem.ios, isWeb: false); + factory MockPlatform.iOS({bool isWeb = false}) { + return MockPlatform(operatingSystem: OperatingSystem.ios, isWeb: isWeb); } - factory MockPlatform.macOS() { - return MockPlatform(operatingSystem: OperatingSystem.macos, isWeb: false); + factory MockPlatform.macOS({bool isWeb = false}) { + return MockPlatform(operatingSystem: OperatingSystem.macos, isWeb: isWeb); } - factory MockPlatform.linux() { - return MockPlatform(operatingSystem: OperatingSystem.linux, isWeb: false); + factory MockPlatform.linux({bool isWeb = false}) { + return MockPlatform(operatingSystem: OperatingSystem.linux, isWeb: isWeb); } - factory MockPlatform.windows() { - return MockPlatform(operatingSystem: OperatingSystem.windows, isWeb: false); + factory MockPlatform.windows({bool isWeb = false}) { + return MockPlatform(operatingSystem: OperatingSystem.windows, isWeb: isWeb); } } diff --git a/flutter/test/sentry_flutter_test.dart b/flutter/test/sentry_flutter_test.dart index 79599d0adb..1fc683ffa4 100644 --- a/flutter/test/sentry_flutter_test.dart +++ b/flutter/test/sentry_flutter_test.dart @@ -323,9 +323,9 @@ void main() { test('Web', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.linux())) - ..methodChannel = native.channel; + final sentryFlutterOptions = defaultTestOptions( + getPlatformChecker(platform: MockPlatform.linux(isWeb: true))) + ..methodChannel = native.channel; await SentryFlutter.init( (options) async { @@ -369,8 +369,8 @@ void main() { }, testOn: 'browser'); test('Web (custom zone)', () async { - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.linux(), isRootZone: false)) + final sentryFlutterOptions = defaultTestOptions(getPlatformChecker( + platform: MockPlatform(isWeb: true), isRootZone: false)) ..methodChannel = native.channel; await SentryFlutter.init( @@ -395,9 +395,9 @@ void main() { test('Web && (iOS || macOS)', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) - ..methodChannel = native.channel; + final sentryFlutterOptions = defaultTestOptions( + getPlatformChecker(platform: MockPlatform.iOS(isWeb: true))) + ..methodChannel = native.channel; // Tests that iOS || macOS integrations aren't added on a browser which // runs on iOS or macOS @@ -438,9 +438,9 @@ void main() { test('Web && (macOS)', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.macOS())) - ..methodChannel = native.channel; + final sentryFlutterOptions = defaultTestOptions( + getPlatformChecker(platform: MockPlatform.macOS(isWeb: true))) + ..methodChannel = native.channel; // Tests that iOS || macOS integrations aren't added on a browser which // runs on iOS or macOS @@ -483,7 +483,7 @@ void main() { List integrations = []; Transport transport = MockTransport(); final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.android())) + getPlatformChecker(platform: MockPlatform.android(isWeb: true))) ..methodChannel = native.channel; // Tests that Android integrations aren't added on an Android browser @@ -583,11 +583,11 @@ void main() { test('not installed with html renderer', () async { List integrations = []; - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) - ..rendererWrapper = MockRendererWrapper(FlutterRenderer.html) - ..release = '' - ..dist = ''; + final sentryFlutterOptions = defaultTestOptions( + getPlatformChecker(platform: MockPlatform.iOS(isWeb: true))) + ..rendererWrapper = MockRendererWrapper(FlutterRenderer.html) + ..release = '' + ..dist = ''; await SentryFlutter.init( (options) async { From 504be25477d2b51d067627ca863730fd496d709a Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 19 Feb 2025 16:01:18 +0100 Subject: [PATCH 09/16] formatting --- dart/lib/src/platform/mock_platform.dart | 3 ++- dart/test/sentry_test.dart | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dart/lib/src/platform/mock_platform.dart b/dart/lib/src/platform/mock_platform.dart index 9402f42a9c..6e43d0a754 100644 --- a/dart/lib/src/platform/mock_platform.dart +++ b/dart/lib/src/platform/mock_platform.dart @@ -17,7 +17,8 @@ class MockPlatform extends Platform { }) { this.isWeb = isWeb ?? super.isWeb; this.operatingSystem = operatingSystem ?? super.operatingSystem; - this.operatingSystemVersion = operatingSystemVersion ?? super.operatingSystemVersion; + this.operatingSystemVersion = + operatingSystemVersion ?? super.operatingSystemVersion; } factory MockPlatform.android({bool isWeb = false}) { diff --git a/dart/test/sentry_test.dart b/dart/test/sentry_test.dart index 4bcd6a7cae..5e68e7c05d 100644 --- a/dart/test/sentry_test.dart +++ b/dart/test/sentry_test.dart @@ -442,7 +442,8 @@ void main() { }); test('options.environment debug', () async { - final sentryOptions = defaultTestOptions(MockPlatformChecker(isDebug: true)); + final sentryOptions = + defaultTestOptions(MockPlatformChecker(isDebug: true)); await Sentry.init( (options) { options.dsn = fakeDsn; @@ -454,7 +455,8 @@ void main() { }); test('options.environment profile', () async { - final sentryOptions = defaultTestOptions(MockPlatformChecker(isProfile: true)); + final sentryOptions = + defaultTestOptions(MockPlatformChecker(isProfile: true)); await Sentry.init( (options) { @@ -467,7 +469,8 @@ void main() { }); test('options.environment production (defaultEnvironment)', () async { - final sentryOptions = defaultTestOptions(MockPlatformChecker(isRelease: true)); + final sentryOptions = + defaultTestOptions(MockPlatformChecker(isRelease: true)); await Sentry.init( (options) { options.dsn = fakeDsn; @@ -479,7 +482,8 @@ void main() { }); test('options.logger is set by setting the debug flag', () async { - final sentryOptions = defaultTestOptions(MockPlatformChecker(isDebug: true)); + final sentryOptions = + defaultTestOptions(MockPlatformChecker(isDebug: true)); await Sentry.init( (options) { From 68e3fb88d9eab33d5552525dc85a6c0e28f16b61 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 24 Feb 2025 19:39:39 +0100 Subject: [PATCH 10/16] move platfomr out of paltform checker --- .../enricher/io_platform_memory.dart | 8 +- .../load_dart_debug_images_integration.dart | 2 +- dart/lib/src/platform/mock_platform.dart | 19 +- dart/lib/src/platform/platform.dart | 4 +- dart/lib/src/platform_checker.dart | 14 - dart/lib/src/sentry.dart | 2 +- dart/lib/src/sentry_client.dart | 11 +- dart/lib/src/sentry_options.dart | 11 +- dart/lib/src/sentry_stack_trace_factory.dart | 3 +- .../http_transport_request_handler.dart | 2 +- .../enricher/io_enricher_test.dart | 7 +- .../enricher/web_enricher_test.dart | 6 +- ...ad_dart_debug_images_integration_test.dart | 8 +- dart/test/mocks/mock_platform_checker.dart | 13 +- dart/test/sentry_client_test.dart | 25 +- dart/test/sentry_event_test.dart | 13 +- dart/test/sentry_options_test.dart | 2 +- dart/test/sentry_test.dart | 10 +- dart/test/stack_trace_test.dart | 10 +- dart/test/test_utils.dart | 6 +- file/lib/src/sentry_file_extension.dart | 3 +- file/test/sentry_file_extension_test.dart | 3 +- .../flutter_enricher_event_processor.dart | 6 +- .../screenshot_event_processor.dart | 3 +- .../load_image_list_integration.dart | 2 +- .../src/native/cocoa/sentry_native_cocoa.dart | 2 +- flutter/lib/src/native/factory_real.dart | 2 +- flutter/lib/src/profiling.dart | 5 +- flutter/lib/src/sentry_flutter.dart | 19 +- flutter/lib/src/sentry_flutter_options.dart | 4 +- .../view_hierarchy_integration.dart | 3 +- ...flutter_enricher_event_processor_test.dart | 99 +- .../screenshot_event_processor_test.dart | 3 +- .../debug_print_integration_test.dart | 9 +- .../integrations/init_native_sdk_test.dart | 3 +- flutter/test/mocks.dart | 17 +- flutter/test/mocks.mocks.dart | 2907 ++++++++--------- flutter/test/profiling_test.dart | 3 +- flutter/test/replay/replay_native_test.dart | 8 +- .../sentry_screenshot_widget_test.mocks.dart | 7 +- flutter/test/sentry_flutter_options_test.dart | 8 +- flutter/test/sentry_flutter_test.dart | 101 +- .../sentry_native/sentry_native_test_ffi.dart | 21 +- flutter/test/sentry_native_channel_test.dart | 9 +- 44 files changed, 1588 insertions(+), 1835 deletions(-) diff --git a/dart/lib/src/event_processor/enricher/io_platform_memory.dart b/dart/lib/src/event_processor/enricher/io_platform_memory.dart index 1f4a32987b..5820859f0a 100644 --- a/dart/lib/src/event_processor/enricher/io_platform_memory.dart +++ b/dart/lib/src/event_processor/enricher/io_platform_memory.dart @@ -11,9 +11,9 @@ class PlatformMemory { final SentryOptions options; int? getTotalPhysicalMemory() { - if (options.platformChecker.platform.isLinux) { + if (options.platform.isLinux) { return _getLinuxMemInfoValue('MemTotal'); - } else if (options.platformChecker.platform.isWindows) { + } else if (options.platform.isWindows) { return _getWindowsWmicValue('ComputerSystem', 'TotalPhysicalMemory'); } else { return null; @@ -21,9 +21,9 @@ class PlatformMemory { } int? getFreePhysicalMemory() { - if (options.platformChecker.platform.isLinux) { + if (options.platform.isLinux) { return _getLinuxMemInfoValue('MemFree'); - } else if (options.platformChecker.platform.isWindows) { + } else if (options.platform.isWindows) { return _getWindowsWmicValue('OS', 'FreePhysicalMemory'); } else { return null; diff --git a/dart/lib/src/load_dart_debug_images_integration.dart b/dart/lib/src/load_dart_debug_images_integration.dart index c271c6232a..66d33996c0 100644 --- a/dart/lib/src/load_dart_debug_images_integration.dart +++ b/dart/lib/src/load_dart_debug_images_integration.dart @@ -91,7 +91,7 @@ class LoadImageIntegrationEventProcessor implements EventProcessor { // It doesn't need to exist and is not used for symbolication. late final String codeFile; - final platform = _options.platformChecker.platform; + final platform = _options.platform; if (platform.isAndroid || platform.isWindows) { type = 'elf'; diff --git a/dart/lib/src/platform/mock_platform.dart b/dart/lib/src/platform/mock_platform.dart index 6e43d0a754..99b3ef81cc 100644 --- a/dart/lib/src/platform/mock_platform.dart +++ b/dart/lib/src/platform/mock_platform.dart @@ -10,15 +10,20 @@ class MockPlatform extends Platform { @override late final String? operatingSystemVersion; - MockPlatform({ - OperatingSystem? operatingSystem, - String? operatingSystemVersion, - bool? isWeb, - }) { + @override + late final bool supportsNativeIntegration; + + MockPlatform( + {OperatingSystem? operatingSystem, + String? operatingSystemVersion, + bool? isWeb, + bool? supportsNativeIntegration}) { this.isWeb = isWeb ?? super.isWeb; this.operatingSystem = operatingSystem ?? super.operatingSystem; this.operatingSystemVersion = operatingSystemVersion ?? super.operatingSystemVersion; + this.supportsNativeIntegration = + supportsNativeIntegration ?? super.supportsNativeIntegration; } factory MockPlatform.android({bool isWeb = false}) { @@ -40,4 +45,8 @@ class MockPlatform extends Platform { factory MockPlatform.windows({bool isWeb = false}) { return MockPlatform(operatingSystem: OperatingSystem.windows, isWeb: isWeb); } + + factory MockPlatform.fuchsia({bool isWeb = false}) { + return MockPlatform(operatingSystem: OperatingSystem.fuchsia, isWeb: isWeb); + } } diff --git a/dart/lib/src/platform/platform.dart b/dart/lib/src/platform/platform.dart index 5ff5d54aff..ea0ed3fdf7 100644 --- a/dart/lib/src/platform/platform.dart +++ b/dart/lib/src/platform/platform.dart @@ -1,8 +1,6 @@ import '_io_platform.dart' if (dart.library.js_interop) '_web_platform.dart' as impl; -const currentPlatform = Platform(); - class Platform extends impl.PlatformBase { const Platform(); @@ -17,6 +15,8 @@ class Platform extends impl.PlatformBase { bool get isIOS => operatingSystem == OperatingSystem.ios; bool get isFuchsia => operatingSystem == OperatingSystem.fuchsia; + + bool get supportsNativeIntegration => !isFuchsia; } enum OperatingSystem { diff --git a/dart/lib/src/platform_checker.dart b/dart/lib/src/platform_checker.dart index 0a743a6570..2fa5487ad7 100644 --- a/dart/lib/src/platform_checker.dart +++ b/dart/lib/src/platform_checker.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'platform/platform.dart'; /// Helper to check in which environment the library is running. /// The environment checks (release/debug/profile) are mutually exclusive. @@ -7,7 +6,6 @@ import 'platform/platform.dart'; // TODO move `platform` directly to options - that is what we actually access 99 % of the times in tests and lib. class PlatformChecker { PlatformChecker({ - this.platform = currentPlatform, bool? isRootZone, }) : isRootZone = isRootZone ?? Zone.current == Zone.root; @@ -35,16 +33,4 @@ class PlatformChecker { ? 'debug' : 'profile'; } - - // TODO remove this check - it should be handled by the native integration... also, it's actually always true... - /// Indicates whether a native integration is available. - bool get hasNativeIntegration => - platform.isWeb || - platform.isAndroid || - platform.isIOS || - platform.isMacOS || - platform.isWindows || - platform.isLinux; - - final Platform platform; } diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 20bb748d67..0033fbb3a1 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -87,7 +87,7 @@ class Sentry { _setEnvironmentVariables(options); // Throws when running on the browser - if (!options.platformChecker.platform.isWeb) { + if (!options.platform.isWeb) { // catch any errors that may occur within the entry function, main() // in the ‘root zone’ where all Dart programs start options.addIntegrationByIndex(0, IsolateErrorIntegration()); diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index 5471c15a88..20bbbd5c9a 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -67,9 +67,9 @@ class SentryClient { ); // TODO: Use spotlight integration directly through JS SDK, then we can remove isWeb check final enableFlutterSpotlight = (options.spotlight.enabled && - (options.platformChecker.platform.isWeb || - options.platformChecker.platform.isLinux || - options.platformChecker.platform.isWindows)); + (options.platform.isWeb || + options.platform.isLinux || + options.platform.isWindows)); // Spotlight in the Flutter layer is only enabled for Web, Linux and Windows // Other platforms use spotlight through their native SDKs if (enableFlutterSpotlight) { @@ -214,8 +214,7 @@ class SentryClient { environment: event.environment ?? _options.environment, release: event.release ?? _options.release, sdk: event.sdk ?? _options.sdk, - platform: event.platform ?? - sdkPlatform(_options.platformChecker.platform.isWeb), + platform: event.platform ?? sdkPlatform(_options.platform.isWeb), ); if (event is SentryTransaction) { @@ -250,7 +249,7 @@ class SentryClient { SentryThread? sentryThread; - if (!_options.platformChecker.platform.isWeb && + if (!_options.platform.isWeb && isolateName != null && _options.attachThreads) { sentryException = sentryException.copyWith(threadId: isolateId); diff --git a/dart/lib/src/sentry_options.dart b/dart/lib/src/sentry_options.dart index 427f96b86b..02e223664d 100644 --- a/dart/lib/src/sentry_options.dart +++ b/dart/lib/src/sentry_options.dart @@ -10,6 +10,7 @@ import 'client_reports/noop_client_report_recorder.dart'; import 'diagnostic_logger.dart'; import 'environment/environment_variables.dart'; import 'noop_client.dart'; +import 'platform/platform.dart'; import 'sentry_exception_factory.dart'; import 'sentry_stack_trace_factory.dart'; import 'transport/noop_transport.dart'; @@ -275,6 +276,8 @@ class SentryOptions { /// This is useful in tests. Should be an implementation of [PlatformChecker]. PlatformChecker platformChecker = PlatformChecker(); + Platform platform = Platform(); + /// If [environmentVariables] is provided, it is used get the environment /// variables. This is useful in tests. EnvironmentVariables environmentVariables = EnvironmentVariables.instance(); @@ -494,13 +497,15 @@ class SentryOptions { /// iOS only supports http proxies, while macOS also supports socks. SentryProxy? proxy; - SentryOptions({String? dsn, PlatformChecker? checker}) { + SentryOptions({String? dsn, Platform? platform, PlatformChecker? checker}) { this.dsn = dsn; + if (platform != null) { + this.platform = platform; + } if (checker != null) { platformChecker = checker; } - sdk = SdkVersion( - name: sdkName(platformChecker.platform.isWeb), version: sdkVersion); + sdk = SdkVersion(name: sdkName(this.platform.isWeb), version: sdkVersion); sdk.addPackage('pub:sentry', sdkVersion); } diff --git a/dart/lib/src/sentry_stack_trace_factory.dart b/dart/lib/src/sentry_stack_trace_factory.dart index 766ce4a4e0..431e065ed9 100644 --- a/dart/lib/src/sentry_stack_trace_factory.dart +++ b/dart/lib/src/sentry_stack_trace_factory.dart @@ -127,8 +127,7 @@ class SentryStackTraceFactory { SentryLevel.debug, "Failed to parse stack frame: $member"); } - final platform = - _options.platformChecker.platform.isWeb ? 'javascript' : 'dart'; + final platform = _options.platform.isWeb ? 'javascript' : 'dart'; final fileName = frame.uri.pathSegments.isNotEmpty ? frame.uri.pathSegments.last : null; final abs = '$eventOrigin${_absolutePathForCrashReport(frame)}'; diff --git a/dart/lib/src/transport/http_transport_request_handler.dart b/dart/lib/src/transport/http_transport_request_handler.dart index fb5db8f1ce..9d1bdd44f4 100644 --- a/dart/lib/src/transport/http_transport_request_handler.dart +++ b/dart/lib/src/transport/http_transport_request_handler.dart @@ -19,7 +19,7 @@ class HttpTransportRequestHandler { HttpTransportRequestHandler(this._options, this._requestUri) : _dsn = _options.parsedDsn, _headers = _buildHeaders( - _options.platformChecker.platform.isWeb, + _options.platform.isWeb, _options.sentryClientName, ) { _credentialBuilder = _CredentialBuilder( diff --git a/dart/test/event_processor/enricher/io_enricher_test.dart b/dart/test/event_processor/enricher/io_enricher_test.dart index 593e9afe99..38bb60e3e1 100644 --- a/dart/test/event_processor/enricher/io_enricher_test.dart +++ b/dart/test/event_processor/enricher/io_enricher_test.dart @@ -5,10 +5,10 @@ import 'dart:io'; import 'package:sentry/sentry.dart'; import 'package:sentry/src/event_processor/enricher/io_enricher_event_processor.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:test/test.dart'; import '../../mocks.dart'; -import '../../mocks/mock_platform_checker.dart'; import '../../test_utils.dart'; void main() { @@ -255,8 +255,9 @@ class Fixture { bool hasNativeIntegration = false, bool includePii = false, }) { - final options = defaultTestOptions( - MockPlatformChecker(hasNativeIntegration: hasNativeIntegration)) + final options = defaultTestOptions() + ..platform = + hasNativeIntegration ? MockPlatform.iOS() : MockPlatform.fuchsia() ..sendDefaultPii = includePii; return IoEnricherEventProcessor(options); diff --git a/dart/test/event_processor/enricher/web_enricher_test.dart b/dart/test/event_processor/enricher/web_enricher_test.dart index ae27ecc392..1c3639ec42 100644 --- a/dart/test/event_processor/enricher/web_enricher_test.dart +++ b/dart/test/event_processor/enricher/web_enricher_test.dart @@ -3,10 +3,10 @@ library; import 'package:sentry/sentry.dart'; import 'package:sentry/src/event_processor/enricher/web_enricher_event_processor.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:test/test.dart'; import '../../mocks.dart'; -import '../../mocks/mock_platform_checker.dart'; import '../../test_utils.dart'; // can be tested on command line with @@ -200,8 +200,8 @@ void main() { class Fixture { WebEnricherEventProcessor getSut() { - final options = - defaultTestOptions(MockPlatformChecker(hasNativeIntegration: false)); + final options = defaultTestOptions() + ..platform = MockPlatform.fuchsia(); // Does not have native integration return enricherEventProcessor(options) as WebEnricherEventProcessor; } } diff --git a/dart/test/load_dart_debug_images_integration_test.dart b/dart/test/load_dart_debug_images_integration_test.dart index d172169c1c..966dec2e69 100644 --- a/dart/test/load_dart_debug_images_integration_test.dart +++ b/dart/test/load_dart_debug_images_integration_test.dart @@ -9,7 +9,6 @@ import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry/src/sentry_stack_trace_factory.dart'; import 'package:test/test.dart'; -import 'mocks/mock_platform_checker.dart'; import 'test_utils.dart'; void main() { @@ -26,8 +25,7 @@ void main() { setUp(() { fixture = Fixture(); - fixture.options.platformChecker = - MockPlatformChecker(platform: platform); + fixture.options.platform = platform; }); test('adds itself to sdk.integrations', () { @@ -193,9 +191,7 @@ isolate_dso_base: 10000000 } test('debug image is null on unsupported platforms', () async { - final fixture = Fixture() - ..options.platformChecker = - MockPlatformChecker(platform: MockPlatform.linux()); + final fixture = Fixture()..options.platform = MockPlatform.linux(); final event = fixture.newEvent(stackTrace: fixture.parse(''' *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** build_id: 'b680cb890f9e3c12a24b172d050dec73' diff --git a/dart/test/mocks/mock_platform_checker.dart b/dart/test/mocks/mock_platform_checker.dart index d110ba1281..ecef1ec8be 100644 --- a/dart/test/mocks/mock_platform_checker.dart +++ b/dart/test/mocks/mock_platform_checker.dart @@ -1,4 +1,3 @@ -import 'package:sentry/src/platform/platform.dart'; import 'package:sentry/src/platform_checker.dart'; import 'no_such_method_provider.dart'; @@ -8,19 +7,12 @@ class MockPlatformChecker extends PlatformChecker with NoSuchMethodProvider { this.isDebug = false, this.isProfile = false, this.isRelease = false, - this.hasNativeIntegration = false, - Platform? platform, - }) : _platform = platform; - - final Platform? _platform; + }); final bool isDebug; final bool isProfile; final bool isRelease; - @override - bool hasNativeIntegration = false; - @override bool isDebugMode() => isDebug; @@ -29,7 +21,4 @@ class MockPlatformChecker extends PlatformChecker with NoSuchMethodProvider { @override bool isReleaseMode() => isRelease; - - @override - Platform get platform => _platform ?? super.platform; } diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index d350b57d67..d605a2b86b 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -20,7 +20,6 @@ import 'package:test/test.dart'; import 'mocks.dart'; import 'mocks/mock_client_report_recorder.dart'; import 'mocks/mock_hub.dart'; -import 'mocks/mock_platform_checker.dart'; import 'mocks/mock_transport.dart'; import 'test_utils.dart'; @@ -1906,9 +1905,7 @@ void main() { test( 'Spotlight enabled should not set transport to SpotlightHttpTransport on iOS', () async { - fixture.options.platformChecker = MockPlatformChecker( - platform: MockPlatform.iOS(), - ); + fixture.options.platform = MockPlatform.iOS(); fixture.options.spotlight = Spotlight(enabled: true); fixture.getSut(); @@ -1918,9 +1915,7 @@ void main() { test( 'Spotlight enabled should not set transport to SpotlightHttpTransport on macOS', () async { - fixture.options.platformChecker = MockPlatformChecker( - platform: MockPlatform.macOS(), - ); + fixture.options.platform = MockPlatform.macOS(); fixture.options.spotlight = Spotlight(enabled: true); fixture.getSut(); @@ -1930,9 +1925,7 @@ void main() { test( 'Spotlight enabled should not set transport to SpotlightHttpTransport on Android', () async { - fixture.options.platformChecker = MockPlatformChecker( - platform: MockPlatform.android(), - ); + fixture.options.platform = MockPlatform.android(); fixture.options.spotlight = Spotlight(enabled: true); fixture.getSut(); @@ -1942,8 +1935,7 @@ void main() { test( 'Spotlight enabled should set transport to SpotlightHttpTransport on Web', () async { - fixture.options.platformChecker = - MockPlatformChecker(platform: MockPlatform(isWeb: true)); + fixture.options.platform = MockPlatform(isWeb: true); fixture.options.spotlight = Spotlight(enabled: true); fixture.getSut(); @@ -1953,8 +1945,7 @@ void main() { test( 'Spotlight enabled should set transport to SpotlightHttpTransport on Linux', () async { - fixture.options.platformChecker = - MockPlatformChecker(platform: MockPlatform.linux()); + fixture.options.platform = MockPlatform.linux(); fixture.options.spotlight = Spotlight(enabled: true); fixture.getSut(); @@ -1964,8 +1955,7 @@ void main() { test( 'Spotlight enabled should set transport to SpotlightHttpTransport on Windows', () async { - fixture.options.platformChecker = - MockPlatformChecker(platform: MockPlatform.windows()); + fixture.options.platform = MockPlatform.windows(); fixture.options.spotlight = Spotlight(enabled: true); fixture.getSut(); @@ -2299,8 +2289,7 @@ class Fixture { final recorder = MockClientReportRecorder(); final transport = MockTransport(); - final options = - defaultTestOptions(MockPlatformChecker(platform: MockPlatform.iOS())); + final options = defaultTestOptions()..platform = MockPlatform.iOS(); late SentryTransactionContext _context; late SentryTracer tracer; diff --git a/dart/test/sentry_event_test.dart b/dart/test/sentry_event_test.dart index 8c82415f6a..ce70623ff0 100644 --- a/dart/test/sentry_event_test.dart +++ b/dart/test/sentry_event_test.dart @@ -4,6 +4,7 @@ import 'package:collection/collection.dart'; import 'package:sentry/sentry.dart'; +import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry/src/version.dart'; import 'package:test/test.dart'; @@ -130,12 +131,12 @@ void main() { ); }); test('$SdkVersion serializes', () { - var platformChecker = PlatformChecker(); + final platform = MockPlatform(); final event = SentryEvent( eventId: SentryId.empty(), timestamp: DateTime.utc(2019), - platform: sdkPlatform(platformChecker.platform.isWeb), + platform: sdkPlatform(platform.isWeb), sdk: SdkVersion( name: 'sentry.dart.flutter', version: '4.3.2', @@ -146,7 +147,7 @@ void main() { ), ); expect(event.toJson(), { - 'platform': platformChecker.platform.isWeb ? 'javascript' : 'other', + 'platform': platform.isWeb ? 'javascript' : 'other', 'event_id': '00000000000000000000000000000000', 'timestamp': '2019-01-01T00:00:00.000Z', 'sdk': { @@ -160,7 +161,7 @@ void main() { }); }); test('serializes to JSON', () { - var platformChecker = PlatformChecker(); + final platform = MockPlatform(); final timestamp = DateTime.utc(2019); final user = SentryUser( @@ -190,7 +191,7 @@ void main() { SentryEvent( eventId: SentryId.empty(), timestamp: timestamp, - platform: sdkPlatform(platformChecker.platform.isWeb), + platform: sdkPlatform(platform.isWeb), message: SentryMessage( 'test-message 1 2', template: 'test-message %d %d', @@ -239,7 +240,7 @@ void main() { unknown: testUnknown) .toJson(), { - 'platform': platformChecker.platform.isWeb ? 'javascript' : 'other', + 'platform': platform.isWeb ? 'javascript' : 'other', 'event_id': '00000000000000000000000000000000', 'timestamp': '2019-01-01T00:00:00.000Z', 'message': { diff --git a/dart/test/sentry_options_test.dart b/dart/test/sentry_options_test.dart index 32d39dcf97..2179f2e5bd 100644 --- a/dart/test/sentry_options_test.dart +++ b/dart/test/sentry_options_test.dart @@ -98,7 +98,7 @@ void main() { final options = defaultTestOptions(); expect(options.sentryClientName, - '${sdkName(options.platformChecker.platform.isWeb)}/$sdkVersion'); + '${sdkName(options.platform.isWeb)}/$sdkVersion'); }); test('SentryOptions has default idleTimeout', () { diff --git a/dart/test/sentry_test.dart b/dart/test/sentry_test.dart index 5e68e7c05d..7b6c7a9bf9 100644 --- a/dart/test/sentry_test.dart +++ b/dart/test/sentry_test.dart @@ -443,7 +443,7 @@ void main() { test('options.environment debug', () async { final sentryOptions = - defaultTestOptions(MockPlatformChecker(isDebug: true)); + defaultTestOptions(checker: MockPlatformChecker(isDebug: true)); await Sentry.init( (options) { options.dsn = fakeDsn; @@ -456,7 +456,7 @@ void main() { test('options.environment profile', () async { final sentryOptions = - defaultTestOptions(MockPlatformChecker(isProfile: true)); + defaultTestOptions(checker: MockPlatformChecker(isProfile: true)); await Sentry.init( (options) { @@ -470,7 +470,7 @@ void main() { test('options.environment production (defaultEnvironment)', () async { final sentryOptions = - defaultTestOptions(MockPlatformChecker(isRelease: true)); + defaultTestOptions(checker: MockPlatformChecker(isRelease: true)); await Sentry.init( (options) { options.dsn = fakeDsn; @@ -483,7 +483,7 @@ void main() { test('options.logger is set by setting the debug flag', () async { final sentryOptions = - defaultTestOptions(MockPlatformChecker(isDebug: true)); + defaultTestOptions(checker: MockPlatformChecker(isDebug: true)); await Sentry.init( (options) { @@ -510,7 +510,7 @@ void main() { test('throw is handled and logged', () async { // Use release mode in platform checker to avoid additional log final sentryOptions = - defaultTestOptions(MockPlatformChecker(isRelease: true)) + defaultTestOptions(checker: MockPlatformChecker(isRelease: true)) ..automatedTestMode = false ..debug = true ..logger = fixture.mockLogger; diff --git a/dart/test/stack_trace_test.dart b/dart/test/stack_trace_test.dart index 40e568f2fe..4507e8f916 100644 --- a/dart/test/stack_trace_test.dart +++ b/dart/test/stack_trace_test.dart @@ -8,7 +8,6 @@ import 'package:sentry/src/sentry_stack_trace_factory.dart'; import 'package:stack_trace/stack_trace.dart'; import 'package:test/test.dart'; -import 'mocks/mock_platform_checker.dart'; import 'test_utils.dart'; void main() { @@ -285,15 +284,13 @@ isolate_instructions: 10fa27070, vm_instructions: 10fa21e20 final fixture = Fixture(); // Test for web platform - fixture.options.platformChecker = - MockPlatformChecker(platform: MockPlatform(isWeb: true)); + fixture.options.platform = MockPlatform(isWeb: true); final webSut = fixture.getSut(); var webFrame = webSut.encodeStackTraceFrame(frame)!; expect(webFrame.platform, 'javascript'); // Test for non-web platform - fixture.options.platformChecker = - MockPlatformChecker(platform: MockPlatform(isWeb: false)); + fixture.options.platform = MockPlatform(isWeb: false); final nativeFrameBeforeSut = fixture.getSut(); var nativeFrameBefore = nativeFrameBeforeSut.encodeStackTraceFrame(frame)!; @@ -310,8 +307,7 @@ isolate_instructions: 10fa27070, vm_instructions: 10fa21e20 } class Fixture { - final options = defaultTestOptions( - MockPlatformChecker(platform: MockPlatform(isWeb: false))); + final options = defaultTestOptions()..platform = MockPlatform(isWeb: false); SentryStackTraceFactory getSut({ List inAppIncludes = const [], diff --git a/dart/test/test_utils.dart b/dart/test/test_utils.dart index 344f135d2b..2e1e1ccdaa 100644 --- a/dart/test/test_utils.dart +++ b/dart/test/test_utils.dart @@ -8,6 +8,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:http/testing.dart'; import 'package:sentry/sentry.dart'; +import 'package:sentry/src/platform/platform.dart'; import 'package:sentry/src/version.dart'; import 'package:test/test.dart'; @@ -18,8 +19,9 @@ const String _testDsnWithPath = const String _testDsnWithPort = 'https://public:secret@sentry.example.com:8888/1'; -SentryOptions defaultTestOptions([PlatformChecker? checker]) { - return SentryOptions(dsn: testDsn, checker: checker) +SentryOptions defaultTestOptions( + {Platform? platform, PlatformChecker? checker}) { + return SentryOptions(dsn: testDsn, platform: platform, checker: checker) ..automatedTestMode = true; } diff --git a/file/lib/src/sentry_file_extension.dart b/file/lib/src/sentry_file_extension.dart index 7945954bcb..3436a3ad8f 100644 --- a/file/lib/src/sentry_file_extension.dart +++ b/file/lib/src/sentry_file_extension.dart @@ -30,8 +30,7 @@ extension SentryFileExtension on File { File sentryTrace({@internal Hub? hub}) { final _hub = hub ?? HubAdapter(); - if (_hub.options.platformChecker.platform.isWeb || - !_hub.options.isTracingEnabled()) { + if (_hub.options.platform.isWeb || !_hub.options.isTracingEnabled()) { return this; } diff --git a/file/test/sentry_file_extension_test.dart b/file/test/sentry_file_extension_test.dart index ab770953b2..cad68cb318 100644 --- a/file/test/sentry_file_extension_test.dart +++ b/file/test/sentry_file_extension_test.dart @@ -55,8 +55,7 @@ class Fixture { bool isWeb = false, }) { options.tracesSampleRate = tracesSampleRate; - options.platformChecker = - PlatformChecker(platform: MockPlatform(isWeb: isWeb)); + options.platform = MockPlatform(isWeb: isWeb); hub = Hub(options); diff --git a/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart b/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart index 3865e5864a..a19199e6c8 100644 --- a/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart +++ b/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart @@ -19,7 +19,7 @@ class FlutterEnricherEventProcessor implements EventProcessor { final SentryFlutterOptions _options; - bool get _hasNativeIntegration => _checker.hasNativeIntegration; + bool get _hasNativeIntegration => _options.platform.supportsNativeIntegration; PlatformChecker get _checker => _options.platformChecker; // We can't use `WidgetsBinding` as a direct parameter @@ -40,7 +40,7 @@ class FlutterEnricherEventProcessor implements EventProcessor { // information available than Flutter. // TODO: while we have a native integration with JS SDK, it's currently opt in and we dont gather contexts yet // so for web it's still better to rely on the information of Flutter. - final device = _hasNativeIntegration && !_checker.platform.isWeb + final device = _hasNativeIntegration && !_options.platform.isWeb ? null : _getDevice(event.contexts.device); @@ -209,7 +209,7 @@ class FlutterEnricherEventProcessor implements EventProcessor { // See // - https://flutter.dev/docs/testing/build-modes // - https://github.com/flutter/flutter/wiki/Flutter%27s-modes - if (_checker.platform.isWeb) { + if (_options.platform.isWeb) { if (_checker.isDebugMode()) { compiler = 'dartdevc'; } else if (_checker.isReleaseMode() || _checker.isProfileMode()) { diff --git a/flutter/lib/src/event_processor/screenshot_event_processor.dart b/flutter/lib/src/event_processor/screenshot_event_processor.dart index b06cdd96e7..17de36b99a 100644 --- a/flutter/lib/src/event_processor/screenshot_event_processor.dart +++ b/flutter/lib/src/event_processor/screenshot_event_processor.dart @@ -92,8 +92,7 @@ class ScreenshotEventProcessor implements EventProcessor { final renderer = _options.rendererWrapper.getRenderer(); - if (_options.platformChecker.platform.isWeb && - renderer != FlutterRenderer.canvasKit) { + if (_options.platform.isWeb && renderer != FlutterRenderer.canvasKit) { _options.logger( SentryLevel.debug, 'Cannot take screenshot with ${renderer?.name} renderer.', diff --git a/flutter/lib/src/integrations/load_image_list_integration.dart b/flutter/lib/src/integrations/load_image_list_integration.dart index 3643dcb83d..f10883d203 100644 --- a/flutter/lib/src/integrations/load_image_list_integration.dart +++ b/flutter/lib/src/integrations/load_image_list_integration.dart @@ -44,7 +44,7 @@ class _LoadImageListIntegrationEventProcessor implements EventProcessor { // On windows, we need to add the ELF debug image of the AOT code. // See https://github.com/flutter/flutter/issues/154840 - if (_options.platformChecker.platform.isWindows) { + if (_options.platform.isWindows) { final debugImage = _dartProcessor.getAppDebugImage(stackTrace); if (debugImage != null) { images ??= List.empty(); diff --git a/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart b/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart index 56f7a4ef13..801638750d 100644 --- a/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart +++ b/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart @@ -18,7 +18,7 @@ class SentryNativeCocoa extends SentryNativeChannel { SentryNativeCocoa(super.options); @override - bool get supportsReplay => options.platformChecker.platform.isIOS; + bool get supportsReplay => options.platform.isIOS; @override Future init(Hub hub) async { diff --git a/flutter/lib/src/native/factory_real.dart b/flutter/lib/src/native/factory_real.dart index 8824d781bf..57a78bbd75 100644 --- a/flutter/lib/src/native/factory_real.dart +++ b/flutter/lib/src/native/factory_real.dart @@ -6,7 +6,7 @@ import 'sentry_native_binding.dart'; import 'sentry_native_channel.dart'; SentryNativeBinding createBinding(SentryFlutterOptions options) { - final platform = options.platformChecker.platform; + final platform = options.platform; if (platform.isIOS || platform.isMacOS) { return SentryNativeCocoa(options); } else if (platform.isAndroid) { diff --git a/flutter/lib/src/profiling.dart b/flutter/lib/src/profiling.dart index 6e7c309fcc..7372aa58b7 100644 --- a/flutter/lib/src/profiling.dart +++ b/flutter/lib/src/profiling.dart @@ -26,12 +26,11 @@ class SentryNativeProfilerFactory implements SentryProfilerFactory { return; } - if (options.platformChecker.platform.isWeb) { + if (options.platform.isWeb) { return; } - if (options.platformChecker.platform.isMacOS || - options.platformChecker.platform.isIOS) { + if (options.platform.isMacOS || options.platform.isIOS) { // ignore: invalid_use_of_internal_member hub.profilerFactory = SentryNativeProfilerFactory(native, options.clock); } diff --git a/flutter/lib/src/sentry_flutter.dart b/flutter/lib/src/sentry_flutter.dart index d78fb35c8d..d3bb4c028c 100644 --- a/flutter/lib/src/sentry_flutter.dart +++ b/flutter/lib/src/sentry_flutter.dart @@ -64,7 +64,7 @@ mixin SentryFlutter { // ignore: invalid_use_of_internal_member sentrySetupStartTime ??= options.clock(); - if (options.platformChecker.hasNativeIntegration) { + if (options.platform.supportsNativeIntegration) { _native = createBinding(options); } @@ -74,7 +74,7 @@ mixin SentryFlutter { // Flutter Web doesn't capture [Future] errors if using [PlatformDispatcher.onError] and not // the [runZonedGuarded]. // likely due to https://github.com/flutter/flutter/issues/100277 - final isOnErrorSupported = !options.platformChecker.platform.isWeb; + final isOnErrorSupported = !options.platform.isWeb; final bool isRootZone = options.platformChecker.isRootZone; @@ -126,13 +126,13 @@ mixin SentryFlutter { // Not all platforms have a native integration. if (_native != null) { if (_native!.supportsCaptureEnvelope) { - if (options.platformChecker.platform.isWeb) { + if (options.platform.isWeb) { options.transport = JavascriptTransport(_native!, options); } else { options.transport = FileSystemTransport(_native!, options); } } - if (!options.platformChecker.platform.isWeb) { + if (!options.platform.isWeb) { options.addScopeObserver(NativeScopeObserver(_native!)); } } @@ -141,7 +141,7 @@ mixin SentryFlutter { options.addEventProcessor(WidgetEventProcessor()); options.addEventProcessor(UrlFilterEventProcessor(options)); - if (options.platformChecker.platform.isAndroid) { + if (options.platform.isAndroid) { options.addEventProcessor( AndroidPlatformExceptionEventProcessor(options), ); @@ -159,7 +159,7 @@ mixin SentryFlutter { bool isOnErrorSupported, ) { final integrations = []; - final platformChecker = options.platformChecker; + final platform = options.platform; // Will call WidgetsFlutterBinding.ensureInitialized() before all other integrations. integrations.add(WidgetsFlutterBindingIntegration()); @@ -180,7 +180,7 @@ mixin SentryFlutter { final native = _native; if (native != null) { integrations.add(createSdkIntegration(native)); - if (!platformChecker.platform.isWeb) { + if (!platform.isWeb) { if (native.supportsLoadContexts) { integrations.add(LoadContextsIntegration(native)); } @@ -198,12 +198,11 @@ mixin SentryFlutter { } final renderer = options.rendererWrapper.getRenderer(); - if (!platformChecker.platform.isWeb || - renderer == FlutterRenderer.canvasKit) { + if (!platform.isWeb || renderer == FlutterRenderer.canvasKit) { integrations.add(ScreenshotIntegration()); } - if (platformChecker.platform.isWeb) { + if (platform.isWeb) { integrations.add(ConnectivityIntegration()); } diff --git a/flutter/lib/src/sentry_flutter_options.dart b/flutter/lib/src/sentry_flutter_options.dart index ed39b63143..b6286ac2d1 100644 --- a/flutter/lib/src/sentry_flutter_options.dart +++ b/flutter/lib/src/sentry_flutter_options.dart @@ -18,7 +18,7 @@ import 'user_interaction/sentry_user_interaction_widget.dart'; /// Note that some of these options require native Sentry integration, which is /// not available on all platforms. class SentryFlutterOptions extends SentryOptions { - SentryFlutterOptions({super.dsn, super.checker}) { + SentryFlutterOptions({super.dsn, super.platform, super.checker}) { enableBreadcrumbTrackingForCurrentPlatform(); } @@ -324,7 +324,7 @@ class SentryFlutterOptions extends SentryOptions { /// available in the Flutter environment. This way you get more detailed /// information where available. void enableBreadcrumbTrackingForCurrentPlatform() { - if (platformChecker.hasNativeIntegration) { + if (platform.supportsNativeIntegration) { useNativeBreadcrumbTracking(); } else { useFlutterBreadcrumbTracking(); diff --git a/flutter/lib/src/view_hierarchy/view_hierarchy_integration.dart b/flutter/lib/src/view_hierarchy/view_hierarchy_integration.dart index 8d2d9f7b19..0086e36524 100644 --- a/flutter/lib/src/view_hierarchy/view_hierarchy_integration.dart +++ b/flutter/lib/src/view_hierarchy/view_hierarchy_integration.dart @@ -13,8 +13,7 @@ class SentryViewHierarchyIntegration void call(Hub hub, SentryFlutterOptions options) { // View hierarchy is always minified on Web and we don't support // symbolication of source maps for view hierarchy yet. - if (!options.attachViewHierarchy || - options.platformChecker.platform.isWeb) { + if (!options.attachViewHierarchy || options.platform.isWeb) { return; } _options = options; diff --git a/flutter/test/event_processor/flutter_enricher_event_processor_test.dart b/flutter/test/event_processor/flutter_enricher_event_processor_test.dart index 0ba1b4864e..efe75c5440 100644 --- a/flutter/test/event_processor/flutter_enricher_event_processor_test.dart +++ b/flutter/test/event_processor/flutter_enricher_event_processor_test.dart @@ -222,31 +222,43 @@ void main() { }); testWidgets('adds correct flutter runtime', (WidgetTester tester) async { - final checkerMap = { - MockPlatformChecker( - mockPlatform: MockPlatform(isWeb: false), - buildMode: MockPlatformCheckerBuildMode.debug): 'Dart VM', - MockPlatformChecker( - mockPlatform: MockPlatform(isWeb: false), - buildMode: MockPlatformCheckerBuildMode.profile): 'Dart AOT', - MockPlatformChecker( - mockPlatform: MockPlatform(isWeb: false), - buildMode: MockPlatformCheckerBuildMode.release): 'Dart AOT', - MockPlatformChecker( - mockPlatform: MockPlatform(isWeb: true), - buildMode: MockPlatformCheckerBuildMode.debug): 'dartdevc', - MockPlatformChecker( - mockPlatform: MockPlatform(isWeb: true), - buildMode: MockPlatformCheckerBuildMode.profile): 'dart2js', - MockPlatformChecker( - mockPlatform: MockPlatform(isWeb: true), - buildMode: MockPlatformCheckerBuildMode.release): 'dart2js', - }; - - for (var pair in checkerMap.entries) { + final testData = [ + PlatformTestData( + MockPlatform(isWeb: false), + MockPlatformCheckerBuildMode.debug, + 'Dart VM', + ), + PlatformTestData( + MockPlatform(isWeb: false), + MockPlatformCheckerBuildMode.profile, + 'Dart AOT', + ), + PlatformTestData( + MockPlatform(isWeb: false), + MockPlatformCheckerBuildMode.release, + 'Dart AOT', + ), + PlatformTestData( + MockPlatform(isWeb: true), + MockPlatformCheckerBuildMode.debug, + 'dartdevc', + ), + PlatformTestData( + MockPlatform(isWeb: true), + MockPlatformCheckerBuildMode.profile, + 'dart2js', + ), + PlatformTestData( + MockPlatform(isWeb: true), + MockPlatformCheckerBuildMode.release, + 'dart2js', + ), + ]; + + for (var entry in testData) { final enricher = fixture.getSut( binding: () => tester.binding, - checker: pair.key, + platformTestData: entry, ); final event = await enricher.apply(SentryEvent(), Hint()); @@ -254,7 +266,7 @@ void main() { .firstWhere((element) => element.name == 'Flutter'); expect(flutterRuntime?.name, 'Flutter'); - expect(flutterRuntime?.compiler, pair.value); + expect(flutterRuntime?.compiler, entry.compiler); } }); @@ -381,9 +393,9 @@ void main() { testWidgets('$FlutterEnricherEventProcessor gets added on init', (tester) async { - // use a mockplatform checker so that we don't need to mock platform channels - final sentryOptions = - defaultTestOptions(MockPlatformChecker(hasNativeIntegration: false)); + // use a mock platform checker so that we don't need to mock platform channels + final sentryOptions = defaultTestOptions(); + sentryOptions.platform = MockPlatform.fuchsia(); // Without native loadTestPackage(); await SentryFlutter.init((options) { @@ -417,21 +429,40 @@ void main() { }); } +class PlatformTestData { + PlatformTestData(this.platform, this.buildMode, this.compiler); + MockPlatform platform; + MockPlatformCheckerBuildMode buildMode; + String compiler; +} + class Fixture { FlutterEnricherEventProcessor getSut({ required WidgetBindingGetter binding, - PlatformChecker? checker, + PlatformTestData? platformTestData, bool hasNativeIntegration = false, bool reportPackages = true, SentryFlutterOptions Function(SentryFlutterOptions)? optionsBuilder, }) { - final platformChecker = checker ?? - MockPlatformChecker( - hasNativeIntegration: hasNativeIntegration, - ); - - final options = defaultTestOptions(platformChecker) + PlatformChecker platformChecker; + if (platformTestData != null) { + platformChecker = MockPlatformChecker( + buildMode: platformTestData.buildMode, + ); + } else { + platformChecker = MockPlatformChecker(); + } + + final options = defaultTestOptions( + platform: + hasNativeIntegration ? MockPlatform.iOS() : MockPlatform.fuchsia(), + checker: platformChecker) ..reportPackages = reportPackages; + + if (platformTestData != null) { + options.platform = platformTestData.platform; + } + final customizedOptions = optionsBuilder?.call(options) ?? options; return FlutterEnricherEventProcessor(customizedOptions); } diff --git a/flutter/test/event_processor/screenshot_event_processor_test.dart b/flutter/test/event_processor/screenshot_event_processor_test.dart index 31ea8231dc..aee99a1739 100644 --- a/flutter/test/event_processor/screenshot_event_processor_test.dart +++ b/flutter/test/event_processor/screenshot_event_processor_test.dart @@ -350,8 +350,7 @@ class Fixture { ScreenshotEventProcessor getSut( FlutterRenderer? flutterRenderer, bool isWeb) { options.rendererWrapper = MockRendererWrapper(flutterRenderer); - options.platformChecker = - MockPlatformChecker(mockPlatform: MockPlatform(isWeb: isWeb)); + options.platform = MockPlatform(isWeb: isWeb); return ScreenshotEventProcessor(options); } } diff --git a/flutter/test/integrations/debug_print_integration_test.dart b/flutter/test/integrations/debug_print_integration_test.dart index a5580d6352..2697cc9db1 100644 --- a/flutter/test/integrations/debug_print_integration_test.dart +++ b/flutter/test/integrations/debug_print_integration_test.dart @@ -94,10 +94,11 @@ class Fixture { bool debug = false, bool enablePrintBreadcrumbs = true, }) { - return defaultTestOptions(MockPlatformChecker( - buildMode: debug - ? MockPlatformCheckerBuildMode.debug - : MockPlatformCheckerBuildMode.release)) + return defaultTestOptions( + checker: MockPlatformChecker( + buildMode: debug + ? MockPlatformCheckerBuildMode.debug + : MockPlatformCheckerBuildMode.release)) ..enablePrintBreadcrumbs = enablePrintBreadcrumbs; } diff --git a/flutter/test/integrations/init_native_sdk_test.dart b/flutter/test/integrations/init_native_sdk_test.dart index 7f2d9fe1a6..63e5e0db64 100644 --- a/flutter/test/integrations/init_native_sdk_test.dart +++ b/flutter/test/integrations/init_native_sdk_test.dart @@ -217,8 +217,7 @@ MethodChannel createChannelWithCallback( } SentryFlutterOptions createOptions() { - final mockPlatformChecker = MockPlatformChecker(hasNativeIntegration: true); - final options = defaultTestOptions(mockPlatformChecker); + final options = defaultTestOptions(); options.sdk = SdkVersion( name: sdkName, version: sdkVersion, diff --git a/flutter/test/mocks.dart b/flutter/test/mocks.dart index 7f69f89eba..7b2d3b1888 100644 --- a/flutter/test/mocks.dart +++ b/flutter/test/mocks.dart @@ -20,8 +20,10 @@ import 'no_such_method_provider.dart'; const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; const fakeProguardUuid = '3457d982-65ef-576d-a6ad-65b5f30f49a5'; -SentryFlutterOptions defaultTestOptions([PlatformChecker? checker]) { - return SentryFlutterOptions(dsn: fakeDsn, checker: checker) +SentryFlutterOptions defaultTestOptions( + {Platform? platform, PlatformChecker? checker}) { + return SentryFlutterOptions( + dsn: fakeDsn, platform: platform, checker: checker) ..automatedTestMode = true; } @@ -62,17 +64,11 @@ void main() {} class MockPlatformChecker with NoSuchMethodProvider implements PlatformChecker { MockPlatformChecker({ this.buildMode = MockPlatformCheckerBuildMode.debug, - this.hasNativeIntegration = false, this.isRoot = true, - Platform? mockPlatform, - }) : _mockPlatform = mockPlatform ?? currentPlatform; + }); final MockPlatformCheckerBuildMode buildMode; final bool isRoot; - final Platform _mockPlatform; - - @override - bool hasNativeIntegration = false; @override bool isDebugMode() => buildMode == MockPlatformCheckerBuildMode.debug; @@ -85,9 +81,6 @@ class MockPlatformChecker with NoSuchMethodProvider implements PlatformChecker { @override bool get isRootZone => isRoot; - - @override - Platform get platform => _mockPlatform; } enum MockPlatformCheckerBuildMode { debug, profile, release } diff --git a/flutter/test/mocks.mocks.dart b/flutter/test/mocks.mocks.dart index 5ff1ff4ccd..b0a3f10f34 100644 --- a/flutter/test/mocks.mocks.dart +++ b/flutter/test/mocks.mocks.dart @@ -47,151 +47,151 @@ import 'mocks.dart' as _i13; class _FakeSentrySpanContext_0 extends _i1.SmartFake implements _i2.SentrySpanContext { _FakeSentrySpanContext_0(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeDateTime_1 extends _i1.SmartFake implements DateTime { _FakeDateTime_1(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeISentrySpan_2 extends _i1.SmartFake implements _i2.ISentrySpan { _FakeISentrySpan_2(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSentryTraceHeader_3 extends _i1.SmartFake implements _i2.SentryTraceHeader { _FakeSentryTraceHeader_3(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSentryTracer_4 extends _i1.SmartFake implements _i3.SentryTracer { _FakeSentryTracer_4(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSentryId_5 extends _i1.SmartFake implements _i2.SentryId { _FakeSentryId_5(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeContexts_6 extends _i1.SmartFake implements _i2.Contexts { _FakeContexts_6(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSentryTransaction_7 extends _i1.SmartFake implements _i2.SentryTransaction { _FakeSentryTransaction_7(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeMethodCodec_8 extends _i1.SmartFake implements _i4.MethodCodec { _FakeMethodCodec_8(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeBinaryMessenger_9 extends _i1.SmartFake implements _i4.BinaryMessenger { _FakeBinaryMessenger_9(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeWidgetsBinding_10 extends _i1.SmartFake implements _i5.WidgetsBinding { _FakeWidgetsBinding_10(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSingletonFlutterWindow_11 extends _i1.SmartFake implements _i6.SingletonFlutterWindow { _FakeSingletonFlutterWindow_11(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakePlatformDispatcher_12 extends _i1.SmartFake implements _i6.PlatformDispatcher { _FakePlatformDispatcher_12(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakePointerRouter_13 extends _i1.SmartFake implements _i7.PointerRouter { _FakePointerRouter_13(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeGestureArenaManager_14 extends _i1.SmartFake implements _i7.GestureArenaManager { _FakeGestureArenaManager_14(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakePointerSignalResolver_15 extends _i1.SmartFake implements _i7.PointerSignalResolver { _FakePointerSignalResolver_15(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeDuration_16 extends _i1.SmartFake implements Duration { _FakeDuration_16(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSamplingClock_17 extends _i1.SmartFake implements _i7.SamplingClock { _FakeSamplingClock_17(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeValueNotifier_18 extends _i1.SmartFake implements _i8.ValueNotifier { _FakeValueNotifier_18(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeHardwareKeyboard_19 extends _i1.SmartFake implements _i4.HardwareKeyboard { _FakeHardwareKeyboard_19(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeKeyEventManager_20 extends _i1.SmartFake implements _i4.KeyEventManager { _FakeKeyEventManager_20(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeChannelBuffers_21 extends _i1.SmartFake implements _i6.ChannelBuffers { _FakeChannelBuffers_21(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeRestorationManager_22 extends _i1.SmartFake implements _i4.RestorationManager { _FakeRestorationManager_22(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeImageCache_23 extends _i1.SmartFake implements _i9.ImageCache { _FakeImageCache_23(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeListenable_24 extends _i1.SmartFake implements _i8.Listenable { _FakeListenable_24(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeAccessibilityFeatures_25 extends _i1.SmartFake implements _i6.AccessibilityFeatures { _FakeAccessibilityFeatures_25(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeRenderView_26 extends _i1.SmartFake implements _i10.RenderView { _FakeRenderView_26(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); @override String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) => @@ -200,18 +200,18 @@ class _FakeRenderView_26 extends _i1.SmartFake implements _i10.RenderView { class _FakeMouseTracker_27 extends _i1.SmartFake implements _i10.MouseTracker { _FakeMouseTracker_27(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakePlatformMenuDelegate_28 extends _i1.SmartFake implements _i9.PlatformMenuDelegate { _FakePlatformMenuDelegate_28(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeFocusManager_29 extends _i1.SmartFake implements _i9.FocusManager { _FakeFocusManager_29(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); @override String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) => @@ -220,51 +220,51 @@ class _FakeFocusManager_29 extends _i1.SmartFake implements _i9.FocusManager { class _FakeFuture_30 extends _i1.SmartFake implements _i11.Future { _FakeFuture_30(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeCodec_31 extends _i1.SmartFake implements _i6.Codec { _FakeCodec_31(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSemanticsHandle_32 extends _i1.SmartFake implements _i12.SemanticsHandle { _FakeSemanticsHandle_32(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSemanticsUpdateBuilder_33 extends _i1.SmartFake implements _i6.SemanticsUpdateBuilder { _FakeSemanticsUpdateBuilder_33(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeViewConfiguration_34 extends _i1.SmartFake implements _i10.ViewConfiguration { _FakeViewConfiguration_34(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeSceneBuilder_35 extends _i1.SmartFake implements _i6.SceneBuilder { _FakeSceneBuilder_35(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakePictureRecorder_36 extends _i1.SmartFake implements _i6.PictureRecorder { _FakePictureRecorder_36(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeCanvas_37 extends _i1.SmartFake implements _i6.Canvas { _FakeCanvas_37(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeWidget_38 extends _i1.SmartFake implements _i9.Widget { _FakeWidget_38(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); @override String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) => @@ -273,17 +273,17 @@ class _FakeWidget_38 extends _i1.SmartFake implements _i9.Widget { class _FakeSentryOptions_39 extends _i1.SmartFake implements _i2.SentryOptions { _FakeSentryOptions_39(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeScope_40 extends _i1.SmartFake implements _i2.Scope { _FakeScope_40(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakeHub_41 extends _i1.SmartFake implements _i2.Hub { _FakeHub_41(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } /// A class which mocks [Callbacks]. @@ -300,9 +300,8 @@ class MockCallbacks extends _i1.Mock implements _i13.Callbacks { dynamic arguments, ]) => (super.noSuchMethod( - Invocation.method(#methodCallHandler, [method, arguments]), - ) - as _i11.Future?); + Invocation.method(#methodCallHandler, [method, arguments]), + ) as _i11.Future?); } /// A class which mocks [Transport]. @@ -316,10 +315,9 @@ class MockTransport extends _i1.Mock implements _i2.Transport { @override _i11.Future<_i2.SentryId?> send(_i2.SentryEnvelope? envelope) => (super.noSuchMethod( - Invocation.method(#send, [envelope]), - returnValue: _i11.Future<_i2.SentryId?>.value(), - ) - as _i11.Future<_i2.SentryId?>); + Invocation.method(#send, [envelope]), + returnValue: _i11.Future<_i2.SentryId?>.value(), + ) as _i11.Future<_i2.SentryId?>); } /// A class which mocks [SentryTracer]. @@ -331,93 +329,83 @@ class MockSentryTracer extends _i1.Mock implements _i3.SentryTracer { } @override - String get name => - (super.noSuchMethod( - Invocation.getter(#name), - returnValue: _i14.dummyValue( - this, - Invocation.getter(#name), - ), - ) - as String); + String get name => (super.noSuchMethod( + Invocation.getter(#name), + returnValue: _i14.dummyValue( + this, + Invocation.getter(#name), + ), + ) as String); @override set name(String? _name) => super.noSuchMethod( - Invocation.setter(#name, _name), - returnValueForMissingStub: null, - ); + Invocation.setter(#name, _name), + returnValueForMissingStub: null, + ); @override _i2.SentryTransactionNameSource get transactionNameSource => (super.noSuchMethod( - Invocation.getter(#transactionNameSource), - returnValue: _i2.SentryTransactionNameSource.custom, - ) - as _i2.SentryTransactionNameSource); + Invocation.getter(#transactionNameSource), + returnValue: _i2.SentryTransactionNameSource.custom, + ) as _i2.SentryTransactionNameSource); @override set transactionNameSource( _i2.SentryTransactionNameSource? _transactionNameSource, - ) => super.noSuchMethod( - Invocation.setter(#transactionNameSource, _transactionNameSource), - returnValueForMissingStub: null, - ); + ) => + super.noSuchMethod( + Invocation.setter(#transactionNameSource, _transactionNameSource), + returnValueForMissingStub: null, + ); @override set profiler(_i15.SentryProfiler? _profiler) => super.noSuchMethod( - Invocation.setter(#profiler, _profiler), - returnValueForMissingStub: null, - ); + Invocation.setter(#profiler, _profiler), + returnValueForMissingStub: null, + ); @override set profileInfo(_i15.SentryProfileInfo? _profileInfo) => super.noSuchMethod( - Invocation.setter(#profileInfo, _profileInfo), - returnValueForMissingStub: null, - ); + Invocation.setter(#profileInfo, _profileInfo), + returnValueForMissingStub: null, + ); @override - Map get measurements => - (super.noSuchMethod( - Invocation.getter(#measurements), - returnValue: {}, - ) - as Map); + Map get measurements => (super.noSuchMethod( + Invocation.getter(#measurements), + returnValue: {}, + ) as Map); @override - _i2.SentrySpanContext get context => - (super.noSuchMethod( - Invocation.getter(#context), - returnValue: _FakeSentrySpanContext_0( - this, - Invocation.getter(#context), - ), - ) - as _i2.SentrySpanContext); + _i2.SentrySpanContext get context => (super.noSuchMethod( + Invocation.getter(#context), + returnValue: _FakeSentrySpanContext_0( + this, + Invocation.getter(#context), + ), + ) as _i2.SentrySpanContext); @override set origin(String? origin) => super.noSuchMethod( - Invocation.setter(#origin, origin), - returnValueForMissingStub: null, - ); + Invocation.setter(#origin, origin), + returnValueForMissingStub: null, + ); @override - DateTime get startTimestamp => - (super.noSuchMethod( - Invocation.getter(#startTimestamp), - returnValue: _FakeDateTime_1( - this, - Invocation.getter(#startTimestamp), - ), - ) - as DateTime); + DateTime get startTimestamp => (super.noSuchMethod( + Invocation.getter(#startTimestamp), + returnValue: _FakeDateTime_1( + this, + Invocation.getter(#startTimestamp), + ), + ) as DateTime); @override - Map get data => - (super.noSuchMethod( - Invocation.getter(#data), - returnValue: {}, - ) - as Map); + Map get data => (super.noSuchMethod( + Invocation.getter(#data), + returnValue: {}, + ) as Map); @override bool get finished => @@ -425,32 +413,28 @@ class MockSentryTracer extends _i1.Mock implements _i3.SentryTracer { as bool); @override - List<_i2.SentrySpan> get children => - (super.noSuchMethod( - Invocation.getter(#children), - returnValue: <_i2.SentrySpan>[], - ) - as List<_i2.SentrySpan>); + List<_i2.SentrySpan> get children => (super.noSuchMethod( + Invocation.getter(#children), + returnValue: <_i2.SentrySpan>[], + ) as List<_i2.SentrySpan>); @override set throwable(dynamic throwable) => super.noSuchMethod( - Invocation.setter(#throwable, throwable), - returnValueForMissingStub: null, - ); + Invocation.setter(#throwable, throwable), + returnValueForMissingStub: null, + ); @override set status(_i2.SpanStatus? status) => super.noSuchMethod( - Invocation.setter(#status, status), - returnValueForMissingStub: null, - ); + Invocation.setter(#status, status), + returnValueForMissingStub: null, + ); @override - Map get tags => - (super.noSuchMethod( - Invocation.getter(#tags), - returnValue: {}, - ) - as Map); + Map get tags => (super.noSuchMethod( + Invocation.getter(#tags), + returnValue: {}, + ) as Map); @override _i11.Future finish({ @@ -459,39 +443,38 @@ class MockSentryTracer extends _i1.Mock implements _i3.SentryTracer { _i2.Hint? hint, }) => (super.noSuchMethod( - Invocation.method(#finish, [], { - #status: status, - #endTimestamp: endTimestamp, - #hint: hint, - }), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + Invocation.method(#finish, [], { + #status: status, + #endTimestamp: endTimestamp, + #hint: hint, + }), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override void removeData(String? key) => super.noSuchMethod( - Invocation.method(#removeData, [key]), - returnValueForMissingStub: null, - ); + Invocation.method(#removeData, [key]), + returnValueForMissingStub: null, + ); @override void removeTag(String? key) => super.noSuchMethod( - Invocation.method(#removeTag, [key]), - returnValueForMissingStub: null, - ); + Invocation.method(#removeTag, [key]), + returnValueForMissingStub: null, + ); @override void setData(String? key, dynamic value) => super.noSuchMethod( - Invocation.method(#setData, [key, value]), - returnValueForMissingStub: null, - ); + Invocation.method(#setData, [key, value]), + returnValueForMissingStub: null, + ); @override void setTag(String? key, String? value) => super.noSuchMethod( - Invocation.method(#setTag, [key, value]), - returnValueForMissingStub: null, - ); + Invocation.method(#setTag, [key, value]), + returnValueForMissingStub: null, + ); @override _i2.ISentrySpan startChild( @@ -500,21 +483,20 @@ class MockSentryTracer extends _i1.Mock implements _i3.SentryTracer { DateTime? startTimestamp, }) => (super.noSuchMethod( - Invocation.method( - #startChild, - [operation], - {#description: description, #startTimestamp: startTimestamp}, - ), - returnValue: _FakeISentrySpan_2( - this, - Invocation.method( - #startChild, - [operation], - {#description: description, #startTimestamp: startTimestamp}, - ), - ), - ) - as _i2.ISentrySpan); + Invocation.method( + #startChild, + [operation], + {#description: description, #startTimestamp: startTimestamp}, + ), + returnValue: _FakeISentrySpan_2( + this, + Invocation.method( + #startChild, + [operation], + {#description: description, #startTimestamp: startTimestamp}, + ), + ), + ) as _i2.ISentrySpan); @override _i2.ISentrySpan startChildWithParentSpanId( @@ -524,58 +506,58 @@ class MockSentryTracer extends _i1.Mock implements _i3.SentryTracer { DateTime? startTimestamp, }) => (super.noSuchMethod( - Invocation.method( - #startChildWithParentSpanId, - [parentSpanId, operation], - {#description: description, #startTimestamp: startTimestamp}, - ), - returnValue: _FakeISentrySpan_2( - this, - Invocation.method( - #startChildWithParentSpanId, - [parentSpanId, operation], - {#description: description, #startTimestamp: startTimestamp}, - ), - ), - ) - as _i2.ISentrySpan); + Invocation.method( + #startChildWithParentSpanId, + [parentSpanId, operation], + {#description: description, #startTimestamp: startTimestamp}, + ), + returnValue: _FakeISentrySpan_2( + this, + Invocation.method( + #startChildWithParentSpanId, + [parentSpanId, operation], + {#description: description, #startTimestamp: startTimestamp}, + ), + ), + ) as _i2.ISentrySpan); @override - _i2.SentryTraceHeader toSentryTrace() => - (super.noSuchMethod( - Invocation.method(#toSentryTrace, []), - returnValue: _FakeSentryTraceHeader_3( - this, - Invocation.method(#toSentryTrace, []), - ), - ) - as _i2.SentryTraceHeader); + _i2.SentryTraceHeader toSentryTrace() => (super.noSuchMethod( + Invocation.method(#toSentryTrace, []), + returnValue: _FakeSentryTraceHeader_3( + this, + Invocation.method(#toSentryTrace, []), + ), + ) as _i2.SentryTraceHeader); @override void setMeasurement( String? name, num? value, { _i2.SentryMeasurementUnit? unit, - }) => super.noSuchMethod( - Invocation.method(#setMeasurement, [name, value], {#unit: unit}), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method(#setMeasurement, [name, value], {#unit: unit}), + returnValueForMissingStub: null, + ); @override void setMeasurementFromChild( String? name, num? value, { _i2.SentryMeasurementUnit? unit, - }) => super.noSuchMethod( - Invocation.method(#setMeasurementFromChild, [name, value], {#unit: unit}), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method( + #setMeasurementFromChild, [name, value], {#unit: unit}), + returnValueForMissingStub: null, + ); @override void scheduleFinish() => super.noSuchMethod( - Invocation.method(#scheduleFinish, []), - returnValueForMissingStub: null, - ); + Invocation.method(#scheduleFinish, []), + returnValueForMissingStub: null, + ); } /// A class which mocks [SentryTransaction]. @@ -588,51 +570,43 @@ class MockSentryTransaction extends _i1.Mock implements _i2.SentryTransaction { } @override - DateTime get startTimestamp => - (super.noSuchMethod( - Invocation.getter(#startTimestamp), - returnValue: _FakeDateTime_1( - this, - Invocation.getter(#startTimestamp), - ), - ) - as DateTime); + DateTime get startTimestamp => (super.noSuchMethod( + Invocation.getter(#startTimestamp), + returnValue: _FakeDateTime_1( + this, + Invocation.getter(#startTimestamp), + ), + ) as DateTime); @override set startTimestamp(DateTime? _startTimestamp) => super.noSuchMethod( - Invocation.setter(#startTimestamp, _startTimestamp), - returnValueForMissingStub: null, - ); + Invocation.setter(#startTimestamp, _startTimestamp), + returnValueForMissingStub: null, + ); @override - List<_i2.SentrySpan> get spans => - (super.noSuchMethod( - Invocation.getter(#spans), - returnValue: <_i2.SentrySpan>[], - ) - as List<_i2.SentrySpan>); + List<_i2.SentrySpan> get spans => (super.noSuchMethod( + Invocation.getter(#spans), + returnValue: <_i2.SentrySpan>[], + ) as List<_i2.SentrySpan>); @override set spans(List<_i2.SentrySpan>? _spans) => super.noSuchMethod( - Invocation.setter(#spans, _spans), - returnValueForMissingStub: null, - ); + Invocation.setter(#spans, _spans), + returnValueForMissingStub: null, + ); @override - _i3.SentryTracer get tracer => - (super.noSuchMethod( - Invocation.getter(#tracer), - returnValue: _FakeSentryTracer_4(this, Invocation.getter(#tracer)), - ) - as _i3.SentryTracer); + _i3.SentryTracer get tracer => (super.noSuchMethod( + Invocation.getter(#tracer), + returnValue: _FakeSentryTracer_4(this, Invocation.getter(#tracer)), + ) as _i3.SentryTracer); @override - Map get measurements => - (super.noSuchMethod( - Invocation.getter(#measurements), - returnValue: {}, - ) - as Map); + Map get measurements => (super.noSuchMethod( + Invocation.getter(#measurements), + returnValue: {}, + ) as Map); @override set measurements(Map? _measurements) => @@ -659,28 +633,22 @@ class MockSentryTransaction extends _i1.Mock implements _i2.SentryTransaction { as bool); @override - _i2.SentryId get eventId => - (super.noSuchMethod( - Invocation.getter(#eventId), - returnValue: _FakeSentryId_5(this, Invocation.getter(#eventId)), - ) - as _i2.SentryId); + _i2.SentryId get eventId => (super.noSuchMethod( + Invocation.getter(#eventId), + returnValue: _FakeSentryId_5(this, Invocation.getter(#eventId)), + ) as _i2.SentryId); @override - _i2.Contexts get contexts => - (super.noSuchMethod( - Invocation.getter(#contexts), - returnValue: _FakeContexts_6(this, Invocation.getter(#contexts)), - ) - as _i2.Contexts); + _i2.Contexts get contexts => (super.noSuchMethod( + Invocation.getter(#contexts), + returnValue: _FakeContexts_6(this, Invocation.getter(#contexts)), + ) as _i2.Contexts); @override - Map toJson() => - (super.noSuchMethod( - Invocation.method(#toJson, []), - returnValue: {}, - ) - as Map); + Map toJson() => (super.noSuchMethod( + Invocation.method(#toJson, []), + returnValue: {}, + ) as Map); @override _i2.SentryTransaction copyWith({ @@ -714,71 +682,70 @@ class MockSentryTransaction extends _i1.Mock implements _i2.SentryTransaction { _i2.SentryTransactionInfo? transactionInfo, }) => (super.noSuchMethod( - Invocation.method(#copyWith, [], { - #eventId: eventId, - #timestamp: timestamp, - #platform: platform, - #logger: logger, - #serverName: serverName, - #release: release, - #dist: dist, - #environment: environment, - #modules: modules, - #message: message, - #transaction: transaction, - #throwable: throwable, - #level: level, - #culprit: culprit, - #tags: tags, - #extra: extra, - #fingerprint: fingerprint, - #user: user, - #contexts: contexts, - #breadcrumbs: breadcrumbs, - #sdk: sdk, - #request: request, - #debugMeta: debugMeta, - #exceptions: exceptions, - #threads: threads, - #type: type, - #measurements: measurements, - #transactionInfo: transactionInfo, - }), - returnValue: _FakeSentryTransaction_7( - this, - Invocation.method(#copyWith, [], { - #eventId: eventId, - #timestamp: timestamp, - #platform: platform, - #logger: logger, - #serverName: serverName, - #release: release, - #dist: dist, - #environment: environment, - #modules: modules, - #message: message, - #transaction: transaction, - #throwable: throwable, - #level: level, - #culprit: culprit, - #tags: tags, - #extra: extra, - #fingerprint: fingerprint, - #user: user, - #contexts: contexts, - #breadcrumbs: breadcrumbs, - #sdk: sdk, - #request: request, - #debugMeta: debugMeta, - #exceptions: exceptions, - #threads: threads, - #type: type, - #measurements: measurements, - #transactionInfo: transactionInfo, - }), - ), - ) - as _i2.SentryTransaction); + Invocation.method(#copyWith, [], { + #eventId: eventId, + #timestamp: timestamp, + #platform: platform, + #logger: logger, + #serverName: serverName, + #release: release, + #dist: dist, + #environment: environment, + #modules: modules, + #message: message, + #transaction: transaction, + #throwable: throwable, + #level: level, + #culprit: culprit, + #tags: tags, + #extra: extra, + #fingerprint: fingerprint, + #user: user, + #contexts: contexts, + #breadcrumbs: breadcrumbs, + #sdk: sdk, + #request: request, + #debugMeta: debugMeta, + #exceptions: exceptions, + #threads: threads, + #type: type, + #measurements: measurements, + #transactionInfo: transactionInfo, + }), + returnValue: _FakeSentryTransaction_7( + this, + Invocation.method(#copyWith, [], { + #eventId: eventId, + #timestamp: timestamp, + #platform: platform, + #logger: logger, + #serverName: serverName, + #release: release, + #dist: dist, + #environment: environment, + #modules: modules, + #message: message, + #transaction: transaction, + #throwable: throwable, + #level: level, + #culprit: culprit, + #tags: tags, + #extra: extra, + #fingerprint: fingerprint, + #user: user, + #contexts: contexts, + #breadcrumbs: breadcrumbs, + #sdk: sdk, + #request: request, + #debugMeta: debugMeta, + #exceptions: exceptions, + #threads: threads, + #type: type, + #measurements: measurements, + #transactionInfo: transactionInfo, + }), + ), + ) as _i2.SentryTransaction); } /// A class which mocks [SentrySpan]. @@ -795,46 +762,40 @@ class MockSentrySpan extends _i1.Mock implements _i2.SentrySpan { as bool); @override - _i3.SentryTracer get tracer => - (super.noSuchMethod( - Invocation.getter(#tracer), - returnValue: _FakeSentryTracer_4(this, Invocation.getter(#tracer)), - ) - as _i3.SentryTracer); + _i3.SentryTracer get tracer => (super.noSuchMethod( + Invocation.getter(#tracer), + returnValue: _FakeSentryTracer_4(this, Invocation.getter(#tracer)), + ) as _i3.SentryTracer); @override set status(_i2.SpanStatus? status) => super.noSuchMethod( - Invocation.setter(#status, status), - returnValueForMissingStub: null, - ); + Invocation.setter(#status, status), + returnValueForMissingStub: null, + ); @override - DateTime get startTimestamp => - (super.noSuchMethod( - Invocation.getter(#startTimestamp), - returnValue: _FakeDateTime_1( - this, - Invocation.getter(#startTimestamp), - ), - ) - as DateTime); + DateTime get startTimestamp => (super.noSuchMethod( + Invocation.getter(#startTimestamp), + returnValue: _FakeDateTime_1( + this, + Invocation.getter(#startTimestamp), + ), + ) as DateTime); @override - _i2.SentrySpanContext get context => - (super.noSuchMethod( - Invocation.getter(#context), - returnValue: _FakeSentrySpanContext_0( - this, - Invocation.getter(#context), - ), - ) - as _i2.SentrySpanContext); + _i2.SentrySpanContext get context => (super.noSuchMethod( + Invocation.getter(#context), + returnValue: _FakeSentrySpanContext_0( + this, + Invocation.getter(#context), + ), + ) as _i2.SentrySpanContext); @override set origin(String? origin) => super.noSuchMethod( - Invocation.setter(#origin, origin), - returnValueForMissingStub: null, - ); + Invocation.setter(#origin, origin), + returnValueForMissingStub: null, + ); @override bool get finished => @@ -843,25 +804,21 @@ class MockSentrySpan extends _i1.Mock implements _i2.SentrySpan { @override set throwable(dynamic throwable) => super.noSuchMethod( - Invocation.setter(#throwable, throwable), - returnValueForMissingStub: null, - ); + Invocation.setter(#throwable, throwable), + returnValueForMissingStub: null, + ); @override - Map get tags => - (super.noSuchMethod( - Invocation.getter(#tags), - returnValue: {}, - ) - as Map); + Map get tags => (super.noSuchMethod( + Invocation.getter(#tags), + returnValue: {}, + ) as Map); @override - Map get data => - (super.noSuchMethod( - Invocation.getter(#data), - returnValue: {}, - ) - as Map); + Map get data => (super.noSuchMethod( + Invocation.getter(#data), + returnValue: {}, + ) as Map); @override _i11.Future finish({ @@ -870,39 +827,38 @@ class MockSentrySpan extends _i1.Mock implements _i2.SentrySpan { _i2.Hint? hint, }) => (super.noSuchMethod( - Invocation.method(#finish, [], { - #status: status, - #endTimestamp: endTimestamp, - #hint: hint, - }), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + Invocation.method(#finish, [], { + #status: status, + #endTimestamp: endTimestamp, + #hint: hint, + }), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override void removeData(String? key) => super.noSuchMethod( - Invocation.method(#removeData, [key]), - returnValueForMissingStub: null, - ); + Invocation.method(#removeData, [key]), + returnValueForMissingStub: null, + ); @override void removeTag(String? key) => super.noSuchMethod( - Invocation.method(#removeTag, [key]), - returnValueForMissingStub: null, - ); + Invocation.method(#removeTag, [key]), + returnValueForMissingStub: null, + ); @override void setData(String? key, dynamic value) => super.noSuchMethod( - Invocation.method(#setData, [key, value]), - returnValueForMissingStub: null, - ); + Invocation.method(#setData, [key, value]), + returnValueForMissingStub: null, + ); @override void setTag(String? key, String? value) => super.noSuchMethod( - Invocation.method(#setTag, [key, value]), - returnValueForMissingStub: null, - ); + Invocation.method(#setTag, [key, value]), + returnValueForMissingStub: null, + ); @override _i2.ISentrySpan startChild( @@ -911,56 +867,52 @@ class MockSentrySpan extends _i1.Mock implements _i2.SentrySpan { DateTime? startTimestamp, }) => (super.noSuchMethod( - Invocation.method( - #startChild, - [operation], - {#description: description, #startTimestamp: startTimestamp}, - ), - returnValue: _FakeISentrySpan_2( - this, - Invocation.method( - #startChild, - [operation], - {#description: description, #startTimestamp: startTimestamp}, - ), - ), - ) - as _i2.ISentrySpan); + Invocation.method( + #startChild, + [operation], + {#description: description, #startTimestamp: startTimestamp}, + ), + returnValue: _FakeISentrySpan_2( + this, + Invocation.method( + #startChild, + [operation], + {#description: description, #startTimestamp: startTimestamp}, + ), + ), + ) as _i2.ISentrySpan); @override - Map toJson() => - (super.noSuchMethod( - Invocation.method(#toJson, []), - returnValue: {}, - ) - as Map); + Map toJson() => (super.noSuchMethod( + Invocation.method(#toJson, []), + returnValue: {}, + ) as Map); @override - _i2.SentryTraceHeader toSentryTrace() => - (super.noSuchMethod( - Invocation.method(#toSentryTrace, []), - returnValue: _FakeSentryTraceHeader_3( - this, - Invocation.method(#toSentryTrace, []), - ), - ) - as _i2.SentryTraceHeader); + _i2.SentryTraceHeader toSentryTrace() => (super.noSuchMethod( + Invocation.method(#toSentryTrace, []), + returnValue: _FakeSentryTraceHeader_3( + this, + Invocation.method(#toSentryTrace, []), + ), + ) as _i2.SentryTraceHeader); @override void setMeasurement( String? name, num? value, { _i2.SentryMeasurementUnit? unit, - }) => super.noSuchMethod( - Invocation.method(#setMeasurement, [name, value], {#unit: unit}), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method(#setMeasurement, [name, value], {#unit: unit}), + returnValueForMissingStub: null, + ); @override void scheduleFinish() => super.noSuchMethod( - Invocation.method(#scheduleFinish, []), - returnValueForMissingStub: null, - ); + Invocation.method(#scheduleFinish, []), + returnValueForMissingStub: null, + ); } /// A class which mocks [SentryClient]. @@ -979,23 +931,22 @@ class MockSentryClient extends _i1.Mock implements _i2.SentryClient { _i2.Hint? hint, }) => (super.noSuchMethod( + Invocation.method( + #captureEvent, + [event], + {#scope: scope, #stackTrace: stackTrace, #hint: hint}, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureEvent, [event], {#scope: scope, #stackTrace: stackTrace, #hint: hint}, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureEvent, - [event], - {#scope: scope, #stackTrace: stackTrace, #hint: hint}, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override _i11.Future<_i2.SentryId> captureException( @@ -1005,23 +956,22 @@ class MockSentryClient extends _i1.Mock implements _i2.SentryClient { _i2.Hint? hint, }) => (super.noSuchMethod( + Invocation.method( + #captureException, + [throwable], + {#stackTrace: stackTrace, #scope: scope, #hint: hint}, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureException, [throwable], {#stackTrace: stackTrace, #scope: scope, #hint: hint}, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureException, - [throwable], - {#stackTrace: stackTrace, #scope: scope, #hint: hint}, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override _i11.Future<_i2.SentryId> captureMessage( @@ -1033,6 +983,20 @@ class MockSentryClient extends _i1.Mock implements _i2.SentryClient { _i2.Hint? hint, }) => (super.noSuchMethod( + Invocation.method( + #captureMessage, + [formatted], + { + #level: level, + #template: template, + #params: params, + #scope: scope, + #hint: hint, + }, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureMessage, [formatted], @@ -1044,24 +1008,9 @@ class MockSentryClient extends _i1.Mock implements _i2.SentryClient { #hint: hint, }, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureMessage, - [formatted], - { - #level: level, - #template: template, - #params: params, - #scope: scope, - #hint: hint, - }, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override _i11.Future<_i2.SentryId> captureTransaction( @@ -1071,31 +1020,29 @@ class MockSentryClient extends _i1.Mock implements _i2.SentryClient { _i2.Hint? hint, }) => (super.noSuchMethod( + Invocation.method( + #captureTransaction, + [transaction], + {#scope: scope, #traceContext: traceContext, #hint: hint}, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureTransaction, [transaction], {#scope: scope, #traceContext: traceContext, #hint: hint}, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureTransaction, - [transaction], - {#scope: scope, #traceContext: traceContext, #hint: hint}, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override _i11.Future<_i2.SentryId?> captureEnvelope(_i2.SentryEnvelope? envelope) => (super.noSuchMethod( - Invocation.method(#captureEnvelope, [envelope]), - returnValue: _i11.Future<_i2.SentryId?>.value(), - ) - as _i11.Future<_i2.SentryId?>); + Invocation.method(#captureEnvelope, [envelope]), + returnValue: _i11.Future<_i2.SentryId?>.value(), + ) as _i11.Future<_i2.SentryId?>); @override _i11.Future<_i2.SentryId> captureFeedback( @@ -1104,29 +1051,28 @@ class MockSentryClient extends _i1.Mock implements _i2.SentryClient { _i2.Hint? hint, }) => (super.noSuchMethod( + Invocation.method( + #captureFeedback, + [feedback], + {#scope: scope, #hint: hint}, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureFeedback, [feedback], {#scope: scope, #hint: hint}, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureFeedback, - [feedback], - {#scope: scope, #hint: hint}, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override void close() => super.noSuchMethod( - Invocation.method(#close, []), - returnValueForMissingStub: null, - ); + Invocation.method(#close, []), + returnValueForMissingStub: null, + ); } /// A class which mocks [MethodChannel]. @@ -1138,42 +1084,35 @@ class MockMethodChannel extends _i1.Mock implements _i4.MethodChannel { } @override - String get name => - (super.noSuchMethod( - Invocation.getter(#name), - returnValue: _i14.dummyValue( - this, - Invocation.getter(#name), - ), - ) - as String); + String get name => (super.noSuchMethod( + Invocation.getter(#name), + returnValue: _i14.dummyValue( + this, + Invocation.getter(#name), + ), + ) as String); @override - _i4.MethodCodec get codec => - (super.noSuchMethod( - Invocation.getter(#codec), - returnValue: _FakeMethodCodec_8(this, Invocation.getter(#codec)), - ) - as _i4.MethodCodec); + _i4.MethodCodec get codec => (super.noSuchMethod( + Invocation.getter(#codec), + returnValue: _FakeMethodCodec_8(this, Invocation.getter(#codec)), + ) as _i4.MethodCodec); @override - _i4.BinaryMessenger get binaryMessenger => - (super.noSuchMethod( - Invocation.getter(#binaryMessenger), - returnValue: _FakeBinaryMessenger_9( - this, - Invocation.getter(#binaryMessenger), - ), - ) - as _i4.BinaryMessenger); + _i4.BinaryMessenger get binaryMessenger => (super.noSuchMethod( + Invocation.getter(#binaryMessenger), + returnValue: _FakeBinaryMessenger_9( + this, + Invocation.getter(#binaryMessenger), + ), + ) as _i4.BinaryMessenger); @override _i11.Future invokeMethod(String? method, [dynamic arguments]) => (super.noSuchMethod( - Invocation.method(#invokeMethod, [method, arguments]), - returnValue: _i11.Future.value(), - ) - as _i11.Future); + Invocation.method(#invokeMethod, [method, arguments]), + returnValue: _i11.Future.value(), + ) as _i11.Future); @override _i11.Future?> invokeListMethod( @@ -1181,10 +1120,9 @@ class MockMethodChannel extends _i1.Mock implements _i4.MethodChannel { dynamic arguments, ]) => (super.noSuchMethod( - Invocation.method(#invokeListMethod, [method, arguments]), - returnValue: _i11.Future?>.value(), - ) - as _i11.Future?>); + Invocation.method(#invokeListMethod, [method, arguments]), + returnValue: _i11.Future?>.value(), + ) as _i11.Future?>); @override _i11.Future?> invokeMapMethod( @@ -1192,18 +1130,18 @@ class MockMethodChannel extends _i1.Mock implements _i4.MethodChannel { dynamic arguments, ]) => (super.noSuchMethod( - Invocation.method(#invokeMapMethod, [method, arguments]), - returnValue: _i11.Future?>.value(), - ) - as _i11.Future?>); + Invocation.method(#invokeMapMethod, [method, arguments]), + returnValue: _i11.Future?>.value(), + ) as _i11.Future?>); @override void setMethodCallHandler( _i11.Future Function(_i4.MethodCall)? handler, - ) => super.noSuchMethod( - Invocation.method(#setMethodCallHandler, [handler]), - returnValueForMissingStub: null, - ); + ) => + super.noSuchMethod( + Invocation.method(#setMethodCallHandler, [handler]), + returnValueForMissingStub: null, + ); } /// A class which mocks [SentryNativeBinding]. @@ -1216,28 +1154,22 @@ class MockSentryNativeBinding extends _i1.Mock } @override - bool get supportsCaptureEnvelope => - (super.noSuchMethod( - Invocation.getter(#supportsCaptureEnvelope), - returnValue: false, - ) - as bool); + bool get supportsCaptureEnvelope => (super.noSuchMethod( + Invocation.getter(#supportsCaptureEnvelope), + returnValue: false, + ) as bool); @override - bool get supportsLoadContexts => - (super.noSuchMethod( - Invocation.getter(#supportsLoadContexts), - returnValue: false, - ) - as bool); + bool get supportsLoadContexts => (super.noSuchMethod( + Invocation.getter(#supportsLoadContexts), + returnValue: false, + ) as bool); @override - bool get supportsReplay => - (super.noSuchMethod( - Invocation.getter(#supportsReplay), - returnValue: false, - ) - as bool); + bool get supportsReplay => (super.noSuchMethod( + Invocation.getter(#supportsReplay), + returnValue: false, + ) as bool); @override _i11.FutureOr init(_i2.Hub? hub) => @@ -1250,19 +1182,17 @@ class MockSentryNativeBinding extends _i1.Mock bool? containsUnhandledException, ) => (super.noSuchMethod( - Invocation.method(#captureEnvelope, [ - envelopeData, - containsUnhandledException, - ]), - ) - as _i11.FutureOr); + Invocation.method(#captureEnvelope, [ + envelopeData, + containsUnhandledException, + ]), + ) as _i11.FutureOr); @override _i11.FutureOr captureStructuredEnvelope(_i2.SentryEnvelope? envelope) => (super.noSuchMethod( - Invocation.method(#captureStructuredEnvelope, [envelope]), - ) - as _i11.FutureOr); + Invocation.method(#captureStructuredEnvelope, [envelope]), + ) as _i11.FutureOr); @override _i11.FutureOr<_i18.NativeFrames?> endNativeFrames(_i2.SentryId? id) => @@ -1321,13 +1251,12 @@ class MockSentryNativeBinding extends _i1.Mock int? endTimeNs, ) => (super.noSuchMethod( - Invocation.method(#collectProfile, [ - traceId, - startTimeNs, - endTimeNs, - ]), - ) - as _i11.FutureOr?>); + Invocation.method(#collectProfile, [ + traceId, + startTimeNs, + endTimeNs, + ]), + ) as _i11.FutureOr?>); @override _i11.FutureOr?> loadDebugImages( @@ -1344,15 +1273,14 @@ class MockSentryNativeBinding extends _i1.Mock @override _i11.FutureOr<_i2.SentryId> captureReplay(bool? isCrash) => (super.noSuchMethod( + Invocation.method(#captureReplay, [isCrash]), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method(#captureReplay, [isCrash]), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method(#captureReplay, [isCrash]), - ), - ), - ) - as _i11.FutureOr<_i2.SentryId>); + ), + ), + ) as _i11.FutureOr<_i2.SentryId>); } /// A class which mocks [SentryDelayedFramesTracker]. @@ -1365,32 +1293,28 @@ class MockSentryDelayedFramesTracker extends _i1.Mock } @override - List<_i20.SentryFrameTiming> get delayedFrames => - (super.noSuchMethod( - Invocation.getter(#delayedFrames), - returnValue: <_i20.SentryFrameTiming>[], - ) - as List<_i20.SentryFrameTiming>); + List<_i20.SentryFrameTiming> get delayedFrames => (super.noSuchMethod( + Invocation.getter(#delayedFrames), + returnValue: <_i20.SentryFrameTiming>[], + ) as List<_i20.SentryFrameTiming>); @override - bool get isTrackingActive => - (super.noSuchMethod( - Invocation.getter(#isTrackingActive), - returnValue: false, - ) - as bool); + bool get isTrackingActive => (super.noSuchMethod( + Invocation.getter(#isTrackingActive), + returnValue: false, + ) as bool); @override void resume() => super.noSuchMethod( - Invocation.method(#resume, []), - returnValueForMissingStub: null, - ); + Invocation.method(#resume, []), + returnValueForMissingStub: null, + ); @override void pause() => super.noSuchMethod( - Invocation.method(#pause, []), - returnValueForMissingStub: null, - ); + Invocation.method(#pause, []), + returnValueForMissingStub: null, + ); @override List<_i20.SentryFrameTiming> getFramesIntersecting({ @@ -1398,13 +1322,12 @@ class MockSentryDelayedFramesTracker extends _i1.Mock required DateTime? endTimestamp, }) => (super.noSuchMethod( - Invocation.method(#getFramesIntersecting, [], { - #startTimestamp: startTimestamp, - #endTimestamp: endTimestamp, - }), - returnValue: <_i20.SentryFrameTiming>[], - ) - as List<_i20.SentryFrameTiming>); + Invocation.method(#getFramesIntersecting, [], { + #startTimestamp: startTimestamp, + #endTimestamp: endTimestamp, + }), + returnValue: <_i20.SentryFrameTiming>[], + ) as List<_i20.SentryFrameTiming>); @override void addFrame(DateTime? startTimestamp, DateTime? endTimestamp) => @@ -1426,18 +1349,17 @@ class MockSentryDelayedFramesTracker extends _i1.Mock required DateTime? spanEndTimestamp, }) => (super.noSuchMethod( - Invocation.method(#getFrameMetrics, [], { - #spanStartTimestamp: spanStartTimestamp, - #spanEndTimestamp: spanEndTimestamp, - }), - ) - as _i20.SpanFrameMetrics?); + Invocation.method(#getFrameMetrics, [], { + #spanStartTimestamp: spanStartTimestamp, + #spanEndTimestamp: spanEndTimestamp, + }), + ) as _i20.SpanFrameMetrics?); @override void clear() => super.noSuchMethod( - Invocation.method(#clear, []), - returnValueForMissingStub: null, - ); + Invocation.method(#clear, []), + returnValueForMissingStub: null, + ); } /// A class which mocks [BindingWrapper]. @@ -1449,15 +1371,13 @@ class MockBindingWrapper extends _i1.Mock implements _i2.BindingWrapper { } @override - _i5.WidgetsBinding ensureInitialized() => - (super.noSuchMethod( - Invocation.method(#ensureInitialized, []), - returnValue: _FakeWidgetsBinding_10( - this, - Invocation.method(#ensureInitialized, []), - ), - ) - as _i5.WidgetsBinding); + _i5.WidgetsBinding ensureInitialized() => (super.noSuchMethod( + Invocation.method(#ensureInitialized, []), + returnValue: _FakeWidgetsBinding_10( + this, + Invocation.method(#ensureInitialized, []), + ), + ) as _i5.WidgetsBinding); } /// A class which mocks [WidgetsFlutterBinding]. @@ -1470,26 +1390,22 @@ class MockWidgetsFlutterBinding extends _i1.Mock } @override - _i6.SingletonFlutterWindow get window => - (super.noSuchMethod( - Invocation.getter(#window), - returnValue: _FakeSingletonFlutterWindow_11( - this, - Invocation.getter(#window), - ), - ) - as _i6.SingletonFlutterWindow); + _i6.SingletonFlutterWindow get window => (super.noSuchMethod( + Invocation.getter(#window), + returnValue: _FakeSingletonFlutterWindow_11( + this, + Invocation.getter(#window), + ), + ) as _i6.SingletonFlutterWindow); @override - _i6.PlatformDispatcher get platformDispatcher => - (super.noSuchMethod( - Invocation.getter(#platformDispatcher), - returnValue: _FakePlatformDispatcher_12( - this, - Invocation.getter(#platformDispatcher), - ), - ) - as _i6.PlatformDispatcher); + _i6.PlatformDispatcher get platformDispatcher => (super.noSuchMethod( + Invocation.getter(#platformDispatcher), + returnValue: _FakePlatformDispatcher_12( + this, + Invocation.getter(#platformDispatcher), + ), + ) as _i6.PlatformDispatcher); @override bool get locked => @@ -1497,91 +1413,77 @@ class MockWidgetsFlutterBinding extends _i1.Mock as bool); @override - _i7.PointerRouter get pointerRouter => - (super.noSuchMethod( - Invocation.getter(#pointerRouter), - returnValue: _FakePointerRouter_13( - this, - Invocation.getter(#pointerRouter), - ), - ) - as _i7.PointerRouter); + _i7.PointerRouter get pointerRouter => (super.noSuchMethod( + Invocation.getter(#pointerRouter), + returnValue: _FakePointerRouter_13( + this, + Invocation.getter(#pointerRouter), + ), + ) as _i7.PointerRouter); @override - _i7.GestureArenaManager get gestureArena => - (super.noSuchMethod( - Invocation.getter(#gestureArena), - returnValue: _FakeGestureArenaManager_14( - this, - Invocation.getter(#gestureArena), - ), - ) - as _i7.GestureArenaManager); + _i7.GestureArenaManager get gestureArena => (super.noSuchMethod( + Invocation.getter(#gestureArena), + returnValue: _FakeGestureArenaManager_14( + this, + Invocation.getter(#gestureArena), + ), + ) as _i7.GestureArenaManager); @override - _i7.PointerSignalResolver get pointerSignalResolver => - (super.noSuchMethod( - Invocation.getter(#pointerSignalResolver), - returnValue: _FakePointerSignalResolver_15( - this, - Invocation.getter(#pointerSignalResolver), - ), - ) - as _i7.PointerSignalResolver); + _i7.PointerSignalResolver get pointerSignalResolver => (super.noSuchMethod( + Invocation.getter(#pointerSignalResolver), + returnValue: _FakePointerSignalResolver_15( + this, + Invocation.getter(#pointerSignalResolver), + ), + ) as _i7.PointerSignalResolver); @override - bool get resamplingEnabled => - (super.noSuchMethod( - Invocation.getter(#resamplingEnabled), - returnValue: false, - ) - as bool); + bool get resamplingEnabled => (super.noSuchMethod( + Invocation.getter(#resamplingEnabled), + returnValue: false, + ) as bool); @override set resamplingEnabled(bool? _resamplingEnabled) => super.noSuchMethod( - Invocation.setter(#resamplingEnabled, _resamplingEnabled), - returnValueForMissingStub: null, - ); + Invocation.setter(#resamplingEnabled, _resamplingEnabled), + returnValueForMissingStub: null, + ); @override - Duration get samplingOffset => - (super.noSuchMethod( - Invocation.getter(#samplingOffset), - returnValue: _FakeDuration_16( - this, - Invocation.getter(#samplingOffset), - ), - ) - as Duration); + Duration get samplingOffset => (super.noSuchMethod( + Invocation.getter(#samplingOffset), + returnValue: _FakeDuration_16( + this, + Invocation.getter(#samplingOffset), + ), + ) as Duration); @override set samplingOffset(Duration? _samplingOffset) => super.noSuchMethod( - Invocation.setter(#samplingOffset, _samplingOffset), - returnValueForMissingStub: null, - ); + Invocation.setter(#samplingOffset, _samplingOffset), + returnValueForMissingStub: null, + ); @override - _i7.SamplingClock get samplingClock => - (super.noSuchMethod( - Invocation.getter(#samplingClock), - returnValue: _FakeSamplingClock_17( - this, - Invocation.getter(#samplingClock), - ), - ) - as _i7.SamplingClock); + _i7.SamplingClock get samplingClock => (super.noSuchMethod( + Invocation.getter(#samplingClock), + returnValue: _FakeSamplingClock_17( + this, + Invocation.getter(#samplingClock), + ), + ) as _i7.SamplingClock); @override - _i21.SchedulingStrategy get schedulingStrategy => - (super.noSuchMethod( - Invocation.getter(#schedulingStrategy), - returnValue: - ({ - required int priority, - required _i21.SchedulerBinding scheduler, - }) => false, - ) - as _i21.SchedulingStrategy); + _i21.SchedulingStrategy get schedulingStrategy => (super.noSuchMethod( + Invocation.getter(#schedulingStrategy), + returnValue: ({ + required int priority, + required _i21.SchedulerBinding scheduler, + }) => + false, + ) as _i21.SchedulingStrategy); @override set schedulingStrategy(_i21.SchedulingStrategy? _schedulingStrategy) => @@ -1591,36 +1493,28 @@ class MockWidgetsFlutterBinding extends _i1.Mock ); @override - int get transientCallbackCount => - (super.noSuchMethod( - Invocation.getter(#transientCallbackCount), - returnValue: 0, - ) - as int); + int get transientCallbackCount => (super.noSuchMethod( + Invocation.getter(#transientCallbackCount), + returnValue: 0, + ) as int); @override - _i11.Future get endOfFrame => - (super.noSuchMethod( - Invocation.getter(#endOfFrame), - returnValue: _i11.Future.value(), - ) - as _i11.Future); + _i11.Future get endOfFrame => (super.noSuchMethod( + Invocation.getter(#endOfFrame), + returnValue: _i11.Future.value(), + ) as _i11.Future); @override - bool get hasScheduledFrame => - (super.noSuchMethod( - Invocation.getter(#hasScheduledFrame), - returnValue: false, - ) - as bool); + bool get hasScheduledFrame => (super.noSuchMethod( + Invocation.getter(#hasScheduledFrame), + returnValue: false, + ) as bool); @override - _i21.SchedulerPhase get schedulerPhase => - (super.noSuchMethod( - Invocation.getter(#schedulerPhase), - returnValue: _i21.SchedulerPhase.idle, - ) - as _i21.SchedulerPhase); + _i21.SchedulerPhase get schedulerPhase => (super.noSuchMethod( + Invocation.getter(#schedulerPhase), + returnValue: _i21.SchedulerPhase.idle, + ) as _i21.SchedulerPhase); @override bool get framesEnabled => @@ -1628,220 +1522,178 @@ class MockWidgetsFlutterBinding extends _i1.Mock as bool); @override - Duration get currentFrameTimeStamp => - (super.noSuchMethod( - Invocation.getter(#currentFrameTimeStamp), - returnValue: _FakeDuration_16( - this, - Invocation.getter(#currentFrameTimeStamp), - ), - ) - as Duration); + Duration get currentFrameTimeStamp => (super.noSuchMethod( + Invocation.getter(#currentFrameTimeStamp), + returnValue: _FakeDuration_16( + this, + Invocation.getter(#currentFrameTimeStamp), + ), + ) as Duration); @override - Duration get currentSystemFrameTimeStamp => - (super.noSuchMethod( - Invocation.getter(#currentSystemFrameTimeStamp), - returnValue: _FakeDuration_16( - this, - Invocation.getter(#currentSystemFrameTimeStamp), - ), - ) - as Duration); + Duration get currentSystemFrameTimeStamp => (super.noSuchMethod( + Invocation.getter(#currentSystemFrameTimeStamp), + returnValue: _FakeDuration_16( + this, + Invocation.getter(#currentSystemFrameTimeStamp), + ), + ) as Duration); @override - _i8.ValueNotifier get accessibilityFocus => - (super.noSuchMethod( - Invocation.getter(#accessibilityFocus), - returnValue: _FakeValueNotifier_18( - this, - Invocation.getter(#accessibilityFocus), - ), - ) - as _i8.ValueNotifier); + _i8.ValueNotifier get accessibilityFocus => (super.noSuchMethod( + Invocation.getter(#accessibilityFocus), + returnValue: _FakeValueNotifier_18( + this, + Invocation.getter(#accessibilityFocus), + ), + ) as _i8.ValueNotifier); @override - _i4.HardwareKeyboard get keyboard => - (super.noSuchMethod( - Invocation.getter(#keyboard), - returnValue: _FakeHardwareKeyboard_19( - this, - Invocation.getter(#keyboard), - ), - ) - as _i4.HardwareKeyboard); + _i4.HardwareKeyboard get keyboard => (super.noSuchMethod( + Invocation.getter(#keyboard), + returnValue: _FakeHardwareKeyboard_19( + this, + Invocation.getter(#keyboard), + ), + ) as _i4.HardwareKeyboard); @override - _i4.KeyEventManager get keyEventManager => - (super.noSuchMethod( - Invocation.getter(#keyEventManager), - returnValue: _FakeKeyEventManager_20( - this, - Invocation.getter(#keyEventManager), - ), - ) - as _i4.KeyEventManager); + _i4.KeyEventManager get keyEventManager => (super.noSuchMethod( + Invocation.getter(#keyEventManager), + returnValue: _FakeKeyEventManager_20( + this, + Invocation.getter(#keyEventManager), + ), + ) as _i4.KeyEventManager); @override - _i4.BinaryMessenger get defaultBinaryMessenger => - (super.noSuchMethod( - Invocation.getter(#defaultBinaryMessenger), - returnValue: _FakeBinaryMessenger_9( - this, - Invocation.getter(#defaultBinaryMessenger), - ), - ) - as _i4.BinaryMessenger); + _i4.BinaryMessenger get defaultBinaryMessenger => (super.noSuchMethod( + Invocation.getter(#defaultBinaryMessenger), + returnValue: _FakeBinaryMessenger_9( + this, + Invocation.getter(#defaultBinaryMessenger), + ), + ) as _i4.BinaryMessenger); @override - _i6.ChannelBuffers get channelBuffers => - (super.noSuchMethod( - Invocation.getter(#channelBuffers), - returnValue: _FakeChannelBuffers_21( - this, - Invocation.getter(#channelBuffers), - ), - ) - as _i6.ChannelBuffers); + _i6.ChannelBuffers get channelBuffers => (super.noSuchMethod( + Invocation.getter(#channelBuffers), + returnValue: _FakeChannelBuffers_21( + this, + Invocation.getter(#channelBuffers), + ), + ) as _i6.ChannelBuffers); @override - _i4.RestorationManager get restorationManager => - (super.noSuchMethod( - Invocation.getter(#restorationManager), - returnValue: _FakeRestorationManager_22( - this, - Invocation.getter(#restorationManager), - ), - ) - as _i4.RestorationManager); + _i4.RestorationManager get restorationManager => (super.noSuchMethod( + Invocation.getter(#restorationManager), + returnValue: _FakeRestorationManager_22( + this, + Invocation.getter(#restorationManager), + ), + ) as _i4.RestorationManager); @override - _i9.ImageCache get imageCache => - (super.noSuchMethod( - Invocation.getter(#imageCache), - returnValue: _FakeImageCache_23( - this, - Invocation.getter(#imageCache), - ), - ) - as _i9.ImageCache); + _i9.ImageCache get imageCache => (super.noSuchMethod( + Invocation.getter(#imageCache), + returnValue: _FakeImageCache_23( + this, + Invocation.getter(#imageCache), + ), + ) as _i9.ImageCache); @override - _i8.Listenable get systemFonts => - (super.noSuchMethod( - Invocation.getter(#systemFonts), - returnValue: _FakeListenable_24( - this, - Invocation.getter(#systemFonts), - ), - ) - as _i8.Listenable); + _i8.Listenable get systemFonts => (super.noSuchMethod( + Invocation.getter(#systemFonts), + returnValue: _FakeListenable_24( + this, + Invocation.getter(#systemFonts), + ), + ) as _i8.Listenable); @override - bool get semanticsEnabled => - (super.noSuchMethod( - Invocation.getter(#semanticsEnabled), - returnValue: false, - ) - as bool); + bool get semanticsEnabled => (super.noSuchMethod( + Invocation.getter(#semanticsEnabled), + returnValue: false, + ) as bool); @override - int get debugOutstandingSemanticsHandles => - (super.noSuchMethod( - Invocation.getter(#debugOutstandingSemanticsHandles), - returnValue: 0, - ) - as int); + int get debugOutstandingSemanticsHandles => (super.noSuchMethod( + Invocation.getter(#debugOutstandingSemanticsHandles), + returnValue: 0, + ) as int); @override - _i6.AccessibilityFeatures get accessibilityFeatures => - (super.noSuchMethod( - Invocation.getter(#accessibilityFeatures), - returnValue: _FakeAccessibilityFeatures_25( - this, - Invocation.getter(#accessibilityFeatures), - ), - ) - as _i6.AccessibilityFeatures); + _i6.AccessibilityFeatures get accessibilityFeatures => (super.noSuchMethod( + Invocation.getter(#accessibilityFeatures), + returnValue: _FakeAccessibilityFeatures_25( + this, + Invocation.getter(#accessibilityFeatures), + ), + ) as _i6.AccessibilityFeatures); @override - bool get disableAnimations => - (super.noSuchMethod( - Invocation.getter(#disableAnimations), - returnValue: false, - ) - as bool); + bool get disableAnimations => (super.noSuchMethod( + Invocation.getter(#disableAnimations), + returnValue: false, + ) as bool); @override - _i10.PipelineOwner get pipelineOwner => - (super.noSuchMethod( - Invocation.getter(#pipelineOwner), - returnValue: _i14.dummyValue<_i10.PipelineOwner>( - this, - Invocation.getter(#pipelineOwner), - ), - ) - as _i10.PipelineOwner); + _i10.PipelineOwner get pipelineOwner => (super.noSuchMethod( + Invocation.getter(#pipelineOwner), + returnValue: _i14.dummyValue<_i10.PipelineOwner>( + this, + Invocation.getter(#pipelineOwner), + ), + ) as _i10.PipelineOwner); @override - _i10.RenderView get renderView => - (super.noSuchMethod( - Invocation.getter(#renderView), - returnValue: _FakeRenderView_26( - this, - Invocation.getter(#renderView), - ), - ) - as _i10.RenderView); + _i10.RenderView get renderView => (super.noSuchMethod( + Invocation.getter(#renderView), + returnValue: _FakeRenderView_26( + this, + Invocation.getter(#renderView), + ), + ) as _i10.RenderView); @override - _i10.MouseTracker get mouseTracker => - (super.noSuchMethod( - Invocation.getter(#mouseTracker), - returnValue: _FakeMouseTracker_27( - this, - Invocation.getter(#mouseTracker), - ), - ) - as _i10.MouseTracker); + _i10.MouseTracker get mouseTracker => (super.noSuchMethod( + Invocation.getter(#mouseTracker), + returnValue: _FakeMouseTracker_27( + this, + Invocation.getter(#mouseTracker), + ), + ) as _i10.MouseTracker); @override - _i10.PipelineOwner get rootPipelineOwner => - (super.noSuchMethod( - Invocation.getter(#rootPipelineOwner), - returnValue: _i14.dummyValue<_i10.PipelineOwner>( - this, - Invocation.getter(#rootPipelineOwner), - ), - ) - as _i10.PipelineOwner); + _i10.PipelineOwner get rootPipelineOwner => (super.noSuchMethod( + Invocation.getter(#rootPipelineOwner), + returnValue: _i14.dummyValue<_i10.PipelineOwner>( + this, + Invocation.getter(#rootPipelineOwner), + ), + ) as _i10.PipelineOwner); @override - Iterable<_i10.RenderView> get renderViews => - (super.noSuchMethod( - Invocation.getter(#renderViews), - returnValue: <_i10.RenderView>[], - ) - as Iterable<_i10.RenderView>); + Iterable<_i10.RenderView> get renderViews => (super.noSuchMethod( + Invocation.getter(#renderViews), + returnValue: <_i10.RenderView>[], + ) as Iterable<_i10.RenderView>); @override - bool get sendFramesToEngine => - (super.noSuchMethod( - Invocation.getter(#sendFramesToEngine), - returnValue: false, - ) - as bool); + bool get sendFramesToEngine => (super.noSuchMethod( + Invocation.getter(#sendFramesToEngine), + returnValue: false, + ) as bool); @override - _i9.PlatformMenuDelegate get platformMenuDelegate => - (super.noSuchMethod( - Invocation.getter(#platformMenuDelegate), - returnValue: _FakePlatformMenuDelegate_28( - this, - Invocation.getter(#platformMenuDelegate), - ), - ) - as _i9.PlatformMenuDelegate); + _i9.PlatformMenuDelegate get platformMenuDelegate => (super.noSuchMethod( + Invocation.getter(#platformMenuDelegate), + returnValue: _FakePlatformMenuDelegate_28( + this, + Invocation.getter(#platformMenuDelegate), + ), + ) as _i9.PlatformMenuDelegate); @override set platformMenuDelegate(_i9.PlatformMenuDelegate? _platformMenuDelegate) => @@ -1851,12 +1703,10 @@ class MockWidgetsFlutterBinding extends _i1.Mock ); @override - bool get debugBuildingDirtyElements => - (super.noSuchMethod( - Invocation.getter(#debugBuildingDirtyElements), - returnValue: false, - ) - as bool); + bool get debugBuildingDirtyElements => (super.noSuchMethod( + Invocation.getter(#debugBuildingDirtyElements), + returnValue: false, + ) as bool); @override set debugBuildingDirtyElements(bool? _debugBuildingDirtyElements) => @@ -1869,165 +1719,148 @@ class MockWidgetsFlutterBinding extends _i1.Mock ); @override - bool get debugShowWidgetInspectorOverride => - (super.noSuchMethod( - Invocation.getter(#debugShowWidgetInspectorOverride), - returnValue: false, - ) - as bool); + bool get debugShowWidgetInspectorOverride => (super.noSuchMethod( + Invocation.getter(#debugShowWidgetInspectorOverride), + returnValue: false, + ) as bool); @override set debugShowWidgetInspectorOverride(bool? value) => super.noSuchMethod( - Invocation.setter(#debugShowWidgetInspectorOverride, value), - returnValueForMissingStub: null, - ); + Invocation.setter(#debugShowWidgetInspectorOverride, value), + returnValueForMissingStub: null, + ); @override _i8.ValueNotifier get debugShowWidgetInspectorOverrideNotifier => (super.noSuchMethod( - Invocation.getter(#debugShowWidgetInspectorOverrideNotifier), - returnValue: _FakeValueNotifier_18( - this, - Invocation.getter(#debugShowWidgetInspectorOverrideNotifier), - ), - ) - as _i8.ValueNotifier); + Invocation.getter(#debugShowWidgetInspectorOverrideNotifier), + returnValue: _FakeValueNotifier_18( + this, + Invocation.getter(#debugShowWidgetInspectorOverrideNotifier), + ), + ) as _i8.ValueNotifier); @override - _i9.FocusManager get focusManager => - (super.noSuchMethod( - Invocation.getter(#focusManager), - returnValue: _FakeFocusManager_29( - this, - Invocation.getter(#focusManager), - ), - ) - as _i9.FocusManager); + _i9.FocusManager get focusManager => (super.noSuchMethod( + Invocation.getter(#focusManager), + returnValue: _FakeFocusManager_29( + this, + Invocation.getter(#focusManager), + ), + ) as _i9.FocusManager); @override - bool get firstFrameRasterized => - (super.noSuchMethod( - Invocation.getter(#firstFrameRasterized), - returnValue: false, - ) - as bool); + bool get firstFrameRasterized => (super.noSuchMethod( + Invocation.getter(#firstFrameRasterized), + returnValue: false, + ) as bool); @override - _i11.Future get waitUntilFirstFrameRasterized => - (super.noSuchMethod( - Invocation.getter(#waitUntilFirstFrameRasterized), - returnValue: _i11.Future.value(), - ) - as _i11.Future); + _i11.Future get waitUntilFirstFrameRasterized => (super.noSuchMethod( + Invocation.getter(#waitUntilFirstFrameRasterized), + returnValue: _i11.Future.value(), + ) as _i11.Future); @override - bool get debugDidSendFirstFrameEvent => - (super.noSuchMethod( - Invocation.getter(#debugDidSendFirstFrameEvent), - returnValue: false, - ) - as bool); + bool get debugDidSendFirstFrameEvent => (super.noSuchMethod( + Invocation.getter(#debugDidSendFirstFrameEvent), + returnValue: false, + ) as bool); @override - bool get isRootWidgetAttached => - (super.noSuchMethod( - Invocation.getter(#isRootWidgetAttached), - returnValue: false, - ) - as bool); + bool get isRootWidgetAttached => (super.noSuchMethod( + Invocation.getter(#isRootWidgetAttached), + returnValue: false, + ) as bool); @override void initInstances() => super.noSuchMethod( - Invocation.method(#initInstances, []), - returnValueForMissingStub: null, - ); + Invocation.method(#initInstances, []), + returnValueForMissingStub: null, + ); @override - bool debugCheckZone(String? entryPoint) => - (super.noSuchMethod( - Invocation.method(#debugCheckZone, [entryPoint]), - returnValue: false, - ) - as bool); + bool debugCheckZone(String? entryPoint) => (super.noSuchMethod( + Invocation.method(#debugCheckZone, [entryPoint]), + returnValue: false, + ) as bool); @override void initServiceExtensions() => super.noSuchMethod( - Invocation.method(#initServiceExtensions, []), - returnValueForMissingStub: null, - ); + Invocation.method(#initServiceExtensions, []), + returnValueForMissingStub: null, + ); @override _i11.Future lockEvents(_i11.Future Function()? callback) => (super.noSuchMethod( - Invocation.method(#lockEvents, [callback]), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + Invocation.method(#lockEvents, [callback]), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override void unlocked() => super.noSuchMethod( - Invocation.method(#unlocked, []), - returnValueForMissingStub: null, - ); + Invocation.method(#unlocked, []), + returnValueForMissingStub: null, + ); @override - _i11.Future reassembleApplication() => - (super.noSuchMethod( - Invocation.method(#reassembleApplication, []), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + _i11.Future reassembleApplication() => (super.noSuchMethod( + Invocation.method(#reassembleApplication, []), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override - _i11.Future performReassemble() => - (super.noSuchMethod( - Invocation.method(#performReassemble, []), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + _i11.Future performReassemble() => (super.noSuchMethod( + Invocation.method(#performReassemble, []), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override void registerSignalServiceExtension({ required String? name, required _i8.AsyncCallback? callback, - }) => super.noSuchMethod( - Invocation.method(#registerSignalServiceExtension, [], { - #name: name, - #callback: callback, - }), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method(#registerSignalServiceExtension, [], { + #name: name, + #callback: callback, + }), + returnValueForMissingStub: null, + ); @override void registerBoolServiceExtension({ required String? name, required _i8.AsyncValueGetter? getter, required _i8.AsyncValueSetter? setter, - }) => super.noSuchMethod( - Invocation.method(#registerBoolServiceExtension, [], { - #name: name, - #getter: getter, - #setter: setter, - }), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method(#registerBoolServiceExtension, [], { + #name: name, + #getter: getter, + #setter: setter, + }), + returnValueForMissingStub: null, + ); @override void registerNumericServiceExtension({ required String? name, required _i8.AsyncValueGetter? getter, required _i8.AsyncValueSetter? setter, - }) => super.noSuchMethod( - Invocation.method(#registerNumericServiceExtension, [], { - #name: name, - #getter: getter, - #setter: setter, - }), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method(#registerNumericServiceExtension, [], { + #name: name, + #getter: getter, + #setter: setter, + }), + returnValueForMissingStub: null, + ); @override void postEvent(String? eventKind, Map? eventData) => @@ -2041,48 +1874,51 @@ class MockWidgetsFlutterBinding extends _i1.Mock required String? name, required _i8.AsyncValueGetter? getter, required _i8.AsyncValueSetter? setter, - }) => super.noSuchMethod( - Invocation.method(#registerStringServiceExtension, [], { - #name: name, - #getter: getter, - #setter: setter, - }), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method(#registerStringServiceExtension, [], { + #name: name, + #getter: getter, + #setter: setter, + }), + returnValueForMissingStub: null, + ); @override void registerServiceExtension({ required String? name, required _i8.ServiceExtensionCallback? callback, - }) => super.noSuchMethod( - Invocation.method(#registerServiceExtension, [], { - #name: name, - #callback: callback, - }), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method(#registerServiceExtension, [], { + #name: name, + #callback: callback, + }), + returnValueForMissingStub: null, + ); @override void cancelPointer(int? pointer) => super.noSuchMethod( - Invocation.method(#cancelPointer, [pointer]), - returnValueForMissingStub: null, - ); + Invocation.method(#cancelPointer, [pointer]), + returnValueForMissingStub: null, + ); @override void handlePointerEvent(_i4.PointerEvent? event) => super.noSuchMethod( - Invocation.method(#handlePointerEvent, [event]), - returnValueForMissingStub: null, - ); + Invocation.method(#handlePointerEvent, [event]), + returnValueForMissingStub: null, + ); @override void hitTestInView( _i7.HitTestResult? result, _i6.Offset? position, int? viewId, - ) => super.noSuchMethod( - Invocation.method(#hitTestInView, [result, position, viewId]), - returnValueForMissingStub: null, - ); + ) => + super.noSuchMethod( + Invocation.method(#hitTestInView, [result, position, viewId]), + returnValueForMissingStub: null, + ); @override void hitTest(_i7.HitTestResult? result, _i6.Offset? position) => @@ -2095,31 +1931,33 @@ class MockWidgetsFlutterBinding extends _i1.Mock void dispatchEvent( _i4.PointerEvent? event, _i7.HitTestResult? hitTestResult, - ) => super.noSuchMethod( - Invocation.method(#dispatchEvent, [event, hitTestResult]), - returnValueForMissingStub: null, - ); + ) => + super.noSuchMethod( + Invocation.method(#dispatchEvent, [event, hitTestResult]), + returnValueForMissingStub: null, + ); @override void handleEvent( _i4.PointerEvent? event, _i7.HitTestEntry<_i7.HitTestTarget>? entry, - ) => super.noSuchMethod( - Invocation.method(#handleEvent, [event, entry]), - returnValueForMissingStub: null, - ); + ) => + super.noSuchMethod( + Invocation.method(#handleEvent, [event, entry]), + returnValueForMissingStub: null, + ); @override void resetGestureBinding() => super.noSuchMethod( - Invocation.method(#resetGestureBinding, []), - returnValueForMissingStub: null, - ); + Invocation.method(#resetGestureBinding, []), + returnValueForMissingStub: null, + ); @override void addTimingsCallback(_i6.TimingsCallback? callback) => super.noSuchMethod( - Invocation.method(#addTimingsCallback, [callback]), - returnValueForMissingStub: null, - ); + Invocation.method(#addTimingsCallback, [callback]), + returnValueForMissingStub: null, + ); @override void removeTimingsCallback(_i6.TimingsCallback? callback) => @@ -2130,9 +1968,9 @@ class MockWidgetsFlutterBinding extends _i1.Mock @override void resetInternalState() => super.noSuchMethod( - Invocation.method(#resetInternalState, []), - returnValueForMissingStub: null, - ); + Invocation.method(#resetInternalState, []), + returnValueForMissingStub: null, + ); @override void handleAppLifecycleStateChanged(_i6.AppLifecycleState? state) => @@ -2149,41 +1987,37 @@ class MockWidgetsFlutterBinding extends _i1.Mock _i22.Flow? flow, }) => (super.noSuchMethod( - Invocation.method( - #scheduleTask, - [task, priority], - {#debugLabel: debugLabel, #flow: flow}, - ), - returnValue: - _i14.ifNotNull( - _i14.dummyValueOrNull( - this, - Invocation.method( - #scheduleTask, - [task, priority], - {#debugLabel: debugLabel, #flow: flow}, - ), - ), - (T v) => _i11.Future.value(v), - ) ?? - _FakeFuture_30( - this, - Invocation.method( - #scheduleTask, - [task, priority], - {#debugLabel: debugLabel, #flow: flow}, - ), + Invocation.method( + #scheduleTask, + [task, priority], + {#debugLabel: debugLabel, #flow: flow}, + ), + returnValue: _i14.ifNotNull( + _i14.dummyValueOrNull( + this, + Invocation.method( + #scheduleTask, + [task, priority], + {#debugLabel: debugLabel, #flow: flow}, ), - ) - as _i11.Future); + ), + (T v) => _i11.Future.value(v), + ) ?? + _FakeFuture_30( + this, + Invocation.method( + #scheduleTask, + [task, priority], + {#debugLabel: debugLabel, #flow: flow}, + ), + ), + ) as _i11.Future); @override - bool handleEventLoopCallback() => - (super.noSuchMethod( - Invocation.method(#handleEventLoopCallback, []), - returnValue: false, - ) - as bool); + bool handleEventLoopCallback() => (super.noSuchMethod( + Invocation.method(#handleEventLoopCallback, []), + returnValue: false, + ) as bool); @override int scheduleFrameCallback( @@ -2191,46 +2025,40 @@ class MockWidgetsFlutterBinding extends _i1.Mock bool? rescheduling = false, }) => (super.noSuchMethod( - Invocation.method( - #scheduleFrameCallback, - [callback], - {#rescheduling: rescheduling}, - ), - returnValue: 0, - ) - as int); + Invocation.method( + #scheduleFrameCallback, + [callback], + {#rescheduling: rescheduling}, + ), + returnValue: 0, + ) as int); @override void cancelFrameCallbackWithId(int? id) => super.noSuchMethod( - Invocation.method(#cancelFrameCallbackWithId, [id]), - returnValueForMissingStub: null, - ); + Invocation.method(#cancelFrameCallbackWithId, [id]), + returnValueForMissingStub: null, + ); @override - bool debugAssertNoTransientCallbacks(String? reason) => - (super.noSuchMethod( - Invocation.method(#debugAssertNoTransientCallbacks, [reason]), - returnValue: false, - ) - as bool); + bool debugAssertNoTransientCallbacks(String? reason) => (super.noSuchMethod( + Invocation.method(#debugAssertNoTransientCallbacks, [reason]), + returnValue: false, + ) as bool); @override bool debugAssertNoPendingPerformanceModeRequests(String? reason) => (super.noSuchMethod( - Invocation.method(#debugAssertNoPendingPerformanceModeRequests, [ - reason, - ]), - returnValue: false, - ) - as bool); + Invocation.method(#debugAssertNoPendingPerformanceModeRequests, [ + reason, + ]), + returnValue: false, + ) as bool); @override - bool debugAssertNoTimeDilation(String? reason) => - (super.noSuchMethod( - Invocation.method(#debugAssertNoTimeDilation, [reason]), - returnValue: false, - ) - as bool); + bool debugAssertNoTimeDilation(String? reason) => (super.noSuchMethod( + Invocation.method(#debugAssertNoTimeDilation, [reason]), + returnValue: false, + ) as bool); @override void addPersistentFrameCallback(_i21.FrameCallback? callback) => @@ -2243,56 +2071,57 @@ class MockWidgetsFlutterBinding extends _i1.Mock void addPostFrameCallback( _i21.FrameCallback? callback, { String? debugLabel = 'callback', - }) => super.noSuchMethod( - Invocation.method( - #addPostFrameCallback, - [callback], - {#debugLabel: debugLabel}, - ), - returnValueForMissingStub: null, - ); + }) => + super.noSuchMethod( + Invocation.method( + #addPostFrameCallback, + [callback], + {#debugLabel: debugLabel}, + ), + returnValueForMissingStub: null, + ); @override void ensureFrameCallbacksRegistered() => super.noSuchMethod( - Invocation.method(#ensureFrameCallbacksRegistered, []), - returnValueForMissingStub: null, - ); + Invocation.method(#ensureFrameCallbacksRegistered, []), + returnValueForMissingStub: null, + ); @override void ensureVisualUpdate() => super.noSuchMethod( - Invocation.method(#ensureVisualUpdate, []), - returnValueForMissingStub: null, - ); + Invocation.method(#ensureVisualUpdate, []), + returnValueForMissingStub: null, + ); @override void scheduleFrame() => super.noSuchMethod( - Invocation.method(#scheduleFrame, []), - returnValueForMissingStub: null, - ); + Invocation.method(#scheduleFrame, []), + returnValueForMissingStub: null, + ); @override void scheduleForcedFrame() => super.noSuchMethod( - Invocation.method(#scheduleForcedFrame, []), - returnValueForMissingStub: null, - ); + Invocation.method(#scheduleForcedFrame, []), + returnValueForMissingStub: null, + ); @override void scheduleWarmUpFrame() => super.noSuchMethod( - Invocation.method(#scheduleWarmUpFrame, []), - returnValueForMissingStub: null, - ); + Invocation.method(#scheduleWarmUpFrame, []), + returnValueForMissingStub: null, + ); @override void resetEpoch() => super.noSuchMethod( - Invocation.method(#resetEpoch, []), - returnValueForMissingStub: null, - ); + Invocation.method(#resetEpoch, []), + returnValueForMissingStub: null, + ); @override void handleBeginFrame(Duration? rawTimeStamp) => super.noSuchMethod( - Invocation.method(#handleBeginFrame, [rawTimeStamp]), - returnValueForMissingStub: null, - ); + Invocation.method(#handleBeginFrame, [rawTimeStamp]), + returnValueForMissingStub: null, + ); @override _i21.PerformanceModeRequestHandle? requestPerformanceMode( @@ -2303,69 +2132,65 @@ class MockWidgetsFlutterBinding extends _i1.Mock @override void handleDrawFrame() => super.noSuchMethod( - Invocation.method(#handleDrawFrame, []), - returnValueForMissingStub: null, - ); + Invocation.method(#handleDrawFrame, []), + returnValueForMissingStub: null, + ); @override - _i4.BinaryMessenger createBinaryMessenger() => - (super.noSuchMethod( - Invocation.method(#createBinaryMessenger, []), - returnValue: _FakeBinaryMessenger_9( - this, - Invocation.method(#createBinaryMessenger, []), - ), - ) - as _i4.BinaryMessenger); + _i4.BinaryMessenger createBinaryMessenger() => (super.noSuchMethod( + Invocation.method(#createBinaryMessenger, []), + returnValue: _FakeBinaryMessenger_9( + this, + Invocation.method(#createBinaryMessenger, []), + ), + ) as _i4.BinaryMessenger); @override void handleMemoryPressure() => super.noSuchMethod( - Invocation.method(#handleMemoryPressure, []), - returnValueForMissingStub: null, - ); + Invocation.method(#handleMemoryPressure, []), + returnValueForMissingStub: null, + ); @override _i11.Future handleSystemMessage(Object? systemMessage) => (super.noSuchMethod( - Invocation.method(#handleSystemMessage, [systemMessage]), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + Invocation.method(#handleSystemMessage, [systemMessage]), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override void initLicenses() => super.noSuchMethod( - Invocation.method(#initLicenses, []), - returnValueForMissingStub: null, - ); + Invocation.method(#initLicenses, []), + returnValueForMissingStub: null, + ); @override void evict(String? asset) => super.noSuchMethod( - Invocation.method(#evict, [asset]), - returnValueForMissingStub: null, - ); + Invocation.method(#evict, [asset]), + returnValueForMissingStub: null, + ); @override void readInitialLifecycleStateFromNativeWindow() => super.noSuchMethod( - Invocation.method(#readInitialLifecycleStateFromNativeWindow, []), - returnValueForMissingStub: null, - ); + Invocation.method(#readInitialLifecycleStateFromNativeWindow, []), + returnValueForMissingStub: null, + ); @override void handleViewFocusChanged(_i6.ViewFocusEvent? event) => super.noSuchMethod( - Invocation.method(#handleViewFocusChanged, [event]), - returnValueForMissingStub: null, - ); + Invocation.method(#handleViewFocusChanged, [event]), + returnValueForMissingStub: null, + ); @override _i11.Future<_i6.AppExitResponse> handleRequestAppExit() => (super.noSuchMethod( - Invocation.method(#handleRequestAppExit, []), - returnValue: _i11.Future<_i6.AppExitResponse>.value( - _i6.AppExitResponse.exit, - ), - ) - as _i11.Future<_i6.AppExitResponse>); + Invocation.method(#handleRequestAppExit, []), + returnValue: _i11.Future<_i6.AppExitResponse>.value( + _i6.AppExitResponse.exit, + ), + ) as _i11.Future<_i6.AppExitResponse>); @override _i11.Future<_i6.AppExitResponse> exitApplication( @@ -2373,23 +2198,20 @@ class MockWidgetsFlutterBinding extends _i1.Mock int? exitCode = 0, ]) => (super.noSuchMethod( - Invocation.method(#exitApplication, [exitType, exitCode]), - returnValue: _i11.Future<_i6.AppExitResponse>.value( - _i6.AppExitResponse.exit, - ), - ) - as _i11.Future<_i6.AppExitResponse>); + Invocation.method(#exitApplication, [exitType, exitCode]), + returnValue: _i11.Future<_i6.AppExitResponse>.value( + _i6.AppExitResponse.exit, + ), + ) as _i11.Future<_i6.AppExitResponse>); @override - _i4.RestorationManager createRestorationManager() => - (super.noSuchMethod( - Invocation.method(#createRestorationManager, []), - returnValue: _FakeRestorationManager_22( - this, - Invocation.method(#createRestorationManager, []), - ), - ) - as _i4.RestorationManager); + _i4.RestorationManager createRestorationManager() => (super.noSuchMethod( + Invocation.method(#createRestorationManager, []), + returnValue: _FakeRestorationManager_22( + this, + Invocation.method(#createRestorationManager, []), + ), + ) as _i4.RestorationManager); @override void setSystemUiChangeCallback(_i4.SystemUiChangeCallback? callback) => @@ -2399,24 +2221,20 @@ class MockWidgetsFlutterBinding extends _i1.Mock ); @override - _i11.Future initializationComplete() => - (super.noSuchMethod( - Invocation.method(#initializationComplete, []), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + _i11.Future initializationComplete() => (super.noSuchMethod( + Invocation.method(#initializationComplete, []), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override - _i9.ImageCache createImageCache() => - (super.noSuchMethod( - Invocation.method(#createImageCache, []), - returnValue: _FakeImageCache_23( - this, - Invocation.method(#createImageCache, []), - ), - ) - as _i9.ImageCache); + _i9.ImageCache createImageCache() => (super.noSuchMethod( + Invocation.method(#createImageCache, []), + returnValue: _FakeImageCache_23( + this, + Invocation.method(#createImageCache, []), + ), + ) as _i9.ImageCache); @override _i11.Future<_i6.Codec> instantiateImageCodecFromBuffer( @@ -2426,6 +2244,18 @@ class MockWidgetsFlutterBinding extends _i1.Mock bool? allowUpscaling = false, }) => (super.noSuchMethod( + Invocation.method( + #instantiateImageCodecFromBuffer, + [buffer], + { + #cacheWidth: cacheWidth, + #cacheHeight: cacheHeight, + #allowUpscaling: allowUpscaling, + }, + ), + returnValue: _i11.Future<_i6.Codec>.value( + _FakeCodec_31( + this, Invocation.method( #instantiateImageCodecFromBuffer, [buffer], @@ -2435,22 +2265,9 @@ class MockWidgetsFlutterBinding extends _i1.Mock #allowUpscaling: allowUpscaling, }, ), - returnValue: _i11.Future<_i6.Codec>.value( - _FakeCodec_31( - this, - Invocation.method( - #instantiateImageCodecFromBuffer, - [buffer], - { - #cacheWidth: cacheWidth, - #cacheHeight: cacheHeight, - #allowUpscaling: allowUpscaling, - }, - ), - ), - ), - ) - as _i11.Future<_i6.Codec>); + ), + ), + ) as _i11.Future<_i6.Codec>); @override _i11.Future<_i6.Codec> instantiateImageCodecWithSize( @@ -2458,23 +2275,22 @@ class MockWidgetsFlutterBinding extends _i1.Mock _i6.TargetImageSizeCallback? getTargetSize, }) => (super.noSuchMethod( + Invocation.method( + #instantiateImageCodecWithSize, + [buffer], + {#getTargetSize: getTargetSize}, + ), + returnValue: _i11.Future<_i6.Codec>.value( + _FakeCodec_31( + this, Invocation.method( #instantiateImageCodecWithSize, [buffer], {#getTargetSize: getTargetSize}, ), - returnValue: _i11.Future<_i6.Codec>.value( - _FakeCodec_31( - this, - Invocation.method( - #instantiateImageCodecWithSize, - [buffer], - {#getTargetSize: getTargetSize}, - ), - ), - ), - ) - as _i11.Future<_i6.Codec>); + ), + ), + ) as _i11.Future<_i6.Codec>); @override void addSemanticsEnabledListener(_i6.VoidCallback? listener) => @@ -2491,15 +2307,13 @@ class MockWidgetsFlutterBinding extends _i1.Mock ); @override - _i12.SemanticsHandle ensureSemantics() => - (super.noSuchMethod( - Invocation.method(#ensureSemantics, []), - returnValue: _FakeSemanticsHandle_32( - this, - Invocation.method(#ensureSemantics, []), - ), - ) - as _i12.SemanticsHandle); + _i12.SemanticsHandle ensureSemantics() => (super.noSuchMethod( + Invocation.method(#ensureSemantics, []), + returnValue: _FakeSemanticsHandle_32( + this, + Invocation.method(#ensureSemantics, []), + ), + ) as _i12.SemanticsHandle); @override void performSemanticsAction(_i6.SemanticsActionEvent? action) => @@ -2510,225 +2324,207 @@ class MockWidgetsFlutterBinding extends _i1.Mock @override void handleAccessibilityFeaturesChanged() => super.noSuchMethod( - Invocation.method(#handleAccessibilityFeaturesChanged, []), - returnValueForMissingStub: null, - ); + Invocation.method(#handleAccessibilityFeaturesChanged, []), + returnValueForMissingStub: null, + ); @override _i6.SemanticsUpdateBuilder createSemanticsUpdateBuilder() => (super.noSuchMethod( - Invocation.method(#createSemanticsUpdateBuilder, []), - returnValue: _FakeSemanticsUpdateBuilder_33( - this, - Invocation.method(#createSemanticsUpdateBuilder, []), - ), - ) - as _i6.SemanticsUpdateBuilder); + Invocation.method(#createSemanticsUpdateBuilder, []), + returnValue: _FakeSemanticsUpdateBuilder_33( + this, + Invocation.method(#createSemanticsUpdateBuilder, []), + ), + ) as _i6.SemanticsUpdateBuilder); @override - _i10.PipelineOwner createRootPipelineOwner() => - (super.noSuchMethod( - Invocation.method(#createRootPipelineOwner, []), - returnValue: _i14.dummyValue<_i10.PipelineOwner>( - this, - Invocation.method(#createRootPipelineOwner, []), - ), - ) - as _i10.PipelineOwner); + _i10.PipelineOwner createRootPipelineOwner() => (super.noSuchMethod( + Invocation.method(#createRootPipelineOwner, []), + returnValue: _i14.dummyValue<_i10.PipelineOwner>( + this, + Invocation.method(#createRootPipelineOwner, []), + ), + ) as _i10.PipelineOwner); @override void addRenderView(_i10.RenderView? view) => super.noSuchMethod( - Invocation.method(#addRenderView, [view]), - returnValueForMissingStub: null, - ); + Invocation.method(#addRenderView, [view]), + returnValueForMissingStub: null, + ); @override void removeRenderView(_i10.RenderView? view) => super.noSuchMethod( - Invocation.method(#removeRenderView, [view]), - returnValueForMissingStub: null, - ); + Invocation.method(#removeRenderView, [view]), + returnValueForMissingStub: null, + ); @override _i10.ViewConfiguration createViewConfigurationFor( _i10.RenderView? renderView, ) => (super.noSuchMethod( - Invocation.method(#createViewConfigurationFor, [renderView]), - returnValue: _FakeViewConfiguration_34( - this, - Invocation.method(#createViewConfigurationFor, [renderView]), - ), - ) - as _i10.ViewConfiguration); + Invocation.method(#createViewConfigurationFor, [renderView]), + returnValue: _FakeViewConfiguration_34( + this, + Invocation.method(#createViewConfigurationFor, [renderView]), + ), + ) as _i10.ViewConfiguration); @override - _i6.SceneBuilder createSceneBuilder() => - (super.noSuchMethod( - Invocation.method(#createSceneBuilder, []), - returnValue: _FakeSceneBuilder_35( - this, - Invocation.method(#createSceneBuilder, []), - ), - ) - as _i6.SceneBuilder); + _i6.SceneBuilder createSceneBuilder() => (super.noSuchMethod( + Invocation.method(#createSceneBuilder, []), + returnValue: _FakeSceneBuilder_35( + this, + Invocation.method(#createSceneBuilder, []), + ), + ) as _i6.SceneBuilder); @override - _i6.PictureRecorder createPictureRecorder() => - (super.noSuchMethod( - Invocation.method(#createPictureRecorder, []), - returnValue: _FakePictureRecorder_36( - this, - Invocation.method(#createPictureRecorder, []), - ), - ) - as _i6.PictureRecorder); + _i6.PictureRecorder createPictureRecorder() => (super.noSuchMethod( + Invocation.method(#createPictureRecorder, []), + returnValue: _FakePictureRecorder_36( + this, + Invocation.method(#createPictureRecorder, []), + ), + ) as _i6.PictureRecorder); @override - _i6.Canvas createCanvas(_i6.PictureRecorder? recorder) => - (super.noSuchMethod( - Invocation.method(#createCanvas, [recorder]), - returnValue: _FakeCanvas_37( - this, - Invocation.method(#createCanvas, [recorder]), - ), - ) - as _i6.Canvas); + _i6.Canvas createCanvas(_i6.PictureRecorder? recorder) => (super.noSuchMethod( + Invocation.method(#createCanvas, [recorder]), + returnValue: _FakeCanvas_37( + this, + Invocation.method(#createCanvas, [recorder]), + ), + ) as _i6.Canvas); @override void handleMetricsChanged() => super.noSuchMethod( - Invocation.method(#handleMetricsChanged, []), - returnValueForMissingStub: null, - ); + Invocation.method(#handleMetricsChanged, []), + returnValueForMissingStub: null, + ); @override void handleTextScaleFactorChanged() => super.noSuchMethod( - Invocation.method(#handleTextScaleFactorChanged, []), - returnValueForMissingStub: null, - ); + Invocation.method(#handleTextScaleFactorChanged, []), + returnValueForMissingStub: null, + ); @override void handlePlatformBrightnessChanged() => super.noSuchMethod( - Invocation.method(#handlePlatformBrightnessChanged, []), - returnValueForMissingStub: null, - ); + Invocation.method(#handlePlatformBrightnessChanged, []), + returnValueForMissingStub: null, + ); @override void initMouseTracker([_i10.MouseTracker? tracker]) => super.noSuchMethod( - Invocation.method(#initMouseTracker, [tracker]), - returnValueForMissingStub: null, - ); + Invocation.method(#initMouseTracker, [tracker]), + returnValueForMissingStub: null, + ); @override void deferFirstFrame() => super.noSuchMethod( - Invocation.method(#deferFirstFrame, []), - returnValueForMissingStub: null, - ); + Invocation.method(#deferFirstFrame, []), + returnValueForMissingStub: null, + ); @override void allowFirstFrame() => super.noSuchMethod( - Invocation.method(#allowFirstFrame, []), - returnValueForMissingStub: null, - ); + Invocation.method(#allowFirstFrame, []), + returnValueForMissingStub: null, + ); @override void resetFirstFrameSent() => super.noSuchMethod( - Invocation.method(#resetFirstFrameSent, []), - returnValueForMissingStub: null, - ); + Invocation.method(#resetFirstFrameSent, []), + returnValueForMissingStub: null, + ); @override void drawFrame() => super.noSuchMethod( - Invocation.method(#drawFrame, []), - returnValueForMissingStub: null, - ); + Invocation.method(#drawFrame, []), + returnValueForMissingStub: null, + ); @override void addObserver(_i5.WidgetsBindingObserver? observer) => super.noSuchMethod( - Invocation.method(#addObserver, [observer]), - returnValueForMissingStub: null, - ); + Invocation.method(#addObserver, [observer]), + returnValueForMissingStub: null, + ); @override bool removeObserver(_i5.WidgetsBindingObserver? observer) => (super.noSuchMethod( - Invocation.method(#removeObserver, [observer]), - returnValue: false, - ) - as bool); + Invocation.method(#removeObserver, [observer]), + returnValue: false, + ) as bool); @override void handleLocaleChanged() => super.noSuchMethod( - Invocation.method(#handleLocaleChanged, []), - returnValueForMissingStub: null, - ); + Invocation.method(#handleLocaleChanged, []), + returnValueForMissingStub: null, + ); @override void dispatchLocalesChanged(List<_i6.Locale>? locales) => super.noSuchMethod( - Invocation.method(#dispatchLocalesChanged, [locales]), - returnValueForMissingStub: null, - ); + Invocation.method(#dispatchLocalesChanged, [locales]), + returnValueForMissingStub: null, + ); @override void dispatchAccessibilityFeaturesChanged() => super.noSuchMethod( - Invocation.method(#dispatchAccessibilityFeaturesChanged, []), - returnValueForMissingStub: null, - ); + Invocation.method(#dispatchAccessibilityFeaturesChanged, []), + returnValueForMissingStub: null, + ); @override - _i11.Future handlePopRoute() => - (super.noSuchMethod( - Invocation.method(#handlePopRoute, []), - returnValue: _i11.Future.value(false), - ) - as _i11.Future); + _i11.Future handlePopRoute() => (super.noSuchMethod( + Invocation.method(#handlePopRoute, []), + returnValue: _i11.Future.value(false), + ) as _i11.Future); @override - _i11.Future handlePushRoute(String? route) => - (super.noSuchMethod( - Invocation.method(#handlePushRoute, [route]), - returnValue: _i11.Future.value(false), - ) - as _i11.Future); + _i11.Future handlePushRoute(String? route) => (super.noSuchMethod( + Invocation.method(#handlePushRoute, [route]), + returnValue: _i11.Future.value(false), + ) as _i11.Future); @override - _i9.Widget wrapWithDefaultView(_i9.Widget? rootWidget) => - (super.noSuchMethod( - Invocation.method(#wrapWithDefaultView, [rootWidget]), - returnValue: _FakeWidget_38( - this, - Invocation.method(#wrapWithDefaultView, [rootWidget]), - ), - ) - as _i9.Widget); + _i9.Widget wrapWithDefaultView(_i9.Widget? rootWidget) => (super.noSuchMethod( + Invocation.method(#wrapWithDefaultView, [rootWidget]), + returnValue: _FakeWidget_38( + this, + Invocation.method(#wrapWithDefaultView, [rootWidget]), + ), + ) as _i9.Widget); @override void scheduleAttachRootWidget(_i9.Widget? rootWidget) => super.noSuchMethod( - Invocation.method(#scheduleAttachRootWidget, [rootWidget]), - returnValueForMissingStub: null, - ); + Invocation.method(#scheduleAttachRootWidget, [rootWidget]), + returnValueForMissingStub: null, + ); @override void attachRootWidget(_i9.Widget? rootWidget) => super.noSuchMethod( - Invocation.method(#attachRootWidget, [rootWidget]), - returnValueForMissingStub: null, - ); + Invocation.method(#attachRootWidget, [rootWidget]), + returnValueForMissingStub: null, + ); @override void attachToBuildOwner(_i5.RootWidget? widget) => super.noSuchMethod( - Invocation.method(#attachToBuildOwner, [widget]), - returnValueForMissingStub: null, - ); + Invocation.method(#attachToBuildOwner, [widget]), + returnValueForMissingStub: null, + ); @override _i6.Locale? computePlatformResolvedLocale( List<_i6.Locale>? supportedLocales, ) => (super.noSuchMethod( - Invocation.method(#computePlatformResolvedLocale, [ - supportedLocales, - ]), - ) - as _i6.Locale?); + Invocation.method(#computePlatformResolvedLocale, [ + supportedLocales, + ]), + ) as _i6.Locale?); } /// A class which mocks [SentryJsBinding]. @@ -2741,21 +2537,21 @@ class MockSentryJsBinding extends _i1.Mock implements _i23.SentryJsBinding { @override void init(Map? options) => super.noSuchMethod( - Invocation.method(#init, [options]), - returnValueForMissingStub: null, - ); + Invocation.method(#init, [options]), + returnValueForMissingStub: null, + ); @override void close() => super.noSuchMethod( - Invocation.method(#close, []), - returnValueForMissingStub: null, - ); + Invocation.method(#close, []), + returnValueForMissingStub: null, + ); @override void captureEnvelope(List? envelope) => super.noSuchMethod( - Invocation.method(#captureEnvelope, [envelope]), - returnValueForMissingStub: null, - ); + Invocation.method(#captureEnvelope, [envelope]), + returnValueForMissingStub: null, + ); } /// A class which mocks [Hub]. @@ -2767,15 +2563,13 @@ class MockHub extends _i1.Mock implements _i2.Hub { } @override - _i2.SentryOptions get options => - (super.noSuchMethod( - Invocation.getter(#options), - returnValue: _FakeSentryOptions_39( - this, - Invocation.getter(#options), - ), - ) - as _i2.SentryOptions); + _i2.SentryOptions get options => (super.noSuchMethod( + Invocation.getter(#options), + returnValue: _FakeSentryOptions_39( + this, + Invocation.getter(#options), + ), + ) as _i2.SentryOptions); @override bool get isEnabled => @@ -2783,26 +2577,22 @@ class MockHub extends _i1.Mock implements _i2.Hub { as bool); @override - _i2.SentryId get lastEventId => - (super.noSuchMethod( - Invocation.getter(#lastEventId), - returnValue: _FakeSentryId_5(this, Invocation.getter(#lastEventId)), - ) - as _i2.SentryId); + _i2.SentryId get lastEventId => (super.noSuchMethod( + Invocation.getter(#lastEventId), + returnValue: _FakeSentryId_5(this, Invocation.getter(#lastEventId)), + ) as _i2.SentryId); @override - _i2.Scope get scope => - (super.noSuchMethod( - Invocation.getter(#scope), - returnValue: _FakeScope_40(this, Invocation.getter(#scope)), - ) - as _i2.Scope); + _i2.Scope get scope => (super.noSuchMethod( + Invocation.getter(#scope), + returnValue: _FakeScope_40(this, Invocation.getter(#scope)), + ) as _i2.Scope); @override set profilerFactory(_i15.SentryProfilerFactory? value) => super.noSuchMethod( - Invocation.setter(#profilerFactory, value), - returnValueForMissingStub: null, - ); + Invocation.setter(#profilerFactory, value), + returnValueForMissingStub: null, + ); @override _i11.Future<_i2.SentryId> captureEvent( @@ -2812,23 +2602,22 @@ class MockHub extends _i1.Mock implements _i2.Hub { _i2.ScopeCallback? withScope, }) => (super.noSuchMethod( + Invocation.method( + #captureEvent, + [event], + {#stackTrace: stackTrace, #hint: hint, #withScope: withScope}, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureEvent, [event], {#stackTrace: stackTrace, #hint: hint, #withScope: withScope}, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureEvent, - [event], - {#stackTrace: stackTrace, #hint: hint, #withScope: withScope}, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override _i11.Future<_i2.SentryId> captureException( @@ -2838,23 +2627,22 @@ class MockHub extends _i1.Mock implements _i2.Hub { _i2.ScopeCallback? withScope, }) => (super.noSuchMethod( + Invocation.method( + #captureException, + [throwable], + {#stackTrace: stackTrace, #hint: hint, #withScope: withScope}, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureException, [throwable], {#stackTrace: stackTrace, #hint: hint, #withScope: withScope}, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureException, - [throwable], - {#stackTrace: stackTrace, #hint: hint, #withScope: withScope}, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override _i11.Future<_i2.SentryId> captureMessage( @@ -2866,6 +2654,20 @@ class MockHub extends _i1.Mock implements _i2.Hub { _i2.ScopeCallback? withScope, }) => (super.noSuchMethod( + Invocation.method( + #captureMessage, + [message], + { + #level: level, + #template: template, + #params: params, + #hint: hint, + #withScope: withScope, + }, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureMessage, [message], @@ -2877,24 +2679,9 @@ class MockHub extends _i1.Mock implements _i2.Hub { #withScope: withScope, }, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureMessage, - [message], - { - #level: level, - #template: template, - #params: params, - #hint: hint, - #withScope: withScope, - }, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override _i11.Future<_i2.SentryId> captureFeedback( @@ -2903,55 +2690,49 @@ class MockHub extends _i1.Mock implements _i2.Hub { _i2.ScopeCallback? withScope, }) => (super.noSuchMethod( + Invocation.method( + #captureFeedback, + [feedback], + {#hint: hint, #withScope: withScope}, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureFeedback, [feedback], {#hint: hint, #withScope: withScope}, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureFeedback, - [feedback], - {#hint: hint, #withScope: withScope}, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override _i11.Future addBreadcrumb(_i2.Breadcrumb? crumb, {_i2.Hint? hint}) => (super.noSuchMethod( - Invocation.method(#addBreadcrumb, [crumb], {#hint: hint}), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + Invocation.method(#addBreadcrumb, [crumb], {#hint: hint}), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override void bindClient(_i2.SentryClient? client) => super.noSuchMethod( - Invocation.method(#bindClient, [client]), - returnValueForMissingStub: null, - ); + Invocation.method(#bindClient, [client]), + returnValueForMissingStub: null, + ); @override - _i2.Hub clone() => - (super.noSuchMethod( - Invocation.method(#clone, []), - returnValue: _FakeHub_41(this, Invocation.method(#clone, [])), - ) - as _i2.Hub); + _i2.Hub clone() => (super.noSuchMethod( + Invocation.method(#clone, []), + returnValue: _FakeHub_41(this, Invocation.method(#clone, [])), + ) as _i2.Hub); @override - _i11.Future close() => - (super.noSuchMethod( - Invocation.method(#close, []), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) - as _i11.Future); + _i11.Future close() => (super.noSuchMethod( + Invocation.method(#close, []), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); @override _i11.FutureOr configureScope(_i2.ScopeCallback? callback) => @@ -2972,34 +2753,33 @@ class MockHub extends _i1.Mock implements _i2.Hub { Map? customSamplingContext, }) => (super.noSuchMethod( - Invocation.method( - #startTransaction, - [name, operation], - { - #description: description, - #startTimestamp: startTimestamp, - #bindToScope: bindToScope, - #waitForChildren: waitForChildren, - #autoFinishAfter: autoFinishAfter, - #trimEnd: trimEnd, - #onFinish: onFinish, - #customSamplingContext: customSamplingContext, - }, - ), - returnValue: _i13.startTransactionShim( - name, - operation, - description: description, - startTimestamp: startTimestamp, - bindToScope: bindToScope, - waitForChildren: waitForChildren, - autoFinishAfter: autoFinishAfter, - trimEnd: trimEnd, - onFinish: onFinish, - customSamplingContext: customSamplingContext, - ), - ) - as _i2.ISentrySpan); + Invocation.method( + #startTransaction, + [name, operation], + { + #description: description, + #startTimestamp: startTimestamp, + #bindToScope: bindToScope, + #waitForChildren: waitForChildren, + #autoFinishAfter: autoFinishAfter, + #trimEnd: trimEnd, + #onFinish: onFinish, + #customSamplingContext: customSamplingContext, + }, + ), + returnValue: _i13.startTransactionShim( + name, + operation, + description: description, + startTimestamp: startTimestamp, + bindToScope: bindToScope, + waitForChildren: waitForChildren, + autoFinishAfter: autoFinishAfter, + trimEnd: trimEnd, + onFinish: onFinish, + customSamplingContext: customSamplingContext, + ), + ) as _i2.ISentrySpan); @override _i2.ISentrySpan startTransactionWithContext( @@ -3013,37 +2793,36 @@ class MockHub extends _i1.Mock implements _i2.Hub { _i2.OnTransactionFinish? onFinish, }) => (super.noSuchMethod( - Invocation.method( - #startTransactionWithContext, - [transactionContext], - { - #customSamplingContext: customSamplingContext, - #startTimestamp: startTimestamp, - #bindToScope: bindToScope, - #waitForChildren: waitForChildren, - #autoFinishAfter: autoFinishAfter, - #trimEnd: trimEnd, - #onFinish: onFinish, - }, - ), - returnValue: _FakeISentrySpan_2( - this, - Invocation.method( - #startTransactionWithContext, - [transactionContext], - { - #customSamplingContext: customSamplingContext, - #startTimestamp: startTimestamp, - #bindToScope: bindToScope, - #waitForChildren: waitForChildren, - #autoFinishAfter: autoFinishAfter, - #trimEnd: trimEnd, - #onFinish: onFinish, - }, - ), - ), - ) - as _i2.ISentrySpan); + Invocation.method( + #startTransactionWithContext, + [transactionContext], + { + #customSamplingContext: customSamplingContext, + #startTimestamp: startTimestamp, + #bindToScope: bindToScope, + #waitForChildren: waitForChildren, + #autoFinishAfter: autoFinishAfter, + #trimEnd: trimEnd, + #onFinish: onFinish, + }, + ), + returnValue: _FakeISentrySpan_2( + this, + Invocation.method( + #startTransactionWithContext, + [transactionContext], + { + #customSamplingContext: customSamplingContext, + #startTimestamp: startTimestamp, + #bindToScope: bindToScope, + #waitForChildren: waitForChildren, + #autoFinishAfter: autoFinishAfter, + #trimEnd: trimEnd, + #onFinish: onFinish, + }, + ), + ), + ) as _i2.ISentrySpan); @override _i11.Future<_i2.SentryId> captureTransaction( @@ -3052,31 +2831,31 @@ class MockHub extends _i1.Mock implements _i2.Hub { _i2.Hint? hint, }) => (super.noSuchMethod( + Invocation.method( + #captureTransaction, + [transaction], + {#traceContext: traceContext, #hint: hint}, + ), + returnValue: _i11.Future<_i2.SentryId>.value( + _FakeSentryId_5( + this, Invocation.method( #captureTransaction, [transaction], {#traceContext: traceContext, #hint: hint}, ), - returnValue: _i11.Future<_i2.SentryId>.value( - _FakeSentryId_5( - this, - Invocation.method( - #captureTransaction, - [transaction], - {#traceContext: traceContext, #hint: hint}, - ), - ), - ), - ) - as _i11.Future<_i2.SentryId>); + ), + ), + ) as _i11.Future<_i2.SentryId>); @override void setSpanContext( dynamic throwable, _i2.ISentrySpan? span, String? transaction, - ) => super.noSuchMethod( - Invocation.method(#setSpanContext, [throwable, span, transaction]), - returnValueForMissingStub: null, - ); + ) => + super.noSuchMethod( + Invocation.method(#setSpanContext, [throwable, span, transaction]), + returnValueForMissingStub: null, + ); } diff --git a/flutter/test/profiling_test.dart b/flutter/test/profiling_test.dart index 8d4135e4f0..1091f893f1 100644 --- a/flutter/test/profiling_test.dart +++ b/flutter/test/profiling_test.dart @@ -8,7 +8,6 @@ import 'package:sentry_flutter/src/profiling.dart'; import 'package:sentry/src/platform/mock_platform.dart'; import 'mocks.dart'; import 'mocks.mocks.dart'; -import 'sentry_flutter_test.dart'; void main() { late MockSentryNativeBinding mock; @@ -21,7 +20,7 @@ void main() { group('$SentryNativeProfilerFactory', () { Hub hubWithSampleRate(double profilesSampleRate) { final o = defaultTestOptions(); - o.platformChecker = getPlatformChecker(platform: MockPlatform.iOS()); + o.platform = MockPlatform.iOS(); o.profilesSampleRate = profilesSampleRate; final hub = MockHub(); diff --git a/flutter/test/replay/replay_native_test.dart b/flutter/test/replay/replay_native_test.dart index d763726f77..70e5abc88d 100644 --- a/flutter/test/replay/replay_native_test.dart +++ b/flutter/test/replay/replay_native_test.dart @@ -42,10 +42,10 @@ void main() { setUp(() { hub = MockHub(); native = NativeChannelFixture(); - options = - defaultTestOptions(MockPlatformChecker(mockPlatform: mockPlatform)) - ..methodChannel = native.channel - ..experimental.replay.quality = SentryReplayQuality.low; + options = defaultTestOptions() + ..platform = mockPlatform + ..methodChannel = native.channel + ..experimental.replay.quality = SentryReplayQuality.low; sut = createBinding(options); if (mockPlatform.isIOS) { diff --git a/flutter/test/screenshot/sentry_screenshot_widget_test.mocks.dart b/flutter/test/screenshot/sentry_screenshot_widget_test.mocks.dart index beb822fd59..260d732543 100644 --- a/flutter/test/screenshot/sentry_screenshot_widget_test.mocks.dart +++ b/flutter/test/screenshot/sentry_screenshot_widget_test.mocks.dart @@ -36,8 +36,7 @@ class MockCallbacks extends _i1.Mock implements _i2.Callbacks { _i3.SentryScreenshotWidgetStatus? b, ) => (super.noSuchMethod( - Invocation.method(#onBuild, [a, b]), - returnValue: false, - ) - as bool); + Invocation.method(#onBuild, [a, b]), + returnValue: false, + ) as bool); } diff --git a/flutter/test/sentry_flutter_options_test.dart b/flutter/test/sentry_flutter_options_test.dart index 7c4d2e79b1..81f723a061 100644 --- a/flutter/test/sentry_flutter_options_test.dart +++ b/flutter/test/sentry_flutter_options_test.dart @@ -1,13 +1,12 @@ import 'package:flutter_test/flutter_test.dart'; - +import 'package:sentry/src/platform/mock_platform.dart'; import 'mocks.dart'; void main() { group('SentryFlutterOptions', () { testWidgets('auto breadcrumb tracking: has native integration', (WidgetTester tester) async { - final options = - defaultTestOptions(MockPlatformChecker(hasNativeIntegration: true)); + final options = defaultTestOptions(); expect(options.enableAppLifecycleBreadcrumbs, isFalse); expect(options.enableWindowMetricBreadcrumbs, isFalse); @@ -19,8 +18,7 @@ void main() { testWidgets('auto breadcrumb tracking: without native integration', (WidgetTester tester) async { - final options = - defaultTestOptions(MockPlatformChecker(hasNativeIntegration: false)); + final options = defaultTestOptions(platform: MockPlatform.fuchsia()); expect(options.enableAppLifecycleBreadcrumbs, isTrue); expect(options.enableWindowMetricBreadcrumbs, isTrue); diff --git a/flutter/test/sentry_flutter_test.dart b/flutter/test/sentry_flutter_test.dart index 1fc683ffa4..bea0eb1fa7 100644 --- a/flutter/test/sentry_flutter_test.dart +++ b/flutter/test/sentry_flutter_test.dart @@ -3,7 +3,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:package_info_plus/package_info_plus.dart'; -import 'package:sentry/src/platform/platform.dart'; import 'package:sentry/src/platform/mock_platform.dart'; import 'package:sentry/src/dart_exception_type_identifier.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; @@ -73,8 +72,8 @@ void main() { late final SentryFlutterOptions options; late final Transport transport; - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.android())) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.android() ..methodChannel = native.channel; await SentryFlutter.init( @@ -130,9 +129,9 @@ void main() { late final SentryFlutterOptions options; late final Transport transport; - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) - ..methodChannel = native.channel; + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.iOS() + ..methodChannel = native.channel; await SentryFlutter.init( (o) async { @@ -184,9 +183,9 @@ void main() { test('macOS', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.macOS())) - ..methodChannel = native.channel; + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.macOS() + ..methodChannel = native.channel; await SentryFlutter.init( (options) async { @@ -228,8 +227,8 @@ void main() { test('Windows', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.windows())) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.windows() // We need to disable native init because sentry.dll is not available here. ..autoInitializeNativeSdk = false; @@ -274,11 +273,11 @@ void main() { test('Linux', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.linux())) - ..methodChannel = native.channel - // We need to disable native init because libsentry.so is not available here. - ..autoInitializeNativeSdk = false; + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.linux() + ..methodChannel = native.channel + // We need to disable native init because libsentry.so is not available here. + ..autoInitializeNativeSdk = false; await SentryFlutter.init( (options) async { @@ -323,8 +322,8 @@ void main() { test('Web', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.linux(isWeb: true))) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.linux(isWeb: true) ..methodChannel = native.channel; await SentryFlutter.init( @@ -369,8 +368,9 @@ void main() { }, testOn: 'browser'); test('Web (custom zone)', () async { - final sentryFlutterOptions = defaultTestOptions(getPlatformChecker( - platform: MockPlatform(isWeb: true), isRootZone: false)) + final checker = MockPlatformChecker(isRoot: false); + final sentryFlutterOptions = defaultTestOptions(checker: checker) + ..platform = MockPlatform.android(isWeb: true) ..methodChannel = native.channel; await SentryFlutter.init( @@ -395,8 +395,8 @@ void main() { test('Web && (iOS || macOS)', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.iOS(isWeb: true))) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.iOS(isWeb: true) ..methodChannel = native.channel; // Tests that iOS || macOS integrations aren't added on a browser which @@ -438,8 +438,8 @@ void main() { test('Web && (macOS)', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.macOS(isWeb: true))) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.macOS(isWeb: true) ..methodChannel = native.channel; // Tests that iOS || macOS integrations aren't added on a browser which @@ -482,8 +482,8 @@ void main() { test('Web && Android', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.android(isWeb: true))) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.android(isWeb: true) ..methodChannel = native.channel; // Tests that Android integrations aren't added on an Android browser @@ -530,12 +530,12 @@ void main() { test('installed on io platforms', () async { List integrations = []; - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) - ..methodChannel = native.channel - ..rendererWrapper = MockRendererWrapper(FlutterRenderer.skia) - ..release = '' - ..dist = ''; + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.iOS() + ..methodChannel = native.channel + ..rendererWrapper = MockRendererWrapper(FlutterRenderer.skia) + ..release = '' + ..dist = ''; await SentryFlutter.init( (options) async { @@ -557,11 +557,11 @@ void main() { test('installed with canvasKit renderer', () async { List integrations = []; - final sentryFlutterOptions = - defaultTestOptions(getPlatformChecker(platform: MockPlatform.iOS())) - ..rendererWrapper = MockRendererWrapper(FlutterRenderer.canvasKit) - ..release = '' - ..dist = ''; + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.iOS() + ..rendererWrapper = MockRendererWrapper(FlutterRenderer.canvasKit) + ..release = '' + ..dist = ''; await SentryFlutter.init( (options) async { @@ -583,8 +583,8 @@ void main() { test('not installed with html renderer', () async { List integrations = []; - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.iOS(isWeb: true))) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.iOS(isWeb: true) ..rendererWrapper = MockRendererWrapper(FlutterRenderer.html) ..release = '' ..dist = ''; @@ -617,8 +617,8 @@ void main() { }); test('test that initial values are set correctly', () async { - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.android())) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.android() ..methodChannel = native.channel; await SentryFlutter.init( @@ -638,8 +638,8 @@ void main() { test( 'enablePureDartSymbolication is set to false during SentryFlutter init', () async { - final sentryFlutterOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.android())) + final sentryFlutterOptions = defaultTestOptions() + ..platform = MockPlatform.android() ..methodChannel = native.channel; SentryFlutter.native = mockNativeBinding(); @@ -703,8 +703,8 @@ void main() { test( 'should add DartExceptionTypeIdentifier and FlutterExceptionTypeIdentifier by default', () async { - final actualOptions = defaultTestOptions( - getPlatformChecker(platform: MockPlatform.android())) + final actualOptions = defaultTestOptions() + ..platform = MockPlatform.android() ..methodChannel = native.channel; await SentryFlutter.init( @@ -758,14 +758,3 @@ void loadTestPackage() { installerStore: null, ); } - -PlatformChecker getPlatformChecker({ - required Platform platform, - bool isRootZone = true, -}) { - final platformChecker = PlatformChecker( - platform: platform, - isRootZone: isRootZone, - ); - return platformChecker; -} diff --git a/flutter/test/sentry_native/sentry_native_test_ffi.dart b/flutter/test/sentry_native/sentry_native_test_ffi.dart index d500ee1880..20f4df42ee 100644 --- a/flutter/test/sentry_native/sentry_native_test_ffi.dart +++ b/flutter/test/sentry_native/sentry_native_test_ffi.dart @@ -23,6 +23,8 @@ extension on NativeBackend { // NOTE: Don't run/debug this main(), it likely won't work. // You can use main() in `sentry_native_test.dart`. void main() { + final currentPlatform = platform.Platform(); + final repoRootDir = Directory.current.path.endsWith('/test') ? Directory.current.parent.path : Directory.current.path; @@ -34,13 +36,12 @@ void main() { setUpAll(() async { late final List expectedDistFiles; if (backend.actualValue == NativeBackend.crashpad) { - expectedDistFiles = platform.currentPlatform.isWindows + expectedDistFiles = currentPlatform.isWindows ? ['sentry.dll', 'crashpad_handler.exe', 'crashpad_wer.dll'] : ['libsentry.so', 'crashpad_handler']; } else { - expectedDistFiles = platform.currentPlatform.isWindows - ? ['sentry.dll'] - : ['libsentry.so']; + expectedDistFiles = + currentPlatform.isWindows ? ['sentry.dll'] : ['libsentry.so']; } helper = NativeTestHelper( @@ -247,11 +248,10 @@ void main() { test('loadDebugImages', () async { final list = await sut.loadDebugImages(SentryStackTrace(frames: [])); expect(list, isNotEmpty); - expect( - list![0].type, platform.currentPlatform.isWindows ? 'pe' : 'elf'); + expect(list![0].type, currentPlatform.isWindows ? 'pe' : 'elf'); expect(list[0].debugId!.length, greaterThan(30)); - expect(list[0].debugFile, - platform.currentPlatform.isWindows ? isNotEmpty : isNull); + expect( + list[0].debugFile, currentPlatform.isWindows ? isNotEmpty : isNull); expect(list[0].imageSize, greaterThan(0)); expect(list[0].imageAddr, startsWith('0x')); expect(list[0].imageAddr?.length, greaterThan(2)); @@ -307,6 +307,7 @@ class NativeTestHelper { /// Compile sentry-native using CMake, as if it was part of a Flutter app. /// Returns the directory containing built libraries Future _buildSentryNative() async { + final currentPlatform = platform.Platform(); if (!_builtVersionIsExpected()) { Directory(cmakeConfDir).createSync(recursive: true); Directory(buildOutputDir).createSync(recursive: true); @@ -316,7 +317,7 @@ int main(int argc, char *argv[]) { return 0; } File('$cmakeConfDir/CMakeLists.txt').writeAsStringSync(''' cmake_minimum_required(VERSION 3.14) project(sentry-native-flutter-test) -add_subdirectory(../../../${platform.currentPlatform.operatingSystem.name} plugin) +add_subdirectory(../../../${currentPlatform.operatingSystem.name} plugin) add_executable(\${CMAKE_PROJECT_NAME} main.c) target_link_libraries(\${CMAKE_PROJECT_NAME} PRIVATE sentry_flutter_plugin) @@ -335,7 +336,7 @@ set(CMAKE_INSTALL_PREFIX "${buildOutputDir.replaceAll('\\', '/')}") '--config', 'Release', ]); - if (platform.currentPlatform.isLinux && + if (currentPlatform.isLinux && nativeBackend.actualValue == NativeBackend.crashpad) { await _exec('chmod', ['+x', '$buildOutputDir/crashpad_handler']); } diff --git a/flutter/test/sentry_native_channel_test.dart b/flutter/test/sentry_native_channel_test.dart index ced93896f1..37ac30cd3e 100644 --- a/flutter/test/sentry_native_channel_test.dart +++ b/flutter/test/sentry_native_channel_test.dart @@ -16,7 +16,6 @@ import 'package:sentry_flutter/src/replay/replay_config.dart'; import 'package:sentry/src/platform/mock_platform.dart'; import 'mocks.dart'; import 'mocks.mocks.dart'; -import 'sentry_flutter_test.dart'; void main() { for (var mockPlatform in [ @@ -30,9 +29,9 @@ void main() { setUp(() { channel = MockMethodChannel(); - final options = - defaultTestOptions(getPlatformChecker(platform: mockPlatform)) - ..methodChannel = channel; + final options = defaultTestOptions() + ..platform = mockPlatform + ..methodChannel = channel; sut = createBinding(options); }); @@ -208,7 +207,7 @@ void main() { if (mockPlatform.isAndroid) { matcher = throwsUnsupportedError; } else if (mockPlatform.isIOS || mockPlatform.isMacOS) { - if (currentPlatform.isMacOS) { + if (Platform().isMacOS) { matcher = throwsA(predicate((e) => e is Exception && e.toString().contains('Failed to load Objective-C class'))); From 90f0e93e29ee3676b71e6dd8fc1c8a9285b58442 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 24 Feb 2025 19:59:58 +0100 Subject: [PATCH 11/16] rename platform check to runtime checker --- dart/lib/sentry.dart | 2 +- .../environment/environment_variables.dart | 4 ++-- .../enricher/io_enricher_event_processor.dart | 2 +- .../web_enricher_event_processor.dart | 2 +- ...form_checker.dart => runtime_checker.dart} | 4 ++-- dart/lib/src/sentry.dart | 4 ++-- dart/lib/src/sentry_options.dart | 11 +++++---- ...checker.dart => mock_runtime_checker.dart} | 6 ++--- dart/test/sentry_test.dart | 20 ++++++++-------- dart/test/test_utils.dart | 2 +- .../flutter_enricher_event_processor.dart | 2 +- .../integrations/debug_print_integration.dart | 2 +- .../src/integrations/web_sdk_integration.dart | 2 +- flutter/lib/src/screenshot/recorder.dart | 2 +- flutter/lib/src/sentry_flutter.dart | 2 +- flutter/lib/src/sentry_privacy_options.dart | 4 ++-- .../script_loader/sentry_script_loader.dart | 2 +- ...flutter_enricher_event_processor_test.dart | 24 +++++++++---------- .../debug_print_integration_test.dart | 6 ++--- flutter/test/mocks.dart | 18 +++++++------- .../test/screenshot/masking_config_test.dart | 2 +- .../test/screenshot/widget_filter_test.dart | 12 +++++----- flutter/test/sentry_flutter_test.dart | 2 +- 23 files changed, 69 insertions(+), 68 deletions(-) rename dart/lib/src/{platform_checker.dart => runtime_checker.dart} (96%) rename dart/test/mocks/{mock_platform_checker.dart => mock_runtime_checker.dart} (69%) diff --git a/dart/lib/sentry.dart b/dart/lib/sentry.dart index 9d5d420d63..81915914ef 100644 --- a/dart/lib/sentry.dart +++ b/dart/lib/sentry.dart @@ -19,7 +19,7 @@ export 'src/integration.dart'; export 'src/noop_isolate_error_integration.dart' if (dart.library.io) 'src/isolate_error_integration.dart'; export 'src/performance_collector.dart'; -export 'src/platform_checker.dart'; +export 'src/runtime_checker.dart'; export 'src/protocol.dart'; export 'src/protocol/sentry_feedback.dart'; export 'src/protocol/sentry_proxy.dart'; diff --git a/dart/lib/src/environment/environment_variables.dart b/dart/lib/src/environment/environment_variables.dart index 7efbd877a6..51c8b1ea0d 100644 --- a/dart/lib/src/environment/environment_variables.dart +++ b/dart/lib/src/environment/environment_variables.dart @@ -1,4 +1,4 @@ -import '../platform_checker.dart'; +import '../runtime_checker.dart'; import '_io_environment_variables.dart' if (dart.library.js_interop) '_web_environment_variables.dart' as env; @@ -28,7 +28,7 @@ abstract class EnvironmentVariables { /// Returns an environment based on the compilation mode of Dart or Flutter. /// This can be set as [SentryOptions.environment] - String environmentForMode(PlatformChecker checker) { + String environmentForMode(RuntimeChecker checker) { // We infer the environment based on the release/non-release and profile // constants. diff --git a/dart/lib/src/event_processor/enricher/io_enricher_event_processor.dart b/dart/lib/src/event_processor/enricher/io_enricher_event_processor.dart index d101c3431d..70c5da2a3c 100644 --- a/dart/lib/src/event_processor/enricher/io_enricher_event_processor.dart +++ b/dart/lib/src/event_processor/enricher/io_enricher_event_processor.dart @@ -96,7 +96,7 @@ class IoEnricherEventProcessor implements EnricherEventProcessor { } return { - 'compile_mode': _options.platformChecker.compileMode, + 'compile_mode': _options.runtimeChecker.compileMode, if (packageConfig != null) 'package_config': packageConfig, // The following information could potentially contain PII if (_options.sendDefaultPii) ...{ diff --git a/dart/lib/src/event_processor/enricher/web_enricher_event_processor.dart b/dart/lib/src/event_processor/enricher/web_enricher_event_processor.dart index c3dfd47c71..c16e90319e 100644 --- a/dart/lib/src/event_processor/enricher/web_enricher_event_processor.dart +++ b/dart/lib/src/event_processor/enricher/web_enricher_event_processor.dart @@ -89,7 +89,7 @@ class WebEnricherEventProcessor implements EnricherEventProcessor { Map _getDartContext() { return { - 'compile_mode': _options.platformChecker.compileMode, + 'compile_mode': _options.runtimeChecker.compileMode, }; } diff --git a/dart/lib/src/platform_checker.dart b/dart/lib/src/runtime_checker.dart similarity index 96% rename from dart/lib/src/platform_checker.dart rename to dart/lib/src/runtime_checker.dart index 2fa5487ad7..85cd9d0029 100644 --- a/dart/lib/src/platform_checker.dart +++ b/dart/lib/src/runtime_checker.dart @@ -4,8 +4,8 @@ import 'dart:async'; /// The environment checks (release/debug/profile) are mutually exclusive. // TODO rename this to `RuntimeChecker` or something similar to better represent what it does. // TODO move `platform` directly to options - that is what we actually access 99 % of the times in tests and lib. -class PlatformChecker { - PlatformChecker({ +class RuntimeChecker { + RuntimeChecker({ bool? isRootZone, }) : isRootZone = isRootZone ?? Zone.current == Zone.root; diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 0033fbb3a1..d89d26c46c 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -93,7 +93,7 @@ class Sentry { options.addIntegrationByIndex(0, IsolateErrorIntegration()); } - if (options.platformChecker.isDebugMode()) { + if (options.runtimeChecker.isDebugMode()) { options.debug = true; options.logger( SentryLevel.debug, @@ -123,7 +123,7 @@ class Sentry { options.dsn = options.dsn ?? vars.dsn; if (options.environment == null) { - var environment = vars.environmentForMode(options.platformChecker); + var environment = vars.environmentForMode(options.runtimeChecker); options.environment = vars.environment ?? environment; } diff --git a/dart/lib/src/sentry_options.dart b/dart/lib/src/sentry_options.dart index 02e223664d..4f560e3e23 100644 --- a/dart/lib/src/sentry_options.dart +++ b/dart/lib/src/sentry_options.dart @@ -272,10 +272,11 @@ class SentryOptions { /// `debugPrint` calls are only recorded in release builds, though. bool enablePrintBreadcrumbs = true; - /// If [platformChecker] is provided, it is used get the environment. - /// This is useful in tests. Should be an implementation of [PlatformChecker]. - PlatformChecker platformChecker = PlatformChecker(); + /// If [runtimeChecker] is provided, it is used get the environment. + /// This is useful in tests. Should be an implementation of [RuntimeChecker]. + RuntimeChecker runtimeChecker = RuntimeChecker(); + /// Info on which platform the SDK runs. Platform platform = Platform(); /// If [environmentVariables] is provided, it is used get the environment @@ -497,13 +498,13 @@ class SentryOptions { /// iOS only supports http proxies, while macOS also supports socks. SentryProxy? proxy; - SentryOptions({String? dsn, Platform? platform, PlatformChecker? checker}) { + SentryOptions({String? dsn, Platform? platform, RuntimeChecker? checker}) { this.dsn = dsn; if (platform != null) { this.platform = platform; } if (checker != null) { - platformChecker = checker; + runtimeChecker = checker; } sdk = SdkVersion(name: sdkName(this.platform.isWeb), version: sdkVersion); sdk.addPackage('pub:sentry', sdkVersion); diff --git a/dart/test/mocks/mock_platform_checker.dart b/dart/test/mocks/mock_runtime_checker.dart similarity index 69% rename from dart/test/mocks/mock_platform_checker.dart rename to dart/test/mocks/mock_runtime_checker.dart index ecef1ec8be..aa869086ff 100644 --- a/dart/test/mocks/mock_platform_checker.dart +++ b/dart/test/mocks/mock_runtime_checker.dart @@ -1,9 +1,9 @@ -import 'package:sentry/src/platform_checker.dart'; +import 'package:sentry/src/runtime_checker.dart'; import 'no_such_method_provider.dart'; -class MockPlatformChecker extends PlatformChecker with NoSuchMethodProvider { - MockPlatformChecker({ +class MockRuntimeChecker extends RuntimeChecker with NoSuchMethodProvider { + MockRuntimeChecker({ this.isDebug = false, this.isProfile = false, this.isRelease = false, diff --git a/dart/test/sentry_test.dart b/dart/test/sentry_test.dart index 7b6c7a9bf9..6d519b4948 100644 --- a/dart/test/sentry_test.dart +++ b/dart/test/sentry_test.dart @@ -7,7 +7,7 @@ import 'package:test/test.dart'; import 'mocks.dart'; import 'mocks/mock_integration.dart'; -import 'mocks/mock_platform_checker.dart'; +import 'mocks/mock_runtime_checker.dart'; import 'mocks/mock_sentry_client.dart'; import 'test_utils.dart'; @@ -371,7 +371,7 @@ void main() { test('should set options.debug to true when in debug mode', () async { final options = defaultTestOptions(); - options.platformChecker = MockPlatformChecker(isDebug: true); + options.runtimeChecker = MockRuntimeChecker(isDebug: true); expect(options.debug, isFalse); await Sentry.init( @@ -385,7 +385,7 @@ void main() { test('should respect user options.debug when in debug mode', () async { final options = defaultTestOptions(); - options.platformChecker = MockPlatformChecker(isDebug: true); + options.runtimeChecker = MockRuntimeChecker(isDebug: true); expect(options.debug, isFalse); await Sentry.init( @@ -401,7 +401,7 @@ void main() { test('should leave options.debug unchanged when not in debug mode', () async { final options = defaultTestOptions(); - options.platformChecker = MockPlatformChecker(isDebug: false); + options.runtimeChecker = MockRuntimeChecker(isDebug: false); expect(options.debug, isFalse); await Sentry.init( @@ -443,7 +443,7 @@ void main() { test('options.environment debug', () async { final sentryOptions = - defaultTestOptions(checker: MockPlatformChecker(isDebug: true)); + defaultTestOptions(checker: MockRuntimeChecker(isDebug: true)); await Sentry.init( (options) { options.dsn = fakeDsn; @@ -456,7 +456,7 @@ void main() { test('options.environment profile', () async { final sentryOptions = - defaultTestOptions(checker: MockPlatformChecker(isProfile: true)); + defaultTestOptions(checker: MockRuntimeChecker(isProfile: true)); await Sentry.init( (options) { @@ -470,7 +470,7 @@ void main() { test('options.environment production (defaultEnvironment)', () async { final sentryOptions = - defaultTestOptions(checker: MockPlatformChecker(isRelease: true)); + defaultTestOptions(checker: MockRuntimeChecker(isRelease: true)); await Sentry.init( (options) { options.dsn = fakeDsn; @@ -483,7 +483,7 @@ void main() { test('options.logger is set by setting the debug flag', () async { final sentryOptions = - defaultTestOptions(checker: MockPlatformChecker(isDebug: true)); + defaultTestOptions(checker: MockRuntimeChecker(isDebug: true)); await Sentry.init( (options) { @@ -508,9 +508,9 @@ void main() { }); test('throw is handled and logged', () async { - // Use release mode in platform checker to avoid additional log + // Use release mode in runtime checker to avoid additional log final sentryOptions = - defaultTestOptions(checker: MockPlatformChecker(isRelease: true)) + defaultTestOptions(checker: MockRuntimeChecker(isRelease: true)) ..automatedTestMode = false ..debug = true ..logger = fixture.mockLogger; diff --git a/dart/test/test_utils.dart b/dart/test/test_utils.dart index 2e1e1ccdaa..cb9fc9a479 100644 --- a/dart/test/test_utils.dart +++ b/dart/test/test_utils.dart @@ -20,7 +20,7 @@ const String _testDsnWithPort = 'https://public:secret@sentry.example.com:8888/1'; SentryOptions defaultTestOptions( - {Platform? platform, PlatformChecker? checker}) { + {Platform? platform, RuntimeChecker? checker}) { return SentryOptions(dsn: testDsn, platform: platform, checker: checker) ..automatedTestMode = true; } diff --git a/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart b/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart index a19199e6c8..945320d068 100644 --- a/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart +++ b/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart @@ -20,7 +20,7 @@ class FlutterEnricherEventProcessor implements EventProcessor { final SentryFlutterOptions _options; bool get _hasNativeIntegration => _options.platform.supportsNativeIntegration; - PlatformChecker get _checker => _options.platformChecker; + RuntimeChecker get _checker => _options.runtimeChecker; // We can't use `WidgetsBinding` as a direct parameter // because it must be called inside the `runZoneGuarded`-Integration. diff --git a/flutter/lib/src/integrations/debug_print_integration.dart b/flutter/lib/src/integrations/debug_print_integration.dart index fbeb1cb6c1..faeb97eaad 100644 --- a/flutter/lib/src/integrations/debug_print_integration.dart +++ b/flutter/lib/src/integrations/debug_print_integration.dart @@ -18,7 +18,7 @@ class DebugPrintIntegration implements Integration { _hub = hub; _options = options; - final isDebug = options.platformChecker.isDebugMode(); + final isDebug = options.runtimeChecker.isDebugMode(); final enablePrintBreadcrumbs = options.enablePrintBreadcrumbs; if (isDebug || !enablePrintBreadcrumbs) { return; diff --git a/flutter/lib/src/integrations/web_sdk_integration.dart b/flutter/lib/src/integrations/web_sdk_integration.dart index 05d0d2e658..98ca504a49 100644 --- a/flutter/lib/src/integrations/web_sdk_integration.dart +++ b/flutter/lib/src/integrations/web_sdk_integration.dart @@ -33,7 +33,7 @@ class WebSdkIntegration implements Integration { _options = options; try { - final scripts = options.platformChecker.isDebugMode() + final scripts = options.runtimeChecker.isDebugMode() ? debugScripts : productionScripts; await _scriptLoader.loadWebSdk(scripts); diff --git a/flutter/lib/src/screenshot/recorder.dart b/flutter/lib/src/screenshot/recorder.dart index 6f22781a6a..a5fa9f0581 100644 --- a/flutter/lib/src/screenshot/recorder.dart +++ b/flutter/lib/src/screenshot/recorder.dart @@ -35,7 +35,7 @@ class ScreenshotRecorder { privacyOptions ??= options.experimental.privacy; final maskingConfig = - privacyOptions.buildMaskingConfig(_log, options.platformChecker); + privacyOptions.buildMaskingConfig(_log, options.runtimeChecker); _maskingConfig = maskingConfig.length > 0 ? maskingConfig : null; } diff --git a/flutter/lib/src/sentry_flutter.dart b/flutter/lib/src/sentry_flutter.dart index d3bb4c028c..1af1e29f1d 100644 --- a/flutter/lib/src/sentry_flutter.dart +++ b/flutter/lib/src/sentry_flutter.dart @@ -76,7 +76,7 @@ mixin SentryFlutter { // likely due to https://github.com/flutter/flutter/issues/100277 final isOnErrorSupported = !options.platform.isWeb; - final bool isRootZone = options.platformChecker.isRootZone; + final bool isRootZone = options.runtimeChecker.isRootZone; // If onError is not supported and no custom zone exists, use runZonedGuarded to capture errors. final bool useRunZonedGuarded = !isOnErrorSupported && isRootZone; diff --git a/flutter/lib/src/sentry_privacy_options.dart b/flutter/lib/src/sentry_privacy_options.dart index f620a72428..dfa0c7b5ea 100644 --- a/flutter/lib/src/sentry_privacy_options.dart +++ b/flutter/lib/src/sentry_privacy_options.dart @@ -31,7 +31,7 @@ class SentryPrivacyOptions { @internal SentryMaskingConfig buildMaskingConfig( - SentryLogger logger, PlatformChecker platform) { + SentryLogger logger, RuntimeChecker runtimeChecker) { // First, we collect rules defined by the user (so they're applied first). final rules = _userMaskingRules.toList(); @@ -76,7 +76,7 @@ class SentryPrivacyOptions { // In Debug mode, check if users explicitly mask (or unmask) widgets that // look like they should be masked, e.g. Videos, WebViews, etc. - if (platform.isDebugMode()) { + if (runtimeChecker.isDebugMode()) { final regexp = RegExp('video|webview|password|pinput|camera|chart', caseSensitive: false); diff --git a/flutter/lib/src/web/script_loader/sentry_script_loader.dart b/flutter/lib/src/web/script_loader/sentry_script_loader.dart index 0c21d7a144..621f84e51b 100644 --- a/flutter/lib/src/web/script_loader/sentry_script_loader.dart +++ b/flutter/lib/src/web/script_loader/sentry_script_loader.dart @@ -57,7 +57,7 @@ class SentryScriptLoader { } Future close() async { - final scriptsToRemove = _options.platformChecker.isReleaseMode() + final scriptsToRemove = _options.runtimeChecker.isReleaseMode() ? productionScripts : debugScripts; diff --git a/flutter/test/event_processor/flutter_enricher_event_processor_test.dart b/flutter/test/event_processor/flutter_enricher_event_processor_test.dart index efe75c5440..db23761aaf 100644 --- a/flutter/test/event_processor/flutter_enricher_event_processor_test.dart +++ b/flutter/test/event_processor/flutter_enricher_event_processor_test.dart @@ -225,32 +225,32 @@ void main() { final testData = [ PlatformTestData( MockPlatform(isWeb: false), - MockPlatformCheckerBuildMode.debug, + MockRuntimeCheckerBuildMode.debug, 'Dart VM', ), PlatformTestData( MockPlatform(isWeb: false), - MockPlatformCheckerBuildMode.profile, + MockRuntimeCheckerBuildMode.profile, 'Dart AOT', ), PlatformTestData( MockPlatform(isWeb: false), - MockPlatformCheckerBuildMode.release, + MockRuntimeCheckerBuildMode.release, 'Dart AOT', ), PlatformTestData( MockPlatform(isWeb: true), - MockPlatformCheckerBuildMode.debug, + MockRuntimeCheckerBuildMode.debug, 'dartdevc', ), PlatformTestData( MockPlatform(isWeb: true), - MockPlatformCheckerBuildMode.profile, + MockRuntimeCheckerBuildMode.profile, 'dart2js', ), PlatformTestData( MockPlatform(isWeb: true), - MockPlatformCheckerBuildMode.release, + MockRuntimeCheckerBuildMode.release, 'dart2js', ), ]; @@ -393,7 +393,7 @@ void main() { testWidgets('$FlutterEnricherEventProcessor gets added on init', (tester) async { - // use a mock platform checker so that we don't need to mock platform channels + // use a mock platform so that we don't need to mock platform channels final sentryOptions = defaultTestOptions(); sentryOptions.platform = MockPlatform.fuchsia(); // Without native @@ -432,7 +432,7 @@ void main() { class PlatformTestData { PlatformTestData(this.platform, this.buildMode, this.compiler); MockPlatform platform; - MockPlatformCheckerBuildMode buildMode; + MockRuntimeCheckerBuildMode buildMode; String compiler; } @@ -444,19 +444,19 @@ class Fixture { bool reportPackages = true, SentryFlutterOptions Function(SentryFlutterOptions)? optionsBuilder, }) { - PlatformChecker platformChecker; + RuntimeChecker runtimeChecker; if (platformTestData != null) { - platformChecker = MockPlatformChecker( + runtimeChecker = MockRuntimeChecker( buildMode: platformTestData.buildMode, ); } else { - platformChecker = MockPlatformChecker(); + runtimeChecker = MockRuntimeChecker(); } final options = defaultTestOptions( platform: hasNativeIntegration ? MockPlatform.iOS() : MockPlatform.fuchsia(), - checker: platformChecker) + checker: runtimeChecker) ..reportPackages = reportPackages; if (platformTestData != null) { diff --git a/flutter/test/integrations/debug_print_integration_test.dart b/flutter/test/integrations/debug_print_integration_test.dart index 2697cc9db1..9f17f9ac23 100644 --- a/flutter/test/integrations/debug_print_integration_test.dart +++ b/flutter/test/integrations/debug_print_integration_test.dart @@ -95,10 +95,10 @@ class Fixture { bool enablePrintBreadcrumbs = true, }) { return defaultTestOptions( - checker: MockPlatformChecker( + checker: MockRuntimeChecker( buildMode: debug - ? MockPlatformCheckerBuildMode.debug - : MockPlatformCheckerBuildMode.release)) + ? MockRuntimeCheckerBuildMode.debug + : MockRuntimeCheckerBuildMode.release)) ..enablePrintBreadcrumbs = enablePrintBreadcrumbs; } diff --git a/flutter/test/mocks.dart b/flutter/test/mocks.dart index 7b2d3b1888..592b70d886 100644 --- a/flutter/test/mocks.dart +++ b/flutter/test/mocks.dart @@ -21,7 +21,7 @@ const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; const fakeProguardUuid = '3457d982-65ef-576d-a6ad-65b5f30f49a5'; SentryFlutterOptions defaultTestOptions( - {Platform? platform, PlatformChecker? checker}) { + {Platform? platform, RuntimeChecker? checker}) { return SentryFlutterOptions( dsn: fakeDsn, platform: platform, checker: checker) ..automatedTestMode = true; @@ -61,29 +61,29 @@ ISentrySpan startTransactionShim( ]) void main() {} -class MockPlatformChecker with NoSuchMethodProvider implements PlatformChecker { - MockPlatformChecker({ - this.buildMode = MockPlatformCheckerBuildMode.debug, +class MockRuntimeChecker with NoSuchMethodProvider implements RuntimeChecker { + MockRuntimeChecker({ + this.buildMode = MockRuntimeCheckerBuildMode.debug, this.isRoot = true, }); - final MockPlatformCheckerBuildMode buildMode; + final MockRuntimeCheckerBuildMode buildMode; final bool isRoot; @override - bool isDebugMode() => buildMode == MockPlatformCheckerBuildMode.debug; + bool isDebugMode() => buildMode == MockRuntimeCheckerBuildMode.debug; @override - bool isProfileMode() => buildMode == MockPlatformCheckerBuildMode.profile; + bool isProfileMode() => buildMode == MockRuntimeCheckerBuildMode.profile; @override - bool isReleaseMode() => buildMode == MockPlatformCheckerBuildMode.release; + bool isReleaseMode() => buildMode == MockRuntimeCheckerBuildMode.release; @override bool get isRootZone => isRoot; } -enum MockPlatformCheckerBuildMode { debug, profile, release } +enum MockRuntimeCheckerBuildMode { debug, profile, release } // Does nothing or returns default values. // Useful for when a Hub needs to be passed but is not used. diff --git a/flutter/test/screenshot/masking_config_test.dart b/flutter/test/screenshot/masking_config_test.dart index a8bdf9d9a4..639688ce2b 100644 --- a/flutter/test/screenshot/masking_config_test.dart +++ b/flutter/test/screenshot/masking_config_test.dart @@ -148,7 +148,7 @@ void main() async { group('$SentryReplayOptions.buildMaskingConfig()', () { List rulesAsStrings(SentryPrivacyOptions options) { final config = - options.buildMaskingConfig(MockLogger().call, PlatformChecker()); + options.buildMaskingConfig(MockLogger().call, RuntimeChecker()); return config.rules .map((rule) => rule.toString()) // These normalize the string on VM & js & wasm: diff --git a/flutter/test/screenshot/widget_filter_test.dart b/flutter/test/screenshot/widget_filter_test.dart index 01b22f9a13..c626252f22 100644 --- a/flutter/test/screenshot/widget_filter_test.dart +++ b/flutter/test/screenshot/widget_filter_test.dart @@ -24,13 +24,13 @@ void main() async { final createSut = ( {bool redactImages = false, bool redactText = false, - PlatformChecker? platformChecker}) { + RuntimeChecker? runtimeChecker}) { final privacyOptions = SentryPrivacyOptions() ..maskAllImages = redactImages ..maskAllText = redactText; logger.clear(); final maskingConfig = privacyOptions.buildMaskingConfig( - logger.call, platformChecker ?? PlatformChecker()); + logger.call, runtimeChecker ?? RuntimeChecker()); return WidgetFilter(maskingConfig, logger.call); }; @@ -219,12 +219,12 @@ void main() async { }); group('warning on sensitive widgets', () { - assert(MockPlatformCheckerBuildMode.values.length == 3); - for (final buildMode in MockPlatformCheckerBuildMode.values) { + assert(MockRuntimeCheckerBuildMode.values.length == 3); + for (final buildMode in MockRuntimeCheckerBuildMode.values) { testWidgets(buildMode.name, (tester) async { final sut = createSut( redactText: true, - platformChecker: MockPlatformChecker(buildMode: buildMode)); + runtimeChecker: MockRuntimeChecker(buildMode: buildMode)); final element = await pumpTestElement(tester, children: [CustomPasswordWidget()]); sut.obscure( @@ -236,7 +236,7 @@ void main() async { .map((item) => item.message) .toList(); - if (buildMode == MockPlatformCheckerBuildMode.debug) { + if (buildMode == MockRuntimeCheckerBuildMode.debug) { expect( logMessages, anyElement(contains( diff --git a/flutter/test/sentry_flutter_test.dart b/flutter/test/sentry_flutter_test.dart index bea0eb1fa7..2c0da8ac95 100644 --- a/flutter/test/sentry_flutter_test.dart +++ b/flutter/test/sentry_flutter_test.dart @@ -368,7 +368,7 @@ void main() { }, testOn: 'browser'); test('Web (custom zone)', () async { - final checker = MockPlatformChecker(isRoot: false); + final checker = MockRuntimeChecker(isRoot: false); final sentryFlutterOptions = defaultTestOptions(checker: checker) ..platform = MockPlatform.android(isWeb: true) ..methodChannel = native.channel; From 91851e67e6a6e6445d09602007cf5b5e2c401495 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 24 Feb 2025 20:01:35 +0100 Subject: [PATCH 12/16] remove todos --- dart/lib/src/runtime_checker.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/dart/lib/src/runtime_checker.dart b/dart/lib/src/runtime_checker.dart index 85cd9d0029..4aee63c8fd 100644 --- a/dart/lib/src/runtime_checker.dart +++ b/dart/lib/src/runtime_checker.dart @@ -2,8 +2,6 @@ import 'dart:async'; /// Helper to check in which environment the library is running. /// The environment checks (release/debug/profile) are mutually exclusive. -// TODO rename this to `RuntimeChecker` or something similar to better represent what it does. -// TODO move `platform` directly to options - that is what we actually access 99 % of the times in tests and lib. class RuntimeChecker { RuntimeChecker({ bool? isRootZone, From e9351bdb45581f54628d0176b800262b89fed531 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 25 Feb 2025 10:17:25 +0100 Subject: [PATCH 13/16] add cl entry --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63263fec85..e553b78b3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,10 @@ - Responses are attached to the `Hint` object, which can be read in `beforeSend`/`beforeSendTransaction` callbacks via `hint.response`. - For now, only the `dio` integration is supported. - Enable privacy masking for screenshots by default ([#2728](https://github.com/getsentry/sentry-dart/pull/2728)) - +- Cleanup platform mocking ([#2730](https://github.com/getsentry/sentry-dart/pull/2730)) + - The `PlatformChecker` was renamed to `RuntimeChecker` + - Moved `PlatfomrChecker.platform` to `options.platform` + ### Enhancements - Replay: improve Android native interop performance by using JNI ([#2670](https://github.com/getsentry/sentry-dart/pull/2670)) From d70dc313a76ec3983eb2a31f462d9f75f0dfdf6a Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 25 Feb 2025 10:55:43 +0100 Subject: [PATCH 14/16] fix test expectations --- dart/test/mocks/mock_runtime_checker.dart | 3 +- .../debug_print_integration_test.dart | 1 + flutter/test/sentry_flutter_test.dart | 120 ++++++++++-------- 3 files changed, 70 insertions(+), 54 deletions(-) diff --git a/dart/test/mocks/mock_runtime_checker.dart b/dart/test/mocks/mock_runtime_checker.dart index aa869086ff..c7ea74b730 100644 --- a/dart/test/mocks/mock_runtime_checker.dart +++ b/dart/test/mocks/mock_runtime_checker.dart @@ -7,7 +7,8 @@ class MockRuntimeChecker extends RuntimeChecker with NoSuchMethodProvider { this.isDebug = false, this.isProfile = false, this.isRelease = false, - }); + bool isRootZone = true, + }) : super(isRootZone: isRootZone); final bool isDebug; final bool isProfile; diff --git a/flutter/test/integrations/debug_print_integration_test.dart b/flutter/test/integrations/debug_print_integration_test.dart index 9f17f9ac23..41827420d7 100644 --- a/flutter/test/integrations/debug_print_integration_test.dart +++ b/flutter/test/integrations/debug_print_integration_test.dart @@ -57,6 +57,7 @@ void main() { test('$DebugPrintIntegration: disabled in debug builds', () { final integration = fixture.getSut(); + integration.call(fixture.hub, fixture.getOptions(debug: true)); debugPrint('Foo Bar'); diff --git a/flutter/test/sentry_flutter_test.dart b/flutter/test/sentry_flutter_test.dart index 2c0da8ac95..52aa973654 100644 --- a/flutter/test/sentry_flutter_test.dart +++ b/flutter/test/sentry_flutter_test.dart @@ -72,9 +72,10 @@ void main() { late final SentryFlutterOptions options; late final Transport transport; - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.android() - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.android() + ..methodChannel = native.channel; await SentryFlutter.init( (o) async { @@ -129,9 +130,10 @@ void main() { late final SentryFlutterOptions options; late final Transport transport; - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.iOS() - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.iOS() + ..methodChannel = native.channel; await SentryFlutter.init( (o) async { @@ -183,9 +185,10 @@ void main() { test('macOS', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.macOS() - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.macOS() + ..methodChannel = native.channel; await SentryFlutter.init( (options) async { @@ -227,10 +230,11 @@ void main() { test('Windows', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.windows() - // We need to disable native init because sentry.dll is not available here. - ..autoInitializeNativeSdk = false; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.windows() + // We need to disable native init because sentry.dll is not available here. + ..autoInitializeNativeSdk = false; await SentryFlutter.init( (options) async { @@ -273,11 +277,12 @@ void main() { test('Linux', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.linux() - ..methodChannel = native.channel - // We need to disable native init because libsentry.so is not available here. - ..autoInitializeNativeSdk = false; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.linux() + ..methodChannel = native.channel + // We need to disable native init because libsentry.so is not available here. + ..autoInitializeNativeSdk = false; await SentryFlutter.init( (options) async { @@ -322,9 +327,10 @@ void main() { test('Web', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.linux(isWeb: true) - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.linux(isWeb: true) + ..methodChannel = native.channel; await SentryFlutter.init( (options) async { @@ -395,9 +401,10 @@ void main() { test('Web && (iOS || macOS)', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.iOS(isWeb: true) - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.iOS(isWeb: true) + ..methodChannel = native.channel; // Tests that iOS || macOS integrations aren't added on a browser which // runs on iOS or macOS @@ -438,9 +445,10 @@ void main() { test('Web && (macOS)', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.macOS(isWeb: true) - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.macOS(isWeb: true) + ..methodChannel = native.channel; // Tests that iOS || macOS integrations aren't added on a browser which // runs on iOS or macOS @@ -482,9 +490,10 @@ void main() { test('Web && Android', () async { List integrations = []; Transport transport = MockTransport(); - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.android(isWeb: true) - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.android(isWeb: true) + ..methodChannel = native.channel; // Tests that Android integrations aren't added on an Android browser await SentryFlutter.init( @@ -530,12 +539,13 @@ void main() { test('installed on io platforms', () async { List integrations = []; - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.iOS() - ..methodChannel = native.channel - ..rendererWrapper = MockRendererWrapper(FlutterRenderer.skia) - ..release = '' - ..dist = ''; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.iOS() + ..methodChannel = native.channel + ..rendererWrapper = MockRendererWrapper(FlutterRenderer.skia) + ..release = '' + ..dist = ''; await SentryFlutter.init( (options) async { @@ -557,11 +567,12 @@ void main() { test('installed with canvasKit renderer', () async { List integrations = []; - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.iOS() - ..rendererWrapper = MockRendererWrapper(FlutterRenderer.canvasKit) - ..release = '' - ..dist = ''; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.iOS() + ..rendererWrapper = MockRendererWrapper(FlutterRenderer.canvasKit) + ..release = '' + ..dist = ''; await SentryFlutter.init( (options) async { @@ -583,11 +594,12 @@ void main() { test('not installed with html renderer', () async { List integrations = []; - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.iOS(isWeb: true) - ..rendererWrapper = MockRendererWrapper(FlutterRenderer.html) - ..release = '' - ..dist = ''; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.iOS(isWeb: true) + ..rendererWrapper = MockRendererWrapper(FlutterRenderer.html) + ..release = '' + ..dist = ''; await SentryFlutter.init( (options) async { @@ -617,9 +629,10 @@ void main() { }); test('test that initial values are set correctly', () async { - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.android() - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.android() + ..methodChannel = native.channel; await SentryFlutter.init( (options) { @@ -638,9 +651,10 @@ void main() { test( 'enablePureDartSymbolication is set to false during SentryFlutter init', () async { - final sentryFlutterOptions = defaultTestOptions() - ..platform = MockPlatform.android() - ..methodChannel = native.channel; + final sentryFlutterOptions = + defaultTestOptions(checker: MockRuntimeChecker()) + ..platform = MockPlatform.android() + ..methodChannel = native.channel; SentryFlutter.native = mockNativeBinding(); await SentryFlutter.init( @@ -703,7 +717,7 @@ void main() { test( 'should add DartExceptionTypeIdentifier and FlutterExceptionTypeIdentifier by default', () async { - final actualOptions = defaultTestOptions() + final actualOptions = defaultTestOptions(checker: MockRuntimeChecker()) ..platform = MockPlatform.android() ..methodChannel = native.channel; From cd186ada9ff0ca1028943c3b8f266eea8939e110 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 3 Mar 2025 15:21:32 +0100 Subject: [PATCH 15/16] fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 204d03f64f..cc29b61374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ - Enable privacy masking for screenshots by default ([#2728](https://github.com/getsentry/sentry-dart/pull/2728)) - Cleanup platform mocking ([#2730](https://github.com/getsentry/sentry-dart/pull/2730)) - The `PlatformChecker` was renamed to `RuntimeChecker` - - Moved `PlatfomrChecker.platform` to `options.platform` + - Moved `PlatformChecker.platform` to `options.platform` From 067b84cf8d3a0036a862d180dbd0c45eb0c3b939 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 3 Mar 2025 15:44:21 +0100 Subject: [PATCH 16/16] fix warnings --- CHANGELOG.md | 8 +++----- dart/example_web/web/main.dart | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc29b61374..e8467cd3cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Move replay and privacy from experimental to options ([#2755](https://github.com/getsentry/sentry-dart/pull/2755)) - Remove renderer from `flutter_context` ([#2751](https://github.com/getsentry/sentry-dart/pull/2751)) +- Cleanup platform mocking ([#2730](https://github.com/getsentry/sentry-dart/pull/2730)) + - The `PlatformChecker` was renamed to `RuntimeChecker` + - Moved `PlatformChecker.platform` to `options.platform` ## 9.0.0-alpha.1 @@ -28,12 +31,7 @@ - Responses are attached to the `Hint` object, which can be read in `beforeSend`/`beforeSendTransaction` callbacks via `hint.response`. - For now, only the `dio` integration is supported. - Enable privacy masking for screenshots by default ([#2728](https://github.com/getsentry/sentry-dart/pull/2728)) -- Cleanup platform mocking ([#2730](https://github.com/getsentry/sentry-dart/pull/2730)) - - The `PlatformChecker` was renamed to `RuntimeChecker` - - Moved `PlatformChecker.platform` to `options.platform` - - ### Enhancements - Replay: improve Android native interop performance by using JNI ([#2670](https://github.com/getsentry/sentry-dart/pull/2670)) diff --git a/dart/example_web/web/main.dart b/dart/example_web/web/main.dart index 3c0305b49e..7e349b7276 100644 --- a/dart/example_web/web/main.dart +++ b/dart/example_web/web/main.dart @@ -24,6 +24,7 @@ Future main() async { Future runApp() async { print('runApp'); + // ignore: deprecated_member_use document.querySelector('#output')?.text = 'Your Dart app is running.'; await Sentry.addBreadcrumb(