Skip to content

[v9]: Replace custom Platform & PlatformChecker with package platform #2729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dart/lib/src/platform/_web_platform.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:platform/platform.dart';
import 'package:web/web.dart' as web;

import 'platform.dart';

/// [Platform] implementation that delegates to `dart:web`.

Check failure on line 6 in dart/lib/src/platform/_web_platform.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The name 'Platform' is defined in the libraries 'package:platform/src/interface/platform.dart (via package:platform/platform.dart)' and 'package:sentry/src/platform/platform.dart'.

Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports. See https://dart.dev/diagnostics/ambiguous_import to learn more about this problem.
class PlatformBase {
const PlatformBase();

Expand Down
1 change: 1 addition & 0 deletions dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions dart/test/mocks/mock_platform.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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');
}
}
40 changes: 40 additions & 0 deletions dart/test/mocks/mock_platform_checker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:platform/platform.dart';
import 'package:sentry/src/platform_checker.dart';

Check failure on line 2 in dart/test/mocks/mock_platform_checker.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

Target of URI doesn't exist: 'package:sentry/src/platform_checker.dart'.

Try creating the file referenced by the URI, or try using a URI for a file that does exist. See https://dart.dev/diagnostics/uri_does_not_exist to learn more about this problem.

import 'no_such_method_provider.dart';

class MockPlatformChecker extends PlatformChecker with NoSuchMethodProvider {
MockPlatformChecker({
this.isDebug = false,
this.isProfile = false,
this.isRelease = false,
this.isWebValue = false,
this.hasNativeIntegration = false,
Platform? platform,
}) : _platform = platform;

final Platform? _platform;

final bool isDebug;
final bool isProfile;
final bool isRelease;
final bool isWebValue;

@override
bool hasNativeIntegration = false;

Check warning on line 24 in dart/test/mocks/mock_platform_checker.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The field doesn't override an inherited getter or setter.

Try updating this class to match the superclass, or removing the override annotation. See https://dart.dev/diagnostics/override_on_non_overriding_member to learn more about this problem.

@override
bool isDebugMode() => isDebug;

Check warning on line 27 in dart/test/mocks/mock_platform_checker.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The method doesn't override an inherited method.

Try updating this class to match the superclass, or removing the override annotation. See https://dart.dev/diagnostics/override_on_non_overriding_member to learn more about this problem.

@override
bool isProfileMode() => isProfile;

Check warning on line 30 in dart/test/mocks/mock_platform_checker.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The method doesn't override an inherited method.

Try updating this class to match the superclass, or removing the override annotation. See https://dart.dev/diagnostics/override_on_non_overriding_member to learn more about this problem.

@override
bool isReleaseMode() => isRelease;

Check warning on line 33 in dart/test/mocks/mock_platform_checker.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The method doesn't override an inherited method.

Try updating this class to match the superclass, or removing the override annotation. See https://dart.dev/diagnostics/override_on_non_overriding_member to learn more about this problem.

@override
bool get isWeb => isWebValue;

Check warning on line 36 in dart/test/mocks/mock_platform_checker.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The getter doesn't override an inherited getter.

Try updating this class to match the superclass, or removing the override annotation. See https://dart.dev/diagnostics/override_on_non_overriding_member to learn more about this problem.

@override
Platform get platform => _platform ?? super.platform;

Check warning on line 39 in dart/test/mocks/mock_platform_checker.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The getter doesn't override an inherited getter.

Try updating this class to match the superclass, or removing the override annotation. See https://dart.dev/diagnostics/override_on_non_overriding_member to learn more about this problem.

Check failure on line 39 in dart/test/mocks/mock_platform_checker.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The getter 'platform' isn't defined in a superclass of 'MockPlatformChecker'.

Try correcting the name to the name of an existing getter, or defining a getter or field named 'platform' in a superclass. See https://dart.dev/diagnostics/undefined_super_member to learn more about this problem.
}
1 change: 1 addition & 0 deletions flutter/test/profiling_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void main() {
Hub hubWithSampleRate(double profilesSampleRate) {
final o = defaultTestOptions();
o.platform = MockPlatform.iOS();

o.profilesSampleRate = profilesSampleRate;

final hub = MockHub();
Expand Down
Loading