• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, Hardware
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gtest/gtest.h"
17 
18 #include "text/font.h"
19 #include "text/font_harfbuzz.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 class FontHarfbuzzTest : public testing::Test {
28 public:
29     static void SetUpTestCase();
30     static void TearDownTestCase();
31     void SetUp() override;
32     void TearDown() override;
33 };
34 
SetUpTestCase()35 void FontHarfbuzzTest::SetUpTestCase() {}
TearDownTestCase()36 void FontHarfbuzzTest::TearDownTestCase() {}
SetUp()37 void FontHarfbuzzTest::SetUp() {}
TearDown()38 void FontHarfbuzzTest::TearDown() {}
39 
40 /**
41  * @tc.name: FontHarfbuzzSetNominalGlyphTest001
42  * @tc.desc:
43  * @tc.type: FUNC
44  * @tc.require:ICG6L3
45  * @tc.author:
46  */
47 HWTEST_F(FontHarfbuzzTest, FontHarfbuzzSetNominalGlyphTest001, TestSize.Level1)
48 {
49     Font font = Font();
50     hb_codepoint_t unicode = 0;
51     hb_codepoint_t glyph = 0;
52     bool ret = FontHarfbuzz::SetNominalGlyph(nullptr, (void*)&font, unicode, &glyph, nullptr);
53     ASSERT_FALSE(ret);
54 }
55 
56 /**
57  * @tc.name: FontHarfbuzzSetGlyphAdvanceTest001
58  * @tc.desc:
59  * @tc.type: FUNC
60  * @tc.require:ICG6L3
61  * @tc.author:
62  */
63 HWTEST_F(FontHarfbuzzTest, FontHarfbuzzSetGlyphAdvanceTest001, TestSize.Level1)
64 {
65     Font font = Font();
66     hb_codepoint_t glyph = 0;
67     hb_position_t position = FontHarfbuzz::SetGlyphAdvance(nullptr, (void*)&font, glyph, nullptr);
68     ASSERT_NE(position, 0);
69     font.SetSubpixel(true);
70     position = FontHarfbuzz::SetGlyphAdvance(nullptr, (void*)&font, glyph, nullptr);
71     ASSERT_NE(position, 0);
72 }
73 
74 /**
75  * @tc.name: FontHarfbuzzGetGlyphExtentsTest001
76  * @tc.desc:
77  * @tc.type: FUNC
78  * @tc.require:ICG6L3
79  * @tc.author:
80  */
81 HWTEST_F(FontHarfbuzzTest, FontHarfbuzzGetGlyphExtentsTest001, TestSize.Level1)
82 {
83     Font font = Font();
84     hb_codepoint_t glyph = 0;
85     hb_glyph_extents_t extents = { 0 };
86     bool ret = FontHarfbuzz::GetGlyphExtents(nullptr, (void*)&font, glyph, &extents, nullptr);
87     ASSERT_EQ(ret, true);
88     font.SetSubpixel(true);
89     ret = FontHarfbuzz::GetGlyphExtents(nullptr, (void*)&font, glyph, &extents, nullptr);
90     ASSERT_EQ(ret, true);
91 }
92 } // namespace Drawing
93 } // namespace Rosen
94 } // namespace OHOS
95