Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
fl_standard_method_codec_test.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h"
#include "flutter/shell/platform/linux/fl_method_codec_private.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_message_codec.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_message_codec.h"
#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 G_DECLARE_FINAL_TYPE (FlTestMethodMessageCodec, fl_test_method_message_codec, FL, TEST_METHOD_MESSAGE_CODEC, FlStandardMessageCodec) struct _FlTestMethodMessageCodec
 
 G_DEFINE_TYPE (FlTestMethodMessageCodec, fl_test_method_message_codec, fl_standard_message_codec_get_type()) static gboolean write_custom_value(FlStandardMessageCodec *codec
 
 g_byte_array_append (buffer, &type, sizeof(uint8_t))
 
 fl_standard_message_codec_write_size (codec, buffer, length)
 
 g_byte_array_append (buffer, reinterpret_cast< const uint8_t * >(text), length)
 
static gboolean fl_test_method_message_codec_write_value (FlStandardMessageCodec *codec, GByteArray *buffer, FlValue *value, GError **error)
 
static FlValueread_custom_value (FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, GError **error)
 
static FlValuefl_test_method_message_codec_read_value_of_type (FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, int type, GError **error)
 
static void fl_test_method_message_codec_class_init (FlTestMethodMessageCodecClass *klass)
 
static void fl_test_method_message_codec_init (FlTestMethodMessageCodec *self)
 
static FlTestMethodMessageCodec * fl_test_method_message_codec_new ()
 
static gchar * encode_method_call (const gchar *name, FlValue *args)
 
static gchar * encode_success_envelope (FlValue *result)
 
static gchar * encode_error_envelope (const gchar *error_code, const gchar *error_message, FlValue *details)
 
static void decode_method_call (const char *hex_string, gchar **name, FlValue **args)
 
static void decode_error_method_call (const char *hex_string, GQuark domain, gint code)
 
static void decode_response_with_success (const char *hex_string, FlValue *result)
 
static void decode_response_with_error (const char *hex_string, const gchar *code, const gchar *error_message, FlValue *details)
 
static void decode_error_response (const char *hex_string, GQuark domain, gint code)
 
 TEST (FlStandardMethodCodecTest, EncodeMethodCallNullptrArgs)
 
 TEST (FlStandardMethodCodecTest, EncodeMethodCallNullArgs)
 
 TEST (FlStandardMethodCodecTest, EncodeMethodCallStringArgs)
 
 TEST (FlStandardMethodCodecTest, EncodeMethodCallListArgs)
 
 TEST (FlStandardMethodCodecTest, DecodeMethodCallNullArgs)
 
 TEST (FlStandardMethodCodecTest, DecodeMethodCallStringArgs)
 
 TEST (FlStandardMethodCodecTest, DecodeMethodCallListArgs)
 
 TEST (FlStandardMethodCodecTest, DecodeMethodCallNoData)
 
 TEST (FlStandardMethodCodecTest, DecodeMethodCallNullMethodName)
 
 TEST (FlStandardMethodCodecTest, DecodeMethodCallMissingArgs)
 
 TEST (FlStandardMethodCodecTest, EncodeSuccessEnvelopeNullptr)
 
 TEST (FlStandardMethodCodecTest, EncodeSuccessEnvelopeNull)
 
 TEST (FlStandardMethodCodecTest, EncodeSuccessEnvelopeString)
 
 TEST (FlStandardMethodCodecTest, EncodeSuccessEnvelopeList)
 
 TEST (FlStandardMethodCodecTest, EncodeErrorEnvelopeEmptyCode)
 
 TEST (FlStandardMethodCodecTest, EncodeErrorEnvelopeNonMessageOrDetails)
 
 TEST (FlStandardMethodCodecTest, EncodeErrorEnvelopeMessage)
 
 TEST (FlStandardMethodCodecTest, EncodeErrorEnvelopeDetails)
 
 TEST (FlStandardMethodCodecTest, EncodeErrorEnvelopeMessageAndDetails)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseSuccessNull)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseSuccessString)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseSuccessList)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorEmptyCode)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorNoMessageOrDetails)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorMessage)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorDetails)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorMessageAndDetails)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseSuccessNoData)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseSuccessExtraData)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorNoData)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorMissingMessageAndDetails)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorMissingDetails)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseErrorExtraData)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseNotImplemented)
 
 TEST (FlStandardMethodCodecTest, DecodeResponseUnknownEnvelope)
 
 TEST (FlStandardMethodCodecTest, CustomMessageCodec)
 

