• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #ifndef FRONTEND_API_DEFINES_H
17 #define FRONTEND_API_DEFINES_H
18 
19 #include <initializer_list>
20 #include <string_view>
21 #include <map>
22 #include "nlohmann/json.hpp"
23 
24 namespace OHOS::uitest {
25     enum ErrCode : uint32_t {
26         /**Old ErrorCode*/
27         NO_ERROR = 0,
28         /**Internal error, not expected to happen.*/
29         INTERNAL_ERROR = 1,
30         /**Widget that is expected to be exist lost.*/
31         WIDGET_LOST = 2,
32         /**Window that is expected to be exist lost.*/
33         WINDOW_LOST = 3,
34         /**The user assertion failure.*/
35         ASSERTION_FAILURE = 4,
36         USAGE_ERROR = 5,
37         /**New ErrorCode*/
38         /**Initialize failed.*/
39         ERR_INITIALIZE_FAILED = 17000001,
40         /**API does not allow calling concurrently.*/
41         ERR_API_USAGE = 17000002,
42         /**Component existence assertion failed.*/
43         ERR_ASSERTION_FAILED = 17000003,
44         /**Component lost/UiWindow lost.*/
45         ERR_COMPONENT_LOST = 17000004,
46         /**This operation is not supported.*/
47         ERR_OPERATION_UNSUPPORTED = 17000005,
48         /**Internal error.*/
49         ERR_INTERNAL = 17000006,
50         /**Invalid input parameter.*/
51         ERR_INVALID_INPUT = 401,
52         /**The specified SystemCapability name was not found.*/
53         ERR_NO_SYSTEM_CAPABILITY = 801,
54     };
55 
56     const std::map<ErrCode, std::string> ErrDescMap = {
57         /**Correspondence between error codes and descriptions*/
58         {NO_ERROR, "No Error"},
59         {ERR_INITIALIZE_FAILED, "Initialization failed."},
60         {ERR_API_USAGE, "The async function is not called with await."},
61         {ERR_ASSERTION_FAILED, "Assertion failed."},
62         {ERR_COMPONENT_LOST, "The window or component is invisible or destroyed."},
63         {ERR_OPERATION_UNSUPPORTED, "This operation is not supported."},
64         {ERR_INTERNAL, "Internal error."},
65         {ERR_NO_SYSTEM_CAPABILITY, "The specified SystemCapability name was not found."},
66         {ERR_INVALID_INPUT, "Invalid input parameter."},
67     };
68 
69     /**API invocation error detail wrapper.*/
70     struct ApiCallErr {
71     public:
72         ErrCode code_;
73         std::string message_ = "";
74 
75         ApiCallErr() = delete;
76 
ApiCallErrApiCallErr77         explicit ApiCallErr(ErrCode ec)
78         {
79             code_ = ec;
80             message_ = ErrDescMap.find(ec)->second;
81         }
82 
ApiCallErrApiCallErr83         ApiCallErr(ErrCode ec, std::string_view msg)
84         {
85             code_ = ec;
86             message_ = std::string(msg);
87         }
88     };
89 
90     /**Structure wraps the api-call data.*/
91     struct ApiCallInfo {
92         std::string apiId_;
93         std::string callerObjRef_;
94         nlohmann::json paramList_ = nlohmann::json::array();
95         int32_t fdParamIndex_ = -1; // support fd as param
96     };
97 
98     /**Structure wraps the api-call reply.*/
99     struct ApiReplyInfo {
100         nlohmann::json resultValue_ = nullptr;
101         ApiCallErr exception_ = ApiCallErr(NO_ERROR);
102     };
103 
104     /** Specifications of a frontend enumerator value.*/
105     struct FrontendEnumValueDef {
106         std::string_view name_;
107         std::string_view valueJson_;
108     };
109 
110     /** Specifications of a frontend enumerator.*/
111     struct FrontendEnumeratorDef {
112         std::string_view name_;
113         const FrontendEnumValueDef *values_;
114         size_t valueCount_;
115     };
116 
117     /** Specifications of a frontend json data property.*/
118     struct FrontEndJsonPropDef {
119         std::string_view name_;
120         std::string_view type_;
121         bool required_;
122     };
123     /** Specifications of a frontend json object.*/
124     struct FrontEndJsonDef {
125         std::string_view name_;
126         const FrontEndJsonPropDef *props_;
127         size_t propCount_;
128     };
129 
130     /** Specifications of a frontend class method.*/
131     struct FrontendMethodDef {
132         std::string_view name_;
133         std::string_view signature_;
134         bool static_;
135         bool fast_;
136     };
137 
138     /** Specifications of a frontend class.*/
139     struct FrontEndClassDef {
140         std::string_view name_;
141         const FrontendMethodDef *methods_;
142         size_t methodCount_;
143         bool bindUiDriver_;
144     };
145 
146     /** MatchPattern enumerator definition.*/
147     constexpr FrontendEnumValueDef PATTERN_VALUES[] = {
148         {"EQUALS", "0"},
149         {"CONTAINS", "1"},
150         {"STARTS_WITH", "2"},
151         {"ENDS_WITH", "3"},
152         {"REG_EXP", "4"},
153         {"REG_EXP_ICASE", "5"},
154     };
155     constexpr FrontendEnumeratorDef MATCH_PATTERN_DEF = {
156         "MatchPattern",
157         PATTERN_VALUES,
158         sizeof(PATTERN_VALUES) / sizeof(FrontendEnumValueDef),
159     };
160 
161     /** Window ResizeDirection enumerator definition.*/
162     constexpr FrontendEnumValueDef RESIZE_DIRECTION_VALUES[] = {
163         {"LEFT", "0"},    {"RIGHT", "1"},     {"UP", "2"},       {"DOWN", "3"},
164         {"LEFT_UP", "4"}, {"LEFT_DOWN", "5"}, {"RIGHT_UP", "6"}, {"RIGHT_DOWN", "7"},
165     };
166     constexpr FrontendEnumeratorDef RESIZE_DIRECTION_DEF = {
167         "ResizeDirection",
168         RESIZE_DIRECTION_VALUES,
169         sizeof(RESIZE_DIRECTION_VALUES) / sizeof(FrontendEnumValueDef),
170     };
171 
172     /** WindowMode enumerator definition.*/
173     constexpr FrontendEnumValueDef WINDOW_MODE_VALUES[] = {
174         {"FULLSCREEN", "0"},
175         {"PRIMARY", "1"},
176         {"SECONDARY", "2"},
177         {"FLOATING", "3"},
178     };
179     constexpr FrontendEnumeratorDef WINDOW_MODE_DEF = {
180         "WindowMode",
181         WINDOW_MODE_VALUES,
182         sizeof(WINDOW_MODE_VALUES) / sizeof(FrontendEnumValueDef),
183     };
184 
185     /** Describes the rotation of the device display.*/
186     constexpr FrontendEnumValueDef DISPLAY_ROTATION_VALUES[] = {
187         {"ROTATION_0", "0"},
188         {"ROTATION_90", "1"},
189         {"ROTATION_180", "2"},
190         {"ROTATION_270", "3"},
191     };
192     constexpr FrontendEnumeratorDef DISPLAY_ROTATION_DEF = {
193         "DisplayRotation",
194         DISPLAY_ROTATION_VALUES,
195         sizeof(DISPLAY_ROTATION_VALUES) / sizeof(FrontendEnumValueDef),
196     };
197 
198     /** Describes the Button of the mouse.*/
199     constexpr FrontendEnumValueDef MOUSE_BUTTON_VALUES[] = {
200         {"MOUSE_BUTTON_LEFT", "0"},
201         {"MOUSE_BUTTON_RIGHT", "1"},
202         {"MOUSE_BUTTON_MIDDLE", "2"},
203     };
204     constexpr FrontendEnumeratorDef MOUSE_BUTTON_DEF = {
205         "MouseButton",
206         MOUSE_BUTTON_VALUES,
207         sizeof(MOUSE_BUTTON_VALUES) / sizeof(FrontendEnumValueDef),
208     };
209 
210     /** Describes the direction of the UI operation.*/
211     constexpr FrontendEnumValueDef UI_DIRECTION_VALUES[] = {
212         {"LEFT", "0"},
213         {"RIGHT", "1"},
214         {"UP", "2"},
215         {"DOWN", "3"},
216     };
217     constexpr FrontendEnumeratorDef UI_DIRECTION_DEF = {
218         "UiDirection",
219         UI_DIRECTION_VALUES,
220         sizeof(UI_DIRECTION_VALUES) / sizeof(FrontendEnumValueDef),
221     };
222 
223     /** Rect jsonObject definition.*/
224     constexpr FrontEndJsonPropDef RECT_PROPERTIES[] = {
225         {"left", "int", true},
226         {"top", "int", true},
227         {"right", "int", true},
228         {"bottom", "int", true},
229         {"displayId", "int", false},
230     };
231     constexpr FrontEndJsonDef RECT_DEF = {
232         "Rect",
233         RECT_PROPERTIES,
234         sizeof(RECT_PROPERTIES) / sizeof(FrontEndJsonPropDef),
235     };
236 
237     /** Point jsonObject definition.*/
238     constexpr FrontEndJsonPropDef POINT_PROPERTIES[] = {
239         {"x", "int", true},
240         {"y", "int", true},
241         {"displayId", "int", false},
242     };
243     constexpr FrontEndJsonDef POINT_DEF = {
244         "Point",
245         POINT_PROPERTIES,
246         sizeof(POINT_PROPERTIES) / sizeof(FrontEndJsonPropDef),
247     };
248 
249     /** WindowFilter jsonObject definition.*/
250     constexpr FrontEndJsonPropDef WINDOW_FILTER_PROPERTIES[] = {
251         {"bundleName", "string", false},
252         {"title", "string", false},
253         {"focused", "bool", false},
254         {"actived", "bool", false}, // Deprecated from API 11
255         {"active", "bool", false},
256         {"displayId", "int", false},
257     };
258     constexpr FrontEndJsonDef WINDOW_FILTER_DEF = {
259         "WindowFilter",
260         WINDOW_FILTER_PROPERTIES,
261         sizeof(WINDOW_FILTER_PROPERTIES) / sizeof(FrontEndJsonPropDef),
262     };
263 
264     /** UIElementInfo jsonObject definition.*/
265     constexpr FrontEndJsonPropDef UI_ELEMENT_INFO_PROPERTIES[] = {
266         {"bundleName", "string", false},
267         {"text", "string", false},
268         {"type", "string", false},
269     };
270     constexpr FrontEndJsonDef UI_ELEMENT_INFO_DEF = {
271         "UIElementInfo",
272         UI_ELEMENT_INFO_PROPERTIES,
273         sizeof(UI_ELEMENT_INFO_PROPERTIES) / sizeof(FrontEndJsonPropDef),
274     };
275 
276     /** TouchPadSwipeOptions definition.*/
277     constexpr FrontEndJsonPropDef TOUCH_PAD_SWIPE_OPTIONS[] = {
278         {"stay", "bool", false},
279         {"speed", "int", false},
280     };
281     constexpr FrontEndJsonDef TOUCH_PAD_SWIPE_OPTIONS_DEF = {
282         "TouchPadSwipeOptions",
283         TOUCH_PAD_SWIPE_OPTIONS,
284         sizeof(TOUCH_PAD_SWIPE_OPTIONS) / sizeof(FrontEndJsonPropDef),
285     };
286 
287     /** By class definition. deprecated since api 9*/
288     constexpr FrontendMethodDef BY_METHODS[] = {
289         {"By.id", "(int):By", false, true},
290         {"By.text", "(string,int?):By", false, true}, //  MatchPattern enum as int value
291         {"By.key", "(string):By", false, true},
292         {"By.type", "(string):By", false, true},
293         {"By.enabled", "(bool?):By", false, true}, // default bool arg: true
294         {"By.focused", "(bool?):By", false, true},
295         {"By.selected", "(bool?):By", false, true},
296         {"By.clickable", "(bool?):By", false, true},
297         {"By.scrollable", "(bool?):By", false, true},
298         {"By.isBefore", "(By):By", false, true},
299         {"By.isAfter", "(By):By", false, true},
300     };
301     constexpr std::string_view REF_SEED_BY = "On#seed";
302     constexpr FrontEndClassDef BY_DEF = {
303         "By",
304         BY_METHODS,
305         sizeof(BY_METHODS) / sizeof(FrontendMethodDef),
306     };
307 
308     /** UiDriver class definition.*/
309     constexpr FrontendMethodDef UI_DRIVER_METHODS[] = {
310         {"UiDriver.create", "():UiDriver", true, true},
311         {"UiDriver.delayMs", "(int):void", false, false},
312         {"UiDriver.findComponent", "(By):UiComponent", false, false},
313         {"UiDriver.findComponents", "(By):[UiComponent]", false, false},
314         {"UiDriver.screenCap", "(int):bool", false, false}, // fliePath as fileDescription.
315         {"UiDriver.assertComponentExist", "(By):void", false, false},
316         {"UiDriver.pressBack", "():void", false, false},
317         {"UiDriver.triggerKey", "(int):void", false, false},
318         {"UiDriver.swipe", "(int,int,int,int,int?):void", false, false},
319         {"UiDriver.click", "(int,int):void", false, false},
320         {"UiDriver.longClick", "(int,int):void", false, false},
321         {"UiDriver.doubleClick", "(int,int):void", false, false},
322     };
323     constexpr FrontEndClassDef UI_DRIVER_DEF = {
324         "UiDriver",
325         UI_DRIVER_METHODS,
326         sizeof(UI_DRIVER_METHODS) / sizeof(FrontendMethodDef),
327     };
328 
329     /** UiComponent class definition.*/
330     constexpr FrontendMethodDef UI_COMPONENT_METHODS[] = {
331         {"UiComponent.getId", "():int", false, false},
332         {"UiComponent.getText", "():string", false, false},
333         {"UiComponent.getKey", "():string", false, false},
334         {"UiComponent.getType", "():string", false, false},
335         {"UiComponent.isEnabled", "():bool", false, false},
336         {"UiComponent.isFocused", "():bool", false, false},
337         {"UiComponent.isSelected", "():bool", false, false},
338         {"UiComponent.isClickable", "():bool", false, false},
339         {"UiComponent.isScrollable", "():bool", false, false},
340         {"UiComponent.click", "():void", false, false},
341         {"UiComponent.longClick", "():void", false, false},
342         {"UiComponent.doubleClick", "():void", false, false},
343         {"UiComponent.inputText", "(string):void", false, false},
344         {"UiComponent.scrollSearch", "(By):UiComponent", false, false},
345     };
346     constexpr FrontEndClassDef UI_COMPONENT_DEF = {
347         "UiComponent",
348         UI_COMPONENT_METHODS,
349         sizeof(UI_COMPONENT_METHODS) / sizeof(FrontendMethodDef),
350     };
351 
352     /** On class definition(since api 9, outdates By class).*/
353     constexpr FrontendMethodDef ON_METHODS[] = {
354         {"On.text", "(string,int?):On", false, true}, //  MatchPattern enum as int value
355         {"On.id", "(string,int?):On", false, true},
356         {"On.type", "(string,int?):On", false, true},
357         {"On.description", "(string,int?):On", false, true},
358         {"On.hint", "(string,int?):On", false, true},
359         {"On.enabled", "(bool?):On", false, true}, // default bool arg: true
360         {"On.focused", "(bool?):On", false, true},
361         {"On.selected", "(bool?):On", false, true},
362         {"On.clickable", "(bool?):On", false, true},
363         {"On.longClickable", "(bool?):On", false, true},
364         {"On.scrollable", "(bool?):On", false, true},
365         {"On.checkable", "(bool?):On", false, true},
366         {"On.checked", "(bool?):On", false, true},
367         {"On.isBefore", "(On):On", false, true},
368         {"On.isAfter", "(On):On", false, true},
369         {"On.within", "(On):On", false, true},
370         {"On.inWindow", "(string):On", false, true},
371         {"On.inDisplay", "(int):On", false, true},
372     };
373 
374     constexpr std::string_view REF_SEED_ON = "On#seed";
375     constexpr FrontEndClassDef ON_DEF = {
376         "On",
377         ON_METHODS,
378         sizeof(ON_METHODS) / sizeof(FrontendMethodDef),
379     };
380 
381     /** Driver class definition. (since api 9, outdates UiDriver)*/
382     constexpr FrontendMethodDef DRIVER_METHODS[] = {
383         {"Driver.create", "():Driver", true, true},
384         {"Driver.delayMs", "(int):void", false, false},
385         {"Driver.findComponent", "(On):Component", false, false},
386         {"Driver.findWindow", "(WindowFilter):UiWindow", false, false},
387         {"Driver.findComponents", "(On):[Component]", false, false},
388         {"Driver.waitForComponent", "(On,int):Component", false, false},
389         {"Driver.screenCap", "(int):bool", false, false},            // fliePath as fileDescription.
390         {"Driver.screenCapture", "(int, Rect?, int?):bool", false, false}, // fliePath as fileDescription.
391         {"Driver.assertComponentExist", "(On):void", false, false},
392         {"Driver.pressBack", "():void", false, false},
393         {"Driver.triggerKey", "(int):void", false, false},
394         {"Driver.triggerCombineKeys", "(int,int,int?):void", false, false},
395         {"Driver.click", "(int,int):void", false, false},
396         {"Driver.click", "(Point):void", false, false},
397         {"Driver.longClick", "(int,int):void", false, false},
398         {"Driver.longClick", "(Point):void", false, false},
399         {"Driver.doubleClick", "(int,int):void", false, false},
400         {"Driver.doubleClick", "(Point):void", false, false},
401         {"Driver.swipe", "(int,int,int,int,int?):void", false, false},
402         {"Driver.swipe", "(Point,Point,int?):void", false, false},
403         {"Driver.drag", "(int,int,int,int,int?):void", false, false},
404         {"Driver.drag", "(Point,Point,int?):void", false, false},
405         {"Driver.setDisplayRotation", "(int):void", false, false},  // DisplayRotation enum as int value
406         {"Driver.getDisplayRotation", "(int?):int", false, false},     // DisplayRotation enum as int value
407         {"Driver.setDisplayRotationEnabled", "(bool):void", false, false},
408         {"Driver.getDisplaySize", "(int?):Point", false, false},
409         {"Driver.getDisplayDensity", "(int?):Point", false, false},
410         {"Driver.wakeUpDisplay", "():void", false, false},
411         {"Driver.pressHome", "():void", false, false},
412         {"Driver.waitForIdle", "(int,int):bool", false, false},
413         {"Driver.fling", "(Point,Point,int,int):void", false, false},
414         {"Driver.fling", "(int,int,int?):void", false, false},
415         {"Driver.injectMultiPointerAction", "(PointerMatrix, int?):bool", false, false},
416         {"Driver.mouseClick", "(Point,int,int?,int?):void", false, false},
417         {"Driver.mouseDoubleClick", "(Point,int,int?,int?):void", false, false},
418         {"Driver.mouseLongClick", "(Point,int,int?,int?):void", false, false},
419         {"Driver.mouseMoveTo", "(Point):void", false, false},
420         {"Driver.mouseMoveWithTrack", "(Point,Point,int?):void", false, false},
421         {"Driver.mouseDrag", "(Point,Point,int?):void", false, false},
422         {"Driver.mouseScroll", "(Point,bool,int,int?,int?,int?):void", false, false},
423         {"Driver.createUIEventObserver", "():UIEventObserver", false, false},
424         {"Driver.inputText", "(Point,string):void", false, false},
425         {"Driver.touchPadMultiFingerSwipe", "(int,int,TouchPadSwipeOptions?):void", false, false},
426         {"Driver.penClick", "(Point):void", false, false},
427         {"Driver.penLongClick", "(Point,float?):void", false, false},
428         {"Driver.penDoubleClick", "(Point):void", false, false},
429         {"Driver.penSwipe", "(Point,Point,int?,float?):void", false, false},
430         {"Driver.injectPenPointerAction", "(PointerMatrix,int?,float?):void", false, false},
431     };
432     constexpr FrontEndClassDef DRIVER_DEF = {
433         "Driver",
434         DRIVER_METHODS,
435         sizeof(DRIVER_METHODS) / sizeof(FrontendMethodDef),
436     };
437 
438     /** Component class definition.(since api 9, outdates UiComponent)*/
439     constexpr FrontendMethodDef COMPONENT_METHODS[] = {
440         {"Component.getText", "():string", false, false},
441         {"Component.getId", "():string", false, false},
442         {"Component.getType", "():string", false, false},
443         {"Component.getDescription", "():string", false, false},
444         {"Component.getHint", "():string", false, false},
445         {"Component.getDisplayId", "():int", false, false},
446         {"Component.isEnabled", "():bool", false, false},
447         {"Component.isFocused", "():bool", false, false},
448         {"Component.isSelected", "():bool", false, false},
449         {"Component.isClickable", "():bool", false, false},
450         {"Component.isLongClickable", "():bool", false, false},
451         {"Component.isScrollable", "():bool", false, false},
452         {"Component.isCheckable", "():bool", false, false},
453         {"Component.isChecked", "():bool", false, false},
454         {"Component.getBounds", "():Rect", false, false},
455         {"Component.getBoundsCenter", "():Point", false, false},
456         {"Component.click", "():void", false, false},
457         {"Component.longClick", "():void", false, false},
458         {"Component.doubleClick", "():void", false, false},
459         {"Component.scrollToTop", "(int?):void", false, false},
460         {"Component.scrollToBottom", "(int?):void", false, false},
461         {"Component.inputText", "(string):void", false, false},
462         {"Component.clearText", "():void", false, false},
463         {"Component.scrollSearch", "(On, bool?, int?):Component", false, false},
464         {"Component.dragTo", "(Component):void", false, false},
465         {"Component.pinchOut", "(float):void", false, false},
466         {"Component.pinchIn", "(float):void", false, false},
467     };
468     constexpr FrontEndClassDef COMPONENT_DEF = {
469         "Component",
470         COMPONENT_METHODS,
471         sizeof(COMPONENT_METHODS) / sizeof(FrontendMethodDef),
472     };
473 
474     /** UiWindow class definition.*/
475     constexpr FrontendMethodDef UI_WINDOW_METHODS[] = {
476         {"UiWindow.getBundleName", "():string", false, false},
477         {"UiWindow.getBounds", "():Rect", false, false},
478         {"UiWindow.getTitle", "():string", false, false},
479         {"UiWindow.getWindowMode", "():int", false, false}, // WindowMode enum as int value
480         {"UiWindow.getDisplayId", "():int", false, false},
481         {"UiWindow.isFocused", "():bool", false, false},
482         {"UiWindow.isActived", "():bool", false, false}, // Deprecated from API 11
483         {"UiWindow.isActive", "():bool", false, false},
484         {"UiWindow.focus", "():void", false, false},
485         {"UiWindow.moveTo", "(int,int):void", false, false},
486         {"UiWindow.resize", "(int,int,int):void", false, false}, // ResizeDirection enum as int value
487         {"UiWindow.split", "():void", false, false},
488         {"UiWindow.maximize", "():void", false, false},
489         {"UiWindow.resume", "():void", false, false},
490         {"UiWindow.minimize", "():void", false, false},
491         {"UiWindow.close", "():void", false, false},
492     };
493     constexpr FrontEndClassDef UI_WINDOW_DEF = {
494         "UiWindow",
495         UI_WINDOW_METHODS,
496         sizeof(UI_WINDOW_METHODS) / sizeof(FrontendMethodDef),
497     };
498 
499     /** PointerMatrix class definition.*/
500     constexpr FrontendMethodDef POINTER_MATRIX_METHODS[] = {
501         {"PointerMatrix.create", "(int,int):PointerMatrix", true, true},
502         {"PointerMatrix.setPoint", "(int,int,Point):void", false, true},
503     };
504     constexpr FrontEndClassDef POINTER_MATRIX_DEF = {
505         "PointerMatrix",
506         POINTER_MATRIX_METHODS,
507         sizeof(POINTER_MATRIX_METHODS) / sizeof(FrontendMethodDef),
508     };
509 
510     /** UIEventObserver class definition.*/
511     constexpr FrontendMethodDef UI_EVENT_OBSERVER_METHODS[] = {
512 	    // callback<UIElementInfo> saved in js, works as callbackRef in c++.
513         {"UIEventObserver.once", "(string, string):void", false, true},
514     };
515     constexpr FrontEndClassDef UI_EVENT_OBSERVER_DEF = {
516         "UIEventObserver",
517         UI_EVENT_OBSERVER_METHODS,
518         sizeof(UI_EVENT_OBSERVER_METHODS) / sizeof(FrontendMethodDef),
519     };
520 
521     /** List all the frontend data-type definitions.*/
522     const auto FRONTEND_CLASS_DEFS = {&BY_DEF, &UI_DRIVER_DEF, &UI_COMPONENT_DEF, &ON_DEF,
523                                       &DRIVER_DEF, &COMPONENT_DEF, &UI_WINDOW_DEF, &POINTER_MATRIX_DEF,
524                                       &UI_EVENT_OBSERVER_DEF};
525     const auto FRONTEND_ENUMERATOR_DEFS = {&MATCH_PATTERN_DEF, &WINDOW_MODE_DEF, &RESIZE_DIRECTION_DEF,
526                                            &DISPLAY_ROTATION_DEF, &MOUSE_BUTTON_DEF, &UI_DIRECTION_DEF};
527     const auto FRONTEND_JSON_DEFS = {&RECT_DEF, &POINT_DEF, &WINDOW_FILTER_DEF, &UI_ELEMENT_INFO_DEF,
528                                      &TOUCH_PAD_SWIPE_OPTIONS_DEF};
529     /** The allowed in/out data type scope of frontend apis.*/
530     const std::initializer_list<std::string_view> DATA_TYPE_SCOPE = {
531         "int",
532         "float",
533         "bool",
534         "string",
535         RECT_DEF.name_,
536         POINT_DEF.name_,
537         WINDOW_FILTER_DEF.name_,
538         BY_DEF.name_,
539         UI_DRIVER_DEF.name_,
540         UI_COMPONENT_DEF.name_,
541         ON_DEF.name_,
542         DRIVER_DEF.name_,
543         COMPONENT_DEF.name_,
544         UI_WINDOW_DEF.name_,
545         POINTER_MATRIX_DEF.name_,
546         UI_EVENT_OBSERVER_DEF.name_,
547         TOUCH_PAD_SWIPE_OPTIONS_DEF.name_,
548     };
549 } // namespace OHOS::uitest
550 
551 #endif