Skip to content

Commit

Permalink
[ios_platform_images] Add integration tests (flutter#4899)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stuartmorgan authored Sep 12, 2023
1 parent 4512e4d commit b04d2cc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:ios_platform_images/ios_platform_images.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('resolves URL', (WidgetTester _) async {
final String? path = await IosPlatformImages.resolveURL('textfile');
expect(Uri.parse(path!).scheme, 'file');
expect(path.contains('Runner.app'), isTrue);
});

testWidgets('loads image', (WidgetTester _) async {
final Completer<bool> successCompleter = Completer<bool>();
final ImageProvider<Object> provider = IosPlatformImages.load('flutter');
final ImageStream imageStream = provider.resolve(ImageConfiguration.empty);
imageStream.addListener(
ImageStreamListener((ImageInfo image, bool synchronousCall) {
successCompleter.complete(true);
}, onError: (Object e, StackTrace? _) {
successCompleter.complete(false);
}));

final bool succeeded = await successCompleter.future;
expect(succeeded, true);
});
}
2 changes: 2 additions & 0 deletions packages/ios_platform_images/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter

flutter:
uses-material-design: true

0 comments on commit b04d2cc

Please sign in to comment.