blob: 1f567c00513d594110220521a4185cc3fb3172af [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
import 'package:path_provider_linux/path_provider_linux.dart';
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
import 'package:xdg_directories/xdg_directories.dart' as xdg;
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
PathProviderLinux.registerWith();
test('registered instance', () {
expect(PathProviderPlatform.instance, isA<PathProviderLinux>());
});
test('getTemporaryPath defaults to TMPDIR', () async {
final PathProviderPlatform plugin = PathProviderLinux.private(
environment: <String, String>{'TMPDIR': '/run/user/0/tmp'},
);
expect(await plugin.getTemporaryPath(), '/run/user/0/tmp');
});
test('getTemporaryPath uses fallback if TMPDIR is empty', () async {
final PathProviderPlatform plugin = PathProviderLinux.private(
environment: <String, String>{'TMPDIR': ''},
);
expect(await plugin.getTemporaryPath(), '/tmp');
});
test('getTemporaryPath uses fallback if TMPDIR is unset', () async {
final PathProviderPlatform plugin = PathProviderLinux.private(
environment: <String, String>{},
);
expect(await plugin.getTemporaryPath(), '/tmp');
});
test('getApplicationSupportPath', () async {
final PathProviderPlatform plugin = PathProviderLinux.private(
executableName: 'path_provider_linux_test_binary',
applicationId: 'com.example.Test');
// Note this will fail if ${xdg.dataHome.path}/path_provider_linux_test_binary exists on the local filesystem.
expect(await plugin.getApplicationSupportPath(),
'${xdg.dataHome.path}/com.example.Test');
});
test('getApplicationSupportPath uses executable name if no application Id',
() async {
final PathProviderPlatform plugin = PathProviderLinux.private(
executableName: 'path_provider_linux_test_binary');
expect(await plugin.getApplicationSupportPath(),
'${xdg.dataHome.path}/path_provider_linux_test_binary');
});
test('getApplicationDocumentsPath', () async {
final PathProviderPlatform plugin = PathProviderPlatform.instance;
expect(await plugin.getApplicationDocumentsPath(), startsWith('/'));
});
test('getDownloadsPath', () async {
final PathProviderPlatform plugin = PathProviderPlatform.instance;
expect(await plugin.getDownloadsPath(), startsWith('/'));
});
}