Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | List of all members
FlutterEngineTest Class Reference
Inheritance diagram for FlutterEngineTest:

Instance Methods

(void) - setUp [implementation]
 
(void) - tearDown [implementation]
 
(void) - testCreate [implementation]
 
(void) - testInfoPlist [implementation]
 
(void) - testDeallocated [implementation]
 
(void) - testSendMessageBeforeRun [implementation]
 
(void) - testSetMessageHandlerBeforeRun [implementation]
 
(void) - testNilSetMessageHandlerBeforeRun [implementation]
 
(void) - testNotifyPluginOfDealloc [implementation]
 
(void) - testSetBinaryMessengerToSameBinaryMessenger [implementation]
 
(void) - testRunningInitialRouteSendsNavigationMessage [implementation]
 
(void) - testInitialRouteSettingsSendsNavigationMessage [implementation]
 
(void) - testPlatformViewsControllerRenderingMetalBackend [implementation]
 
(void) - testPlatformViewsControllerRenderingSoftware [implementation]
 
(void) - testWaitForFirstFrameTimeout [implementation]
 
(void) - testSpawn [implementation]
 
(void) - testDeallocNotification [implementation]
 
(void) - testSetHandlerAfterRun [implementation]
 
(void) - testThreadPrioritySetCorrectly [implementation]
 
(void) - testCanEnableDisableEmbedderAPIThroughInfoPlist [implementation]
 
(void) - testFlutterTextInputViewDidResignFirstResponderWillCallTextInputClientConnectionClosed [implementation]
 
(void) - testFlutterEngineUpdatesDisplays [implementation]
 
(void) - testLifeCycleNotificationDidEnterBackground [implementation]
 
(void) - testLifeCycleNotificationWillEnterForeground [implementation]
 
(void) - testSpawnsShareGpuContext [implementation]
 
(void) - testEnableSemanticsWhenFlutterViewAccessibilityDidCall [implementation]
 
(void) - testIsolateId [implementation]
 
(void) - testChannelSetup [implementation]
 
(void) - testReleaseViewControllerAfterDestroyContextInHeadlessMode [implementation]
 

Detailed Description

Definition at line 55 of file FlutterEngineTest.mm.

Method Documentation

◆ setUp

- (void) setUp
implementation

Definition at line 44 of file FlutterEngineTest.mm.

60 {
61}

◆ tearDown

- (void) tearDown
implementation

Definition at line 44 of file FlutterEngineTest.mm.

63 {
64}

◆ testCanEnableDisableEmbedderAPIThroughInfoPlist

- (void) testCanEnableDisableEmbedderAPIThroughInfoPlist
implementation

Definition at line 44 of file FlutterEngineTest.mm.

344 {
345 {
346 // Not enable embedder API by default
348 settings.enable_software_rendering = true;
349 FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings];
350 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
351 XCTAssertFalse(engine.enableEmbedderAPI);
352 }
353 {
354 // Enable embedder api
355 id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
356 OCMStub([mockMainBundle objectForInfoDictionaryKey:@"FLTEnableIOSEmbedderAPI"])
357 .andReturn(@"YES");
359 settings.enable_software_rendering = true;
360 FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings];
361 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
362 XCTAssertTrue(engine.enableEmbedderAPI);
363 }
364}
FlutterEngine engine
Definition main.cc:68
flutter::Settings FLTDefaultSettingsForBundle(NSBundle *bundle, NSProcessInfo *processInfoOrNil)

◆ testChannelSetup

- (void) testChannelSetup
implementation

Definition at line 15 of file FlutterEngineTest.m.

34 {
35 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil];
36 XCTAssertNil(engine.navigationChannel);
37 XCTAssertNil(engine.platformChannel);
38 XCTAssertNil(engine.lifecycleChannel);
39
40 XCTAssertTrue([engine run]);
41
42 XCTAssertNotNil(engine.navigationChannel);
43 XCTAssertNotNil(engine.platformChannel);
44 XCTAssertNotNil(engine.lifecycleChannel);
45
46 [engine destroyContext];
47
48 XCTAssertNil(engine.navigationChannel);
49 XCTAssertNil(engine.platformChannel);
50 XCTAssertNil(engine.lifecycleChannel);
51}
FlutterMethodChannel * navigationChannel
FlutterBasicMessageChannel * lifecycleChannel
FlutterMethodChannel * platformChannel
Definition run.py:1

