| Flutter Linux Embedder |

Functions
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/testing/fl_test.h"`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Functions
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)

## Function Documentation

## ◆ decode_error_method_call()

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

Definition at line 67 of file fl_standard_method_codec_test.cc.

69 {
70 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
71 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
72 g_autoptr(GError) error = nullptr;
73 g_autofree gchar* name = nullptr;
74 g_autoptr(FlValue) args = nullptr;
75 gboolean result = fl_method_codec_decode_method_call(
76 FL_METHOD_CODEC(codec), message, &name, &args, &error);
77 EXPECT_FALSE(result);
78 EXPECT_EQ(name, nullptr);
79 EXPECT_EQ(args, nullptr);
80 EXPECT_TRUE(g_error_matches(error, domain, code));
81 }

References args, error, fl_method_codec_decode_method_call(), fl_standard_method_codec_new(), and result.

Referenced by TEST().

## ◆ decode_error_response()

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

Definition at line 137 of file fl_standard_method_codec_test.cc.

139 {
140 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
141 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
142 g_autoptr(GError) error = nullptr;
143 g_autoptr(FlMethodResponse) response =
144 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
145 EXPECT_EQ(response, nullptr);
146 EXPECT_TRUE(g_error_matches(error, domain, code));
147 }

References error, fl_method_codec_decode_response(), and fl_standard_method_codec_new().

Referenced by TEST().

## ◆ decode_method_call()

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

Definition at line 54 of file fl_standard_method_codec_test.cc.

56 {
57 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
58 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
59 g_autoptr(GError) error = nullptr;
60 gboolean result = fl_method_codec_decode_method_call(
61 FL_METHOD_CODEC(codec), message, name, args, &error);
62 EXPECT_TRUE(result);
63 EXPECT_EQ(error, nullptr);
64 }

References args, error, fl_method_codec_decode_method_call(), fl_standard_method_codec_new(), and result.

Referenced by TEST().

## ◆ 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 102 of file fl_standard_method_codec_test.cc.

105 {
106 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
107 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
108 g_autoptr(GError) error = nullptr;
109 g_autoptr(FlMethodResponse) response =
110 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
111 ASSERT_NE(response, nullptr);
112 EXPECT_EQ(error, nullptr);
113 EXPECT_TRUE(FL_IS_METHOD_ERROR_RESPONSE(response));
114 EXPECT_STREQ(
115 fl_method_error_response_get_code(FL_METHOD_ERROR_RESPONSE(response)),
116 code);
117 if (error_message == nullptr) {
118 EXPECT_EQ(fl_method_error_response_get_message(
119 FL_METHOD_ERROR_RESPONSE(response)),
120 nullptr);
121 } else {
122 EXPECT_STREQ(fl_method_error_response_get_message(
123 FL_METHOD_ERROR_RESPONSE(response)),
124 error_message);
125 }
126 if (details == nullptr) {
127 EXPECT_EQ(fl_method_error_response_get_details(
128 FL_METHOD_ERROR_RESPONSE(response)),
129 nullptr);
130 } else {
131 EXPECT_TRUE(fl_value_equal(fl_method_error_response_get_details(
132 FL_METHOD_ERROR_RESPONSE(response)),
133 details));
134 }
135 }

References error, fl_method_codec_decode_response(), fl_method_error_response_get_code(), fl_method_error_response_get_details(), fl_method_error_response_get_message(), fl_standard_method_codec_new(), and fl_value_equal().

Referenced by TEST().

## ◆ decode_response_with_success()

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

Definition at line 85 of file fl_standard_method_codec_test.cc.

86 {
87 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
88 g_autoptr(GBytes) message = hex_string_to_bytes(hex_string);
89 g_autoptr(GError) error = nullptr;
90 g_autoptr(FlMethodResponse) response =
91 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
92 ASSERT_NE(response, nullptr);
93 EXPECT_EQ(error, nullptr);
94 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
95 EXPECT_TRUE(fl_value_equal(fl_method_success_response_get_result(
96 FL_METHOD_SUCCESS_RESPONSE(response)),
97 result));
98 }

References error, fl_method_codec_decode_response(), fl_method_success_response_get_result(), fl_standard_method_codec_new(), fl_value_equal(), and result.

Referenced by TEST().

## ◆ encode_error_envelope()

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

Definition at line 40 of file fl_standard_method_codec_test.cc.

42 {
43 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
44 g_autoptr(GError) error = nullptr;
45 g_autoptr(GBytes) message = fl_method_codec_encode_error_envelope(
46 FL_METHOD_CODEC(codec), error_code, error_message, details, &error);
47 EXPECT_NE(message, nullptr);
48 EXPECT_EQ(error, nullptr);
49
50 return bytes_to_hex_string(message);
51 }

References error, fl_method_codec_encode_error_envelope(), and fl_standard_method_codec_new().

Referenced by TEST().

## ◆ encode_method_call()

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

Definition at line 15 of file fl_standard_method_codec_test.cc.

15 {
16 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
17 g_autoptr(GError) error = nullptr;
18 g_autoptr(GBytes) message = fl_method_codec_encode_method_call(
19 FL_METHOD_CODEC(codec), name, args, &error);
20 EXPECT_NE(message, nullptr);
21 EXPECT_EQ(error, nullptr);
22
23 return bytes_to_hex_string(message);
24 }

References args, error, fl_method_codec_encode_method_call(), and fl_standard_method_codec_new().

Referenced by TEST().

## ◆ encode_success_envelope()

static gchar* encode_success_envelope | ( | FlValue * | result | ) |
| static

Definition at line 28 of file fl_standard_method_codec_test.cc.

28 {
29 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
30 g_autoptr(GError) error = nullptr;
31 g_autoptr(GBytes) message = fl_method_codec_encode_success_envelope(
32 FL_METHOD_CODEC(codec), result, &error);
33 EXPECT_NE(message, nullptr);
34 EXPECT_EQ(error, nullptr);
35
36 return bytes_to_hex_string(message);
37 }

References error, fl_method_codec_encode_success_envelope(), fl_standard_method_codec_new(), and result.

Referenced by TEST().

## ◆ TEST() [1/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeMethodCallListArgs |
| ) |  |

Definition at line 191 of file fl_standard_method_codec_test.cc.

191 {
192 g_autofree gchar* name = nullptr;
193 g_autoptr(FlValue) args = nullptr;
194 decode_method_call("070568656c6c6f0c020705636f756e74032a000000", &name,
195 &args);
196 EXPECT_STREQ(name, "hello");
197 ASSERT_EQ(fl_value_get_type(args), FL_VALUE_TYPE_LIST);
198 EXPECT_EQ(fl_value_get_length(args), static_cast<size_t>(2));
199
200 FlValue* arg0 = fl_value_get_list_value(args, 0);
201 ASSERT_EQ(fl_value_get_type(arg0), FL_VALUE_TYPE_STRING);
202 EXPECT_STREQ(fl_value_get_string(arg0), "count");
203
204 FlValue* arg1 = fl_value_get_list_value(args, 1);
205 ASSERT_EQ(fl_value_get_type(arg1), FL_VALUE_TYPE_INT);
206 EXPECT_EQ(fl_value_get_int(arg1), 42);
207 }

References args, decode_method_call(), fl_value_get_int(), fl_value_get_length(), fl_value_get_list_value(), fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_INT, FL_VALUE_TYPE_LIST, and FL_VALUE_TYPE_STRING.

## ◆ TEST() [2/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeMethodCallMissingArgs |
| ) |  |

Definition at line 219 of file fl_standard_method_codec_test.cc.

219 {
220 decode_error_method_call("070568656c6c6f", FL_MESSAGE_CODEC_ERROR,
221 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA);
222 }

References decode_error_method_call(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

## ◆ TEST() [3/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeMethodCallNoData |
| ) |  |

Definition at line 209 of file fl_standard_method_codec_test.cc.

209 {
210 decode_error_method_call("", FL_MESSAGE_CODEC_ERROR,
211 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA);
212 }

References decode_error_method_call(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

## ◆ TEST() [4/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeMethodCallNullArgs |
| ) |  |

Definition at line 174 of file fl_standard_method_codec_test.cc.

174 {
175 g_autofree gchar* name = nullptr;
176 g_autoptr(FlValue) args = nullptr;
177 decode_method_call("070568656c6c6f00", &name, &args);
178 EXPECT_STREQ(name, "hello");
179 ASSERT_EQ(fl_value_get_type(args), FL_VALUE_TYPE_NULL);
180 }

References args, decode_method_call(), fl_value_get_type(), and FL_VALUE_TYPE_NULL.

## ◆ TEST() [5/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeMethodCallNullMethodName |
| ) |  |

