Skip to content

Commit

Permalink
[pigeon] Add the iOS tests in the new harness as non-default options (#…
Browse files Browse the repository at this point in the history
…2867)

* Move Obj-C tests into the new harness

* Modernize imports in ObjC tests

* Fix new generation code for merge

* Plumb in new integration tests

* Format

* Add Dart-based support for the new unit test harness

* Restore the old path in run_tests.sh

* Restore ios_unit_tests temporarily, but with symlinks

* Point to new location for generated files

* Hack the imports to work in both locations

* Switch from symlinks to project location changes

* Update README
  • Loading branch information
stuartmorgan committed Nov 30, 2022
1 parent 6d9f6c6 commit e1dc854
Show file tree
Hide file tree
Showing 28 changed files with 559 additions and 116 deletions.
7 changes: 7 additions & 0 deletions packages/pigeon/platform_tests/README.md
Expand Up @@ -29,3 +29,10 @@ supported plugin languages. It covers:
Dart unit tests for null-safe mode. This is a legacy structure from before
NNBD was the only mode Pigeon supported; these should be folded back into
the main tests.

## ios\_unit\_tests

This is a legacy harness that is only necessary for CI, and will be
removed in the future. See
[this PR](https://github.com/flutter/packages/pull/2816) for more
details.
Expand Up @@ -29,6 +29,10 @@ flutter_ios_podfile_setup

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -37,6 +37,17 @@
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33AA165E291EB8B600ECBEEB"
BuildableName = "RunnerTests.xctest"
BlueprintName = "RunnerTests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -2,9 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <XCTest/XCTest.h>
@import Flutter;
@import XCTest;

#ifdef LEGACY_HARNESS
#import "AllDatatypes.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "EchoMessenger.h"

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Expand Up @@ -2,9 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <XCTest/XCTest.h>
@import Flutter;
@import XCTest;

#ifdef LEGACY_HARNESS
#import "AsyncHandlers.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "MockBinaryMessenger.h"

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <Foundation/Foundation.h>
@import Flutter;
@import Foundation;

NS_ASSUME_NONNULL_BEGIN

Expand Down
Expand Up @@ -2,10 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <XCTest/XCTest.h>
#import "EchoMessenger.h"
@import Flutter;
@import XCTest;

#ifdef LEGACY_HARNESS
#import "Enum.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "EchoMessenger.h"

///////////////////////////////////////////////////////////////////////////////////////////
@interface EnumTest : XCTestCase
Expand Down
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <Foundation/Foundation.h>
@import Flutter;
@import Foundation;

NS_ASSUME_NONNULL_BEGIN

Expand Down
Expand Up @@ -2,10 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <XCTest/XCTest.h>
#import "EchoMessenger.h"
@import Flutter;
@import XCTest;

#ifdef LEGACY_HARNESS
#import "List.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "EchoMessenger.h"

///////////////////////////////////////////////////////////////////////////////////////////
@interface ListTest : XCTestCase
Expand Down
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <Foundation/Foundation.h>
@import Flutter;
@import Foundation;

NS_ASSUME_NONNULL_BEGIN

Expand Down
Expand Up @@ -2,10 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <XCTest/XCTest.h>
#import "HandlerBinaryMessenger.h"
@import Flutter;
@import XCTest;

#ifdef LEGACY_HARNESS
#import "MultipleArity.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "HandlerBinaryMessenger.h"

///////////////////////////////////////////////////////////////////////////////////////////
@interface MultipleAritytest : XCTestCase
Expand Down
Expand Up @@ -3,10 +3,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <XCTest/XCTest.h>
#import "EchoMessenger.h"
@import Flutter;
@import XCTest;

#ifdef LEGACY_HARNESS
#import "NonNullFields.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "EchoMessenger.h"

///////////////////////////////////////////////////////////////////////////////////////////
@interface NonNullFieldsTest : XCTestCase
Expand Down
Expand Up @@ -2,10 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <XCTest/XCTest.h>
#import "EchoMessenger.h"
@import Flutter;
@import XCTest;

#ifdef LEGACY_HARNESS
#import "NullFields.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "EchoMessenger.h"

///////////////////////////////////////////////////////////////////////////////////////////
@interface NullFieldsSearchRequest ()
Expand Down
Expand Up @@ -2,10 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <XCTest/XCTest.h>
@import XCTest;

#ifdef LEGACY_HARNESS
#import "NullableReturns.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "EchoMessenger.h"
#import "MockBinaryMessenger.h"
#import "NullableReturns.gen.h"

///////////////////////////////////////////////////////////////////////////////////////////
@interface MockNullableArgHostApi : NSObject <NullableArgHostApi>
Expand Down
Expand Up @@ -2,10 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <XCTest/XCTest.h>
#import "EchoMessenger.h"
@import Flutter;
@import XCTest;

#ifdef LEGACY_HARNESS
#import "Primitive.gen.h"
#else
@import alternate_language_test_plugin;
#endif

#import "EchoMessenger.h"

///////////////////////////////////////////////////////////////////////////////////////////
@interface PrimitiveTest : XCTestCase
Expand Down
Expand Up @@ -2,8 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <XCTest/XCTest.h>
@import XCTest;

#ifdef LEGACY_HARNESS
#import "Message.gen.h"
#else
@import alternate_language_test_plugin;
#endif

@interface ACMessageSearchReply ()
+ (ACMessageSearchReply *)fromMap:(NSDictionary *)dict;
Expand Down
@@ -0,0 +1,5 @@
# TODO(stuartmorgan): Remove this, so that review will show the effects of
# changes on generated files. This will need a way to avoid unnecessary churn,
# such as a flag to suppress version stamp generation.
*.gen.h
*.gen.m
Expand Up @@ -4,5 +4,8 @@

#import <Flutter/Flutter.h>

@interface AlternateLanguageTestPlugin : NSObject <FlutterPlugin>
#import "AllDatatypes.gen.h"
#import "AllVoid.gen.h"

@interface AlternateLanguageTestPlugin : NSObject <FlutterPlugin, AllVoidHostApi, HostEverything>
@end
Expand Up @@ -4,21 +4,36 @@

#import "AlternateLanguageTestPlugin.h"

#import "AllDatatypes.gen.h"
#import "AllVoid.gen.h"

/**
* 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.
*/
@implementation AlternateLanguageTestPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
FlutterMethodChannel *channel =
[FlutterMethodChannel methodChannelWithName:@"alternate_language_test_plugin"
binaryMessenger:[registrar messenger]];
AlternateLanguageTestPlugin *instance = [[AlternateLanguageTestPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
AlternateLanguageTestPlugin *plugin = [[AlternateLanguageTestPlugin alloc] init];
AllVoidHostApiSetup(registrar.messenger, plugin);
HostEverythingSetup(registrar.messenger, plugin);
}

#pragma mark AllVoidHostApi implementation

- (void)doitWithError:(FlutterError *_Nullable *_Nonnull)error {
// No-op.
}

#pragma mark HostEverything implementation

- (nullable Everything *)giveMeEverythingWithError:(FlutterError *_Nullable *_Nonnull)error {
// Currently unused in integration tests, so just return an empty object.
return [[Everything alloc] init];
}

- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
} else {
result(FlutterMethodNotImplemented);
}
- (nullable Everything *)echoEverything:(Everything *)everything
error:(FlutterError *_Nullable *_Nonnull)error {
return everything;
}

@end

0 comments on commit e1dc854

Please sign in to comment.