Skip to content

Commit 33bf242

Browse files
[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
1 parent ff16ee0 commit 33bf242

12 files changed

+96
-45
lines changed

packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,39 @@ set(PLUGIN_NAME "test_plugin_plugin")
1616
list(APPEND PLUGIN_SOURCES
1717
"test_plugin.cpp"
1818
"test_plugin.h"
19+
# Generated sources.
20+
"pigeon/all_datatypes.gen.cpp"
21+
"pigeon/all_datatypes.gen.h"
22+
"pigeon/all_void.gen.cpp"
23+
"pigeon/all_void.gen.h"
24+
"pigeon/async_handlers.gen.cpp"
25+
"pigeon/async_handlers.gen.h"
26+
"pigeon/enum.gen.cpp"
27+
"pigeon/enum.gen.h"
28+
"pigeon/host2flutter.gen.cpp"
29+
"pigeon/host2flutter.gen.h"
30+
"pigeon/list.gen.cpp"
31+
"pigeon/list.gen.h"
32+
"pigeon/message.gen.cpp"
33+
"pigeon/message.gen.h"
34+
"pigeon/multiple_arity.gen.cpp"
35+
"pigeon/multiple_arity.gen.h"
36+
"pigeon/non_null_fields.gen.cpp"
37+
"pigeon/non_null_fields.gen.h"
38+
"pigeon/null_fields.gen.cpp"
39+
"pigeon/null_fields.gen.h"
40+
"pigeon/nullable_returns.gen.cpp"
41+
"pigeon/nullable_returns.gen.h"
42+
"pigeon/primitive.gen.cpp"
43+
"pigeon/primitive.gen.h"
44+
"pigeon/void_arg_flutter.gen.cpp"
45+
"pigeon/void_arg_flutter.gen.h"
46+
"pigeon/void_arg_host.gen.cpp"
47+
"pigeon/void_arg_host.gen.h"
48+
"pigeon/voidflutter.gen.cpp"
49+
"pigeon/voidflutter.gen.h"
50+
"pigeon/voidhost.gen.cpp"
51+
"pigeon/voidhost.gen.h"
1952
)
2053

2154
# Define the plugin library target. Its name must not be changed (see comment
@@ -82,39 +115,6 @@ add_executable(${TEST_RUNNER}
82115
test/null_fields_test.cpp
83116
test/pigeon_test.cpp
84117
test/primitive_test.cpp
85-
# Generated sources.
86-
test/all_datatypes.gen.cpp
87-
test/all_datatypes.gen.h
88-
test/all_void.gen.cpp
89-
test/all_void.gen.h
90-
test/async_handlers.gen.cpp
91-
test/async_handlers.gen.h
92-
test/enum.gen.cpp
93-
test/enum.gen.h
94-
test/host2flutter.gen.cpp
95-
test/host2flutter.gen.h
96-
test/list.gen.cpp
97-
test/list.gen.h
98-
test/message.gen.cpp
99-
test/message.gen.h
100-
test/multiple_arity.gen.cpp
101-
test/multiple_arity.gen.h
102-
test/non_null_fields.gen.cpp
103-
test/non_null_fields.gen.h
104-
test/null_fields.gen.cpp
105-
test/null_fields.gen.h
106-
test/nullable_returns.gen.cpp
107-
test/nullable_returns.gen.h
108-
test/primitive.gen.cpp
109-
test/primitive.gen.h
110-
test/void_arg_flutter.gen.cpp
111-
test/void_arg_flutter.gen.h
112-
test/void_arg_host.gen.cpp
113-
test/void_arg_host.gen.h
114-
test/voidflutter.gen.cpp
115-
test/voidflutter.gen.h
116-
test/voidhost.gen.cpp
117-
test/voidhost.gen.h
118118
# Test utilities.
119119
test/utils/echo_messenger.cpp
120120
test/utils/echo_messenger.h

packages/pigeon/platform_tests/test_plugin/windows/test/multiple_arity_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <gtest/gtest.h>
66

7-
#include "test/multiple_arity.gen.h"
7+
#include "pigeon/multiple_arity.gen.h"
88
#include "test/utils/fake_host_messenger.h"
99

1010
namespace multiple_arity_pigeontest {

packages/pigeon/platform_tests/test_plugin/windows/test/non_null_fields_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <gtest/gtest.h>
66

7-
#include "non_null_fields.gen.h"
7+
#include "pigeon/non_null_fields.gen.h"
88

99
namespace non_null_fields_pigeontest {
1010

packages/pigeon/platform_tests/test_plugin/windows/test/null_fields_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <flutter/encodable_value.h>
66
#include <gtest/gtest.h>
77

8-
#include "null_fields.gen.h"
8+
#include "pigeon/null_fields.gen.h"
99

1010
namespace null_fields_pigeontest {
1111

packages/pigeon/platform_tests/test_plugin/windows/test/nullable_returns_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <optional>
88

9-
#include "test/nullable_returns.gen.h"
9+
#include "pigeon/nullable_returns.gen.h"
1010
#include "test/utils/fake_host_messenger.h"
1111

1212
namespace nullable_returns_pigeontest {

packages/pigeon/platform_tests/test_plugin/windows/test/pigeon_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <memory>
1111
#include <string>
1212

13-
#include "message.gen.h"
13+
#include "pigeon/message.gen.h"
1414

1515
namespace test_plugin {
1616
namespace test {

packages/pigeon/platform_tests/test_plugin/windows/test/primitive_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <gtest/gtest.h>
66

7-
#include "test/primitive.gen.h"
7+
#include "pigeon/primitive.gen.h"
88
#include "test/utils/fake_host_messenger.h"
99

1010
namespace primitive_pigeontest {

packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,22 @@
1010

1111
#include <memory>
1212

13+
#include "pigeon/all_datatypes.gen.h"
14+
#include "pigeon/all_void.gen.h"
15+
1316
namespace test_plugin {
1417

18+
using all_datatypes_pigeontest::Everything;
19+
using all_datatypes_pigeontest::HostEverything;
20+
using all_void_pigeontest::AllVoidHostApi;
21+
1522
// static
1623
void TestPlugin::RegisterWithRegistrar(
1724
flutter::PluginRegistrarWindows* registrar) {
1825
auto plugin = std::make_unique<TestPlugin>();
1926

20-
// This plugin is currently a no-op since only unit tests have been set up.
21-
// In the future, this will register Pigeon APIs used in integration tests.
27+
AllVoidHostApi::SetUp(registrar->messenger(), plugin.get());
28+
HostEverything::SetUp(registrar->messenger(), plugin.get());
2229

2330
registrar->AddPlugin(std::move(plugin));
2431
}
@@ -27,4 +34,20 @@ TestPlugin::TestPlugin() {}
2734

2835
TestPlugin::~TestPlugin() {}
2936

37+
std::optional<all_void_pigeontest::FlutterError> TestPlugin::Doit() {
38+
// No-op.
39+
return std::nullopt;
40+
}
41+
42+
// HostEverything.
43+
all_datatypes_pigeontest::ErrorOr<Everything> TestPlugin::GiveMeEverything() {
44+
// Currently unused in integration tests, so just return an empty object.
45+
return Everything();
46+
}
47+
48+
all_datatypes_pigeontest::ErrorOr<Everything> TestPlugin::Echo(
49+
const Everything& everything) {
50+
return everything;
51+
}
52+
3053
} // namespace test_plugin

packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010

1111
#include <memory>
1212

13+
#include "pigeon/all_datatypes.gen.h"
14+
#include "pigeon/all_void.gen.h"
15+
1316
namespace test_plugin {
1417

15-
class TestPlugin : public flutter::Plugin {
18+
// This plugin handles the native side of the integration tests in
19+
// example/integration_test/
20+
class TestPlugin : public flutter::Plugin,
21+
public all_datatypes_pigeontest::HostEverything,
22+
public all_void_pigeontest::AllVoidHostApi {
1623
public:
1724
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows* registrar);
1825

@@ -23,6 +30,15 @@ class TestPlugin : public flutter::Plugin {
2330
// Disallow copy and assign.
2431
TestPlugin(const TestPlugin&) = delete;
2532
TestPlugin& operator=(const TestPlugin&) = delete;
33+
34+
// AllVoidHostApi.
35+
std::optional<all_void_pigeontest::FlutterError> Doit() override;
36+
37+
// HostEverything.
38+
all_datatypes_pigeontest::ErrorOr<all_datatypes_pigeontest::Everything>
39+
GiveMeEverything() override;
40+
all_datatypes_pigeontest::ErrorOr<all_datatypes_pigeontest::Everything> Echo(
41+
const all_datatypes_pigeontest::Everything& everything) override;
2642
};
2743

2844
} // namespace test_plugin

packages/pigeon/tool/run_tests.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const Map<String, _TestInfo> _tests = <String, _TestInfo>{
3838
'windows_unittests': _TestInfo(
3939
function: _runWindowsUnitTests,
4040
description: 'Unit tests on generated Windows C++ code.'),
41+
'windows_integration_tests': _TestInfo(
42+
function: _runWindowsIntegrationTests,
43+
description: 'Integration tests on generated Windows C++ code.'),
4144
'android_unittests': _TestInfo(
4245
function: _runAndroidUnitTests,
4346
description: 'Unit tests on generated Java code.'),
@@ -255,6 +258,15 @@ Future<int> _runWindowsUnitTests() async {
255258
<String>[]);
256259
}
257260

261+
Future<int> _runWindowsIntegrationTests() async {
262+
const String examplePath = './$_testPluginRelativePath/example';
263+
return runFlutterCommand(
264+
examplePath,
265+
'test',
266+
<String>[_integrationTestFileRelativePath, '-d', 'windows'],
267+
);
268+
}
269+
258270
Future<void> main(List<String> args) async {
259271
final ArgParser parser = ArgParser()
260272
..addOption(_testFlag, abbr: 't', help: 'Only run specified test.')
@@ -306,7 +318,7 @@ ${parser.usage}''');
306318
// the mode used by CI.
307319
if (testsToRun.isEmpty) {
308320
if (Platform.isWindows) {
309-
testsToRun = <String>['windows_unittests'];
321+
testsToRun = <String>['windows_unittests', 'windows_integration_tests'];
310322
} else {
311323
// TODO(gaaclarke): migrate from run_tests.sh to this script.
312324
}

packages/pigeon/tool/shared/generation.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ Future<int> generatePigeons({required String baseDir}) async {
103103
// Windows
104104
cppHeaderOut: skipLanguages.contains(GeneratorLanguages.cpp)
105105
? null
106-
: '$outputBase/windows/test/$input.gen.h',
106+
: '$outputBase/windows/pigeon/$input.gen.h',
107107
cppSourceOut: skipLanguages.contains(GeneratorLanguages.cpp)
108108
? null
109-
: '$outputBase/windows/test/$input.gen.cpp',
109+
: '$outputBase/windows/pigeon/$input.gen.cpp',
110110
cppNamespace: '${input}_pigeontest',
111111
);
112112
if (generateCode != 0) {

0 commit comments

Comments
 (0)