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_style_set.h" 20 21 using namespace testing; 22 using namespace testing::ext; 23 24 namespace OHOS { 25 namespace Rosen { 26 namespace TextEngine { 27 class TexgineFontStyleSetTest : public testing::Test { 28 }; 29 30 /** 31 * @tc.name:Count 32 * @tc.desc: Verify the Count 33 * @tc.type:FUNC 34 */ 35 HWTEST_F(TexgineFontStyleSetTest, Count, TestSize.Level1) 36 { 37 EXPECT_NO_THROW({ 38 std::shared_ptr<TexgineFontStyleSet> tfss1 = 39 std::make_shared<TexgineFontStyleSet>(nullptr); 40 tfss1->Count(); 41 42 std::shared_ptr<TexgineFontStyleSet> tfss2 = 43 #ifndef USE_ROSEN_DRAWING 44 std::make_shared<TexgineFontStyleSet>(SkFontStyleSet::CreateEmpty()); 45 #else 46 std::make_shared<TexgineFontStyleSet>(RSFontStyleSet::CreateEmpty()); 47 #endif 48 tfss2->Count(); 49 }); 50 } 51 52 /** 53 * @tc.name:GetStyle 54 * @tc.desc: Verify the GetStyle 55 * @tc.type:FUNC 56 */ 57 HWTEST_F(TexgineFontStyleSetTest, GetStyle, TestSize.Level1) 58 { 59 std::shared_ptr<TexgineFontStyle> tfs = std::make_shared<TexgineFontStyle>(); 60 std::shared_ptr<TexgineString> name = std::make_shared<TexgineString>(); 61 EXPECT_NO_THROW({ 62 std::shared_ptr<TexgineFontStyleSet> tfss1 = 63 std::make_shared<TexgineFontStyleSet>(nullptr); 64 tfss1->GetStyle(0, tfs, name); 65 66 std::shared_ptr<TexgineFontStyleSet> tfss2 = 67 #ifndef USE_ROSEN_DRAWING 68 std::make_shared<TexgineFontStyleSet>(SkFontStyleSet::CreateEmpty()); 69 #else 70 std::make_shared<TexgineFontStyleSet>(RSFontStyleSet::CreateEmpty()); 71 #endif 72 tfss2->GetStyle(0, nullptr, name); 73 74 std::shared_ptr<TexgineFontStyleSet> tfss3 = 75 #ifndef USE_ROSEN_DRAWING 76 std::make_shared<TexgineFontStyleSet>(SkFontStyleSet::CreateEmpty()); 77 #else 78 std::make_shared<TexgineFontStyleSet>(RSFontStyleSet::CreateEmpty()); 79 #endif 80 tfss3->GetStyle(0, tfs, nullptr); 81 82 std::shared_ptr<TexgineFontStyleSet> tfss4 = 83 #ifndef USE_ROSEN_DRAWING 84 std::make_shared<TexgineFontStyleSet>(SkFontStyleSet::CreateEmpty()); 85 #else 86 std::make_shared<TexgineFontStyleSet>(RSFontStyleSet::CreateEmpty()); 87 #endif 88 tfss4->GetStyle(0, tfs, name); 89 }); 90 } 91 92 /** 93 * @tc.name:CreateTypeface 94 * @tc.desc: Verify the CreateTypeface 95 * @tc.type:FUNC 96 */ 97 HWTEST_F(TexgineFontStyleSetTest, CreateTypeface, TestSize.Level1) 98 { 99 EXPECT_NO_THROW({ 100 std::shared_ptr<TexgineFontStyleSet> tfss1 = 101 std::make_shared<TexgineFontStyleSet>(nullptr); 102 tfss1->CreateTypeface(0); 103 104 std::shared_ptr<TexgineFontStyleSet> tfss2 = 105 #ifndef USE_ROSEN_DRAWING 106 std::make_shared<TexgineFontStyleSet>(SkFontStyleSet::CreateEmpty()); 107 #else 108 std::make_shared<TexgineFontStyleSet>(RSFontStyleSet::CreateEmpty()); 109 #endif 110 tfss2->CreateTypeface(0); 111 }); 112 } 113 114 /** 115 * @tc.name:MatchStyle 116 * @tc.desc: Verify the MatchStyle 117 * @tc.type:FUNC 118 */ 119 HWTEST_F(TexgineFontStyleSetTest, MatchStyle, TestSize.Level1) 120 { 121 std::shared_ptr<TexgineFontStyle> tfs = std::make_shared<TexgineFontStyle>(); 122 EXPECT_NO_THROW({ 123 std::shared_ptr<TexgineFontStyleSet> tfss1 = 124 std::make_shared<TexgineFontStyleSet>(nullptr); 125 tfss1->MatchStyle(tfs); 126 127 std::shared_ptr<TexgineFontStyleSet> tfss2 = 128 #ifndef USE_ROSEN_DRAWING 129 std::make_shared<TexgineFontStyleSet>(SkFontStyleSet::CreateEmpty()); 130 #else 131 std::make_shared<TexgineFontStyleSet>(RSFontStyleSet::CreateEmpty()); 132 #endif 133 tfss2->MatchStyle(nullptr); 134 135 std::shared_ptr<TexgineFontStyleSet> tfss3 = 136 #ifndef USE_ROSEN_DRAWING 137 std::make_shared<TexgineFontStyleSet>(SkFontStyleSet::CreateEmpty()); 138 #else 139 std::make_shared<TexgineFontStyleSet>(RSFontStyleSet::CreateEmpty()); 140 #endif 141 tfss3->MatchStyle(tfs); 142 143 tfs->SetFontStyle(nullptr); 144 std::shared_ptr<TexgineFontStyleSet> tfss4 = 145 #ifndef USE_ROSEN_DRAWING 146 std::make_shared<TexgineFontStyleSet>(SkFontStyleSet::CreateEmpty()); 147 #else 148 std::make_shared<TexgineFontStyleSet>(RSFontStyleSet::CreateEmpty()); 149 #endif 150 tfss4->MatchStyle(tfs); 151 }); 152 } 153 } // namespace TextEngine 154 } // namespace Rosen 155 } // namespace OHOS 156