Flutter Engine
fl_test.h File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
#include <glib.h>
#include <stdint.h>

Go to the source code of this file.

Functions

G_BEGIN_DECLS GBytes * hex_string_to_bytes (const gchar *hex_string)
 
gchar * bytes_to_hex_string (GBytes *bytes)
 
FlEngine * make_mock_engine ()
 

Function Documentation

◆ bytes_to_hex_string()

gchar* bytes_to_hex_string ( GBytes *  bytes)

Definition at line 39 of file fl_test.cc.

Referenced by encode_error_envelope(), encode_message(), encode_method_call(), and encode_success_envelope().

39  {
40  GString* hex_string = g_string_new("");
41  size_t data_length;
42  const uint8_t* data =
43  static_cast<const uint8_t*>(g_bytes_get_data(bytes, &data_length));
44  for (size_t i = 0; i < data_length; i++)
45  g_string_append_printf(hex_string, "%02x", data[i]);
46  return g_string_free(hex_string, FALSE);
47 }

◆ hex_string_to_bytes()

G_BEGIN_DECLS GBytes* hex_string_to_bytes ( const gchar *  hex_string)

Definition at line 30 of file fl_test.cc.

References parse_hex8(), and value.

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

30  {
31  GByteArray* buffer = g_byte_array_new();
32  for (int i = 0; hex_string[i] != '\0' && hex_string[i + 1] != '\0'; i += 2) {
33  uint8_t value = parse_hex8(hex_string + i);
34  g_byte_array_append(buffer, &value, 1);
35  }
36  return g_byte_array_free_to_bytes(buffer);
37 }
uint8_t value
static uint8_t parse_hex8(const gchar *hex_string)
Definition: fl_test.cc:24

◆ make_mock_engine()

FlEngine* make_mock_engine ( )

Definition at line 49 of file fl_test.cc.

References engine, fl_dart_project_new(), fl_engine_new(), fl_engine_start(), and fl_mock_renderer_new().

49  {
50  g_autoptr(FlDartProject) project = fl_dart_project_new();
51  g_autoptr(FlMockRenderer) renderer = fl_mock_renderer_new();
52  g_autoptr(FlEngine) engine = fl_engine_new(project, FL_RENDERER(renderer));
53  g_autoptr(GError) engine_error = nullptr;
54  EXPECT_TRUE(fl_engine_start(engine, &engine_error));
55  EXPECT_EQ(engine_error, nullptr);
56 
57  return static_cast<FlEngine*>(g_object_ref(engine));
58 }
FlMockRenderer * fl_mock_renderer_new()
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:353
FlEngine * fl_engine_new(FlDartProject *project, FlRenderer *renderer)
Definition: fl_engine.cc:338
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()