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 };
62 jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
63 { JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
64 { JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
65 { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
66 };
67 jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0;
68 }
69
BuildSaveComponentJson(nlohmann::json & jsonComponent)70 void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent)
71 {
72 jsonComponent[JsonTagConstants::JSON_SC_TYPE] = SAVE_COMPONENT;
73 jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0;
74 jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
75 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
76 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
77 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
78 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
79 };
80 jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
81 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
82 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
83 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
84 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
85 };
86 nlohmann::json jsonPadding = nlohmann::json {
87 { JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
88 { JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
89 { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
90 { JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
91 };
92
93 jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
94 { JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
95 { JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
96 { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
97 { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
98 };
99
100 jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
101 { JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
102 { JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_BLUE },
103 { JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
104 };
105
106 jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
107 { JsonTagConstants::JSON_BORDER_WIDTH_TAG, ServiceTestCommon::TEST_SIZE },
108 };
109 jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json {
110 { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false },
111 };
112 jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
113 { JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD },
114 { JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON },
115 { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
116 };
117 jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0;
118 }
119
BuildPasteComponentJson(nlohmann::json & jsonComponent)120 void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent)
121 {
122 jsonComponent[JsonTagConstants::JSON_SC_TYPE] = PASTE_COMPONENT;
123 jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0;
124 jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
125 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
126 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
127 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
128 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
129 };
130 jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
131 {JsonTagConstants::JSON_RECT_X, ServiceTestCommon::TEST_COORDINATE },
132 {JsonTagConstants::JSON_RECT_Y, ServiceTestCommon::TEST_COORDINATE },
133 {JsonTagConstants::JSON_RECT_WIDTH, ServiceTestCommon::TEST_COORDINATE },
134 {JsonTagConstants::JSON_RECT_HEIGHT, ServiceTestCommon::TEST_COORDINATE }
135 };
136 nlohmann::json jsonPadding = nlohmann::json {
137 { JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
138 { JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
139 { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
140 { JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
141 };
142
143 jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
144 { JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
145 { JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
146 { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
147 { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
148 };
149
150 jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
151 { JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
152 { JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_BLUE },
153 { JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
154 };
155
156 jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
157 { JsonTagConstants::JSON_BORDER_WIDTH_TAG, ServiceTestCommon::TEST_SIZE },
158 };
159 jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json {
160 { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false },
161 };
162 jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
163 { JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE },
164 { JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON },
165 { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
166 };
167 jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0;
168 }
169 } // namespace SecurityComponent
170 } // namespace Security
171 } // namespace OHOS
172