blob: 72a8ba07bcbc12afb6dc41e55b40e892735ab755 [file] [log] [blame]
// Copyright 2014 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.
#include "platform/fonts/FontCache.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/SimpleFontData.h"
#include "platform/testing/TestingPlatformSupport.h"
#include "public/platform/Platform.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
TEST(FontCache, getLastResortFallbackFont) {
FontCache* fontCache = FontCache::fontCache();
ASSERT_TRUE(fontCache);
FontDescription fontDescription;
fontDescription.setGenericFamily(FontDescription::StandardFamily);
RefPtr<SimpleFontData> fontData =
fontCache->getLastResortFallbackFont(fontDescription, Retain);
EXPECT_TRUE(fontData);
fontDescription.setGenericFamily(FontDescription::SansSerifFamily);
fontData = fontCache->getLastResortFallbackFont(fontDescription, Retain);
EXPECT_TRUE(fontData);
}
TEST(FontCache, firstAvailableOrFirst) {
EXPECT_TRUE(FontCache::firstAvailableOrFirst("").isEmpty());
EXPECT_TRUE(FontCache::firstAvailableOrFirst(String()).isEmpty());
EXPECT_EQ("Arial", FontCache::firstAvailableOrFirst("Arial"));
EXPECT_EQ("not exist", FontCache::firstAvailableOrFirst("not exist"));
EXPECT_EQ("Arial", FontCache::firstAvailableOrFirst("Arial, not exist"));
EXPECT_EQ("Arial", FontCache::firstAvailableOrFirst("not exist, Arial"));
EXPECT_EQ("Arial",
FontCache::firstAvailableOrFirst("not exist, Arial, not exist"));
EXPECT_EQ("not exist",
FontCache::firstAvailableOrFirst("not exist, not exist 2"));
EXPECT_EQ("Arial", FontCache::firstAvailableOrFirst(", not exist, Arial"));
EXPECT_EQ("not exist",
FontCache::firstAvailableOrFirst(", not exist, not exist"));
}
#if !OS(MACOSX)
TEST(FontCache, systemFont) {
FontCache::systemFontFamily();
// Test the function does not crash. Return value varies by system and config.
}
#endif
} // namespace blink