Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FlutterEngineGroupTest.mm
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 <OCMock/OCMock.h>
6#import <XCTest/XCTest.h>
7
8#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h"
9#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h"
10
12
13@interface FlutterEngineGroup ()
15@end
16
17@interface FlutterEngineGroupTest : XCTestCase
18@end
19
20@implementation FlutterEngineGroupTest
21
22- (void)testMake {
23 FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil];
25 XCTAssertNotNil(engine);
26}
27
28- (void)testSpawn {
29 FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil];
30 FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil];
31 spawner.isGpuDisabled = YES;
32 FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil];
33 XCTAssertNotNil(spawner);
34 XCTAssertNotNil(spawnee);
35 XCTAssertEqual(&spawner.threadHost, &spawnee.threadHost);
36 XCTAssertEqual(spawner.isGpuDisabled, spawnee.isGpuDisabled);
37}
38
40 FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil];
41 @autoreleasepool {
42 FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil];
43 XCTAssertNotNil(spawner);
44 }
45 FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil];
46 XCTAssertNotNil(spawnee);
47}
48
50 FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo"
51 project:nil]);
52 FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]);
53 OCMStub([group makeEngine]).andReturn(mockEngine);
54 OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any]
55 libraryURI:[OCMArg any]
56 initialRoute:[OCMArg any]
57 entrypointArgs:[OCMArg any]])
58 .andReturn(OCMClassMock([FlutterEngine class]));
59 FlutterEngine* spawner = [group makeEngineWithEntrypoint:@"firstEntrypoint"
60 libraryURI:@"firstLibraryURI"];
61 XCTAssertNotNil(spawner);
62 OCMVerify([spawner runWithEntrypoint:@"firstEntrypoint"
63 libraryURI:@"firstLibraryURI"
64 initialRoute:nil
65 entrypointArgs:nil]);
66
67 FlutterEngine* spawnee = [group makeEngineWithEntrypoint:@"secondEntrypoint"
68 libraryURI:@"secondLibraryURI"];
69 XCTAssertNotNil(spawnee);
70 OCMVerify([spawner spawnWithEntrypoint:@"secondEntrypoint"
71 libraryURI:@"secondLibraryURI"
72 initialRoute:nil
73 entrypointArgs:nil]);
74}
75
77 FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo"
78 project:nil]);
79 FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]);
80 OCMStub([group makeEngine]).andReturn(mockEngine);
81 OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any]
82 libraryURI:[OCMArg any]
83 initialRoute:[OCMArg any]
84 entrypointArgs:[OCMArg any]])
85 .andReturn(OCMClassMock([FlutterEngine class]));
86 FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"foo"];
87 XCTAssertNotNil(spawner);
88 OCMVerify([spawner runWithEntrypoint:nil libraryURI:nil initialRoute:@"foo" entrypointArgs:nil]);
89
90 FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"bar"];
91 XCTAssertNotNil(spawnee);
92 OCMVerify([spawner spawnWithEntrypoint:nil
93 libraryURI:nil
94 initialRoute:@"bar"
95 entrypointArgs:nil]);
96}
97
99 FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo"
100 project:nil]);
101 FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]);
102 OCMStub([group makeEngine]).andReturn(mockEngine);
103 OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any]
104 libraryURI:[OCMArg any]
105 initialRoute:[OCMArg any]
106 entrypointArgs:[OCMArg any]])
107 .andReturn(OCMClassMock([FlutterEngine class]));
108 FlutterEngineGroupOptions* firstOptions = [[FlutterEngineGroupOptions alloc] init];
109 NSArray* firstEntrypointArgs = @[ @"foo", @"first" ];
110 firstOptions.entrypointArgs = firstEntrypointArgs;
111 FlutterEngine* spawner = [group makeEngineWithOptions:firstOptions];
112 XCTAssertNotNil(spawner);
113 OCMVerify([spawner runWithEntrypoint:nil
114 libraryURI:nil
115 initialRoute:nil
116 entrypointArgs:firstEntrypointArgs]);
117
118 NSArray* secondEntrypointArgs = @[ @"bar", @"second" ];
119 FlutterEngineGroupOptions* secondOptions = [[FlutterEngineGroupOptions alloc] init];
120 secondOptions.entrypointArgs = secondEntrypointArgs;
121 FlutterEngine* spawnee = [group makeEngineWithOptions:secondOptions];
122 XCTAssertNotNil(spawnee);
123 OCMVerify([spawner spawnWithEntrypoint:nil
124 libraryURI:nil
125 initialRoute:nil
126 entrypointArgs:secondEntrypointArgs]);
127}
128
130 __weak FlutterDartProject* weakProject;
131 @autoreleasepool {
132 FlutterDartProject* mockProject = OCMClassMock([FlutterDartProject class]);
133 FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo"
134 project:mockProject];
135 XCTAssertNotNil(group);
136 weakProject = mockProject;
137 XCTAssertNotNil(weakProject);
138 group = nil;
139 mockProject = nil;
140 }
141 XCTAssertNil(weakProject);
142}
143
144@end
FlutterEngine engine
Definition main.cc:68
NSArray< NSString * > * entrypointArgs
FlutterEngine * makeEngine()
FlutterEngine * makeEngineWithEntrypoint:libraryURI:initialRoute:(nullable NSString *entrypoint,[libraryURI] nullable NSString *libraryURI,[initialRoute] nullable NSString *initialRoute)
FlutterEngine * makeEngineWithEntrypoint:libraryURI:(nullable NSString *entrypoint,[libraryURI] nullable NSString *libraryURI)
FlutterEngine * makeEngineWithOptions:(nullable FlutterEngineGroupOptions *options)
const flutter::ThreadHost & threadHost()