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

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

Issue 2581083003: Initial OpenType Font Variations Support (Closed)
Patch Set: Fix hash collision tests, adjust test expectations Created 4 years 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
Index: third_party/WebKit/Source/platform/fonts/opentype/FontSettingsTest.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/opentype/FontSettingsTest.cpp b/third_party/WebKit/Source/platform/fonts/opentype/FontSettingsTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..191411826dc3180f6028a1b16b38c11b9d49eb44
--- /dev/null
+++ b/third_party/WebKit/Source/platform/fonts/opentype/FontSettingsTest.cpp
@@ -0,0 +1,44 @@
+// Copyright 2016 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/FontSettings.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/PassRefPtr.h"
+
+namespace blink {
+
+PassRefPtr<FontVariationSettings> makeFontVariationSettings(
+ std::initializer_list<FontVariationAxis> variationAxes) {
+ RefPtr<FontVariationSettings> variationSettings =
+ FontVariationSettings::create();
+
+ for (auto axis = variationAxes.begin(); axis != variationAxes.end(); ++axis) {
+ variationSettings->append(*axis);
+ }
+ return variationSettings;
+}
+
+TEST(FontSettingsTest, HashTest) {
+ RefPtr<FontVariationSettings> oneAxisA =
+ makeFontVariationSettings({FontVariationAxis{"a ", 0}});
+ RefPtr<FontVariationSettings> oneAxisB =
+ makeFontVariationSettings({FontVariationAxis{"b ", 0}});
+ RefPtr<FontVariationSettings> twoAxes = makeFontVariationSettings(
+ {FontVariationAxis{"a ", 0}, FontVariationAxis{"b ", 0}});
+ RefPtr<FontVariationSettings> twoAxesDifferentValue =
+ makeFontVariationSettings(
+ {FontVariationAxis{"a ", 0}, FontVariationAxis{"b ", 1}});
+
+ RefPtr<FontVariationSettings> emptyVariationSettings =
+ FontVariationSettings::create();
+
+ CHECK_NE(oneAxisA->hash(), oneAxisB->hash());
+ CHECK_NE(oneAxisA->hash(), twoAxes->hash());
+ CHECK_NE(oneAxisA->hash(), twoAxesDifferentValue->hash());
+ CHECK_NE(emptyVariationSettings->hash(), oneAxisA->hash());
+ CHECK_EQ(emptyVariationSettings->hash(), 0u);
+};
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698