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_metrics.h" 20 21 using namespace testing; 22 using namespace testing::ext; 23 24 namespace OHOS { 25 namespace Rosen { 26 namespace TextEngine { 27 class TexgineFontMetricsTest : public testing::Test { 28 }; 29 30 /** 31 * @tc.name:SetFontMetrics 32 * @tc.desc: Verify the SetFontMetrics 33 * @tc.type:FUNC 34 */ 35 HWTEST_F(TexgineFontMetricsTest, SetFontMetrics, TestSize.Level1) 36 { 37 std::shared_ptr<TexgineFontMetrics> tfm = std::make_shared<TexgineFontMetrics>(); 38 #ifndef USE_ROSEN_DRAWING 39 std::shared_ptr<SkFontMetrics> sfm = std::make_shared<SkFontMetrics>(); 40 #else 41 std::shared_ptr<RSFontMetrics> sfm = std::make_shared<RSFontMetrics>(); 42 #endif 43 EXPECT_NO_THROW({ 44 tfm->SetFontMetrics(nullptr); 45 tfm->SetFontMetrics(sfm); 46 EXPECT_EQ(tfm->GetFontMetrics(), sfm); 47 }); 48 } 49 } // namespace TextEngine 50 } // namespace Rosen 51 } // namespace OHOS 52