Skip to content

Commit 3333aa7

Browse files
committed
add web test
1 parent af93414 commit 3333aa7

File tree

3 files changed

+113
-2
lines changed

3 files changed

+113
-2
lines changed

.github/workflows/web.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797

9898
# Run all unit-tests with code coverage
9999
- name: Run unit tests
100-
run: flutter test --coverage
100+
run: flutter test --coverage --platform chrome
101101
working-directory: ${{env.source-directory}}
102102

103103
# Upload code coverage information

cached_network_image_web/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dev_dependencies:
1717
flutter_test:
1818
sdk: flutter
1919
flutter_lints: ^1.0.4
20+
file: ^6.1.2
2021

2122
# For information on the generic Dart part of this file, see the
2223
# following page: https://dart.dev/tools/pub/pubspec
Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,113 @@
1+
import 'dart:async';
2+
import 'dart:typed_data';
3+
4+
import 'package:cached_network_image_platform_interface'
5+
'/cached_network_image_platform_interface.dart' hide ImageLoader;
6+
import 'package:cached_network_image_web/cached_network_image_web.dart';
7+
import 'package:flutter/widgets.dart';
8+
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
9+
import 'package:flutter_test/flutter_test.dart';
10+
import 'dart:ui' as ui;
11+
import 'package:file/file.dart';
12+
113
void main() {
2-
// missing tests :(
14+
test('loadAsync returns a stream', () {
15+
var imageLoader = ImageLoader();
16+
var stream = imageLoader.loadAsync(
17+
'test.com/image',
18+
null,
19+
StreamController<ImageChunkEvent>(),
20+
decoder,
21+
MockCacheManager(),
22+
null,
23+
null,
24+
null,
25+
null,
26+
ImageRenderMethodForWeb.HttpGet,
27+
() => {});
28+
expect(stream, isNotNull);
29+
});
30+
}
31+
32+
Future<ui.Codec> decoder(
33+
Uint8List bytes, {
34+
int? cacheWidth,
35+
int? cacheHeight,
36+
bool allowUpscaling = false,
37+
}) {
38+
throw UnimplementedError();
39+
}
40+
41+
class MockCacheManager implements BaseCacheManager {
42+
@override
43+
Future<void> dispose() {
44+
throw UnimplementedError();
45+
}
46+
47+
@override
48+
Future<FileInfo> downloadFile(
49+
String url, {
50+
String? key,
51+
Map<String, String>? authHeaders,
52+
bool force = false,
53+
}) {
54+
throw UnimplementedError();
55+
}
56+
57+
@override
58+
Future<void> emptyCache() {
59+
throw UnimplementedError();
60+
}
61+
62+
@override
63+
Stream<FileInfo> getFile(String url,
64+
{String? key, Map<String, String>? headers}) {
65+
throw UnimplementedError();
66+
}
67+
68+
@override
69+
Future<FileInfo?> getFileFromCache(String key,
70+
{bool ignoreMemCache = false}) {
71+
throw UnimplementedError();
72+
}
73+
74+
@override
75+
Future<FileInfo?> getFileFromMemory(String key) {
76+
throw UnimplementedError();
77+
}
78+
79+
@override
80+
Stream<FileResponse> getFileStream(String url,
81+
{String? key, Map<String, String>? headers, bool withProgress = false}) {
82+
throw UnimplementedError();
83+
}
84+
85+
@override
86+
Future<File> getSingleFile(String url,
87+
{String? key, Map<String, String>? headers}) {
88+
throw UnimplementedError();
89+
}
90+
91+
@override
92+
Future<File> putFile(String url, Uint8List fileBytes,
93+
{String? key,
94+
String? eTag,
95+
Duration maxAge = const Duration(days: 30),
96+
String fileExtension = 'file'}) {
97+
throw UnimplementedError();
98+
}
99+
100+
@override
101+
Future<File> putFileStream(String url, Stream<List<int>> source,
102+
{String? key,
103+
String? eTag,
104+
Duration maxAge = const Duration(days: 30),
105+
String fileExtension = 'file'}) {
106+
throw UnimplementedError();
107+
}
108+
109+
@override
110+
Future<void> removeFile(String key) {
111+
throw UnimplementedError();
112+
}
3113
}

0 commit comments

Comments
 (0)