• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "common/common.h"
17 
18 namespace ArkUICapiTest {
19 
TestTextLetterSpacing001(napi_env env,napi_callback_info info)20 static napi_value TestTextLetterSpacing001(napi_env env, napi_callback_info info)
21 {
22     NAPI_START(text, ARKUI_NODE_TEXT);
23     float letterSpacingValue = 50;
24     ArkUI_NumberValue value[] = {{.f32 = letterSpacingValue}};
25     ArkUI_AttributeItem valueItem = {value, sizeof(value) / sizeof(ArkUI_NumberValue)};
26     auto ret = nodeAPI->setAttribute(text, NODE_TEXT_LETTER_SPACING, &valueItem);
27     ASSERT_EQ(ret, SUCCESS);
28     ASSERT_EQ(nodeAPI->getAttribute(text, NODE_TEXT_LETTER_SPACING)->value[PARAM_0].f32, letterSpacingValue);
29     NAPI_END;
30 }
31 
TestTextLetterSpacing002(napi_env env,napi_callback_info info)32 static napi_value TestTextLetterSpacing002(napi_env env, napi_callback_info info)
33 {
34     NAPI_START(text, ARKUI_NODE_TEXT);
35     float largeValue = 1000;
36     ArkUI_NumberValue value[] = {{.f32 = largeValue}};
37     ArkUI_AttributeItem valueItem = {value, sizeof(value) / sizeof(ArkUI_NumberValue)};
38     auto ret = nodeAPI->setAttribute(text, NODE_TEXT_LETTER_SPACING, &valueItem);
39     ASSERT_EQ(ret, SUCCESS);
40     ASSERT_EQ(nodeAPI->getAttribute(text, NODE_TEXT_LETTER_SPACING)->value[PARAM_0].f32, largeValue);
41     NAPI_END;
42 }
43 
TestTextLetterSpacing003(napi_env env,napi_callback_info info)44 static napi_value TestTextLetterSpacing003(napi_env env, napi_callback_info info)
45 {
46     NAPI_START(text, ARKUI_NODE_TEXT);
47     float exceptionValue = -100;
48     ArkUI_NumberValue value[] = {{.f32 = exceptionValue}};
49     ArkUI_AttributeItem valueItem = {value, sizeof(value) / sizeof(ArkUI_NumberValue)};
50     auto ret = nodeAPI->setAttribute(text, NODE_TEXT_LETTER_SPACING, &valueItem);
51     ASSERT_EQ(ret, SUCCESS);
52     ASSERT_EQ(nodeAPI->getAttribute(text, NODE_TEXT_LETTER_SPACING)->value[PARAM_0].f32, exceptionValue);
53     NAPI_END;
54 }
55 
56 } // namespace ArkUICapiTest
57