• 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_paint.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
setColor(SkColor color)24 void SkPaint::setColor(SkColor color)
25 {
26 }
27 
setAlphaf(float a)28 void SkPaint::setAlphaf(float a)
29 {
30 }
31 
setStrokeWidth(SkScalar width)32 void SkPaint::setStrokeWidth(SkScalar width)
33 {
34 }
35 
setARGB(U8CPU a,U8CPU r,U8CPU g,U8CPU b)36 void SkPaint::setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
37 {
38 }
39 
setStyle(Style style)40 void SkPaint::setStyle(Style style)
41 {
42 }
43 
setPathEffect(sk_sp<SkPathEffect> pathEffect)44 void SkPaint::setPathEffect(sk_sp<SkPathEffect> pathEffect)
45 {
46 }
47 
setMaskFilter(sk_sp<SkMaskFilter> maskFilter)48 void SkPaint::setMaskFilter(sk_sp<SkMaskFilter> maskFilter)
49 {
50 }
51 
setBlendMode(SkBlendMode mode)52 void SkPaint::setBlendMode(SkBlendMode mode)
53 {
54 }
55 
56 namespace OHOS {
57 namespace Rosen {
58 namespace TextEngine {
59 class TexginePaintTest : public testing::Test {
60 };
61 
62 /**
63  * @tc.name:SetPaint
64  * @tc.desc: Verify the SetPaint
65  * @tc.type:FUNC
66  */
67 HWTEST_F(TexginePaintTest, SetPaint, TestSize.Level1)
68 {
69     std::shared_ptr<TexginePaint> tp = std::make_shared<TexginePaint>();
70 #ifndef USE_ROSEN_DRAWING
71     std::shared_ptr<SkPaint> sp = std::make_shared<SkPaint>();
72     EXPECT_NO_THROW({
73         tp->SetPaint(*sp);
74         EXPECT_EQ(tp->GetPaint(), *sp);
75     });
76 #else
77     std::shared_ptr<RSBrush> brush = std::make_shared<RSBrush>();
78     std::shared_ptr<RSPen> pen = std::make_shared<RSPen>();
79     EXPECT_NO_THROW({
80         tp->SetBrush(*brush);
81         EXPECT_EQ(tp->GetBrush(), *brush);
82     });
83     EXPECT_NO_THROW({
84         tp->SetPen(*pen);
85         EXPECT_EQ(tp->GetPen(), *pen);
86     });
87 #endif
88 }
89 
90 /**
91  * @tc.name:SetFunctions
92  * @tc.desc: Verify the SetFunctions
93  * @tc.type:FUNC
94  */
95 HWTEST_F(TexginePaintTest, SetFunctions, TestSize.Level1)
96 {
97     std::shared_ptr<TexginePaint> tp = std::make_shared<TexginePaint>();
98     std::shared_ptr<TexginePathEffect> tpe = std::make_shared<TexginePathEffect>();
99     std::shared_ptr<TexgineMaskFilter> tmf = std::make_shared<TexgineMaskFilter>();
100     EXPECT_NO_THROW({
101         tp->SetColor(0);
102         tp->SetAlphaf(0);
103         tp->SetStrokeWidth(0);
104         tp->SetAntiAlias(true);
105         tp->SetARGB(0, 0, 0, 0);
106         tp->SetStyle(TexginePaint::Style::FILL);
107         tp->SetPathEffect(tpe);
108         tpe = nullptr;
109         tp->SetPathEffect(tpe);
110         tp->SetMaskFilter(tmf);
111         tmf = nullptr;
112         tp->SetMaskFilter(tmf);
113         tp->SetAlpha(0);
114         tp->SetBlendMode(TexginePaint::TexgineBlendMode::CLEAR);
115     });
116 }
117 } // namespace TextEngine
118 } // namespace Rosen
119 } // namespace OHOS
120