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