mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-22 09:31:02 +02:00
fix(conversion): preserve Unicode SAF document names
This commit is contained in:
@@ -2,6 +2,68 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:spotiflac_android/utils/saf_display_path.dart';
|
||||
|
||||
void main() {
|
||||
group('SAF document locations', () {
|
||||
test('keeps Unicode and reserved filename characters decoded once', () {
|
||||
final uri = Uri(
|
||||
scheme: 'content',
|
||||
host: 'com.android.externalstorage.documents',
|
||||
pathSegments: const [
|
||||
'tree',
|
||||
'primary:Music',
|
||||
'document',
|
||||
'primary:Music/Like a Prayer (From “Deadpool & Wolverine”).alac',
|
||||
],
|
||||
).toString();
|
||||
|
||||
final location = resolveSafDocumentLocation(uri);
|
||||
|
||||
expect(location, isNotNull);
|
||||
expect(
|
||||
location!.treeUri,
|
||||
'content://com.android.externalstorage.documents/tree/primary%3AMusic',
|
||||
);
|
||||
expect(location.relativeDir, isEmpty);
|
||||
expect(
|
||||
location.fileName,
|
||||
'Like a Prayer (From “Deadpool & Wolverine”).alac',
|
||||
);
|
||||
});
|
||||
|
||||
test('preserves Unicode folders, emoji, and a literal percent sign', () {
|
||||
final uri = Uri(
|
||||
scheme: 'content',
|
||||
host: 'com.android.externalstorage.documents',
|
||||
pathSegments: const [
|
||||
'tree',
|
||||
'primary:Music/Beyoncé',
|
||||
'document',
|
||||
'primary:Music/Beyoncé/日本語/100% & 🎵.flac',
|
||||
],
|
||||
).toString();
|
||||
|
||||
final location = resolveSafDocumentLocation(uri);
|
||||
|
||||
expect(location, isNotNull);
|
||||
expect(
|
||||
location!.treeUri,
|
||||
'content://com.android.externalstorage.documents/tree/'
|
||||
'primary%3AMusic%2FBeyonc%C3%A9',
|
||||
);
|
||||
expect(location.relativeDir, '日本語');
|
||||
expect(location.fileName, '100% & 🎵.flac');
|
||||
});
|
||||
|
||||
test('rejects a document URI without writable tree context', () {
|
||||
expect(
|
||||
resolveSafDocumentLocation(
|
||||
'content://com.android.providers.media.documents/'
|
||||
'document/audio%3A12345',
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('SAF display paths', () {
|
||||
test('normalizes an external-storage document URI', () {
|
||||
const uri =
|
||||
|
||||
Reference in New Issue
Block a user