mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 23:51:55 +08:00
[pigeon] Enable iOS Swift integration tests (#2858)
* [pigeon] Fix Java integration test script Fixes a copy/paste error in run_tests.dart that would cause the command for the new Java integration tests to run the Kotlin tests instead. * Enable Swift iOS integration tests
This commit is contained in:
@ -6,14 +6,30 @@ import Flutter
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This plugin is currently a no-op since only unit tests have been set up.
|
* This plugin handles the native side of the integration tests in
|
||||||
* In the future, this will register Pigeon APIs used in integration tests.
|
* example/integration_test/.
|
||||||
*/
|
*/
|
||||||
public class TestPlugin: NSObject, FlutterPlugin {
|
public class TestPlugin: NSObject, FlutterPlugin, AllVoidHostApi, HostEverything {
|
||||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||||
|
let plugin = TestPlugin()
|
||||||
|
AllVoidHostApiSetup.setUp(binaryMessenger: registrar.messenger(), api: plugin)
|
||||||
|
HostEverythingSetup.setUp(binaryMessenger: registrar.messenger(), api: plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
// MARK: AllVoidHostApi implementation
|
||||||
result(FlutterMethodNotImplemented)
|
|
||||||
|
func doit() {
|
||||||
|
// No-op
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: HostEverything implementation
|
||||||
|
|
||||||
|
func giveMeEverything() -> Everything {
|
||||||
|
// Currently unused in integration tests, so just return an empty object.
|
||||||
|
return Everything()
|
||||||
|
}
|
||||||
|
|
||||||
|
func echo(everything: Everything) -> Everything {
|
||||||
|
return everything
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,10 @@ run_ios_swift_unittests() {
|
|||||||
dart run tool/run_tests.dart -t ios_swift_unittests --skip-generation
|
dart run tool/run_tests.dart -t ios_swift_unittests --skip-generation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_ios_swift_e2e_tests() {
|
||||||
|
dart run tool/run_tests.dart -t ios_swift_integration_tests --skip-generation
|
||||||
|
}
|
||||||
|
|
||||||
run_macos_swift_unittests() {
|
run_macos_swift_unittests() {
|
||||||
dart run tool/run_tests.dart -t macos_swift_unittests --skip-generation
|
dart run tool/run_tests.dart -t macos_swift_unittests --skip-generation
|
||||||
}
|
}
|
||||||
@ -214,7 +218,7 @@ run_ios_unittests() {
|
|||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
run_ios_e2e_tests() {
|
run_ios_e2e_legacy_tests() {
|
||||||
DARTLE_H="e2e_tests/test_objc/ios/Runner/dartle.h"
|
DARTLE_H="e2e_tests/test_objc/ios/Runner/dartle.h"
|
||||||
DARTLE_M="e2e_tests/test_objc/ios/Runner/dartle.m"
|
DARTLE_M="e2e_tests/test_objc/ios/Runner/dartle.m"
|
||||||
DARTLE_DART="e2e_tests/test_objc/lib/dartle.dart"
|
DARTLE_DART="e2e_tests/test_objc/lib/dartle.dart"
|
||||||
@ -262,9 +266,13 @@ should_run_android_unittests=true
|
|||||||
should_run_dart_compilation_tests=true
|
should_run_dart_compilation_tests=true
|
||||||
should_run_dart_unittests=true
|
should_run_dart_unittests=true
|
||||||
should_run_flutter_unittests=true
|
should_run_flutter_unittests=true
|
||||||
should_run_ios_e2e_tests=true
|
should_run_ios_e2e_legacy_tests=true
|
||||||
should_run_ios_unittests=true
|
should_run_ios_unittests=true
|
||||||
should_run_ios_swift_unittests=true
|
should_run_ios_swift_unittests=true
|
||||||
|
# Currently these are testing exactly the same thing as macos_swift_e2e_tests,
|
||||||
|
# so we don't need to run both by default. This should become `true` if any
|
||||||
|
# iOS-only tests are added (e.g., for a feature not supported by macOS).
|
||||||
|
should_run_ios_swift_e2e_tests=false
|
||||||
should_run_mock_handler_tests=true
|
should_run_mock_handler_tests=true
|
||||||
should_run_macos_swift_unittests=true
|
should_run_macos_swift_unittests=true
|
||||||
should_run_macos_swift_e2e_tests=true
|
should_run_macos_swift_e2e_tests=true
|
||||||
@ -280,9 +288,10 @@ while getopts "t:l?h" opt; do
|
|||||||
should_run_dart_compilation_tests=false
|
should_run_dart_compilation_tests=false
|
||||||
should_run_dart_unittests=false
|
should_run_dart_unittests=false
|
||||||
should_run_flutter_unittests=false
|
should_run_flutter_unittests=false
|
||||||
should_run_ios_e2e_tests=false
|
should_run_ios_e2e_legacy_tests=false
|
||||||
should_run_ios_unittests=false
|
should_run_ios_unittests=false
|
||||||
should_run_ios_swift_unittests=false
|
should_run_ios_swift_unittests=false
|
||||||
|
should_run_ios_swift_e2e_tests=false
|
||||||
should_run_mock_handler_tests=false
|
should_run_mock_handler_tests=false
|
||||||
should_run_macos_swift_unittests=false
|
should_run_macos_swift_unittests=false
|
||||||
should_run_macos_swift_e2e_tests=false
|
should_run_macos_swift_e2e_tests=false
|
||||||
@ -296,10 +305,11 @@ while getopts "t:l?h" opt; do
|
|||||||
dart_compilation_tests) should_run_dart_compilation_tests=true ;;
|
dart_compilation_tests) should_run_dart_compilation_tests=true ;;
|
||||||
dart_unittests) should_run_dart_unittests=true ;;
|
dart_unittests) should_run_dart_unittests=true ;;
|
||||||
flutter_unittests) should_run_flutter_unittests=true ;;
|
flutter_unittests) should_run_flutter_unittests=true ;;
|
||||||
ios_e2e_tests) should_run_ios_e2e_tests=true ;;
|
ios_e2e_legacy_tests) should_run_ios_e2e_legacy_tests=true ;;
|
||||||
# TODO(stuartmorgan): Rename to include "objc".
|
# TODO(stuartmorgan): Rename to include "objc".
|
||||||
ios_unittests) should_run_ios_unittests=true ;;
|
ios_unittests) should_run_ios_unittests=true ;;
|
||||||
ios_swift_unittests) should_run_ios_swift_unittests=true ;;
|
ios_swift_unittests) should_run_ios_swift_unittests=true ;;
|
||||||
|
ios_swift_e2e_tests) should_run_ios_swift_e2e_tests=true ;;
|
||||||
mock_handler_tests) should_run_mock_handler_tests=true ;;
|
mock_handler_tests) should_run_mock_handler_tests=true ;;
|
||||||
macos_swift_unittests) should_run_macos_swift_unittests=true ;;
|
macos_swift_unittests) should_run_macos_swift_unittests=true ;;
|
||||||
macos_swift_e2e_tests) should_run_macos_swift_e2e_tests=true ;;
|
macos_swift_e2e_tests) should_run_macos_swift_e2e_tests=true ;;
|
||||||
@ -320,9 +330,10 @@ while getopts "t:l?h" opt; do
|
|||||||
dart_compilation_tests - Compilation tests on generated Dart code.
|
dart_compilation_tests - Compilation tests on generated Dart code.
|
||||||
dart_unittests - Unit tests on and analysis on Pigeon's implementation.
|
dart_unittests - Unit tests on and analysis on Pigeon's implementation.
|
||||||
flutter_unittests - Unit tests on generated Dart code.
|
flutter_unittests - Unit tests on generated Dart code.
|
||||||
ios_e2e_tests - End-to-end objc tests run on iOS Simulator
|
ios_e2e_legacy_tests - Legacy end-to-end Obj-C tests; build-only.
|
||||||
ios_unittests - Unit tests on generated Objc code.
|
ios_unittests - Unit tests on generated Objc code.
|
||||||
ios_swift_unittests - Unit tests on generated Swift code.
|
ios_swift_unittests - Unit tests on generated Swift code.
|
||||||
|
ios_swift_e2e_tests - Integration tests on generated Swift code on iOS.
|
||||||
mock_handler_tests - Unit tests on generated Dart mock handler code.
|
mock_handler_tests - Unit tests on generated Dart mock handler code.
|
||||||
macos_swift_unittests - Unit tests on generated Swift code on macOS.
|
macos_swift_unittests - Unit tests on generated Swift code on macOS.
|
||||||
macos_swift_e2e_tests - Integration tests on generated Swift code on macOS.
|
macos_swift_e2e_tests - Integration tests on generated Swift code on macOS.
|
||||||
@ -373,8 +384,11 @@ fi
|
|||||||
if [ "$should_run_ios_swift_unittests" = true ]; then
|
if [ "$should_run_ios_swift_unittests" = true ]; then
|
||||||
run_ios_swift_unittests
|
run_ios_swift_unittests
|
||||||
fi
|
fi
|
||||||
if [ "$should_run_ios_e2e_tests" = true ]; then
|
if [ "$should_run_ios_swift_e2e_tests" = true ]; then
|
||||||
run_ios_e2e_tests
|
run_ios_swift_e2e_tests
|
||||||
|
fi
|
||||||
|
if [ "$should_run_ios_e2e_legacy_tests" = true ]; then
|
||||||
|
run_ios_e2e_legacy_tests
|
||||||
fi
|
fi
|
||||||
if [ "$should_run_android_unittests" = true ]; then
|
if [ "$should_run_android_unittests" = true ]; then
|
||||||
run_android_unittests
|
run_android_unittests
|
||||||
|
@ -68,11 +68,14 @@ const Map<String, _TestInfo> _tests = <String, _TestInfo>{
|
|||||||
function: _runFlutterUnitTests,
|
function: _runFlutterUnitTests,
|
||||||
description: 'Unit tests on generated Dart code.'),
|
description: 'Unit tests on generated Dart code.'),
|
||||||
'ios_unittests': _TestInfo(
|
'ios_unittests': _TestInfo(
|
||||||
function: _runIosUnitTests,
|
function: _runIOSUnitTests,
|
||||||
description: 'Unit tests on generated Objective-C code.'),
|
description: 'Unit tests on generated Objective-C code.'),
|
||||||
'ios_swift_unittests': _TestInfo(
|
'ios_swift_unittests': _TestInfo(
|
||||||
function: _runIosSwiftUnitTests,
|
function: _runIOSSwiftUnitTests,
|
||||||
description: 'Unit tests on generated Swift code.'),
|
description: 'Unit tests on generated Swift code.'),
|
||||||
|
'ios_swift_integration_tests': _TestInfo(
|
||||||
|
function: _runIOSSwiftIntegrationTests,
|
||||||
|
description: 'Integration tests on generated Swift code.'),
|
||||||
'macos_swift_unittests': _TestInfo(
|
'macos_swift_unittests': _TestInfo(
|
||||||
function: _runMacOSSwiftUnitTests,
|
function: _runMacOSSwiftUnitTests,
|
||||||
description: 'Unit tests on generated Swift code on macOS.'),
|
description: 'Unit tests on generated Swift code on macOS.'),
|
||||||
@ -89,7 +92,8 @@ Future<int> _runAndroidJavaUnitTests() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> _runAndroidJavaIntegrationTests() async {
|
Future<int> _runAndroidJavaIntegrationTests() async {
|
||||||
return _runAndroidIntegrationTests(_alternateLanguageTestPluginRelativePath);
|
return _runMobileIntegrationTests(
|
||||||
|
'Android', _alternateLanguageTestPluginRelativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> _runAndroidKotlinUnitTests() async {
|
Future<int> _runAndroidKotlinUnitTests() async {
|
||||||
@ -107,14 +111,15 @@ Future<int> _runAndroidKotlinUnitTests() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> _runAndroidKotlinIntegrationTests() async {
|
Future<int> _runAndroidKotlinIntegrationTests() async {
|
||||||
return _runAndroidIntegrationTests(_testPluginRelativePath);
|
return _runMobileIntegrationTests('Android', _testPluginRelativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> _runAndroidIntegrationTests(String testPluginPath) async {
|
Future<int> _runMobileIntegrationTests(
|
||||||
final String? device = await getDeviceForPlatform('android');
|
String platform, String testPluginPath) async {
|
||||||
|
final String? device = await getDeviceForPlatform(platform.toLowerCase());
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
print('No Android device available. Attach an Android device or start '
|
print('No $platform device available. Attach an $platform device or start '
|
||||||
'an emulator to run integration tests');
|
'an emulator/simulator to run integration tests');
|
||||||
return _noDeviceAvailableExitCode;
|
return _noDeviceAvailableExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +223,7 @@ Future<int> _runFlutterUnitTests() async {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> _runIosUnitTests() async {
|
Future<int> _runIOSUnitTests() async {
|
||||||
throw UnimplementedError('See run_tests.sh.');
|
throw UnimplementedError('See run_tests.sh.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +249,7 @@ Future<int> _runMacOSSwiftIntegrationTests() async {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> _runIosSwiftUnitTests() async {
|
Future<int> _runIOSSwiftUnitTests() async {
|
||||||
const String examplePath = './$_testPluginRelativePath/example';
|
const String examplePath = './$_testPluginRelativePath/example';
|
||||||
final int compileCode = await runFlutterBuild(
|
final int compileCode = await runFlutterBuild(
|
||||||
examplePath,
|
examplePath,
|
||||||
@ -263,6 +268,10 @@ Future<int> _runIosSwiftUnitTests() async {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> _runIOSSwiftIntegrationTests() async {
|
||||||
|
return _runMobileIntegrationTests('iOS', _testPluginRelativePath);
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> _runMockHandlerTests() async {
|
Future<int> _runMockHandlerTests() async {
|
||||||
const String unitTestsPath = './mock_handler_tester';
|
const String unitTestsPath = './mock_handler_tester';
|
||||||
final int generateCode = await runPigeon(
|
final int generateCode = await runPigeon(
|
||||||
|
Reference in New Issue
Block a user