Flutter Engine
FlutterBinaryMessengerRelayTest.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/Source/FlutterBinaryMessengerRelay.h"
6 
7 #import <OCMock/OCMock.h>
8 #import <XCTest/XCTest.h>
9 
10 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
11 
13 
14 @interface FlutterBinaryMessengerRelayTest : XCTestCase
15 @end
16 
17 @implementation FlutterBinaryMessengerRelayTest
18 
19 - (void)setUp {
20 }
21 
22 - (void)tearDown {
23 }
24 
25 - (void)testCreate {
26  id messenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
28  [[FlutterBinaryMessengerRelay alloc] initWithParent:messenger];
29  XCTAssertNotNil(relay);
30  XCTAssertEqual(messenger, relay.parent);
31 }
32 
33 - (void)testPassesCallOn {
34  id messenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
36  [[FlutterBinaryMessengerRelay alloc] initWithParent:messenger];
37  char messageData[] = {'a', 'a', 'r', 'o', 'n'};
38  NSData* message = [NSData dataWithBytes:messageData length:sizeof(messageData)];
39  NSString* channel = @"foobar";
40  [relay sendOnChannel:channel message:message binaryReply:nil];
41  OCMVerify([messenger sendOnChannel:channel message:message binaryReply:nil]);
42 }
43 
44 - (void)testDoesntPassCallOn {
45  id messenger = OCMStrictProtocolMock(@protocol(FlutterBinaryMessenger));
47  [[FlutterBinaryMessengerRelay alloc] initWithParent:messenger];
48  char messageData[] = {'a', 'a', 'r', 'o', 'n'};
49  NSData* message = [NSData dataWithBytes:messageData length:sizeof(messageData)];
50  NSString* channel = @"foobar";
51  relay.parent = nil;
52  [relay sendOnChannel:channel message:message binaryReply:nil];
53 }
54 
55 @end
NSObject< FlutterBinaryMessenger > * parent
#define FLUTTER_ASSERT_ARC
Definition: FlutterMacros.h:44