Definition at line 214 of file fl_standard_method_codec_test.cc.

214 {
215 decode_error_method_call("000000", FL_MESSAGE_CODEC_ERROR,
216 FL_MESSAGE_CODEC_ERROR_FAILED);
217 }

References decode_error_method_call(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_FAILED.

## ◆ TEST() [6/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeMethodCallStringArgs |
| ) |  |

Definition at line 182 of file fl_standard_method_codec_test.cc.

182 {
183 g_autofree gchar* name = nullptr;
184 g_autoptr(FlValue) args = nullptr;
185 decode_method_call("070568656c6c6f0705776f726c64", &name, &args);
186 EXPECT_STREQ(name, "hello");
187 ASSERT_EQ(fl_value_get_type(args), FL_VALUE_TYPE_STRING);
188 EXPECT_STREQ(fl_value_get_string(args), "world");
189 }

References args, decode_method_call(), fl_value_get_string(), fl_value_get_type(), and FL_VALUE_TYPE_STRING.

## ◆ TEST() [7/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorDetails |
| ) |  |

Definition at line 316 of file fl_standard_method_codec_test.cc.

316 {
317 g_autoptr(FlValue) details = fl_value_new_list();
318 fl_value_append_take(details, fl_value_new_string("count"));
319 fl_value_append_take(details, fl_value_new_int(42));
320 decode_response_with_error("0107056572726f72000c020705636f756e74032a000000",
321 "error", nullptr, details);
322 }

References decode_response_with_error(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), and fl_value_new_string().

## ◆ TEST() [8/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorEmptyCode |
| ) |  |

Definition at line 303 of file fl_standard_method_codec_test.cc.

303 {
304 decode_response_with_error("0107000000", "", nullptr, nullptr);
305 }

References decode_response_with_error().

## ◆ TEST() [9/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorExtraData |
| ) |  |

Definition at line 358 of file fl_standard_method_codec_test.cc.

358 {
359 decode_error_response("0107056572726f72000000", FL_MESSAGE_CODEC_ERROR,
360 FL_MESSAGE_CODEC_ERROR_FAILED);
361 }

References decode_error_response(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_FAILED.

## ◆ TEST() [10/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorMessage |
| ) |  |

Definition at line 311 of file fl_standard_method_codec_test.cc.

311 {
312 decode_response_with_error("0107056572726f7207076d65737361676500", "error",
313 "message", nullptr);
314 }

References decode_response_with_error().

## ◆ TEST() [11/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorMessageAndDetails |
| ) |  |

Definition at line 324 of file fl_standard_method_codec_test.cc.

324 {
325 g_autoptr(FlValue) details = fl_value_new_list();
326 fl_value_append_take(details, fl_value_new_string("count"));
327 fl_value_append_take(details, fl_value_new_int(42));
328 decode_response_with_error(
329 "0107056572726f7207076d6573736167650c020705636f756e74032a000000", "error",
330 "message", details);
331 }

References decode_response_with_error(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), and fl_value_new_string().

## ◆ TEST() [12/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorMissingDetails |
| ) |  |

Definition at line 353 of file fl_standard_method_codec_test.cc.

353 {
354 decode_error_response("0107056572726f7200", FL_MESSAGE_CODEC_ERROR,
355 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA);
356 }

References decode_error_response(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

## ◆ TEST() [13/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorMissingMessageAndDetails |
| ) |  |

Definition at line 348 of file fl_standard_method_codec_test.cc.

348 {
349 decode_error_response("0107056572726f72", FL_MESSAGE_CODEC_ERROR,
350 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA);
351 }

References decode_error_response(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

## ◆ TEST() [14/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorNoData |
| ) |  |

Definition at line 343 of file fl_standard_method_codec_test.cc.

343 {
344 decode_error_response("01", FL_MESSAGE_CODEC_ERROR,
345 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA);
346 }

References decode_error_response(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

## ◆ TEST() [15/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseErrorNoMessageOrDetails |
| ) |  |

Definition at line 307 of file fl_standard_method_codec_test.cc.

307 {
308 decode_response_with_error("0107056572726f720000", "error", nullptr, nullptr);
309 }

References decode_response_with_error().

## ◆ TEST() [16/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseNotImplemented |
| ) |  |

Definition at line 363 of file fl_standard_method_codec_test.cc.

