1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "service_test_common.h"
16
17 namespace OHOS {
18 namespace Security {
19 namespace SecurityComponent {
BuildLocationComponentJson(nlohmann::json & jsonComponent)20 void ServiceTestCommon::BuildLocationComponentJson(nlohmann::json& jsonComponent)
21 {
22 jsonComponent[JsonTagConstants::JSON_SC_TYPE] = LOCATION_COMPONENT;
23 jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0;
24 jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
25 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
26 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
27 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
28 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
29 };
30 jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
31 { JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
32 { JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
33 { JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
34 { JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
35 };
36 nlohmann::json jsonPadding = nlohmann::json {
37 { JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
38 { JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
39 { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
40 { JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
41 };
42
43 jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
44 { JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
45 { JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
46 { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
47 { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
48 };
49
50 jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
51 { JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
52 { JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_BLUE },
53 { JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
54 };
55
56 jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
57 { JsonTagConstants::JSON_BORDER_WIDTH_TAG, ServiceTestCommon::TEST_SIZE },
58 };
59 jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json {
60 { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false },
61 { JsonTagConstants::JSON_IS_CLIPPED_TAG, false },
62 { JsonTagConstants::JSON_TOP_CLIP_TAG, 0.0 },
63 { JsonTagConstants::JSON_BOTTOM_CLIP_TAG, 0.0 },
64 { JsonTagConstants::JSON_LEFT_CLIP_TAG, 0.0 },
65 { JsonTagConstants::JSON_RIGHT_CLIP_TAG, 0.0 },
66 { JsonTagConstants::JSON_PARENT_TAG_TAG, "" },
67 };
68 jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
69 { JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
70 { JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
71 { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
72 };
73 jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0;
74 jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0;
75 jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0;
76 }
77
BuildSaveComponentJson(nlohmann::json & jsonComponent)78 void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent)
79 {
80 jsonComponent[JsonTagConstants::JSON_SC_TYPE] = SAVE_COMPONENT;
81 jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0;
82 jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
83 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
84 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
85 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
86 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
87 };
88 jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
89 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
90 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
91 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
92 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
93 };
94 nlohmann::json jsonPadding = nlohmann::json {
95 { JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
96 { JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
97 { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
98 { JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
99 };
100
101 jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
102 { JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
103 { JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
104 { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
105 { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
106 };
107
108 jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
109 { JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
110 { JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_BLUE },
111 { JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
112 };
113
114 jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
115 { JsonTagConstants::JSON_BORDER_WIDTH_TAG, ServiceTestCommon::TEST_SIZE },
116 };
117 jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json {
118 { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false },
119 { JsonTagConstants::JSON_IS_CLIPPED_TAG, false },
120 { JsonTagConstants::JSON_TOP_CLIP_TAG, 0.0 },
121 { JsonTagConstants::JSON_BOTTOM_CLIP_TAG, 0.0 },
122 { JsonTagConstants::JSON_LEFT_CLIP_TAG, 0.0 },
123 { JsonTagConstants::JSON_RIGHT_CLIP_TAG, 0.0 },
124 { JsonTagConstants::JSON_PARENT_TAG_TAG, "" },
125 };
126 jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
127 { JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD },
128 { JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON },
129 { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
130 };
131 jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0;
132 jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0;
133 jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0;
134 }
135
BuildPasteComponentJson(nlohmann::json & jsonComponent)136 void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent)
137 {
138 jsonComponent[JsonTagConstants::JSON_SC_TYPE] = PASTE_COMPONENT;
139 jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0;
140 jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
141 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
142 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
143 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
144 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
145 };
146 jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
147 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
148 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
149 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
150 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
151 };
152 nlohmann::json jsonPadding = nlohmann::json {
153 { JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
154 { JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
155 { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
156 { JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
157 };
158
159 jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
160 { JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
161 { JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
162 { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
163 { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
164 };
165
166 jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
167 { JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
168 { JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_BLUE },
169 { JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
170 };
171
172 jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
173 { JsonTagConstants::JSON_BORDER_WIDTH_TAG, ServiceTestCommon::TEST_SIZE },
174 };
175 jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json {
176 { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false },
177 { JsonTagConstants::JSON_IS_CLIPPED_TAG, false },
178 { JsonTagConstants::JSON_TOP_CLIP_TAG, 0.0 },
179 { JsonTagConstants::JSON_BOTTOM_CLIP_TAG, 0.0 },
180 { JsonTagConstants::JSON_LEFT_CLIP_TAG, 0.0 },
181 { JsonTagConstants::JSON_RIGHT_CLIP_TAG, 0.0 },
182 { JsonTagConstants::JSON_PARENT_TAG_TAG, "" },
183 };
184 jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
185 { JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE },
186 { JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON },
187 { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
188 };
189 jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0;
190 jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0;
191 jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0;
192 }
193 } // namespace SecurityComponent
194 } // namespace Security
195 } // namespace OHOS
196