5#include "flutter/shell/platform/linux/public/flutter_linux/fl_message_codec.h"
6#include "gtest/gtest.h"
16G_DEFINE_TYPE(FlTestCodec, fl_test_codec, fl_message_codec_get_type())
26 return g_bytes_new(&c, 1);
42 static_cast<const uint8_t*
>(g_bytes_get_data(
message, &data_length));
43 if (data_length < 1) {
48 if (data_length > 1) {
51 "FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA");
66 return FL_TEST_CODEC(g_object_new(fl_test_codec_get_type(),
nullptr));
69TEST(FlMessageCodecTest, EncodeMessage) {
73 g_autoptr(GError)
error =
nullptr;
77 EXPECT_EQ(
error,
nullptr);
78 EXPECT_EQ(g_bytes_get_size(
message),
static_cast<gsize
>(1));
79 EXPECT_EQ(
static_cast<const uint8_t*
>(g_bytes_get_data(
message,
nullptr))[0],
83TEST(FlMessageCodecTest, EncodeMessageError) {
87 g_autoptr(GError)
error =
nullptr;
95TEST(FlMessageCodecTest, DecodeMessageEmpty) {
97 g_autoptr(GBytes)
message = g_bytes_new(
nullptr, 0);
99 g_autoptr(GError)
error =
nullptr;
102 EXPECT_EQ(
value,
nullptr);
107TEST(FlMessageCodecTest, DecodeMessage) {
109 uint8_t
data[] = {
'1'};
112 g_autoptr(GError)
error =
nullptr;
115 EXPECT_NE(
value,
nullptr);
116 EXPECT_EQ(
error,
nullptr);
122TEST(FlMessageCodecTest, DecodeMessageExtraData) {
124 uint8_t
data[] = {
'1',
'2'};
127 g_autoptr(GError)
error =
nullptr;
130 EXPECT_EQ(
value,
nullptr);
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlAccessibleTextField, fl_accessible_text_field, FL, ACCESSIBLE_TEXT_FIELD, FlAccessibleNode)
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
G_MODULE_EXPORT FlValue * fl_message_codec_decode_message(FlMessageCodec *self, GBytes *message, GError **error)
G_MODULE_EXPORT GBytes * fl_message_codec_encode_message(FlMessageCodec *self, FlValue *message, GError **error)
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
@ FL_MESSAGE_CODEC_ERROR_FAILED
@ FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
#define FL_MESSAGE_CODEC_ERROR
static FlValue * fl_test_codec_decode_message(FlMessageCodec *codec, GBytes *message, GError **error)
static FlTestCodec * fl_test_codec_new()
static GBytes * fl_test_codec_encode_message(FlMessageCodec *codec, FlValue *value, GError **error)
TEST(FlMessageCodecTest, EncodeMessage)
static void fl_test_codec_init(FlTestCodec *self)
static void fl_test_codec_class_init(FlTestCodecClass *klass)
const uint8_t uint32_t uint32_t GError ** error
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_null()
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
typedefG_BEGIN_DECLS struct _FlValue FlValue
FlMessageCodec parent_instance
std::shared_ptr< const fml::Mapping > data
#define EXPECT_TRUE(handle)