Skip to content

Commit b04d2cc

Browse files
[ios_platform_images] Add integration tests (flutter#4899)
Currently there are no end-to-end tests for this package that would fail if the communication with the native implementation didn't work, or if the native implementation were broken. This is especially problematic since we want to convert this plugin to both Swift and Pigeon, each of which has the potential to break things that would currently not be caught. This adds basic integration tests of both methods to ensure that the simple case of a successful call works as expected.
1 parent 4512e4d commit b04d2cc

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import 'package:flutter/widgets.dart';
8+
import 'package:flutter_test/flutter_test.dart';
9+
import 'package:integration_test/integration_test.dart';
10+
import 'package:ios_platform_images/ios_platform_images.dart';
11+
12+
void main() {
13+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
14+
15+
testWidgets('resolves URL', (WidgetTester _) async {
16+
final String? path = await IosPlatformImages.resolveURL('textfile');
17+
expect(Uri.parse(path!).scheme, 'file');
18+
expect(path.contains('Runner.app'), isTrue);
19+
});
20+
21+
testWidgets('loads image', (WidgetTester _) async {
22+
final Completer<bool> successCompleter = Completer<bool>();
23+
final ImageProvider<Object> provider = IosPlatformImages.load('flutter');
24+
final ImageStream imageStream = provider.resolve(ImageConfiguration.empty);
25+
imageStream.addListener(
26+
ImageStreamListener((ImageInfo image, bool synchronousCall) {
27+
successCompleter.complete(true);
28+
}, onError: (Object e, StackTrace? _) {
29+
successCompleter.complete(false);
30+
}));
31+
32+
final bool succeeded = await successCompleter.future;
33+
expect(succeeded, true);
34+
});
35+
}

packages/ios_platform_images/example/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ dependencies:
2121
dev_dependencies:
2222
flutter_test:
2323
sdk: flutter
24+
integration_test:
25+
sdk: flutter
2426

2527
flutter:
2628
uses-material-design: true

0 commit comments

Comments
 (0)