• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace Rosen {
26 namespace TextEngine {
27 class TexgineFontStyleTest : public testing::Test {
28 };
29 
30 /**
31  * @tc.name:SetAndGet
32  * @tc.desc: Verify the SetAndGet
33  * @tc.type:FUNC
34  */
35 HWTEST_F(TexgineFontStyleTest, SetAndGet, TestSize.Level1)
36 {
37 #ifndef USE_ROSEN_DRAWING
38     std::shared_ptr<SkFontStyle> sfs1 = std::make_shared<SkFontStyle>();
39     std::shared_ptr<SkFontStyle> sfs2 = nullptr;
40 #else
41     std::shared_ptr<RSFontStyle> sfs1 = std::make_shared<RSFontStyle>();
42     std::shared_ptr<RSFontStyle> sfs2 = nullptr;
43 #endif
44     EXPECT_NO_THROW({
45         std::shared_ptr<TexgineFontStyle> tfs1 = std::make_shared<TexgineFontStyle>(sfs1);
46         EXPECT_EQ(tfs1->GetFontStyle(), sfs1);
47         tfs1->SetFontStyle(sfs2);
48         tfs1->SetStyle(*sfs1);
49         EXPECT_EQ(tfs1->GetFontStyle(), nullptr);
50 
51         std::shared_ptr<TexgineFontStyle> tfs2 = std::make_shared<TexgineFontStyle>();
52         tfs2->SetStyle(*sfs1);
53         EXPECT_EQ(*tfs2->GetFontStyle(), *sfs1);
54     });
55 }
56 } // namespace TextEngine
57 } // namespace Rosen
58 } // namespace OHOS
59