• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
40  * @tc.name: CreateDynamicFontMgr001
41  * @tc.desc: Test CreateDynamicFontMgr
42  * @tc.type: FUNC
43  * @tc.require: I91F9L
44  */
45 HWTEST_F(SkiaFontMgrTest, CreateDynamicFontMgr001, TestSize.Level1)
46 {
47     std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
48     ASSERT_TRUE(skiaFontMgr != nullptr);
49 }
50 
51 /**
52  * @tc.name: LoadDynamicFont001
53  * @tc.desc: Test LoadDynamicFont
54  * @tc.type: FUNC
55  * @tc.require: I91F9L
56  */
57 HWTEST_F(SkiaFontMgrTest, LoadDynamicFont001, TestSize.Level1)
58 {
59     std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
60     ASSERT_TRUE(skiaFontMgr != nullptr);
61     skiaFontMgr->LoadDynamicFont("0", nullptr, 0);
62     skiaFontMgr->LoadDynamicFont("", nullptr, 0);
63 }
64 
65 /**
66  * @tc.name: LoadThemeFont001
67  * @tc.desc: Test LoadThemeFont
68  * @tc.type: FUNC
69  * @tc.require: I91F9L
70  */
71 HWTEST_F(SkiaFontMgrTest, LoadThemeFont001, TestSize.Level1)
72 {
73     std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
74     ASSERT_TRUE(skiaFontMgr != nullptr);
75     skiaFontMgr->LoadThemeFont("0", "none", nullptr, 0);
76 }
77 
78 /**
79  * @tc.name: MatchFamily001
80  * @tc.desc: Test MatchFamily
81  * @tc.type: FUNC
82  * @tc.require: I91F9L
83  */
84 HWTEST_F(SkiaFontMgrTest, MatchFamily001, TestSize.Level1)
85 {
86     std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
87     ASSERT_TRUE(skiaFontMgr != nullptr);
88     auto fontStyleSet = skiaFontMgr->MatchFamily("0");
89     ASSERT_TRUE(fontStyleSet != nullptr);
90 }
91 
92 /**
93  * @tc.name: MatchFamilyStyle001
94  * @tc.desc: Test MatchFamilyStyle
95  * @tc.type: FUNC
96  * @tc.require: I91F9L
97  */
98 HWTEST_F(SkiaFontMgrTest, MatchFamilyStyle001, TestSize.Level1)
99 {
100     std::shared_ptr<FontMgrImpl> skiaFontMgr = SkiaFontMgr::CreateDynamicFontMgr();
101     ASSERT_TRUE(skiaFontMgr != nullptr);
102     FontStyle fontStyle;
103     auto typeface = skiaFontMgr->MatchFamilyStyle("0", fontStyle);
104     ASSERT_TRUE(typeface == nullptr);
105 }
106 } // namespace Drawing
107 } // namespace Rosen
108 } // namespace OHOS