This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Started asserting the FlutterEngine is running before communicating over channels. #12469
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3464a50
Started asserting the FlutterEngine is running before communicating
gaaclarke 5ef69cb
Added unit tests.
gaaclarke f8dd376
use NSParameterAssert
gaaclarke 060de29
Turned arc on for FlutterEngineTest.
gaaclarke df43744
format code
gaaclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -6,6 +6,14 @@ | |
| #import <XCTest/XCTest.h> | ||
| #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h" | ||
|
|
||
| #ifndef __has_feature | ||
| #define __has_feature(x) 0 /* for non-clang compilers */ | ||
| #endif | ||
|
|
||
| #if !__has_feature(objc_arc) | ||
| #error ARC must be enabled! | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity what non-clang compilers are compiling these test files?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None today that I know of. If we accidentally used GCC it should probably be an error. I'm just being cautious. Ideally this would be a macro too, I just haven't gotten around to make it one. It's not straightforward to get a macro of macros, I'd have to spend some time looking things up and fiddling with it. |
||
| #endif | ||
|
|
||
| @interface FlutteEngineTest : XCTestCase | ||
| @end | ||
|
|
||
|
|
@@ -19,9 +27,29 @@ - (void)tearDown { | |
|
|
||
| - (void)testCreate { | ||
| id project = OCMClassMock([FlutterDartProject class]); | ||
| FlutterEngine* engine = [[[FlutterEngine alloc] initWithName:@"foobar" | ||
| project:project] autorelease]; | ||
| FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project]; | ||
| XCTAssertNotNil(engine); | ||
| } | ||
|
|
||
| - (void)testSendMessageBeforeRun { | ||
| id project = OCMClassMock([FlutterDartProject class]); | ||
| FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project]; | ||
| XCTAssertNotNil(engine); | ||
| XCTAssertThrows([engine.binaryMessenger | ||
| sendOnChannel:@"foo" | ||
| message:[@"bar" dataUsingEncoding:NSUTF8StringEncoding] | ||
| binaryReply:nil]); | ||
| } | ||
|
|
||
| - (void)testSetMessageHandlerBeforeRun { | ||
| id project = OCMClassMock([FlutterDartProject class]); | ||
| FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project]; | ||
| XCTAssertNotNil(engine); | ||
| XCTAssertThrows([engine.binaryMessenger | ||
| setMessageHandlerOnChannel:@"foo" | ||
| binaryMessageHandler:^(NSData* _Nullable message, FlutterBinaryReply _Nonnull reply){ | ||
|
|
||
| }]); | ||
| } | ||
|
|
||
| @end | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we tell them how to run it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was careful to use the word "run" to match the verb in our run methods. It's a bit complicated, should I say something like "See run* methods"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh it's okay, it would make sense to list it if there was maybe only one way to run it. What you have is fine.