提交 f9af6786 编写于 作者: S Seigo Nonaka 提交者: Android (Google) Code Review

Merge "Fix lock assertion failures in unit test."

......@@ -20,12 +20,15 @@
#include "FontTestUtils.h"
#include "ICUTestBase.h"
#include "MinikinFontForTest.h"
#include "MinikinInternal.h"
#include "UnicodeUtils.h"
using android::AutoMutex;
using android::FontCollection;
using android::FontFamily;
using android::FontLanguage;
using android::FontStyle;
using android::gMinikinLock;
const char kItemizeFontXml[] = kTestFontDir "itemize.xml";
const char kEmojiFont[] = kTestFontDir "Emoji.ttf";
......@@ -55,6 +58,7 @@ void itemize(FontCollection* collection, const char* str, FontStyle style,
result->clear();
ParseUnicode(buf, BUF_SIZE, str, &len, NULL);
AutoMutex _l(gMinikinLock);
collection->itemize(buf, len, style, result);
}
......
......@@ -31,11 +31,13 @@ typedef ICUTestBase FontLanguagesTest;
typedef ICUTestBase FontLanguageTest;
static FontLanguages createFontLanguages(const std::string& input) {
AutoMutex _l(gMinikinLock);
uint32_t langId = FontLanguageListCache::getId(input);
return FontLanguageListCache::getById(langId);
}
static FontLanguage createFontLanguage(const std::string& input) {
AutoMutex _l(gMinikinLock);
uint32_t langId = FontLanguageListCache::getId(input);
return FontLanguageListCache::getById(langId)[0];
}
......
......@@ -20,17 +20,20 @@
#include "FontLanguageListCache.h"
#include "ICUTestBase.h"
#include "MinikinInternal.h"
namespace android {
typedef ICUTestBase FontLanguageListCacheTest;
TEST_F(FontLanguageListCacheTest, getId) {
EXPECT_EQ(0UL, FontLanguageListCache::getId(""));
EXPECT_NE(0UL, FontStyle::registerLanguageList("en"));
EXPECT_NE(0UL, FontStyle::registerLanguageList("jp"));
EXPECT_NE(0UL, FontStyle::registerLanguageList("en,zh-Hans"));
AutoMutex _l(gMinikinLock);
EXPECT_EQ(0UL, FontLanguageListCache::getId(""));
EXPECT_EQ(FontLanguageListCache::getId("en"), FontLanguageListCache::getId("en"));
EXPECT_NE(FontLanguageListCache::getId("en"), FontLanguageListCache::getId("jp"));
......@@ -47,6 +50,7 @@ TEST_F(FontLanguageListCacheTest, getId) {
}
TEST_F(FontLanguageListCacheTest, getById) {
AutoMutex _l(gMinikinLock);
uint32_t enLangId = FontLanguageListCache::getId("en");
uint32_t jpLangId = FontLanguageListCache::getId("jp");
FontLanguage english = FontLanguageListCache::getById(enLangId)[0];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册