| Flutter Linux Embedder |

Functions
fl_json_method_codec_test.cc File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_method_codec.h"`
`#include <cstring>`
`#include "flutter/shell/platform/linux/fl_method_codec_private.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_message_codec.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_message_codec.h"`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Functions
static gchar * | message_to_text (GBytes *message)
static GBytes * | text_to_message (const gchar *text)
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 *text, gchar **name, FlValue **args)
static void | decode_error_method_call (const char *text, GQuark domain, gint code)
static void | decode_response_with_success (const char *text, FlValue *result)
static void | decode_response_with_error (const char *text, const gchar *code, const gchar *error_message, FlValue *details)
static void | decode_error_response (const char *text, GQuark domain, gint code)
| TEST (FlJsonMethodCodecTest, EncodeMethodCallNullptrArgs)
| TEST (FlJsonMethodCodecTest, EncodeMethodCallNullArgs)
| TEST (FlJsonMethodCodecTest, EncodeMethodCallStringArgs)
| TEST (FlJsonMethodCodecTest, EncodeMethodCallListArgs)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallNoArgs)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallNullArgs)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallStringArgs)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallListArgs)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallNoData)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallNoMethodOrArgs)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallInvalidJson)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallWrongType)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallNoMethod)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallNoTerminator)
| TEST (FlJsonMethodCodecTest, DecodeMethodCallExtraData)
| TEST (FlJsonMethodCodecTest, EncodeSuccessEnvelopeNullptr)
| TEST (FlJsonMethodCodecTest, EncodeSuccessEnvelopeNull)
| TEST (FlJsonMethodCodecTest, EncodeSuccessEnvelopeString)
| TEST (FlJsonMethodCodecTest, EncodeSuccessEnvelopeList)

## Function Documentation

## ◆ decode_error_method_call()

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

Definition at line 77 of file fl_json_method_codec_test.cc.

79 {
80 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
81 g_autoptr(GBytes) data = text_to_message(text);
82 g_autoptr(GError) error = nullptr;
83 g_autofree gchar* name = nullptr;
84 g_autoptr(FlValue) args = nullptr;
85 gboolean result = fl_method_codec_decode_method_call(
86 FL_METHOD_CODEC(codec), data, &name, &args, &error);
87 EXPECT_FALSE(result);
88 EXPECT_EQ(name, nullptr);
89 EXPECT_EQ(args, nullptr);
90 EXPECT_TRUE(g_error_matches(error, domain, code));
91 }
g_autoptr
g_autoptr(GMutexLocker) locker
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
fl_json_method_codec_new
G_MODULE_EXPORT FlJsonMethodCodec * fl_json_method_codec_new()
Definition: fl_json_method_codec.cc:205
text_to_message
static GBytes * text_to_message(const gchar *text)
Definition: fl_json_method_codec_test.cc:23
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
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42

References args, error, fl_json_method_codec_new(), fl_method_codec_decode_method_call(), g_autoptr(), and text_to_message().

Referenced by TEST().

## ◆ decode_error_response()

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

Definition at line 146 of file fl_json_method_codec_test.cc.

146 {
147 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
148 g_autoptr(GBytes) message = text_to_message(text);
149 g_autoptr(GError) error = nullptr;
150 g_autoptr(FlMethodResponse) response =
151 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
152 EXPECT_EQ(response, nullptr);
153 EXPECT_TRUE(g_error_matches(error, domain, code));
154 }
fl_method_codec_decode_response
FlMethodResponse * fl_method_codec_decode_response(FlMethodCodec *self, GBytes *message, GError **error)
Definition: fl_method_codec.cc:88

References error, fl_json_method_codec_new(), fl_method_codec_decode_response(), g_autoptr(), and text_to_message().

## ◆ decode_method_call()

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

Definition at line 66 of file fl_json_method_codec_test.cc.

66 {
67 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
68 g_autoptr(GBytes) data = text_to_message(text);
69 g_autoptr(GError) error = nullptr;
70 gboolean result = fl_method_codec_decode_method_call(
71 FL_METHOD_CODEC(codec), data, name, args, &error);
72 EXPECT_TRUE(result);
73 EXPECT_EQ(error, nullptr);
74 }