◆ testCreate

- (void) testCreate
implementation

Definition at line 44 of file FlutterEngineTest.mm.

66 {
67 FlutterDartProject* project = [[FlutterDartProject alloc] init];
68 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
69 XCTAssertNotNil(engine);
70}

◆ testDeallocated

- (void) testDeallocated
implementation

Definition at line 44 of file FlutterEngineTest.mm.

128 {
129 __weak FlutterEngine* weakEngine = nil;
130 @autoreleasepool {
131 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
132 weakEngine = engine;
133 [engine run];
134 XCTAssertNotNil(weakEngine);
135 }
136 XCTAssertNil(weakEngine);
137}

◆ testDeallocNotification

- (void) testDeallocNotification
implementation

Definition at line 44 of file FlutterEngineTest.mm.

276 {
277 XCTestExpectation* deallocNotification = [self expectationWithDescription:@"deallocNotification"];
278 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
279 id<NSObject> observer;
280 @autoreleasepool {
281 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
282 observer = [center addObserverForName:kFlutterEngineWillDealloc
283 object:engine
284 queue:[NSOperationQueue mainQueue]
285 usingBlock:^(NSNotification* note) {
286 [deallocNotification fulfill];
287 }];
288 }
289 [self waitForExpectationsWithTimeout:1 handler:nil];
290 [center removeObserver:observer];
291}
static SkScalar center(float pos0, float pos1)

◆ testEnableSemanticsWhenFlutterViewAccessibilityDidCall

- (void) testEnableSemanticsWhenFlutterViewAccessibilityDidCall
implementation

Definition at line 44 of file FlutterEngineTest.mm.

466 {
467 FlutterEngineSpy* engine = [[FlutterEngineSpy alloc] initWithName:@"foobar"];
468 engine.ensureSemanticsEnabledCalled = NO;
470 XCTAssertTrue(engine.ensureSemanticsEnabledCalled);
471}
void flutterViewAccessibilityDidCall()

◆ testFlutterEngineUpdatesDisplays

- (void) testFlutterEngineUpdatesDisplays
implementation

Definition at line 44 of file FlutterEngineTest.mm.

379 {
380 FlutterEngine* engine = [[FlutterEngine alloc] init];
381 id mockEngine = OCMPartialMock(engine);
382
383 [engine run];
384 OCMVerify(times(1), [mockEngine updateDisplays]);
386 OCMVerify(times(2), [mockEngine updateDisplays]);
387}
static SkISize times(const SkISize &size, float factor)
FlutterViewController * viewController

◆ testFlutterTextInputViewDidResignFirstResponderWillCallTextInputClientConnectionClosed

- (void) testFlutterTextInputViewDidResignFirstResponderWillCallTextInputClientConnectionClosed
implementation

Definition at line 44 of file FlutterEngineTest.mm.

366 {
367 id mockBinaryMessenger = OCMClassMock([FlutterBinaryMessengerRelay class]);
368 FlutterEngine* engine = [[FlutterEngine alloc] init];
369 [engine setBinaryMessenger:mockBinaryMessenger];
370 [engine runWithEntrypoint:FlutterDefaultDartEntrypoint initialRoute:@"test"];
372 FlutterMethodCall* methodCall =
373 [FlutterMethodCall methodCallWithMethodName:@"TextInputClient.onConnectionClosed"
374 arguments:@[ @(1) ]];
375 NSData* encodedMethodCall = [[FlutterJSONMethodCodec sharedInstance] encodeMethodCall:methodCall];
376 OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/textinput" message:encodedMethodCall]);
377}
void flutterTextInputView:didResignFirstResponderWithTextInputClient:(FlutterTextInputView *textInputView, [didResignFirstResponderWithTextInputClient] int client)
void setBinaryMessenger:(FlutterBinaryMessengerRelay *binaryMessenger)
BOOL runWithEntrypoint:initialRoute:(nullable NSString *entrypoint,[initialRoute] nullable NSString *initialRoute)
instancetype sharedInstance()
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
Win32Message message

◆ testInfoPlist

- (void) testInfoPlist
implementation

Definition at line 44 of file FlutterEngineTest.mm.

72 {
73 // Check the embedded Flutter.framework Info.plist, not the linked dylib.
74 NSURL* flutterFrameworkURL =
75 [NSBundle.mainBundle.privateFrameworksURL URLByAppendingPathComponent:@"Flutter.framework"];
76 NSBundle* flutterBundle = [NSBundle bundleWithURL:flutterFrameworkURL];
77 XCTAssertEqualObjects(flutterBundle.bundleIdentifier, @"io.flutter.flutter");
78
79 NSDictionary<NSString*, id>* infoDictionary = flutterBundle.infoDictionary;
80
81 // OS version can have one, two, or three digits: "8", "8.0", "8.0.0"
82 NSError* regexError = NULL;
83 NSRegularExpression* osVersionRegex =
84 [NSRegularExpression regularExpressionWithPattern:@"((0|[1-9]\\d*)\\.)*(0|[1-9]\\d*)"
85 options:NSRegularExpressionCaseInsensitive
86 error:&regexError];
87 XCTAssertNil(regexError);
88
89 // Smoke test the test regex.
90 NSString* testString = @"9";
91 NSUInteger versionMatches =
92 [osVersionRegex numberOfMatchesInString:testString
93 options:NSMatchingAnchored
94 range:NSMakeRange(0, testString.length)];
95 XCTAssertEqual(versionMatches, 1UL);
96 testString = @"9.1";
97 versionMatches = [osVersionRegex numberOfMatchesInString:testString
98 options:NSMatchingAnchored
99 range:NSMakeRange(0, testString.length)];
100 XCTAssertEqual(versionMatches, 1UL);
101 testString = @"9.0.1";
102 versionMatches = [osVersionRegex numberOfMatchesInString:testString
103 options:NSMatchingAnchored
104 range:NSMakeRange(0, testString.length)];
105 XCTAssertEqual(versionMatches, 1UL);
106 testString = @".0.1";
107 versionMatches = [osVersionRegex numberOfMatchesInString:testString
108 options:NSMatchingAnchored
109 range:NSMakeRange(0, testString.length)];
110 XCTAssertEqual(versionMatches, 0UL);
111
112 // Test Info.plist values.
113 NSString* minimumOSVersion = infoDictionary[@"MinimumOSVersion"];
114 versionMatches = [osVersionRegex numberOfMatchesInString:minimumOSVersion
115 options:NSMatchingAnchored
116 range:NSMakeRange(0, minimumOSVersion.length)];
117 XCTAssertEqual(versionMatches, 1UL);
118
119 // SHA length is 40.
120 XCTAssertEqual(((NSString*)infoDictionary[@"FlutterEngine"]).length, 40UL);
121
122 // {clang_version} placeholder is 15 characters. The clang string version
123 // is longer than that, so check if the placeholder has been replaced, without
124 // actually checking a literal string, which could be different on various machines.
125 XCTAssertTrue(((NSString*)infoDictionary[@"ClangVersion"]).length > 15UL);
126}
size_t length

◆ testInitialRouteSettingsSendsNavigationMessage

- (void) testInitialRouteSettingsSendsNavigationMessage
implementation

Definition at line 44 of file FlutterEngineTest.mm.

214 {
215 id mockBinaryMessenger = OCMClassMock([FlutterBinaryMessengerRelay class]);
216
218 settings.route = "test";
219 FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings];
220 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
221 [engine setBinaryMessenger:mockBinaryMessenger];
222 [engine run];
223
224 // Now check that an encoded method call has been made on the binary messenger to set the
225 // initial route to "test".
226 FlutterMethodCall* setInitialRouteMethodCall =
227 [FlutterMethodCall methodCallWithMethodName:@"setInitialRoute" arguments:@"test"];
228 NSData* encodedSetInitialRouteMethod =
229 [[FlutterJSONMethodCodec sharedInstance] encodeMethodCall:setInitialRouteMethodCall];
230 OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/navigation"
231 message:encodedSetInitialRouteMethod]);
232}

◆ testIsolateId

- (void) testIsolateId
implementation

Definition at line 15 of file FlutterEngineTest.m.

17 {
18 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil];
19 XCTAssertNil(engine.isolateId);
20 [self keyValueObservingExpectationForObject:engine keyPath:@"isolateId" handler:nil];
21
22 XCTAssertTrue([engine runWithEntrypoint:nil]);
23
24 [self waitForExpectationsWithTimeout:30.0 handler:nil];
25
26 XCTAssertNotNil(engine.isolateId);
27 XCTAssertTrue([engine.isolateId hasPrefix:@"isolates/"]);
28
29 [engine destroyContext];
30
31 XCTAssertNil(engine.isolateId);
32}
NSString * isolateId

◆ testLifeCycleNotificationDidEnterBackground

- (void) testLifeCycleNotificationDidEnterBackground
implementation

Definition at line 44 of file FlutterEngineTest.mm.

389 {
390 FlutterDartProject* project = [[FlutterDartProject alloc] init];
391 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
392 [engine run];
393 NSNotification* sceneNotification =
394 [NSNotification notificationWithName:UISceneDidEnterBackgroundNotification
395 object:nil
396 userInfo:nil];
397 NSNotification* applicationNotification =
398 [NSNotification notificationWithName:UIApplicationDidEnterBackgroundNotification
399 object:nil
400 userInfo:nil];
401 id mockEngine = OCMPartialMock(engine);
402 [[NSNotificationCenter defaultCenter] postNotification:sceneNotification];
403 [[NSNotificationCenter defaultCenter] postNotification:applicationNotification];
404#if APPLICATION_EXTENSION_API_ONLY
405 OCMVerify(times(1), [mockEngine sceneDidEnterBackground:[OCMArg any]]);
406#else
407 OCMVerify(times(1), [mockEngine applicationDidEnterBackground:[OCMArg any]]);
408#endif
409 XCTAssertTrue(engine.isGpuDisabled);
410 bool switch_value = false;
411 [engine shell].GetIsGpuDisabledSyncSwitch()->Execute(
412 fml::SyncSwitch::Handlers().SetIfTrue([&] { switch_value = true; }).SetIfFalse([&] {
413 switch_value = false;
414 }));
415 XCTAssertTrue(switch_value);
416}
flutter::Shell & shell()
SIT bool any(const Vec< 1, T > &x)
Definition SkVx.h:530
Represents the 2 code paths available when calling |SyncSwitchExecute|.
Definition sync_switch.h:35

◆ testLifeCycleNotificationWillEnterForeground

- (void) testLifeCycleNotificationWillEnterForeground
implementation

Definition at line 44 of file FlutterEngineTest.mm.

418 {
419 FlutterDartProject* project = [[FlutterDartProject alloc] init];
420 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
421 [engine run];
422 NSNotification* sceneNotification =
423 [NSNotification notificationWithName:UISceneWillEnterForegroundNotification
424 object:nil
425 userInfo:nil];
426 NSNotification* applicationNotification =
427 [NSNotification notificationWithName:UIApplicationWillEnterForegroundNotification
428 object:nil
429 userInfo:nil];
430 id mockEngine = OCMPartialMock(engine);
431 [[NSNotificationCenter defaultCenter] postNotification:sceneNotification];
432 [[NSNotificationCenter defaultCenter] postNotification:applicationNotification];
433#if APPLICATION_EXTENSION_API_ONLY
434 OCMVerify(times(1), [mockEngine sceneWillEnterForeground:[OCMArg any]]);
435#else
436 OCMVerify(times(1), [mockEngine applicationWillEnterForeground:[OCMArg any]]);
437#endif
438 XCTAssertFalse(engine.isGpuDisabled);
439 bool switch_value = true;
440 [engine shell].GetIsGpuDisabledSyncSwitch()->Execute(
441 fml::SyncSwitch::Handlers().SetIfTrue([&] { switch_value = true; }).SetIfFalse([&] {
442 switch_value = false;
443 }));
444 XCTAssertFalse(switch_value);
445}

◆ testNilSetMessageHandlerBeforeRun

- (void) testNilSetMessageHandlerBeforeRun
implementation

Definition at line 44 of file FlutterEngineTest.mm.

160 {
161 FlutterDartProject* project = [[FlutterDartProject alloc] init];
162 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
163 XCTAssertNotNil(engine);
164 XCTAssertNoThrow([engine.binaryMessenger setMessageHandlerOnChannel:@"foo"
165 binaryMessageHandler:nil]);
166}
NSObject< FlutterBinaryMessenger > * binaryMessenger

◆ testNotifyPluginOfDealloc

- (void) testNotifyPluginOfDealloc
implementation

Definition at line 44 of file FlutterEngineTest.mm.

168 {
169 id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
170 OCMStub([plugin detachFromEngineForRegistrar:[OCMArg any]]);
171 {
172 FlutterDartProject* project = [[FlutterDartProject alloc] init];
173 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"engine" project:project];
174 NSObject<FlutterPluginRegistrar>* registrar = [engine registrarForPlugin:@"plugin"];
175 [registrar publish:plugin];
176 engine = nil;
177 }
178 OCMVerify([plugin detachFromEngineForRegistrar:[OCMArg any]]);
179}
NSObject< FlutterPluginRegistrar > * registrarForPlugin:(NSString *pluginKey)

◆ testPlatformViewsControllerRenderingMetalBackend

- (void) testPlatformViewsControllerRenderingMetalBackend
implementation

Definition at line 44 of file FlutterEngineTest.mm.

234 {
235 FlutterEngine* engine = [[FlutterEngine alloc] init];
236 [engine run];
238
239 XCTAssertEqual(renderingApi, flutter::IOSRenderingAPI::kMetal);
240}
flutter::IOSRenderingAPI platformViewsRenderingAPI()

◆ testPlatformViewsControllerRenderingSoftware

- (void) testPlatformViewsControllerRenderingSoftware
implementation

Definition at line 44 of file FlutterEngineTest.mm.

242 {
244 settings.enable_software_rendering = true;
245 FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings];
246 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
247 [engine run];
249
250 XCTAssertEqual(renderingApi, flutter::IOSRenderingAPI::kSoftware);
251}

◆ testReleaseViewControllerAfterDestroyContextInHeadlessMode

- (void) testReleaseViewControllerAfterDestroyContextInHeadlessMode
implementation

Definition at line 15 of file FlutterEngineTest.m.

54 {
55 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
56 project:nil
57 allowHeadlessExecution:YES];
58 XCTAssertNil(engine.navigationChannel);
59 XCTAssertNil(engine.platformChannel);
60 XCTAssertNil(engine.lifecycleChannel);
61
62 XCTAssertTrue([engine run]);
63
64 XCTAssertNotNil(engine.navigationChannel);
65 XCTAssertNotNil(engine.platformChannel);
66 XCTAssertNotNil(engine.lifecycleChannel);
67 XCTestExpectation* expectation =
68 [[XCTestExpectation alloc] initWithDescription:@"notification called"];
69 @autoreleasepool {
70 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
71 nibName:nil
72 bundle:nil];
73 [engine setViewController:viewController];
74 [engine destroyContext];
75 [[NSNotificationCenter defaultCenter] addObserverForName:FlutterViewControllerWillDealloc
76 object:nil
77 queue:[NSOperationQueue mainQueue]
78 usingBlock:^(NSNotification* _Nonnull note) {
79 [expectation fulfill];
80 }];
81 viewController = nil;
82 }
83 [self waitForExpectations:@[ expectation ] timeout:30.0];
84 XCTAssertNil(engine.navigationChannel);
85 XCTAssertNil(engine.platformChannel);
86 XCTAssertNil(engine.lifecycleChannel);
87}
void setViewController:(FlutterViewController *viewController)
FlutterViewController * viewController

◆ testRunningInitialRouteSendsNavigationMessage

- (void) testRunningInitialRouteSendsNavigationMessage
implementation

Definition at line 44 of file FlutterEngineTest.mm.

195 {
196 id mockBinaryMessenger = OCMClassMock([FlutterBinaryMessengerRelay class]);
197
198 FlutterEngine* engine = [[FlutterEngine alloc] init];
199 [engine setBinaryMessenger:mockBinaryMessenger];
200
201 // Run with an initial route.
202 [engine runWithEntrypoint:FlutterDefaultDartEntrypoint initialRoute:@"test"];
203
204 // Now check that an encoded method call has been made on the binary messenger to set the
205 // initial route to "test".
206 FlutterMethodCall* setInitialRouteMethodCall =
207 [FlutterMethodCall methodCallWithMethodName:@"setInitialRoute" arguments:@"test"];
208 NSData* encodedSetInitialRouteMethod =
209 [[FlutterJSONMethodCodec sharedInstance] encodeMethodCall:setInitialRouteMethodCall];
210 OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/navigation"
211 message:encodedSetInitialRouteMethod]);
212}

◆ testSendMessageBeforeRun

- (void) testSendMessageBeforeRun
implementation

Definition at line 44 of file FlutterEngineTest.mm.

139 {
140 FlutterDartProject* project = [[FlutterDartProject alloc] init];
141 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
142 XCTAssertNotNil(engine);
143 XCTAssertThrows([engine.binaryMessenger
144 sendOnChannel:@"foo"
145 message:[@"bar" dataUsingEncoding:NSUTF8StringEncoding]
146 binaryReply:nil]);
147}

◆ testSetBinaryMessengerToSameBinaryMessenger

- (void) testSetBinaryMessengerToSameBinaryMessenger
implementation

Definition at line 44 of file FlutterEngineTest.mm.

181 {
182 FakeBinaryMessengerRelay* fakeBinaryMessenger = [[FakeBinaryMessengerRelay alloc] init];
183
184 FlutterEngine* engine = [[FlutterEngine alloc] init];
185 [engine setBinaryMessenger:fakeBinaryMessenger];
186
187 // Verify that the setter doesn't free the old messenger before setting the new messenger.
188 fakeBinaryMessenger.failOnDealloc = YES;
189 [engine setBinaryMessenger:fakeBinaryMessenger];
190
191 // Don't fail when ARC releases the binary messenger.
192 fakeBinaryMessenger.failOnDealloc = NO;
193}

◆ testSetHandlerAfterRun

- (void) testSetHandlerAfterRun
implementation

Definition at line 44 of file FlutterEngineTest.mm.

293 {
294 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
295 XCTestExpectation* gotMessage = [self expectationWithDescription:@"gotMessage"];
296 dispatch_async(dispatch_get_main_queue(), ^{
297 NSObject<FlutterPluginRegistrar>* registrar = [engine registrarForPlugin:@"foo"];
299 [engine run];
301 engine.shell.GetTaskRunners().GetUITaskRunner()->PostTask([&latch, &shell] {
303 auto message = std::make_unique<flutter::PlatformMessage>("foo", nullptr);
304 delegate.OnEngineHandlePlatformMessage(std::move(message));
305 latch.Signal();
306 });
307 latch.Wait();
308 [registrar.messenger setMessageHandlerOnChannel:@"foo"
309 binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) {
310 [gotMessage fulfill];
311 }];
312 });
313 [self waitForExpectationsWithTimeout:1 handler:nil];
314}
While the engine operates entirely on the UI task runner, it needs the capabilities of the other comp...
Definition engine.h:140
virtual void OnEngineHandlePlatformMessage(std::unique_ptr< PlatformMessage > message)=0
When the Flutter application has a message to send to the underlying platform, the message needs to b...
const TaskRunners & GetTaskRunners() const override
If callers wish to interact directly with any shell subcomponents, they must (on the platform thread)...
Definition shell.cc:799

◆ testSetMessageHandlerBeforeRun

- (void) testSetMessageHandlerBeforeRun
implementation

Definition at line 44 of file FlutterEngineTest.mm.

149 {
150 FlutterDartProject* project = [[FlutterDartProject alloc] init];
151 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
152 XCTAssertNotNil(engine);
153 XCTAssertThrows([engine.binaryMessenger
154 setMessageHandlerOnChannel:@"foo"
155 binaryMessageHandler:^(NSData* _Nullable message, FlutterBinaryReply _Nonnull reply){
156
157 }]);
158}
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)

◆ testSpawn

- (void) testSpawn
implementation

Definition at line 44 of file FlutterEngineTest.mm.

266 {
267 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
268 [engine run];
270 libraryURI:nil
271 initialRoute:nil
272 entrypointArgs:nil];
273 XCTAssertNotNil(spawn);
274}
FlutterEngine * spawnWithEntrypoint:libraryURI:initialRoute:entrypointArgs:(/*nullable */NSString *entrypoint, [libraryURI]/*nullable */NSString *libraryURI, [initialRoute]/*nullable */NSString *initialRoute, [entrypointArgs]/*nullable */NSArray< NSString * > *entrypointArgs)

◆ testSpawnsShareGpuContext

- (void) testSpawnsShareGpuContext
implementation

Definition at line 44 of file FlutterEngineTest.mm.

447 {
448 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
449 [engine run];
451 libraryURI:nil
452 initialRoute:nil
453 entrypointArgs:nil];
454 XCTAssertNotNil(spawn);
455 XCTAssertTrue([engine iosPlatformView] != nullptr);
456 XCTAssertTrue([spawn iosPlatformView] != nullptr);
457 std::shared_ptr<flutter::IOSContext> engine_context = [engine iosPlatformView]->GetIosContext();
458 std::shared_ptr<flutter::IOSContext> spawn_context = [spawn iosPlatformView]->GetIosContext();
459 XCTAssertEqual(engine_context, spawn_context);
460 // If this assert fails it means we may be using the software. For software rendering, this is
461 // expected to be nullptr.
462 XCTAssertTrue(engine_context->GetMainContext() != nullptr);
463 XCTAssertEqual(engine_context->GetMainContext(), spawn_context->GetMainContext());
464}
flutter::PlatformViewIOS * iosPlatformView()

◆ testThreadPrioritySetCorrectly

- (void) testThreadPrioritySetCorrectly
implementation

Definition at line 44 of file FlutterEngineTest.mm.

316 {
317 XCTestExpectation* prioritiesSet = [self expectationWithDescription:@"prioritiesSet"];
318 prioritiesSet.expectedFulfillmentCount = 3;
319
320 IMP mockSetThreadPriority =
321 imp_implementationWithBlock(^(NSThread* thread, double threadPriority) {
322 if ([thread.name hasSuffix:@".ui"]) {
323 XCTAssertEqual(threadPriority, 1.0);
324 [prioritiesSet fulfill];
325 } else if ([thread.name hasSuffix:@".raster"]) {
326 XCTAssertEqual(threadPriority, 1.0);
327 [prioritiesSet fulfill];
328 } else if ([thread.name hasSuffix:@".io"]) {
329 XCTAssertEqual(threadPriority, 0.5);
330 [prioritiesSet fulfill];
331 }
332 });
333 Method method = class_getInstanceMethod([NSThread class], @selector(setThreadPriority:));
334 IMP originalSetThreadPriority = method_getImplementation(method);
335 method_setImplementation(method, mockSetThreadPriority);
336
337 FlutterEngine* engine = [[FlutterEngine alloc] init];
338 [engine run];
339 [self waitForExpectationsWithTimeout:1 handler:nil];
340
341 method_setImplementation(method, originalSetThreadPriority);
342}

◆ testWaitForFirstFrameTimeout

- (void) testWaitForFirstFrameTimeout
implementation

Definition at line 44 of file FlutterEngineTest.mm.

253 {
254 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
255 [engine run];
256 XCTestExpectation* timeoutFirstFrame = [self expectationWithDescription:@"timeoutFirstFrame"];
257 [engine waitForFirstFrame:0.1
258 callback:^(BOOL didTimeout) {
259 if (timeoutFirstFrame) {
260 [timeoutFirstFrame fulfill];
261 }
262 }];
263 [self waitForExpectationsWithTimeout:5 handler:nil];
264}
void waitForFirstFrame:callback:(NSTimeInterval timeout, [callback] void(^_Nonnull callback)(BOOL didTimeout))

The documentation for this class was generated from the following files: