| Flutter Linux Embedder |

fl_dart_project_test.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/shell/platform/linux/public/flutter_linux/fl_dart_project.h"
6
7 #include <gmodule.h>
8
9 #include <cstdlib>
10
11 #include "gtest/gtest.h"
12
13 TEST(FlDartProjectTest, GetPaths) {
14 g_autoptr(FlDartProject) project = fl_dart_project_new();
15 g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", nullptr);
16 ASSERT_TRUE(exe_path != nullptr);
17 g_autofree gchar* dir = g_path_get_dirname(exe_path);
18 g_autofree gchar* expected_aot_library_path =
19 g_build_filename(dir, "lib", "libapp.so", nullptr);
20 EXPECT_STREQ(fl_dart_project_get_aot_library_path(project),
21 expected_aot_library_path);
22 g_autofree gchar* expected_assets_path =
23 g_build_filename(dir, "data", "flutter_assets", nullptr);
24 EXPECT_STREQ(fl_dart_project_get_assets_path(project), expected_assets_path);
25 g_autofree gchar* expected_icu_data_path =
26 g_build_filename(dir, "data", "icudtl.dat", nullptr);
27 EXPECT_STREQ(fl_dart_project_get_icu_data_path(project),
28 expected_icu_data_path);
29 }
30
31 TEST(FlDartProjectTest, OverrideAotLibraryPath) {
32 g_autoptr(FlDartProject) project = fl_dart_project_new();
33
34 char aot_library_path[] = "/normal/tuesday/night/for/shia/labeouf";
35 fl_dart_project_set_aot_library_path(project, aot_library_path);
36 EXPECT_STREQ(fl_dart_project_get_aot_library_path(project), aot_library_path);
37 }
38
39 TEST(FlDartProjectTest, OverrideAssetsPath) {
40 g_autoptr(FlDartProject) project = fl_dart_project_new();
41
42 char assets_path[] = "/normal/tuesday/night/for/shia/labeouf";
43 fl_dart_project_set_assets_path(project, assets_path);
44 EXPECT_STREQ(fl_dart_project_get_assets_path(project), assets_path);
45 }
46
47 TEST(FlDartProjectTest, OverrideIcuDataPath) {
48 g_autoptr(FlDartProject) project = fl_dart_project_new();
49
50 char icu_data_path[] = "/living/in/the/woods/icudtl.dat";
51 fl_dart_project_set_icu_data_path(project, icu_data_path);
52 EXPECT_STREQ(fl_dart_project_get_icu_data_path(project), icu_data_path);
53 }
54
55 TEST(FlDartProjectTest, DartEntrypointArgs) {
56 g_autoptr(FlDartProject) project = fl_dart_project_new();
57
58 char** retrieved_args =
59 fl_dart_project_get_dart_entrypoint_arguments(project);
60
61 EXPECT_EQ(retrieved_args, nullptr);
62
63 GPtrArray* args_array = g_ptr_array_new();
64 g_ptr_array_add(args_array, const_cast<char*>("arg_one"));
65 g_ptr_array_add(args_array, const_cast<char*>("arg_two"));
66 g_ptr_array_add(args_array, const_cast<char*>("arg_three"));
67 g_ptr_array_add(args_array, nullptr);
68 gchar** args = reinterpret_cast<gchar**>(g_ptr_array_free(args_array, false));
69
70 fl_dart_project_set_dart_entrypoint_arguments(project, args);
71
72 retrieved_args = fl_dart_project_get_dart_entrypoint_arguments(project);
73
74 // FlDartProject should have done a deep copy of the args
75 EXPECT_NE(retrieved_args, args);
76
77 EXPECT_EQ(g_strv_length(retrieved_args), 3U);
78 }
g_autoptr
g_autoptr(FlEngine) engine
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:52
fl_dart_project_get_aot_library_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
Definition: fl_dart_project.cc:74
fl_dart_project_get_dart_entrypoint_arguments
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
Definition: fl_dart_project.cc:106
fl_dart_project_set_icu_data_path
G_MODULE_EXPORT void fl_dart_project_set_icu_data_path(FlDartProject *self, gchar *path)
Definition: fl_dart_project.cc:93
fl_dart_project_set_dart_entrypoint_arguments
G_MODULE_EXPORT void fl_dart_project_set_dart_entrypoint_arguments(FlDartProject *self, char **argv)
Definition: fl_dart_project.cc:112
fl_dart_project_get_icu_data_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
Definition: fl_dart_project.cc:100
fl_dart_project_get_assets_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
Definition: fl_dart_project.cc:87
fl_dart_project_set_assets_path
G_MODULE_EXPORT void fl_dart_project_set_assets_path(FlDartProject *self, gchar *path)
Definition: fl_dart_project.cc:80
fl_dart_project_set_aot_library_path
G_MODULE_EXPORT void fl_dart_project_set_aot_library_path(FlDartProject *self, const gchar *path)
Definition: fl_dart_project.cc:67
fl_dart_project.h
TEST
TEST(FlDartProjectTest, GetPaths)
Definition: fl_dart_project_test.cc:13
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89