Build txt_unittests

Many of these fail because they assume they're being executed on Android, but
at least they build.

Change-Id: I5d86e3d2632a0d6fa4219d3f5182f2683c9dd314
This commit is contained in:
Adam Barth
2017-05-08 12:40:16 -07:00
parent ebc9d58082
commit 878c4a2586
15 changed files with 171 additions and 15 deletions

View File

@@ -3,7 +3,10 @@
# found in the LICENSE file.
group("txt") {
testonly = true
deps = [
"libs/minikin",
"tests/unittest($host_toolchain)",
]
}

View File

@@ -47,6 +47,7 @@ static_library("minikin") {
public_configs = [ ":minikin_config" ]
public_deps = [
"//lib/txt/shims",
"//third_party/freetype2",
"//third_party/harfbuzz",
"//third_party/icu:icuuc",
@@ -54,6 +55,5 @@ static_library("minikin") {
deps = [
"//third_party/zlib",
"//lib/txt/shims",
]
}

View File

@@ -20,6 +20,7 @@ source_set("shims") {
sources = [
"log/log.h",
"log/log.cc",
"utils/JenkinsHash.cpp",
"utils/JenkinsHash.h",
"utils/LruCache.h",
"utils/TypeHelpers.h",

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Implementation of Jenkins one-at-a-time hash function. These choices are
* optimized for code size and portability, rather than raw speed. But speed
* should still be quite good.
**/
#include <stdlib.h>
#include <utils/JenkinsHash.h>
namespace android {
#ifdef __clang__
__attribute__((no_sanitize("integer")))
#endif
hash_t JenkinsHashWhiten(uint32_t hash) {
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size) {
if (size > UINT32_MAX) {
abort();
}
hash = JenkinsHashMix(hash, (uint32_t)size);
size_t i;
for (i = 0; i < (size & -4); i += 4) {
uint32_t data = bytes[i] | (bytes[i+1] << 8) | (bytes[i+2] << 16) | (bytes[i+3] << 24);
hash = JenkinsHashMix(hash, data);
}
if (size & 3) {
uint32_t data = bytes[i];
data |= ((size & 3) > 1) ? (bytes[i+1] << 8) : 0;
data |= ((size & 3) > 2) ? (bytes[i+2] << 16) : 0;
hash = JenkinsHashMix(hash, data);
}
return hash;
}
uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size) {
if (size > UINT32_MAX) {
abort();
}
hash = JenkinsHashMix(hash, (uint32_t)size);
size_t i;
for (i = 0; i < (size & -2); i += 2) {
uint32_t data = shorts[i] | (shorts[i+1] << 16);
hash = JenkinsHashMix(hash, data);
}
if (size & 1) {
uint32_t data = shorts[i];
hash = JenkinsHashMix(hash, data);
}
return hash;
}
}

View File

@@ -0,0 +1,39 @@
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
executable("unittest") {
output_name = "txt_unittests"
testonly = true
sources = [
"CmapCoverageTest.cpp",
"EmojiTest.cpp",
"FontCollectionItemizeTest.cpp",
"FontCollectionTest.cpp",
"FontFamilyTest.cpp",
"FontLanguageListCacheTest.cpp",
"GraphemeBreakTests.cpp",
"HbFontCacheTest.cpp",
"HyphenatorTest.cpp",
"ICUTestBase.h",
"LayoutTest.cpp",
"LayoutUtilsTest.cpp",
"MeasurementTests.cpp",
"SparseBitSetTest.cpp",
"UnicodeUtilsTest.cpp",
"WordBreakerTests.cpp",
"//lib/ftl/test/run_all_unittests.cc",
]
defines = [
"kTestFontDir=\"/data/nativetest/minikin_tests/data/\"",
]
deps = [
"//lib/txt/tests/util",
"//lib/txt/libs/minikin",
"//third_party/gtest",
]
}

View File

@@ -18,12 +18,12 @@
#include <memory>
#include "FontLanguageListCache.h"
#include "FontLanguage.h"
#include "lib/txt/libs/minikin/FontLanguageListCache.h"
#include "lib/txt/libs/minikin/FontLanguage.h"
#include "FontTestUtils.h"
#include "ICUTestBase.h"
#include "MinikinFontForTest.h"
#include "MinikinInternal.h"
#include "lib/txt/libs/minikin/MinikinInternal.h"
#include "UnicodeUtils.h"
#include "minikin/FontFamily.h"

View File

@@ -19,7 +19,7 @@
#include <minikin/FontCollection.h>
#include "FontTestUtils.h"
#include "MinikinFontForTest.h"
#include "MinikinInternal.h"
#include "lib/txt/libs/minikin/MinikinInternal.h"
namespace minikin {

View File

@@ -19,10 +19,10 @@
#include <log/log.h>
#include <gtest/gtest.h>
#include "FontLanguageListCache.h"
#include "lib/txt/libs/minikin/FontLanguageListCache.h"
#include "ICUTestBase.h"
#include "MinikinFontForTest.h"
#include "MinikinInternal.h"
#include "lib/txt/libs/minikin/MinikinInternal.h"
namespace minikin {

View File

@@ -18,9 +18,9 @@
#include <minikin/FontFamily.h>
#include "FontLanguageListCache.h"
#include "lib/txt/libs/minikin/FontLanguageListCache.h"
#include "ICUTestBase.h"
#include "MinikinInternal.h"
#include "lib/txt/libs/minikin/MinikinInternal.h"
namespace minikin {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "HbFontCache.h"
#include "lib/txt/libs/minikin/HbFontCache.h"
#include <log/log.h>
#include <gtest/gtest.h>
@@ -24,7 +24,7 @@
#include <hb.h>
#include "MinikinInternal.h"
#include "lib/txt/libs/minikin/MinikinInternal.h"
#include "MinikinFontForTest.h"
#include <minikin/MinikinFont.h>

View File

@@ -17,7 +17,7 @@
#include <gtest/gtest.h>
#include <UnicodeUtils.h>
#include "LayoutUtils.h"
#include "lib/txt/libs/minikin/LayoutUtils.h"
namespace minikin {

View File

@@ -0,0 +1,40 @@
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
config("util_config") {
include_dirs = [ "." ]
}
source_set("util") {
sources = [
"FileUtils.cpp",
"FileUtils.h",
"FontTestUtils.cpp",
"FontTestUtils.h",
"MinikinFontForTest.cpp",
"MinikinFontForTest.h",
"UnicodeUtils.cpp",
"UnicodeUtils.h",
]
public_configs = [ ":util_config" ]
public_deps = [
"//lib/txt/libs/minikin",
]
deps = [
"//third_party/libxml2",
]
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
#include <cutils/log.h>
#include <log/log.h>
#include <stdio.h>
#include <sys/stat.h>

View File

@@ -21,7 +21,7 @@
#include <log/log.h>
#include "FontLanguage.h"
#include "lib/txt/libs/minikin/FontLanguage.h"
#include "MinikinFontForTest.h"
#include <minikin/FontCollection.h>
#include <minikin/FontFamily.h>

View File

@@ -17,7 +17,7 @@
#include <unicode/utf.h>
#include <unicode/utf8.h>
#include <cstdlib>
#include <cutils/log.h>
#include <log/log.h>
#include <vector>
#include <string>