363 {
364 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
365 g_autoptr(GBytes) message = g_bytes_new(nullptr, 0);
366 g_autoptr(GError) error = nullptr;
367 g_autoptr(FlMethodResponse) response =
368 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
369 ASSERT_NE(response, nullptr);
370 EXPECT_EQ(error, nullptr);
371 EXPECT_TRUE(FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response));
372 }

References error, fl_method_codec_decode_response(), and fl_standard_method_codec_new().

## ◆ TEST() [17/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseSuccessExtraData |
| ) |  |

Definition at line 338 of file fl_standard_method_codec_test.cc.

338 {
339 decode_error_response("000000", FL_MESSAGE_CODEC_ERROR,
340 FL_MESSAGE_CODEC_ERROR_FAILED);
341 }

References decode_error_response(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_FAILED.

## ◆ TEST() [18/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseSuccessList |
| ) |  |

Definition at line 296 of file fl_standard_method_codec_test.cc.

296 {
297 g_autoptr(FlValue) result = fl_value_new_list();
298 fl_value_append_take(result, fl_value_new_string("count"));
299 fl_value_append_take(result, fl_value_new_int(42));
300 decode_response_with_success("000c020705636f756e74032a000000", result);
301 }

References decode_response_with_success(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), fl_value_new_string(), and result.

## ◆ TEST() [19/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseSuccessNoData |
| ) |  |

Definition at line 333 of file fl_standard_method_codec_test.cc.

333 {
334 decode_error_response("00", FL_MESSAGE_CODEC_ERROR,
335 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA);
336 }

References decode_error_response(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

## ◆ TEST() [20/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseSuccessNull |
| ) |  |

Definition at line 286 of file fl_standard_method_codec_test.cc.

286 {
287 g_autoptr(FlValue) result = fl_value_new_null();
288 decode_response_with_success("0000", result);
289 }

References decode_response_with_success(), fl_value_new_null(), and result.

## ◆ TEST() [21/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseSuccessString |
| ) |  |

Definition at line 291 of file fl_standard_method_codec_test.cc.

291 {
292 g_autoptr(FlValue) result = fl_value_new_string("hello");
293 decode_response_with_success("00070568656c6c6f", result);
294 }

References decode_response_with_success(), fl_value_new_string(), and result.

## ◆ TEST() [22/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | DecodeResponseUnknownEnvelope |
| ) |  |

Definition at line 374 of file fl_standard_method_codec_test.cc.

374 {
375 decode_error_response("02", FL_MESSAGE_CODEC_ERROR,
376 FL_MESSAGE_CODEC_ERROR_FAILED);
377 }

References decode_error_response(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_FAILED.

## ◆ TEST() [23/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeErrorEnvelopeDetails |
| ) |  |

Definition at line 266 of file fl_standard_method_codec_test.cc.

266 {
267 g_autoptr(FlValue) details = fl_value_new_list();
268 fl_value_append_take(details, fl_value_new_string("count"));
269 fl_value_append_take(details, fl_value_new_int(42));
270 g_autofree gchar* hex_string =
271 encode_error_envelope("error", nullptr, details);
272 EXPECT_STREQ(hex_string, "0107056572726f72000c020705636f756e74032a000000");
273 }

References encode_error_envelope(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), and fl_value_new_string().

## ◆ TEST() [24/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeErrorEnvelopeEmptyCode |
| ) |  |

Definition at line 249 of file fl_standard_method_codec_test.cc.

249 {
250 g_autofree gchar* hex_string = encode_error_envelope("", nullptr, nullptr);
251 EXPECT_STREQ(hex_string, "0107000000");
252 }

References encode_error_envelope().

## ◆ TEST() [25/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeErrorEnvelopeMessage |
| ) |  |

Definition at line 260 of file fl_standard_method_codec_test.cc.

260 {
261 g_autofree gchar* hex_string =
262 encode_error_envelope("error", "message", nullptr);
263 EXPECT_STREQ(hex_string, "0107056572726f7207076d65737361676500");
264 }

References encode_error_envelope().

## ◆ TEST() [26/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeErrorEnvelopeMessageAndDetails |
| ) |  |

Definition at line 275 of file fl_standard_method_codec_test.cc.

275 {
276 g_autoptr(FlValue) details = fl_value_new_list();
277 fl_value_append_take(details, fl_value_new_string("count"));
278 fl_value_append_take(details, fl_value_new_int(42));
279 g_autofree gchar* hex_string =
280 encode_error_envelope("error", "message", details);
281 EXPECT_STREQ(
282 hex_string,
283 "0107056572726f7207076d6573736167650c020705636f756e74032a000000");
284 }

