summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/FontFamilyTest.cpp37
-rw-r--r--tests/MinikinFontForTest.cpp14
-rw-r--r--tests/MinikinFontForTest.h2
-rw-r--r--tests/how_to_run.txt2
4 files changed, 29 insertions, 26 deletions
diff --git a/tests/FontFamilyTest.cpp b/tests/FontFamilyTest.cpp
index 907f395..194063f 100644
--- a/tests/FontFamilyTest.cpp
+++ b/tests/FontFamilyTest.cpp
@@ -350,9 +350,9 @@ void expectVSGlyphs(FontFamily* family, uint32_t codepoint, const std::set<uint3
}
TEST_F(FontFamilyTest, hasVariationSelectorTest) {
- MinikinFontForTest minikinFont(kVsTestFont);
- FontFamily family;
- family.addFont(&minikinFont);
+ MinikinAutoUnref<MinikinFontForTest> minikinFont(new MinikinFontForTest(kVsTestFont));
+ MinikinAutoUnref<FontFamily> family(new FontFamily);
+ family->addFont(minikinFont.get());
AutoMutex _l(gMinikinLock);
@@ -365,24 +365,24 @@ TEST_F(FontFamilyTest, hasVariationSelectorTest) {
const uint32_t kVS20 = 0xE0103;
const uint32_t kSupportedChar1 = 0x82A6;
- EXPECT_TRUE(family.getCoverage()->get(kSupportedChar1));
- expectVSGlyphs(&family, kSupportedChar1, std::set<uint32_t>({kVS1, kVS17, kVS18, kVS19}));
+ EXPECT_TRUE(family->getCoverage()->get(kSupportedChar1));
+ expectVSGlyphs(family.get(), kSupportedChar1, std::set<uint32_t>({kVS1, kVS17, kVS18, kVS19}));
const uint32_t kSupportedChar2 = 0x845B;
- EXPECT_TRUE(family.getCoverage()->get(kSupportedChar2));
- expectVSGlyphs(&family, kSupportedChar2, std::set<uint32_t>({kVS2, kVS18, kVS19, kVS20}));
+ EXPECT_TRUE(family->getCoverage()->get(kSupportedChar2));
+ expectVSGlyphs(family.get(), kSupportedChar2, std::set<uint32_t>({kVS2, kVS18, kVS19, kVS20}));
const uint32_t kNoVsSupportedChar = 0x537F;
- EXPECT_TRUE(family.getCoverage()->get(kNoVsSupportedChar));
- expectVSGlyphs(&family, kNoVsSupportedChar, std::set<uint32_t>());
+ EXPECT_TRUE(family->getCoverage()->get(kNoVsSupportedChar));
+ expectVSGlyphs(family.get(), kNoVsSupportedChar, std::set<uint32_t>());
const uint32_t kVsOnlySupportedChar = 0x717D;
- EXPECT_FALSE(family.getCoverage()->get(kVsOnlySupportedChar));
- expectVSGlyphs(&family, kVsOnlySupportedChar, std::set<uint32_t>({kVS3, kVS19, kVS20}));
+ EXPECT_FALSE(family->getCoverage()->get(kVsOnlySupportedChar));
+ expectVSGlyphs(family.get(), kVsOnlySupportedChar, std::set<uint32_t>({kVS3, kVS19, kVS20}));
const uint32_t kNotSupportedChar = 0x845C;
- EXPECT_FALSE(family.getCoverage()->get(kNotSupportedChar));
- expectVSGlyphs(&family, kNotSupportedChar, std::set<uint32_t>());
+ EXPECT_FALSE(family->getCoverage()->get(kNotSupportedChar));
+ expectVSGlyphs(family.get(), kNotSupportedChar, std::set<uint32_t>());
}
TEST_F(FontFamilyTest, hasVSTableTest) {
@@ -403,12 +403,13 @@ TEST_F(FontFamilyTest, hasVSTableTest) {
"Font " + testCase.fontPath + " should have a variation sequence table." :
"Font " + testCase.fontPath + " shouldn't have a variation sequence table.");
- MinikinFontForTest minikinFont(testCase.fontPath);
- FontFamily family;
- family.addFont(&minikinFont);
- family.getCoverage();
+ MinikinAutoUnref<MinikinFontForTest> minikinFont(new MinikinFontForTest(testCase.fontPath));
+ MinikinAutoUnref<FontFamily> family(new FontFamily);
+ family->addFont(minikinFont.get());
+ AutoMutex _l(gMinikinLock);
+ family->getCoverage();
- EXPECT_EQ(testCase.hasVSTable, family.hasVSTable());
+ EXPECT_EQ(testCase.hasVSTable, family->hasVSTable());
}
}
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();
-}
diff --git a/tests/MinikinFontForTest.h b/tests/MinikinFontForTest.h
index 4686f7a..e527d21 100644
--- a/tests/MinikinFontForTest.h
+++ b/tests/MinikinFontForTest.h
@@ -24,6 +24,7 @@ class SkTypeface;
class MinikinFontForTest : public android::MinikinFont {
public:
explicit MinikinFontForTest(const std::string& font_path);
+ MinikinFontForTest(const std::string& font_path, SkTypeface* typeface);
~MinikinFontForTest();
// MinikinFont overrides.
@@ -31,7 +32,6 @@ public:
void GetBounds(android::MinikinRect* bounds, uint32_t glyph_id,
const android::MinikinPaint& paint) const;
const void* GetTable(uint32_t tag, size_t* size, android::MinikinDestroyFunc* destroy);
- int32_t GetUniqueId() const;
const std::string& fontPath() const { return mFontPath; }
private:
diff --git a/tests/how_to_run.txt b/tests/how_to_run.txt
index a135c30..bee367b 100644
--- a/tests/how_to_run.txt
+++ b/tests/how_to_run.txt
@@ -1,5 +1,5 @@
mmm -j8 frameworks/minikin/tests &&
adb push $OUT/data/nativetest/minikin_tests/minikin_tests \
/data/nativetest/minikin_tests/minikin_tests &&
-adb push frameworks/minikin/tests/data /data/nativetest/minikin_tests/data &&
+adb push frameworks/minikin/tests/data /data/nativetest/minikin_tests/ &&
adb shell /data/nativetest/minikin_tests/minikin_tests