forked from flutter/plugins
-
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.
Add native unit tests to iOS and macOS templates (#117147)
* Improve Swift plugin implementation * Add iOS tests * Review feedback on structure * Remove duplicate scheme file * Add macOS * Add iOS * swift test tweaks * unit tests * Whitespace * Add e2e tests
- Loading branch information
1 parent
9a347fb
commit 2a50236
Showing
18 changed files
with
633 additions
and
93 deletions.
There are no files selected for viewing
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
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
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
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
43 changes: 43 additions & 0 deletions
43
packages/flutter_tools/templates/app_shared/ios-objc.tmpl/RunnerTests/RunnerTests.m.tmpl
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,43 @@ | ||
#import <Flutter/Flutter.h> | ||
#import <UIKit/UIKit.h> | ||
#import <XCTest/XCTest.h> | ||
{{#withPlatformChannelPluginHook}} | ||
|
||
@import {{pluginProjectName}}; | ||
|
||
// This demonstrates a simple unit test of the Objective-C portion of this plugin's implementation. | ||
// | ||
// See https://developer.apple.com/documentation/xctest for more information about using XCTest. | ||
{{/withPlatformChannelPluginHook}} | ||
|
||
@interface RunnerTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation RunnerTests | ||
|
||
{{#withPlatformChannelPluginHook}} | ||
- (void)testExample { | ||
{{pluginClass}} *plugin = [[{{pluginClass}} alloc] init]; | ||
|
||
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"getPlatformVersion" | ||
arguments:nil]; | ||
XCTestExpectation *expectation = [self expectationWithDescription:@"result block must be called"]; | ||
[plugin handleMethodCall:call | ||
result:^(id result) { | ||
NSString *expected = [NSString | ||
stringWithFormat:@"iOS %@", UIDevice.currentDevice.systemVersion]; | ||
XCTAssertEqualObjects(result, expected); | ||
[expectation fulfill]; | ||
}]; | ||
[self waitForExpectationsWithTimeout:1 handler:nil]; | ||
} | ||
{{/withPlatformChannelPluginHook}} | ||
{{^withPlatformChannelPluginHook}} | ||
- (void)testExample { | ||
// If you add code to the Runner application, consider adding tests here. | ||
// See https://developer.apple.com/documentation/xctest for more information about using XCTest. | ||
} | ||
{{/withPlatformChannelPluginHook}} | ||
|
||
@end |
Oops, something went wrong.