Variables

GByteArray * buffer
 
GByteArray FlValuevalue
 
GByteArray FlValue GError ** error
 
size_t length = strlen(text)
 
uint8_t type = 128
 
return TRUE
 

Function Documentation

◆ decode_error_method_call()

static void decode_error_method_call ( const char *  hex_string,
GQuark  domain,
gint  code 
)
static

Definition at line 170 of file fl_standard_method_codec_test.cc.

172 {
173 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
174 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
175 g_autoptr(GError) error = nullptr;
176 g_autofree gchar* name = nullptr;
177 g_autoptr(FlValue) args = nullptr;
179 FL_METHOD_CODEC(codec), message, &name, &args, &error);
180 EXPECT_FALSE(result);
181 EXPECT_EQ(name, nullptr);
182 EXPECT_EQ(args, nullptr);
183 EXPECT_TRUE(g_error_matches(error, domain, code));
184}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
gboolean fl_method_codec_decode_method_call(FlMethodCodec *self, GBytes *message, gchar **name, FlValue **args, GError **error)
G_MODULE_EXPORT FlStandardMethodCodec * fl_standard_method_codec_new()
GByteArray FlValue GError ** error
GBytes * hex_string_to_bytes(const gchar *hex_string)
Definition fl_test.cc:43
GAsyncResult * result
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
const char * name
Definition fuchsia.cc:50
Win32Message message
#define EXPECT_TRUE(handle)
Definition unit_test.h:685

◆ decode_error_response()

static void decode_error_response ( const char *  hex_string,
GQuark  domain,
gint  code 
)
static

Definition at line 240 of file fl_standard_method_codec_test.cc.

242 {
243 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
244 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
245 g_autoptr(GError) error = nullptr;
246 g_autoptr(FlMethodResponse) response =
247 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
248 EXPECT_EQ(response, nullptr);
249 EXPECT_TRUE(g_error_matches(error, domain, code));
250}
FlMethodResponse * fl_method_codec_decode_response(FlMethodCodec *self, GBytes *message, GError **error)

◆ decode_method_call()

static void decode_method_call ( const char *  hex_string,
gchar **  name,
FlValue **  args 
)
static

Definition at line 157 of file fl_standard_method_codec_test.cc.

159 {
160 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
161 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
162 g_autoptr(GError) error = nullptr;
164 FL_METHOD_CODEC(codec), message, name, args, &error);
166 EXPECT_EQ(error, nullptr);
167}

◆ decode_response_with_error()

static void decode_response_with_error ( const char *  hex_string,
const gchar *  code,
const gchar *  error_message,
FlValue details 
)
static

Definition at line 205 of file fl_standard_method_codec_test.cc.

208 {
209 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
210 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
211 g_autoptr(GError) error = nullptr;
212 g_autoptr(FlMethodResponse) response =
213 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
214 ASSERT_NE(response, nullptr);
215 EXPECT_EQ(error, nullptr);
216 EXPECT_TRUE(FL_IS_METHOD_ERROR_RESPONSE(response));
217 EXPECT_STREQ(
218 fl_method_error_response_get_code(FL_METHOD_ERROR_RESPONSE(response)),
219 code);
220 if (error_message == nullptr) {
222 FL_METHOD_ERROR_RESPONSE(response)),
223 nullptr);
224 } else {
226 FL_METHOD_ERROR_RESPONSE(response)),
227 error_message);
228 }
229 if (details == nullptr) {
231 FL_METHOD_ERROR_RESPONSE(response)),
232 nullptr);
233 } else {
235 FL_METHOD_ERROR_RESPONSE(response)),
236 details));
237 }
238}
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
G_MODULE_EXPORT FlValue * fl_method_error_response_get_details(FlMethodErrorResponse *self)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
Definition fl_value.cc:471

◆ decode_response_with_success()

static void decode_response_with_success ( const char *  hex_string,
FlValue result 
)
static

Definition at line 188 of file fl_standard_method_codec_test.cc.

189 {
190 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
191 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
192 g_autoptr(GError) error = nullptr;
193 g_autoptr(FlMethodResponse) response =
194 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
195 ASSERT_NE(response, nullptr);
196 EXPECT_EQ(error, nullptr);
197 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
199 FL_METHOD_SUCCESS_RESPONSE(response)),
200 result));
201}
G_MODULE_EXPORT FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *self)

◆ encode_error_envelope()

static gchar * encode_error_envelope ( const gchar *  error_code,
const gchar *  error_message,
FlValue details 
)
static

Definition at line 143 of file fl_standard_method_codec_test.cc.

145 {
146 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
147 g_autoptr(GError) error = nullptr;
149 FL_METHOD_CODEC(codec), error_code, error_message, details, &error);
150 EXPECT_NE(message, nullptr);
151 EXPECT_EQ(error, nullptr);
152
154}
GBytes * fl_method_codec_encode_error_envelope(FlMethodCodec *self, const gchar *code, const gchar *message, FlValue *details, GError **error)
gchar * bytes_to_hex_string(GBytes *bytes)
Definition fl_test.cc:52

◆ encode_method_call()

static gchar * encode_method_call ( const gchar *  name,
FlValue args 
)
static

Definition at line 118 of file fl_standard_method_codec_test.cc.

118 {
119 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
120 g_autoptr(GError) error = nullptr;
122 FL_METHOD_CODEC(codec), name, args, &error);
123 EXPECT_NE(message, nullptr);
124 EXPECT_EQ(error, nullptr);
125
127}
GBytes * fl_method_codec_encode_method_call(FlMethodCodec *self, const gchar *name, FlValue *args, GError **error)

◆ encode_success_envelope()

static gchar * encode_success_envelope ( FlValue result)
static

Definition at line 131 of file fl_standard_method_codec_test.cc.

131 {
132 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
133 g_autoptr(GError) error = nullptr;
135 FL_METHOD_CODEC(codec), result, &error);
136 EXPECT_NE(message, nullptr);
137 EXPECT_EQ(error, nullptr);
138
140}
GBytes * fl_method_codec_encode_success_envelope(FlMethodCodec *self, FlValue *result, GError **error)

◆ fl_standard_message_codec_write_size()

fl_standard_message_codec_write_size ( codec  ,
buffer  ,
length   
)

◆ fl_test_method_message_codec_class_init()

static void fl_test_method_message_codec_class_init ( FlTestMethodMessageCodecClass *  klass)
static

Definition at line 96 of file fl_standard_method_codec_test.cc.

97 {
98 FL_STANDARD_MESSAGE_CODEC_CLASS(klass)->write_value =
100 FL_STANDARD_MESSAGE_CODEC_CLASS(klass)->read_value_of_type =
102}
static FlValue * fl_test_method_message_codec_read_value_of_type(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, int type, GError **error)
static gboolean fl_test_method_message_codec_write_value(FlStandardMessageCodec *codec, GByteArray *buffer, FlValue *value, GError **error)

◆ fl_test_method_message_codec_init()

static void fl_test_method_message_codec_init ( FlTestMethodMessageCodec *  self)
static

Definition at line 104 of file fl_standard_method_codec_test.cc.

104 {
105 // The following line suppresses a warning for unused function
106 FL_IS_TEST_METHOD_MESSAGE_CODEC(self);
107}

◆ fl_test_method_message_codec_new()

static FlTestMethodMessageCodec * fl_test_method_message_codec_new ( )
static

Definition at line 109 of file fl_standard_method_codec_test.cc.

109 {
110 return FL_TEST_METHOD_MESSAGE_CODEC(
111 g_object_new(fl_test_method_message_codec_get_type(), nullptr));
112}

◆ fl_test_method_message_codec_read_value_of_type()

static FlValue * fl_test_method_message_codec_read_value_of_type ( FlStandardMessageCodec *  codec,
GBytes *  buffer,
size_t *  offset,
int  type,
GError **  error 
)
static

Definition at line 81 of file fl_standard_method_codec_test.cc.

86 {
87 if (type == 128) {
88 return read_custom_value(codec, buffer, offset, error);
89 } else {
90 return FL_STANDARD_MESSAGE_CODEC_CLASS(
91 fl_test_method_message_codec_parent_class)
92 ->read_value_of_type(codec, buffer, offset, type, error);
93 }
94}
static FlValue * read_custom_value(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, GError **error)
GByteArray * buffer
Point offset

