1 /*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <gtest/gtest.h>
18
19 #include "FontTestUtils.h"
20 #include "minikin/Constants.h"
21 #include "minikin/MinikinPaint.h"
22
23 namespace minikin {
24
TEST(MinikinPaintTest,variationSettings_empty_default)25 TEST(MinikinPaintTest, variationSettings_empty_default) {
26 auto fc = buildFontCollection("Ascii.ttf");
27 MinikinPaint paint(fc);
28 EXPECT_TRUE(paint.fontVariationSettings.empty());
29 }
30
TEST(MinikinPaintTest,variationSettings_varsettings_produce_different_hash)31 TEST(MinikinPaintTest, variationSettings_varsettings_produce_different_hash) {
32 auto fc = buildFontCollection("Ascii.ttf");
33 MinikinPaint left(fc);
34 MinikinPaint right(fc);
35 left.fontVariationSettings = VariationSettings({{TAG_wght, 400}, {TAG_ital, 1}});
36
37 EXPECT_NE(left, right);
38 }
39
TEST(MinikinPaintTest,variationSettings_different_varsettings)40 TEST(MinikinPaintTest, variationSettings_different_varsettings) {
41 auto fc = buildFontCollection("Ascii.ttf");
42 MinikinPaint left(fc);
43 MinikinPaint right(fc);
44 left.fontVariationSettings = VariationSettings({{TAG_wght, 400}, {TAG_ital, 1}});
45 right.fontVariationSettings = VariationSettings({{TAG_wght, 500}, {TAG_ital, 1}});
46
47 EXPECT_NE(left, right);
48 }
49
TEST(MinikinPaintTest,variationSettings)50 TEST(MinikinPaintTest, variationSettings) {
51 auto fc = buildFontCollection("Ascii.ttf");
52 MinikinPaint left(fc);
53 MinikinPaint right(fc);
54 left.fontVariationSettings = VariationSettings({{TAG_wght, 400}, {TAG_ital, 1}});
55 right.fontVariationSettings = VariationSettings({{TAG_ital, 1}, {TAG_wght, 400}});
56 EXPECT_EQ(left.hash(), right.hash());
57 EXPECT_EQ(left, right);
58 }
59
60 } // namespace minikin
61