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 
6 
7 #include <gmodule.h>
8 
9 #include <cstdlib>
10 
11 #include "flutter/shell/platform/linux/testing/linux_test.h"
12 #include "gtest/gtest.h"
13 
14 class FlDartProjectTest : public flutter::testing::LinuxTest {};
15 
17  g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", nullptr);
18  ASSERT_TRUE(exe_path != nullptr);
19  g_autofree gchar* dir = g_path_get_dirname(exe_path);
20  g_autofree gchar* expected_aot_library_path =
21  g_build_filename(dir, "lib", "libapp.so", nullptr);
22  EXPECT_STREQ(fl_dart_project_get_aot_library_path(project),
23  expected_aot_library_path);
24  g_autofree gchar* expected_assets_path =
25  g_build_filename(dir, "data", "flutter_assets", nullptr);
26  EXPECT_STREQ(fl_dart_project_get_assets_path(project), expected_assets_path);
27  g_autofree gchar* expected_icu_data_path =
28  g_build_filename(dir, "data", "icudtl.dat", nullptr);
29  EXPECT_STREQ(fl_dart_project_get_icu_data_path(project),
30  expected_icu_data_path);
31 }
32 
33 TEST_F(FlDartProjectTest, OverrideAotLibraryPath) {
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_F(FlDartProjectTest, OverrideAssetsPath) {
40  char assets_path[] = "/normal/tuesday/night/for/shia/labeouf";
41  fl_dart_project_set_assets_path(project, assets_path);
42  EXPECT_STREQ(fl_dart_project_get_assets_path(project), assets_path);
43 }
44 
45 TEST_F(FlDartProjectTest, OverrideIcuDataPath) {
46  char icu_data_path[] = "/living/in/the/woods/icudtl.dat";
47  fl_dart_project_set_icu_data_path(project, icu_data_path);
48  EXPECT_STREQ(fl_dart_project_get_icu_data_path(project), icu_data_path);
49 }
50 
51 TEST_F(FlDartProjectTest, DartEntrypointArgs) {
52  char** retrieved_args =
54 
55  EXPECT_EQ(retrieved_args, nullptr);
56 
57  GPtrArray* args_array = g_ptr_array_new();
58  g_ptr_array_add(args_array, const_cast<char*>("arg_one"));
59  g_ptr_array_add(args_array, const_cast<char*>("arg_two"));
60  g_ptr_array_add(args_array, const_cast<char*>("arg_three"));
61  g_ptr_array_add(args_array, nullptr);
62  gchar** args = reinterpret_cast<gchar**>(g_ptr_array_free(args_array, false));
63 
65 
66  retrieved_args = fl_dart_project_get_dart_entrypoint_arguments(project);
67 
68  // FlDartProject should have done a deep copy of the args
69  EXPECT_NE(retrieved_args, args);
70 
71  EXPECT_EQ(g_strv_length(retrieved_args), 3U);
72 }
73 
74 TEST_F(FlDartProjectTest, EnableImpeller) {
75  EXPECT_TRUE(fl_dart_project_get_enable_impeller(project));
76 
78  EXPECT_FALSE(fl_dart_project_get_enable_impeller(project));
79 
81  EXPECT_TRUE(fl_dart_project_get_enable_impeller(project));
82 }
83 
84 TEST_F(FlDartProjectTest, EnableFlutterGpu) {
85  EXPECT_FALSE(fl_dart_project_get_enable_flutter_gpu(project));
86 
88  EXPECT_TRUE(fl_dart_project_get_enable_flutter_gpu(project));
89 
91  EXPECT_FALSE(fl_dart_project_get_enable_flutter_gpu(project));
92 }
return TRUE
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
G_MODULE_EXPORT gboolean fl_dart_project_get_enable_impeller(FlDartProject *project)
G_MODULE_EXPORT void fl_dart_project_set_enable_impeller(FlDartProject *project, gboolean enable_impeller)
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
G_MODULE_EXPORT void fl_dart_project_set_icu_data_path(FlDartProject *self, gchar *path)
G_MODULE_EXPORT gboolean fl_dart_project_get_enable_flutter_gpu(FlDartProject *project)
G_MODULE_EXPORT void fl_dart_project_set_dart_entrypoint_arguments(FlDartProject *self, char **argv)
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
G_MODULE_EXPORT void fl_dart_project_set_enable_flutter_gpu(FlDartProject *project, gboolean enable_flutter_gpu)
G_MODULE_EXPORT void fl_dart_project_set_assets_path(FlDartProject *self, gchar *path)
G_MODULE_EXPORT void fl_dart_project_set_aot_library_path(FlDartProject *self, const gchar *path)
TEST_F(FlDartProjectTest, GetPaths)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args