Skip to content

Commit

Permalink
Fix order-dependant platform interface tests (flutter#4406)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan authored and amantoux committed Dec 11, 2021
1 parent 003d568 commit 0da1851
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import 'package:file_selector_platform_interface/src/method_channel/method_chann
import 'package:flutter_test/flutter_test.dart';

void main() {
// Store the initial instance before any tests change it.
final FileSelectorPlatform initialInstance = FileSelectorPlatform.instance;

group('$FileSelectorPlatform', () {
test('$MethodChannelFileSelector() is the default instance', () {
expect(FileSelectorPlatform.instance,
isInstanceOf<MethodChannelFileSelector>());
expect(initialInstance, isInstanceOf<MethodChannelFileSelector>());
});

test('Can be extended', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
void main() {
TestWidgetsFlutterBinding.ensureInitialized();

// Store the initial instance before any tests change it.
final GoogleMapsFlutterPlatform initialInstance =
GoogleMapsFlutterPlatform.instance;

group('$GoogleMapsFlutterPlatform', () {
test('$MethodChannelGoogleMapsFlutter() is the default instance', () {
expect(GoogleMapsFlutterPlatform.instance,
isInstanceOf<MethodChannelGoogleMapsFlutter>());
expect(initialInstance, isInstanceOf<MethodChannelGoogleMapsFlutter>());
});

test('Cannot be implemented with `implements`', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';

void main() {
// Store the initial instance before any tests change it.
final GoogleSignInPlatform initialInstance = GoogleSignInPlatform.instance;

group('$GoogleSignInPlatform', () {
test('$MethodChannelGoogleSignIn is the default instance', () {
expect(GoogleSignInPlatform.instance, isA<MethodChannelGoogleSignIn>());
expect(initialInstance, isA<MethodChannelGoogleSignIn>());
});

test('Cannot be implemented with `implements`', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import 'package:quick_actions_platform_interface/platform_interface/quick_action
void main() {
TestWidgetsFlutterBinding.ensureInitialized();

// Store the initial instance before any tests change it.
final QuickActionsPlatform initialInstance = QuickActionsPlatform.instance;

group('$QuickActionsPlatform', () {
test('$MethodChannelQuickActions is the default instance', () {
expect(QuickActionsPlatform.instance, isA<MethodChannelQuickActions>());
expect(initialInstance, isA<MethodChannelQuickActions>());
});

test('Cannot be implemented with `implements`', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface.
void main() {
TestWidgetsFlutterBinding.ensureInitialized();

// Store the initial instance before any tests change it.
final UrlLauncherPlatform initialInstance = UrlLauncherPlatform.instance;

group('$UrlLauncherPlatform', () {
test('$MethodChannelUrlLauncher() is the default instance', () {
expect(UrlLauncherPlatform.instance,
isInstanceOf<MethodChannelUrlLauncher>());
expect(initialInstance, isInstanceOf<MethodChannelUrlLauncher>());
});

test('Cannot be implemented with `implements`', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ class _ApiLogger implements TestHostVideoPlayerApi {
void main() {
TestWidgetsFlutterBinding.ensureInitialized();

// Store the initial instance before any tests change it.
final VideoPlayerPlatform initialInstance = VideoPlayerPlatform.instance;

group('$VideoPlayerPlatform', () {
test('$MethodChannelVideoPlayer() is the default instance', () {
expect(VideoPlayerPlatform.instance,
isInstanceOf<MethodChannelVideoPlayer>());
expect(initialInstance, isInstanceOf<MethodChannelVideoPlayer>());
});
});

Expand Down

0 comments on commit 0da1851

Please sign in to comment.