blob: 7b9e9fda53058dd7ad2929dc8096652226c8f143 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "MockBinaryMessenger.h"
@implementation MockBinaryMessenger
- (instancetype)initWithCodec:(NSObject<FlutterMessageCodec> *)codec {
self = [super init];
if (self) {
_codec = codec;
_handlers = [[NSMutableDictionary alloc] init];
}
return self;
}
- (void)cleanupConnection:(FlutterBinaryMessengerConnection)connection {
}
- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData *_Nullable)message {
}
- (void)sendOnChannel:(nonnull NSString *)channel
message:(NSData *_Nullable)message
binaryReply:(FlutterBinaryReply _Nullable)callback {
if (self.result) {
callback([_codec encode:self.result]);
}
}
- (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(nonnull NSString *)channel
binaryMessageHandler:
(FlutterBinaryMessageHandler _Nullable)handler {
_handlers[channel] = [handler copy];
return _handlers.count;
}
- (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection {
}
@end