Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
15
16@interface FlutterTextureRegistryRelayTest : XCTestCase
17@end
18
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
39 id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry));
41 [[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry];
42 [relay textureFrameAvailable:0];
43 OCMVerify([textureRegistry textureFrameAvailable:0]);
44}
45
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
FlutterEngine engine
Definition main.cc:68
NSObject< FlutterTextureRegistry > * textureRegistry
NSObject< FlutterTextureRegistry > * parent
int64_t registerTexture:(NSObject< FlutterTexture > *texture)
FlTexture * texture