Skip to content

Commit 0da1851

Browse files
stuartmorgan-gamantoux
authored andcommitted
Fix order-dependant platform interface tests (flutter#4406)
1 parent 003d568 commit 0da1851

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

packages/file_selector/file_selector_platform_interface/test/file_selector_platform_interface_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import 'package:file_selector_platform_interface/src/method_channel/method_chann
77
import 'package:flutter_test/flutter_test.dart';
88

99
void main() {
10+
// Store the initial instance before any tests change it.
11+
final FileSelectorPlatform initialInstance = FileSelectorPlatform.instance;
12+
1013
group('$FileSelectorPlatform', () {
1114
test('$MethodChannelFileSelector() is the default instance', () {
12-
expect(FileSelectorPlatform.instance,
13-
isInstanceOf<MethodChannelFileSelector>());
15+
expect(initialInstance, isInstanceOf<MethodChannelFileSelector>());
1416
});
1517

1618
test('Can be extended', () {

packages/google_maps_flutter/google_maps_flutter_platform_interface/test/platform_interface/google_maps_flutter_platform_test.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
1616
void main() {
1717
TestWidgetsFlutterBinding.ensureInitialized();
1818

19+
// Store the initial instance before any tests change it.
20+
final GoogleMapsFlutterPlatform initialInstance =
21+
GoogleMapsFlutterPlatform.instance;
22+
1923
group('$GoogleMapsFlutterPlatform', () {
2024
test('$MethodChannelGoogleMapsFlutter() is the default instance', () {
21-
expect(GoogleMapsFlutterPlatform.instance,
22-
isInstanceOf<MethodChannelGoogleMapsFlutter>());
25+
expect(initialInstance, isInstanceOf<MethodChannelGoogleMapsFlutter>());
2326
});
2427

2528
test('Cannot be implemented with `implements`', () {

packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import 'package:flutter_test/flutter_test.dart';
77
import 'package:mockito/mockito.dart';
88

99
void main() {
10+
// Store the initial instance before any tests change it.
11+
final GoogleSignInPlatform initialInstance = GoogleSignInPlatform.instance;
12+
1013
group('$GoogleSignInPlatform', () {
1114
test('$MethodChannelGoogleSignIn is the default instance', () {
12-
expect(GoogleSignInPlatform.instance, isA<MethodChannelGoogleSignIn>());
15+
expect(initialInstance, isA<MethodChannelGoogleSignIn>());
1316
});
1417

1518
test('Cannot be implemented with `implements`', () {

packages/quick_actions/quick_actions_platform_interface/test/quick_actions_platform_interface_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import 'package:quick_actions_platform_interface/platform_interface/quick_action
99
void main() {
1010
TestWidgetsFlutterBinding.ensureInitialized();
1111

12+
// Store the initial instance before any tests change it.
13+
final QuickActionsPlatform initialInstance = QuickActionsPlatform.instance;
14+
1215
group('$QuickActionsPlatform', () {
1316
test('$MethodChannelQuickActions is the default instance', () {
14-
expect(QuickActionsPlatform.instance, isA<MethodChannelQuickActions>());
17+
expect(initialInstance, isA<MethodChannelQuickActions>());
1518
});
1619

1720
test('Cannot be implemented with `implements`', () {

packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface.
1414
void main() {
1515
TestWidgetsFlutterBinding.ensureInitialized();
1616

17+
// Store the initial instance before any tests change it.
18+
final UrlLauncherPlatform initialInstance = UrlLauncherPlatform.instance;
19+
1720
group('$UrlLauncherPlatform', () {
1821
test('$MethodChannelUrlLauncher() is the default instance', () {
19-
expect(UrlLauncherPlatform.instance,
20-
isInstanceOf<MethodChannelUrlLauncher>());
22+
expect(initialInstance, isInstanceOf<MethodChannelUrlLauncher>());
2123
});
2224

2325
test('Cannot be implemented with `implements`', () {

packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ class _ApiLogger implements TestHostVideoPlayerApi {
9292
void main() {
9393
TestWidgetsFlutterBinding.ensureInitialized();
9494

95+
// Store the initial instance before any tests change it.
96+
final VideoPlayerPlatform initialInstance = VideoPlayerPlatform.instance;
97+
9598
group('$VideoPlayerPlatform', () {
9699
test('$MethodChannelVideoPlayer() is the default instance', () {
97-
expect(VideoPlayerPlatform.instance,
98-
isInstanceOf<MethodChannelVideoPlayer>());
100+
expect(initialInstance, isInstanceOf<MethodChannelVideoPlayer>());
99101
});
100102
});
101103

0 commit comments

Comments
 (0)