| Flutter iOS Embedder |

FlutterTextureRegistryRelayTest.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 "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h"
6 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.h"
7
8 #import <OCMock/OCMock.h>
9 #import <XCTest/XCTest.h>
10
11 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
12 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h"
13
14 FLUTTER_ASSERT_ARC
15
16 @interface FlutterTextureRegistryRelayTest : XCTestCase
17 @end
18
19 @implementation FlutterTextureRegistryRelayTest
20
21 - (void)testCreate {
22 id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry));
23 FlutterTextureRegistryRelay* relay =
24 [[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry];
25 XCTAssertNotNil(relay);
26 XCTAssertEqual(textureRegistry, relay.parent);
27 }
28
29 - (void)testRegisterTexture {
30 id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry));
31 FlutterTextureRegistryRelay* relay =
32 [[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry];
33 id texture = OCMProtocolMock(@protocol(FlutterTexture));
34 [relay registerTexture:texture];
35 OCMVerify([textureRegistry registerTexture:texture]);
36 }
37
38 - (void)testTextureFrameAvailable {
39 id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry));
40 FlutterTextureRegistryRelay* relay =
41 [[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry];
42 [relay textureFrameAvailable:0];
43 OCMVerify([textureRegistry textureFrameAvailable:0]);
44 }
45
46 - (void)testUnregisterTexture {
47 id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry));
48 FlutterTextureRegistryRelay* relay =
49 [[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry];
50 [relay unregisterTexture:0];
51 OCMVerify([textureRegistry unregisterTexture:0]);
52 }
53
54 - (void)testRetainCycle {
55 __weak FlutterEngine* weakEngine;
56 NSObject<FlutterTextureRegistry>* strongRelay;
57 @autoreleasepool {
58 FlutterDartProject* project = [[FlutterDartProject alloc] init];
59 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
60 strongRelay = [engine textureRegistry];
61 weakEngine = engine;
62 }
63 XCTAssertNil(weakEngine);
64 XCTAssertNotNil(strongRelay);
65 }
66
67 @end
FlutterTextureRegistryRelay::parent
NSObject< FlutterTextureRegistry > * parent
Definition: FlutterTextureRegistryRelay.h:25
-[FlutterTextureRegistry-p registerTexture:]
int64_t registerTexture:(NSObject< FlutterTexture > *texture)
FlutterTextureRegistryRelayTest
Definition: FlutterTextureRegistryRelayTest.mm:16
FlutterEngine
Definition: FlutterEngine.h:61
FlutterEngine.h
FlutterTextureRegistry-p
Definition: FlutterTexture.h:45
FlutterTexture.h
FlutterMacros.h
FlutterEngine::textureRegistry
NSObject< FlutterTextureRegistry > * textureRegistry
Definition: FlutterEngine.h:442
-[FlutterTextureRegistry-p unregisterTexture:]
void unregisterTexture:(int64_t textureId)
FlutterTextureRegistryRelay
Definition: FlutterTextureRegistryRelay.h:20
FlutterTexture
Definition: FlutterMetalLayer.mm:58
engine
id engine
Definition: FlutterTextInputPluginTest.mm:89
FlutterDartProject
Definition: FlutterDartProject.mm:262
FlutterTextureRegistryRelay.h
-[FlutterTextureRegistry-p textureFrameAvailable:]
void textureFrameAvailable:(int64_t textureId)
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13