◆ fl_test_method_message_codec_write_value()

static gboolean fl_test_method_message_codec_write_value ( FlStandardMessageCodec *  codec,
GByteArray *  buffer,
FlValue value,
GError **  error 
)
static

Definition at line 41 of file fl_standard_method_codec_test.cc.

45 {
48 return write_custom_value(codec, buffer, value, error);
49 } else {
50 return FL_STANDARD_MESSAGE_CODEC_CLASS(
51 fl_test_method_message_codec_parent_class)
52 ->write_value(codec, buffer, value, error);
53 }
54}
GByteArray FlValue * value
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition fl_value.cc:466
G_MODULE_EXPORT int fl_value_get_custom_type(FlValue *self)
Definition fl_value.cc:822
@ FL_VALUE_TYPE_CUSTOM
Definition fl_value.h:77

◆ g_byte_array_append() [1/2]

g_byte_array_append ( buffer  ,
type,
sizeof(uint8_t)   
)

◆ g_byte_array_append() [2/2]

g_byte_array_append ( buffer  ,
reinterpret_cast< const uint8_t * >  text,
length   
)

◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE ( FlTestMethodMessageCodec  ,
fl_test_method_message_codec  ,
FL  ,
TEST_METHOD_MESSAGE_CODEC  ,
FlStandardMessageCodec   
)

Definition at line 12 of file fl_standard_method_codec_test.cc.

18 {
19 FlStandardMessageCodec parent_instance;
20};

◆ G_DEFINE_TYPE()

G_DEFINE_TYPE ( FlTestMethodMessageCodec  ,
fl_test_method_message_codec  ,
fl_standard_message_codec_get_type()   
)

◆ read_custom_value()

static FlValue * read_custom_value ( FlStandardMessageCodec *  codec,
GBytes *  buffer,
size_t *  offset,
GError **  error 
)
static

Definition at line 56 of file fl_standard_method_codec_test.cc.

59 {
60 uint32_t length;
62 error)) {
63 return nullptr;
64 }
65 if (*offset + length > g_bytes_get_size(buffer)) {
66 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
67 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA, "Unexpected end of data");
68 return nullptr;
69 }
71 128,
72 g_strndup(static_cast<const gchar*>(g_bytes_get_data(buffer, nullptr)) +
73 *offset,
74 length),
75 g_free);
76 *offset += length;
77
78 return value;
79}
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
#define FL_MESSAGE_CODEC_ERROR
G_MODULE_EXPORT gboolean fl_standard_message_codec_read_size(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
G_MODULE_EXPORT FlValue * fl_value_new_custom(int type, gconstpointer value, GDestroyNotify destroy_notify)
Definition fl_value.cc:374

◆ TEST() [1/36]

TEST ( FlStandardMethodCodecTest  ,
CustomMessageCodec   
)

Definition at line 482 of file fl_standard_method_codec_test.cc.

482 {
483 g_autoptr(FlTestMethodMessageCodec) message_codec =
485 g_autoptr(FlStandardMethodCodec) codec =
487 FL_STANDARD_MESSAGE_CODEC(message_codec));
488
489 g_autoptr(GError) error = nullptr;
490 g_autoptr(FlValue) value = fl_value_new_custom(128, "hello", nullptr);
492 FL_METHOD_CODEC(codec), value, &error);
493 EXPECT_NE(message, nullptr);
494 EXPECT_EQ(error, nullptr);
495 g_autofree gchar* hex_string = bytes_to_hex_string(message);
496 EXPECT_STREQ(hex_string, "00800568656c6c6f");
497
498 g_autoptr(FlMethodResponse) response =
499 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
500 EXPECT_NE(response, nullptr);
501 EXPECT_EQ(error, nullptr);
502 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
504 FL_METHOD_SUCCESS_RESPONSE(response));
506 ASSERT_EQ(fl_value_get_custom_type(result), 128);
507 EXPECT_STREQ(static_cast<const gchar*>(fl_value_get_custom_value(result)),
508 "hello");
509}
G_MODULE_EXPORT FlStandardMethodCodec * fl_standard_method_codec_new_with_message_codec(FlStandardMessageCodec *message_codec)
static FlTestMethodMessageCodec * fl_test_method_message_codec_new()
G_MODULE_EXPORT gconstpointer fl_value_get_custom_value(FlValue *self)
Definition fl_value.cc:830

