mirror of
https://github.com/flutter/packages.git
synced 2025-07-02 08:34:31 +08:00
[pigeon] Enable integrations tests for Windows (#2853)
Enables the new shared integration tests for the Windows C++ generator, adding the new corresponding test script target and running it by default in CI. Part of flutter/flutter#111505
This commit is contained in:
@ -16,6 +16,39 @@ set(PLUGIN_NAME "test_plugin_plugin")
|
||||
list(APPEND PLUGIN_SOURCES
|
||||
"test_plugin.cpp"
|
||||
"test_plugin.h"
|
||||
# Generated sources.
|
||||
"pigeon/all_datatypes.gen.cpp"
|
||||
"pigeon/all_datatypes.gen.h"
|
||||
"pigeon/all_void.gen.cpp"
|
||||
"pigeon/all_void.gen.h"
|
||||
"pigeon/async_handlers.gen.cpp"
|
||||
"pigeon/async_handlers.gen.h"
|
||||
"pigeon/enum.gen.cpp"
|
||||
"pigeon/enum.gen.h"
|
||||
"pigeon/host2flutter.gen.cpp"
|
||||
"pigeon/host2flutter.gen.h"
|
||||
"pigeon/list.gen.cpp"
|
||||
"pigeon/list.gen.h"
|
||||
"pigeon/message.gen.cpp"
|
||||
"pigeon/message.gen.h"
|
||||
"pigeon/multiple_arity.gen.cpp"
|
||||
"pigeon/multiple_arity.gen.h"
|
||||
"pigeon/non_null_fields.gen.cpp"
|
||||
"pigeon/non_null_fields.gen.h"
|
||||
"pigeon/null_fields.gen.cpp"
|
||||
"pigeon/null_fields.gen.h"
|
||||
"pigeon/nullable_returns.gen.cpp"
|
||||
"pigeon/nullable_returns.gen.h"
|
||||
"pigeon/primitive.gen.cpp"
|
||||
"pigeon/primitive.gen.h"
|
||||
"pigeon/void_arg_flutter.gen.cpp"
|
||||
"pigeon/void_arg_flutter.gen.h"
|
||||
"pigeon/void_arg_host.gen.cpp"
|
||||
"pigeon/void_arg_host.gen.h"
|
||||
"pigeon/voidflutter.gen.cpp"
|
||||
"pigeon/voidflutter.gen.h"
|
||||
"pigeon/voidhost.gen.cpp"
|
||||
"pigeon/voidhost.gen.h"
|
||||
)
|
||||
|
||||
# Define the plugin library target. Its name must not be changed (see comment
|
||||
@ -82,39 +115,6 @@ add_executable(${TEST_RUNNER}
|
||||
test/null_fields_test.cpp
|
||||
test/pigeon_test.cpp
|
||||
test/primitive_test.cpp
|
||||
# Generated sources.
|
||||
test/all_datatypes.gen.cpp
|
||||
test/all_datatypes.gen.h
|
||||
test/all_void.gen.cpp
|
||||
test/all_void.gen.h
|
||||
test/async_handlers.gen.cpp
|
||||
test/async_handlers.gen.h
|
||||
test/enum.gen.cpp
|
||||
test/enum.gen.h
|
||||
test/host2flutter.gen.cpp
|
||||
test/host2flutter.gen.h
|
||||
test/list.gen.cpp
|
||||
test/list.gen.h
|
||||
test/message.gen.cpp
|
||||
test/message.gen.h
|
||||
test/multiple_arity.gen.cpp
|
||||
test/multiple_arity.gen.h
|
||||
test/non_null_fields.gen.cpp
|
||||
test/non_null_fields.gen.h
|
||||
test/null_fields.gen.cpp
|
||||
test/null_fields.gen.h
|
||||
test/nullable_returns.gen.cpp
|
||||
test/nullable_returns.gen.h
|
||||
test/primitive.gen.cpp
|
||||
test/primitive.gen.h
|
||||
test/void_arg_flutter.gen.cpp
|
||||
test/void_arg_flutter.gen.h
|
||||
test/void_arg_host.gen.cpp
|
||||
test/void_arg_host.gen.h
|
||||
test/voidflutter.gen.cpp
|
||||
test/voidflutter.gen.h
|
||||
test/voidhost.gen.cpp
|
||||
test/voidhost.gen.h
|
||||
# Test utilities.
|
||||
test/utils/echo_messenger.cpp
|
||||
test/utils/echo_messenger.h
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "test/multiple_arity.gen.h"
|
||||
#include "pigeon/multiple_arity.gen.h"
|
||||
#include "test/utils/fake_host_messenger.h"
|
||||
|
||||
namespace multiple_arity_pigeontest {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "non_null_fields.gen.h"
|
||||
#include "pigeon/non_null_fields.gen.h"
|
||||
|
||||
namespace non_null_fields_pigeontest {
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <flutter/encodable_value.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "null_fields.gen.h"
|
||||
#include "pigeon/null_fields.gen.h"
|
||||
|
||||
namespace null_fields_pigeontest {
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "test/nullable_returns.gen.h"
|
||||
#include "pigeon/nullable_returns.gen.h"
|
||||
#include "test/utils/fake_host_messenger.h"
|
||||
|
||||
namespace nullable_returns_pigeontest {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "message.gen.h"
|
||||
#include "pigeon/message.gen.h"
|
||||
|
||||
namespace test_plugin {
|
||||
namespace test {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "test/primitive.gen.h"
|
||||
#include "pigeon/primitive.gen.h"
|
||||
#include "test/utils/fake_host_messenger.h"
|
||||
|
||||
namespace primitive_pigeontest {
|
||||
|
@ -10,15 +10,22 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "pigeon/all_datatypes.gen.h"
|
||||
#include "pigeon/all_void.gen.h"
|
||||
|
||||
namespace test_plugin {
|
||||
|
||||
using all_datatypes_pigeontest::Everything;
|
||||
using all_datatypes_pigeontest::HostEverything;
|
||||
using all_void_pigeontest::AllVoidHostApi;
|
||||
|
||||
// static
|
||||
void TestPlugin::RegisterWithRegistrar(
|
||||
flutter::PluginRegistrarWindows* registrar) {
|
||||
auto plugin = std::make_unique<TestPlugin>();
|
||||
|
||||
// This plugin is currently a no-op since only unit tests have been set up.
|
||||
// In the future, this will register Pigeon APIs used in integration tests.
|
||||
AllVoidHostApi::SetUp(registrar->messenger(), plugin.get());
|
||||
HostEverything::SetUp(registrar->messenger(), plugin.get());
|
||||
|
||||
registrar->AddPlugin(std::move(plugin));
|
||||
}
|
||||
@ -27,4 +34,20 @@ TestPlugin::TestPlugin() {}
|
||||
|
||||
TestPlugin::~TestPlugin() {}
|
||||
|
||||
std::optional<all_void_pigeontest::FlutterError> TestPlugin::Doit() {
|
||||
// No-op.
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// HostEverything.
|
||||
all_datatypes_pigeontest::ErrorOr<Everything> TestPlugin::GiveMeEverything() {
|
||||
// Currently unused in integration tests, so just return an empty object.
|
||||
return Everything();
|
||||
}
|
||||
|
||||
all_datatypes_pigeontest::ErrorOr<Everything> TestPlugin::Echo(
|
||||
const Everything& everything) {
|
||||
return everything;
|
||||
}
|
||||
|
||||
} // namespace test_plugin
|
||||
|
@ -10,9 +10,16 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "pigeon/all_datatypes.gen.h"
|
||||
#include "pigeon/all_void.gen.h"
|
||||
|
||||
namespace test_plugin {
|
||||
|
||||
class TestPlugin : public flutter::Plugin {
|
||||
// This plugin handles the native side of the integration tests in
|
||||
// example/integration_test/
|
||||
class TestPlugin : public flutter::Plugin,
|
||||
public all_datatypes_pigeontest::HostEverything,
|
||||
public all_void_pigeontest::AllVoidHostApi {
|
||||
public:
|
||||
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows* registrar);
|
||||
|
||||
@ -23,6 +30,15 @@ class TestPlugin : public flutter::Plugin {
|
||||
// Disallow copy and assign.
|
||||
TestPlugin(const TestPlugin&) = delete;
|
||||
TestPlugin& operator=(const TestPlugin&) = delete;
|
||||
|
||||
// AllVoidHostApi.
|
||||
std::optional<all_void_pigeontest::FlutterError> Doit() override;
|
||||
|
||||
// HostEverything.
|
||||
all_datatypes_pigeontest::ErrorOr<all_datatypes_pigeontest::Everything>
|
||||
GiveMeEverything() override;
|
||||
all_datatypes_pigeontest::ErrorOr<all_datatypes_pigeontest::Everything> Echo(
|
||||
const all_datatypes_pigeontest::Everything& everything) override;
|
||||
};
|
||||
|
||||
} // namespace test_plugin
|
||||
|
@ -38,6 +38,9 @@ const Map<String, _TestInfo> _tests = <String, _TestInfo>{
|
||||
'windows_unittests': _TestInfo(
|
||||
function: _runWindowsUnitTests,
|
||||
description: 'Unit tests on generated Windows C++ code.'),
|
||||
'windows_integration_tests': _TestInfo(
|
||||
function: _runWindowsIntegrationTests,
|
||||
description: 'Integration tests on generated Windows C++ code.'),
|
||||
'android_unittests': _TestInfo(
|
||||
function: _runAndroidUnitTests,
|
||||
description: 'Unit tests on generated Java code.'),
|
||||
@ -255,6 +258,15 @@ Future<int> _runWindowsUnitTests() async {
|
||||
<String>[]);
|
||||
}
|
||||
|
||||
Future<int> _runWindowsIntegrationTests() async {
|
||||
const String examplePath = './$_testPluginRelativePath/example';
|
||||
return runFlutterCommand(
|
||||
examplePath,
|
||||
'test',
|
||||
<String>[_integrationTestFileRelativePath, '-d', 'windows'],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
final ArgParser parser = ArgParser()
|
||||
..addOption(_testFlag, abbr: 't', help: 'Only run specified test.')
|
||||
@ -306,7 +318,7 @@ ${parser.usage}''');
|
||||
// the mode used by CI.
|
||||
if (testsToRun.isEmpty) {
|
||||
if (Platform.isWindows) {
|
||||
testsToRun = <String>['windows_unittests'];
|
||||
testsToRun = <String>['windows_unittests', 'windows_integration_tests'];
|
||||
} else {
|
||||
// TODO(gaaclarke): migrate from run_tests.sh to this script.
|
||||
}
|
||||
|
@ -103,10 +103,10 @@ Future<int> generatePigeons({required String baseDir}) async {
|
||||
// Windows
|
||||
cppHeaderOut: skipLanguages.contains(GeneratorLanguages.cpp)
|
||||
? null
|
||||
: '$outputBase/windows/test/$input.gen.h',
|
||||
: '$outputBase/windows/pigeon/$input.gen.h',
|
||||
cppSourceOut: skipLanguages.contains(GeneratorLanguages.cpp)
|
||||
? null
|
||||
: '$outputBase/windows/test/$input.gen.cpp',
|
||||
: '$outputBase/windows/pigeon/$input.gen.cpp',
|
||||
cppNamespace: '${input}_pigeontest',
|
||||
);
|
||||
if (generateCode != 0) {
|
||||
|
Reference in New Issue
Block a user