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 ()
 
FlEngine * make_mock_engine_with_project (FlDartProject *project)
 

Function Documentation

◆ bytes_to_hex_string()

gchar* bytes_to_hex_string ( GBytes *  bytes)

Definition at line 40 of file fl_test.cc.

References flutter::data, and FALSE.

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

40  {
41  GString* hex_string = g_string_new("");
42  size_t data_length;
43  const uint8_t* data =
44  static_cast<const uint8_t*>(g_bytes_get_data(bytes, &data_length));
45  for (size_t i = 0; i < data_length; i++) {
46  g_string_append_printf(hex_string, "%02x", data[i]);
47  }
48  return g_string_free(hex_string, FALSE);
49 }
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41
return FALSE

◆ hex_string_to_bytes()

G_BEGIN_DECLS GBytes* hex_string_to_bytes ( const gchar *  hex_string)

Definition at line 31 of file fl_test.cc.

References buffer, 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().

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

◆ make_mock_engine()

FlEngine* make_mock_engine ( )

Definition at line 51 of file fl_test.cc.

References fl_dart_project_new(), and make_mock_engine_with_project().

51  {
52  g_autoptr(FlDartProject) project = fl_dart_project_new();
53  return make_mock_engine_with_project(project);
54 }
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
FlEngine * make_mock_engine_with_project(FlDartProject *project)
Definition: fl_test.cc:56

◆ make_mock_engine_with_project()

FlEngine* make_mock_engine_with_project ( FlDartProject *  project)

Definition at line 56 of file fl_test.cc.

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

Referenced by make_mock_engine(), and TEST().

56  {
57  g_autoptr(FlMockRenderer) renderer = fl_mock_renderer_new();
58  g_autoptr(FlEngine) engine = fl_engine_new(project, FL_RENDERER(renderer));
59  g_autoptr(GError) engine_error = nullptr;
60  EXPECT_TRUE(fl_engine_start(engine, &engine_error));
61  EXPECT_EQ(engine_error, nullptr);
62 
63  return static_cast<FlEngine*>(g_object_ref(engine));
64 }
FlMockRenderer * fl_mock_renderer_new()
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:422
FlEngine * fl_engine_new(FlDartProject *project, FlRenderer *renderer)
Definition: fl_engine.cc:407