References args, error, fl_json_method_codec_new(), fl_method_codec_decode_method_call(), g_autoptr(), and text_to_message().

Referenced by TEST().

## ◆ decode_response_with_error()

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

Definition at line 110 of file fl_json_method_codec_test.cc.

113 {
114 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
115 g_autoptr(GBytes) message = text_to_message(text);
116 g_autoptr(GError) error = nullptr;
117 g_autoptr(FlMethodResponse) response =
118 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
119 ASSERT_NE(response, nullptr);
120 EXPECT_EQ(error, nullptr);
121 ASSERT_TRUE(FL_IS_METHOD_ERROR_RESPONSE(response));
122 EXPECT_STREQ(
123 fl_method_error_response_get_code(FL_METHOD_ERROR_RESPONSE(response)),
124 code);
125 if (error_message == nullptr) {
126 EXPECT_EQ(fl_method_error_response_get_message(
127 FL_METHOD_ERROR_RESPONSE(response)),
128 nullptr);
129 } else {
130 EXPECT_STREQ(fl_method_error_response_get_message(
131 FL_METHOD_ERROR_RESPONSE(response)),
132 error_message);
133 }
134 if (details == nullptr) {
135 EXPECT_EQ(fl_method_error_response_get_details(
136 FL_METHOD_ERROR_RESPONSE(response)),
137 nullptr);
138 } else {
139 EXPECT_TRUE(fl_value_equal(fl_method_error_response_get_details(
140 FL_METHOD_ERROR_RESPONSE(response)),
141 details));
142 }
143 }
fl_method_error_response_get_code
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)
Definition: fl_method_response.cc:160
fl_method_error_response_get_message
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
Definition: fl_method_response.cc:166
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_equal
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
Definition: fl_value.cc:471

References error, fl_json_method_codec_new(), fl_method_codec_decode_response(), fl_method_error_response_get_code(), fl_method_error_response_get_details(), fl_method_error_response_get_message(), fl_value_equal(), g_autoptr(), and text_to_message().

## ◆ decode_response_with_success()

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

Definition at line 94 of file fl_json_method_codec_test.cc.

94 {
95 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
96 g_autoptr(GBytes) message = text_to_message(text);
97 g_autoptr(GError) error = nullptr;
98 g_autoptr(FlMethodResponse) response =
99 fl_method_codec_decode_response(FL_METHOD_CODEC(codec), message, &error);
100 ASSERT_NE(response, nullptr);
101 EXPECT_EQ(error, nullptr);
102 ASSERT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
103 EXPECT_TRUE(fl_value_equal(fl_method_success_response_get_result(
104 FL_METHOD_SUCCESS_RESPONSE(response)),
105 result));
106 }
fl_method_success_response_get_result
G_MODULE_EXPORT FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *self)
Definition: fl_method_response.cc:138

References error, fl_json_method_codec_new(), fl_method_codec_decode_response(), fl_method_success_response_get_result(), fl_value_equal(), g_autoptr(), and text_to_message().

## ◆ encode_error_envelope()

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

Definition at line 52 of file fl_json_method_codec_test.cc.

54 {
55 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
56 g_autoptr(GError) error = nullptr;
57 g_autoptr(GBytes) message = fl_method_codec_encode_error_envelope(
58 FL_METHOD_CODEC(codec), error_code, error_message, details, &error);
59 EXPECT_NE(message, nullptr);
60 EXPECT_EQ(error, nullptr);
61
62 return message_to_text(message);
63 }
message_to_text
static gchar * message_to_text(GBytes *message)
Definition: fl_json_method_codec_test.cc:15
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

References error, fl_json_method_codec_new(), fl_method_codec_encode_error_envelope(), g_autoptr(), and message_to_text().

## ◆ encode_method_call()

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

Definition at line 28 of file fl_json_method_codec_test.cc.

28 {
29 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
30 g_autoptr(GError) error = nullptr;
31 g_autoptr(GBytes) message = fl_method_codec_encode_method_call(
32 FL_METHOD_CODEC(codec), name, args, &error);
33 EXPECT_NE(message, nullptr);
34 EXPECT_EQ(error, nullptr);
35
36 return message_to_text(message);
37 }
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

