| Flutter iOS Embedder |

FlutterEngineTest_mrc.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/common/framework/Headers/FlutterMacros.h"
9 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
10 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h"
11 #import "flutter/shell/platform/darwin/ios/platform_view_ios.h"
12
13 FLUTTER_ASSERT_NOT_ARC
14
15 @interface FlutterEngineSpy : FlutterEngine
16 @property(nonatomic) BOOL ensureSemanticsEnabledCalled;
17 @end
18
19 @implementation FlutterEngineSpy
20
21 - (void)ensureSemanticsEnabled {
22 _ensureSemanticsEnabledCalled = YES;
23 }
24
25 @end
26
27 @interface FlutterEngineTest_mrc : XCTestCase
28 @end
29
30 @implementation FlutterEngineTest_mrc
31
32 - (void)setUp {
33 }
34
35 - (void)tearDown {
36 }
37
38 - (void)testSpawnsShareGpuContext {
39 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
40 [engine run];
41 FlutterEngine* spawn = [engine spawnWithEntrypoint:nil
42 libraryURI:nil
43 initialRoute:nil
44 entrypointArgs:nil];
45 XCTAssertNotNil(spawn);
46 XCTAssertTrue([engine iosPlatformView] != nullptr);
47 XCTAssertTrue([spawn iosPlatformView] != nullptr);
48 std::shared_ptr<flutter::IOSContext> engine_context = [engine iosPlatformView]->GetIosContext();
49 std::shared_ptr<flutter::IOSContext> spawn_context = [spawn iosPlatformView]->GetIosContext();
50 XCTAssertEqual(engine_context, spawn_context);
51 // If this assert fails it means we may be using the software. For software rendering, this is
52 // expected to be nullptr.
53 XCTAssertTrue(engine_context->GetMainContext() != nullptr);
54 XCTAssertEqual(engine_context->GetMainContext(), spawn_context->GetMainContext());
55 [engine release];
56 }
57
58 - (void)testEnableSemanticsWhenFlutterViewAccessibilityDidCall {
59 FlutterEngineSpy* engine = [[FlutterEngineSpy alloc] initWithName:@"foobar"];
60 engine.ensureSemanticsEnabledCalled = NO;
61 [engine flutterViewAccessibilityDidCall];
62 XCTAssertTrue(engine.ensureSemanticsEnabledCalled);
63 [engine release];
64 }
65
66 @end
FlutterEngine
Definition: FlutterEngine.h:59
FLUTTER_ASSERT_NOT_ARC
Definition: VsyncWaiterIosTest.mm:15
FlutterEngineSpy::ensureSemanticsEnabledCalled
BOOL ensureSemanticsEnabledCalled
Definition: FlutterEngineTest_mrc.mm:16
FlutterEngine_Test.h
-[FlutterEngine ensureSemanticsEnabled]
void ensureSemanticsEnabled()
Definition: FlutterEngine.mm:420
FlutterEngineTest_mrc
Definition: FlutterEngineTest_mrc.mm:27
FlutterEngine_Internal.h
FlutterEngineSpy
Definition: FlutterEngineTest_mrc.mm:15
FlutterMacros.h
engine
id engine
Definition: FlutterTextInputPluginTest.mm:89
platform_view_ios.h
-[FlutterEngine spawnWithEntrypoint:libraryURI:initialRoute:entrypointArgs:]
FlutterEngine * spawnWithEntrypoint:libraryURI:initialRoute:entrypointArgs:(/*nullable */NSString *entrypoint,[libraryURI]/*nullable */NSString *libraryURI,[initialRoute]/*nullable */NSString *initialRoute,[entrypointArgs]/*nullable */NSArray< NSString * > *entrypointArgs)
-[FlutterEngine run]
BOOL run()
Definition: FlutterEngine.mm:938