• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "test_common.h"
16 
17 namespace OHOS {
18 namespace Security {
19 namespace SecurityComponent {
BuildLocationComponentInfo(nlohmann::json & jsonComponent)20 void TestCommon::BuildLocationComponentInfo(nlohmann::json& jsonComponent)
21 {
22     jsonComponent[JsonTagConstants::JSON_SC_TYPE] = LOCATION_COMPONENT;
23     jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
24         {JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE },
25         {JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE },
26         {JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE },
27         {JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE }
28     };
29     jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0;
30     jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
31         {JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE },
32         {JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE },
33         {JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE },
34         {JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE }
35     };
36     nlohmann::json jsonPadding = nlohmann::json {
37         { JsonTagConstants::JSON_PADDING_TOP_TAG, TestCommon::TEST_DIMENSION },
38         { JsonTagConstants::JSON_PADDING_RIGHT_TAG, TestCommon::TEST_DIMENSION },
39         { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TestCommon::TEST_DIMENSION },
40         { JsonTagConstants::JSON_PADDING_LEFT_TAG, TestCommon::TEST_DIMENSION },
41     };
42 
43     jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
44         { JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
45         { JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
46         { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::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, TestCommon::TEST_COLOR_RED },
52         { JsonTagConstants::JSON_ICON_COLOR_TAG, TestCommon::TEST_COLOR_BLUE },
53         { JsonTagConstants::JSON_BG_COLOR_TAG, TestCommon::TEST_COLOR_YELLOW }
54     };
55 
56     jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
57         { JsonTagConstants::JSON_BORDER_WIDTH_TAG, TestCommon::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 }
68 
BuildSaveComponentInfo(nlohmann::json & jsonComponent)69 void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent)
70 {
71     jsonComponent[JsonTagConstants::JSON_SC_TYPE] = SAVE_COMPONENT;
72     jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0;
73     jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
74         {JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE },
75         {JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE },
76         {JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE },
77         {JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE }
78     };
79     jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
80         {JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE },
81         {JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE },
82         {JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE },
83         {JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE }
84     };
85     nlohmann::json jsonPadding = nlohmann::json {
86         { JsonTagConstants::JSON_PADDING_TOP_TAG, TestCommon::TEST_DIMENSION },
87         { JsonTagConstants::JSON_PADDING_RIGHT_TAG, TestCommon::TEST_DIMENSION },
88         { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TestCommon::TEST_DIMENSION },
89         { JsonTagConstants::JSON_PADDING_LEFT_TAG, TestCommon::TEST_DIMENSION },
90     };
91 
92     jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
93         { JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
94         { JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
95         { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::TEST_SIZE },
96         { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
97     };
98 
99     jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
100         { JsonTagConstants::JSON_FONT_COLOR_TAG, TestCommon::TEST_COLOR_RED },
101         { JsonTagConstants::JSON_ICON_COLOR_TAG, TestCommon::TEST_COLOR_BLUE },
102         { JsonTagConstants::JSON_BG_COLOR_TAG, TestCommon::TEST_COLOR_YELLOW }
103     };
104 
105     jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
106         { JsonTagConstants::JSON_BORDER_WIDTH_TAG, TestCommon::TEST_SIZE },
107     };
108     jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json {
109         { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false },
110     };
111     jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
112         { JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD },
113         { JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON },
114         { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
115     };
116 }
117 
BuildPasteComponentInfo(nlohmann::json & jsonComponent)118 void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent)
119 {
120     jsonComponent[JsonTagConstants::JSON_SC_TYPE] = PASTE_COMPONENT;
121     jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0;
122     jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
123         {JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE },
124         {JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE },
125         {JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE },
126         {JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE }
127     };
128     jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
129         {JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE },
130         {JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE },
131         {JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE },
132         {JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE }
133     };
134     nlohmann::json jsonPadding = nlohmann::json {
135         { JsonTagConstants::JSON_PADDING_TOP_TAG, TestCommon::TEST_DIMENSION },
136         { JsonTagConstants::JSON_PADDING_RIGHT_TAG, TestCommon::TEST_DIMENSION },
137         { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TestCommon::TEST_DIMENSION },
138         { JsonTagConstants::JSON_PADDING_LEFT_TAG, TestCommon::TEST_DIMENSION },
139     };
140 
141     jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
142         { JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
143         { JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
144         { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::TEST_SIZE },
145         { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
146     };
147 
148     jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
149         { JsonTagConstants::JSON_FONT_COLOR_TAG, TestCommon::TEST_COLOR_RED },
150         { JsonTagConstants::JSON_ICON_COLOR_TAG, TestCommon::TEST_COLOR_BLUE },
151         { JsonTagConstants::JSON_BG_COLOR_TAG, TestCommon::TEST_COLOR_YELLOW }
152     };
153 
154     jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
155         { JsonTagConstants::JSON_BORDER_WIDTH_TAG, TestCommon::TEST_SIZE },
156     };
157     jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json {
158         { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false },
159     };
160     jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
161         { JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE },
162         { JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON },
163         { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
164     };
165 }
166 }  // namespace SecurityComponent
167 }  // namespace Security
168 }  // namespace OHOS
169