/* * SPDX-FileCopyrightText: 2019-2021 Vishesh Handa * * SPDX-License-Identifier: AGPL-3.0-or-later */ // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: depend_on_referenced_packages import 'package:path/path.dart'; import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'package:test/fake.dart'; import 'package:universal_io/io.dart'; // from path_provider_test const String kTemporaryPath = 'temporaryPath'; const String kApplicationSupportPath = 'applicationSupportPath'; const String kDownloadsPath = 'downloadsPath'; const String kLibraryPath = 'libraryPath'; const String kApplicationDocumentsPath = 'applicationDocumentsPath'; const String kExternalCachePath = 'externalCachePath'; const String kExternalStoragePath = 'externalStoragePath'; class FakePathProviderPlatform extends Fake with MockPlatformInterfaceMixin implements PathProviderPlatform { final Directory dir; FakePathProviderPlatform(this.dir); static Future init() async { var dir = await Directory.systemTemp.createTemp(); await Directory(join(dir.path, kTemporaryPath)).create(); return FakePathProviderPlatform(dir); } @override Future getTemporaryPath() async { return join(dir.path, kTemporaryPath); } @override Future getApplicationSupportPath() async { return kApplicationSupportPath; } @override Future getLibraryPath() async { return kLibraryPath; } @override Future getApplicationDocumentsPath() async { return kApplicationDocumentsPath; } @override Future getExternalStoragePath() async { return kExternalStoragePath; } @override Future?> getExternalCachePaths() async { return [kExternalCachePath]; } @override Future?> getExternalStoragePaths({ StorageDirectory? type, }) async { return [kExternalStoragePath]; } @override Future getDownloadsPath() async { return kDownloadsPath; } }