1 /*
2  * Copyright (c) 2022 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TEXT_STYLE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TEXT_STYLE_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "testing_color.h"
23 #include "testing_pen.h"
24 #include "testing_point.h"
25 
26 namespace OHOS::Ace::Testing {
27 enum class TestingFontWeight {
28     W100, // thin
29     W200,
30     W300,
31     W400,
32     W500,
33     W600,
34     W700,
35     W800,
36     W900,
37 };
38 
39 enum class TestingTextDecoration {
40     NONE = 0x0,
41     UNDERLINE = 0x1,
42     OVERLINE = 0x2,
43 #ifndef USE_GRAPHIC_TEXT_GINE
44     LINETHROUGH = 0x4,
45 #else
46     LINE_THROUGH = 0x4,
47 #endif
48 };
49 
50 enum class TestingTextDecorationStyle {
51     SOLID,
52     DOUBLE,
53     DOTTED,
54     DASHED,
55     WAVY,
56 };
57 
58 enum class TestingFontStyle {
59     NORMAL,
60     ITALIC,
61 };
62 
63 enum class TestingTextBaseline {
64     ALPHABETIC,
65     IDEOGRAPHIC,
66 };
67 
68 class TestingTextShadow {
69 public:
70     TestingTextShadow() = default;
71     virtual ~TestingTextShadow() = default;
72 
hasShadow()73     virtual bool hasShadow() const
74     {
75         return false;
76     }
77 
78 #ifndef USE_GRAPHIC_TEXT_GINE
79     TestingColor color_;
80     TestingPoint offset_;
81     double blurRadius_ = 0.0;
82 #else
83     TestingColor color;
84     TestingPoint offset;
85     double blurRadius = 0.0;
86 #endif
87 };
88 
89 class TestingFontFeatures {
90 public:
91     TestingFontFeatures() = default;
92     virtual ~TestingFontFeatures() = default;
93 };
94 
95 class TestingTextStyle {
96 public:
97     TestingTextStyle() = default;
98     ~TestingTextStyle() = default;
99 
equals(const TestingTextStyle &)100     virtual bool equals(const TestingTextStyle& /* rhs */) const
101     {
102         return false;
103     }
104 
105 #ifndef USE_GRAPHIC_TEXT_GINE
106     double decorationThicknessMultiplier_ = 1.0;
107     double fontSize_ = 14.0;
108     double letterSpacing_ = 0.0;
109     double wordSpacing_ = 0.0;
110     double height_ = 1.0;
111     bool hasHeightOverride_ = false;
112     bool hasBackground_ = false;
113     bool hasForeground_ = false;
114     std::u16string ellipsis_;
115     std::string locale_;
116     std::vector<std::string> fontFamilies_;
117     TestingColor color_;
118     TestingTextDecoration decoration_ = TestingTextDecoration::NONE;
119     TestingColor decorationColor_;
120     TestingPen background_;
121     TestingPen foreground_;
122     TestingTextDecorationStyle decorationStyle_ = TestingTextDecorationStyle::SOLID;
123     TestingFontWeight fontWeight_ = TestingFontWeight::W400;
124     TestingFontStyle fontStyle_ = TestingFontStyle::NORMAL;
125     TestingTextBaseline textBaseline_ = TestingTextBaseline::ALPHABETIC;
126     std::vector<TestingTextShadow> textShadows_;
127     TestingFontFeatures fontFeatures_;
128 #else
129     double decorationThicknessMultiplier = 1.0;
130     double fontSize = 14.0;
131     double letterSpacing = 0.0;
132     double wordSpacing = 0.0;
133     double heightScale = 1.0;
134     bool heightOnly = false;
135     bool hasBackground = false;
136     bool hasForeground = false;
137     std::u16string ellipsis;
138     std::string locale;
139     std::vector<std::string> fontFamilies;
140     TestingColor color;
141     TestingTextDecoration decoration = TestingTextDecoration::NONE;
142     TestingColor decorationColor;
143     TestingPen background;
144     TestingPen foreground;
145     TestingTextDecorationStyle decorationStyle = TestingTextDecorationStyle::SOLID;
146     TestingFontWeight fontWeight = TestingFontWeight::W400;
147     TestingFontStyle fontStyle = TestingFontStyle::NORMAL;
148     TestingTextBaseline baseline = TestingTextBaseline::ALPHABETIC;
149     std::vector<TestingTextShadow> textShadows;
150     TestingFontFeatures fontFeatures;
151 #endif
152 };
153 } // namespace OHOS::Ace::Testing
154 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TEXT_STYLE_H
155