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

Unified Diff: Source/platform/fonts/FontPlatformDataTest.cpp

Issue 1238753005: Add unit tests for FontPlatformData::hasSpaceInLigaturesOrKerning (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase w/HEAD Created 5 years, 5 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 | « Source/platform/fonts/FontPlatformData.cpp ('k') | Source/platform/fonts/TestFontSelector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/FontPlatformDataTest.cpp
diff --git a/Source/web/tests/WebSelectorTest.cpp b/Source/platform/fonts/FontPlatformDataTest.cpp
similarity index 52%
copy from Source/web/tests/WebSelectorTest.cpp
copy to Source/platform/fonts/FontPlatformDataTest.cpp
index 28b8f7adf51b08af3d251c9d027bde83a596e818..ecc0c37fe10b4e923761b28b783fda6bb30bedff 100644
--- a/Source/web/tests/WebSelectorTest.cpp
+++ b/Source/platform/fonts/FontPlatformDataTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2015 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,30 +29,50 @@
*/
#include "config.h"
-#include "public/web/WebSelector.h"
+#include "platform/fonts/Font.h"
-#include "public/platform/WebString.h"
+#include "platform/fonts/TestFontSelector.h"
+#include "platform/fonts/TypesettingFeatures.h"
#include "public/platform/WebUnitTestSupport.h"
+
#include <gtest/gtest.h>
namespace blink {
-TEST(WebSelectorTest, Canonicalizes)
+static inline String fontPath(String relativePath)
{
- EXPECT_EQ("h1, h2[style=\"foobar\"] span", canonicalizeSelector("h1,h2[style='foobar'] span").utf8());
- EXPECT_EQ("h1, h2[style=\"foobar\"] span", canonicalizeSelector("h1, h2[style=\"foobar\"] span").utf8());
+ return Platform::current()->unitTestSupport()->webKitRootDir()
+ + String("/LayoutTests/")
+ + relativePath;
}
-TEST(WebSelectorTest, Checks)
+TEST(FontPlatformDataTest, AhemHasNoSpaceInLigaturesOrKerning)
{
- EXPECT_EQ("", canonicalizeSelector("h1..h2").utf8());
- EXPECT_EQ("", canonicalizeSelector("h1..h2", WebSelectorTypeCompound).utf8());
+ Font font = createTestFont("Ahem", fontPath("resources/Ahem.woff"));
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+ TypesettingFeatures features = Kerning | Ligatures;
+
+ EXPECT_FALSE(platformData.hasSpaceInLigaturesOrKerning(features));
}
-TEST(WebSelectorTest, Restricts)
+TEST(FontPlatformDataTest, AhemSpaceLigatureHasSpaceInLigaturesOrKerning)
{
- EXPECT_EQ("", canonicalizeSelector("h1 span,h2", WebSelectorTypeCompound).utf8());
- EXPECT_EQ("h1, h2[style=\"foobar\"].cls", canonicalizeSelector("h1,h2[style=\"foobar\"].cls", WebSelectorTypeCompound).utf8());
+ Font font = createTestFont("AhemSpaceLigature",
+ fontPath("third_party/AhemSpaceLigature/AhemSpaceLigature.woff"));
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+ TypesettingFeatures features = Kerning | Ligatures;
+
+ EXPECT_TRUE(platformData.hasSpaceInLigaturesOrKerning(features));
+}
+
+TEST(FontPlatformDataTest, AhemSpaceLigatureHasNoSpaceWithoutFontFeatures)
+{
+ Font font = createTestFont("AhemSpaceLigature",
+ fontPath("third_party/AhemSpaceLigature/AhemSpaceLigature.woff"));
+ const FontPlatformData& platformData = font.primaryFont()->platformData();
+ TypesettingFeatures features = 0;
+
+ EXPECT_FALSE(platformData.hasSpaceInLigaturesOrKerning(features));
}
} // namespace blink
« no previous file with comments | « Source/platform/fonts/FontPlatformData.cpp ('k') | Source/platform/fonts/TestFontSelector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698