◆ TEST() [2/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeMethodCallListArgs   
)

Definition at line 294 of file fl_standard_method_codec_test.cc.

294 {
295 g_autofree gchar* name = nullptr;
296 g_autoptr(FlValue) args = nullptr;
297 decode_method_call("070568656c6c6f0c020705636f756e74032a000000", &name,
298 &args);
299 EXPECT_STREQ(name, "hello");
301 EXPECT_EQ(fl_value_get_length(args), static_cast<size_t>(2));
302
304 ASSERT_EQ(fl_value_get_type(arg0), FL_VALUE_TYPE_STRING);
305 EXPECT_STREQ(fl_value_get_string(arg0), "count");
306
308 ASSERT_EQ(fl_value_get_type(arg1), FL_VALUE_TYPE_INT);
309 EXPECT_EQ(fl_value_get_int(arg1), 42);
310}
static void decode_method_call(const char *hex_string, gchar **name, FlValue **args)
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition fl_value.cc:668
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition fl_value.cc:682
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition fl_value.cc:776
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition fl_value.cc:724
@ FL_VALUE_TYPE_STRING
Definition fl_value.h:69
@ FL_VALUE_TYPE_INT
Definition fl_value.h:67
@ FL_VALUE_TYPE_LIST
Definition fl_value.h:74

◆ TEST() [3/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeMethodCallMissingArgs   
)

Definition at line 322 of file fl_standard_method_codec_test.cc.

322 {
325}
static void decode_error_method_call(const char *hex_string, GQuark domain, gint code)

◆ TEST() [4/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeMethodCallNoData   
)

◆ TEST() [5/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeMethodCallNullArgs   
)

Definition at line 277 of file fl_standard_method_codec_test.cc.

277 {
278 g_autofree gchar* name = nullptr;
279 g_autoptr(FlValue) args = nullptr;
280 decode_method_call("070568656c6c6f00", &name, &args);
281 EXPECT_STREQ(name, "hello");
283}
@ FL_VALUE_TYPE_NULL
Definition fl_value.h:65

◆ TEST() [6/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeMethodCallNullMethodName   
)

Definition at line 317 of file fl_standard_method_codec_test.cc.

◆ TEST() [7/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeMethodCallStringArgs   
)

Definition at line 285 of file fl_standard_method_codec_test.cc.

285 {
286 g_autofree gchar* name = nullptr;
287 g_autoptr(FlValue) args = nullptr;
288 decode_method_call("070568656c6c6f0705776f726c64", &name, &args);
289 EXPECT_STREQ(name, "hello");
291 EXPECT_STREQ(fl_value_get_string(args), "world");
292}

◆ TEST() [8/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorDetails   
)

Definition at line 419 of file fl_standard_method_codec_test.cc.

419 {
420 g_autoptr(FlValue) details = fl_value_new_list();
421 fl_value_append_take(details, fl_value_new_string("count"));
423 decode_response_with_error("0107056572726f72000c020705636f756e74032a000000",
424 "error", nullptr, details);
425}
static void decode_response_with_error(const char *hex_string, const gchar *code, const gchar *error_message, FlValue *details)
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition fl_value.cc:276
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition fl_value.cc:262
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition fl_value.cc:600
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition fl_value.cc:349

◆ TEST() [9/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorEmptyCode   
)

Definition at line 406 of file fl_standard_method_codec_test.cc.

406 {
407 decode_response_with_error("0107000000", "", nullptr, nullptr);
408}

◆ TEST() [10/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorExtraData   
)

Definition at line 461 of file fl_standard_method_codec_test.cc.

461 {
462 decode_error_response("0107056572726f72000000", FL_MESSAGE_CODEC_ERROR,
464}
static void decode_error_response(const char *hex_string, GQuark domain, gint code)

◆ TEST() [11/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorMessage   
)

Definition at line 414 of file fl_standard_method_codec_test.cc.

414 {
415 decode_response_with_error("0107056572726f7207076d65737361676500", "error",
416 "message", nullptr);
417}

◆ TEST() [12/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorMessageAndDetails   
)

Definition at line 427 of file fl_standard_method_codec_test.cc.

427 {
428 g_autoptr(FlValue) details = fl_value_new_list();
429 fl_value_append_take(details, fl_value_new_string("count"));
432 "0107056572726f7207076d6573736167650c020705636f756e74032a000000", "error",
433 "message", details);
434}

