diff --git a/BUILD.gn b/BUILD.gn index f172357d3d25ed49a2766d37010ee4af62d4e5ac..91d7724287a0fd182cee56f849256240992c2730 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -106,6 +106,10 @@ group("flutter") { "//flutter/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests", ] } + if (is_linux) { + public_deps += + [ "//flutter/shell/platform/linux:flutter_linux_unittests" ] + } } } } diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 75ea1d7ced01922348f3de0691862c88318dce20..f79af121f37815b8f3fcd3e69781fd838bee11d2 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1174,6 +1174,7 @@ FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.h FILE: ../../../flutter/shell/platform/linux/fl_binary_messenger.cc FILE: ../../../flutter/shell/platform/linux/fl_binary_messenger_private.h FILE: ../../../flutter/shell/platform/linux/fl_dart_project.cc +FILE: ../../../flutter/shell/platform/linux/fl_dart_project_test.cc FILE: ../../../flutter/shell/platform/linux/fl_engine.cc FILE: ../../../flutter/shell/platform/linux/fl_engine_private.h FILE: ../../../flutter/shell/platform/linux/fl_renderer.cc diff --git a/shell/platform/linux/BUILD.gn b/shell/platform/linux/BUILD.gn index cb0a85d6549dfb8d656319c9d7affcfaa59ada4a..213374bdc15ac2e589ed06f75279b9721152391f 100644 --- a/shell/platform/linux/BUILD.gn +++ b/shell/platform/linux/BUILD.gn @@ -5,6 +5,7 @@ assert(is_linux) import("//flutter/shell/platform/glfw/config.gni") +import("//flutter/testing/testing.gni") group("linux") { deps = [ @@ -80,6 +81,31 @@ source_set("flutter_linux") { ] } +test_fixtures("flutter_linux_fixtures") { + fixtures = [] +} + +executable("flutter_linux_unittests") { + testonly = true + + sources = [ + "fl_dart_project_test.cc", + ] + + public_configs = [ "//flutter:config" ] + + configs += [ "//flutter/shell/platform/linux/config:gtk" ] + + # Set flag to allow public headers to be directly included (library users should not do this) + defines = [ "FLUTTER_LINUX_COMPILATION" ] + + deps = [ + ":flutter_linux", + ":flutter_linux_fixtures", + "//flutter/testing", + ] +} + shared_library("flutter_linux_gtk") { deps = [ ":flutter_linux", diff --git a/shell/platform/linux/fl_dart_project_test.cc b/shell/platform/linux/fl_dart_project_test.cc new file mode 100644 index 0000000000000000000000000000000000000000..6d4e4766c5e7fa4543ca88e2b6dfa09f285d7a06 --- /dev/null +++ b/shell/platform/linux/fl_dart_project_test.cc @@ -0,0 +1,37 @@ +// 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 "gtest/gtest.h" + +#include + +TEST(FlDartProjectTest, GetPath) { + g_autoptr(FlDartProject) project = + fl_dart_project_new("/projects/my_dart_project"); + EXPECT_STREQ(fl_dart_project_get_path(project), "/projects/my_dart_project"); +} + +TEST(FlDartProjectTest, GetPathRelative) { + g_autoptr(FlDartProject) project = fl_dart_project_new("foo"); + 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_path = g_build_filename(dir, "foo", nullptr); + EXPECT_STREQ(fl_dart_project_get_path(project), expected_path); +} + +TEST(FlDartProjectTest, GetAssetsPath) { + g_autoptr(FlDartProject) project = + fl_dart_project_new("/projects/my_dart_project"); + g_autofree gchar* assets_path = fl_dart_project_get_assets_path(project); + EXPECT_STREQ(assets_path, "/projects/my_dart_project/flutter_assets"); +} + +TEST(FlDartProjectTest, GetIcuDataPath) { + g_autoptr(FlDartProject) project = + fl_dart_project_new("/projects/my_dart_project"); + g_autofree gchar* assets_path = fl_dart_project_get_icu_data_path(project); + EXPECT_STREQ(assets_path, "/projects/my_dart_project/icudtl.dat"); +} diff --git a/shell/platform/linux/public/flutter_linux/fl_dart_project.h b/shell/platform/linux/public/flutter_linux/fl_dart_project.h index 1a379713ccc06c042f62dd88fbecdcd0a0800cae..970618c35bcfcb37688b668f4d883e7e7add879c 100644 --- a/shell/platform/linux/public/flutter_linux/fl_dart_project.h +++ b/shell/platform/linux/public/flutter_linux/fl_dart_project.h @@ -71,7 +71,7 @@ const gchar* fl_dart_project_get_path(FlDartProject* project); * application. * * Returns: (type filename): a file path, e.g. - * "/projects/my_dart_project/assets" + * "/projects/my_dart_project/flutter_assets" */ gchar* fl_dart_project_get_assets_path(FlDartProject* project); diff --git a/testing/run_tests.py b/testing/run_tests.py index b6769343f44a1f6d321ab1526546c05d04bcfdd7..bd84a36f291d5e99a08ec85de32e255a62698c42 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -153,6 +153,9 @@ def RunCCTests(build_dir, filter): if IsLinux(): RunEngineExecutable(build_dir, 'txt_unittests', filter, shuffle_flags) + if IsLinux(): + RunEngineExecutable(build_dir, 'flutter_linux_unittests', filter, shuffle_flags) + def RunEngineBenchmarks(build_dir, filter): print("Running Engine Benchmarks.")