1 /*
2 * Copyright (c) 2024 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, software
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 <cstddef>
17 #include "gtest/gtest.h"
18 #include "skia_adapter/skia_font_mgr.h"
19
20 using namespace testing;
21 using namespace testing::ext;
22
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class SkiaFontMgrTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp() override;
31 void TearDown() override;
32 };
33
SetUpTestCase()34 void SkiaFontMgrTest::SetUpTestCase() {}
TearDownTestCase()35 void SkiaFontMgrTest::TearDownTestCase() {}
SetUp()36 void SkiaFontMgrTest::SetUp() {}
TearDown()37 void SkiaFontMgrTest::TearDown() {}
38
39 #ifndef USE_TEXGINE
40 /**
41 * @tc.name: CreateDynamicFontMgr001
42 * @tc.desc: Test CreateDynamicFontMgr
43 * @tc.type: FUNC
44 * @tc.require: I91F9L
45 */
46 HWTEST_F(SkiaFontMgrTest, CreateDynamicFontMgr001, TestSize.Level1)
47 {
48 std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
49 ASSERT_TRUE(skiaFontMgr != nullptr);
50 }
51
52 /**
53 * @tc.name: LoadDynamicFont001
54 * @tc.desc: Test LoadDynamicFont
55 * @tc.type: FUNC
56 * @tc.require: I91F9L
57 */
58 HWTEST_F(SkiaFontMgrTest, LoadDynamicFont001, TestSize.Level1)
59 {
60 std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
61 ASSERT_TRUE(skiaFontMgr != nullptr);
62 skiaFontMgr->LoadDynamicFont("0", nullptr, 0);
63 skiaFontMgr->LoadDynamicFont("", nullptr, 0);
64 }
65
66 /**
67 * @tc.name: LoadThemeFont001
68 * @tc.desc: Test LoadThemeFont
69 * @tc.type: FUNC
70 * @tc.require: I91F9L
71 */
72 HWTEST_F(SkiaFontMgrTest, LoadThemeFont001, TestSize.Level1)
73 {
74 std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
75 ASSERT_TRUE(skiaFontMgr != nullptr);
76 skiaFontMgr->LoadThemeFont("0", "none", nullptr, 0);
77 }
78 #endif
79
80 /**
81 * @tc.name: MatchFamily001
82 * @tc.desc: Test MatchFamily
83 * @tc.type: FUNC
84 * @tc.require: I91F9L
85 */
86 HWTEST_F(SkiaFontMgrTest, MatchFamily001, TestSize.Level1)
87 {
88 std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
89 ASSERT_TRUE(skiaFontMgr != nullptr);
90 auto fontStyleSet = skiaFontMgr->MatchFamily("0");
91 ASSERT_TRUE(fontStyleSet != nullptr);
92 }
93
94 /**
95 * @tc.name: MatchFamilyStyle001
96 * @tc.desc: Test MatchFamilyStyle
97 * @tc.type: FUNC
98 * @tc.require: I91F9L
99 */
100 HWTEST_F(SkiaFontMgrTest, MatchFamilyStyle001, TestSize.Level1)
101 {
102 std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
103 ASSERT_TRUE(skiaFontMgr != nullptr);
104 FontStyle fontStyle;
105 auto typeface = skiaFontMgr->MatchFamilyStyle("0", fontStyle);
106 ASSERT_TRUE(typeface == nullptr);
107 }
108 } // namespace Drawing
109 } // namespace Rosen
110 } // namespace OHOS