References args, error, fl_json_method_codec_new(), fl_method_codec_encode_method_call(), g_autoptr(), and message_to_text().

Referenced by TEST().

## ◆ encode_success_envelope()

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

Definition at line 40 of file fl_json_method_codec_test.cc.

40 {
41 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
42 g_autoptr(GError) error = nullptr;
43 g_autoptr(GBytes) message = fl_method_codec_encode_success_envelope(
44 FL_METHOD_CODEC(codec), result, &error);
45 EXPECT_NE(message, nullptr);
46 EXPECT_EQ(error, nullptr);
47
48 return message_to_text(message);
49 }
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

References error, fl_json_method_codec_new(), fl_method_codec_encode_success_envelope(), g_autoptr(), and message_to_text().

Referenced by TEST().

## ◆ message_to_text()

static gchar* message_to_text | ( | GBytes * | message | ) |
| static

Definition at line 15 of file fl_json_method_codec_test.cc.

15 {
16 size_t data_length;
17 const gchar* data =
18 static_cast<const gchar*>(g_bytes_get_data(message, &data_length));
19 return g_strndup(data, data_length);
20 }

Referenced by encode_error_envelope(), encode_method_call(), encode_success_envelope(), fl_test_codec_decode_method_call(), fl_test_codec_decode_response(), and TEST().

## ◆ TEST() [1/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallExtraData |
| ) |  |

Definition at line 255 of file fl_json_method_codec_test.cc.

255 {
256 decode_error_method_call("{\"method\":\"hello\"}XXX",
257 FL_JSON_MESSAGE_CODEC_ERROR,
258 FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON);
259 }
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON
Definition: fl_json_message_codec.h:31
FL_JSON_MESSAGE_CODEC_ERROR
#define FL_JSON_MESSAGE_CODEC_ERROR
Definition: fl_json_message_codec.h:27
decode_error_method_call
static void decode_error_method_call(const char *text, GQuark domain, gint code)
Definition: fl_json_method_codec_test.cc:77

References decode_error_method_call(), FL_JSON_MESSAGE_CODEC_ERROR, and FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON.

## ◆ TEST() [2/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallInvalidJson |
| ) |  |

Definition at line 234 of file fl_json_method_codec_test.cc.

234 {
235 decode_error_method_call("X", FL_JSON_MESSAGE_CODEC_ERROR,
236 FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON);
237 }

References decode_error_method_call(), FL_JSON_MESSAGE_CODEC_ERROR, and FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON.

## ◆ TEST() [3/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallListArgs |
| ) |  |

Definition at line 206 of file fl_json_method_codec_test.cc.

206 {
207 g_autofree gchar* name = nullptr;
208 g_autoptr(FlValue) args = nullptr;
209 decode_method_call("{\"method\":\"hello\",\"args\":[\"count\",42]}", &name,
210 &args);
211 EXPECT_STREQ(name, "hello");
212 ASSERT_EQ(fl_value_get_type(args), FL_VALUE_TYPE_LIST);
213 EXPECT_EQ(fl_value_get_length(args), static_cast<size_t>(2));
214
215 FlValue* arg0 = fl_value_get_list_value(args, 0);
216 ASSERT_EQ(fl_value_get_type(arg0), FL_VALUE_TYPE_STRING);
217 EXPECT_STREQ(fl_value_get_string(arg0), "count");
218
219 FlValue* arg1 = fl_value_get_list_value(args, 1);
220 ASSERT_EQ(fl_value_get_type(arg1), FL_VALUE_TYPE_INT);
221 EXPECT_EQ(fl_value_get_int(arg1), 42);
222 }
decode_method_call
static void decode_method_call(const char *text, gchar **name, FlValue **args)
Definition: fl_json_method_codec_test.cc:66
fl_value_get_list_value
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition: fl_value.cc:776
fl_value_get_int
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:668
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
fl_value_get_string
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:682
fl_value_get_length
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
FL_VALUE_TYPE_STRING
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:68
FL_VALUE_TYPE_INT
@ FL_VALUE_TYPE_INT
Definition: fl_value.h:66
FL_VALUE_TYPE_LIST
@ FL_VALUE_TYPE_LIST
Definition: fl_value.h:73

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, FL_VALUE_TYPE_STRING, and g_autoptr().

