@@ -7,15 +7,30 @@ import 'dart:io';
77import 'package:flutter_test/flutter_test.dart' ;
88import 'package:path_provider_platform_interface/path_provider_platform_interface.dart' ;
99import 'package:path_provider_windows/path_provider_windows.dart' ;
10+ import 'package:path_provider_windows/src/path_provider_windows_real.dart'
11+ show languageEn, encodingCP1252, encodingUnicode;
1012
1113// A fake VersionInfoQuerier that just returns preset responses.
1214class FakeVersionInfoQuerier implements VersionInfoQuerier {
13- FakeVersionInfoQuerier (this .responses);
15+ FakeVersionInfoQuerier (this .responses,
16+ [this .language = languageEn, this .encoding = encodingUnicode]);
1417
18+ final String language;
19+ final String encoding;
1520 final Map <String , String > responses;
1621
17- String ? getStringValue (Pointer <Uint8 >? versionInfo, String key) =>
18- responses[key];
22+ String ? getStringValue (
23+ Pointer <Uint8 >? versionInfo,
24+ String key, {
25+ required String language,
26+ required String encoding,
27+ }) {
28+ if (language == this .language && encoding == this .encoding) {
29+ return responses[key];
30+ } else {
31+ return null ;
32+ }
33+ }
1934}
2035
2136void main () {
@@ -40,12 +55,12 @@ void main() {
4055 expect (path, endsWith (r'flutter_tester' ));
4156 }, skip: ! Platform .isWindows);
4257
43- test ('getApplicationSupportPath with full version info' , () async {
58+ test ('getApplicationSupportPath with full version info in CP1252 ' , () async {
4459 final PathProviderWindows pathProvider = PathProviderWindows ();
4560 pathProvider.versionInfoQuerier = FakeVersionInfoQuerier (< String , String > {
4661 'CompanyName' : 'A Company' ,
4762 'ProductName' : 'Amazing App' ,
48- });
63+ }, languageEn, encodingCP1252 );
4964 final String ? path = await pathProvider.getApplicationSupportPath ();
5065 expect (path, isNotNull);
5166 if (path != null ) {
@@ -54,6 +69,35 @@ void main() {
5469 }
5570 }, skip: ! Platform .isWindows);
5671
72+ test ('getApplicationSupportPath with full version info in Unicode' , () async {
73+ final PathProviderWindows pathProvider = PathProviderWindows ();
74+ pathProvider.versionInfoQuerier = FakeVersionInfoQuerier (< String , String > {
75+ 'CompanyName' : 'A Company' ,
76+ 'ProductName' : 'Amazing App' ,
77+ }, languageEn, encodingUnicode);
78+ final String ? path = await pathProvider.getApplicationSupportPath ();
79+ expect (path, isNotNull);
80+ if (path != null ) {
81+ expect (path, endsWith (r'AppData\Roaming\A Company\Amazing App' ));
82+ expect (Directory (path).existsSync (), isTrue);
83+ }
84+ }, skip: ! Platform .isWindows);
85+
86+ test (
87+ 'getApplicationSupportPath with full version info in Unsupported Encoding' ,
88+ () async {
89+ final PathProviderWindows pathProvider = PathProviderWindows ();
90+ pathProvider.versionInfoQuerier = FakeVersionInfoQuerier (< String , String > {
91+ 'CompanyName' : 'A Company' ,
92+ 'ProductName' : 'Amazing App' ,
93+ }, '0000' , '0000' );
94+ final String ? path = await pathProvider.getApplicationSupportPath ();
95+ expect (path, contains (r'C:\' ));
96+ expect (path, contains (r'AppData' ));
97+ // The last path component should be the executable name.
98+ expect (path, endsWith (r'flutter_tester' ));
99+ }, skip: ! Platform .isWindows);
100+
57101 test ('getApplicationSupportPath with missing company' , () async {
58102 final PathProviderWindows pathProvider = PathProviderWindows ();
59103 pathProvider.versionInfoQuerier = FakeVersionInfoQuerier (< String , String > {
0 commit comments