7 #include "gtest/gtest.h"
13 const uint8_t* message_data =
reinterpret_cast<const uint8_t*
>(0xcafebabe);
14 auto dispatcher = std::make_unique<IncomingMessageDispatcher>(messenger);
15 bool did_call =
false;
16 dispatcher->SetMessageCallback(
23 reinterpret_cast<const uint8_t*
>(0xcafebabe));
25 *
reinterpret_cast<bool*
>(
user_data) =
true;
31 .message = message_data,
33 .response_handle =
nullptr,
35 dispatcher->HandleMessage(message);
36 EXPECT_TRUE(did_call);
41 auto dispatcher = std::make_unique<IncomingMessageDispatcher>(messenger);
42 bool did_call[3] = {
false,
false,
false};
43 dispatcher->SetMessageCallback(
54 .response_handle =
nullptr,
56 dispatcher->HandleMessage(
57 message, [&did_call] { did_call[1] =
true; },
58 [&did_call] { did_call[2] =
true; });
59 EXPECT_TRUE(did_call[0]);
60 EXPECT_FALSE(did_call[1]);
61 EXPECT_FALSE(did_call[2]);
66 auto dispatcher = std::make_unique<IncomingMessageDispatcher>(messenger);
67 static int counter = 0;
68 int did_call[3] = {-1, -1, -1};
69 dispatcher->EnableInputBlockingForChannel(
"hello");
70 dispatcher->SetMessageCallback(
81 .response_handle =
nullptr,
83 dispatcher->HandleMessage(
84 message, [&did_call] { did_call[counter++] = 0; },
85 [&did_call] { did_call[counter++] = 2; });
86 EXPECT_EQ(did_call[0], 0);
87 EXPECT_EQ(did_call[1], 1);
88 EXPECT_EQ(did_call[2], 2);