Skip to content

Commit 0a53933

Browse files
[path_provider] Remove use of Pigeon's Dart test generator
- Updates `path_provider_android` to use DI to inject the fake Pigeon API implementation, instead of the Dart test generator, following the pattern of newer plugins in the repo. - Does the same for `path_provider_foundation`, and also replaces the use of mockito with a trivial fake, to simplify test maintenance. Part of flutter/flutter#159886
1 parent c8ba0cc commit 0a53933

File tree

10 files changed

+121
-572
lines changed

10 files changed

+121
-572
lines changed

packages/path_provider/path_provider_android/lib/path_provider_android.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:flutter/foundation.dart' show visibleForTesting;
56
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
67
import 'messages.g.dart' as messages;
78

@@ -36,7 +37,11 @@ messages.StorageDirectory _convertStorageDirectory(
3637

3738
/// The Android implementation of [PathProviderPlatform].
3839
class PathProviderAndroid extends PathProviderPlatform {
39-
final messages.PathProviderApi _api = messages.PathProviderApi();
40+
/// Creates an instance of [PathProviderAndroid].
41+
PathProviderAndroid({@visibleForTesting messages.PathProviderApi? api})
42+
: _api = api ?? messages.PathProviderApi();
43+
44+
final messages.PathProviderApi _api;
4045

4146
/// Registers this class as the default instance of [PathProviderPlatform].
4247
static void registerWith() {

packages/path_provider/path_provider_android/pigeons/messages.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'package:pigeon/pigeon.dart';
1313
package: 'io.flutter.plugins.pathprovider',
1414
),
1515
dartOut: 'lib/messages.g.dart',
16-
dartTestOut: 'test/messages_test.g.dart',
1716
copyrightHeader: 'pigeons/copyright.txt',
1817
),
1918
)
@@ -31,7 +30,7 @@ enum StorageDirectory {
3130
documents,
3231
}
3332

34-
@HostApi(dartHostTestHandler: 'TestPathProviderApi')
33+
@HostApi()
3534
abstract class PathProviderApi {
3635
@TaskQueue(type: TaskQueueType.serialBackgroundThread)
3736
String? getTemporaryPath();

packages/path_provider/path_provider_android/test/messages_test.g.dart

Lines changed: 0 additions & 301 deletions
This file was deleted.

0 commit comments

Comments
 (0)