## ◆ TEST() [4/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallNoArgs |
| ) |  |

Definition at line 181 of file fl_json_method_codec_test.cc.

181 {
182 g_autofree gchar* name = nullptr;
183 g_autoptr(FlValue) args = nullptr;
184 decode_method_call("{\"method\":\"hello\"}", &name, &args);
185 EXPECT_STREQ(name, "hello");
186 ASSERT_EQ(args, nullptr);
187 }

References args, decode_method_call(), and g_autoptr().

## ◆ TEST() [5/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallNoData |
| ) |  |

Definition at line 224 of file fl_json_method_codec_test.cc.

224 {
225 decode_error_method_call("", FL_JSON_MESSAGE_CODEC_ERROR,
226 FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON);
227 }

References decode_error_method_call(), FL_JSON_MESSAGE_CODEC_ERROR, and FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON.

## ◆ TEST() [6/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallNoMethod |
| ) |  |

Definition at line 244 of file fl_json_method_codec_test.cc.

244 {
245 decode_error_method_call("{\"args\":\"world\"}", FL_MESSAGE_CODEC_ERROR,
246 FL_MESSAGE_CODEC_ERROR_FAILED);
247 }
FL_MESSAGE_CODEC_ERROR_FAILED
@ FL_MESSAGE_CODEC_ERROR_FAILED
Definition: fl_message_codec.h:33
FL_MESSAGE_CODEC_ERROR
#define FL_MESSAGE_CODEC_ERROR
Definition: fl_message_codec.h:30

References decode_error_method_call(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_FAILED.

## ◆ TEST() [7/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallNoMethodOrArgs |
| ) |  |

Definition at line 229 of file fl_json_method_codec_test.cc.

229 {
230 decode_error_method_call("{}", FL_MESSAGE_CODEC_ERROR,
231 FL_MESSAGE_CODEC_ERROR_FAILED);
232 }

References decode_error_method_call(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_FAILED.

## ◆ TEST() [8/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallNoTerminator |
| ) |  |

Definition at line 249 of file fl_json_method_codec_test.cc.

249 {
250 decode_error_method_call("{\"method\":\"hello\",\"args\":\"world\"",
251 FL_JSON_MESSAGE_CODEC_ERROR,
252 FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON);
253 }

References decode_error_method_call(), FL_JSON_MESSAGE_CODEC_ERROR, and FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON.

## ◆ TEST() [9/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallNullArgs |
| ) |  |

Definition at line 189 of file fl_json_method_codec_test.cc.

189 {
190 g_autofree gchar* name = nullptr;
191 g_autoptr(FlValue) args = nullptr;
192 decode_method_call("{\"method\":\"hello\",\"args\":null}", &name, &args);
193 EXPECT_STREQ(name, "hello");
194 ASSERT_EQ(fl_value_get_type(args), FL_VALUE_TYPE_NULL);
195 }
FL_VALUE_TYPE_NULL
@ FL_VALUE_TYPE_NULL
Definition: fl_value.h:64

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

## ◆ TEST() [10/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallStringArgs |
| ) |  |

Definition at line 197 of file fl_json_method_codec_test.cc.

197 {
198 g_autofree gchar* name = nullptr;
199 g_autoptr(FlValue) args = nullptr;
200 decode_method_call("{\"method\":\"hello\",\"args\":\"world\"}", &name, &args);
201 EXPECT_STREQ(name, "hello");
202 ASSERT_EQ(fl_value_get_type(args), FL_VALUE_TYPE_STRING);
203 EXPECT_STREQ(fl_value_get_string(args), "world");
204 }

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

## ◆ TEST() [11/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | DecodeMethodCallWrongType |
| ) |  |

Definition at line 239 of file fl_json_method_codec_test.cc.

