Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0995e9f

Browse files
committed
Add first Linux shell tests
1 parent b1b1df0 commit 0995e9f

File tree

5 files changed

+70
-1
lines changed

5 files changed

+70
-1
lines changed

BUILD.gn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ group("flutter") {
106106
"//flutter/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests",
107107
]
108108
}
109+
if (is_linux) {
110+
public_deps +=
111+
[ "//flutter/shell/platform/linux:flutter_linux_unittests" ]
112+
}
109113
}
110114
}
111115
}

ci/licenses_golden/licenses_flutter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,7 @@ FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.h
11741174
FILE: ../../../flutter/shell/platform/linux/fl_binary_messenger.cc
11751175
FILE: ../../../flutter/shell/platform/linux/fl_binary_messenger_private.h
11761176
FILE: ../../../flutter/shell/platform/linux/fl_dart_project.cc
1177+
FILE: ../../../flutter/shell/platform/linux/fl_dart_project_test.cc
11771178
FILE: ../../../flutter/shell/platform/linux/fl_engine.cc
11781179
FILE: ../../../flutter/shell/platform/linux/fl_engine_private.h
11791180
FILE: ../../../flutter/shell/platform/linux/fl_renderer.cc

shell/platform/linux/BUILD.gn

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
assert(is_linux)
66

77
import("//flutter/shell/platform/glfw/config.gni")
8+
import("//flutter/testing/testing.gni")
89

910
group("linux") {
1011
deps = [
@@ -80,6 +81,31 @@ source_set("flutter_linux") {
8081
]
8182
}
8283

84+
test_fixtures("flutter_linux_fixtures") {
85+
fixtures = []
86+
}
87+
88+
executable("flutter_linux_unittests") {
89+
testonly = true
90+
91+
sources = [
92+
"fl_dart_project_test.cc",
93+
]
94+
95+
public_configs = [ "//flutter:config" ]
96+
97+
configs += [ "//flutter/shell/platform/linux/config:gtk" ]
98+
99+
# Set flag to allow public headers to be directly included (library users should not do this)
100+
defines = [ "FLUTTER_LINUX_COMPILATION" ]
101+
102+
deps = [
103+
":flutter_linux",
104+
":flutter_linux_fixtures",
105+
"//flutter/testing",
106+
]
107+
}
108+
83109
shared_library("flutter_linux_gtk") {
84110
deps = [
85111
":flutter_linux",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
#include "gtest/gtest.h"
7+
8+
#include <gmodule.h>
9+
10+
TEST(FlDartProjectTest, GetPath) {
11+
g_autoptr(FlDartProject) project =
12+
fl_dart_project_new("/projects/my_dart_project");
13+
ASSERT_STREQ(fl_dart_project_get_path(project),
14+
"/projects/my_dart_project");
15+
}
16+
17+
TEST(FlDartProjectTest, GetPathRelative) {
18+
g_autoptr(FlDartProject) project = fl_dart_project_new("foo");
19+
g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", nullptr);
20+
ASSERT_TRUE(exe_path != nullptr);
21+
g_autofree gchar* dir = g_path_get_dirname(exe_path);
22+
g_autofree gchar* expected_path = g_build_filename(dir, "foo", nullptr);
23+
ASSERT_STREQ(fl_dart_project_get_path(project), expected_path);
24+
}
25+
26+
TEST(FlDartProjectTest, GetAssetsPath) {
27+
g_autoptr(FlDartProject) project =
28+
fl_dart_project_new("/projects/my_dart_project");
29+
g_autofree gchar* assets_path = fl_dart_project_get_assets_path(project);
30+
ASSERT_STREQ(assets_path, "/projects/my_dart_project/flutter_assets");
31+
}
32+
33+
TEST(FlDartProjectTest, GetIcuDataPath) {
34+
g_autoptr(FlDartProject) project =
35+
fl_dart_project_new("/projects/my_dart_project");
36+
g_autofree gchar* assets_path = fl_dart_project_get_icu_data_path(project);
37+
ASSERT_STREQ(assets_path, "/projects/my_dart_project/icudtl.dat");
38+
}

shell/platform/linux/public/flutter_linux/fl_dart_project.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const gchar* fl_dart_project_get_path(FlDartProject* project);
7171
* application.
7272
*
7373
* Returns: (type filename): a file path, e.g.
74-
* "/projects/my_dart_project/assets"
74+
* "/projects/my_dart_project/flutter_assets"
7575
*/
7676
gchar* fl_dart_project_get_assets_path(FlDartProject* project);
7777

0 commit comments

Comments
 (0)