Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
flutter::TestBinaryMessenger Class Reference

#include <test_binary_messenger.h>

Inheritance diagram for flutter::TestBinaryMessenger:
flutter::BinaryMessenger flutter::BinaryMessenger flutter::BinaryMessenger flutter::BinaryMessenger

Public Types

using SendHandler = std::function< void(const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply)>
 

Public Member Functions

 TestBinaryMessenger (SendHandler send_handler=nullptr)
 
virtual ~TestBinaryMessenger ()=default
 
bool SimulateEngineMessage (const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply)
 
void Send (const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply) const override
 
void SetMessageHandler (const std::string &channel, BinaryMessageHandler handler) override
 
- Public Member Functions inherited from flutter::BinaryMessenger
virtual ~BinaryMessenger ()=default
 
virtual void Send (const std::string &channel, const uint8_t *message, size_t message_size, BinaryReply reply=nullptr) const =0
 
virtual void SetMessageHandler (const std::string &channel, BinaryMessageHandler handler)=0
 

Detailed Description

Definition at line 19 of file test_binary_messenger.h.

Member Typedef Documentation

◆ SendHandler

using flutter::TestBinaryMessenger::SendHandler = std::function<void(const std::string& channel, const uint8_t* message, size_t message_size, BinaryReply reply)>

Definition at line 21 of file test_binary_messenger.h.

Constructor & Destructor Documentation

◆ TestBinaryMessenger()

flutter::TestBinaryMessenger::TestBinaryMessenger ( SendHandler  send_handler = nullptr)
inlineexplicit

Definition at line 27 of file test_binary_messenger.h.

28 : send_handler_(std::move(send_handler)) {}

◆ ~TestBinaryMessenger()

virtual flutter::TestBinaryMessenger::~TestBinaryMessenger ( )
virtualdefault

Member Function Documentation

◆ Send()

void flutter::TestBinaryMessenger::Send ( const std::string &  channel,
const uint8_t *  message,
size_t  message_size,
BinaryReply  reply 
) const
inlineoverridevirtual

Implements flutter::BinaryMessenger.

Definition at line 48 of file test_binary_messenger.h.

51 {
52 // If something under test sends a message, the test should be handling it.
53 FML_DCHECK(send_handler_);
54 send_handler_(channel, message, message_size, reply);
55 }
#define FML_DCHECK(condition)
Definition: logging.h:103
Win32Message message

◆ SetMessageHandler()

void flutter::TestBinaryMessenger::SetMessageHandler ( const std::string &  channel,
BinaryMessageHandler  handler 
)
inlineoverridevirtual

Implements flutter::BinaryMessenger.

Definition at line 58 of file test_binary_messenger.h.

59 {
60 if (handler) {
61 registered_handlers_[channel] = handler;
62 } else {
63 registered_handlers_.erase(channel);
64 }
65 }

◆ SimulateEngineMessage()

bool flutter::TestBinaryMessenger::SimulateEngineMessage ( const std::string &  channel,
const uint8_t *  message,
size_t  message_size,
BinaryReply  reply 
)
inline

Definition at line 35 of file test_binary_messenger.h.

38 {
39 auto handler = registered_handlers_.find(channel);
40 if (handler == registered_handlers_.end()) {
41 return false;
42 }
43 (handler->second)(message, message_size, reply);
44 return true;
45 }

The documentation for this class was generated from the following file: