Commit d2df0526 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Enable HyphenationTest for all platforms

This patch enables |HyphenationTest| for all platforms.

It turns out that try-bots do not copy all test data files and
that tests fail on most bots. This patch adds |data_deps|
rules to |BUILD.gn| to copy dictionaries used in testing as
part of |blink_platform_unittests_data|.

The same issue occurs on |web_tests| too, I will investigate
it in following patches.

Bug: 1139950
Change-Id: I654332076a5ae194db905c72c525a16c3f90de4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2483725Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818929}
parent 5349bb92
...@@ -2172,6 +2172,9 @@ source_set("blink_platform_unittests_sources") { ...@@ -2172,6 +2172,9 @@ source_set("blink_platform_unittests_sources") {
data_deps = [ ":blink_platform_unittests_data" ] data_deps = [ ":blink_platform_unittests_data" ]
defines = [ "INSIDE_BLINK" ] defines = [ "INSIDE_BLINK" ]
if (use_minikin_hyphenation) {
defines += [ "USE_MINIKIN_HYPHENATION" ]
}
} }
executable("image_decode_bench") { executable("image_decode_bench") {
...@@ -2247,6 +2250,8 @@ test("blink_platform_perftests") { ...@@ -2247,6 +2250,8 @@ test("blink_platform_perftests") {
} }
group("blink_platform_unittests_data") { group("blink_platform_unittests_data") {
testonly = true
data = [ data = [
"testing/data/", "testing/data/",
...@@ -2260,6 +2265,8 @@ group("blink_platform_unittests_data") { ...@@ -2260,6 +2265,8 @@ group("blink_platform_unittests_data") {
# Required by some font tests. # Required by some font tests.
"//third_party/blink/web_tests/third_party/", "//third_party/blink/web_tests/third_party/",
] ]
data_deps = [ "//third_party/hyphenation-patterns:test_data" ]
} }
if (current_cpu == "x86" || current_cpu == "x64") { if (current_cpu == "x86" || current_cpu == "x64") {
......
...@@ -124,6 +124,12 @@ String AccessibilityTestDataPath(const String& relative_path) { ...@@ -124,6 +124,12 @@ String AccessibilityTestDataPath(const String& relative_path) {
.Append(WebStringToFilePath(relative_path))); .Append(WebStringToFilePath(relative_path)));
} }
base::FilePath HyphenationDictionaryDir() {
base::FilePath exe_dir;
base::PathService::Get(base::DIR_EXE, &exe_dir);
return exe_dir.AppendASCII("gen/hyphen-data");
}
scoped_refptr<SharedBuffer> ReadFromFile(const String& path) { scoped_refptr<SharedBuffer> ReadFromFile(const String& path) {
base::FilePath file_path = blink::WebStringToFilePath(path); base::FilePath file_path = blink::WebStringToFilePath(path);
std::string buffer; std::string buffer;
......
...@@ -81,6 +81,9 @@ String AccessibilityTestDataPath(const String& relative_path = String()); ...@@ -81,6 +81,9 @@ String AccessibilityTestDataPath(const String& relative_path = String());
// specified. // specified.
String BlinkWebTestsFontsTestDataPath(const String& relative_path = String()); String BlinkWebTestsFontsTestDataPath(const String& relative_path = String());
// Returns the directory of hyphenation dictionaries for testing.
base::FilePath HyphenationDictionaryDir();
scoped_refptr<SharedBuffer> ReadFromFile(const String& path); scoped_refptr<SharedBuffer> ReadFromFile(const String& path);
class LineReader { class LineReader {
......
...@@ -7,14 +7,17 @@ ...@@ -7,14 +7,17 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/text/layout_locale.h" #include "third_party/blink/renderer/platform/text/layout_locale.h"
using testing::ElementsAre; using testing::ElementsAre;
using testing::ElementsAreArray; using testing::ElementsAreArray;
#if defined(OS_ANDROID) #if defined(USE_MINIKIN_HYPHENATION) && defined(OS_FUCHSIA)
#define USE_MINIKIN_HYPHENATION // Fuchsia doesn't include |blink_platform_unittests_data|.
#undef USE_MINIKIN_HYPHENATION
#endif #endif
#if defined(USE_MINIKIN_HYPHENATION) #if defined(USE_MINIKIN_HYPHENATION)
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "third_party/blink/renderer/platform/text/hyphenation/hyphenation_minikin.h" #include "third_party/blink/renderer/platform/text/hyphenation/hyphenation_minikin.h"
...@@ -35,7 +38,7 @@ class HyphenationTest : public testing::Test { ...@@ -35,7 +38,7 @@ class HyphenationTest : public testing::Test {
void TearDown() override { LayoutLocale::ClearForTesting(); } void TearDown() override { LayoutLocale::ClearForTesting(); }
#if defined(USE_MINIKIN_HYPHENATION) || defined(OS_MAC) #if defined(USE_MINIKIN_HYPHENATION) || defined(OS_MAC)
// Get a |Hyphenation| instnace for the specified locale for testing. // Get a |Hyphenation| instance for the specified locale for testing.
scoped_refptr<Hyphenation> GetHyphenation(const AtomicString& locale) { scoped_refptr<Hyphenation> GetHyphenation(const AtomicString& locale) {
#if defined(USE_MINIKIN_HYPHENATION) #if defined(USE_MINIKIN_HYPHENATION)
// Because the mojo service to open hyphenation dictionaries is not // Because the mojo service to open hyphenation dictionaries is not
...@@ -45,7 +48,7 @@ class HyphenationTest : public testing::Test { ...@@ -45,7 +48,7 @@ class HyphenationTest : public testing::Test {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
base::FilePath path("/system/usr/hyphen-data"); base::FilePath path("/system/usr/hyphen-data");
#else #else
#error "This configuration is not supported." base::FilePath path = test::HyphenationDictionaryDir();
#endif #endif
path = path.AppendASCII(filename); path = path.AppendASCII(filename);
base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ);
...@@ -77,7 +80,7 @@ TEST_F(HyphenationTest, HyphenLocations) { ...@@ -77,7 +80,7 @@ TEST_F(HyphenationTest, HyphenLocations) {
if (!hyphenation) if (!hyphenation)
return; return;
#endif #endif
ASSERT_TRUE(hyphenation) << "Cannot find the hyphenation engine"; ASSERT_TRUE(hyphenation) << "Cannot find the hyphenation for en-us";
// Get all hyphenation points by |HyphenLocations|. // Get all hyphenation points by |HyphenLocations|.
const String word("hyphenation"); const String word("hyphenation");
......
...@@ -47,3 +47,14 @@ zip("hyphenation-patterns") { ...@@ -47,3 +47,14 @@ zip("hyphenation-patterns") {
output = "$root_build_dir/hyphens-data.zip" output = "$root_build_dir/hyphens-data.zip"
base_dir = "hyb" base_dir = "hyb"
} }
copy("test_data") {
testonly = true
sources = [
# Dictionaries used in unit tests and web_tests.
"hyb/hyph-de-1996.hyb",
"hyb/hyph-en-gb.hyb",
"hyb/hyph-en-us.hyb",
]
outputs = [ "$root_gen_dir/hyphen-data/{{source_file_part}}" ]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment