Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Unified Diff: third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp

Issue 1882063002: Add OpenTypeCapsSupport class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@caseMapHbBufferFillerLand
Patch Set: Adding used font files to .isolate recipe, now with trailing slashes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5cfa615cf44996b374664af6f539d5a216c19c30
--- /dev/null
+++ b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp
@@ -0,0 +1,113 @@
+// Copyright 2015 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/opentype/OpenTypeCapsSupport.h"
+
+#include "platform/fonts/Font.h"
+#include "platform/testing/FontTestHelpers.h"
+#include "platform/testing/UnitTestHelpers.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using blink::testing::createTestFont;
+
+namespace blink {
+
+static inline String layoutTestsFontPath(String relativePath)
+{
+ return testing::blinkRootDir()
+ + String("/LayoutTests/third_party/")
+ + relativePath;
+}
+
+TEST(OpenTypeCapsSupportTest, LibertineSmcpC2scSupported)
+{
+ Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLibertine_R.woff"), 16);
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+
+ OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::SmallCaps, HB_SCRIPT_LATIN);
+ EXPECT_FALSE(capsSupport.needsRunCaseSplitting());
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded));
+}
+
+TEST(OpenTypeCapsSupportTest, LibertineIgnoreMissingTitling)
+{
+ Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLibertine_R.woff"), 16);
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+
+ OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::TitlingCaps, HB_SCRIPT_LATIN);
+ EXPECT_FALSE(capsSupport.needsRunCaseSplitting());
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded));
+}
+
+TEST(OpenTypeCapsSupportTest, LibertineAllPetiteSynthesis)
+{
+ Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLibertine_R.woff"), 16);
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+
+ OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::AllPetiteCaps, HB_SCRIPT_LATIN);
+ EXPECT_TRUE(capsSupport.needsRunCaseSplitting());
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(FontDescription::AllSmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(FontDescription::AllSmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded));
+}
+
+TEST(OpenTypeCapsSupportTest, MEgalopolisSmallCapsSynthetic)
+{
+ Font font = createTestFont("MEgalopolis", layoutTestsFontPath("MEgalopolis/MEgalopolisExtra.woff"), 16);
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+
+ OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::SmallCaps, HB_SCRIPT_LATIN);
+ EXPECT_TRUE(capsSupport.needsRunCaseSplitting());
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_TRUE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(CaseMapIntend::UpperCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded));
+}
+
+TEST(OpenTypeCapsSupportTest, MEgalopolisUnicaseSynthetic)
+{
+ Font font = createTestFont("MEgalopolis", layoutTestsFontPath("MEgalopolis/MEgalopolisExtra.woff"), 16);
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+
+ OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::Unicase, HB_SCRIPT_LATIN);
+ EXPECT_TRUE(capsSupport.needsRunCaseSplitting());
+ EXPECT_TRUE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded));
+}
+
+TEST(OpenTypeCapsSupportTest, LibertineUnicaseFallback)
+{
+ Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLibertine_R.woff"), 16);
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+
+ OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::Unicase, HB_SCRIPT_LATIN);
+ EXPECT_TRUE(capsSupport.needsRunCaseSplitting());
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(CaseMapIntend::LowerCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded));
+ EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase));
+ EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded));
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698