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

Commit f9fb9fb

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

File tree

6 files changed

+72
-1
lines changed

6 files changed

+72
-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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
EXPECT_STREQ(fl_dart_project_get_path(project), "/projects/my_dart_project");
14+
}
15+
16+
TEST(FlDartProjectTest, GetPathRelative) {
17+
g_autoptr(FlDartProject) project = fl_dart_project_new("foo");
18+
g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", nullptr);
19+
ASSERT_TRUE(exe_path != nullptr);
20+
g_autofree gchar* dir = g_path_get_dirname(exe_path);
21+
g_autofree gchar* expected_path = g_build_filename(dir, "foo", nullptr);
22+
EXPECT_STREQ(fl_dart_project_get_path(project), expected_path);
23+
}
24+
25+
TEST(FlDartProjectTest, GetAssetsPath) {
26+
g_autoptr(FlDartProject) project =
27+
fl_dart_project_new("/projects/my_dart_project");
28+
g_autofree gchar* assets_path = fl_dart_project_get_assets_path(project);
29+
EXPECT_STREQ(assets_path, "/projects/my_dart_project/flutter_assets");
30+
}
31+
32+
TEST(FlDartProjectTest, GetIcuDataPath) {
33+
g_autoptr(FlDartProject) project =
34+
fl_dart_project_new("/projects/my_dart_project");
35+
g_autofree gchar* assets_path = fl_dart_project_get_icu_data_path(project);
36+
EXPECT_STREQ(assets_path, "/projects/my_dart_project/icudtl.dat");
37+
}

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

testing/run_tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ def RunCCTests(build_dir, filter):
153153
if IsLinux():
154154
RunEngineExecutable(build_dir, 'txt_unittests', filter, shuffle_flags)
155155

156+
if IsLinux():
157+
RunEngineExecutable(build_dir, 'flutter_linux_unittests', filter, shuffle_flags)
158+
156159

157160
def RunEngineBenchmarks(build_dir, filter):
158161
print("Running Engine Benchmarks.")

0 commit comments

Comments
 (0)