1 /*
2 * Copyright (c) 2023 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 <gtest/gtest.h>
17 #include <gmock/gmock.h>
18
19 #include "texgine_font.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
setSize(SkScalar size)24 void SkFont::setSize(SkScalar size)
25 {
26 }
27
getMetrics(SkFontMetrics * metrics) const28 SkScalar SkFont::getMetrics(SkFontMetrics *metrics) const
29 {
30 return 1.0; // set getMetrics return value
31 }
32
33 namespace OHOS {
34 namespace Rosen {
35 namespace TextEngine {
36 class TexgineFontTest : public testing::Test {
37 };
38
39 /**
40 * @tc.name:SetTypeface
41 * @tc.desc: Verify the SetTypeface
42 * @tc.type:FUNC
43 */
44 HWTEST_F(TexgineFontTest, SetTypeface, TestSize.Level1)
45 {
46 std::shared_ptr<TexgineFont> tf = std::make_shared<TexgineFont>();
47 std::shared_ptr<TexgineTypeface> tt1 = nullptr;
48 std::shared_ptr<TexgineTypeface> tt2 = std::make_shared<TexgineTypeface>();
49 EXPECT_NO_THROW({
50 tf->SetTypeface(tt1);
51 tf->SetTypeface(tt2);
52 });
53 }
54
55 /**
56 * @tc.name:SetSize
57 * @tc.desc: Verify the SetSize
58 * @tc.type:FUNC
59 */
60 HWTEST_F(TexgineFontTest, SetSize, TestSize.Level1)
61 {
62 std::shared_ptr<TexgineFont> tf = std::make_shared<TexgineFont>();
63 EXPECT_NO_THROW({
64 tf->SetSize(0.0);
65 });
66 }
67
68 /**
69 * @tc.name:GetMetrics
70 * @tc.desc: Verify the GetMetrics
71 * @tc.type:FUNC
72 */
73 HWTEST_F(TexgineFontTest, GetMetrics, TestSize.Level1)
74 {
75 std::shared_ptr<TexgineFont> tf = std::make_shared<TexgineFont>();
76 std::shared_ptr<TexgineFontMetrics> tfm = std::make_shared<TexgineFontMetrics>();
77 EXPECT_NO_THROW({
78 EXPECT_EQ(tf->GetMetrics(nullptr), 0.0);
79 EXPECT_EQ(tf->GetMetrics(tfm), 1.0);
80 });
81 }
82 } // namespace TextEngine
83 } // namespace Rosen
84 } // namespace OHOS
85