239 {
240 decode_error_method_call("42", FL_MESSAGE_CODEC_ERROR,
241 FL_MESSAGE_CODEC_ERROR_FAILED);
242 }

References decode_error_method_call(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_FAILED.

## ◆ TEST() [12/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | EncodeMethodCallListArgs |
| ) |  |

Definition at line 173 of file fl_json_method_codec_test.cc.

173 {
174 g_autoptr(FlValue) args = fl_value_new_list();
175 fl_value_append_take(args, fl_value_new_string("count"));
176 fl_value_append_take(args, fl_value_new_int(42));
177 g_autofree gchar* text = encode_method_call("hello", args);
178 EXPECT_STREQ(text, "{\"method\":\"hello\",\"args\":[\"count\",42]}");
179 }
encode_method_call
static gchar * encode_method_call(const gchar *name, FlValue *args)
Definition: fl_json_method_codec_test.cc:28
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276
fl_value_new_list
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:349
fl_value_append_take
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:600
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262

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

## ◆ TEST() [13/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | EncodeMethodCallNullArgs |
| ) |  |

Definition at line 161 of file fl_json_method_codec_test.cc.

161 {
162 g_autoptr(FlValue) value = fl_value_new_null();
163 g_autofree gchar* text = encode_method_call("hello", value);
164 EXPECT_STREQ(text, "{\"method\":\"hello\",\"args\":null}");
165 }
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_value_new_null
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition: fl_value.cc:251

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

## ◆ TEST() [14/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | EncodeMethodCallNullptrArgs |
| ) |  |

Definition at line 156 of file fl_json_method_codec_test.cc.

156 {
157 g_autofree gchar* text = encode_method_call("hello", nullptr);
158 EXPECT_STREQ(text, "{\"method\":\"hello\",\"args\":null}");
159 }

References encode_method_call().

## ◆ TEST() [15/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | EncodeMethodCallStringArgs |
| ) |  |

Definition at line 167 of file fl_json_method_codec_test.cc.

167 {
168 g_autoptr(FlValue) args = fl_value_new_string("world");
169 g_autofree gchar* text = encode_method_call("hello", args);
170 EXPECT_STREQ(text, "{\"method\":\"hello\",\"args\":\"world\"}");
171 }

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

## ◆ TEST() [16/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | EncodeSuccessEnvelopeList |
| ) |  |

Definition at line 278 of file fl_json_method_codec_test.cc.

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

## ◆ TEST() [17/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | EncodeSuccessEnvelopeNull |
| ) |  |

Definition at line 266 of file fl_json_method_codec_test.cc.

266 {
267 g_autoptr(FlValue) result = fl_value_new_null();
268 g_autofree gchar* text = encode_success_envelope(result);
269 EXPECT_STREQ(text, "[null]");
270 }
encode_success_envelope
static gchar * encode_success_envelope(FlValue *result)
Definition: fl_json_method_codec_test.cc:40

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

## ◆ TEST() [18/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | EncodeSuccessEnvelopeNullptr |
| ) |  |

Definition at line 261 of file fl_json_method_codec_test.cc.

261 {
262 g_autofree gchar* text = encode_success_envelope(nullptr);
263 EXPECT_STREQ(text, "[null]");
264 }

References encode_success_envelope().

## ◆ TEST() [19/19]

TEST | ( | FlJsonMethodCodecTest | ,
|  | EncodeSuccessEnvelopeString |
| ) |  |

Definition at line 272 of file fl_json_method_codec_test.cc.

272 {
273 g_autoptr(FlValue) result = fl_value_new_string("hello");
274 g_autofree gchar* text = encode_success_envelope(result);
275 EXPECT_STREQ(text, "[\"hello\"]");
276 }

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

## ◆ text_to_message()

static GBytes* text_to_message | ( | const gchar * | text | ) |
| static

Definition at line 23 of file fl_json_method_codec_test.cc.

23 {
24 return g_bytes_new(text, strlen(text));
25 }

Referenced by decode_error_method_call(), decode_error_response(), decode_method_call(), decode_response_with_error(), and decode_response_with_success().