• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 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 <fstream>
17 #include <string>
18 
19 #include "drawing_bitmap.h"
20 #include "drawing_brush.h"
21 #include "drawing_canvas.h"
22 #include "drawing_color.h"
23 #include "drawing_font.h"
24 #include "drawing_font_collection.h"
25 #include "drawing_path.h"
26 #include "drawing_pen.h"
27 #include "drawing_rect.h"
28 #include "drawing_point.h"
29 #include "drawing_text_declaration.h"
30 #include "drawing_text_typography.h"
31 #include "gtest/gtest.h"
32 #include "rosen_text/typography.h"
33 #include "rosen_text/typography_create.h"
34 #include "txt/text_bundle_config_parser.h"
35 
36 using namespace OHOS::Rosen;
37 using namespace testing;
38 using namespace testing::ext;
39 
40 namespace OHOS {
41 namespace {
42 const double LEFT_POS = 50.0;
43 const double RIGHT_POS = 150.0;
44 const double ARC_FONT_SIZE = 30;
45 const double MAX_WIDTH = 800.0;
46 const double SWEEP_DEGREE = 180.0;
47 constexpr static float FLOAT_DATA_EPSILON = 1e-6f;
48 } // namespace
49 
50 class OH_Drawing_TypographyTest : public testing::Test {
51 };
52 
ConvertToOriginalText(OH_Drawing_TypographyStyle * style)53 static TypographyStyle* ConvertToOriginalText(OH_Drawing_TypographyStyle* style)
54 {
55     return reinterpret_cast<TypographyStyle*>(style);
56 }
57 
ConvertToOriginalText(OH_Drawing_TextStyle * style)58 static TextStyle* ConvertToOriginalText(OH_Drawing_TextStyle* style)
59 {
60     return reinterpret_cast<TextStyle*>(style);
61 }
62 
63 /*
64  * @tc.name: OH_Drawing_TypographyTest001
65  * @tc.desc: test for creating TypographyStyle
66  * @tc.type: FUNC
67  */
68 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest001, TestSize.Level1)
69 {
70     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
71     EXPECT_NE(typoStyle, nullptr);
72     OH_Drawing_DestroyTypographyStyle(typoStyle);
73     OH_Drawing_DestroyTypographyStyle(nullptr);
74 }
75 
76 /*
77  * @tc.name: OH_Drawing_TypographyTest002
78  * @tc.desc: test for text direction
79  * @tc.type: FUNC
80  */
81 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest002, TestSize.Level1)
82 {
83     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
84     OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_LTR);
85     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::LTR);
86     OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_RTL);
87     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::RTL);
88     OH_Drawing_SetTypographyTextDirection(typoStyle, -1);
89     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::LTR);
90     OH_Drawing_SetTypographyTextDirection(nullptr, 0);
91     OH_Drawing_DestroyTypographyStyle(typoStyle);
92 }
93 
94 /*
95  * @tc.name: OH_Drawing_TypographyTest003
96  * @tc.desc: test for text alignment
97  * @tc.type: FUNC
98  */
99 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest003, TestSize.Level1)
100 {
101     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
102     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_LEFT);
103     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::LEFT);
104     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_RIGHT);
105     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::RIGHT);
106     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_CENTER);
107     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::CENTER);
108     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_JUSTIFY);
109     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::JUSTIFY);
110     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_START);
111     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::START);
112     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_END);
113     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::END);
114     OH_Drawing_SetTypographyTextAlign(typoStyle, -1);
115     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::LEFT);
116     OH_Drawing_SetTypographyTextAlign(nullptr, 0);
117     OH_Drawing_DestroyTypographyStyle(typoStyle);
118 }
119 
120 /*
121  * @tc.name: OH_Drawing_TypographyTest004
122  * @tc.desc: test for max lines
123  * @tc.type: FUNC
124  */
125 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest004, TestSize.Level1)
126 {
127     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
128     OH_Drawing_SetTypographyTextMaxLines(typoStyle, 100);
129     EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines, 100);
130     OH_Drawing_SetTypographyTextMaxLines(typoStyle, 200);
131     EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines, 200);
132     OH_Drawing_SetTypographyTextMaxLines(typoStyle, -100);
133     EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines, 0);
134     OH_Drawing_SetTypographyTextMaxLines(nullptr, 0);
135     OH_Drawing_DestroyTypographyStyle(typoStyle);
136 }
137 
138 /*
139  * @tc.name: OH_Drawing_TypographyTest005
140  * @tc.desc: test for creating text style
141  * @tc.type: FUNC
142  */
143 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest005, TestSize.Level1)
144 {
145     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
146     EXPECT_NE(txtStyle, nullptr);
147     OH_Drawing_DestroyTextStyle(txtStyle);
148     OH_Drawing_DestroyTextStyle(nullptr);
149 }
150 
151 /*
152  * @tc.name: OH_Drawing_TypographyTest006
153  * @tc.desc: test for text color
154  * @tc.type: FUNC
155  */
156 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest006, TestSize.Level1)
157 {
158     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
159     // black
160     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
161     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFF000000);
162     // red
163     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00));
164     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFFFF0000);
165     // blue
166     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0xFF));
167     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFF0000FF);
168     OH_Drawing_SetTextStyleColor(nullptr, 0);
169     OH_Drawing_DestroyTextStyle(txtStyle);
170 }
171 
172 /*
173  * @tc.name: OH_Drawing_TypographyTest007
174  * @tc.desc: test for font size
175  * @tc.type: FUNC
176  */
177 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest007, TestSize.Level1)
178 {
179     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
180     OH_Drawing_SetTextStyleFontSize(txtStyle, 80);
181     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize, 80);
182     OH_Drawing_SetTextStyleFontSize(txtStyle, 40);
183     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize, 40);
184     OH_Drawing_SetTextStyleFontSize(txtStyle, -40);
185     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize, -40);
186     OH_Drawing_SetTextStyleFontSize(nullptr, 0);
187     OH_Drawing_DestroyTextStyle(txtStyle);
188 }
189 
190 /*
191  * @tc.name: OH_Drawing_TypographyTest008
192  * @tc.desc: test for font weight
193  * @tc.type: FUNC
194  */
195 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest008, TestSize.Level1)
196 {
197     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
198     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_100);
199     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W100);
200     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_200);
201     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W200);
202     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_300);
203     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W300);
204     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
205     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W400);
206     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_500);
207     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W500);
208     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_600);
209     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W600);
210     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_700);
211     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W700);
212     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_800);
213     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W800);
214     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_900);
215     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W900);
216     OH_Drawing_SetTextStyleFontWeight(txtStyle, -1);
217     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W400);
218     OH_Drawing_SetTextStyleFontWeight(nullptr, 0);
219     OH_Drawing_DestroyTextStyle(txtStyle);
220 }
221 
222 /*
223  * @tc.name: OH_Drawing_TypographyTest009
224  * @tc.desc: test for baseline location
225  * @tc.type: FUNC
226  */
227 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest009, TestSize.Level1)
228 {
229     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
230     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
231     EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::ALPHABETIC);
232     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_IDEOGRAPHIC);
233     EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::IDEOGRAPHIC);
234     OH_Drawing_SetTextStyleBaseLine(txtStyle, -1);
235     EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::ALPHABETIC);
236     OH_Drawing_SetTextStyleBaseLine(nullptr, 0);
237     OH_Drawing_DestroyTextStyle(txtStyle);
238 }
239 
240 /*
241  * @tc.name: OH_Drawing_TypographyTest010
242  * @tc.desc: test for text decoration
243  * @tc.type: FUNC
244  */
245 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest010, TestSize.Level1)
246 {
247     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
248     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_NONE);
249     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::NONE);
250     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_UNDERLINE);
251     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE);
252     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_OVERLINE);
253     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::OVERLINE);
254     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_LINE_THROUGH);
255     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::LINE_THROUGH);
256     OH_Drawing_SetTextStyleDecoration(txtStyle, -1);
257     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::NONE);
258     OH_Drawing_SetTextStyleDecoration(nullptr, 0);
259     OH_Drawing_DestroyTextStyle(txtStyle);
260 }
261 
262 /*
263  * @tc.name: OH_Drawing_TypographyTest011
264  * @tc.desc: test for text decoration color
265  * @tc.type: FUNC
266  */
267 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest011, TestSize.Level1)
268 {
269     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
270     OH_Drawing_SetTextStyleDecorationColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
271     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor, 0xFF000000);
272     OH_Drawing_SetTextStyleDecorationColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00));
273     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor, 0xFFFF0000);
274     OH_Drawing_SetTextStyleDecorationColor(nullptr, 0);
275     OH_Drawing_DestroyTextStyle(txtStyle);
276 }
277 
278 /*
279  * @tc.name: OH_Drawing_TypographyTest012
280  * @tc.desc: test for font height
281  * @tc.type: FUNC
282  */
283 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest012, TestSize.Level1)
284 {
285     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
286     OH_Drawing_SetTextStyleFontHeight(txtStyle, 0.0);
287     EXPECT_EQ(ConvertToOriginalText(txtStyle)->heightScale, 0.0);
288     OH_Drawing_SetTextStyleFontHeight(txtStyle, -1.0);
289     EXPECT_EQ(ConvertToOriginalText(txtStyle)->heightScale, -1.0);
290     OH_Drawing_SetTextStyleFontHeight(nullptr, 0);
291     OH_Drawing_DestroyTextStyle(txtStyle);
292 }
293 
294 /*
295  * @tc.name: OH_Drawing_TypographyTest013
296  * @tc.desc: test for font families
297  * @tc.type: FUNC
298  */
299 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest013, TestSize.Level1)
300 {
301     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
302     const char* fontFamilies[] = { "Roboto", "Arial" };
303     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 2, fontFamilies);
304     std::vector<std::string> fontFamiliesResult = { "Roboto", "Arial" };
305     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontFamilies, fontFamiliesResult);
306     OH_Drawing_SetTextStyleFontFamilies(nullptr, 0, nullptr);
307     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 0, nullptr);
308     OH_Drawing_DestroyTextStyle(txtStyle);
309 }
310 
311 /*
312  * @tc.name: OH_Drawing_TypographyTest014
313  * @tc.desc: test for font italic
314  * @tc.type: FUNC
315  */
316 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest014, TestSize.Level1)
317 {
318     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
319     OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_NORMAL);
320     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::NORMAL);
321     OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_ITALIC);
322     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::ITALIC);
323     OH_Drawing_SetTextStyleFontStyle(txtStyle, -1);
324     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::NORMAL);
325     OH_Drawing_SetTextStyleFontStyle(nullptr, 0);
326     OH_Drawing_DestroyTextStyle(txtStyle);
327 }
328 
329 /*
330  * @tc.name: OH_Drawing_TypographyTest015
331  * @tc.desc: test for font locale
332  * @tc.type: FUNC
333  */
334 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest015, TestSize.Level1)
335 {
336     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
337     OH_Drawing_SetTextStyleLocale(txtStyle, "en");
338     EXPECT_EQ(ConvertToOriginalText(txtStyle)->locale, "en");
339     OH_Drawing_SetTextStyleLocale(txtStyle, "zh");
340     EXPECT_EQ(ConvertToOriginalText(txtStyle)->locale, "zh");
341     OH_Drawing_SetTextStyleLocale(nullptr, "");
342     OH_Drawing_DestroyTextStyle(txtStyle);
343 }
344 
345 /*
346  * @tc.name: OH_Drawing_TypographyTest016
347  * @tc.desc: test for typography
348  * @tc.type: FUNC
349  */
350 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest016, TestSize.Level1)
351 {
352     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
353     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
354     OH_Drawing_TypographyCreate* handler =
355         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
356     EXPECT_NE(handler, nullptr);
357 
358     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
359     double fontSize = 30;
360     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
361     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
362     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
363     const char* fontFamilies[] = { "Roboto" };
364     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
365     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
366     const char* text = "OpenHarmony\n";
367     OH_Drawing_TypographyHandlerAddText(handler, text);
368     OH_Drawing_TypographyHandlerPopTextStyle(handler);
369     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
370     const float indents[] = { 1.2, 3.4 };
371     OH_Drawing_TypographySetIndents(typography, 2, indents);
372     EXPECT_EQ(indents[1], OH_Drawing_TypographyGetIndentsWithIndex(typography, 1));
373     EXPECT_EQ(indents[0], OH_Drawing_TypographyGetIndentsWithIndex(typography, 0));
374     double maxWidth = 800.0;
375     OH_Drawing_TypographyLayout(typography, maxWidth);
376     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
377     double position[2] = { 10.0, 15.0 };
378     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
379     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
380     uint32_t width = 20;
381     uint32_t height = 40;
382     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
383     EXPECT_EQ(width, OH_Drawing_BitmapGetWidth(cBitmap));
384     EXPECT_EQ(height, OH_Drawing_BitmapGetHeight(cBitmap));
385     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
386     OH_Drawing_CanvasBind(cCanvas, cBitmap);
387     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
388     EXPECT_EQ(OH_Drawing_TypographyGetHeight(typography), 70);
389     EXPECT_EQ(static_cast<int>(OH_Drawing_TypographyGetLongestLine(typography)), 200);
390     EXPECT_TRUE(OH_Drawing_TypographyGetLongestLine(typography) <= maxWidth);
391     EXPECT_EQ(
392         OH_Drawing_TypographyGetMinIntrinsicWidth(typography), OH_Drawing_TypographyGetMaxIntrinsicWidth(typography));
393     EXPECT_EQ(static_cast<int>(OH_Drawing_TypographyGetAlphabeticBaseline(typography)), 27);
394     EXPECT_EQ(static_cast<int>(OH_Drawing_TypographyGetIdeographicBaseline(typography)), 35);
395     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
396     OH_Drawing_DestroyTypography(typography);
397     OH_Drawing_DestroyTypographyHandler(handler);
398     OH_Drawing_DestroyTextStyle(txtStyle);
399 }
400 
401 /*
402  * @tc.name: OH_Drawing_TypographyTest017
403  * @tc.desc: test for break strategy
404  * @tc.type: FUNC
405  */
406 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest017, TestSize.Level1)
407 {
408     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
409     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_GREEDY);
410     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy, BreakStrategy::GREEDY);
411     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_HIGH_QUALITY);
412     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy, BreakStrategy::HIGH_QUALITY);
413     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_BALANCED);
414     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy, BreakStrategy::BALANCED);
415     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, -1);
416     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy, BreakStrategy::GREEDY);
417     OH_Drawing_SetTypographyTextBreakStrategy(nullptr, 0);
418     OH_Drawing_DestroyTypographyStyle(typoStyle);
419 }
420 
421 /*
422  * @tc.name: OH_Drawing_TypographyTest018
423  * @tc.desc: test for word break type
424  * @tc.type: FUNC
425  */
426 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest018, TestSize.Level1)
427 {
428     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
429     OH_Drawing_SetTypographyTextWordBreakType(typoStyle, WORD_BREAK_TYPE_NORMAL);
430     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType, WordBreakType::NORMAL);
431     OH_Drawing_SetTypographyTextWordBreakType(typoStyle, WORD_BREAK_TYPE_BREAK_ALL);
432     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType, WordBreakType::BREAK_ALL);
433     OH_Drawing_SetTypographyTextWordBreakType(typoStyle, WORD_BREAK_TYPE_BREAK_WORD);
434     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType, WordBreakType::BREAK_WORD);
435     OH_Drawing_SetTypographyTextWordBreakType(typoStyle, -1);
436     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType, WordBreakType::BREAK_WORD);
437     OH_Drawing_SetTypographyTextWordBreakType(nullptr, 0);
438     OH_Drawing_DestroyTypographyStyle(typoStyle);
439 }
440 
441 /*
442  * @tc.name: OH_Drawing_TypographyTest019
443  * @tc.desc: test for ellipsis modal
444  * @tc.type: FUNC
445  */
446 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest019, TestSize.Level1)
447 {
448     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
449     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, ELLIPSIS_MODAL_HEAD);
450     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal, EllipsisModal::HEAD);
451     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, ELLIPSIS_MODAL_MIDDLE);
452     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal, EllipsisModal::MIDDLE);
453     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, ELLIPSIS_MODAL_TAIL);
454     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal, EllipsisModal::TAIL);
455     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, -1);
456     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal, EllipsisModal::TAIL);
457     OH_Drawing_SetTypographyTextEllipsisModal(nullptr, 0);
458     OH_Drawing_DestroyTypographyStyle(typoStyle);
459 }
460 
461 /*
462  * @tc.name: OH_Drawing_TypographyTest020
463  * @tc.desc: test for decoration style
464  * @tc.type: FUNC
465  */
466 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest020, TestSize.Level1)
467 {
468     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
469     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_SOLID);
470     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::SOLID);
471     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_DOUBLE);
472     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::DOUBLE);
473     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_DOTTED);
474     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::DOTTED);
475     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_DASHED);
476     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::DASHED);
477     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_WAVY);
478     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::WAVY);
479     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, -1);
480     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::SOLID);
481     OH_Drawing_SetTextStyleDecorationStyle(nullptr, 0);
482     OH_Drawing_DestroyTextStyle(txtStyle);
483 }
484 
485 /*
486  * @tc.name: OH_Drawing_TypographyTest021
487  * @tc.desc: test for decoration thickness scale
488  * @tc.type: FUNC
489  */
490 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest021, TestSize.Level1)
491 {
492     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
493     OH_Drawing_SetTextStyleDecorationThicknessScale(txtStyle, 10);
494     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationThicknessScale, 10);
495     OH_Drawing_SetTextStyleDecorationThicknessScale(txtStyle, 20);
496     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationThicknessScale, 20);
497     OH_Drawing_SetTextStyleDecorationThicknessScale(txtStyle, -20);
498     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationThicknessScale, -20);
499     OH_Drawing_SetTextStyleDecorationThicknessScale(nullptr, 0);
500     OH_Drawing_DestroyTextStyle(txtStyle);
501 }
502 
503 /*
504  * @tc.name: OH_Drawing_TypographyTest022
505  * @tc.desc: test for letter spacing
506  * @tc.type: FUNC
507  */
508 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest022, TestSize.Level1)
509 {
510     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
511     OH_Drawing_SetTextStyleLetterSpacing(txtStyle, 10);
512     EXPECT_EQ(ConvertToOriginalText(txtStyle)->letterSpacing, 10);
513     OH_Drawing_SetTextStyleLetterSpacing(txtStyle, 20);
514     EXPECT_EQ(ConvertToOriginalText(txtStyle)->letterSpacing, 20);
515     OH_Drawing_SetTextStyleLetterSpacing(txtStyle, -20);
516     EXPECT_EQ(ConvertToOriginalText(txtStyle)->letterSpacing, -20);
517     OH_Drawing_SetTextStyleLetterSpacing(nullptr, 0);
518     OH_Drawing_DestroyTextStyle(txtStyle);
519 }
520 
521 /*
522  * @tc.name: OH_Drawing_TypographyTest023
523  * @tc.desc: test for word spacing
524  * @tc.type: FUNC
525  */
526 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest023, TestSize.Level1)
527 {
528     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
529     OH_Drawing_SetTextStyleWordSpacing(txtStyle, 10);
530     EXPECT_EQ(ConvertToOriginalText(txtStyle)->wordSpacing, 10);
531     OH_Drawing_SetTextStyleWordSpacing(txtStyle, 20);
532     EXPECT_EQ(ConvertToOriginalText(txtStyle)->wordSpacing, 20);
533     OH_Drawing_SetTextStyleWordSpacing(txtStyle, -20);
534     EXPECT_EQ(ConvertToOriginalText(txtStyle)->wordSpacing, -20);
535     OH_Drawing_SetTextStyleWordSpacing(nullptr, 0);
536     OH_Drawing_DestroyTextStyle(txtStyle);
537 }
538 
539 /*
540  * @tc.name: OH_Drawing_TypographyTest024
541  * @tc.desc: test for ellipsis modal
542  * @tc.type: FUNC
543  */
544 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest024, TestSize.Level1)
545 {
546     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
547     OH_Drawing_SetTextStyleEllipsisModal(txtStyle, ELLIPSIS_MODAL_HEAD);
548     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal, EllipsisModal::HEAD);
549     OH_Drawing_SetTextStyleEllipsisModal(txtStyle, ELLIPSIS_MODAL_MIDDLE);
550     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal, EllipsisModal::MIDDLE);
551     OH_Drawing_SetTextStyleEllipsisModal(txtStyle, ELLIPSIS_MODAL_TAIL);
552     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal, EllipsisModal::TAIL);
553     OH_Drawing_SetTextStyleEllipsisModal(txtStyle, -1);
554     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal, EllipsisModal::TAIL);
555     OH_Drawing_SetTextStyleEllipsisModal(nullptr, 0);
556     OH_Drawing_DestroyTextStyle(txtStyle);
557 }
558 
559 /*
560  * @tc.name: OH_Drawing_TypographyTest025
561  * @tc.desc: test for set ellipsis
562  * @tc.type: FUNC
563  */
564 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest025, TestSize.Level1)
565 {
566     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
567     OH_Drawing_SetTextStyleEllipsis(txtStyle, "...");
568     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsis, u"...");
569     OH_Drawing_SetTextStyleEllipsis(txtStyle, "hello");
570     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsis, u"hello");
571     OH_Drawing_SetTextStyleEllipsis(nullptr, nullptr);
572     OH_Drawing_SetTextStyleEllipsis(txtStyle, nullptr);
573     OH_Drawing_DestroyTextStyle(txtStyle);
574 }
575 
576 /*
577  * @tc.name: OH_Drawing_TypographyTest026
578  * @tc.desc: test for typography and txtStyle
579  * @tc.type: FUNC
580  */
581 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest026, TestSize.Level1)
582 {
583     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
584     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
585     OH_Drawing_TypographyCreate* handler =
586         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
587     EXPECT_NE(handler, nullptr);
588     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
589     double fontSize = 30;
590     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
591     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
592     bool halfLeading = true;
593     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
594     const char* fontFamilies[] = { "Roboto" };
595     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
596     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
597     const char* text = "OpenHarmony\n";
598     OH_Drawing_TypographyHandlerAddText(handler, text);
599     OH_Drawing_PlaceholderSpan placeholderSpan = { 20, 40, ALIGNMENT_OFFSET_AT_BASELINE, TEXT_BASELINE_ALPHABETIC, 10 };
600     OH_Drawing_TypographyHandlerAddPlaceholder(handler, &placeholderSpan);
601     OH_Drawing_TypographyHandlerPopTextStyle(handler);
602     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
603     double maxWidth = 800.0;
604     OH_Drawing_TypographyLayout(typography, maxWidth);
605     double position[2] = { 10.0, 15.0 };
606     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
607     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
608     uint32_t width = 20;
609     uint32_t height = 40;
610     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
611     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
612     OH_Drawing_CanvasBind(cCanvas, cBitmap);
613     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
614     EXPECT_NE(OH_Drawing_TypographyDidExceedMaxLines(typography), true);
615     OH_Drawing_RectHeightStyle heightStyle = RECT_HEIGHT_STYLE_TIGHT;
616     OH_Drawing_RectWidthStyle widthStyle = RECT_WIDTH_STYLE_TIGHT;
617     auto box = OH_Drawing_TypographyGetRectsForRange(typography, 1, 2, heightStyle, widthStyle);
618     EXPECT_NE(box, nullptr);
619     OH_Drawing_GetRightFromTextBox(box, 0);
620     EXPECT_NE(OH_Drawing_TypographyGetRectsForPlaceholders(typography), nullptr);
621     EXPECT_NE(OH_Drawing_TypographyGetGlyphPositionAtCoordinate(typography, 1, 0), nullptr);
622     EXPECT_NE(OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster(typography, 1, 0), nullptr);
623     EXPECT_NE(OH_Drawing_TypographyGetWordBoundary(typography, 1), nullptr);
624     EXPECT_NE(OH_Drawing_TypographyGetLineTextRange(typography, 1, true), nullptr);
625     EXPECT_NE(OH_Drawing_TypographyGetLineCount(typography), 0);
626     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
627     OH_Drawing_DestroyTypography(typography);
628     OH_Drawing_DestroyTypographyHandler(handler);
629     OH_Drawing_DestroyTypographyStyle(typoStyle);
630 }
631 
632 /*
633  * @tc.name: OH_Drawing_TypographyTest027
634  * @tc.desc: test for getting line info for text typography
635  * @tc.type: FUNC
636  */
637 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest027, TestSize.Level1)
638 {
639     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
640     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
641     OH_Drawing_TypographyCreate* handler =
642         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
643     EXPECT_NE(handler, nullptr);
644     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
645     double fontSize = 30;
646     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
647     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
648     bool halfLeading = true;
649     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
650     const char* fontFamilies[] = { "Roboto" };
651     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
652     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
653     const char* text = "OpenHarmony\n";
654     OH_Drawing_TypographyHandlerAddText(handler, text);
655     OH_Drawing_TypographyHandlerPopTextStyle(handler);
656     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
657     double maxWidth = 800.0;
658     OH_Drawing_TypographyLayout(typography, maxWidth);
659     double position[2] = { 10.0, 15.0 };
660     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
661     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
662     uint32_t width = 20;
663     uint32_t height = 40;
664     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
665     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
666     OH_Drawing_CanvasBind(cCanvas, cBitmap);
667     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
668     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
669     int lineNum = 0;
670     bool oneLine = true;
671     bool includeWhitespace = true;
672     OH_Drawing_LineMetrics lineMetrics;
673     EXPECT_FALSE(OH_Drawing_TypographyGetLineInfo(typography, lineNum, oneLine, includeWhitespace, nullptr));
674     EXPECT_FALSE(OH_Drawing_TypographyGetLineInfo(typography, -1, oneLine, includeWhitespace, &lineMetrics));
675     EXPECT_TRUE(OH_Drawing_TypographyGetLineInfo(typography, lineNum, oneLine, includeWhitespace, &lineMetrics));
676     OH_Drawing_DestroyTypography(typography);
677     OH_Drawing_DestroyTypographyHandler(handler);
678     OH_Drawing_DestroyTypographyStyle(typoStyle);
679 }
680 
681 /*
682  * @tc.name: OH_Drawing_TypographyTest028
683  * @tc.desc: test for getting line info for text typography
684  * @tc.type: FUNC
685  */
686 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest028, TestSize.Level1)
687 {
688     OH_Drawing_TextShadow* textShadow = OH_Drawing_CreateTextShadow();
689     EXPECT_NE(textShadow, nullptr);
690     OH_Drawing_DestroyTextShadow(textShadow);
691     OH_Drawing_DestroyTextShadow(nullptr);
692 }
693 
694 /*
695  * @tc.name: OH_Drawing_TypographyTest029
696  * @tc.desc: test for font weight of text typography
697  * @tc.type: FUNC
698  */
699 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest029, TestSize.Level1)
700 {
701     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
702     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_100);
703     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W100);
704     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_200);
705     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W200);
706     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_300);
707     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W300);
708     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_400);
709     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W400);
710     OH_Drawing_SetTypographyTextFontWeight(nullptr, FONT_WEIGHT_100);
711     OH_Drawing_DestroyTypographyStyle(typoStyle);
712 }
713 
714 /*
715  * @tc.name: OH_Drawing_TypographyTest030
716  * @tc.desc: test for font style of text typography
717  * @tc.type: FUNC
718  */
719 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest030, TestSize.Level1)
720 {
721     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
722     OH_Drawing_SetTypographyTextFontStyle(typoStyle, FONT_STYLE_NORMAL);
723     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle, FontStyle::NORMAL);
724     OH_Drawing_SetTypographyTextFontStyle(typoStyle, FONT_STYLE_ITALIC);
725     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle, FontStyle::ITALIC);
726     OH_Drawing_SetTypographyTextFontStyle(typoStyle, -1);
727     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle, FontStyle::NORMAL);
728     OH_Drawing_SetTypographyTextFontStyle(nullptr, 0);
729     OH_Drawing_DestroyTypographyStyle(typoStyle);
730 }
731 
732 /*
733  * @tc.name: OH_Drawing_TypographyTest031
734  * @tc.desc: test for font family of text typography
735  * @tc.type: FUNC
736  */
737 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest031, TestSize.Level1)
738 {
739     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
740     OH_Drawing_SetTypographyTextFontFamily(typoStyle, "monospace");
741     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontFamily, "monospace");
742     OH_Drawing_SetTypographyTextFontFamily(nullptr, nullptr);
743     OH_Drawing_DestroyTypographyStyle(typoStyle);
744     OH_Drawing_DestroyTypographyStyle(nullptr);
745 }
746 
747 /*
748  * @tc.name: OH_Drawing_TypographyTest032
749  * @tc.desc: test for font size of text typography
750  * @tc.type: FUNC
751  */
752 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest032, TestSize.Level1)
753 {
754     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
755     OH_Drawing_SetTypographyTextFontSize(typoStyle, 80);
756     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontSize, 80);
757     OH_Drawing_SetTypographyTextFontSize(typoStyle, 40);
758     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontSize, 40);
759     // -1 is invalid value
760     OH_Drawing_SetTypographyTextFontSize(typoStyle, -1);
761     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontSize, -1);
762     OH_Drawing_SetTypographyTextFontSize(nullptr, 0);
763     OH_Drawing_DestroyTypographyStyle(typoStyle);
764 }
765 
766 /*
767  * @tc.name: OH_Drawing_TypographyTest033
768  * @tc.desc: test for font height of text typography
769  * @tc.type: FUNC
770  */
771 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest033, TestSize.Level1)
772 {
773     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
774     OH_Drawing_SetTypographyTextFontHeight(typoStyle, 0.0);
775     EXPECT_EQ(ConvertToOriginalText(typoStyle)->heightScale, 0.0);
776     // -1 is invalid value
777     OH_Drawing_SetTypographyTextFontHeight(typoStyle, -1);
778     EXPECT_EQ(ConvertToOriginalText(typoStyle)->heightScale, 0);
779     OH_Drawing_SetTypographyTextFontHeight(nullptr, 0);
780     OH_Drawing_DestroyTypographyStyle(typoStyle);
781 }
782 
783 /*
784  * @tc.name: OH_Drawing_TypographyTest034
785  * @tc.desc: test for font style of line style for text typography
786  * @tc.type: FUNC
787  */
788 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest034, TestSize.Level1)
789 {
790     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
791     OH_Drawing_SetTypographyTextLineStyleFontStyle(typoStyle, FONT_STYLE_NORMAL);
792     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle, FontStyle::NORMAL);
793     OH_Drawing_SetTypographyTextLineStyleFontStyle(typoStyle, FONT_STYLE_ITALIC);
794     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle, FontStyle::ITALIC);
795     OH_Drawing_SetTypographyTextLineStyleFontStyle(typoStyle, -1);
796     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle, FontStyle::NORMAL);
797     OH_Drawing_SetTypographyTextLineStyleFontStyle(nullptr, 0);
798     OH_Drawing_DestroyTypographyStyle(typoStyle);
799 }
800 
801 /*
802  * @tc.name: OH_Drawing_TypographyTest035
803  * @tc.desc: test for font weight of line style for text typography
804  * @tc.type: FUNC
805  */
806 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest035, TestSize.Level1)
807 {
808     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
809     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_100);
810     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W100);
811     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_200);
812     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W200);
813     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_300);
814     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W300);
815     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_400);
816     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W400);
817     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_500);
818     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W500);
819     OH_Drawing_SetTypographyTextLineStyleFontWeight(nullptr, 0);
820     OH_Drawing_DestroyTypographyStyle(typoStyle);
821 }
822 
823 /*
824  * @tc.name: OH_Drawing_TypographyTest036
825  * @tc.desc: test for font size of line style for text typography
826  * @tc.type: FUNC
827  */
828 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest036, TestSize.Level1)
829 {
830     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
831     OH_Drawing_SetTypographyTextLineStyleFontSize(typoStyle, 80);
832     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontSize, 80);
833     OH_Drawing_SetTypographyTextLineStyleFontSize(typoStyle, 40);
834     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontSize, 40);
835     OH_Drawing_SetTypographyTextLineStyleFontSize(nullptr, 0);
836     OH_Drawing_DestroyTypographyStyle(typoStyle);
837 }
838 
839 /*
840  * @tc.name: OH_Drawing_TypographyTest037
841  * @tc.desc: test for font families of line style for text typography
842  * @tc.type: FUNC
843  */
844 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest037, TestSize.Level1)
845 {
846     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
847     const char* fontFamilies[] = { "Roboto" };
848     OH_Drawing_SetTypographyTextLineStyleFontFamilies(typoStyle, 1, fontFamilies);
849     std::vector<std::string> fontFamiliesResult = { "Roboto" };
850     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontFamilies, fontFamiliesResult);
851     OH_Drawing_SetTypographyTextLineStyleFontFamilies(nullptr, 0, nullptr);
852     OH_Drawing_SetTypographyTextLineStyleFontFamilies(typoStyle, 0, nullptr);
853     OH_Drawing_DestroyTypographyStyle(typoStyle);
854 }
855 
856 /*
857  * @tc.name: OH_Drawing_TypographyTest038
858  * @tc.desc: test for spacing scale of line style for text typography
859  * @tc.type: FUNC
860  */
861 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest038, TestSize.Level1)
862 {
863     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
864     OH_Drawing_SetTypographyTextLineStyleSpacingScale(typoStyle, 1.0);
865     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleSpacingScale, 1.0);
866     OH_Drawing_SetTypographyTextLineStyleSpacingScale(typoStyle, 2.0);
867     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleSpacingScale, 2.0);
868     OH_Drawing_SetTypographyTextLineStyleSpacingScale(nullptr, 0);
869     OH_Drawing_DestroyTypographyStyle(typoStyle);
870 }
871 
872 /*
873  * @tc.name: OH_Drawing_TypographyTest039
874  * @tc.desc: test for font height of line style for text typography
875  * @tc.type: FUNC
876  */
877 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest039, TestSize.Level1)
878 {
879     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
880     OH_Drawing_SetTypographyTextLineStyleFontHeight(typoStyle, 0.0);
881     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleHeightScale, 0.0);
882     OH_Drawing_SetTypographyTextLineStyleFontHeight(nullptr, 0);
883     OH_Drawing_DestroyTypographyStyle(typoStyle);
884 }
885 
886 /*
887  * @tc.name: OH_Drawing_TypographyTest040
888  * @tc.desc: test for line metrics for text typography
889  * @tc.type: FUNC
890  */
891 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest040, TestSize.Level1)
892 {
893     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
894     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
895     OH_Drawing_TypographyCreate* handler =
896         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
897     EXPECT_NE(handler, nullptr);
898     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
899     double fontSize = 30;
900     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
901     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
902     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
903     const char* fontFamilies[] = { "Roboto" };
904     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
905     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
906     const char* text = "OpenHarmony\n";
907     OH_Drawing_TypographyHandlerAddText(handler, text);
908     OH_Drawing_TypographyHandlerPopTextStyle(handler);
909     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
910     double maxWidth = 800.0;
911     OH_Drawing_TypographyLayout(typography, maxWidth);
912     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
913     double position[2] = { 10.0, 15.0 };
914     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
915     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
916     uint32_t width = 20;
917     uint32_t height = 40;
918     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
919     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
920     OH_Drawing_CanvasBind(cCanvas, cBitmap);
921     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
922     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
923     OH_Drawing_FontDescriptor* descriptor = OH_Drawing_CreateFontDescriptor();
924     OH_Drawing_FontParser* parser = OH_Drawing_CreateFontParser();
925 
926     static const std::string FILE_NAME = "/system/fonts/visibility_list.json";
927     std::ifstream fileStream(FILE_NAME.c_str());
928     if (fileStream.is_open()) {
929         size_t fontNum;
930         char** list = OH_Drawing_FontParserGetSystemFontList(parser, &fontNum);
931         EXPECT_NE(list, nullptr);
932         const char* name = list[0];
933         EXPECT_NE(OH_Drawing_FontParserGetFontByName(parser, name), nullptr);
934         OH_Drawing_DestroySystemFontList(list, fontNum);
935     }
936     OH_Drawing_DestroyFontParser(parser);
937     OH_Drawing_DestroyFontDescriptor(descriptor);
938     OH_Drawing_LineMetrics* vectorMetrics = OH_Drawing_TypographyGetLineMetrics(typography);
939     EXPECT_NE(vectorMetrics, nullptr);
940     EXPECT_NE(OH_Drawing_LineMetricsGetSize(vectorMetrics), 0);
941     OH_Drawing_DestroyLineMetrics(vectorMetrics);
942     OH_Drawing_LineMetrics* metrics = new OH_Drawing_LineMetrics();
943     EXPECT_TRUE(OH_Drawing_TypographyGetLineMetricsAt(typography, 0, metrics));
944     OH_Drawing_DestroyTypography(typography);
945     OH_Drawing_DestroyTypographyHandler(handler);
946 }
947 
948 /*
949  * @tc.name: OH_Drawing_TypographyTest041
950  * @tc.desc: test for font weight of line style for text typography
951  * @tc.type: FUNC
952  */
953 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest041, TestSize.Level1)
954 {
955     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
956     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_600);
957     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W600);
958     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_700);
959     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W700);
960     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_800);
961     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W800);
962     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_900);
963     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W900);
964     OH_Drawing_SetTypographyTextLineStyleFontWeight(nullptr, 0);
965     OH_Drawing_DestroyTypographyStyle(typoStyle);
966 }
967 
968 /*
969  * @tc.name: OH_Drawing_TypographyTest042
970  * @tc.desc: test for text shadow for textstyle
971  * @tc.type: FUNC
972  */
973 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest042, TestSize.Level1)
974 {
975     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
976     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
977     OH_Drawing_TypographyCreate* handler =
978         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
979     EXPECT_NE(handler, nullptr);
980     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
981     double fontSize = 30;
982     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
983     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
984     bool halfLeading = true;
985     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
986     const char* fontFamilies[] = { "Roboto" };
987     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
988     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
989     const char* text = "OpenHarmony\n";
990     OH_Drawing_TypographyHandlerAddText(handler, text);
991     OH_Drawing_TypographyHandlerPopTextStyle(handler);
992     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
993     double maxWidth = 800.0;
994     OH_Drawing_TypographyLayout(typography, maxWidth);
995     double position[2] = { 10.0, 15.0 };
996     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
997     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
998     uint32_t width = 20;
999     uint32_t height = 40;
1000     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1001     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1002     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1003     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1004     EXPECT_NE(OH_Drawing_TextStyleGetShadows(txtStyle), nullptr);
1005     OH_Drawing_TextStyleClearShadows(txtStyle);
1006     OH_Drawing_TextShadow* textshadows = OH_Drawing_TextStyleGetShadows(txtStyle);
1007     OH_Drawing_DestroyTextShadows(textshadows);
1008     OH_Drawing_DestroyTextShadows(nullptr);
1009     OH_Drawing_TextStyleAddShadow(txtStyle, nullptr);
1010     OH_Drawing_TextStyleAddShadow(txtStyle, OH_Drawing_CreateTextShadow());
1011     EXPECT_NE(OH_Drawing_TextStyleGetShadowWithIndex(txtStyle, 0), nullptr);
1012     EXPECT_EQ(OH_Drawing_TextStyleGetShadowWithIndex(txtStyle, 10000000), nullptr);
1013     EXPECT_EQ(OH_Drawing_TextStyleGetShadowWithIndex(nullptr, 0), nullptr);
1014     EXPECT_EQ(OH_Drawing_TextStyleGetShadowCount(txtStyle), 1);
1015     EXPECT_EQ(OH_Drawing_TextStyleGetShadowCount(nullptr), 0);
1016     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1017     OH_Drawing_DestroyTypography(typography);
1018     OH_Drawing_DestroyTypographyHandler(handler);
1019 }
1020 
1021 /*
1022  * @tc.name: OH_Drawing_TypographyTest043
1023  * @tc.desc: test for foreground brush for textstyle
1024  * @tc.type: FUNC
1025  */
1026 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest043, TestSize.Level1)
1027 {
1028     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1029     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1030     OH_Drawing_TypographyCreate* handler =
1031         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
1032     EXPECT_NE(handler, nullptr);
1033     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1034     double fontSize = 30;
1035     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1036     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1037     bool halfLeading = true;
1038     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1039     const char* fontFamilies[] = { "Roboto" };
1040     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1041     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1042     const char* text = "OpenHarmony\n";
1043     OH_Drawing_TypographyHandlerAddText(handler, text);
1044     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1045     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1046     double maxWidth = 800.0;
1047     OH_Drawing_TypographyLayout(typography, maxWidth);
1048     double position[2] = { 10.0, 15.0 };
1049     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1050     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
1051     uint32_t width = 20;
1052     uint32_t height = 40;
1053     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1054     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1055     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1056     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1057     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1058     OH_Drawing_Brush* foregroundBrush = OH_Drawing_BrushCreate();
1059     uint8_t alpha = 128;
1060     OH_Drawing_BrushSetAlpha(foregroundBrush, alpha);
1061     OH_Drawing_SetTextStyleForegroundBrush(txtStyle, nullptr);
1062     OH_Drawing_SetTextStyleForegroundBrush(txtStyle, foregroundBrush);
1063     OH_Drawing_Brush* resForegroundBrush = OH_Drawing_BrushCreate();
1064     OH_Drawing_TextStyleGetForegroundBrush(txtStyle, nullptr);
1065     OH_Drawing_TextStyleGetForegroundBrush(txtStyle, resForegroundBrush);
1066     EXPECT_EQ(OH_Drawing_BrushGetAlpha(resForegroundBrush), alpha);
1067     OH_Drawing_BrushDestroy(resForegroundBrush);
1068     OH_Drawing_BrushDestroy(foregroundBrush);
1069     OH_Drawing_DestroyTypography(typography);
1070     OH_Drawing_DestroyTypographyHandler(handler);
1071 }
1072 
1073 /*
1074  * @tc.name: OH_Drawing_TypographyTest044
1075  * @tc.desc: test for effectiveAlignment, isLineUnlimited, isEllipsized for text typography
1076  * @tc.type: FUNC
1077  */
1078 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest044, TestSize.Level1)
1079 {
1080     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1081     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1082     OH_Drawing_TypographyCreate* handler =
1083         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
1084     EXPECT_NE(handler, nullptr);
1085 
1086     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1087     double fontSize = 30;
1088     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1089     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1090     bool halfLeading = true;
1091     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1092     const char* fontFamilies[] = { "Roboto" };
1093     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1094     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1095     const char* text = "OpenHarmony\n";
1096     OH_Drawing_TypographyHandlerAddText(handler, text);
1097     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1098     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1099     double maxWidth = 800.0;
1100     OH_Drawing_TypographyLayout(typography, maxWidth);
1101     double position[2] = { 10.0, 15.0 };
1102     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1103     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
1104     uint32_t width = 20;
1105     uint32_t height = 40;
1106     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1107     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1108     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1109     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1110     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1111     OH_Drawing_Font_Metrics fontmetrics;
1112     EXPECT_TRUE(OH_Drawing_TextStyleGetFontMetrics(typography, txtStyle, &fontmetrics));
1113     EXPECT_FALSE(OH_Drawing_TextStyleGetFontMetrics(nullptr, txtStyle, &fontmetrics));
1114     OH_Drawing_DisableFontCollectionFallback(OH_Drawing_CreateFontCollection());
1115     OH_Drawing_DisableFontCollectionFallback(nullptr);
1116     OH_Drawing_DisableFontCollectionSystemFont(OH_Drawing_CreateFontCollection());
1117     OH_Drawing_SetTypographyTextEllipsis(typoStyle, text);
1118     OH_Drawing_SetTypographyTextLocale(typoStyle, text);
1119     OH_Drawing_SetTypographyTextSplitRatio(typoStyle, fontSize);
1120     OH_Drawing_TypographyGetTextStyle(typoStyle);
1121     EXPECT_TRUE(OH_Drawing_TypographyGetEffectiveAlignment(typoStyle) >= 0);
1122     EXPECT_NE(OH_Drawing_TypographyIsLineUnlimited(typoStyle), 0);
1123     EXPECT_NE(OH_Drawing_TypographyIsEllipsized(typoStyle), 0);
1124     OH_Drawing_SetTypographyTextStyle(typoStyle, txtStyle);
1125     OH_Drawing_DestroyTypography(typography);
1126     OH_Drawing_DestroyTypographyHandler(handler);
1127 }
1128 
1129 /*
1130  * @tc.name: OH_Drawing_TypographyTest045
1131  * @tc.desc: test for background brush for textstyle
1132  * @tc.type: FUNC
1133  */
1134 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest045, TestSize.Level1)
1135 {
1136     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1137     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1138     OH_Drawing_TypographyCreate* handler =
1139         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
1140     EXPECT_NE(handler, nullptr);
1141 
1142     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1143     double fontSize = 30;
1144     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1145     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1146     bool halfLeading = true;
1147     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1148     const char* fontFamilies[] = { "Roboto" };
1149     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1150     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1151     const char* text = "OpenHarmony\n";
1152     OH_Drawing_TypographyHandlerAddText(handler, text);
1153     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1154     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1155     double maxWidth = 800.0;
1156     OH_Drawing_TypographyLayout(typography, maxWidth);
1157     double position[2] = { 10.0, 15.0 };
1158     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1159     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
1160     uint32_t width = 20;
1161     uint32_t height = 40;
1162     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1163     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1164     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1165     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1166     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1167     OH_Drawing_Brush* backgroundBrush = OH_Drawing_BrushCreate();
1168     uint8_t backgroundAlpha = 64;
1169     OH_Drawing_BrushSetAlpha(backgroundBrush, backgroundAlpha);
1170     OH_Drawing_SetTextStyleBackgroundBrush(txtStyle, nullptr);
1171     OH_Drawing_SetTextStyleBackgroundBrush(txtStyle, backgroundBrush);
1172     OH_Drawing_Brush* resBackgroundBrush = OH_Drawing_BrushCreate();
1173     OH_Drawing_TextStyleGetBackgroundBrush(txtStyle, nullptr);
1174     OH_Drawing_TextStyleGetBackgroundBrush(txtStyle, resBackgroundBrush);
1175     EXPECT_EQ(OH_Drawing_BrushGetAlpha(resBackgroundBrush), backgroundAlpha);
1176     OH_Drawing_BrushDestroy(resBackgroundBrush);
1177     OH_Drawing_BrushDestroy(backgroundBrush);
1178     OH_Drawing_DestroyTypography(typography);
1179     OH_Drawing_DestroyTypographyHandler(handler);
1180 }
1181 
1182 /*
1183  * @tc.name: OH_Drawing_TypographyTest046
1184  * @tc.desc: test for background pen for textstyle
1185  * @tc.type: FUNC
1186  */
1187 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest046, TestSize.Level1)
1188 {
1189     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1190     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1191     OH_Drawing_TypographyCreate* handler =
1192         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
1193     EXPECT_NE(handler, nullptr);
1194 
1195     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1196     double fontSize = 30;
1197     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1198     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1199     bool halfLeading = true;
1200     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1201     const char* fontFamilies[] = { "Roboto" };
1202     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1203     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1204     const char* text = "OpenHarmony\n";
1205     OH_Drawing_TypographyHandlerAddText(handler, text);
1206     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1207     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1208     double maxWidth = 800.0;
1209     OH_Drawing_TypographyLayout(typography, maxWidth);
1210     double position[2] = { 10.0, 15.0 };
1211     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1212     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
1213     uint32_t width = 20;
1214     uint32_t height = 40;
1215     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1216     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1217     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1218     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1219     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1220     OH_Drawing_Pen* backgroundPen = OH_Drawing_PenCreate();
1221     float backgroundPenWidth = 10;
1222     OH_Drawing_PenSetWidth(backgroundPen, backgroundPenWidth);
1223     OH_Drawing_SetTextStyleBackgroundPen(txtStyle, nullptr);
1224     OH_Drawing_SetTextStyleBackgroundPen(txtStyle, backgroundPen);
1225     OH_Drawing_Pen* resBackgroundPen = OH_Drawing_PenCreate();
1226     OH_Drawing_TextStyleGetBackgroundPen(txtStyle, nullptr);
1227     OH_Drawing_TextStyleGetBackgroundPen(txtStyle, resBackgroundPen);
1228     EXPECT_EQ(OH_Drawing_PenGetWidth(resBackgroundPen), backgroundPenWidth);
1229     OH_Drawing_PenDestroy(resBackgroundPen);
1230     OH_Drawing_PenDestroy(backgroundPen);
1231     OH_Drawing_DestroyTypography(typography);
1232     OH_Drawing_DestroyTypographyHandler(handler);
1233 }
1234 
1235 /*
1236  * @tc.name: OH_Drawing_TypographyTest047
1237  * @tc.desc: test for foreground pen for textstyle
1238  * @tc.type: FUNC
1239  */
1240 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest047, TestSize.Level1)
1241 {
1242     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1243     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1244     OH_Drawing_TypographyCreate* handler =
1245         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
1246     EXPECT_NE(handler, nullptr);
1247     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1248     double fontSize = 30;
1249     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1250     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1251     bool halfLeading = true;
1252     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1253     const char* fontFamilies[] = { "Roboto" };
1254     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1255     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1256     const char* text = "OpenHarmony\n";
1257     OH_Drawing_TypographyHandlerAddText(handler, text);
1258     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1259     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1260     double maxWidth = 800.0;
1261     OH_Drawing_TypographyLayout(typography, maxWidth);
1262     double position[2] = { 10.0, 15.0 };
1263     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1264     OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
1265     uint32_t width = 20;
1266     uint32_t height = 40;
1267     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1268     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1269     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1270     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1271     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1272     OH_Drawing_Pen* foregroundPen = OH_Drawing_PenCreate();
1273     float foregroundPenWidth = 20;
1274     OH_Drawing_PenSetWidth(foregroundPen, foregroundPenWidth);
1275     OH_Drawing_SetTextStyleForegroundPen(txtStyle, nullptr);
1276     OH_Drawing_SetTextStyleForegroundPen(txtStyle, foregroundPen);
1277     OH_Drawing_Pen* resForegroundPen = OH_Drawing_PenCreate();
1278     OH_Drawing_TextStyleGetForegroundPen(txtStyle, nullptr);
1279     OH_Drawing_TextStyleGetForegroundPen(txtStyle, resForegroundPen);
1280     EXPECT_EQ(OH_Drawing_PenGetWidth(resForegroundPen), foregroundPenWidth);
1281     OH_Drawing_PenDestroy(resForegroundPen);
1282     OH_Drawing_PenDestroy(foregroundPen);
1283     OH_Drawing_DestroyTypography(typography);
1284     OH_Drawing_DestroyTypographyHandler(handler);
1285 }
1286 
1287 /*
1288  * @tc.name: OH_Drawing_TypographyTest048
1289  * @tc.desc: test for font weight for text typography
1290  * @tc.type: FUNC
1291  */
1292 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest048, TestSize.Level1)
1293 {
1294     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1295     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_500);
1296     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W500);
1297     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_600);
1298     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W600);
1299     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_700);
1300     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W700);
1301     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_800);
1302     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W800);
1303     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_900);
1304     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W900);
1305     OH_Drawing_SetTypographyTextFontWeight(nullptr, 0);
1306     OH_Drawing_DestroyTypographyStyle(typoStyle);
1307 }
1308 
1309 /*
1310  * @tc.name: OH_Drawing_TypographyTest049
1311  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1312  * @tc.type: FUNC
1313  */
1314 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest049, TestSize.Level1)
1315 {
1316     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1317     bool halfLeading = true;
1318     OH_Drawing_SetTypographyTextHalfLeading(typoStyle, halfLeading);
1319     EXPECT_TRUE(ConvertToOriginalText(typoStyle)->halfLeading);
1320     OH_Drawing_SetTypographyTextLineStyleHalfLeading(typoStyle, halfLeading);
1321     EXPECT_TRUE(ConvertToOriginalText(typoStyle)->lineStyleHalfLeading);
1322     bool uselineStyle = true;
1323     OH_Drawing_SetTypographyTextUseLineStyle(typoStyle, uselineStyle);
1324     EXPECT_TRUE(ConvertToOriginalText(typoStyle)->useLineStyle);
1325     bool linestyleOnly = false;
1326     OH_Drawing_SetTypographyTextLineStyleOnly(typoStyle, linestyleOnly);
1327     EXPECT_FALSE(ConvertToOriginalText(typoStyle)->lineStyleOnly);
1328     OH_Drawing_SetTypographyTextLineStyleOnly(nullptr, 0);
1329     OH_Drawing_DestroyTypographyStyle(typoStyle);
1330 }
1331 
1332 /*
1333  * @tc.name: OH_Drawing_TypographyTest050
1334  * @tc.desc: test for getting numbers for textstyle
1335  * @tc.type: FUNC
1336  */
1337 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest050, TestSize.Level1)
1338 {
1339     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1340     OH_Drawing_SetTextStyleColor(txtStyle, 1);
1341     EXPECT_EQ(OH_Drawing_TextStyleGetColor(txtStyle), 1);
1342     EXPECT_EQ(OH_Drawing_TextStyleGetColor(nullptr), 0xFFFFFFFF);
1343     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_SOLID);
1344     EXPECT_EQ(OH_Drawing_TextStyleGetDecorationStyle(txtStyle), 0);
1345     EXPECT_EQ(OH_Drawing_TextStyleGetDecorationStyle(nullptr), TEXT_DECORATION_STYLE_SOLID);
1346     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_100);
1347     EXPECT_EQ(OH_Drawing_TextStyleGetFontWeight(txtStyle), 0);
1348     EXPECT_EQ(OH_Drawing_TextStyleGetFontWeight(nullptr), FONT_WEIGHT_400);
1349     OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_NORMAL);
1350     EXPECT_EQ(OH_Drawing_TextStyleGetFontStyle(txtStyle), 0);
1351     EXPECT_EQ(OH_Drawing_TextStyleGetFontStyle(nullptr), FONT_STYLE_NORMAL);
1352     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
1353     EXPECT_EQ(OH_Drawing_TextStyleGetBaseline(txtStyle), 0);
1354     EXPECT_EQ(OH_Drawing_TextStyleGetBaseline(nullptr), TEXT_BASELINE_ALPHABETIC);
1355     const char* fontFamilies[] = { "Roboto" };
1356     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1357     size_t fontFamiliesNumber;
1358     char** fontFamiliesList = OH_Drawing_TextStyleGetFontFamilies(txtStyle, &fontFamiliesNumber);
1359     EXPECT_NE(fontFamiliesList, nullptr);
1360     EXPECT_EQ(OH_Drawing_TextStyleGetFontFamilies(nullptr, &fontFamiliesNumber), nullptr);
1361     OH_Drawing_TextStyleDestroyFontFamilies(fontFamiliesList, fontFamiliesNumber);
1362     OH_Drawing_SetTextStyleFontSize(txtStyle, 60); // 60 means font size for test
1363     EXPECT_EQ(OH_Drawing_TextStyleGetFontSize(txtStyle), 60);
1364     EXPECT_EQ(OH_Drawing_TextStyleGetFontSize(nullptr), 0.0);
1365     OH_Drawing_SetTextStyleLetterSpacing(txtStyle, 20); // 20 means letter spacing for test
1366     EXPECT_EQ(OH_Drawing_TextStyleGetLetterSpacing(txtStyle), 20);
1367     EXPECT_EQ(OH_Drawing_TextStyleGetLetterSpacing(nullptr), 0.0);
1368     OH_Drawing_SetTextStyleWordSpacing(txtStyle, 80); // 80 means word spacing for test
1369     EXPECT_EQ(OH_Drawing_TextStyleGetWordSpacing(txtStyle), 80);
1370     EXPECT_EQ(OH_Drawing_TextStyleGetWordSpacing(nullptr), 0.0);
1371     OH_Drawing_SetTextStyleFontHeight(txtStyle, 0.0); // 0.0 means font height for test
1372     EXPECT_EQ(OH_Drawing_TextStyleGetFontHeight(txtStyle), 0.0);
1373     EXPECT_EQ(OH_Drawing_TextStyleGetFontHeight(nullptr), 0.0);
1374     bool halfLeading = true;
1375     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1376     EXPECT_TRUE(OH_Drawing_TextStyleGetHalfLeading(txtStyle));
1377     EXPECT_FALSE(OH_Drawing_TextStyleGetHalfLeading(nullptr));
1378     OH_Drawing_SetTextStyleLocale(txtStyle, "en");
1379     EXPECT_EQ(std::strcmp(OH_Drawing_TextStyleGetLocale(txtStyle), "en"), 0);
1380     EXPECT_EQ(OH_Drawing_TextStyleGetLocale(nullptr), nullptr);
1381 }
1382 
1383 /*
1384  * @tc.name: OH_Drawing_TypographyTest051
1385  * @tc.desc: test for getting line info for text typography
1386  * @tc.type: FUNC
1387  */
1388 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest051, TestSize.Level1)
1389 {
1390     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1391     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1392     OH_Drawing_TypographyCreate* handler =
1393         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
1394     OH_Drawing_RectStyle_Info rectStyleInfo = { 1, 1.5, 1.5, 1.5, 1.5 }; // 1.5 means corner radius for test
1395     int styleId = 1;                                                     // 1 means styleId for test
1396     OH_Drawing_TextStyleSetBackgroundRect(txtStyle, nullptr, styleId);
1397     OH_Drawing_TextStyleSetBackgroundRect(nullptr, &rectStyleInfo, styleId);
1398     OH_Drawing_TextStyleSetBackgroundRect(txtStyle, &rectStyleInfo, styleId);
1399     uint32_t symbol = 2; // 2 means symbol for test
1400     OH_Drawing_TypographyHandlerAddSymbol(handler, symbol);
1401     OH_Drawing_TypographyHandlerAddSymbol(nullptr, symbol);
1402     const char* key1 = "宋体";
1403     int value1 = 1; // 1 for test
1404     OH_Drawing_TextStyleAddFontFeature(nullptr, key1, value1);
1405     OH_Drawing_TextStyleAddFontFeature(txtStyle, nullptr, value1);
1406     OH_Drawing_TextStyleAddFontFeature(txtStyle, key1, value1);
1407     const char* key2 = "斜体";
1408     int value2 = 2; // 2 for test
1409     OH_Drawing_TextStyleAddFontFeature(txtStyle, key2, value2);
1410     const char* key3 = "方体";
1411     int value3 = 3; // 3 for test
1412     OH_Drawing_TextStyleAddFontFeature(txtStyle, key3, value3);
1413     EXPECT_EQ(OH_Drawing_TextStyleGetFontFeatureSize(txtStyle), 3); // 3 means font feature size for test
1414     EXPECT_EQ(OH_Drawing_TextStyleGetFontFeatureSize(nullptr), 0);
1415     OH_Drawing_FontFeature* fontFeaturesArray = OH_Drawing_TextStyleGetFontFeatures(txtStyle);
1416     EXPECT_NE(fontFeaturesArray, nullptr);
1417     EXPECT_EQ(OH_Drawing_TextStyleGetFontFeatures(nullptr), nullptr);
1418     OH_Drawing_TextStyleDestroyFontFeatures(fontFeaturesArray, OH_Drawing_TextStyleGetFontFeatureSize(txtStyle));
1419     OH_Drawing_TextStyleDestroyFontFeatures(nullptr, OH_Drawing_TextStyleGetFontFeatureSize(txtStyle));
1420     OH_Drawing_TextStyleClearFontFeature(txtStyle);
1421     OH_Drawing_TextStyleClearFontFeature(nullptr);
1422     EXPECT_EQ(OH_Drawing_TextStyleGetFontFeatureSize(txtStyle), 0);
1423     double lineShift = 1.5; // 1.5 means baseline shift for test
1424     OH_Drawing_TextStyleSetBaselineShift(nullptr, lineShift);
1425     EXPECT_EQ(OH_Drawing_TextStyleGetBaselineShift(nullptr), 0.0);
1426     OH_Drawing_TextStyleSetBaselineShift(txtStyle, lineShift);
1427     EXPECT_EQ(OH_Drawing_TextStyleGetBaselineShift(txtStyle), 1.5);
1428 }
1429 
1430 /*
1431  * @tc.name: OH_Drawing_TypographyTest052
1432  * @tc.desc: test for setting the mode of leading over and under text
1433  * @tc.type: FUNC
1434  */
1435 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest052, TestSize.Level1)
1436 {
1437     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1438     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_ALL);
1439     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textHeightBehavior, TextHeightBehavior::ALL);
1440     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_FIRST_ASCENT);
1441     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textHeightBehavior, TextHeightBehavior::DISABLE_FIRST_ASCENT);
1442     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_LAST_ASCENT);
1443     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textHeightBehavior, TextHeightBehavior::DISABLE_LAST_ASCENT);
1444     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_ALL);
1445     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textHeightBehavior, TextHeightBehavior::DISABLE_ALL);
1446     OH_Drawing_TypographyTextSetHeightBehavior(nullptr, TEXT_HEIGHT_ALL);
1447     OH_Drawing_DestroyTypographyStyle(typoStyle);
1448 }
1449 
1450 /*
1451  * @tc.name: OH_Drawing_TypographyTest053
1452  * @tc.desc: test for getting the mode of leading over and under text
1453  * @tc.type: FUNC
1454  */
1455 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest053, TestSize.Level1)
1456 {
1457     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(nullptr), TEXT_HEIGHT_ALL);
1458     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1459     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_ALL);
1460     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(typoStyle), TEXT_HEIGHT_ALL);
1461     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_FIRST_ASCENT);
1462     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(typoStyle), TEXT_HEIGHT_DISABLE_FIRST_ASCENT);
1463     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_LAST_ASCENT);
1464     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(typoStyle), TEXT_HEIGHT_DISABLE_LAST_ASCENT);
1465     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_ALL);
1466     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(typoStyle), TEXT_HEIGHT_DISABLE_ALL);
1467     OH_Drawing_DestroyTypographyStyle(typoStyle);
1468 }
1469 
1470 /*
1471  * @tc.name: OH_Drawing_TypographyTest054
1472  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1473  * @tc.type: FUNC
1474  */
1475 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest054, TestSize.Level1)
1476 {
1477     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1478     ASSERT_NE(typoStyle, nullptr);
1479     OH_Drawing_FontCollection* fontCollection = OH_Drawing_CreateFontCollection();
1480     ASSERT_NE(fontCollection, nullptr);
1481     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection);
1482     ASSERT_NE(handler, nullptr);
1483     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1484     ASSERT_NE(typography, nullptr);
1485     OH_Drawing_TypographyMarkDirty(typography);
1486     OH_Drawing_TypographyMarkDirty(nullptr);
1487     OH_Drawing_DestroyTypographyStyle(typoStyle);
1488     OH_Drawing_DestroyFontCollection(fontCollection);
1489     OH_Drawing_DestroyTypographyHandler(handler);
1490     OH_Drawing_DestroyTypography(typography);
1491 }
1492 
1493 /*
1494  * @tc.name: OH_Drawing_TypographyTest055
1495  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1496  * @tc.type: FUNC
1497  */
1498 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest055, TestSize.Level1)
1499 {
1500     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1501     ASSERT_NE(typoStyle, nullptr);
1502     OH_Drawing_FontCollection* fontCollection = OH_Drawing_CreateFontCollection();
1503     ASSERT_NE(fontCollection, nullptr);
1504     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection);
1505     ASSERT_NE(handler, nullptr);
1506     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1507     ASSERT_NE(typography, nullptr);
1508     int32_t result = OH_Drawing_TypographyGetUnresolvedGlyphsCount(typography);
1509     EXPECT_NE(result, 0);
1510     result = OH_Drawing_TypographyGetUnresolvedGlyphsCount(nullptr);
1511     EXPECT_EQ(result, 0);
1512     OH_Drawing_DestroyTypographyStyle(typoStyle);
1513     OH_Drawing_DestroyFontCollection(fontCollection);
1514     OH_Drawing_DestroyTypographyHandler(handler);
1515     OH_Drawing_DestroyTypography(typography);
1516 }
1517 
1518 /*
1519  * @tc.name: OH_Drawing_TypographyTest056
1520  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1521  * @tc.type: FUNC
1522  */
1523 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest056, TestSize.Level1)
1524 {
1525     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1526     ASSERT_NE(typoStyle, nullptr);
1527     OH_Drawing_FontCollection* fontCollection = OH_Drawing_CreateFontCollection();
1528     ASSERT_NE(fontCollection, nullptr);
1529     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection);
1530     ASSERT_NE(handler, nullptr);
1531     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1532     ASSERT_NE(typography, nullptr);
1533     size_t from = 10;     // 10 means font size for test
1534     size_t to = 11;       // 11 means font size for test
1535     float fontSize = 1.0; // 1.0 means font size for test
1536     OH_Drawing_TypographyUpdateFontSize(typography, from, to, fontSize);
1537     OH_Drawing_TypographyUpdateFontSize(nullptr, from, to, fontSize);
1538     OH_Drawing_DestroyTypographyStyle(typoStyle);
1539     OH_Drawing_DestroyFontCollection(fontCollection);
1540     OH_Drawing_DestroyTypographyHandler(handler);
1541     OH_Drawing_DestroyTypography(typography);
1542 }
1543 
1544 /*
1545  * @tc.name: OH_Drawing_TypographyTest057
1546  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1547  * @tc.type: FUNC
1548  */
1549 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest057, TestSize.Level1)
1550 {
1551     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1552     ASSERT_NE(typoStyle, nullptr);
1553     bool useLineStyle = true;
1554     OH_Drawing_SetTypographyTextUseLineStyle(typoStyle, useLineStyle);
1555     bool result = OH_Drawing_TypographyTextGetLineStyle(typoStyle);
1556     EXPECT_TRUE(result);
1557     result = OH_Drawing_TypographyTextGetLineStyle(nullptr);
1558     EXPECT_FALSE(result);
1559     OH_Drawing_DestroyTypographyStyle(typoStyle);
1560 }
1561 
1562 /*
1563  * @tc.name: OH_Drawing_TypographyTest058
1564  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1565  * @tc.type: FUNC
1566  */
1567 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest058, TestSize.Level1)
1568 {
1569     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1570     ASSERT_NE(typoStyle, nullptr);
1571     int weight = FONT_WEIGHT_100;
1572     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, weight);
1573     OH_Drawing_FontWeight result = OH_Drawing_TypographyTextlineStyleGetFontWeight(typoStyle);
1574     EXPECT_EQ(result, FONT_WEIGHT_100);
1575     result = OH_Drawing_TypographyTextlineStyleGetFontWeight(nullptr);
1576     EXPECT_EQ(result, FONT_WEIGHT_400);
1577     OH_Drawing_DestroyTypographyStyle(typoStyle);
1578 }
1579 
1580 /*
1581  * @tc.name: OH_Drawing_TypographyTest059
1582  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1583  * @tc.type: FUNC
1584  */
1585 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest059, TestSize.Level1)
1586 {
1587     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1588     ASSERT_NE(typoStyle, nullptr);
1589     int fontStyle = FONT_STYLE_ITALIC;
1590     OH_Drawing_SetTypographyTextLineStyleFontStyle(typoStyle, fontStyle);
1591     OH_Drawing_FontStyle result = OH_Drawing_TypographyTextlineStyleGetFontStyle(typoStyle);
1592     EXPECT_EQ(result, FONT_STYLE_ITALIC);
1593     result = OH_Drawing_TypographyTextlineStyleGetFontStyle(nullptr);
1594     EXPECT_EQ(result, FONT_STYLE_NORMAL);
1595     OH_Drawing_DestroyTypographyStyle(typoStyle);
1596 }
1597 
1598 /*
1599  * @tc.name: OH_Drawing_TypographyTest060
1600  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1601  * @tc.type: FUNC
1602  */
1603 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest060, TestSize.Level1)
1604 {
1605     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1606     ASSERT_NE(typoStyle, nullptr);
1607     size_t fontNum = 1; // 1 means font number for test
1608     const char* fontFamilies[] = { "Roboto" };
1609     int fontFamiliesNumber = 1; // 1 means font families number for test
1610     OH_Drawing_SetTypographyTextLineStyleFontFamilies(typoStyle, fontFamiliesNumber, fontFamilies);
1611     char** result = OH_Drawing_TypographyTextlineStyleGetFontFamilies(typoStyle, &fontNum);
1612     EXPECT_NE(result, nullptr);
1613     result = OH_Drawing_TypographyTextlineStyleGetFontFamilies(nullptr, &fontNum);
1614     EXPECT_EQ(result, nullptr);
1615     OH_Drawing_TypographyTextlineStyleDestroyFontFamilies(result, fontNum);
1616     OH_Drawing_DestroyTypographyStyle(typoStyle);
1617 }
1618 
1619 /*
1620  * @tc.name: OH_Drawing_TypographyTest061
1621  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1622  * @tc.type: FUNC
1623  */
1624 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest061, TestSize.Level1)
1625 {
1626     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1627     ASSERT_NE(typoStyle, nullptr);
1628     double result = OH_Drawing_TypographyTextlineStyleGetFontSize(typoStyle);
1629     // 14.0 Fontsize default value
1630     EXPECT_EQ(result, 14.0);
1631     result = OH_Drawing_TypographyTextlineStyleGetFontSize(nullptr);
1632     EXPECT_EQ(result, 0);
1633     OH_Drawing_DestroyTypographyStyle(typoStyle);
1634 }
1635 
1636 /*
1637  * @tc.name: OH_Drawing_TypographyTest062
1638  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1639  * @tc.type: FUNC
1640  */
1641 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest062, TestSize.Level1)
1642 {
1643     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1644     ASSERT_NE(typoStyle, nullptr);
1645     double result = OH_Drawing_TypographyTextlineStyleGetHeightScale(typoStyle);
1646     EXPECT_EQ(result, 1.0); // 1.0 means enable the font height for line styles in text layout only
1647     result = OH_Drawing_TypographyTextlineStyleGetHeightScale(nullptr);
1648     EXPECT_EQ(result, 0);
1649     OH_Drawing_DestroyTypographyStyle(typoStyle);
1650 }
1651 
1652 /*
1653  * @tc.name: OH_Drawing_TypographyTest063
1654  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1655  * @tc.type: FUNC
1656  */
1657 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest063, TestSize.Level1)
1658 {
1659     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1660     ASSERT_NE(typoStyle, nullptr);
1661     // 2.0 measn font height for test
1662     double lineStyleFontHeight = 2.0;
1663     OH_Drawing_SetTypographyTextLineStyleFontHeight(typoStyle, lineStyleFontHeight);
1664     bool result = OH_Drawing_TypographyTextlineStyleGetHeightOnly(typoStyle);
1665     EXPECT_TRUE(result);
1666     result = OH_Drawing_TypographyTextlineStyleGetHeightOnly(nullptr);
1667     EXPECT_FALSE(result);
1668     OH_Drawing_DestroyTypographyStyle(typoStyle);
1669 }
1670 
1671 /*
1672  * @tc.name: OH_Drawing_TypographyTest064
1673  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1674  * @tc.type: FUNC
1675  */
1676 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest064, TestSize.Level1)
1677 {
1678     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1679     ASSERT_NE(typoStyle, nullptr);
1680     bool lineStyleHalfLeading = true;
1681     OH_Drawing_SetTypographyTextLineStyleHalfLeading(typoStyle, lineStyleHalfLeading);
1682     bool result = OH_Drawing_TypographyTextlineStyleGetHalfLeading(typoStyle);
1683     EXPECT_TRUE(result);
1684     result = OH_Drawing_TypographyTextlineStyleGetHalfLeading(nullptr);
1685     EXPECT_FALSE(result);
1686     OH_Drawing_DestroyTypographyStyle(typoStyle);
1687 }
1688 
1689 /*
1690  * @tc.name: OH_Drawing_TypographyTest065
1691  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1692  * @tc.type: FUNC
1693  */
1694 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest065, TestSize.Level1)
1695 {
1696     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1697     ASSERT_NE(typoStyle, nullptr);
1698     double result = OH_Drawing_TypographyTextlineStyleGetSpacingScale(typoStyle);
1699     // -1.0 for test
1700     EXPECT_EQ(result, -1.0);
1701     result = OH_Drawing_TypographyTextlineStyleGetSpacingScale(nullptr);
1702     EXPECT_EQ(result, 0);
1703     OH_Drawing_DestroyTypographyStyle(typoStyle);
1704 }
1705 
1706 /*
1707  * @tc.name: OH_Drawing_TypographyTest066
1708  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1709  * @tc.type: FUNC
1710  */
1711 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest066, TestSize.Level1)
1712 {
1713     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1714     ASSERT_NE(typoStyle, nullptr);
1715     int direction = TEXT_DIRECTION_RTL;
1716     OH_Drawing_SetTypographyTextDirection(typoStyle, direction);
1717     OH_Drawing_TextDirection result = OH_Drawing_TypographyGetTextDirection(typoStyle);
1718     EXPECT_EQ(result, TEXT_DIRECTION_RTL);
1719     result = OH_Drawing_TypographyGetTextDirection(nullptr);
1720     EXPECT_EQ(result, TEXT_DIRECTION_LTR);
1721     OH_Drawing_DestroyTypographyStyle(typoStyle);
1722 }
1723 
1724 /*
1725  * @tc.name: OH_Drawing_TypographyTest067
1726  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1727  * @tc.type: FUNC
1728  */
1729 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest067, TestSize.Level1)
1730 {
1731     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1732     ASSERT_NE(typoStyle, nullptr);
1733     size_t result = OH_Drawing_TypographyGetTextMaxLines(typoStyle);
1734     EXPECT_NE(result, 0);
1735     result = OH_Drawing_TypographyGetTextMaxLines(nullptr);
1736     EXPECT_EQ(result, 0);
1737     OH_Drawing_DestroyTypographyStyle(typoStyle);
1738 }
1739 
1740 /*
1741  * @tc.name: OH_Drawing_TypographyTest068
1742  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1743  * @tc.type: FUNC
1744  */
1745 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest068, TestSize.Level1)
1746 {
1747     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1748     ASSERT_NE(typoStyle, nullptr);
1749     char* result = OH_Drawing_TypographyGetTextEllipsis(typoStyle);
1750     EXPECT_NE(result, nullptr);
1751     result = OH_Drawing_TypographyGetTextEllipsis(nullptr);
1752     EXPECT_EQ(result, nullptr);
1753     OH_Drawing_TypographyDestroyEllipsis(result);
1754     OH_Drawing_DestroyTypographyStyle(typoStyle);
1755 }
1756 
1757 /*
1758  * @tc.name: OH_Drawing_TypographyTest069
1759  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1760  * @tc.type: FUNC
1761  */
1762 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest069, TestSize.Level1)
1763 {
1764     OH_Drawing_TypographyStyle* from = OH_Drawing_CreateTypographyStyle();
1765     OH_Drawing_TypographyStyle* to = OH_Drawing_CreateTypographyStyle();
1766     bool result = OH_Drawing_TypographyStyleEquals(from, to);
1767     EXPECT_TRUE(result);
1768     result = OH_Drawing_TypographyStyleEquals(nullptr, to);
1769     EXPECT_FALSE(result);
1770     result = OH_Drawing_TypographyStyleEquals(from, nullptr);
1771     EXPECT_FALSE(result);
1772     OH_Drawing_DestroyTypographyStyle(from);
1773     OH_Drawing_DestroyTypographyStyle(to);
1774 }
1775 
1776 /*
1777  * @tc.name: OH_Drawing_TypographyTest070
1778  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1779  * @tc.type: FUNC
1780  */
1781 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest070, TestSize.Level1)
1782 {
1783     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1784     ASSERT_NE(typoStyle, nullptr);
1785     OH_Drawing_SetTypographyTextLineStyleOnly(typoStyle, true);
1786     bool result = OH_Drawing_TypographyTextlineGetStyleOnly(typoStyle);
1787     EXPECT_TRUE(result);
1788     result = OH_Drawing_TypographyTextlineGetStyleOnly(nullptr);
1789     EXPECT_FALSE(result);
1790     OH_Drawing_DestroyTypographyStyle(typoStyle);
1791 }
1792 
1793 /*
1794  * @tc.name: OH_Drawing_TypographyTest071
1795  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1796  * @tc.type: FUNC
1797  */
1798 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest071, TestSize.Level1)
1799 {
1800     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1801     ASSERT_NE(typoStyle, nullptr);
1802     int align = TEXT_ALIGN_RIGHT;
1803     OH_Drawing_SetTypographyTextAlign(typoStyle, align);
1804     OH_Drawing_TextAlign result = OH_Drawing_TypographyGetTextAlign(typoStyle);
1805     EXPECT_EQ(result, TEXT_ALIGN_RIGHT);
1806     result = OH_Drawing_TypographyGetTextAlign(nullptr);
1807     EXPECT_EQ(result, TEXT_ALIGN_LEFT);
1808     OH_Drawing_DestroyTypographyStyle(typoStyle);
1809 }
1810 
1811 /*
1812  * @tc.name: OH_Drawing_TypographyTest072
1813  * @tc.desc: test for create and releases the memory occupied by system font configuration information
1814  * @tc.type: FUNC
1815  */
1816 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest072, TestSize.Level1)
1817 {
1818     OH_Drawing_FontConfigInfoErrorCode code = ERROR_FONT_CONFIG_INFO_UNKNOWN;
1819     OH_Drawing_FontConfigInfo* configJsonInfo = OH_Drawing_GetSystemFontConfigInfo(&code);
1820     if (configJsonInfo != nullptr) {
1821         EXPECT_EQ(code, SUCCESS_FONT_CONFIG_INFO);
1822     } else {
1823         EXPECT_NE(code, SUCCESS_FONT_CONFIG_INFO);
1824     }
1825     OH_Drawing_DestroySystemFontConfigInfo(configJsonInfo);
1826     OH_Drawing_DestroySystemFontConfigInfo(nullptr);
1827 }
1828 
1829 /*
1830  * @tc.name: OH_Drawing_TypographyTest073
1831  * @tc.desc: test for getting all font metrics array from current line
1832  * @tc.type: FUNC
1833  */
1834 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest073, TestSize.Level1)
1835 {
1836     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1837     EXPECT_NE(typoStyle, nullptr);
1838     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1839     EXPECT_NE(txtStyle, nullptr);
1840     OH_Drawing_TypographyCreate* handler =
1841         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
1842     EXPECT_NE(handler, nullptr);
1843     size_t charNumber = 0;
1844     const char* text = "OpenHarmony\n";
1845     OH_Drawing_TypographyHandlerAddText(handler, text);
1846     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1847     EXPECT_NE(typography, nullptr);
1848     OH_Drawing_Font_Metrics* StartLineFont = OH_Drawing_TypographyGetLineFontMetrics(typography, 1, &charNumber);
1849     EXPECT_EQ(StartLineFont, nullptr);
1850     OH_Drawing_TypographyDestroyLineFontMetrics(StartLineFont);
1851     OH_Drawing_DestroyTypography(typography);
1852     OH_Drawing_DestroyTypographyHandler(handler);
1853     OH_Drawing_DestroyTypographyStyle(typoStyle);
1854     OH_Drawing_DestroyTextStyle(txtStyle);
1855 }
1856 
1857 /*
1858  * @tc.name: OH_Drawing_TypographyTest074
1859  * @tc.desc: test for getting and setting strut style
1860  * @tc.type: FUNC
1861  */
1862 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest074, TestSize.Level1)
1863 {
1864     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1865     OH_Drawing_StrutStyle* strutstyle = new OH_Drawing_StrutStyle();
1866     strutstyle->weight = FONT_WEIGHT_400;
1867     strutstyle->style = FONT_STYLE_ITALIC;
1868     // 17.0 For size
1869     strutstyle->size = 17.0;
1870     // 2.0 For heightScale
1871     strutstyle->heightScale = 2;
1872     strutstyle->heightOverride = true;
1873     strutstyle->halfLeading = true;
1874     // 3.0 For leading
1875     strutstyle->leading = 3.0;
1876     strutstyle->forceStrutHeight = true;
1877     // 4 For families size
1878     strutstyle->familiesSize = 4;
1879     strutstyle->families = (char**)malloc(strutstyle->familiesSize * sizeof(char*));
1880     const char* temp[] = { "1", "2", "3", "4" };
1881     for (int i = 0; i < strutstyle->familiesSize; i++) {
1882         // 2 For families member size
1883         strutstyle->families[i] = (char*)malloc(2 * sizeof(char));
1884         strcpy_s(strutstyle->families[i], 2, temp[i]);
1885     }
1886     OH_Drawing_SetTypographyStyleTextStrutStyle(typoStyle, strutstyle);
1887     EXPECT_NE(OH_Drawing_TypographyStyleGetStrutStyle(typoStyle), nullptr);
1888     OH_Drawing_TypographyStyleDestroyStrutStyle(strutstyle);
1889     OH_Drawing_DestroyTypographyStyle(typoStyle);
1890 }
1891 
1892 /*
1893  * @tc.name: OH_Drawing_TypographyTest075
1894  * @tc.desc: test for sets and gets isPlaceholder for TextStyle objects
1895  * @tc.type: FUNC
1896  */
1897 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest075, TestSize.Level1)
1898 {
1899     EXPECT_FALSE(OH_Drawing_TextStyleIsPlaceholder(nullptr));
1900     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1901     EXPECT_FALSE(OH_Drawing_TextStyleIsPlaceholder(txtStyle));
1902     OH_Drawing_TextStyleSetPlaceholder(nullptr);
1903     OH_Drawing_TextStyleSetPlaceholder(txtStyle);
1904     EXPECT_TRUE(OH_Drawing_TextStyleIsPlaceholder(txtStyle));
1905     EXPECT_TRUE(ConvertToOriginalText(txtStyle)->isPlaceholder);
1906     OH_Drawing_DestroyTextStyle(txtStyle);
1907 }
1908 
1909 /*
1910  * @tc.name: OH_Drawing_TypographyTest076
1911  * @tc.desc: test for the two TextStyle objects have matching properties
1912  * @tc.type: FUNC
1913  */
1914 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest076, TestSize.Level1)
1915 {
1916     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1917     OH_Drawing_TextStyle* txtStyleCompare = OH_Drawing_CreateTextStyle();
1918     bool result = OH_Drawing_TextStyleIsAttributeMatched(txtStyle, txtStyleCompare, TEXT_STYLE_ALL_ATTRIBUTES);
1919     EXPECT_TRUE(result);
1920     OH_Drawing_SetTextStyleLocale(txtStyle, "en");
1921     result = OH_Drawing_TextStyleIsAttributeMatched(txtStyle, txtStyleCompare, TEXT_STYLE_ALL_ATTRIBUTES);
1922     EXPECT_FALSE(result);
1923     EXPECT_FALSE(OH_Drawing_TextStyleIsAttributeMatched(nullptr, txtStyleCompare, TEXT_STYLE_ALL_ATTRIBUTES));
1924     EXPECT_FALSE(OH_Drawing_TextStyleIsAttributeMatched(txtStyle, nullptr, TEXT_STYLE_ALL_ATTRIBUTES));
1925     OH_Drawing_DestroyTextStyle(txtStyle);
1926     OH_Drawing_DestroyTextStyle(txtStyleCompare);
1927 }
1928 
1929 /*
1930  * @tc.name: OH_Drawing_TypographyTest077
1931  * @tc.desc: test for strutstyle equals
1932  * @tc.type: FUNC
1933  */
1934 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest077, TestSize.Level1)
1935 {
1936     OH_Drawing_StrutStyle* from = new OH_Drawing_StrutStyle();
1937     OH_Drawing_StrutStyle* to = new OH_Drawing_StrutStyle();
1938     bool result = OH_Drawing_TypographyStyleStrutStyleEquals(from, to);
1939     EXPECT_TRUE(result);
1940     result = OH_Drawing_TypographyStyleStrutStyleEquals(nullptr, to);
1941     EXPECT_FALSE(result);
1942     result = OH_Drawing_TypographyStyleStrutStyleEquals(from, nullptr);
1943     EXPECT_FALSE(result);
1944     OH_Drawing_TypographyStyleDestroyStrutStyle(from);
1945     OH_Drawing_TypographyStyleDestroyStrutStyle(to);
1946 }
1947 
1948 /*
1949  * @tc.name: OH_Drawing_TypographyTest078
1950  * @tc.desc: test for gets the typoStyle alignment mode and whether to enable text prompts
1951  * @tc.type: FUNC
1952  */
1953 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest078, TestSize.Level1)
1954 {
1955     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1956     EXPECT_EQ(OH_Drawing_TypographyStyleGetEffectiveAlignment(typoStyle), TEXT_ALIGN_LEFT);
1957     EXPECT_FALSE(OH_Drawing_TypographyStyleIsHintEnabled(typoStyle));
1958     OH_Drawing_DestroyTypographyStyle(typoStyle);
1959 }
1960 
1961 /*
1962  * @tc.name: OH_Drawing_TypographyTest079
1963  * @tc.desc: test for setting the hinting of text typography
1964  * @tc.type: FUNC
1965  */
1966 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest079, TestSize.Level1)
1967 {
1968     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1969     OH_Drawing_TypographyStyleSetHintsEnabled(typoStyle, true);
1970     EXPECT_TRUE(ConvertToOriginalText(typoStyle)->hintingIsOn);
1971     OH_Drawing_DestroyTypographyStyle(typoStyle);
1972 }
1973 
1974 /*
1975  * @tc.name: OH_Drawing_TypographyTest080
1976  * @tc.desc: test for whether two TextStyle objects are equal
1977  * @tc.type: FUNC
1978  */
1979 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest080, TestSize.Level1)
1980 {
1981     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1982     OH_Drawing_TextStyle* txtStyleCompare = OH_Drawing_CreateTextStyle();
1983     bool result = OH_Drawing_TextStyleIsEqual(txtStyle, txtStyleCompare);
1984     EXPECT_TRUE(result);
1985 
1986     OH_Drawing_SetTextStyleColor(txtStyle, 1);
1987     result = OH_Drawing_TextStyleIsEqual(txtStyle, txtStyleCompare);
1988     EXPECT_FALSE(result);
1989     OH_Drawing_SetTextStyleColor(txtStyleCompare, 1);
1990     result = OH_Drawing_TextStyleIsEqual(txtStyle, txtStyleCompare);
1991     EXPECT_TRUE(result);
1992     EXPECT_FALSE(OH_Drawing_TextStyleIsEqual(nullptr, txtStyleCompare));
1993     EXPECT_FALSE(OH_Drawing_TextStyleIsEqual(txtStyle, nullptr));
1994     EXPECT_TRUE(OH_Drawing_TextStyleIsEqual(nullptr, nullptr));
1995     OH_Drawing_DestroyTextStyle(txtStyle);
1996     OH_Drawing_DestroyTextStyle(txtStyleCompare);
1997 }
1998 
1999 /*
2000  * @tc.name: OH_Drawing_TypographyTest081
2001  * @tc.desc: test for getting and setting text style
2002  * @tc.type: FUNC
2003  */
2004 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest081, TestSize.Level1)
2005 {
2006     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2007     EXPECT_NE(txtStyle, nullptr);
2008     OH_Drawing_FontStyleStruct normalStyle;
2009     normalStyle.weight = FONT_WEIGHT_400;
2010     normalStyle.width = FONT_WIDTH_NORMAL;
2011     normalStyle.slant = FONT_STYLE_NORMAL;
2012     OH_Drawing_SetTextStyleFontStyleStruct(txtStyle, normalStyle);
2013     OH_Drawing_SetTextStyleFontStyleStruct(nullptr, normalStyle);
2014 
2015     OH_Drawing_FontStyleStruct style = OH_Drawing_TextStyleGetFontStyleStruct(txtStyle);
2016     EXPECT_EQ(style.weight, normalStyle.weight);
2017     EXPECT_EQ(style.width, normalStyle.width);
2018     EXPECT_EQ(style.slant, normalStyle.slant);
2019     OH_Drawing_DestroyTextStyle(txtStyle);
2020 }
2021 
2022 /*
2023  * @tc.name: OH_Drawing_TypographyTest082
2024  * @tc.desc: test for getting and setting typography style
2025  * @tc.type: FUNC
2026  */
2027 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest082, TestSize.Level1)
2028 {
2029     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2030     EXPECT_NE(typoStyle, nullptr);
2031     OH_Drawing_FontStyleStruct normalStyle;
2032     normalStyle.weight = FONT_WEIGHT_400;
2033     normalStyle.width = FONT_WIDTH_NORMAL;
2034     normalStyle.slant = FONT_STYLE_NORMAL;
2035     OH_Drawing_SetTypographyStyleFontStyleStruct(typoStyle, normalStyle);
2036     OH_Drawing_SetTypographyStyleFontStyleStruct(nullptr, normalStyle);
2037 
2038     OH_Drawing_FontStyleStruct style = OH_Drawing_TypographyStyleGetFontStyleStruct(typoStyle);
2039     EXPECT_EQ(style.weight, normalStyle.weight);
2040     EXPECT_EQ(style.width, normalStyle.width);
2041     EXPECT_EQ(style.slant, normalStyle.slant);
2042     OH_Drawing_DestroyTypographyStyle(typoStyle);
2043 }
2044 
2045 /*
2046  * @tc.name: OH_Drawing_TypographyTest083
2047  * @tc.desc: test for the font properties of two TextStyle objects are equal
2048  * @tc.type: FUNC
2049  */
2050 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest083, TestSize.Level1)
2051 {
2052     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2053     OH_Drawing_TextStyle* txtStyleCompare = OH_Drawing_CreateTextStyle();
2054     OH_Drawing_SetTextStyleLocale(txtStyle, "en");
2055     OH_Drawing_SetTextStyleLocale(txtStyleCompare, "en");
2056     bool result = OH_Drawing_TextStyleIsEqualByFont(txtStyle, txtStyleCompare);
2057     EXPECT_TRUE(result);
2058 
2059     OH_Drawing_SetTextStyleLocale(txtStyle, "ch");
2060     result = OH_Drawing_TextStyleIsEqualByFont(txtStyle, txtStyleCompare);
2061     EXPECT_FALSE(result);
2062     EXPECT_FALSE(OH_Drawing_TextStyleIsEqualByFont(nullptr, txtStyleCompare));
2063     EXPECT_FALSE(OH_Drawing_TextStyleIsEqualByFont(txtStyle, nullptr));
2064     OH_Drawing_DestroyTextStyle(txtStyle);
2065     OH_Drawing_DestroyTextStyle(txtStyleCompare);
2066 }
2067 
2068 /*
2069  * @tc.name: OH_Drawing_TypographyTest084
2070  * @tc.desc: test for BREAK_STRATEGY_GREEDY
2071  * @tc.type: FUNC
2072  */
2073 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest084, TestSize.Level1)
2074 {
2075     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2076     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2077     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_GREEDY);
2078     OH_Drawing_TypographyCreate* handler =
2079         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2080     EXPECT_NE(handler, nullptr);
2081     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2082     const char* text = "breakStrategyTest breakStrategy breakStrategyGreedyTest";
2083     OH_Drawing_TypographyHandlerAddText(handler, text);
2084     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2085     // {1.2, 3.4} for unit test
2086     const float indents[] = { 1.2, 3.4 };
2087     OH_Drawing_TypographySetIndents(typography, 2, indents);
2088     // 300.0 for unit test
2089     double maxWidth = 300.0;
2090     OH_Drawing_TypographyLayout(typography, maxWidth);
2091     OH_Drawing_TypographyLayout(nullptr, maxWidth);
2092     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
2093 }
2094 
2095 /*
2096  * @tc.name: OH_Drawing_TypographyTest085
2097  * @tc.desc: test for BREAK_STRATEGY_BALANCED
2098  * @tc.type: FUNC
2099  */
2100 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest085, TestSize.Level1)
2101 {
2102     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2103     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2104     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_BALANCED);
2105     OH_Drawing_TypographyCreate* handler =
2106         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2107     EXPECT_NE(handler, nullptr);
2108     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2109     const char* text = "breakStrategyTest breakStrategy breakStrategyBALANCEDTest";
2110     OH_Drawing_TypographyHandlerAddText(handler, text);
2111     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2112     // {1.2, 3.4} for unit test
2113     const float indents[] = { 1.2, 3.4 };
2114     OH_Drawing_TypographySetIndents(typography, 2, indents);
2115     // 300.0 for unit test
2116     double maxWidth = 300.0;
2117     OH_Drawing_TypographyLayout(typography, maxWidth);
2118     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
2119 }
2120 
2121 /*
2122  * @tc.name: OH_Drawing_TypographyTest086
2123  * @tc.desc: test for BREAK_STRATEGY_HIGH_QUALITY
2124  * @tc.type: FUNC
2125  */
2126 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest086, TestSize.Level1)
2127 {
2128     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2129     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2130     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_HIGH_QUALITY);
2131     OH_Drawing_TypographyCreate* handler =
2132         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2133     EXPECT_NE(handler, nullptr);
2134     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2135     const char* text = "breakStrategyTest breakStrategy breakStrategyHighQualityTest";
2136     OH_Drawing_TypographyHandlerAddText(handler, text);
2137     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2138     // {1.2, 3.4} for unit test
2139     const float indents[] = { 1.2, 3.4 };
2140     OH_Drawing_TypographySetIndents(typography, 2, indents);
2141     OH_Drawing_TypographySetIndents(nullptr, 0, indents);
2142     // 300.0 for unit test
2143     double maxWidth = 300.0;
2144     OH_Drawing_TypographyLayout(typography, maxWidth);
2145     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
2146 }
2147 
2148 /*
2149  * @tc.name: OH_Drawing_TypographyTest089
2150  * @tc.desc: test for getting line  metrics for text typography
2151  * @tc.type: FUNC
2152  */
2153 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest089, TestSize.Level1)
2154 {
2155     OH_Drawing_Typography* typography = nullptr;
2156     OH_Drawing_LineMetrics* vectorMetrics = OH_Drawing_TypographyGetLineMetrics(typography);
2157     EXPECT_EQ(vectorMetrics, nullptr);
2158 }
2159 
2160 /*
2161  * @tc.name: OH_Drawing_TypographyTest090
2162  * @tc.desc: test for getting size of line metrics for text typography
2163  * @tc.type: FUNC
2164  */
2165 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest090, TestSize.Level1)
2166 {
2167     OH_Drawing_Typography* typography = nullptr;
2168     OH_Drawing_LineMetrics* vectorMetrics = OH_Drawing_TypographyGetLineMetrics(typography);
2169     OH_Drawing_TypographyGetLineMetrics(nullptr);
2170     EXPECT_EQ(vectorMetrics, nullptr);
2171     OH_Drawing_LineMetricsGetSize(nullptr);
2172     EXPECT_EQ(OH_Drawing_LineMetricsGetSize(vectorMetrics), 0);
2173     OH_Drawing_DestroyLineMetrics(vectorMetrics);
2174 }
2175 
2176 /*
2177  * @tc.name: OH_Drawing_TypographyTest091
2178  * @tc.desc: test returning line metrics info for the line text typography
2179  * @tc.type: FUNC
2180  */
2181 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest091, TestSize.Level1)
2182 {
2183     OH_Drawing_Typography* typography = nullptr;
2184     OH_Drawing_LineMetrics* metrics = nullptr;
2185     EXPECT_FALSE(OH_Drawing_TypographyGetLineMetricsAt(typography, 0, metrics));
2186     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2187     OH_Drawing_TypographyCreate* handler =
2188         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2189     typography = OH_Drawing_CreateTypography(handler);
2190     metrics = new OH_Drawing_LineMetrics();
2191     EXPECT_FALSE(OH_Drawing_TypographyGetLineMetricsAt(nullptr, 0, nullptr));
2192     EXPECT_FALSE(OH_Drawing_TypographyGetLineMetricsAt(typography, 0, nullptr));
2193     EXPECT_FALSE(OH_Drawing_TypographyGetLineMetricsAt(typography, -1, metrics));
2194     OH_Drawing_DestroyTypography(typography);
2195     OH_Drawing_DestroyTypographyHandler(handler);
2196     delete metrics;
2197     metrics = nullptr;
2198 }
2199 
2200 /*
2201  * @tc.name: OH_Drawing_TypographyTest092
2202  * @tc.desc: test for getting indets of index for text typography
2203  * @tc.type: FUNC
2204  */
2205 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest092, TestSize.Level1)
2206 {
2207     OH_Drawing_Typography* typography = nullptr;
2208     EXPECT_EQ(0.0, OH_Drawing_TypographyGetIndentsWithIndex(typography, 1));
2209     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2210     OH_Drawing_TypographyCreate* handler =
2211         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2212     typography = OH_Drawing_CreateTypography(handler);
2213     EXPECT_EQ(0.0, OH_Drawing_TypographyGetIndentsWithIndex(typography, -1));
2214     // {1.2, 3.4} for unit test
2215     const float indents[] = { 1.2, 3.4 };
2216     OH_Drawing_TypographySetIndents(typography, 2, indents);
2217     int indexOutOfBounds = 3;
2218     EXPECT_EQ(0, OH_Drawing_TypographyGetIndentsWithIndex(nullptr, 0));
2219     EXPECT_EQ(indents[1], OH_Drawing_TypographyGetIndentsWithIndex(typography, indexOutOfBounds));
2220     OH_Drawing_DestroyTypography(typography);
2221     OH_Drawing_DestroyTypographyHandler(handler);
2222     OH_Drawing_DestroyTypographyStyle(typoStyle);
2223 }
2224 
2225 /*
2226  * @tc.name: OH_Drawing_TypographyTest093
2227  * @tc.desc: test for getting line font metrics for text typography
2228  * @tc.type: FUNC
2229  */
2230 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest093, TestSize.Level1)
2231 {
2232     size_t charNumber = 0;
2233     EXPECT_EQ(OH_Drawing_TypographyGetLineFontMetrics(nullptr, 1, &charNumber), nullptr);
2234     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2235     OH_Drawing_TypographyCreate* handler =
2236         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2237     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2238     EXPECT_EQ(OH_Drawing_TypographyGetLineFontMetrics(typography, 1, nullptr), nullptr);
2239     EXPECT_EQ(OH_Drawing_TypographyGetLineFontMetrics(typography, 0, &charNumber), nullptr);
2240     EXPECT_EQ(OH_Drawing_TypographyGetLineFontMetrics(nullptr, 0, nullptr), nullptr);
2241     OH_Drawing_DestroyTypography(typography);
2242     OH_Drawing_DestroyTypographyHandler(handler);
2243     OH_Drawing_DestroyTypographyStyle(typoStyle);
2244 }
2245 
2246 /*
2247  * @tc.name: OH_Drawing_TypographyTest094
2248  * @tc.desc: test for setting font weight for text typography
2249  * @tc.type: FUNC
2250  */
2251 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest094, TestSize.Level1)
2252 {
2253     OH_Drawing_SetTypographyTextFontWeight(nullptr, FONT_WEIGHT_100);
2254     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2255     OH_Drawing_SetTypographyTextFontWeight(typoStyle, -1);
2256     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W400);
2257     OH_Drawing_SetTypographyTextFontStyle(nullptr, FONT_STYLE_NORMAL);
2258     OH_Drawing_DestroyTypographyStyle(typoStyle);
2259 }
2260 
2261 /*
2262  * @tc.name: OH_Drawing_TypographyTest095
2263  * @tc.desc: test for setting font height for text typography
2264  * @tc.type: FUNC
2265  */
2266 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest095, TestSize.Level1)
2267 {
2268     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2269     // -1.2 for unit test
2270     OH_Drawing_SetTypographyTextFontHeight(typoStyle, -1.2);
2271     OH_Drawing_SetTypographyTextFontHeight(nullptr, 0);
2272     EXPECT_TRUE(ConvertToOriginalText(typoStyle)->heightOnly);
2273     EXPECT_EQ(ConvertToOriginalText(typoStyle)->heightScale, 0);
2274 }
2275 
2276 /*
2277  * @tc.name: OH_Drawing_TypographyTest096
2278  * @tc.desc: test for setting half leading for text typography
2279  * @tc.type: FUNC
2280  */
2281 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest096, TestSize.Level1)
2282 {
2283     bool halfLeading = false;
2284     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2285     OH_Drawing_SetTypographyTextHalfLeading(typoStyle, halfLeading);
2286     OH_Drawing_SetTypographyTextHalfLeading(nullptr, halfLeading);
2287     EXPECT_FALSE(ConvertToOriginalText(typoStyle)->halfLeading);
2288 }
2289 
2290 /*
2291  * @tc.name: OH_Drawing_TypographyTest097
2292  * @tc.desc: test for setting text line style font weight for text typography
2293  * @tc.type: FUNC
2294  */
2295 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest097, TestSize.Level1)
2296 {
2297     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2298     // -1 for unit test
2299     int weight = -1;
2300     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, weight);
2301     OH_Drawing_SetTypographyTextLineStyleFontWeight(nullptr, weight);
2302     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W400);
2303 }
2304 
2305 /*
2306  * @tc.name: OH_Drawing_TypographyTest098
2307  * @tc.desc: test for text line style getting font families for text typography
2308  * @tc.type: FUNC
2309  */
2310 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest098, TestSize.Level1)
2311 {
2312     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2313     char** result = OH_Drawing_TypographyTextlineStyleGetFontFamilies(typoStyle, nullptr);
2314     EXPECT_EQ(result, nullptr);
2315 }
2316 
2317 /*
2318  * @tc.name: OH_Drawing_TypographyTest099
2319  * @tc.desc: test for text line style setting half leading for text typography
2320  * @tc.type: FUNC
2321  */
2322 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest099, TestSize.Level1)
2323 {
2324     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2325     bool lineStyleHalfLeading = false;
2326     OH_Drawing_SetTypographyTextLineStyleHalfLeading(typoStyle, lineStyleHalfLeading);
2327     OH_Drawing_SetTypographyTextLineStyleHalfLeading(nullptr, lineStyleHalfLeading);
2328     bool result = OH_Drawing_TypographyTextlineStyleGetHalfLeading(typoStyle);
2329     EXPECT_FALSE(result);
2330 }
2331 
2332 /*
2333  * @tc.name: OH_Drawing_TypographyTest100
2334  * @tc.desc: test for getting style struct for text typography
2335  * @tc.type: FUNC
2336  */
2337 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest100, TestSize.Level1)
2338 {
2339     // 0.0 for unit test
2340     double lineShift = 0.0;
2341     EXPECT_EQ(OH_Drawing_TypographyStyleGetStrutStyle(nullptr), nullptr);
2342     OH_Drawing_TextStyleSetBaselineShift(nullptr, lineShift);
2343     EXPECT_EQ(OH_Drawing_TextStyleGetBaselineShift(nullptr), 0.0);
2344     EXPECT_EQ(OH_Drawing_TypographyStyleGetEffectiveAlignment(nullptr), TEXT_ALIGN_START);
2345     EXPECT_FALSE(OH_Drawing_TypographyStyleIsHintEnabled(nullptr));
2346 }
2347 
2348 /*
2349  * @tc.name: OH_Drawing_TypographyTest101
2350  * @tc.desc: test for getting font style struct for text typography
2351  * @tc.type: FUNC
2352  */
2353 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest101, TestSize.Level1)
2354 {
2355     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2356     EXPECT_NE(typoStyle, nullptr);
2357     OH_Drawing_FontStyleStruct normalStyle;
2358     normalStyle.weight = FONT_WEIGHT_900;
2359     normalStyle.width = FONT_WIDTH_ULTRA_EXPANDED;
2360     normalStyle.slant = FONT_STYLE_ITALIC;
2361     OH_Drawing_SetTypographyStyleFontStyleStruct(typoStyle, normalStyle);
2362 
2363     OH_Drawing_FontStyleStruct style = OH_Drawing_TypographyStyleGetFontStyleStruct(typoStyle);
2364     EXPECT_EQ(style.weight, FONT_WEIGHT_900);
2365     EXPECT_EQ(style.width, FONT_WIDTH_ULTRA_EXPANDED);
2366     EXPECT_EQ(style.slant, FONT_STYLE_ITALIC);
2367     OH_Drawing_DestroyTypographyStyle(typoStyle);
2368 }
2369 
2370 /*
2371  * @tc.name: OH_Drawing_TypographyTest102
2372  * @tc.desc: test for the font parser
2373  * @tc.type: FUNC
2374  */
2375 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest102, TestSize.Level1)
2376 {
2377     OH_Drawing_FontParser* parser = OH_Drawing_CreateFontParser();
2378     static const std::string FILE_NAME = "/system/fonts/visibility_list.json";
2379     std::ifstream fileStream(FILE_NAME.c_str());
2380     if (fileStream.is_open()) {
2381         size_t fontNum;
2382         char** list = OH_Drawing_FontParserGetSystemFontList(parser, &fontNum);
2383         EXPECT_NE(list, nullptr);
2384         EXPECT_EQ(OH_Drawing_FontParserGetSystemFontList(nullptr, &fontNum), nullptr);
2385         const char* name = list[0] ;
2386         EXPECT_NE(OH_Drawing_FontParserGetFontByName(parser, name), nullptr);
2387         EXPECT_EQ(OH_Drawing_FontParserGetFontByName(nullptr, name), nullptr);
2388         OH_Drawing_DestroySystemFontList(list, fontNum);
2389         OH_Drawing_DestroySystemFontList(nullptr, fontNum);
2390     }
2391     OH_Drawing_DestroyFontParser(parser);
2392 }
2393 
2394 /*
2395  * @tc.name: OH_Drawing_TypographyTest103
2396  * @tc.desc: test arc text offset
2397  * @tc.type: FUNC
2398  */
2399 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest104, TestSize.Level1)
2400 {
2401     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2402     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2403     OH_Drawing_TypographyCreate* handler =
2404         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2405     EXPECT_NE(handler, nullptr);
2406     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
2407     OH_Drawing_SetTextStyleFontSize(txtStyle, ARC_FONT_SIZE);
2408     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
2409     bool halfLeading = true;
2410     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
2411     const char* fontFamilies[] = { "Roboto" };
2412     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
2413     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2414     const char* text = "OpenHarmony\n";
2415     OH_Drawing_TypographyHandlerAddText(handler, text);
2416     OH_Drawing_TypographyHandlerPopTextStyle(handler);
2417     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2418     OH_Drawing_TypographyLayout(typography, MAX_WIDTH);
2419     OH_Drawing_Path* cPath = OH_Drawing_PathCreate();
2420     OH_Drawing_PathArcTo(cPath, LEFT_POS, LEFT_POS, RIGHT_POS, RIGHT_POS, 0, SWEEP_DEGREE);
2421 
2422     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
2423     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
2424     OH_Drawing_CanvasDrawPath(cCanvas, cPath);
2425     OH_Drawing_TypographyPaintOnPath(typography, cCanvas, cPath, ARC_FONT_SIZE, ARC_FONT_SIZE);
2426     OH_Drawing_Font_Metrics fontmetrics;
2427     EXPECT_TRUE(OH_Drawing_TextStyleGetFontMetrics(typography, txtStyle, &fontmetrics));
2428     OH_Drawing_SetTypographyTextStyle(typoStyle, txtStyle);
2429     OH_Drawing_DestroyTypography(typography);
2430     OH_Drawing_DestroyTypographyHandler(handler);
2431     OH_Drawing_DestroyTypographyStyle(typoStyle);
2432     OH_Drawing_DestroyTextStyle(txtStyle);
2433     OH_Drawing_PathDestroy(cPath);
2434     OH_Drawing_CanvasDestroy(cCanvas);
2435 }
2436 
2437 /*
2438  * @tc.name: OH_Drawing_TypographyTest104
2439  * @tc.desc: test arc text drawing
2440  * @tc.type: FUNC
2441  */
2442 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest103, TestSize.Level1)
2443 {
2444     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2445     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2446     OH_Drawing_TypographyCreate* handler =
2447         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2448     EXPECT_NE(handler, nullptr);
2449     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
2450     OH_Drawing_SetTextStyleFontSize(txtStyle, ARC_FONT_SIZE);
2451     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
2452     bool halfLeading = true;
2453     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
2454     const char* fontFamilies[] = { "Roboto" };
2455     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
2456     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2457     const char* text = "OpenHarmony\n";
2458     OH_Drawing_TypographyHandlerAddText(handler, text);
2459     OH_Drawing_TypographyHandlerPopTextStyle(handler);
2460     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2461     OH_Drawing_TypographyLayout(typography, MAX_WIDTH);
2462     OH_Drawing_Path* cPath = OH_Drawing_PathCreate();
2463     OH_Drawing_PathArcTo(cPath, LEFT_POS, LEFT_POS, RIGHT_POS, RIGHT_POS, 0, SWEEP_DEGREE);
2464 
2465     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
2466     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
2467     OH_Drawing_CanvasDrawPath(cCanvas, cPath);
2468     OH_Drawing_TypographyPaintOnPath(typography, cCanvas, cPath, ARC_FONT_SIZE, ARC_FONT_SIZE);
2469     OH_Drawing_Font_Metrics fontmetrics;
2470     EXPECT_TRUE(OH_Drawing_TextStyleGetFontMetrics(typography, txtStyle, &fontmetrics));
2471     OH_Drawing_SetTypographyTextStyle(typoStyle, txtStyle);
2472     OH_Drawing_DestroyTypography(typography);
2473     OH_Drawing_DestroyTypographyHandler(handler);
2474     OH_Drawing_DestroyTypographyStyle(typoStyle);
2475     OH_Drawing_DestroyTextStyle(txtStyle);
2476     OH_Drawing_PathDestroy(cPath);
2477     OH_Drawing_CanvasDestroy(cCanvas);
2478 }
2479 
2480 /*
2481  * @tc.name: OH_Drawing_TypographyTest105
2482  * @tc.desc: test for the text box
2483  * @tc.type: FUNC
2484  */
2485 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest105, TestSize.Level1)
2486 {
2487     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2488     OH_Drawing_TypographyCreate* handler =
2489         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2490     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2491     OH_Drawing_TextBox* textBox = OH_Drawing_TypographyGetRectsForPlaceholders(typography);
2492     OH_Drawing_GetLeftFromTextBox(textBox, 0);
2493     OH_Drawing_GetRightFromTextBox(textBox, 0);
2494     OH_Drawing_GetTopFromTextBox(textBox, 0);
2495     OH_Drawing_GetBottomFromTextBox(textBox, 0);
2496     EXPECT_EQ(OH_Drawing_GetTextDirectionFromTextBox(textBox, 0), 0);
2497     EXPECT_EQ(OH_Drawing_GetSizeOfTextBox(textBox), 0);
2498 
2499     OH_Drawing_PositionAndAffinity* positionAndAffinity =
2500         OH_Drawing_TypographyGetGlyphPositionAtCoordinate(typography, 1, 0);
2501     OH_Drawing_GetPositionFromPositionAndAffinity(positionAndAffinity);
2502     OH_Drawing_GetPositionFromPositionAndAffinity(nullptr);
2503     OH_Drawing_GetAffinityFromPositionAndAffinity(positionAndAffinity);
2504     OH_Drawing_GetAffinityFromPositionAndAffinity(nullptr);
2505 
2506     OH_Drawing_Range* range = OH_Drawing_TypographyGetWordBoundary(typography, 1);
2507     OH_Drawing_GetStartFromRange(range);
2508     OH_Drawing_GetStartFromRange(nullptr);
2509     OH_Drawing_GetEndFromRange(range);
2510     OH_Drawing_GetEndFromRange(nullptr);
2511     OH_Drawing_TypographyGetLineHeight(typography, 1);
2512     OH_Drawing_TypographyGetLineHeight(nullptr, 1);
2513     OH_Drawing_TypographyGetLineWidth(typography, 1);
2514     OH_Drawing_TypographyGetLineWidth(nullptr, 1);
2515 }
2516 
2517 /*
2518  * @tc.name: OH_Drawing_TypographyTest106
2519  * @tc.desc: test for the textbox.
2520  * @tc.type: FUNC
2521  */
2522 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest106, TestSize.Level1)
2523 {
2524     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2525     OH_Drawing_TypographyCreate* handler =
2526         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2527     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2528     OH_Drawing_TextBox* textBox = OH_Drawing_TypographyGetRectsForPlaceholders(typography);
2529     OH_Drawing_TypographyGetRectsForPlaceholders(nullptr);
2530     EXPECT_NE(textBox, nullptr);
2531     OH_Drawing_DestroyTypographyStyle(typoStyle);
2532     OH_Drawing_DestroyTypographyHandler(handler);
2533     OH_Drawing_DestroyTypography(typography);
2534     OH_Drawing_TypographyDestroyTextBox(textBox);
2535 }
2536 
2537 /*
2538  * @tc.name: OH_Drawing_TypographyTest107
2539  * @tc.desc: test for default textshadow.
2540  * @tc.type: FUNC
2541  */
2542 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest107, TestSize.Level1)
2543 {
2544     // Test default scenario
2545     OH_Drawing_TextShadow* shadow = OH_Drawing_CreateTextShadow();
2546     EXPECT_NE(shadow, nullptr);
2547     uint32_t color = 0;
2548     OH_Drawing_Point* offset = OH_Drawing_PointCreate(0, 0);
2549     double blurRadius = 0.0;
2550     OH_Drawing_SetTextShadow(shadow, color, offset, blurRadius);
2551     OH_Drawing_DestroyTextShadow(shadow);
2552     OH_Drawing_PointDestroy(offset);
2553     OH_Drawing_SetTextShadow(nullptr, color, nullptr, blurRadius);
2554     OH_Drawing_SetTextShadow(shadow, color, nullptr, blurRadius);
2555     OH_Drawing_DestroyTextShadow(nullptr);
2556     OH_Drawing_PointDestroy(nullptr);
2557     EXPECT_NE(shadow, nullptr);
2558 }
2559 
2560 /*
2561  * @tc.name: OH_Drawing_TextStyleAddShadowTest
2562  * @tc.desc: test for multiple shadow parameters and abnormal shadow parameters.
2563  * @tc.type: FUNC
2564  */
2565 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TextStyleAddShadowTest, TestSize.Level1)
2566 {
2567     // Test the full shadow parameters of the scene
2568     OH_Drawing_TextShadow* shadow2 = OH_Drawing_CreateTextShadow();
2569     uint32_t color2 = OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00);
2570     OH_Drawing_Point* offset2 = OH_Drawing_PointCreate(10, 10);
2571     double blurRadius2 = 10.0;
2572     OH_Drawing_SetTextShadow(shadow2, color2, offset2, blurRadius2);
2573     OH_Drawing_TextStyle* textStyle = OH_Drawing_CreateTextStyle();
2574     OH_Drawing_TextStyleAddShadow(textStyle, shadow2);
2575     OH_Drawing_TextStyleAddShadow(textStyle, shadow2);
2576     int getCount2 = OH_Drawing_TextStyleGetShadowCount(textStyle);
2577     EXPECT_EQ(getCount2, 2);
2578     OH_Drawing_TextStyleClearShadows(textStyle);
2579     EXPECT_EQ(OH_Drawing_TextStyleGetShadowCount(textStyle), 0);
2580     OH_Drawing_TextShadow* shadow21 = OH_Drawing_CreateTextShadow();
2581     uint32_t color21 = OH_Drawing_ColorSetArgb(0xFF, 0x00, 0xFF, 0x00);
2582     OH_Drawing_Point* offset21 = OH_Drawing_PointCreate(-10, -10);
2583     double blurRadius21 = 20.0;
2584     OH_Drawing_SetTextShadow(shadow21, color21, offset21, blurRadius21);
2585     OH_Drawing_TextStyleAddShadow(textStyle, shadow21);
2586     OH_Drawing_TextStyleAddShadow(textStyle, shadow2);
2587     OH_Drawing_TextShadow* getShadow2 = OH_Drawing_TextStyleGetShadowWithIndex(textStyle, getCount2 - 1);
2588     EXPECT_NE(getShadow2, nullptr);
2589     OH_Drawing_TextShadow* getShadow21 = OH_Drawing_TextStyleGetShadowWithIndex(textStyle, 0);
2590     EXPECT_NE(getShadow21, nullptr);
2591     EXPECT_EQ(OH_Drawing_TextStyleGetShadowWithIndex(textStyle, -1), nullptr);
2592     EXPECT_EQ(OH_Drawing_TextStyleGetShadowWithIndex(textStyle, getCount2), nullptr);
2593     OH_Drawing_PointDestroy(offset2);
2594     OH_Drawing_PointDestroy(offset21);
2595     OH_Drawing_DestroyTextShadow(shadow2);
2596     OH_Drawing_DestroyTextShadow(shadow21);
2597     EXPECT_NE(shadow2, nullptr);
2598     EXPECT_NE(shadow21, nullptr);
2599 
2600     // Test the scene for abnormal shadow parameters
2601     OH_Drawing_TextShadow* shadow3 = OH_Drawing_CreateTextShadow();
2602     uint32_t color3 = -1;
2603     OH_Drawing_Point* offset3 = OH_Drawing_PointCreate(10, 10);
2604     double blurRadius3 = -10.0;
2605     OH_Drawing_SetTextShadow(shadow3, color3, offset3, blurRadius3);
2606     EXPECT_NE(shadow3, nullptr);
2607     OH_Drawing_TextStyleAddShadow(textStyle, shadow3);
2608     OH_Drawing_TextStyleAddShadow(textStyle, shadow3);
2609     OH_Drawing_PointDestroy(offset3);
2610     OH_Drawing_DestroyTextShadow(shadow3);
2611     OH_Drawing_TextShadow* shadow3AllGet = OH_Drawing_TextStyleGetShadows(textStyle);
2612     EXPECT_NE(shadow3AllGet, nullptr);
2613     OH_Drawing_DestroyTextShadows(shadow3AllGet);
2614     EXPECT_NE(shadow3AllGet, nullptr);
2615 }
2616 
2617 /*
2618  * @tc.name: OH_Drawing_AddTextStyleDecorationTest
2619  * @tc.desc: test for add multiple text decoration
2620  * @tc.type: FUNC
2621  */
2622 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_AddTextStyleDecorationTest, TestSize.Level1)
2623 {
2624     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2625     EXPECT_NE(txtStyle, nullptr);
2626     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_NONE);
2627 
2628     OH_Drawing_AddTextStyleDecoration(txtStyle, TEXT_DECORATION_UNDERLINE);
2629     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE);
2630 
2631     OH_Drawing_AddTextStyleDecoration(txtStyle, -1);
2632     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE);
2633 
2634     OH_Drawing_AddTextStyleDecoration(txtStyle, TEXT_DECORATION_OVERLINE);
2635     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE | TextDecoration::OVERLINE);
2636 
2637     OH_Drawing_AddTextStyleDecoration(nullptr, TEXT_DECORATION_LINE_THROUGH);
2638     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE | TextDecoration::OVERLINE);
2639 
2640     OH_Drawing_AddTextStyleDecoration(txtStyle, TEXT_DECORATION_LINE_THROUGH);
2641     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration,
2642         TextDecoration::UNDERLINE | TextDecoration::OVERLINE | TextDecoration::LINE_THROUGH);
2643 
2644     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_NONE);
2645     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::NONE);
2646     OH_Drawing_AddTextStyleDecoration(txtStyle, TEXT_DECORATION_UNDERLINE | TEXT_DECORATION_LINE_THROUGH);
2647     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE | TextDecoration::LINE_THROUGH);
2648     OH_Drawing_AddTextStyleDecoration(nullptr, TEXT_DECORATION_UNDERLINE | TEXT_DECORATION_LINE_THROUGH);
2649 
2650     OH_Drawing_DestroyTextStyle(txtStyle);
2651 }
2652 
2653 /*
2654  * @tc.name: OH_Drawing_RemoveTextStyleDecorationTest
2655  * @tc.desc: test for remove specific text decoration
2656  * @tc.type: FUNC
2657  */
2658 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_RemoveTextStyleDecorationTest, TestSize.Level1)
2659 {
2660     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2661     EXPECT_NE(txtStyle, nullptr);
2662     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_NONE);
2663 
2664     OH_Drawing_AddTextStyleDecoration(txtStyle, TEXT_DECORATION_UNDERLINE);
2665     OH_Drawing_AddTextStyleDecoration(txtStyle, TEXT_DECORATION_OVERLINE);
2666     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE | TextDecoration::OVERLINE);
2667     OH_Drawing_RemoveTextStyleDecoration(txtStyle, TEXT_DECORATION_UNDERLINE);
2668     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::OVERLINE);
2669 
2670     OH_Drawing_RemoveTextStyleDecoration(txtStyle, -1);
2671     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::OVERLINE);
2672 
2673     OH_Drawing_RemoveTextStyleDecoration(nullptr, TEXT_DECORATION_LINE_THROUGH);
2674     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::OVERLINE);
2675 
2676     OH_Drawing_AddTextStyleDecoration(txtStyle,
2677         TEXT_DECORATION_UNDERLINE | TEXT_DECORATION_OVERLINE | TEXT_DECORATION_LINE_THROUGH);
2678     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration,
2679         TextDecoration::UNDERLINE | TextDecoration::OVERLINE | TextDecoration::LINE_THROUGH);
2680     OH_Drawing_RemoveTextStyleDecoration(txtStyle, TEXT_DECORATION_UNDERLINE | TEXT_DECORATION_LINE_THROUGH);
2681     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::OVERLINE);
2682     OH_Drawing_RemoveTextStyleDecoration(nullptr, TEXT_DECORATION_UNDERLINE | TEXT_DECORATION_LINE_THROUGH);
2683 
2684     OH_Drawing_DestroyTextStyle(txtStyle);
2685 }
2686 
2687 /*
2688  * @tc.name: OH_Drawing_TypographyTest108
2689  * @tc.desc: test for the text tab create and destroy
2690  * @tc.type: FUNC
2691  */
2692 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest108, TestSize.Level1)
2693 {
2694     OH_Drawing_TextTab* textTab = OH_Drawing_CreateTextTab(TEXT_ALIGN_LEFT, 0.0);
2695     EXPECT_NE(textTab, nullptr);
2696     OH_Drawing_TextTab* textTab2 = OH_Drawing_CreateTextTab(TEXT_ALIGN_END, -1.0);
2697     EXPECT_NE(textTab2, nullptr);
2698     OH_Drawing_DestroyTextTab(textTab);
2699     OH_Drawing_DestroyTextTab(textTab2);
2700 }
2701 
2702 /*
2703  * @tc.name: OH_Drawing_TypographyTest109
2704  * @tc.desc: test for get alignment of the text tab
2705  * @tc.type: FUNC
2706  */
2707 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest109, TestSize.Level1)
2708 {
2709     OH_Drawing_TextTab* textTab = OH_Drawing_CreateTextTab(TEXT_ALIGN_LEFT, 0.0);
2710     EXPECT_EQ(OH_Drawing_GetTextTabAlignment(textTab), TEXT_ALIGN_LEFT);
2711     OH_Drawing_TextTab* textTab2 = OH_Drawing_CreateTextTab(TEXT_ALIGN_JUSTIFY, 0.0);
2712     EXPECT_EQ(OH_Drawing_GetTextTabAlignment(textTab), TEXT_ALIGN_LEFT);
2713     EXPECT_EQ(OH_Drawing_GetTextTabAlignment(nullptr), TEXT_ALIGN_LEFT);
2714     OH_Drawing_DestroyTextTab(textTab);
2715     OH_Drawing_DestroyTextTab(textTab2);
2716 }
2717 
2718 /*
2719  * @tc.name: OH_Drawing_TypographyTest110
2720  * @tc.desc: test for get location of the text tab
2721  * @tc.type: FUNC
2722  */
2723 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest110, TestSize.Level1)
2724 {
2725     OH_Drawing_TextTab* textTab = OH_Drawing_CreateTextTab(TEXT_ALIGN_LEFT, 0.0);
2726     EXPECT_EQ(OH_Drawing_GetTextTabLocation(textTab), 0.0);
2727     OH_Drawing_DestroyTextTab(textTab);
2728     OH_Drawing_TextTab* textTab2 = OH_Drawing_CreateTextTab(TEXT_ALIGN_LEFT, -100.0);
2729     EXPECT_EQ(OH_Drawing_GetTextTabLocation(textTab2), -100.0);
2730     EXPECT_EQ(OH_Drawing_GetTextTabLocation(nullptr), 0.0);
2731     OH_Drawing_DestroyTextTab(textTab2);
2732 }
2733 
2734 /*
2735  * @tc.name: OH_Drawing_TypographyTest111
2736  * @tc.desc: test for typography style set text tab
2737  * @tc.type: FUNC
2738  */
2739 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest111, TestSize.Level1)
2740 {
2741     OH_Drawing_TextTab* textTab = OH_Drawing_CreateTextTab(TEXT_ALIGN_LEFT, -1.0);
2742     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2743     OH_Drawing_SetTypographyTextTab(typoStyle, textTab);
2744     OH_Drawing_SetTypographyTextTab(nullptr, textTab);
2745     OH_Drawing_SetTypographyTextTab(typoStyle, nullptr);
2746     EXPECT_EQ(ConvertToOriginalText(typoStyle)->tab.alignment, TextAlign::LEFT);
2747     EXPECT_EQ(ConvertToOriginalText(typoStyle)->tab.location, -1.0);
2748     OH_Drawing_DestroyTextTab(textTab);
2749     OH_Drawing_DestroyTypographyStyle(typoStyle);
2750 }
2751 
2752 /*
2753  * @tc.name: OH_Drawing_TypographyTest112
2754  * @tc.desc: test for truncated emoji text drawing
2755  * @tc.type: FUNC
2756  */
2757 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest112, TestSize.Level1)
2758 {
2759     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2760     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2761     OH_Drawing_TypographyCreate* handler =
2762         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2763     EXPECT_NE(handler, nullptr);
2764     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
2765     OH_Drawing_SetTextStyleFontSize(txtStyle, ARC_FONT_SIZE);
2766     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
2767     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2768     const char* text = "\xF0\x9F\x98";
2769     OHOS::Rosen::SPText::TextBundleConfigParser::GetInstance().initStatus_ = true;
2770     OHOS::Rosen::SPText::TextBundleConfigParser::GetInstance().bundleApiVersion_ =
2771         OHOS::Rosen::SPText::SINCE_API18_VERSION;
2772     OH_Drawing_TypographyHandlerAddText(handler, text);
2773     OHOS::Rosen::SPText::TextBundleConfigParser::GetInstance().initStatus_ = false;
2774     OH_Drawing_TypographyHandlerPopTextStyle(handler);
2775     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2776     EXPECT_NE(typography, nullptr);
2777     OH_Drawing_TypographyLayout(typography, MAX_WIDTH);
2778 
2779     float longestLineWidth = OH_Drawing_TypographyGetLongestLine(typography);
2780     ASSERT_TRUE(skia::textlayout::nearlyEqual(longestLineWidth, ARC_FONT_SIZE));
2781 
2782     OH_Drawing_DestroyTypography(typography);
2783     OH_Drawing_DestroyTypographyHandler(handler);
2784     OH_Drawing_DestroyTypographyStyle(typoStyle);
2785     OH_Drawing_DestroyTextStyle(txtStyle);
2786 }
2787 
2788 /*
2789  * @tc.name: OH_Drawing_FontParserGetSystemFontListTest001
2790  * @tc.desc: test for the OH_Drawing_FontParserGetSystemFontList.
2791  * @tc.type: FUNC
2792  * @tc.require: IALK43
2793  */
2794 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_FontParserGetSystemFontListTest001, TestSize.Level1)
2795 {
2796     OH_Drawing_FontParser* fontParser = OH_Drawing_CreateFontParser();
2797     ASSERT_NE(fontParser, nullptr);
2798     size_t value = 100; // 100 for test
2799     size_t* num = &value;
2800     ASSERT_EQ(OH_Drawing_FontParserGetSystemFontList(fontParser, num), nullptr);
2801     num = nullptr;
2802     ASSERT_EQ(OH_Drawing_FontParserGetSystemFontList(fontParser, num), nullptr);
2803     fontParser = nullptr;
2804     ASSERT_EQ(OH_Drawing_FontParserGetSystemFontList(fontParser, num), nullptr);
2805 }
2806 
2807 /*
2808  * @tc.name: OH_Drawing_DestroySystemFontListTest001
2809  * @tc.desc: test for the OH_Drawing_DestroySystemFontList.
2810  * @tc.type: FUNC
2811  * @tc.require: IALK43
2812  */
2813 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_DestroySystemFontListTest001, TestSize.Level1)
2814 {
2815     char** fontList = new char*[3]; // 3 means the number of font
2816     std::string tempStr1 = "Test1";
2817     std::string tempStr3 = "Test3";
2818     fontList[0] = new char[tempStr1.size() + 1];
2819     std::copy(tempStr1.begin(), tempStr1.end(), fontList[0]);
2820     fontList[0][tempStr1.size()] = '\0';
2821     fontList[1] = nullptr;
2822     fontList[2] = new char[tempStr3.size() + 1]; // 2 means the index of font
2823     std::copy(tempStr3.begin(), tempStr3.end(), fontList[2]); // 2 means the index of font
2824     fontList[2][tempStr3.size()] = '\0'; // 2 means the index of font
2825     size_t num = 3; // 3 means the number of font
2826     ASSERT_NE(fontList, nullptr);
2827     OH_Drawing_DestroySystemFontList(fontList, num);
2828 
2829     fontList = nullptr;
2830     OH_Drawing_DestroySystemFontList(fontList, num);
2831 }
2832 
2833 /*
2834  * @tc.name: OH_Drawing_FontParserGetFontByNameTest001
2835  * @tc.desc: test for the OH_Drawing_FontParserGetFontByName.
2836  * @tc.type: FUNC
2837  * @tc.require: IALK43
2838  */
2839 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_FontParserGetFontByNameTest001, TestSize.Level1)
2840 {
2841     OH_Drawing_FontParser* fontParser = OH_Drawing_CreateFontParser();
2842     ASSERT_NE(fontParser, nullptr);
2843     const char* name = "test";
2844     OH_Drawing_FontDescriptor* fontDescriptor = OH_Drawing_FontParserGetFontByName(fontParser, name);
2845     ASSERT_EQ(fontDescriptor, nullptr);
2846 
2847     OH_Drawing_FontDescriptor* fontDescriptor1 = OH_Drawing_FontParserGetFontByName(fontParser, nullptr);
2848     ASSERT_EQ(fontDescriptor1, nullptr);
2849 
2850     OH_Drawing_FontDescriptor* fontDescriptor2 = OH_Drawing_FontParserGetFontByName(nullptr, name);
2851     ASSERT_EQ(fontDescriptor2, nullptr);
2852     OH_Drawing_DestroyFontParser(fontParser);
2853 }
2854 
2855 /*
2856  * @tc.name: OH_Drawing_TypographyGetLineMetricsTest001
2857  * @tc.desc: test for the OH_Drawing_TypographyGetLineMetrics.
2858  * @tc.type: FUNC
2859  * @tc.require: IALK43
2860  */
2861 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyGetLineMetricsTest001, TestSize.Level1)
2862 {
2863     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2864     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2865         OH_Drawing_CreateFontCollection());
2866     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2867     ASSERT_NE(typography, nullptr);
2868     OH_Drawing_LineMetrics* lineMetrics = OH_Drawing_TypographyGetLineMetrics(typography);
2869     ASSERT_EQ(lineMetrics, nullptr);
2870     OH_Drawing_DestroyTypographyStyle(typoStyle);
2871     OH_Drawing_DestroyTypographyHandler(handler);
2872     OH_Drawing_DestroyTypography(typography);
2873 }
2874 
2875 /*
2876  * @tc.name: OH_Drawing_TextStyleGetShadowCountTest001
2877  * @tc.desc: test for the OH_Drawing_TextStyleGetShadowCount.
2878  * @tc.type: FUNC
2879  * @tc.require: IALK43
2880  */
2881 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TextStyleGetShadowCountTest001, TestSize.Level1)
2882 {
2883     OH_Drawing_TextStyle* style = OH_Drawing_CreateTextStyle();
2884     ASSERT_NE(style, nullptr);
2885     ASSERT_EQ(OH_Drawing_TextStyleGetShadowCount(style), 0);
2886     OH_Drawing_TextShadow* textShadow = OH_Drawing_TextStyleGetShadows(style);
2887     ASSERT_NE(textShadow, nullptr);
2888 
2889     ASSERT_EQ(OH_Drawing_TextStyleGetShadowCount(nullptr), 0);
2890     OH_Drawing_TextShadow* textShadow1 = OH_Drawing_TextStyleGetShadows(nullptr);
2891     ASSERT_EQ(textShadow1, nullptr);
2892     OH_Drawing_DestroyTextStyle(style);
2893     OH_Drawing_DestroyTextShadows(textShadow);
2894 }
2895 
2896 /*
2897  * @tc.name: OH_Drawing_SetTextShadowTest001
2898  * @tc.desc: test for the OH_Drawing_SetTextShadow.
2899  * @tc.type: FUNC
2900  * @tc.require: IALK43
2901  */
2902 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_SetTextShadowTest001, TestSize.Level1)
2903 {
2904     OH_Drawing_TextStyle* style = OH_Drawing_CreateTextStyle();
2905     OH_Drawing_TextShadow* originShadow = OH_Drawing_CreateTextShadow();
2906     OH_Drawing_TextStyleAddShadow(style, originShadow);
2907     OH_Drawing_TextShadow* shadow = OH_Drawing_TextStyleGetShadowWithIndex(style, 0);
2908     ASSERT_NE(shadow, nullptr);
2909     uint32_t color = 0;
2910     OH_Drawing_Point* offset = OH_Drawing_PointCreate(0, 0);
2911     ASSERT_NE(offset, nullptr);
2912     double blurRadius = true;
2913     OH_Drawing_SetTextShadow(shadow, color, offset, blurRadius);
2914     OH_Drawing_SetTextShadow(shadow, color, nullptr, blurRadius);
2915     OH_Drawing_SetTextShadow(nullptr, color, offset, blurRadius);
2916 
2917     OH_Drawing_DestroyTextStyle(style);
2918     OH_Drawing_PointDestroy(offset);
2919     OH_Drawing_DestroyTextShadow(originShadow);
2920 }
2921 
2922 /*
2923  * @tc.name: OH_Drawing_TextStyleAddShadowTest001
2924  * @tc.desc: test for the OH_Drawing_TextStyleAddShadow.
2925  * @tc.type: FUNC
2926  * @tc.require: IALK43
2927  */
2928 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TextStyleAddShadowTest001, TestSize.Level1)
2929 {
2930     OH_Drawing_TextStyle* style = OH_Drawing_CreateTextStyle();
2931     OH_Drawing_TextShadow* shadow = OH_Drawing_TextStyleGetShadows(style);
2932     ASSERT_NE(shadow, nullptr);
2933     OH_Drawing_TextStyleAddShadow(style, shadow);
2934     EXPECT_NE(OH_Drawing_TextStyleGetShadows(style), nullptr);
2935     OH_Drawing_TextStyleClearShadows(style);
2936     OH_Drawing_TextStyleAddShadow(nullptr, shadow);
2937     OH_Drawing_TextStyleClearShadows(nullptr);
2938     OH_Drawing_TextStyleAddShadow(style, nullptr);
2939     OH_Drawing_DestroyTextStyle(style);
2940     OH_Drawing_DestroyTextShadows(shadow);
2941 }
2942 
2943 /*
2944  * @tc.name: OH_Drawing_TextStyleGetShadowWithIndexTest001
2945  * @tc.desc: test for the OH_Drawing_TextStyleGetShadowWithIndex.
2946  * @tc.type: FUNC
2947  * @tc.require: IALK43
2948  */
2949 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TextStyleGetShadowWithIndexTest001, TestSize.Level1)
2950 {
2951     OH_Drawing_TextStyle* style = OH_Drawing_CreateTextStyle();
2952     ASSERT_NE(style, nullptr);
2953     OH_Drawing_TextShadow* textShadow = OH_Drawing_TextStyleGetShadowWithIndex(style, 0);
2954     ASSERT_EQ(textShadow, nullptr);
2955     // 2 for test
2956     OH_Drawing_TextShadow* textShadow1 = OH_Drawing_TextStyleGetShadowWithIndex(style, 2);
2957     ASSERT_EQ(textShadow1, nullptr);
2958     // -1 for test
2959     OH_Drawing_TextShadow* textShadow2 = OH_Drawing_TextStyleGetShadowWithIndex(style, -1);
2960     ASSERT_EQ(textShadow2, nullptr);
2961     // -1 for test
2962     OH_Drawing_TextShadow* textShadow3 = OH_Drawing_TextStyleGetShadowWithIndex(nullptr, -1);
2963     ASSERT_EQ(textShadow3, nullptr);
2964     OH_Drawing_DestroyTextStyle(style);
2965 }
2966 
2967 /*
2968  * @tc.name: OH_Drawing_TextStyleGetShadowsTest001
2969  * @tc.desc: test for the OH_Drawing_DestroyTextShadows.
2970  * @tc.type: FUNC
2971  * @tc.require: IALK43
2972  */
2973 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TextStyleGetShadowsTest001, TestSize.Level1)
2974 {
2975     OH_Drawing_TextStyle* style = OH_Drawing_CreateTextStyle();
2976     OH_Drawing_TextShadow* shadow = OH_Drawing_TextStyleGetShadows(style);
2977     ASSERT_NE(shadow, nullptr);
2978     OH_Drawing_DestroyTextShadows(shadow);
2979     OH_Drawing_DestroyTextShadows(nullptr);
2980     OH_Drawing_DestroyTextStyle(style);
2981 }
2982 
2983 /*
2984  * @tc.name: OH_Drawing_SetTypographyTextEllipsisTest001
2985  * @tc.desc: test for the OH_Drawing_SetTypographyTextLocale.
2986  * @tc.type: FUNC
2987  * @tc.require: IALK43
2988  */
2989 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_SetTypographyTextEllipsisTest001, TestSize.Level1)
2990 {
2991     OH_Drawing_TypographyStyle* style = OH_Drawing_CreateTypographyStyle();
2992     ASSERT_NE(style, nullptr);
2993     const char* locale = "test";
2994     OH_Drawing_SetTypographyTextLocale(style, locale);
2995     OH_Drawing_SetTypographyTextSplitRatio(style, 0.f);
2996     OH_Drawing_TextStyle* textStyle = OH_Drawing_TypographyGetTextStyle(style);
2997     ASSERT_NE(textStyle, nullptr);
2998     ASSERT_EQ(OH_Drawing_TypographyGetEffectiveAlignment(style), 0);
2999     ASSERT_EQ(OH_Drawing_TypographyIsLineUnlimited(style), true);
3000     ASSERT_EQ(OH_Drawing_TypographyIsEllipsized(style), false);
3001     const char* ellipsis = "ellipsis";
3002     OH_Drawing_SetTypographyTextEllipsis(style, ellipsis);
3003 
3004     const char* ellipsisVal = nullptr;
3005     OH_Drawing_SetTypographyTextEllipsis(style, ellipsisVal);
3006 
3007     OH_Drawing_SetTypographyTextLocale(nullptr, locale);
3008     OH_Drawing_SetTypographyTextSplitRatio(nullptr, 0.f);
3009     OH_Drawing_TextStyle* textStyle1 = OH_Drawing_TypographyGetTextStyle(nullptr);
3010     ASSERT_EQ(textStyle1, nullptr);
3011     ASSERT_EQ(OH_Drawing_TypographyGetEffectiveAlignment(nullptr), 0);
3012     ASSERT_EQ(OH_Drawing_TypographyIsLineUnlimited(nullptr), false);
3013     ASSERT_EQ(OH_Drawing_TypographyIsEllipsized(nullptr), false);
3014     OH_Drawing_SetTypographyTextEllipsis(nullptr, ellipsisVal);
3015     OH_Drawing_DestroyTypographyStyle(style);
3016 }
3017 
3018 /*
3019  * @tc.name: OH_Drawing_TypographyHandlerPushTextStyle001
3020  * @tc.desc: test for the actual effective value of textstyle in each of the three scenarios.
3021  * @tc.type: FUNC
3022  * @tc.require: IALK43
3023  */
3024 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyHandlerPushTextStyle001, TestSize.Level1)
3025 {
3026     // Use interfaces such as OH_Drawing_SetTypographyTextFontSize to test the fallback textstyle.
3027     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
3028     OH_Drawing_SetTypographyTextFontSize(typoStyle, 100);
3029     OH_Drawing_SetTypographyTextFontHeight(typoStyle, 1);
3030     OH_Drawing_TextStyle* textStyle = OH_Drawing_TypographyGetTextStyle(typoStyle);
3031     ASSERT_NE(textStyle, nullptr);
3032     OH_Drawing_TypographyCreate* handler =
3033         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateSharedFontCollection());
3034     ASSERT_NE(handler, nullptr);
3035     const char* text = "test OH_Drawing_SetTypographyTextLineStylexxx";
3036     OH_Drawing_TypographyHandlerAddText(handler, text);
3037     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
3038     double maxWidth = 10000.0;
3039     OH_Drawing_TypographyLayout(typography, maxWidth);
3040     EXPECT_EQ(OH_Drawing_TypographyGetHeight(typography), 100);
3041 
3042     // After setting the default text style in typographstyle, the fallback text style becomes ineffective.
3043     OH_Drawing_TypographyStyle* typoStyle2 = OH_Drawing_CreateTypographyStyle();
3044     OH_Drawing_SetTypographyTextFontSize(typoStyle2, 500);
3045     OH_Drawing_SetTypographyTextFontHeight(typoStyle2, 1);
3046     OH_Drawing_TextStyle* textStyle2 = OH_Drawing_CreateTextStyle();
3047     OH_Drawing_SetTextStyleFontSize(textStyle2, 30);
3048     OH_Drawing_SetTextStyleFontHeight(textStyle2, 2);
3049     OH_Drawing_SetTypographyTextStyle(typoStyle2, textStyle2);
3050     OH_Drawing_TypographyCreate* handler2 =
3051         OH_Drawing_CreateTypographyHandler(typoStyle2, OH_Drawing_CreateSharedFontCollection());
3052     ASSERT_NE(handler2, nullptr);
3053     const char* text2 = "test OH_Drawing_OH_Drawing_SetTypographyTextStyle, 该方法优先";
3054     OH_Drawing_TypographyHandlerAddText(handler2, text2);
3055     OH_Drawing_Typography* typography2 = OH_Drawing_CreateTypography(handler2);
3056     OH_Drawing_TypographyLayout(typography2, maxWidth);
3057     EXPECT_EQ(OH_Drawing_TypographyGetHeight(typography2), 60);
3058 
3059     // After pushing a new text style, the default text style becomes ineffective.
3060     OH_Drawing_TypographyStyle* typoStyle3 = OH_Drawing_CreateTypographyStyle();
3061     OH_Drawing_SetTypographyTextFontSize(typoStyle3, 500);
3062     OH_Drawing_SetTypographyTextFontHeight(typoStyle3, 1);
3063     OH_Drawing_TextStyle* textStyle3 = OH_Drawing_CreateTextStyle();
3064     OH_Drawing_SetTextStyleFontSize(textStyle3, 30);
3065     OH_Drawing_SetTextStyleFontHeight(textStyle3, 2);
3066     OH_Drawing_SetTypographyTextStyle(typoStyle3, textStyle3);
3067     OH_Drawing_SetTextStyleFontSize(textStyle3, 80);
3068     OH_Drawing_SetTextStyleFontHeight(textStyle3, 3);
3069     OH_Drawing_TypographyCreate* handler3 =
3070         OH_Drawing_CreateTypographyHandler(typoStyle3, OH_Drawing_CreateSharedFontCollection());
3071     ASSERT_NE(handler3, nullptr);
3072     OH_Drawing_TypographyHandlerPushTextStyle(handler3, textStyle3);
3073     const char* text3 = "test OH_Drawing_TypographyHandlerPushTextStyle, 该方法优先";
3074     OH_Drawing_TypographyHandlerAddText(handler3, text3);
3075     OH_Drawing_Typography* typography3 = OH_Drawing_CreateTypography(handler3);
3076     OH_Drawing_TypographyLayout(typography3, maxWidth);
3077     EXPECT_EQ(OH_Drawing_TypographyGetHeight(typography3), 240);
3078 }
3079 
3080 /*
3081  * @tc.name: OH_Drawing_TypographyHandlerPushTextStyle002
3082  * @tc.desc: test the height of Tibetan and Uighur in push textstyle scenarios.
3083  * @tc.type: FUNC
3084  * @tc.require: IALK43
3085  */
3086 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyHandlerPushTextStyle002, TestSize.Level1)
3087 {
3088     // After pushing a new text style, the default text style becomes ineffective.
3089     OH_Drawing_TypographyStyle* typoStyle3 = OH_Drawing_CreateTypographyStyle();
3090     OH_Drawing_SetTypographyTextFontSize(typoStyle3, 500);
3091     OH_Drawing_SetTypographyTextFontHeight(typoStyle3, 1);
3092     OH_Drawing_TextStyle* textStyle3 = OH_Drawing_CreateTextStyle();
3093     OH_Drawing_SetTextStyleFontSize(textStyle3, 30);
3094     OH_Drawing_SetTextStyleFontHeight(textStyle3, 2);
3095     OH_Drawing_SetTypographyTextStyle(typoStyle3, textStyle3);
3096     OH_Drawing_SetTextStyleFontSize(textStyle3, 80);
3097     OH_Drawing_SetTextStyleFontHeight(textStyle3, 3);
3098 
3099     // Testing the line height of Uyghur text in 'heightonly' mode
3100     const char* text4 = "بۇ ئۇسۇل ئالدىنقى ئورۇندا";
3101     OH_Drawing_TypographyCreate* handler4 =
3102         OH_Drawing_CreateTypographyHandler(typoStyle3, OH_Drawing_CreateSharedFontCollection());
3103     ASSERT_NE(handler4, nullptr);
3104     OH_Drawing_TypographyHandlerPushTextStyle(handler4, textStyle3);
3105     OH_Drawing_TypographyHandlerAddText(handler4, text4);
3106     OH_Drawing_Typography* typography4 = OH_Drawing_CreateTypography(handler4);
3107     double maxWidth = 10000.0;
3108     OH_Drawing_TypographyLayout(typography4, maxWidth);
3109     EXPECT_NE(OH_Drawing_TypographyGetHeight(typography4), 240);
3110     EXPECT_EQ(OH_Drawing_TypographyGetHeight(typography4), 242);
3111 
3112     // Testing the line height of Tibetan text in 'heightonly' mode.
3113     const char* text5 = "ཐབས་ལམ་འདི་ལྡནཐབས་ལམ་འདི་ལྡན";
3114     OH_Drawing_TypographyCreate* handler5 =
3115         OH_Drawing_CreateTypographyHandler(typoStyle3, OH_Drawing_CreateSharedFontCollection());
3116     ASSERT_NE(handler4, nullptr);
3117     OH_Drawing_TypographyHandlerPushTextStyle(handler5, textStyle3);
3118     OH_Drawing_TypographyHandlerAddText(handler5, text5);
3119     OH_Drawing_Typography* typography5 = OH_Drawing_CreateTypography(handler5);
3120     OH_Drawing_TypographyLayout(typography5, maxWidth);
3121     EXPECT_NE(OH_Drawing_TypographyGetHeight(typography5), 240);
3122     EXPECT_EQ(OH_Drawing_TypographyGetHeight(typography5), 190);
3123 }
3124 
3125 /*
3126  * @tc.name: OH_Drawing_FontFamiliesTest001
3127  * @tc.desc: test for the OH_Drawing_TypographyTextlineStyleDestroyFontFamilies.
3128  * @tc.type: FUNC
3129  * @tc.require: IALK43
3130  */
3131 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_FontFamiliesTest001, TestSize.Level1)
3132 {
3133     char** fontFamilies = new char*[3]; // 3 means the number of font
3134     std::string tempStr1 = "Test1";
3135     std::string tempStr3 = "Test3";
3136     fontFamilies[0] = new char[tempStr1.size() + 1];
3137     std::copy(tempStr1.begin(), tempStr1.end(), fontFamilies[0]);
3138     fontFamilies[0][tempStr1.size()] = '\0';
3139     fontFamilies[1] = nullptr;
3140     fontFamilies[2] = new char[tempStr3.size() + 1]; // 2 means the index of font
3141     std::copy(tempStr3.begin(), tempStr3.end(), fontFamilies[2]); // 2 means the index of font
3142     fontFamilies[2][tempStr3.size()] = '\0'; // 2 means the index of font
3143     size_t num = 3; // 3 means the number of font
3144     ASSERT_NE(fontFamilies, nullptr);
3145     OH_Drawing_TypographyTextlineStyleDestroyFontFamilies(fontFamilies, num);
3146 
3147     fontFamilies = nullptr;
3148     OH_Drawing_TypographyTextlineStyleDestroyFontFamilies(fontFamilies, num);
3149 }
3150 
3151 /*
3152  * @tc.name: OH_Drawing_TypographyGetLineFontMetricsTest001
3153  * @tc.desc: test for the OH_Drawing_TypographyGetLineFontMetrics.
3154  * @tc.type: FUNC
3155  * @tc.require: IALK43
3156  */
3157 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyGetLineFontMetricsTest001, TestSize.Level1)
3158 {
3159     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
3160     OH_Drawing_TypographyCreate* handler =
3161         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
3162     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
3163     ASSERT_NE(typography, nullptr);
3164     size_t lineNumber = 1;
3165     size_t fontMetrics = 1;
3166     size_t* fontMetricsSize = &fontMetrics;
3167     ASSERT_NE(fontMetricsSize, nullptr);
3168     OH_Drawing_Font_Metrics* metrics = OH_Drawing_TypographyGetLineFontMetrics(typography, lineNumber, fontMetricsSize);
3169     ASSERT_EQ(metrics, nullptr);
3170 
3171     OH_Drawing_Font_Metrics* metrics1 = OH_Drawing_TypographyGetLineFontMetrics(typography, 0, fontMetricsSize);
3172     ASSERT_EQ(metrics1, nullptr);
3173     OH_Drawing_Font_Metrics* metrics2 = OH_Drawing_TypographyGetLineFontMetrics(typography, lineNumber, nullptr);
3174     ASSERT_EQ(metrics2, nullptr);
3175     OH_Drawing_Font_Metrics* metrics3 = OH_Drawing_TypographyGetLineFontMetrics(nullptr, lineNumber, fontMetricsSize);
3176     ASSERT_EQ(metrics3, nullptr);
3177     OH_Drawing_TypographyDestroyLineFontMetrics(metrics);
3178     OH_Drawing_DestroyTypographyStyle(typoStyle);
3179     OH_Drawing_DestroyTypographyHandler(handler);
3180     OH_Drawing_DestroyTypography(typography);
3181 }
3182 
3183 /*
3184  * @tc.name: OH_Drawing_TextStyleAddFontVariationTest001
3185  * @tc.desc: test for the OH_Drawing_TextStyleAddFontVariation.
3186  * @tc.type: FUNC
3187  * @tc.require: IALK43
3188  */
3189 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TextStyleAddFontVariationTest001, TestSize.Level1)
3190 {
3191     OH_Drawing_TypographyStyle* style = OH_Drawing_CreateTypographyStyle();
3192     ASSERT_NE(style, nullptr);
3193     OH_Drawing_TextStyle* textStyle = OH_Drawing_TypographyGetTextStyle(style);
3194     ASSERT_NE(textStyle, nullptr);
3195     const char* axis = "T";
3196     const float value = 1.f;
3197     OH_Drawing_TextStyleAddFontVariation(textStyle, axis, value);
3198     OH_Drawing_TextStyleAddFontVariation(textStyle, nullptr, value);
3199     OH_Drawing_TextStyleAddFontVariation(nullptr, axis, value);
3200     OH_Drawing_DestroyTypographyStyle(style);
3201 }
3202 
3203 /*
3204 * @tc.name: OH_Drawing_TypographyGetLineTextRangeTest001
3205 * @tc.desc: test for typography mutiple lines,but set Set end line spaces and ellipsis
3206 * @tc.type: FUNC
3207 */
3208 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyGetLineTextRangeTest001, TestSize.Level1)
3209 {
3210     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
3211     OH_Drawing_TextStyle *txtStyle = OH_Drawing_CreateTextStyle();
3212     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x11, 0x11, 0xFF));
3213     OH_Drawing_SetTextStyleFontSize(txtStyle, 50);
3214     OH_Drawing_SetTypographyTextMaxLines(typoStyle, 4);
3215     OH_Drawing_TypographyCreate* handler =
3216         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
3217     const char *elipss = "...";
3218     OH_Drawing_SetTypographyTextEllipsis(typoStyle, elipss);
3219     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, 2);
3220     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
3221     const char *text = "这是一个排版信息دددھساسااساساس获取接口的测试文本:Hello World     \n是版信息获取接测试文本Drawing.";
3222     OH_Drawing_TypographyHandlerAddText(handler, text);
3223     text = "这是一个排版信息བསདབད获取接口的སངབངསབ测试文lo World这是一个 ..... \u1234排版信息的测试文སསསས本Drawing.དདདདདད.       ";
3224     OH_Drawing_TypographyHandlerAddText(handler, text);
3225     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
3226     OH_Drawing_TypographyLayout(typography, MAX_WIDTH);
3227     double longestLine = OH_Drawing_TypographyGetLongestLine(typography);
3228     double lineCount = OH_Drawing_TypographyGetLineCount(typography);
3229     double maxLineWidth = 0.0;
3230     for (int i = 0; i < lineCount; i++) {
3231         double lineWidth = OH_Drawing_TypographyGetLineWidth(typography, i);
3232         maxLineWidth = std::max(maxLineWidth, lineWidth);
3233     }
3234     OH_Drawing_Range *range1 = OH_Drawing_TypographyGetLineTextRange(typography, 1, false);
3235     EXPECT_EQ(55, OH_Drawing_GetStartFromRange(range1));
3236     EXPECT_EQ(93, OH_Drawing_GetEndFromRange(range1));
3237     OH_Drawing_Range *range2 = OH_Drawing_TypographyGetLineTextRange(typography, 1, true);
3238     EXPECT_EQ(55, OH_Drawing_GetStartFromRange(range2));
3239     EXPECT_EQ(98, OH_Drawing_GetEndFromRange(range2));
3240     EXPECT_NEAR(longestLine, maxLineWidth, FLOAT_DATA_EPSILON);
3241     OH_Drawing_PositionAndAffinity* posAAClusrterDown =
3242         OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster(typography, 80, 0);
3243     int affinityClusterDown = OH_Drawing_GetAffinityFromPositionAndAffinity(posAAClusrterDown);
3244     int aPositionClusterDown = OH_Drawing_GetPositionFromPositionAndAffinity(posAAClusrterDown);
3245     EXPECT_EQ(0, affinityClusterDown);
3246     EXPECT_EQ(2, aPositionClusterDown);
3247     OH_Drawing_PositionAndAffinity* posAAClusrterUp =
3248         OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster(typography, 100, 100);
3249     int affinityClusterUp = OH_Drawing_GetAffinityFromPositionAndAffinity(posAAClusrterUp);
3250     int aPositionClusterUp = OH_Drawing_GetPositionFromPositionAndAffinity(posAAClusrterUp);
3251     EXPECT_EQ(1, affinityClusterUp);
3252     EXPECT_EQ(25, aPositionClusterUp);
3253     OH_Drawing_DestroyTypography(typography);
3254     OH_Drawing_DestroyTypographyStyle(typoStyle);
3255     OH_Drawing_DestroyTypographyHandler(handler);
3256     OH_Drawing_DestroyTextStyle(txtStyle);
3257 }
3258 
3259 /*
3260 * @tc.name: OH_Drawing_TypographyGetLineTextRangeTest002
3261 * @tc.desc: test for typography mutiple lines,but set Set end line spaces and ellipsis
3262 * @tc.type: FUNC
3263 */
3264 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyGetLineTextRangeTest002, TestSize.Level1)
3265 {
3266     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
3267     OH_Drawing_TextStyle *txtStyle = OH_Drawing_CreateTextStyle();
3268     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x11, 0x11, 0xFF));
3269     OH_Drawing_SetTextStyleFontSize(txtStyle, 50);
3270     OH_Drawing_SetTypographyTextMaxLines(typoStyle, 4);
3271     OH_Drawing_TypographyCreate* handler =
3272         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
3273     const char *elipss = "...";
3274     OH_Drawing_SetTypographyTextEllipsis(typoStyle, elipss);
3275     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, 2);
3276     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
3277     const char *text = "这是一个排版信息دددھساسااساساس获取接口的测试文本:Hello World     \n是版信息获取接测试文本Drawing.";
3278     OH_Drawing_TypographyHandlerAddText(handler, text);
3279     text = "这是一个排版信息བསདབད获取接口的སངབངསབ测试文lo World这是一个 ..... \u1234排版信息的测试文སསསས本Drawing.དདདདདད.       ";
3280     OH_Drawing_TypographyHandlerAddText(handler, text);
3281 
3282     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
3283     OH_Drawing_Range *range1 = OH_Drawing_TypographyGetLineTextRange(typography, 0, false);
3284     EXPECT_EQ(0, OH_Drawing_GetStartFromRange(range1));
3285     EXPECT_EQ(0, OH_Drawing_GetEndFromRange(range1));
3286     OH_Drawing_TypographyLayout(typography, MAX_WIDTH);
3287 
3288     double lineCount = OH_Drawing_TypographyGetLineCount(typography);
3289     OH_Drawing_Range *range2 = OH_Drawing_TypographyGetLineTextRange(typography, lineCount, false);
3290     EXPECT_EQ(0, OH_Drawing_GetStartFromRange(range2));
3291     EXPECT_EQ(0, OH_Drawing_GetEndFromRange(range2));
3292     OH_Drawing_DestroyTypography(typography);
3293     OH_Drawing_DestroyTypographyStyle(typoStyle);
3294     OH_Drawing_DestroyTypographyHandler(handler);
3295     OH_Drawing_DestroyTextStyle(txtStyle);
3296 }
3297 } // namespace OHOS