◆ TEST() [13/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorMissingDetails   
)

Definition at line 456 of file fl_standard_method_codec_test.cc.

◆ TEST() [14/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorMissingMessageAndDetails   
)

Definition at line 451 of file fl_standard_method_codec_test.cc.

◆ TEST() [15/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorNoData   
)

◆ TEST() [16/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseErrorNoMessageOrDetails   
)

Definition at line 410 of file fl_standard_method_codec_test.cc.

410 {
411 decode_response_with_error("0107056572726f720000", "error", nullptr, nullptr);
412}

◆ TEST() [17/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseNotImplemented   
)

Definition at line 466 of file fl_standard_method_codec_test.cc.

466 {
467 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
468 g_autoptr(GBytes) message = g_bytes_new(nullptr, 0);
469 g_autoptr(GError) error = nullptr;
470 g_autoptr(FlMethodResponse) response =
471 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
472 ASSERT_NE(response, nullptr);
473 EXPECT_EQ(error, nullptr);
474 EXPECT_TRUE(FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response));
475}

◆ TEST() [18/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseSuccessExtraData   
)

◆ TEST() [19/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseSuccessList   
)

Definition at line 399 of file fl_standard_method_codec_test.cc.

399 {
400 g_autoptr(FlValue) result = fl_value_new_list();
403 decode_response_with_success("000c020705636f756e74032a000000", result);
404}
static void decode_response_with_success(const char *hex_string, FlValue *result)

◆ TEST() [20/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseSuccessNoData   
)

◆ TEST() [21/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseSuccessNull   
)

Definition at line 389 of file fl_standard_method_codec_test.cc.

389 {
390 g_autoptr(FlValue) result = fl_value_new_null();
392}
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition fl_value.cc:251

◆ TEST() [22/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseSuccessString   
)

Definition at line 394 of file fl_standard_method_codec_test.cc.

394 {
395 g_autoptr(FlValue) result = fl_value_new_string("hello");
396 decode_response_with_success("00070568656c6c6f", result);
397}

◆ TEST() [23/36]

TEST ( FlStandardMethodCodecTest  ,
DecodeResponseUnknownEnvelope   
)

◆ TEST() [24/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeErrorEnvelopeDetails   
)

Definition at line 369 of file fl_standard_method_codec_test.cc.

369 {
370 g_autoptr(FlValue) details = fl_value_new_list();
371 fl_value_append_take(details, fl_value_new_string("count"));
373 g_autofree gchar* hex_string =
374 encode_error_envelope("error", nullptr, details);
375 EXPECT_STREQ(hex_string, "0107056572726f72000c020705636f756e74032a000000");
376}
static gchar * encode_error_envelope(const gchar *error_code, const gchar *error_message, FlValue *details)

◆ TEST() [25/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeErrorEnvelopeEmptyCode   
)

Definition at line 352 of file fl_standard_method_codec_test.cc.

352 {
353 g_autofree gchar* hex_string = encode_error_envelope("", nullptr, nullptr);
354 EXPECT_STREQ(hex_string, "0107000000");
355}

◆ TEST() [26/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeErrorEnvelopeMessage   
)

Definition at line 363 of file fl_standard_method_codec_test.cc.

363 {
364 g_autofree gchar* hex_string =
365 encode_error_envelope("error", "message", nullptr);
366 EXPECT_STREQ(hex_string, "0107056572726f7207076d65737361676500");
367}

◆ TEST() [27/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeErrorEnvelopeMessageAndDetails   
)

Definition at line 378 of file fl_standard_method_codec_test.cc.

378 {
379 g_autoptr(FlValue) details = fl_value_new_list();
380 fl_value_append_take(details, fl_value_new_string("count"));
382 g_autofree gchar* hex_string =
383 encode_error_envelope("error", "message", details);
384 EXPECT_STREQ(
385 hex_string,
386 "0107056572726f7207076d6573736167650c020705636f756e74032a000000");
387}

