Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Apply PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Dec 6, 2021
1 parent 43eb78e commit 08023b2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.webkit.WebView;
import io.flutter.plugins.webviewflutter.GeneratedAndroidWebView.FlutterAssetManagerHostApi;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand All @@ -27,6 +28,11 @@ public FlutterAssetManagerHostApiImpl(FlutterAssetManager flutterAssetManager) {
public List<String> list(String path) {
try {
String[] paths = flutterAssetManager.list(path);

if (paths == null) {
return new ArrayList<>();
}

return Arrays.asList(paths);
} catch (IOException ex) {
throw new RuntimeException(ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -43,6 +45,19 @@ public void list() {
}
}

@Test
public void list_returns_empty_list_when_no_results() {
try {
when(mockFlutterAssetManager.list("test/path"))
.thenReturn(null);
List<String> actualFilePaths = testFlutterAssetManagerHostApiImpl.list("test/path");
verify(mockFlutterAssetManager).list("test/path");
assertArrayEquals(new String[] {}, actualFilePaths.toArray());
} catch (IOException ex) {
fail();
}
}

@Test(expected = RuntimeException.class)
public void list_should_convert_io_exception_to_runtime_exception() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ repository: https://github.com/flutter/plugins/tree/master/packages/webview_flut
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 2.5.0

# TODO(mvanbeusekom): Remove when webview_flutter_platform_interface no longer referenced through path reference.
publish_to: none

environment:
sdk: ">=2.14.0 <3.0.0"
flutter: ">=2.5.0"
Expand All @@ -22,9 +19,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
# TODO(mvanbeusekom): Update to pub.dev dependency once version 1.8.0 is released.
webview_flutter_platform_interface:
path: ../webview_flutter_platform_interface
webview_flutter_platform_interface: ^1.8.0

dev_dependencies:
build_runner: ^2.1.4
Expand Down

0 comments on commit 08023b2

Please sign in to comment.