References encode_error_envelope(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), and fl_value_new_string().

## ◆ TEST() [27/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeErrorEnvelopeNonMessageOrDetails |
| ) |  |

Definition at line 254 of file fl_standard_method_codec_test.cc.

254 {
255 g_autofree gchar* hex_string =
256 encode_error_envelope("error", nullptr, nullptr);
257 EXPECT_STREQ(hex_string, "0107056572726f720000");
258 }

References encode_error_envelope().

## ◆ TEST() [28/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeMethodCallListArgs |
| ) |  |

Definition at line 166 of file fl_standard_method_codec_test.cc.

166 {
167 g_autoptr(FlValue) args = fl_value_new_list();
168 fl_value_append_take(args, fl_value_new_string("count"));
169 fl_value_append_take(args, fl_value_new_int(42));
170 g_autofree gchar* hex_string = encode_method_call("hello", args);
171 EXPECT_STREQ(hex_string, "070568656c6c6f0c020705636f756e74032a000000");
172 }

References args, encode_method_call(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), and fl_value_new_string().

## ◆ TEST() [29/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeMethodCallNullArgs |
| ) |  |

Definition at line 154 of file fl_standard_method_codec_test.cc.

154 {
155 g_autoptr(FlValue) value = fl_value_new_null();
156 g_autofree gchar* hex_string = encode_method_call("hello", value);
157 EXPECT_STREQ(hex_string, "070568656c6c6f00");
158 }

References encode_method_call(), fl_value_new_null(), and value.

## ◆ TEST() [30/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeMethodCallNullptrArgs |
| ) |  |

Definition at line 149 of file fl_standard_method_codec_test.cc.

149 {
150 g_autofree gchar* hex_string = encode_method_call("hello", nullptr);
151 EXPECT_STREQ(hex_string, "070568656c6c6f00");
152 }

References encode_method_call().

## ◆ TEST() [31/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeMethodCallStringArgs |
| ) |  |

Definition at line 160 of file fl_standard_method_codec_test.cc.

160 {
161 g_autoptr(FlValue) args = fl_value_new_string("world");
162 g_autofree gchar* hex_string = encode_method_call("hello", args);
163 EXPECT_STREQ(hex_string, "070568656c6c6f0705776f726c64");
164 }

References args, encode_method_call(), and fl_value_new_string().

## ◆ TEST() [32/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeSuccessEnvelopeList |
| ) |  |

Definition at line 241 of file fl_standard_method_codec_test.cc.

241 {
242 g_autoptr(FlValue) result = fl_value_new_list();
243 fl_value_append_take(result, fl_value_new_string("count"));
244 fl_value_append_take(result, fl_value_new_int(42));
245 g_autofree gchar* hex_string = encode_success_envelope(result);
246 EXPECT_STREQ(hex_string, "000c020705636f756e74032a000000");
247 }

References encode_success_envelope(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), fl_value_new_string(), and result.

## ◆ TEST() [33/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeSuccessEnvelopeNull |
| ) |  |

Definition at line 229 of file fl_standard_method_codec_test.cc.

229 {
230 g_autoptr(FlValue) result = fl_value_new_null();
231 g_autofree gchar* hex_string = encode_success_envelope(result);
232 EXPECT_STREQ(hex_string, "0000");
233 }

References encode_success_envelope(), fl_value_new_null(), and result.

## ◆ TEST() [34/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeSuccessEnvelopeNullptr |
| ) |  |

Definition at line 224 of file fl_standard_method_codec_test.cc.

224 {
225 g_autofree gchar* hex_string = encode_success_envelope(nullptr);
226 EXPECT_STREQ(hex_string, "0000");
227 }

References encode_success_envelope().

## ◆ TEST() [35/35]

TEST | ( | FlStandardMethodCodecTest | ,
|  | EncodeSuccessEnvelopeString |
| ) |  |

Definition at line 235 of file fl_standard_method_codec_test.cc.

235 {
236 g_autoptr(FlValue) result = fl_value_new_string("hello");
237 g_autofree gchar* hex_string = encode_success_envelope(result);
238 EXPECT_STREQ(hex_string, "00070568656c6c6f");
239 }

References encode_success_envelope(), fl_value_new_string(), and result.

