forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
1 parent
4512e4d
commit b04d2cc
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/ios_platform_images/example/integration_test/ios_platform_images_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters