Flutter Engine
FlutterEngineTest.m
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #import <Flutter/Flutter.h>
6 #import <XCTest/XCTest.h>
7 
8 #import "AppDelegate.h"
9 
10 @interface FlutterEngineTest : XCTestCase
11 @end
12 
13 @implementation FlutterEngineTest
14 
15 - (void)testIsolateId {
16  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil];
17  XCTAssertNil(engine.isolateId);
18  [self keyValueObservingExpectationForObject:engine keyPath:@"isolateId" handler:nil];
19 
20  XCTAssertTrue([engine runWithEntrypoint:nil]);
21 
22  [self waitForExpectationsWithTimeout:30.0 handler:nil];
23 
24  XCTAssertNotNil(engine.isolateId);
25  XCTAssertTrue([engine.isolateId hasPrefix:@"isolates/"]);
26 
27  [engine destroyContext];
28 
29  XCTAssertNil(engine.isolateId);
30 }
31 
32 - (void)testChannelSetup {
33  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil];
34  XCTAssertNil(engine.navigationChannel);
35  XCTAssertNil(engine.platformChannel);
36  XCTAssertNil(engine.lifecycleChannel);
37 
38  XCTAssertTrue([engine run]);
39 
40  XCTAssertNotNil(engine.navigationChannel);
41  XCTAssertNotNil(engine.platformChannel);
42  XCTAssertNotNil(engine.lifecycleChannel);
43 
44  [engine destroyContext];
45 
46  XCTAssertNil(engine.navigationChannel);
47  XCTAssertNil(engine.platformChannel);
48  XCTAssertNil(engine.lifecycleChannel);
49 }
50 
51 @end
NSString * isolateId
FlutterMethodChannel * navigationChannel
FlutterMethodChannel * platformChannel
FlutterBasicMessageChannel * lifecycleChannel