This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree 3 files changed +22
-6
lines changed
packages/webview_flutter/webview_flutter_android
main/java/io/flutter/plugins/webviewflutter
test/java/io/flutter/plugins/webviewflutter
3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 7
7
import android .webkit .WebView ;
8
8
import io .flutter .plugins .webviewflutter .GeneratedAndroidWebView .FlutterAssetManagerHostApi ;
9
9
import java .io .IOException ;
10
+ import java .util .ArrayList ;
10
11
import java .util .Arrays ;
11
12
import java .util .List ;
12
13
@@ -27,6 +28,11 @@ public FlutterAssetManagerHostApiImpl(FlutterAssetManager flutterAssetManager) {
27
28
public List <String > list (String path ) {
28
29
try {
29
30
String [] paths = flutterAssetManager .list (path );
31
+
32
+ if (paths == null ) {
33
+ return new ArrayList <>();
34
+ }
35
+
30
36
return Arrays .asList (paths );
31
37
} catch (IOException ex ) {
32
38
throw new RuntimeException (ex .getMessage ());
Original file line number Diff line number Diff line change 6
6
7
7
import static org .junit .Assert .assertArrayEquals ;
8
8
import static org .junit .Assert .assertEquals ;
9
+ import static org .junit .Assert .assertNull ;
9
10
import static org .junit .Assert .fail ;
10
11
import static org .mockito .Mockito .mock ;
11
12
import static org .mockito .Mockito .verify ;
12
13
import static org .mockito .Mockito .when ;
13
14
14
15
import java .io .IOException ;
16
+ import java .util .ArrayList ;
15
17
import java .util .List ;
16
18
import org .junit .Before ;
17
19
import org .junit .Test ;
@@ -43,6 +45,19 @@ public void list() {
43
45
}
44
46
}
45
47
48
+ @ Test
49
+ public void list_returns_empty_list_when_no_results () {
50
+ try {
51
+ when (mockFlutterAssetManager .list ("test/path" ))
52
+ .thenReturn (null );
53
+ List <String > actualFilePaths = testFlutterAssetManagerHostApiImpl .list ("test/path" );
54
+ verify (mockFlutterAssetManager ).list ("test/path" );
55
+ assertArrayEquals (new String [] {}, actualFilePaths .toArray ());
56
+ } catch (IOException ex ) {
57
+ fail ();
58
+ }
59
+ }
60
+
46
61
@ Test (expected = RuntimeException .class )
47
62
public void list_should_convert_io_exception_to_runtime_exception () {
48
63
try {
Original file line number Diff line number Diff line change @@ -4,9 +4,6 @@ repository: https://github.com/flutter/plugins/tree/master/packages/webview_flut
4
4
issue_tracker : https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
5
5
version : 2.5.0
6
6
7
- # TODO(mvanbeusekom): Remove when webview_flutter_platform_interface no longer referenced through path reference.
8
- publish_to : none
9
-
10
7
environment :
11
8
sdk : " >=2.14.0 <3.0.0"
12
9
flutter : " >=2.5.0"
@@ -22,9 +19,7 @@ flutter:
22
19
dependencies :
23
20
flutter :
24
21
sdk : flutter
25
- # TODO(mvanbeusekom): Update to pub.dev dependency once version 1.8.0 is released.
26
- webview_flutter_platform_interface :
27
- path : ../webview_flutter_platform_interface
22
+ webview_flutter_platform_interface : ^1.8.0
28
23
29
24
dev_dependencies :
30
25
build_runner : ^2.1.4
You can’t perform that action at this time.
0 commit comments