fl_method_codec_encode_method_call
GBytes * fl_method_codec_encode_method_call(FlMethodCodec *self, const gchar *name, FlValue *args, GError **error)
Definition: fl_method_codec.cc:16
decode_error_response
static void decode_error_response(const char *hex_string, GQuark domain, gint code)
Definition: fl_standard_method_codec_test.cc:137
decode_response_with_success
static void decode_response_with_success(const char *hex_string, FlValue *result)
Definition: fl_standard_method_codec_test.cc:85
fl_standard_method_codec_new
G_MODULE_EXPORT FlStandardMethodCodec * fl_standard_method_codec_new()
Definition: fl_standard_method_codec.cc:248
encode_method_call
static gchar * encode_method_call(const gchar *name, FlValue *args)
Definition: fl_standard_method_codec_test.cc:15
fl_value_new_list
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:338
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
fl_value_new_null
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition: fl_value.cc:240
FL_VALUE_TYPE_LIST
@ FL_VALUE_TYPE_LIST
Definition: fl_value.h:69
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:251
fl_value_get_string
const G_MODULE_EXPORT gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:642
fl_method_error_response_get_message
const G_MODULE_EXPORT gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
Definition: fl_method_response.cc:166
FL_VALUE_TYPE_NULL
@ FL_VALUE_TYPE_NULL
Definition: fl_value.h:60
decode_method_call
static void decode_method_call(const char *hex_string, gchar **name, FlValue **args)
Definition: fl_standard_method_codec_test.cc:54
decode_error_method_call
static void decode_error_method_call(const char *hex_string, GQuark domain, gint code)
Definition: fl_standard_method_codec_test.cc:67
fl_value_get_int
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:628
fl_method_error_response_get_details
G_MODULE_EXPORT FlValue * fl_method_error_response_get_details(FlMethodErrorResponse *self)
Definition: fl_method_response.cc:172
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:428
fl_value_get_list_value
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition: fl_value.cc:735
FL_VALUE_TYPE_STRING
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:64
fl_method_codec_decode_method_call
gboolean fl_method_codec_decode_method_call(FlMethodCodec *self, GBytes *message, gchar **name, FlValue **args, GError **error)
Definition: fl_method_codec.cc:27
fl_method_success_response_get_result
G_MODULE_EXPORT FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *self)
Definition: fl_method_response.cc:138
FL_MESSAGE_CODEC_ERROR_FAILED
@ FL_MESSAGE_CODEC_ERROR_FAILED
Definition: fl_message_codec.h:33
fl_value_append_take
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:560
fl_method_codec_encode_success_envelope
GBytes * fl_method_codec_encode_success_envelope(FlMethodCodec *self, FlValue *result, GError **error)
Definition: fl_method_codec.cc:41
fl_value_get_length
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:684
fl_method_codec_decode_response
FlMethodResponse * fl_method_codec_decode_response(FlMethodCodec *self, GBytes *message, GError **error)
Definition: fl_method_codec.cc:62
fl_value_equal
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
Definition: fl_value.cc:433
FL_VALUE_TYPE_INT
@ FL_VALUE_TYPE_INT
Definition: fl_value.h:62
result
GAsyncResult * result
Definition: fl_text_input_plugin.cc:106
FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
Definition: fl_message_codec.h:34
fl_method_error_response_get_code
const G_MODULE_EXPORT gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)
Definition: fl_method_response.cc:160
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
decode_response_with_error
static void decode_response_with_error(const char *hex_string, const gchar *code, const gchar *error_message, FlValue *details)
Definition: fl_standard_method_codec_test.cc:102
encode_error_envelope
static gchar * encode_error_envelope(const gchar *error_code, const gchar *error_message, FlValue *details)
Definition: fl_standard_method_codec_test.cc:40
fl_method_codec_encode_error_envelope
GBytes * fl_method_codec_encode_error_envelope(FlMethodCodec *self, const gchar *code, const gchar *message, FlValue *details, GError **error)
Definition: fl_method_codec.cc:50
encode_success_envelope
static gchar * encode_success_envelope(FlValue *result)
Definition: fl_standard_method_codec_test.cc:28
value
uint8_t value
Definition: fl_standard_message_codec.cc:41
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:265
FL_MESSAGE_CODEC_ERROR
#define FL_MESSAGE_CODEC_ERROR
Definition: fl_message_codec.h:30