diff options
author | Seigo Nonaka <nona@google.com> | 2016-04-11 17:53:34 +0900 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2016-04-11 16:12:26 -0700 |
commit | febefe05b35aa4b7a58e9a13fd83b264832bccb4 (patch) | |
tree | 6f389a2979b0585148168a6e6ea1ad91ee655272 /tests/MinikinFontForTest.cpp | |
parent | e45eb1adda4fd33028e98783fb15c83e990f73ca (diff) | |
download | android_frameworks_minikin-febefe05b35aa4b7a58e9a13fd83b264832bccb4.tar.gz android_frameworks_minikin-febefe05b35aa4b7a58e9a13fd83b264832bccb4.tar.bz2 android_frameworks_minikin-febefe05b35aa4b7a58e9a13fd83b264832bccb4.zip |
Fix minikin_unittests
This CL fixes following test cases in minikin_tests
- FontFamilyTest.hasVariationSelectorTest
- HbFontCacheTest.getHbFontLockedTest
- HbFontCacheTest.purgeCacheTest
For the fix of FontFamilyTest.hasVariationSelectorTest, removing virtual
from GetUniqueId() in MinikinFont. After [1], MinikinFont's destructor
started calling purgeHbCache() which calls virtual method,
MinikinFont::GetUniqueId(). Fortunately, the SkTypeface::uniqueID()
returns just internal value, so we can store it at the construction time
and use it instead of calling SkTypeface::uniqueID() every time.
This patch also changes purgeHbFont to purgeHbFontLocked, as all uses of
it were already under global mutex. This change avoids deadlock on
explicit unref, as when invoked by a Java finalizer from the Java object
that holds a reference to the font.
Some of the tests needed to change to using the ref counting protocol
rather than explicitly destructing font objects, as well.
[1] 9afcc6e2bd4d89e4e1deb6e18c3c4daca4e114fd
Bug: 28105730
Bug: 28105688
Change-Id: Ie5983c4869147dacabdca81af1605066cd680b3f
Diffstat (limited to 'tests/MinikinFontForTest.cpp')
-rw-r--r-- | tests/MinikinFontForTest.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/MinikinFontForTest.cpp b/tests/MinikinFontForTest.cpp index 96f3326..66dd4ea 100644 --- a/tests/MinikinFontForTest.cpp +++ b/tests/MinikinFontForTest.cpp @@ -22,8 +22,14 @@ #include <cutils/log.h> -MinikinFontForTest::MinikinFontForTest(const std::string& font_path) : mFontPath(font_path) { - mTypeface = SkTypeface::CreateFromFile(font_path.c_str()); +MinikinFontForTest::MinikinFontForTest(const std::string& font_path) : + MinikinFontForTest(font_path, SkTypeface::CreateFromFile(font_path.c_str())) { +} + +MinikinFontForTest::MinikinFontForTest(const std::string& font_path, SkTypeface* typeface) : + MinikinFont(typeface->uniqueID()), + mTypeface(typeface), + mFontPath(font_path) { } MinikinFontForTest::~MinikinFontForTest() { @@ -55,7 +61,3 @@ const void* MinikinFontForTest::GetTable(uint32_t tag, size_t* size, *destroy = free; return buf; } - -int32_t MinikinFontForTest::GetUniqueId() const { - return mTypeface->uniqueID(); -} |