File tree Expand file tree Collapse file tree 3 files changed +49
-9
lines changed Expand file tree Collapse file tree 3 files changed +49
-9
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ class ClientIO extends ClientBase with ClientMixin {
80
80
@override
81
81
String get endPoint => _endPoint;
82
82
83
- Future<Directory > getCookiePath () async {
83
+ Future<Directory > _getCookiePath () async {
84
84
final directory = await getApplicationDocumentsDirectory();
85
85
final path = directory.path;
86
86
final Directory dir = Directory('$path/cookies');
@@ -133,7 +133,7 @@ class ClientIO extends ClientBase with ClientMixin {
133
133
Future init() async {
134
134
if(_initProgress) return;
135
135
_initProgress = true;
136
- final Directory cookieDir = await getCookiePath ();
136
+ final Directory cookieDir = await _getCookiePath ();
137
137
_cookieJar = PersistCookieJar(storage: FileStorage(cookieDir.path));
138
138
_interceptors.add(CookieManager(_cookieJar));
139
139
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ dependencies:
21
21
universal_html: ^2.0.8
22
22
23
23
dev_dependencies:
24
+ path_provider_platform_interface: ^2.0.5
24
25
flutter_lints: ^2.0.1
25
26
flutter_test:
26
27
sdk: flutter
Original file line number Diff line number Diff line change 1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:path_provider_platform_interface/path_provider_platform_interface.dart' ;
3
+
2
4
import '../lib/packageName.dart' ;
3
5
import '../lib/client_io.dart' ;
4
6
import '../lib/models.dart' ;
5
7
import 'dart:io' ;
6
8
7
- class MockClient extends ClientIO {
8
- Future <Directory > getCookiePath () async {
9
- final dir = Directory ('cookies' );
10
- await dir.create ();
11
- return dir;
9
+ class FakePathProvider extends PathProviderPlatform {
10
+ @override
11
+ Future <String ?> getTemporaryPath () async {
12
+ return '.' ;
13
+ }
14
+
15
+ @override
16
+ Future <String ?> getApplicationSupportPath () async {
17
+ return '.' ;
18
+ }
19
+
20
+ @override
21
+ Future <String ?> getLibraryPath () async {
22
+ return '.' ;
23
+ }
24
+
25
+ @override
26
+ Future <String ?> getApplicationDocumentsPath () async {
27
+ return '.' ;
28
+ }
29
+
30
+ @override
31
+ Future <String ?> getExternalStoragePath () async {
32
+ return '.' ;
33
+ }
34
+
35
+ @override
36
+ Future <List <String >?> getExternalCachePaths () async {
37
+ return < String > ['.' ];
38
+ }
39
+
40
+ @override
41
+ Future <List <String >?> getExternalStoragePaths ({
42
+ StorageDirectory ? type,
43
+ }) async {
44
+ return < String > ['.' ];
45
+ }
46
+
47
+ @override
48
+ Future <String ?> getDownloadsPath () async {
49
+ return '.' ;
12
50
}
13
51
}
14
52
53
+
15
54
void main () async {
16
55
WidgetsFlutterBinding .ensureInitialized ();
17
-
18
- Client client = MockClient ();
56
+ PathProviderPlatform .instance = FakePathProvider ();
57
+ Client client = Client ();
19
58
Foo foo = Foo (client);
20
59
Bar bar = Bar (client);
21
60
General general = General (client);
You can’t perform that action at this time.
0 commit comments