mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Add unit test for PayloadListner
PiperOrigin-RevId: 481773299
This commit is contained in:
committed by
Copybara-Service
parent
a620d8eeb6
commit
4157b1f70b
@@ -15,11 +15,13 @@
|
||||
#include "connections/listeners.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
@@ -54,6 +56,24 @@ TEST(ListenersTest, EnsurePartiallyInitializedIsCallable) {
|
||||
EXPECT_TRUE(initiated_cb_called);
|
||||
}
|
||||
|
||||
TEST(ListenersTest, PayloadListener_PayloadCb_Works) {
|
||||
bool payload_content_match = false;
|
||||
const std::string input_bytes = "input";
|
||||
Payload payload = Payload(ByteArray(input_bytes));
|
||||
|
||||
PayloadListener listener{
|
||||
.payload_cb =
|
||||
[&](const std::string& endpoint_id, Payload payload) {
|
||||
if (payload.AsBytes().data() == input_bytes) {
|
||||
payload_content_match = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
listener.payload_cb("endpoint_id", std::move(payload));
|
||||
|
||||
EXPECT_TRUE(payload_content_match);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
Reference in New Issue
Block a user