Flutter Engine
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
 
 TestBinaryMessenger (TestBinaryMessenger const &)=delete
 
TestBinaryMessenger & operator= (TestBinaryMessenger const &)=delete
 
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
 

Detailed Description

Definition at line 18 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 23 of file test_binary_messenger.h.

Constructor & Destructor Documentation

◆ TestBinaryMessenger() [1/2]

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

Definition at line 26 of file test_binary_messenger.h.

References operator=(), and TestBinaryMessenger().

Referenced by TestBinaryMessenger().

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

◆ ~TestBinaryMessenger()

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

◆ TestBinaryMessenger() [2/2]

flutter::TestBinaryMessenger::TestBinaryMessenger ( TestBinaryMessenger const &  )
delete

Member Function Documentation

◆ operator=()

TestBinaryMessenger& flutter::TestBinaryMessenger::operator= ( TestBinaryMessenger const &  )
delete

Referenced by TestBinaryMessenger().

◆ 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 51 of file test_binary_messenger.h.

54  {
55  // If something under test sends a message, the test should be handling it.
56  assert(send_handler_);
57  send_handler_(channel, message, message_size, reply);
58  }
Win32Message message

◆ SetMessageHandler()

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

Implements flutter::BinaryMessenger.

Definition at line 61 of file test_binary_messenger.h.

62  {
63  if (handler) {
64  registered_handlers_[channel] = handler;
65  } else {
66  registered_handlers_.erase(channel);
67  }
68  }

◆ SimulateEngineMessage()

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

Definition at line 38 of file test_binary_messenger.h.

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

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