Flutter Engine
fl_dart_project_test.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_dart_project.h"
#include <gmodule.h>
#include <cstdlib>
#include "flutter/shell/platform/linux/fl_dart_project_private.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 TEST (FlDartProjectTest, GetPaths)
 
 TEST (FlDartProjectTest, EnableMirrors)
 
 TEST (FlDartProjectTest, SwitchesEmpty)
 
 TEST (FlDartProjectTest, Switches)
 

Function Documentation

◆ TEST() [1/4]

TEST ( FlDartProjectTest  ,
GetPaths   
)

Definition at line 14 of file fl_dart_project_test.cc.

References fl_dart_project_get_aot_library_path(), fl_dart_project_get_assets_path(), fl_dart_project_get_icu_data_path(), and fl_dart_project_new().

14  {
15  g_autoptr(FlDartProject) project = fl_dart_project_new();
16  g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", nullptr);
17  ASSERT_TRUE(exe_path != nullptr);
18  g_autofree gchar* dir = g_path_get_dirname(exe_path);
19  g_autofree gchar* expected_aot_library_path =
20  g_build_filename(dir, "lib", "libapp.so", nullptr);
21  EXPECT_STREQ(fl_dart_project_get_aot_library_path(project),
22  expected_aot_library_path);
23  g_autofree gchar* expected_assets_path =
24  g_build_filename(dir, "data", "flutter_assets", nullptr);
25  EXPECT_STREQ(fl_dart_project_get_assets_path(project), expected_assets_path);
26  g_autofree gchar* expected_icu_data_path =
27  g_build_filename(dir, "data", "icudtl.dat", nullptr);
28  EXPECT_STREQ(fl_dart_project_get_icu_data_path(project),
29  expected_icu_data_path);
30 }
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)

◆ TEST() [2/4]

TEST ( FlDartProjectTest  ,
EnableMirrors   
)

Definition at line 32 of file fl_dart_project_test.cc.

References fl_dart_project_get_enable_mirrors(), fl_dart_project_new(), fl_dart_project_set_enable_mirrors(), and TRUE.

32  {
33  g_autoptr(FlDartProject) project = fl_dart_project_new();
34  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
35  EXPECT_FALSE(fl_dart_project_get_enable_mirrors(project));
37  EXPECT_TRUE(fl_dart_project_get_enable_mirrors(project));
38  G_GNUC_END_IGNORE_DEPRECATIONS
39 }
G_MODULE_EXPORT gboolean fl_dart_project_get_enable_mirrors(FlDartProject *self)
return TRUE
Definition: fl_view.cc:107
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
G_MODULE_EXPORT void fl_dart_project_set_enable_mirrors(FlDartProject *self, gboolean enable_mirrors)

◆ TEST() [3/4]

TEST ( FlDartProjectTest  ,
SwitchesEmpty   
)

Definition at line 41 of file fl_dart_project_test.cc.

References fl_dart_project_get_switches(), and fl_dart_project_new().

41  {
42  g_autoptr(FlDartProject) project = fl_dart_project_new();
43 
44  // Clear the main environment variable, since test order is not guaranteed.
45  unsetenv("FLUTTER_ENGINE_SWITCHES");
46 
47  g_autoptr(GPtrArray) switches = fl_dart_project_get_switches(project);
48 
49  EXPECT_EQ(switches->len, 0U);
50 }
GPtrArray * fl_dart_project_get_switches(FlDartProject *self)
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()

◆ TEST() [4/4]

TEST ( FlDartProjectTest  ,
Switches   
)

Definition at line 53 of file fl_dart_project_test.cc.

References fl_dart_project_get_switches(), and fl_dart_project_new().

53  {
54  g_autoptr(FlDartProject) project = fl_dart_project_new();
55 
56  setenv("FLUTTER_ENGINE_SWITCHES", "2", 1);
57  setenv("FLUTTER_ENGINE_SWITCH_1", "abc", 1);
58  setenv("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"", 1);
59 
60  g_autoptr(GPtrArray) switches = fl_dart_project_get_switches(project);
61  EXPECT_EQ(switches->len, 2U);
62  EXPECT_STREQ(static_cast<const char*>(g_ptr_array_index(switches, 0)),
63  "--abc");
64  EXPECT_STREQ(static_cast<const char*>(g_ptr_array_index(switches, 1)),
65  "--foo=\"bar, baz\"");
66 }
GPtrArray * fl_dart_project_get_switches(FlDartProject *self)
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()