◆ TEST() [28/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeErrorEnvelopeNonMessageOrDetails   
)

Definition at line 357 of file fl_standard_method_codec_test.cc.

357 {
358 g_autofree gchar* hex_string =
359 encode_error_envelope("error", nullptr, nullptr);
360 EXPECT_STREQ(hex_string, "0107056572726f720000");
361}

◆ TEST() [29/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeMethodCallListArgs   
)

Definition at line 269 of file fl_standard_method_codec_test.cc.

269 {
270 g_autoptr(FlValue) args = fl_value_new_list();
273 g_autofree gchar* hex_string = encode_method_call("hello", args);
274 EXPECT_STREQ(hex_string, "070568656c6c6f0c020705636f756e74032a000000");
275}
static gchar * encode_method_call(const gchar *name, FlValue *args)

◆ TEST() [30/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeMethodCallNullArgs   
)

Definition at line 257 of file fl_standard_method_codec_test.cc.

257 {
258 g_autoptr(FlValue) value = fl_value_new_null();
259 g_autofree gchar* hex_string = encode_method_call("hello", value);
260 EXPECT_STREQ(hex_string, "070568656c6c6f00");
261}

◆ TEST() [31/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeMethodCallNullptrArgs   
)

Definition at line 252 of file fl_standard_method_codec_test.cc.

252 {
253 g_autofree gchar* hex_string = encode_method_call("hello", nullptr);
254 EXPECT_STREQ(hex_string, "070568656c6c6f00");
255}

◆ TEST() [32/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeMethodCallStringArgs   
)

Definition at line 263 of file fl_standard_method_codec_test.cc.

263 {
264 g_autoptr(FlValue) args = fl_value_new_string("world");
265 g_autofree gchar* hex_string = encode_method_call("hello", args);
266 EXPECT_STREQ(hex_string, "070568656c6c6f0705776f726c64");
267}

◆ TEST() [33/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeSuccessEnvelopeList   
)

Definition at line 344 of file fl_standard_method_codec_test.cc.

344 {
345 g_autoptr(FlValue) result = fl_value_new_list();
348 g_autofree gchar* hex_string = encode_success_envelope(result);
349 EXPECT_STREQ(hex_string, "000c020705636f756e74032a000000");
350}
static gchar * encode_success_envelope(FlValue *result)

◆ TEST() [34/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeSuccessEnvelopeNull   
)

Definition at line 332 of file fl_standard_method_codec_test.cc.

332 {
333 g_autoptr(FlValue) result = fl_value_new_null();
334 g_autofree gchar* hex_string = encode_success_envelope(result);
335 EXPECT_STREQ(hex_string, "0000");
336}

◆ TEST() [35/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeSuccessEnvelopeNullptr   
)

Definition at line 327 of file fl_standard_method_codec_test.cc.

327 {
328 g_autofree gchar* hex_string = encode_success_envelope(nullptr);
329 EXPECT_STREQ(hex_string, "0000");
330}

◆ TEST() [36/36]

TEST ( FlStandardMethodCodecTest  ,
EncodeSuccessEnvelopeString   
)

Definition at line 338 of file fl_standard_method_codec_test.cc.

338 {
339 g_autoptr(FlValue) result = fl_value_new_string("hello");
340 g_autofree gchar* hex_string = encode_success_envelope(result);
341 EXPECT_STREQ(hex_string, "00070568656c6c6f");
342}

Variable Documentation

◆ buffer

GByteArray* buffer

Definition at line 27 of file fl_standard_method_codec_test.cc.

◆ error

GByteArray FlValue GError** error
Initial value:
{
const gchar* text =
static_cast<const gchar*>(fl_value_get_custom_value(value))
std::u16string text

Definition at line 29 of file fl_standard_method_codec_test.cc.

◆ length

size_t length = strlen(text)

Definition at line 32 of file fl_standard_method_codec_test.cc.

◆ TRUE

return TRUE

Definition at line 38 of file fl_standard_method_codec_test.cc.

◆ type

uint8_t type = 128

Definition at line 34 of file fl_standard_method_codec_test.cc.

◆ value

GByteArray FlValue* value

Definition at line 28 of file fl_standard_method_codec_test.cc.