Use the fixtures mechanism for txt unit-tests and benchmarks. (flutter/engine#13180)
These tests and benchmarks can now be run without needing additional flags on the command line.
This commit is contained in:
@@ -21,7 +21,6 @@ fonts_dir = os.path.join(buildroot_dir, 'flutter', 'third_party', 'txt', 'third_
|
||||
roboto_font_path = os.path.join(fonts_dir, 'Roboto-Regular.ttf')
|
||||
dart_tests_dir = os.path.join(buildroot_dir, 'flutter', 'testing', 'dart',)
|
||||
|
||||
fonts_dir_flag = '--font-directory=%s' % fonts_dir
|
||||
time_sensitve_test_flag = '--gtest_filter="-*TimeSensitiveTest*"'
|
||||
|
||||
def IsMac():
|
||||
@@ -112,7 +111,7 @@ def RunCCTests(build_dir, filter):
|
||||
|
||||
# https://github.com/flutter/flutter/issues/36296
|
||||
if IsLinux():
|
||||
RunEngineExecutable(build_dir, 'txt_unittests', filter, [ fonts_dir_flag ] + shuffle_flags)
|
||||
RunEngineExecutable(build_dir, 'txt_unittests', filter, shuffle_flags)
|
||||
|
||||
|
||||
def RunEngineBenchmarks(build_dir, filter):
|
||||
@@ -123,7 +122,7 @@ def RunEngineBenchmarks(build_dir, filter):
|
||||
RunEngineExecutable(build_dir, 'fml_benchmarks', filter)
|
||||
|
||||
if IsLinux():
|
||||
RunEngineExecutable(build_dir, 'txt_benchmarks', filter, [ fonts_dir_flag ])
|
||||
RunEngineExecutable(build_dir, 'txt_benchmarks', filter)
|
||||
|
||||
|
||||
|
||||
|
||||
72
engine/src/flutter/third_party/txt/BUILD.gn
vendored
72
engine/src/flutter/third_party/txt/BUILD.gn
vendored
@@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("$flutter_root/common/config.gni")
|
||||
import("$flutter_root/testing/testing.gni")
|
||||
|
||||
declare_args() {
|
||||
flutter_use_fontconfig = false
|
||||
@@ -185,6 +186,72 @@ source_set("txt_test_utils") {
|
||||
]
|
||||
}
|
||||
|
||||
test_fixtures("txt_fixtures") {
|
||||
fixtures = [
|
||||
"third_party/fonts/Bold.ttf",
|
||||
"third_party/fonts/Bold.ttx",
|
||||
"third_party/fonts/BoldItalic.ttf",
|
||||
"third_party/fonts/BoldItalic.ttx",
|
||||
"third_party/fonts/ColorEmojiFont.ttf",
|
||||
"third_party/fonts/ColorEmojiFont.ttx",
|
||||
"third_party/fonts/ColorTextMixedEmojiFont.ttf",
|
||||
"third_party/fonts/ColorTextMixedEmojiFont.ttx",
|
||||
"third_party/fonts/DroidSerif.ttf",
|
||||
"third_party/fonts/Emoji.ttf",
|
||||
"third_party/fonts/Emoji.ttx",
|
||||
"third_party/fonts/HomemadeApple.ttf",
|
||||
"third_party/fonts/Italic.ttf",
|
||||
"third_party/fonts/Italic.ttx",
|
||||
"third_party/fonts/Ja.ttf",
|
||||
"third_party/fonts/Ja.ttx",
|
||||
"third_party/fonts/Katibeh-Regular.ttf",
|
||||
"third_party/fonts/Ko.ttf",
|
||||
"third_party/fonts/Ko.ttx",
|
||||
"third_party/fonts/MultiAxis.ttf",
|
||||
"third_party/fonts/MultiAxis.ttx",
|
||||
"third_party/fonts/NoCmapFormat14.ttf",
|
||||
"third_party/fonts/NoCmapFormat14.ttx",
|
||||
"third_party/fonts/NoGlyphFont.ttf",
|
||||
"third_party/fonts/NoGlyphFont.ttx",
|
||||
"third_party/fonts/NotoColorEmoji.ttf",
|
||||
"third_party/fonts/NotoNaskhArabic-Regular.ttf",
|
||||
"third_party/fonts/NotoSansCJK-Regular.ttc",
|
||||
"third_party/fonts/Regular.ttf",
|
||||
"third_party/fonts/Regular.ttx",
|
||||
"third_party/fonts/Roboto-Black.ttf",
|
||||
"third_party/fonts/Roboto-BlackItalic.ttf",
|
||||
"third_party/fonts/Roboto-Bold.ttf",
|
||||
"third_party/fonts/Roboto-BoldItalic.ttf",
|
||||
"third_party/fonts/Roboto-Italic.ttf",
|
||||
"third_party/fonts/Roboto-Light.ttf",
|
||||
"third_party/fonts/Roboto-LightItalic.ttf",
|
||||
"third_party/fonts/Roboto-Medium.ttf",
|
||||
"third_party/fonts/Roboto-MediumItalic.ttf",
|
||||
"third_party/fonts/Roboto-Regular.ttf",
|
||||
"third_party/fonts/Roboto-Thin.ttf",
|
||||
"third_party/fonts/Roboto-ThinItalic.ttf",
|
||||
"third_party/fonts/SourceHanSerifCN-Bold.otf",
|
||||
"third_party/fonts/SourceHanSerifCN-Regular.otf",
|
||||
"third_party/fonts/TextEmojiFont.ttf",
|
||||
"third_party/fonts/TextEmojiFont.ttx",
|
||||
"third_party/fonts/UnicodeBMPOnly.ttf",
|
||||
"third_party/fonts/UnicodeBMPOnly.ttx",
|
||||
"third_party/fonts/UnicodeBMPOnly2.ttf",
|
||||
"third_party/fonts/UnicodeBMPOnly2.ttx",
|
||||
"third_party/fonts/UnicodeUCS4.ttf",
|
||||
"third_party/fonts/UnicodeUCS4.ttx",
|
||||
"third_party/fonts/VariationSelectorTest-Regular.ttf",
|
||||
"third_party/fonts/VariationSelectorTest-Regular.ttx",
|
||||
"third_party/fonts/ZhHans.ttf",
|
||||
"third_party/fonts/ZhHans.ttx",
|
||||
"third_party/fonts/ZhHant.ttf",
|
||||
"third_party/fonts/ZhHant.ttx",
|
||||
"third_party/fonts/ahem.ttf",
|
||||
"third_party/fonts/emoji.xml",
|
||||
"third_party/fonts/itemize.xml",
|
||||
]
|
||||
}
|
||||
|
||||
executable("txt_unittests") {
|
||||
testonly = true
|
||||
|
||||
@@ -229,7 +296,8 @@ executable("txt_unittests") {
|
||||
deps = [
|
||||
":txt",
|
||||
":txt_test_utils",
|
||||
"//third_party/googletest:gtest",
|
||||
"$flutter_root/testing:testing_lib",
|
||||
":txt_fixtures",
|
||||
] + txt_common_executable_deps
|
||||
}
|
||||
|
||||
@@ -247,6 +315,8 @@ executable("txt_benchmarks") {
|
||||
deps = [
|
||||
":txt",
|
||||
":txt_test_utils",
|
||||
"$flutter_root/testing:testing_lib",
|
||||
"//third_party/benchmark",
|
||||
":txt_fixtures",
|
||||
] + txt_common_executable_deps
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "flutter/fml/icu_util.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "flutter/third_party/txt/tests/txt_test_utils.h"
|
||||
#include "third_party/benchmark/include/benchmark/benchmark_api.h"
|
||||
|
||||
@@ -24,12 +25,9 @@ int main(int argc, char** argv) {
|
||||
::benchmark::Initialize(&argc, argv);
|
||||
fml::CommandLine cmd = fml::CommandLineFromArgcArgv(argc, argv);
|
||||
txt::SetCommandLine(cmd);
|
||||
std::string dir = txt::GetCommandLineForProcess().GetOptionValueWithDefault(
|
||||
"font-directory", "");
|
||||
txt::SetFontDir(dir);
|
||||
txt::SetFontDir(flutter::testing::GetFixturesPath());
|
||||
if (txt::GetFontDir().length() <= 0) {
|
||||
FML_LOG(ERROR) << "Font directory must be specified with "
|
||||
"--font-directory=\"<directory>\" to run this test.";
|
||||
FML_LOG(ERROR) << "Font directory not set via txt::SetFontDir.";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
FML_DCHECK(txt::GetFontDir().length() > 0);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "flutter/fml/command_line.h"
|
||||
#include "flutter/fml/icu_util.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "third_party/skia/include/core/SkGraphics.h"
|
||||
#include "txt_test_utils.h"
|
||||
|
||||
@@ -26,16 +26,12 @@
|
||||
int main(int argc, char** argv) {
|
||||
fml::CommandLine cmd = fml::CommandLineFromArgcArgv(argc, argv);
|
||||
txt::SetCommandLine(cmd);
|
||||
std::string dir = txt::GetCommandLineForProcess().GetOptionValueWithDefault(
|
||||
"font-directory", "");
|
||||
txt::SetFontDir(dir);
|
||||
txt::SetFontDir(flutter::testing::GetFixturesPath());
|
||||
if (txt::GetFontDir().length() <= 0) {
|
||||
FML_LOG(ERROR) << "Font directory must be specified with "
|
||||
"--font-directory=\"<directory>\" to run this test.";
|
||||
FML_LOG(ERROR) << "Font directory not set via txt::SetFontDir.";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
FML_DCHECK(txt::GetFontDir().length() > 0);
|
||||
|
||||
fml::icu::InitializeICU("icudtl.dat");
|
||||
SkGraphics::Init();
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
Reference in New Issue
Block a user