Flutter iOS Embedder
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 
7 
8 #import <OCMock/OCMock.h>
9 #import <XCTest/XCTest.h>
10 
13 
15 
16 @interface FlutterTextureRegistryRelayTest : XCTestCase
17 @end
18 
19 @implementation FlutterTextureRegistryRelayTest
20 
21 - (void)testCreate {
22  id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry));
24  [[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry];
25  XCTAssertNotNil(relay);
26  XCTAssertEqual(textureRegistry, relay.parent);
27 }
28 
29 - (void)testRegisterTexture {
30  id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry));
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));
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));
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
NSObject< FlutterTextureRegistry > * textureRegistry
NSObject< FlutterTextureRegistry > * parent
int64_t registerTexture:(NSObject< FlutterTexture > *texture)
void textureFrameAvailable:(int64_t textureId)
void unregisterTexture:(int64_t textureId)