1 /*
2 * Copyright (c) 2021 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 #define private public
16 #define protected public
17
18 #include "hilog_wrapper.h"
19
20 // event/commonevent
21 #include "async_common_event_result.h"
22 #include "common_event_manager.h"
23 #include "common_event_data.h"
24 #include "common_event_publish_info.h"
25 #include "common_event_subscribe_info.h"
26 #include "common_event_subscriber.h"
27 #include "common_event_support.h"
28 #include "matching_skills.h"
29
30 // event/eventhandle
31 #include "event_handler.h"
32 #include "event_queue.h"
33 #include "event_runner.h"
34 #include "inner_event.h"
35 #include "dumper.h"
36 #include "logger.h"
37
38 // aafwk/ability
39 #include "ability.h"
40 #include "data_ability_helper.h"
41 #include "ability_lifecycle_interface.h"
42 #include "ability_lifecycle.h"
43 #include "data_uri_utils.h"
44 #include "ability_manager.h"
45
46 // AMS
47 #include "ohos_application.h"
48 #include "ability_context.h"
49 #include "data_uri_utils.h"
50 #include "element_name.h"
51 #include "want.h"
52 #include "ability_record_mgr.h"
53
54 // aafwk/bundle
55 #include "bundle_mgr_proxy.h"
56 #include "ohos/aafwk/base/short_wrapper.h"
57 #include "../include/getparam.h"
58 #include "../include/fuzzTestManager.h"
59
60 #include "../include/fuzzConfigParser.h"
61
62 #include "abs_shared_result_set.h"
63 #include "data_ability_predicates.h"
64 #include "values_bucket.h"
65
66 #include <unistd.h>
67 #include <csignal>
68
69 #undef private
70 #undef protected
71 using namespace OHOS::AppExecFwk;
72 namespace OHOS {
73 namespace EventFwk {
74 std::shared_ptr<fuzzTestManager> fuzzTestManager::instance_ = nullptr;
75
76 // RegisterAsyncCommonEventResult
RegisterAsyncCommonEventResult()77 void fuzzTestManager::RegisterAsyncCommonEventResult()
78 {
79 callFunctionMap_["AsyncCommonEventResultSetCode"] = []() {
80 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
81 temp.get()->SetCode(GetU32Param());
82 std::cout << temp->GetCode();
83 };
84 callFunctionMap_["AsyncCommonEventResultGetCode"] = []() {
85 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
86 temp->GetCode();
87 };
88 callFunctionMap_["AsyncCommonEventResultSetData"] = []() {
89 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
90 temp->SetData(GetStringParam());
91 };
92 callFunctionMap_["AsyncCommonEventResultGetData"] = []() {
93 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
94 temp->GetData();
95 };
96 callFunctionMap_["AsyncCommonEventResultSetCodeAndData"] = []() {
97 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
98 temp->SetCodeAndData(GetIntParam(), GetStringParam());
99 };
100 callFunctionMap_["AsyncCommonEventResultAbortCommonEvent"] = []() {
101 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
102 temp->AbortCommonEvent();
103 };
104 callFunctionMap_["AsyncCommonEventResultClearAbortCommonEvent"] = []() {
105 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
106 temp->ClearAbortCommonEvent();
107 };
108 callFunctionMap_["AsyncCommonEventResultGetAbortCommonEvent"] = []() {
109 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
110 temp->GetAbortCommonEvent();
111 };
112 callFunctionMap_["AsyncCommonEventResultFinishCommonEvent"] = []() {
113 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
114 temp->FinishCommonEvent();
115 };
116 callFunctionMap_["AsyncCommonEventResultIsOrderedCommonEvent"] = []() {
117 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
118 temp->IsOrderedCommonEvent();
119 };
120 callFunctionMap_["AsyncCommonEventResultIsStickyCommonEvent"] = []() {
121 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
122 temp->IsStickyCommonEvent();
123 };
124 callFunctionMap_["AsyncCommonEventResultCheckSynchronous"] = []() {
125 std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
126 temp->CheckSynchronous();
127 };
128 }
129
130 // RegisterCommonEventData
RegisterCommonEventData()131 void fuzzTestManager::RegisterCommonEventData()
132 {
133 callFunctionMap_["CommonEventDataSetWant"] = []() {
134 std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
135 temp->SetWant(*(GetParamWant().get()));
136 };
137 callFunctionMap_["CommonEventDataGetWant"] = []() {
138 std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
139 temp->GetWant();
140 };
141 callFunctionMap_["CommonEventDataSetCode"] = []() {
142 std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
143 temp->SetCode(GetIntParam());
144 };
145 callFunctionMap_["CommonEventDataGetCode"] = []() {
146 std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
147 temp->GetCode();
148 };
149 callFunctionMap_["CommonEventDataSetData"] = []() {
150 std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
151 temp->SetData(GetStringParam());
152 };
153 callFunctionMap_["CommonEventDataGetData"] = []() {
154 std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
155 temp->GetData();
156 };
157 callFunctionMap_["CommonEventDataMarshalling"] = []() {
158 std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
159 Parcel p;
160 temp->Marshalling(p);
161 };
162 callFunctionMap_["CommonEventDataUnmarshalling"] = []() {
163 std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
164 Parcel p;
165 temp->Unmarshalling(p);
166 };
167 }
168
169 // RegisterCommonEventManager
RegisterCommonEventManager()170 void fuzzTestManager::RegisterCommonEventManager()
171 {
172 callFunctionMap_["CommonEventManagerPublishCommonEventCommonEventData"] = []() {
173 std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
174 temp->PublishCommonEvent(*(GetParamCommonEventData().get()));
175 };
176 callFunctionMap_["CommonEventManagerPublishCommonEventCommonEventDataCommonEventPublishInfo"] = []() {
177 std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
178 temp->PublishCommonEvent(*(GetParamCommonEventData().get()), *(GetParamCommonEventPublishInfo().get()));
179 };
180 callFunctionMap_["CommonEventManagerPublishCommonEventCommonEventDataCommonEventPublishInfoCommonEventSubscriber"] =
181 []() {
182 std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
183 temp->PublishCommonEvent(*(GetParamCommonEventData().get()),
184 *(GetParamCommonEventPublishInfo().get()),
185 GetParamCommonEventSubscriber());
186 };
187 callFunctionMap_["CommonEventManagerSubscribeCommonEvent"] = []() {
188 std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
189 temp->SubscribeCommonEvent(GetParamCommonEventSubscriber());
190 };
191 callFunctionMap_["CommonEventManagerUnSubscribeCommonEvent"] = []() {
192 std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
193 temp->UnSubscribeCommonEvent(GetParamCommonEventSubscriber());
194 };
195 callFunctionMap_["CommonEventManagerGetStickyCommonEvent"] = []() {
196 std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
197 temp->GetStickyCommonEvent(GetStringParam(), *(GetParamCommonEventData()));
198 };
199 }
200
201 // RegisterCommonEventPublishInfo
RegisterCommonEventPublishInfo()202 void fuzzTestManager::RegisterCommonEventPublishInfo()
203 {
204 callFunctionMap_["CommonEventPublishInfoSetSticky"] = []() {
205 std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
206 temp->SetSticky(GetBoolParam());
207 };
208 callFunctionMap_["CommonEventPublishInfoIsSticky"] = []() {
209 std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
210 temp->IsSticky();
211 };
212 callFunctionMap_["CommonEventPublishInfoSetSubscriberPermissions"] = []() {
213 std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
214 temp->SetSubscriberPermissions(GetStringVectorParam());
215 };
216 callFunctionMap_["CommonEventPublishInfoGetSubscriberPermissions"] = []() {
217 std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
218 temp->GetSubscriberPermissions();
219 };
220 callFunctionMap_["CommonEventPublishInfoSetOrdered"] = []() {
221 std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
222 temp->SetOrdered(GetBoolParam());
223 };
224 callFunctionMap_["CommonEventPublishInfoIsOrdered"] = []() {
225 std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
226 temp->IsOrdered();
227 };
228 callFunctionMap_["CommonEventPublishInfoMarshalling"] = []() {
229 std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
230 Parcel p;
231 temp->Marshalling(p);
232 };
233
234 callFunctionMap_["CommonEventPublishInfoUnmarshalling"] = []() {
235 std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
236 Parcel p;
237 temp->Unmarshalling(p);
238 };
239 }
240
241 // RegisterCommonEventSubscribeInfo
RegisterCommonEventSubscribeInfo()242 void fuzzTestManager::RegisterCommonEventSubscribeInfo()
243 {
244 callFunctionMap_["CommonEventSubscribeInfoSetPriority"] = []() {
245 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
246 temp->SetPriority(GetS32Param());
247 };
248 callFunctionMap_["CommonEventSubscribeInfoGetPriority"] = []() {
249 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
250 temp->GetPriority();
251 };
252 callFunctionMap_["CommonEventSubscribeInfoSetPermission"] = []() {
253 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
254 temp->SetPermission(GetStringParam());
255 };
256 callFunctionMap_["CommonEventSubscribeInfoGetPermission"] = []() {
257 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
258 temp->GetPermission();
259 };
260 callFunctionMap_["CommonEventSubscribeInfoSetThreadMode"] = []() {
261 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
262 temp->SetThreadMode(GetParamThreadMode());
263 };
264 callFunctionMap_["CommonEventSubscribeInfoSetDeviceId"] = []() {
265 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
266 temp->SetDeviceId(GetStringParam());
267 };
268 callFunctionMap_["CommonEventSubscribeInfoGetDeviceId"] = []() {
269 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
270 temp->GetDeviceId();
271 };
272 callFunctionMap_["CommonEventSubscribeInfoGetMatchingSkills"] = []() {
273 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
274 temp->GetMatchingSkills();
275 };
276 callFunctionMap_["CommonEventSubscribeInfoMarshalling"] = []() {
277 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
278 Parcel p;
279 temp->Marshalling(p);
280 };
281 callFunctionMap_["CommonEventSubscribeInfoUnmarshalling"] = []() {
282 std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
283 Parcel p;
284 temp->Unmarshalling(p);
285 };
286 }
287
288 // RegisterCommonEventSubscriber
RegisterCommonEventSubscriber()289 void fuzzTestManager::RegisterCommonEventSubscriber()
290 {
291 callFunctionMap_["CommonEventSubscriberOnReceiveEvent"] = []() {
292 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
293 temp->OnReceiveEvent(*(GetParamCommonEventData().get()));
294 };
295 callFunctionMap_["CommonEventSubscriberGetSubscribeInfo"] = []() {
296 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
297 temp->GetSubscribeInfo();
298 };
299 callFunctionMap_["CommonEventSubscriberSetCode"] = []() {
300 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
301 temp->SetCode(GetIntParam());
302 };
303 callFunctionMap_["CommonEventSubscriberGetCode"] = []() {
304 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
305 temp->GetCode();
306 };
307 callFunctionMap_["CommonEventSubscriberSetData"] = []() {
308 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
309 temp->SetData(GetStringParam());
310 };
311 callFunctionMap_["CommonEventSubscriberGetData"] = []() {
312 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
313 temp->GetData();
314 };
315 callFunctionMap_["CommonEventSubscriberSetCodeAndData"] = []() {
316 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
317 temp->SetCodeAndData(GetIntParam(), GetStringParam());
318 };
319 callFunctionMap_["CommonEventSubscriberAbortCommonEvent"] = []() {
320 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
321 temp->AbortCommonEvent();
322 };
323 callFunctionMap_["CommonEventSubscriberClearAbortCommonEvent"] = []() {
324 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
325 temp->ClearAbortCommonEvent();
326 };
327 callFunctionMap_["CommonEventSubscriberGetAbortCommonEvent"] = []() {
328 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
329 temp->GetAbortCommonEvent();
330 };
331 callFunctionMap_["CommonEventSubscriberGoAsyncCommonEvent"] = []() {
332 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
333 temp->GoAsyncCommonEvent();
334 };
335 callFunctionMap_["CommonEventSubscriberIsOrderedCommonEvent"] = []() {
336 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
337 temp->IsOrderedCommonEvent();
338 };
339 callFunctionMap_["CommonEventSubscriberIsStickyCommonEvent"] = []() {
340 std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
341 temp->IsStickyCommonEvent();
342 };
343 }
344
345 // RegisterCommonEventSupport
RegisterCommonEventSupport()346 void fuzzTestManager::RegisterCommonEventSupport()
347 {
348 callFunctionMap_["CommonEventSupportIsSystemEvent"] = []() {
349 std::shared_ptr<CommonEventSupport> temp = GetParamCommonEventSupport();
350 std::string s = GetStringParam();
351 temp->IsSystemEvent(s);
352 };
353 }
354
355 // RegisterMatchingSkills
RegisterMatchingSkills()356 void fuzzTestManager::RegisterMatchingSkills()
357 {
358 callFunctionMap_["MatchingSkillsAddEntity"] = []() {
359 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
360 temp->AddEntity(GetStringParam());
361 };
362 callFunctionMap_["MatchingSkillsHasEntity"] = []() {
363 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
364 temp->HasEntity(GetStringParam());
365 };
366 callFunctionMap_["MatchingSkillsRemoveEntity"] = []() {
367 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
368 temp->RemoveEntity(GetStringParam());
369 };
370 callFunctionMap_["MatchingSkillsCountEntities"] = []() {
371 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
372 temp->CountEntities();
373 };
374 callFunctionMap_["MatchingSkillsAddEvent"] = []() {
375 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
376 temp->AddEvent(GetStringParam());
377 };
378 callFunctionMap_["MatchingSkillsCountEvent"] = []() {
379 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
380 temp->CountEvent();
381 };
382 callFunctionMap_["MatchingSkillsGetEvents"] = []() {
383 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
384 temp->GetEvents();
385 };
386 callFunctionMap_["MatchingSkillsRemoveEvent"] = []() {
387 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
388 temp->RemoveEvent(GetStringParam());
389 };
390 callFunctionMap_["MatchingSkillsHasEvent"] = []() {
391 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
392 temp->HasEvent(GetStringParam());
393 };
394 callFunctionMap_["MatchingSkillsAddScheme"] = []() {
395 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
396 temp->AddScheme(GetStringParam());
397 };
398 callFunctionMap_["MatchingSkillsHasScheme"] = []() {
399 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
400 temp->HasScheme(GetStringParam());
401 };
402 callFunctionMap_["MatchingSkillsRemoveScheme"] = []() {
403 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
404 temp->RemoveScheme(GetStringParam());
405 };
406 callFunctionMap_["MatchingSkillsCountSchemes"] = []() {
407 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
408 temp->CountSchemes();
409 };
410 callFunctionMap_["MatchingSkillsMatch"] = []() {
411 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
412 temp->Match(*(GetParamWant().get()));
413 };
414 callFunctionMap_["MatchingSkillsMarshalling"] = []() {
415 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
416 Parcel p;
417 temp->Marshalling(p);
418 };
419 callFunctionMap_["MatchingSkillsUnmarshalling"] = []() {
420 std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
421 Parcel p;
422 temp->Unmarshalling(p);
423 };
424 }
425
426 // RegisterDumper
RegisterDumper()427 void fuzzTestManager::RegisterDumper()
428 {
429 callFunctionMap_["DumperDump"] = []() {
430 TestDumper temp;
431 temp.Dump(GetStringParam());
432 };
433 callFunctionMap_["DumperGetTag"] = []() {
434 TestDumper temp;
435 temp.GetTag();
436 };
437 }
438
439 // RegisterEventHandler
RegisterEventHandler()440 void fuzzTestManager::RegisterEventHandler()
441 {
442 callFunctionMap_["EventHandlerCurrent"] = []() {
443 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
444 temp->Current();
445 };
446 callFunctionMap_["EventHandlerSendEventPointer&int64_tPriority"] = []() {
447 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
448 temp->SendEvent(GetParamInnerEvent(), GetS64Param());
449 };
450
451 callFunctionMap_["EventHandlerSendTimingEvent"] = []() {
452 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
453 temp->SendTimingEvent(GetParamInnerEvent(), GetS64Param());
454 };
455
456 callFunctionMap_["EventHandlerSendEventPointerPriority"] = []() {
457 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
458 temp->SendEvent(GetParamInnerEvent());
459 };
460
461 callFunctionMap_["EventHandlerSendEventPointer&&int64_tPriority"] = []() {
462 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
463 temp->SendEvent(GetParamInnerEvent(), GetS64Param());
464 };
465
466 callFunctionMap_["EventHandlerSendEventuint32_tint64_tint64_t"] = []() {
467 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
468 temp->SendEvent(GetU32Param(), GetS64Param(), GetS64Param());
469 };
470
471 callFunctionMap_["EventHandlerSendEventuint32_tint64_tPriority"] = []() {
472 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
473 temp->SendEvent(GetU32Param(), GetS64Param(), GetParamPriority());
474 };
475
476 callFunctionMap_["EventHandlerSendEventuint32_tPriority"] = []() {
477 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
478 temp->SendEvent(GetU32Param(), GetParamPriority());
479 };
480
481 callFunctionMap_["EventHandlerSendEventuint32_tshared_ptr<T>int64_t"] = []() {
482 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
483 temp->SendEvent(GetU32Param(), GetParamEventHandler(), GetS64Param());
484 };
485
486 callFunctionMap_["EventHandlerSendEventuint32_tweak_ptr<T>int64_t"] = []() {
487 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
488 std::weak_ptr<int> wp = std::make_shared<int>(1);
489 temp->SendEvent(GetU32Param(), wp, GetS64Param());
490 };
491
492 callFunctionMap_["EventHandlerSendEventuint32_tunique_ptr<T, D>&int64_t"] = []() {
493 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
494 std::unique_ptr<int> p(new int, std::default_delete<int>());
495 temp->SendEvent(GetU32Param(), p, GetS64Param());
496 };
497
498 callFunctionMap_["EventHandlerSendEventuint32_t"] = []() {
499 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
500 temp->SendEvent(GetU32Param());
501 };
502
503 callFunctionMap_["EventHandlerSendEventunique_ptr<T, D>&&int64_t"] = []() {
504 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
505 temp->SendImmediateEvent(GetParamInnerEvent());
506 };
507
508 callFunctionMap_["EventHandlerSendImmediateEventPointer"] = []() {
509 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
510 temp->SendImmediateEvent(GetParamInnerEvent());
511 };
512
513 callFunctionMap_["EventHandlerSendImmediateEventuint32_tint64_t"] = []() {
514 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
515 temp->SendImmediateEvent(GetU32Param(), GetS64Param());
516 };
517
518 callFunctionMap_["EventHandlerSendImmediateEventuint32_tshared_ptr<T>"] = []() {
519 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
520 temp->SendImmediateEvent(GetU32Param(), GetParamInnerEvent());
521 };
522
523 callFunctionMap_["EventHandlerSendImmediateEventuint32_t:unique_ptr<T, D>&"] = []() {
524 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
525 temp->SendImmediateEvent(GetU32Param(), GetParamInnerEvent());
526 };
527
528 callFunctionMap_["EventHandlerSendImmediateEventuint32_t:unique_ptr<T, D>&&"] = []() {
529 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
530 std::unique_ptr<int> p(new int, std::default_delete<int>());
531 temp->SendImmediateEvent(GetU32Param(), p);
532 };
533
534 callFunctionMap_["EventHandlerSendHighPriorityEventPointer&int64_t"] = []() {
535 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
536 temp->SendImmediateEvent(GetU32Param(), GetS64Param());
537 };
538
539 callFunctionMap_["EventHandlerSendHighPriorityEventPointer&&int64_t"] = []() {
540 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
541 temp->SendHighPriorityEvent(GetParamInnerEvent(), GetS64Param());
542 };
543
544 callFunctionMap_["EventHandlerSendHighPriorityEventPointer&int64_t"] = []() {
545 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
546 temp->SendHighPriorityEvent(GetParamInnerEvent(), GetS64Param());
547 };
548
549 callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tint64_tint64_t"] = []() {
550 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
551 temp->SendHighPriorityEvent(GetU32Param(), GetS64Param(), GetS64Param());
552 };
553
554 callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tshared_ptr<T>&int64_t"] = []() {
555 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
556 temp->SendHighPriorityEvent(GetU32Param(), GetParamEventHandler(), GetS64Param());
557 };
558
559 callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tweak_ptr<T>&int64_t"] = []() {
560 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
561 std::weak_ptr<int> wp = std::make_shared<int>(1);
562 temp->SendHighPriorityEvent(GetU32Param(), wp, GetS64Param());
563 };
564
565 callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tunique_ptr<T, D>&int64_t"] = []() {
566 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
567 std::unique_ptr<int> p(new int, std::default_delete<int>());
568 temp->SendHighPriorityEvent(GetU32Param(), p, GetS64Param());
569 };
570
571 callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tunique_ptr<T, D>&&int64_t"] = []() {
572 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
573 std::unique_ptr<int> p(new int, std::default_delete<int>());
574 temp->SendHighPriorityEvent(GetU32Param(), p, GetS64Param());
575 };
576
577 callFunctionMap_["EventHandlerPostTaskCallbackstringint64_tPriority"] = []() {
578 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
579 temp->PostTask(GetParamCallback(), GetStringParam(), GetS64Param());
580 };
581
582 callFunctionMap_["EventHandlerPostTaskCallbackPriority"] = []() {
583 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
584 temp->PostTask(GetParamCallback(), GetParamPriority());
585 };
586
587 callFunctionMap_["EventHandlerPostTaskCallbackint64_tPriority"] = []() {
588 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
589 temp->PostTask(GetParamCallback(), GetS64Param(), GetParamPriority());
590 };
591
592 callFunctionMap_["EventHandlerPostImmediateTaskCallbackstring"] = []() {
593 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
594 temp->PostImmediateTask(GetParamCallback(), GetStringParam());
595 };
596
597 callFunctionMap_["EventHandlerPostHighPriorityTaskCallbackstringint64_t"] = []() {
598 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
599 temp->PostHighPriorityTask(GetParamCallback(), GetStringParam(), GetS64Param());
600 };
601
602 callFunctionMap_["EventHandlerPostHighPriorityTaskCallbackint64_t"] = []() {
603 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
604 temp->PostHighPriorityTask(GetParamCallback(), GetS64Param());
605 };
606
607 callFunctionMap_["EventHandlerPostIdleTaskCallbackstringint64_t"] = []() {
608 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
609 temp->PostIdleTask(GetParamCallback(), GetStringParam(), GetS64Param());
610 };
611
612 callFunctionMap_["EventHandlerPostIdleTaskCallbackint64_t"] = []() {
613 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
614 temp->PostIdleTask(GetParamCallback(), GetS64Param());
615 };
616
617 callFunctionMap_["EventHandlerSendSyncEventPointer&Priority"] = []() {
618 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
619 temp->SendSyncEvent(GetParamInnerEvent(), GetParamPriority());
620 };
621
622 callFunctionMap_["EventHandlerSendSyncEventPointer&&Priority"] = []() {
623 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
624 temp->SendSyncEvent(GetParamInnerEvent(), GetParamPriority());
625 };
626
627 callFunctionMap_["EventHandlerSendSyncEventuint32_tint64_tPriority"] = []() {
628 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
629 temp->SendSyncEvent(GetU32Param(), GetS64Param(), GetParamPriority());
630 };
631
632 callFunctionMap_["EventHandlerSendSyncEventuint32_tPriority"] = []() {
633 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
634 temp->SendSyncEvent(GetU32Param(), GetParamPriority());
635 };
636
637 callFunctionMap_["EventHandlerSendSyncEventuint32_tshared_ptr<T>Priority"] = []() {
638 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
639 temp->SendSyncEvent(GetU32Param(), GetParamEventHandler(), GetParamPriority());
640 };
641
642 callFunctionMap_["EventHandlerSendSyncEventuint32_tweak_ptr<T>Priority"] = []() {
643 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
644 std::weak_ptr<int> wp = std::make_shared<int>(1);
645 temp->SendSyncEvent(GetU32Param(), wp, GetParamPriority());
646 };
647
648 callFunctionMap_["EventHandlerSendSyncEventuint32_tunique_ptr<T, D>&Priority"] = []() {
649 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
650 std::unique_ptr<int> p(new int, std::default_delete<int>());
651 temp->SendSyncEvent(GetU32Param(), p, GetParamPriority());
652 };
653
654 callFunctionMap_["EventHandlerSendSyncEventuint32_tunique_ptr<T, D>&&Priority"] = []() {
655 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
656 std::unique_ptr<int> p(new int, std::default_delete<int>());
657 temp->SendSyncEvent(GetU32Param(), p, GetParamPriority());
658 };
659
660 callFunctionMap_["EventHandlerPostSyncTaskCallbackstringPriority"] = []() {
661 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
662 temp->PostSyncTask(GetParamCallback(), GetStringParam(), GetParamPriority());
663 };
664
665 callFunctionMap_["EventHandlerPostSyncTaskCallbackPriority"] = []() {
666 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
667 temp->PostSyncTask(GetParamCallback(), GetParamPriority());
668 };
669
670 callFunctionMap_["EventHandlerSendTimingEventPointerint64_tPriority"] = []() {
671 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
672 temp->SendTimingEvent(GetParamInnerEvent(), GetS64Param(), GetParamPriority());
673 };
674
675 callFunctionMap_["EventHandlerSendTimingEventPointerint64_t"] = []() {
676 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
677 temp->SendTimingEvent(GetParamInnerEvent(), GetS64Param());
678 };
679
680 callFunctionMap_["EventHandlerSendTimingEventuint32_tint64_tint64_t"] = []() {
681 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
682 temp->SendTimingEvent(GetU32Param(), GetS64Param(), GetS64Param());
683 };
684
685 callFunctionMap_["EventHandlerSendTimingEventuint32_tint64_tPriority"] = []() {
686 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
687 temp->SendTimingEvent(GetU32Param(), GetS64Param(), GetParamPriority());
688 };
689
690 callFunctionMap_["EventHandlerSendTimingEventuint32_tint64_t"] = []() {
691 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
692 temp->SendTimingEvent(GetU32Param(), GetS64Param());
693 };
694
695 callFunctionMap_["EventHandlerSendTimingEventuint32_tshared_ptr<T>int64_tPriority"] = []() {
696 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
697 temp->SendTimingEvent(GetU32Param(), GetParamEventHandler(), GetS64Param(), GetParamPriority());
698 };
699
700 callFunctionMap_["EventHandlerSendTimingEventuint32_tweak_ptr<T>int64_tPriority"] = []() {
701 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
702 std::weak_ptr<int> wp = std::make_shared<int>(1);
703 temp->SendTimingEvent(GetU32Param(), wp, GetS64Param(), GetParamPriority());
704 };
705
706 callFunctionMap_["EventHandlerSendTimingEventuint32_tunique_ptr<T, D>&int64_tPriority"] = []() {
707 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
708 std::unique_ptr<int> p(new int, std::default_delete<int>());
709 temp->SendTimingEvent(GetU32Param(), p, GetS64Param(), GetParamPriority());
710 };
711
712 callFunctionMap_["EventHandlerSendTimingEventuint32_tunique_ptr<T, D>&&int64_tPriority"] = []() {
713 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
714 std::unique_ptr<int> p(new int, std::default_delete<int>());
715 temp->SendTimingEvent(GetU32Param(), p, GetS64Param(), GetParamPriority());
716 };
717
718 callFunctionMap_["EventHandlerPostTimingTaskCallbackint64_tstringPriority"] = []() {
719 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
720 temp->PostTimingTask(GetParamCallback(), GetS64Param(), GetStringParam());
721 };
722
723 callFunctionMap_["EventHandlerPostTimingTaskCallbackint64_tPriority"] = []() {
724 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
725 temp->PostTimingTask(GetParamCallback(), GetS64Param(), GetParamPriority());
726 };
727
728 callFunctionMap_["EventHandlerRemoveAllEvents"] = []() {
729 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
730 temp->RemoveAllEvents();
731 };
732
733 callFunctionMap_["EventHandlerRemoveEvent"] = []() {
734 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
735 temp->RemoveEvent(GetU32Param());
736 };
737
738 callFunctionMap_["EventHandlerRemoveEventuint32_tint64_t"] = []() {
739 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
740 temp->RemoveEvent(GetU32Param(), GetS64Param());
741 };
742
743 callFunctionMap_["EventHandlerRemoveTask"] = []() {
744 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
745 temp->RemoveTask(GetStringParam());
746 };
747
748 callFunctionMap_["EventHandlerAddFileDescriptorListener"] = []() {
749 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
750 temp->AddFileDescriptorListener(GetS32Param(), GetU32Param(), GetParamFileDescriptorListener());
751 };
752
753 callFunctionMap_["EventHandlerRemoveAllFileDescriptorListeners"] = []() {
754 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
755 temp->RemoveAllFileDescriptorListeners();
756 };
757
758 callFunctionMap_["EventHandlerRemoveFileDescriptorListener"] = []() {
759 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
760 temp->RemoveFileDescriptorListener(GetS32Param());
761 };
762
763 callFunctionMap_["EventHandlerSetEventRunner"] = []() {
764 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
765 temp->SetEventRunner(GetParamEventRunner());
766 };
767
768 callFunctionMap_["EventHandlerGetEventRunner"] = []() {
769 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
770 temp->GetEventRunner();
771 };
772
773 callFunctionMap_["EventHandlerDistributeEvent"] = []() {
774 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
775 temp->DistributeEvent(GetParamInnerEvent());
776 };
777
778 callFunctionMap_["EventHandlerDump"] = []() {
779 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
780 TestDumper param;
781 temp->Dump(param);
782 };
783
784 callFunctionMap_["EventHandlerHasInnerEventuint32_t"] = []() {
785 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
786 temp->HasInnerEvent(GetU32Param());
787 };
788
789 callFunctionMap_["EventHandlerHasInnerEventint64_t"] = []() {
790 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
791 temp->HasInnerEvent(GetS64Param());
792 };
793
794 callFunctionMap_["EventHandlerGetEventNamePointer"] = []() {
795 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
796 temp->GetEventName(GetParamInnerEvent());
797 };
798
799 callFunctionMap_["EventHandlerIsIdle"] = []() {
800 std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
801 temp->IsIdle();
802 };
803 }
804
805 // RegisterEventQueue
RegisterEventQueue()806 void fuzzTestManager::RegisterEventQueue()
807 {
808 callFunctionMap_["EventQueueInsert"] = []() {
809 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
810 AppExecFwk::InnerEvent::Pointer param = GetParamInnerEvent();
811 temp->Insert(param, GetParamPriority());
812 };
813
814 callFunctionMap_["EventQueueRemoveOrphan"] = []() {
815 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
816 temp->RemoveOrphan();
817 };
818 callFunctionMap_["EventQueueRemoveshared_ptr<EventHandler>"] = []() {
819 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
820 temp->Remove(GetParamEventHandler());
821 };
822 callFunctionMap_["EventQueueRemoveshared_ptr<EventHandler>uint32_t"] = []() {
823 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
824 temp->Remove(GetParamEventHandler(), GetU32Param());
825 };
826 callFunctionMap_["EventQueueRemoveshared_ptr<EventHandler>uint32_tint64_t"] = []() {
827 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
828 temp->Remove(GetParamEventHandler(), GetU32Param(), GetS64Param());
829 };
830 callFunctionMap_["EventQueueRemoveshared_ptr<EventHandler>string"] = []() {
831 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
832 temp->Remove(GetParamEventHandler(), GetStringParam());
833 };
834 callFunctionMap_["EventQueueAddFileDescriptor"] = []() {
835 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
836 temp->AddFileDescriptorListener(GetS32Param(), GetU32Param(), GetParamFileDescriptorListener());
837 };
838 callFunctionMap_["EventQueueRemoveFileDescriptorListenershared_ptr<EventHandler>"] = []() {
839 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
840 temp->RemoveFileDescriptorListener(GetParamEventHandler());
841 };
842 callFunctionMap_["EventQueueRemoveFileDescriptorListenerint32_t"] = []() {
843 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
844 temp->RemoveFileDescriptorListener(GetS32Param());
845 };
846 callFunctionMap_["EventQueuePrepare"] = []() {
847 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
848 temp->Prepare();
849 };
850 callFunctionMap_["EventQueueFinish"] = []() {
851 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
852 temp->Finish();
853 };
854 callFunctionMap_["EventQueueGetEvent"] = []() {
855 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
856 temp->GetEvent();
857 };
858 callFunctionMap_["EventQueueGetExpiredEvent"] = []() {
859 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
860 AppExecFwk::InnerEvent::TimePoint param = GetParamTimePoint();
861 temp->GetExpiredEvent(param);
862 };
863 callFunctionMap_["EventQueueDump"] = []() {
864 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
865 TestDumper param;
866 temp->Dump(param);
867 };
868 callFunctionMap_["EventQueueIsIdle"] = []() {
869 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
870 temp->IsIdle();
871 };
872 callFunctionMap_["EventQueueIsQueueEmpty"] = []() {
873 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
874 temp->IsQueueEmpty();
875 };
876 callFunctionMap_["EventQueueHasInnerEventuint32_t"] = []() {
877 std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
878 temp->HasInnerEvent(GetParamEventHandler(), GetU32Param());
879 };
880 }
881
882 // RegisterEventRunner
RegisterEventRunner()883 void fuzzTestManager::RegisterEventRunner()
884 {
885 callFunctionMap_["EventRunnerCreatebool"] = []() {
886 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
887 temp->Create(GetBoolParam());
888 };
889 callFunctionMap_["EventRunnerCreatechar*"] = []() {
890 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
891 temp->Create(GetCharArryParam());
892 };
893 callFunctionMap_["EventRunnerCurrent"] = []() {
894 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
895 temp->Current();
896 };
897 callFunctionMap_["EventRunnerRun"] = []() {
898 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
899 temp->Run();
900 };
901 callFunctionMap_["EventRunnerStop"] = []() {
902 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
903 temp->Stop();
904 };
905 callFunctionMap_["EventRunnerGetEventQueue"] = []() {
906 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
907 temp->GetEventQueue();
908 };
909 callFunctionMap_["EventRunnerGetCurrentEventQueue"] = []() {
910 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
911 temp->GetCurrentEventQueue();
912 };
913 callFunctionMap_["EventRunnerDump"] = []() {
914 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
915 TestDumper param;
916 temp->Dump(param);
917 };
918 callFunctionMap_["EventRunnerSetLogger"] = []() {
919 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
920 temp->SetLogger(GetParamLogger());
921 };
922 callFunctionMap_["EventRunnerGetThreadId"] = []() {
923 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
924 temp->GetThreadId();
925 };
926 callFunctionMap_["EventRunnerIsCurrentRunnerThread"] = []() {
927 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
928 temp->IsCurrentRunnerThread();
929 };
930 callFunctionMap_["EventRunnerGetMainEventRunner"] = []() {
931 std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
932 temp->GetMainEventRunner();
933 };
934 }
935
936 // RegisterFileDescriptorListener
RegisterFileDescriptorListener()937 void fuzzTestManager::RegisterFileDescriptorListener()
938 {
939 callFunctionMap_["FileDescriptorListenerOnReadable"] = []() {
940 std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
941 temp->OnReadable(GetS32Param());
942 };
943 callFunctionMap_["FileDescriptorListenerOnWritable"] = []() {
944 std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
945 temp->OnWritable(GetS32Param());
946 };
947 callFunctionMap_["FileDescriptorListenerOnShutdown"] = []() {
948 std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
949 temp->OnShutdown(GetS32Param());
950 };
951 callFunctionMap_["FileDescriptorListenerOnException"] = []() {
952 std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
953 temp->OnException(GetS32Param());
954 };
955 callFunctionMap_["FileDescriptorListenerGetOwner"] = []() {
956 std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
957 temp->GetOwner();
958 };
959 callFunctionMap_["FileDescriptorListenerSetOwner"] = []() {
960 std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
961 temp->SetOwner(GetParamEventHandler());
962 };
963 }
964
965 // RegisterInnerEvent
RegisterInnerEvent()966 void fuzzTestManager::RegisterInnerEvent()
967 {
968 callFunctionMap_["InnerEventGetuint32_tint64_t"] = []() {
969 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
970 temp->Get(GetU32Param(), GetS64Param());
971 };
972 callFunctionMap_["InnerEventGetuint32_tshared_ptr<T>int64_t"] = []() {
973 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
974 temp->Get<AppExecFwk::EventRunner>(GetU32Param(), GetParamEventRunner(), GetS64Param());
975 };
976 callFunctionMap_["InnerEventGetuint32_tstd::weak_ptr<T>int64_t"] = []() {
977 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
978 std::weak_ptr<int> wp = std::make_shared<int>(1);
979 temp->Get(GetU32Param(), wp, GetS64Param());
980 };
981
982 callFunctionMap_["InnerEventGetuint32_tunique_ptr<T, D>&&int64_t"] = []() {
983 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
984 std::unique_ptr<int> p(new int, std::default_delete<int>());
985 temp->Get(GetU32Param(), p, GetS64Param());
986 };
987
988 callFunctionMap_["InnerEventGetuint32_tunique_ptr<T, D>&int64_t"] = []() {
989 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
990 std::unique_ptr<int> p(new int, std::default_delete<int>());
991 temp->Get(GetU32Param(), p, GetS64Param());
992 };
993
994 callFunctionMap_["InnerEventGetuint32_tint64_tshared_ptr<T>"] = []() {
995 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
996 temp->Get<AppExecFwk::EventRunner>(GetU32Param(), GetS64Param(), GetParamEventRunner());
997 };
998
999 callFunctionMap_["InnerEventGetuint32_tint64_tweak_ptr<T>"] = []() {
1000 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1001 std::weak_ptr<int> wp = std::make_shared<int>(1);
1002 temp->Get(GetU32Param(), GetS64Param(), wp);
1003 };
1004
1005 callFunctionMap_["InnerEventGetuint32_tint64_tunique_ptr<T, D>&&"] = []() {
1006 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1007 std::unique_ptr<int> p(new int, std::default_delete<int>());
1008 temp->Get(GetU32Param(), GetS64Param(), p);
1009 };
1010 callFunctionMap_["InnerEventGetuint32_tint64_tunique_ptr<T, D>&"] = []() {
1011 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1012 std::unique_ptr<int> p(new int, std::default_delete<int>());
1013 temp->Get(GetU32Param(), GetS64Param(), p);
1014 };
1015 callFunctionMap_["InnerEventGetCallbackstring"] = []() {
1016 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1017 temp->Get(GetParamCallback(), GetStringParam());
1018 };
1019 callFunctionMap_["InnerEventGet"] = []() {
1020 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1021 temp->Get();
1022 };
1023 callFunctionMap_["InnerEventGetOwner"] = []() {
1024 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1025 temp->GetOwner();
1026 };
1027 callFunctionMap_["InnerEventSetOwner"] = []() {
1028 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1029 temp->SetOwner(GetParamEventHandler());
1030 };
1031 callFunctionMap_["InnerEventGetHandleTime"] = []() {
1032 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1033 temp->GetHandleTime();
1034 };
1035 callFunctionMap_["InnerEventSetHandleTime"] = []() {
1036 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1037 AppExecFwk::InnerEvent::TimePoint param = GetParamTimePoint();
1038 temp->SetHandleTime(param);
1039 };
1040 callFunctionMap_["InnerEventGetSendTime"] = []() {
1041 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1042 temp->GetSendTime();
1043 };
1044 callFunctionMap_["InnerEventSetSendTime"] = []() {
1045 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1046 AppExecFwk::InnerEvent::TimePoint param = GetParamTimePoint();
1047 temp->SetSendTime(param);
1048 };
1049 callFunctionMap_["InnerEventGetInnerEventId"] = []() {
1050 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1051 temp->GetInnerEventId();
1052 };
1053 callFunctionMap_["InnerEventGetParam"] = []() {
1054 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1055 temp->GetParam();
1056 };
1057 callFunctionMap_["InnerEventGetSharedObject"] = []() {
1058 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1059 temp->GetSharedObject<int>();
1060 };
1061 callFunctionMap_["InnerEventGetUniqueObject"] = []() {
1062 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1063 temp->GetUniqueObject<int>();
1064 };
1065 callFunctionMap_["InnerEventGetUniqueObject2"] = []() {
1066 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1067 using deleter = void (*)(uint32_t *);
1068 temp->GetUniqueObject<uint32_t, deleter>();
1069 };
1070 callFunctionMap_["InnerEventGetTaskName"] = []() {
1071 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1072 temp->GetTaskName();
1073 };
1074 callFunctionMap_["InnerEventGetTask"] = []() {
1075 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1076 temp->GetTask();
1077 };
1078 callFunctionMap_["InnerEventHasTask"] = []() {
1079 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1080 temp->HasTask();
1081 };
1082 callFunctionMap_["InnerEventDump"] = []() {
1083 std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1084 temp->Dump();
1085 };
1086 }
1087
1088 // RegisterEventRunnerNativeImplement
RegisterEventRunnerNativeImplement()1089 void fuzzTestManager::RegisterEventRunnerNativeImplement()
1090 {
1091 callFunctionMap_["EventRunnerNativeImplementGetEventRunnerNativeObj"] = []() {
1092 std::shared_ptr<EventRunnerNativeImplement> temp = GetParamEventRunnerNativeImplement();
1093 temp->GetEventRunnerNativeObj();
1094 };
1095 callFunctionMap_["EventRunnerNativeImplementCreateEventRunnerNativeObj"] = []() {
1096 std::shared_ptr<EventRunnerNativeImplement> temp = GetParamEventRunnerNativeImplement();
1097 temp->CreateEventRunnerNativeObj();
1098 };
1099 callFunctionMap_["EventRunnerNativeImplementStopEventRunnerNativeObj"] = []() {
1100 std::shared_ptr<EventRunnerNativeImplement> temp = GetParamEventRunnerNativeImplement();
1101 temp->StopEventRunnerNativeObj();
1102 };
1103 }
1104
1105 // RegisterAbilityManager
RegisterAbilityManager()1106 void fuzzTestManager::RegisterAbilityManager()
1107 {
1108 callFunctionMap_["AbilityManagerStartAbility"] = []() {
1109 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1110 temp->StartAbility(*(GetParamWant().get()), GetIntParam());
1111 };
1112 callFunctionMap_["AbilityManagerMoveMissionToTop"] = []() {
1113 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1114 temp->MoveMissionToTop(GetIntParam());
1115 };
1116 callFunctionMap_["AbilityManagerGetAllStackInfo"] = []() {
1117 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1118 temp->GetAllStackInfo();
1119 };
1120 callFunctionMap_["AbilityManagerQueryRecentAbilityMissionInfo"] = []() {
1121 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1122 temp->QueryRecentAbilityMissionInfo(GetIntParam(), GetIntParam());
1123 };
1124 callFunctionMap_["AbilityManagerQueryRunningAbilityMissionInfo"] = []() {
1125 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1126 temp->QueryRunningAbilityMissionInfo(GetIntParam());
1127 };
1128 callFunctionMap_["AbilityManagerQueryRunningAbilityMissionInfo2"] = []() {
1129 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1130 temp->QueryRunningAbilityMissionInfo(GetIntParam());
1131 };
1132 callFunctionMap_["AbilityManagerRemoveMissions"] = []() {
1133 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1134 temp->RemoveMissions(GetIntVectorParam());
1135 };
1136 callFunctionMap_["AbilityManagerClearUpApplicationData"] = []() {
1137 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1138 temp->ClearUpApplicationData(GetStringParam());
1139 };
1140 callFunctionMap_["AbilityManagerGetAllRunningProcesses"] = []() {
1141 std::shared_ptr<AppExecFwk::AbilityManager> temp = GetParamAbilityManager();
1142 temp->GetAllRunningProcesses();
1143 };
1144 }
1145
1146 // RegisterWantParams
RegisterWantParams()1147 void fuzzTestManager::RegisterWantParams()
1148 {
1149 callFunctionMap_["WantParamsoperator="] = []() {
1150 AAFwk::WantParams want1;
1151 AAFwk::WantParams want2;
1152 want1 = want2;
1153 };
1154
1155 callFunctionMap_["WantParamsGetParam"] = []() {
1156 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1157 temp->GetParam(GetStringParam());
1158 };
1159 callFunctionMap_["WantParamsGetParams"] = []() {
1160 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1161 temp->GetParams();
1162 };
1163 callFunctionMap_["WantParamsKeySet"] = []() {
1164 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1165 temp->KeySet();
1166 };
1167 callFunctionMap_["WantParamsRemove"] = []() {
1168 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1169 temp->Remove(GetStringParam());
1170 };
1171 callFunctionMap_["WantParamsHasParam"] = []() {
1172 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1173 temp->HasParam(GetStringParam());
1174 };
1175 callFunctionMap_["WantParamsSize"] = []() {
1176 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1177 temp->Size();
1178 };
1179 callFunctionMap_["WantParamsIsEmpty"] = []() {
1180 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1181 temp->IsEmpty();
1182 };
1183 callFunctionMap_["WantParamsMarshalling"] = []() {
1184 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1185 Parcel p;
1186 temp->Marshalling(p);
1187 };
1188 callFunctionMap_["WantParamsUnmarshalling"] = []() {
1189 std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1190 Parcel p;
1191 temp->Unmarshalling(p);
1192 };
1193 }
1194
1195 // bundle
RegisterBundleMgrProxy()1196 void fuzzTestManager::RegisterBundleMgrProxy()
1197 {
1198 callFunctionMap_["BundleMgrProxyGetApplicationInfo"] = []() {
1199 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1200 ApplicationInfo a;
1201 temp->GetApplicationInfo(GetStringParam(), GetParamApplicationFlag(), GetIntParam(), a);
1202 };
1203
1204 callFunctionMap_["BundleMgrProxyGetApplicationInfos"] = []() {
1205 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1206 std::vector<ApplicationInfo> a;
1207 temp->GetApplicationInfos(GetParamApplicationFlag(), GetIntParam(), a);
1208 };
1209
1210 callFunctionMap_["BundleMgrProxyGetBundleInfo"] = []() {
1211 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1212 BundleInfo a;
1213 temp->GetBundleInfo(GetStringParam(), GetParamBundleFlag(), a);
1214 };
1215
1216 callFunctionMap_["BundleMgrProxyGetBundleInfos"] = []() {
1217 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1218 std::vector<BundleInfo> a;
1219 temp->GetBundleInfos(GetParamBundleFlag(), a);
1220 };
1221
1222 callFunctionMap_["BundleMgrProxyGetUidByBundleName"] = []() {
1223 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1224 temp->GetUidByBundleName(GetStringParam(), GetIntParam());
1225 };
1226
1227 callFunctionMap_["BundleMgrProxyGetBundleNameForUid"] = []() {
1228 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1229 std::string a;
1230 temp->GetBundleNameForUid(GetIntParam(), a);
1231 };
1232
1233 callFunctionMap_["BundleMgrProxyGetBundleGids"] = []() {
1234 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1235 std::vector<int> a;
1236 temp->GetBundleGids(GetStringParam(), a);
1237 };
1238
1239 callFunctionMap_["BundleMgrProxyGetAppType"] = []() {
1240 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1241 temp->GetAppType(GetStringParam());
1242 };
1243
1244 callFunctionMap_["BundleMgrProxyCheckIsSystemAppByUid"] = []() {
1245 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1246 temp->GetAppType(GetStringParam());
1247 };
1248
1249 callFunctionMap_["BundleMgrProxyGetBundleInfosByMetaData"] = []() {
1250 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1251 std::vector<BundleInfo> a;
1252 temp->GetBundleInfosByMetaData(GetStringParam(), a);
1253 };
1254
1255 callFunctionMap_["BundleMgrProxyQueryAbilityInfo"] = []() {
1256 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1257 AbilityInfo a;
1258 Want want;
1259 temp->QueryAbilityInfo(want, a);
1260 };
1261
1262 callFunctionMap_["BundleMgrProxyQueryAbilityInfoByUri"] = []() {
1263 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1264 AbilityInfo a;
1265 temp->QueryAbilityInfoByUri(GetStringParam(), a);
1266 };
1267
1268 callFunctionMap_["BundleMgrProxyQueryKeepAliveBundleInfos"] = []() {
1269 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1270 std::vector<BundleInfo> a;
1271 temp->QueryKeepAliveBundleInfos(a);
1272 };
1273
1274 callFunctionMap_["BundleMgrProxyGetAbilityLabel"] = []() {
1275 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1276 temp->GetAbilityLabel(GetStringParam(), GetStringParam());
1277 };
1278
1279 callFunctionMap_["BundleMgrProxyGetBundleArchiveInfo"] = []() {
1280 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1281 BundleInfo a;
1282 temp->GetBundleArchiveInfo(GetStringParam(), GetParamBundleFlag(), a);
1283 };
1284
1285 callFunctionMap_["BundleMgrProxyGetHapModuleInfo"] = []() {
1286 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1287 HapModuleInfo moduleInfo;
1288 AbilityInfo abilityInfo;
1289 temp->GetHapModuleInfo(abilityInfo, moduleInfo);
1290 };
1291
1292 callFunctionMap_["BundleMgrProxyGetLaunchWantForBundle"] = []() {
1293 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1294 Want want;
1295 temp->GetLaunchWantForBundle(GetStringParam(), want);
1296 };
1297
1298 callFunctionMap_["BundleMgrProxyCheckPublicKeys"] = []() {
1299 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1300 temp->CheckPublicKeys(GetStringParam(), GetStringParam());
1301 };
1302
1303 callFunctionMap_["BundleMgrProxyCheckPermission"] = []() {
1304 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1305 temp->CheckPermission(GetStringParam(), GetStringParam());
1306 };
1307
1308 callFunctionMap_["BundleMgrProxyGetPermissionDef"] = []() {
1309 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1310 PermissionDef a;
1311 temp->GetPermissionDef(GetStringParam(), a);
1312 };
1313 callFunctionMap_["BundleMgrProxyGetAllPermissionGroupDefs"] = []() {
1314 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1315 std::vector<PermissionDef> a;
1316 temp->GetAllPermissionGroupDefs(a);
1317 };
1318
1319 callFunctionMap_["BundleMgrProxyGetAppsGrantedPermissions"] = []() {
1320 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1321 std::vector<std::string> a;
1322 temp->GetAppsGrantedPermissions(GetStringVectorParam(), a);
1323 };
1324
1325 callFunctionMap_["BundleMgrProxyGetSystemAvailableCapabilities"] = []() {
1326 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1327 std::vector<std::string> a;
1328 temp->GetSystemAvailableCapabilities(a);
1329 };
1330
1331 callFunctionMap_["BundleMgrProxyIsSafeMode"] = []() {
1332 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1333 temp->IsSafeMode();
1334 };
1335
1336 callFunctionMap_["BundleMgrProxyCleanBundleCacheFiles"] = []() {
1337 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1338 temp->CleanBundleCacheFiles(GetStringParam(), GetParamICleanCacheCallback());
1339 };
1340
1341 callFunctionMap_["BundleMgrProxyCleanBundleDataFiles"] = []() {
1342 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1343 temp->CleanBundleDataFiles(GetStringParam(), GetIntParam());
1344 };
1345
1346 callFunctionMap_["BundleMgrProxyRegisterBundleStatusCallback"] = []() {
1347 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1348 temp->RegisterBundleStatusCallback(GetParamIBundleStatusCallback());
1349 };
1350
1351 callFunctionMap_["BundleMgrProxyClearBundleStatusCallback"] = []() {
1352 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1353 temp->ClearBundleStatusCallback(GetParamIBundleStatusCallback());
1354 };
1355
1356 callFunctionMap_["BundleMgrProxyUnregisterBundleStatusCallback"] = []() {
1357 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1358 temp->UnregisterBundleStatusCallback();
1359 };
1360
1361 callFunctionMap_["BundleMgrProxyDumpInfos"] = []() {
1362 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1363 std::string a;
1364 temp->DumpInfos(GetParamDumpFlag(), GetStringParam(), 0, a);
1365 };
1366
1367 callFunctionMap_["BundleMgrProxyIsApplicationEnabled"] = []() {
1368 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1369 temp->IsApplicationEnabled(GetStringParam());
1370 };
1371
1372 callFunctionMap_["BundleMgrProxySetApplicationEnabled"] = []() {
1373 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1374 temp->SetApplicationEnabled(GetStringParam(), GetBoolParam());
1375 };
1376
1377 callFunctionMap_["BundleMgrProxyGetBundleInstaller"] = []() {
1378 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1379 temp->GetBundleInstaller();
1380 };
1381
1382 callFunctionMap_["BundleMgrProxyRequestPermissionFromUser"] = []() {
1383 std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1384 temp->RequestPermissionFromUser(GetStringParam(), GetStringParam(), GetIntParam());
1385 };
1386 }
1387
1388 // RegisterWant
RegisterWant()1389 void fuzzTestManager::RegisterWant()
1390 {
1391 callFunctionMap_["Wantoperator="] = []() {
1392 Want want1;
1393 Want want2;
1394 want1 = want2;
1395 };
1396 callFunctionMap_["WantSetFlags"] = []() {
1397 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1398 temp->SetFlags(GetUIntParam());
1399 };
1400 callFunctionMap_["WantGetFlags"] = []() {
1401 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1402 temp->GetFlags();
1403 };
1404 callFunctionMap_["WantAddFlags"] = []() {
1405 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1406 temp->AddFlags(GetUIntParam());
1407 };
1408 callFunctionMap_["WantRemoveFlags"] = []() {
1409 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1410 temp->RemoveFlags(GetUIntParam());
1411 };
1412 callFunctionMap_["WantSetElementName"] = []() {
1413 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1414 temp->SetElementName(GetStringParam(), GetStringParam());
1415 };
1416 callFunctionMap_["WantSetElementName2"] = []() {
1417 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1418 temp->SetElementName(GetStringParam(), GetStringParam(), GetStringParam());
1419 };
1420 callFunctionMap_["WantSetElement"] = []() {
1421 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1422 temp->SetElement(*(GetParamElementName()));
1423 };
1424 callFunctionMap_["WantGetElement"] = []() {
1425 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1426 temp->GetElement();
1427 };
1428 callFunctionMap_["WantMakeMainAbility"] = []() {
1429 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1430 temp->MakeMainAbility(*(GetParamElementName()));
1431 };
1432 callFunctionMap_["WantWantParseUri"] = []() {
1433 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1434 temp->WantParseUri(GetCharArryParam());
1435 };
1436 callFunctionMap_["WantParseUri"] = []() {
1437 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1438 temp->ParseUri(GetStringParam());
1439 };
1440 callFunctionMap_["WantGetUri"] = []() {
1441 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1442 temp->GetUri();
1443 };
1444 callFunctionMap_["WantGetUriString"] = []() {
1445 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1446 temp->GetUriString();
1447 };
1448 callFunctionMap_["WantSetUri"] = []() {
1449 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1450 temp->SetUri(GetStringParam());
1451 };
1452 callFunctionMap_["WantSetUri2"] = []() {
1453 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1454 temp->SetUri(GetParamUri());
1455 };
1456 callFunctionMap_["WantSetUriAndType"] = []() {
1457 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1458 temp->SetUriAndType(GetParamUri(), GetStringParam());
1459 };
1460 callFunctionMap_["WantWantToUri"] = []() {
1461 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1462 temp->WantToUri(*(GetParamWant().get()));
1463 };
1464 callFunctionMap_["WantToUri"] = []() {
1465 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1466 temp->ToUri();
1467 };
1468 callFunctionMap_["WantFormatUri"] = []() {
1469 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1470 temp->FormatUri(GetStringParam());
1471 };
1472 callFunctionMap_["WantFormatUri2"] = []() {
1473 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1474 temp->FormatUri(GetParamUri());
1475 };
1476 callFunctionMap_["WantGetAction"] = []() {
1477 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1478 temp->GetAction();
1479 };
1480 callFunctionMap_["WantSetAction"] = []() {
1481 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1482 temp->SetAction(GetStringParam());
1483 };
1484 callFunctionMap_["WantGetBundle"] = []() {
1485 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1486 temp->GetBundle();
1487 };
1488 callFunctionMap_["WantSetBundle"] = []() {
1489 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1490 temp->SetBundle(GetStringParam());
1491 };
1492 callFunctionMap_["WantGetEntities"] = []() {
1493 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1494 temp->GetEntities();
1495 };
1496 callFunctionMap_["WantAddEntity"] = []() {
1497 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1498 temp->AddEntity(GetStringParam());
1499 };
1500 callFunctionMap_["WantRemoveEntity"] = []() {
1501 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1502 temp->RemoveEntity(GetStringParam());
1503 };
1504 callFunctionMap_["WantHasEntity"] = []() {
1505 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1506 temp->HasEntity(GetStringParam());
1507 };
1508 callFunctionMap_["WantCountEntities"] = []() {
1509 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1510 temp->CountEntities();
1511 };
1512 callFunctionMap_["WantGetScheme"] = []() {
1513 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1514 temp->GetScheme();
1515 };
1516 callFunctionMap_["WantGetType"] = []() {
1517 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1518 temp->GetType();
1519 };
1520 callFunctionMap_["WantSetType"] = []() {
1521 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1522 temp->SetType(GetStringParam());
1523 };
1524 callFunctionMap_["WantFormatType"] = []() {
1525 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1526 temp->FormatType(GetStringParam());
1527 };
1528 callFunctionMap_["WantFormatUriAndType"] = []() {
1529 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1530 temp->FormatUriAndType(GetParamUri(), GetStringParam());
1531 };
1532 callFunctionMap_["WantFormatMimeType"] = []() {
1533 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1534 temp->FormatMimeType(GetStringParam());
1535 };
1536 callFunctionMap_["WantClearWant"] = []() {
1537 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1538 temp->ClearWant(GetParamWant().get());
1539 };
1540 callFunctionMap_["WantGetParams"] = []() {
1541 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1542 temp->GetParams();
1543 };
1544 callFunctionMap_["WantSetParams"] = []() {
1545 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1546 temp->SetParams(*(GetParamWantParams()));
1547 };
1548 callFunctionMap_["WantGetBoolParam"] = []() {
1549 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1550 temp->GetBoolParam(GetStringParam(), GetBoolParam());
1551 };
1552 callFunctionMap_["WantGetBoolArrayParam"] = []() {
1553 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1554 temp->GetBoolArrayParam(GetStringParam());
1555 };
1556 callFunctionMap_["WantSetParam"] = []() {
1557 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1558 temp->SetParam(GetStringParam(), GetBoolParam());
1559 };
1560 callFunctionMap_["WantSetParam2"] = []() {
1561 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1562 temp->SetParam(GetStringParam(), GetBoolVectorParam());
1563 };
1564 callFunctionMap_["WantGetByteParam"] = []() {
1565 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1566 temp->GetByteParam(GetStringParam(), GetCharParam());
1567 };
1568 callFunctionMap_["WantGetByteArrayParam"] = []() {
1569 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1570 temp->GetByteArrayParam(GetStringParam());
1571 };
1572 callFunctionMap_["WantSetParam3"] = []() {
1573 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1574 temp->SetParam(GetStringParam(), GetCharParam());
1575 };
1576 callFunctionMap_["WantSetParam4"] = []() {
1577 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1578 temp->SetParam(GetStringParam(), GetCharVectorParam());
1579 };
1580 callFunctionMap_["WantGetCharParam"] = []() {
1581 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1582 temp->GetCharParam(GetStringParam(), GetChar32Param());
1583 };
1584 callFunctionMap_["WantGetCharArrayParam"] = []() {
1585 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1586 temp->GetCharArrayParam(GetStringParam());
1587 };
1588 callFunctionMap_["WantSetParam5"] = []() {
1589 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1590 temp->SetParam(GetStringParam(), GetChar32Param());
1591 };
1592 callFunctionMap_["WantSetParam6"] = []() {
1593 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1594 temp->SetParam(GetStringParam(), GetChar32VectorParam());
1595 };
1596 callFunctionMap_["WantGetIntParam"] = []() {
1597 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1598 temp->GetIntParam(GetStringParam(), GetIntParam());
1599 };
1600 callFunctionMap_["WantGetIntArrayParam"] = []() {
1601 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1602 temp->GetIntArrayParam(GetStringParam());
1603 };
1604 callFunctionMap_["WantSetParam7"] = []() {
1605 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1606 temp->SetParam(GetStringParam(), GetIntParam());
1607 };
1608 callFunctionMap_["WantSetParam8"] = []() {
1609 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1610 temp->SetParam(GetStringParam(), GetIntVectorParam());
1611 };
1612 callFunctionMap_["WantGetDoubleParam"] = []() {
1613 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1614 temp->GetDoubleParam(GetStringParam(), GetDoubleParam());
1615 };
1616 callFunctionMap_["WantGetDoubleArrayParam"] = []() {
1617 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1618 temp->GetDoubleArrayParam(GetStringParam());
1619 };
1620 callFunctionMap_["WantSetParam9"] = []() {
1621 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1622 temp->SetParam(GetStringParam(), GetDoubleParam());
1623 };
1624 callFunctionMap_["WantSetParam10"] = []() {
1625 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1626 temp->SetParam(GetStringParam(), GetDoubleVectorParam());
1627 };
1628 callFunctionMap_["WantGetFloatParam"] = []() {
1629 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1630 temp->GetFloatParam(GetStringParam(), GetFloatParam());
1631 };
1632 callFunctionMap_["WantGetFloatArrayParam"] = []() {
1633 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1634 temp->GetFloatArrayParam(GetStringParam());
1635 };
1636 callFunctionMap_["WantSetParam11"] = []() {
1637 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1638 temp->SetParam(GetStringParam(), GetFloatParam());
1639 };
1640 callFunctionMap_["WantSetParam12"] = []() {
1641 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1642 temp->SetParam(GetStringParam(), GetFloatVectorParam());
1643 };
1644 callFunctionMap_["WantGetLongParam"] = []() {
1645 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1646 temp->GetLongParam(GetStringParam(), GetLongParam());
1647 };
1648 callFunctionMap_["WantGetLongArrayParam"] = []() {
1649 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1650 temp->GetLongArrayParam(GetStringParam());
1651 };
1652 callFunctionMap_["WantSetParam13"] = []() {
1653 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1654 temp->SetParam(GetStringParam(), GetLongParam());
1655 };
1656 callFunctionMap_["WantSetParam14"] = []() {
1657 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1658 temp->SetParam(GetStringParam(), GetLongVectorParam());
1659 };
1660 callFunctionMap_["WantGetShortParam"] = []() {
1661 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1662 temp->GetShortParam(GetStringParam(), GetShortParam());
1663 };
1664 callFunctionMap_["WantGetShortArrayParam"] = []() {
1665 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1666 temp->GetShortArrayParam(GetStringParam());
1667 };
1668 callFunctionMap_["WantSetParam15"] = []() {
1669 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1670 temp->SetParam(GetStringParam(), GetShortParam());
1671 };
1672 callFunctionMap_["WantSetParam16"] = []() {
1673 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1674 temp->SetParam(GetStringParam(), GetShortVectorParam());
1675 };
1676 callFunctionMap_["WantGetStringParam"] = []() {
1677 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1678 temp->GetStringParam(GetStringParam());
1679 };
1680 callFunctionMap_["WantGetStringArrayParam"] = []() {
1681 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1682 temp->GetStringArrayParam(GetStringParam());
1683 };
1684 callFunctionMap_["WantSetParam17"] = []() {
1685 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1686 temp->SetParam(GetStringParam(), GetStringParam());
1687 };
1688 callFunctionMap_["WantSetParam18"] = []() {
1689 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1690 temp->SetParam(GetStringParam(), GetStringVectorParam());
1691 };
1692 callFunctionMap_["WantHasParameter"] = []() {
1693 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1694 temp->HasParameter(GetStringParam());
1695 };
1696 callFunctionMap_["WantReplaceParams"] = []() {
1697 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1698 temp->ReplaceParams(*(GetParamWantParams().get()));
1699 };
1700 callFunctionMap_["WantReplaceParams2"] = []() {
1701 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1702 temp->ReplaceParams(*(GetParamWant().get()));
1703 };
1704 callFunctionMap_["WantRemoveParam"] = []() {
1705 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1706 temp->RemoveParam(GetStringParam());
1707 };
1708 callFunctionMap_["WantGetOperation"] = []() {
1709 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1710 temp->GetOperation();
1711 };
1712 callFunctionMap_["WantSetOperation"] = []() {
1713 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1714 temp->SetOperation(GetParamOperation());
1715 };
1716 callFunctionMap_["WantOperationEquals"] = []() {
1717 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1718 temp->OperationEquals(*(GetParamWant().get()));
1719 };
1720 callFunctionMap_["WantCloneOperation"] = []() {
1721 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1722 temp->CloneOperation();
1723 };
1724 callFunctionMap_["WantMarshalling"] = []() {
1725 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1726 Parcel p;
1727 temp->Marshalling(p);
1728 };
1729 callFunctionMap_["WantUnmarshalling"] = []() {
1730 std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1731 Parcel p;
1732 temp->Unmarshalling(p);
1733 };
1734 }
1735
1736 // RegisterElementName
RegisterElementName()1737 void fuzzTestManager::RegisterElementName()
1738 {
1739 callFunctionMap_["ElementNameGetURI"] = []() {
1740 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1741 temp->GetURI();
1742 };
1743 callFunctionMap_["ElementNameoperator=="] = []() {
1744 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1745 std::shared_ptr<AppExecFwk::ElementName> temp2 = GetParamElementName();
1746 if (*temp == *temp2) {
1747 return;
1748 };
1749 };
1750 callFunctionMap_["ElementNameSetDeviceID"] = []() {
1751 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1752 temp->SetDeviceID(GetStringParam());
1753 };
1754 callFunctionMap_["ElementNameGetDeviceID"] = []() {
1755 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1756 temp->GetDeviceID();
1757 };
1758 callFunctionMap_["ElementNameSetBundleName"] = []() {
1759 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1760 temp->SetBundleName(GetStringParam());
1761 };
1762 callFunctionMap_["ElementNameGetBundleName"] = []() {
1763 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1764 temp->GetBundleName();
1765 };
1766 callFunctionMap_["ElementNameSetAbilityName"] = []() {
1767 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1768 temp->SetAbilityName(GetStringParam());
1769 };
1770 callFunctionMap_["ElementNameGetAbilityName"] = []() {
1771 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1772 temp->GetAbilityName();
1773 };
1774 callFunctionMap_["ElementNameReadFromParcel"] = []() {
1775 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1776 Parcel p;
1777 temp->ReadFromParcel(p);
1778 };
1779 callFunctionMap_["ElementNameMarshalling"] = []() {
1780 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1781 Parcel p;
1782 temp->Marshalling(p);
1783 };
1784 callFunctionMap_["ElementNameUnmarshalling"] = []() {
1785 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1786 Parcel p;
1787 temp->Unmarshalling(p);
1788 };
1789 callFunctionMap_["ElementNameSetElementDeviceID"] = []() {
1790 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1791 temp->SetElementDeviceID(GetParamElementName().get(), GetCharArryParam());
1792 };
1793 callFunctionMap_["ElementNameSetElementBundleName"] = []() {
1794 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1795 temp->SetElementBundleName(GetParamElementName().get(), GetCharArryParam());
1796 };
1797 callFunctionMap_["ElementNameSetElementAbilityName"] = []() {
1798 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1799 temp->SetElementAbilityName(GetParamElementName().get(), GetCharArryParam());
1800 };
1801 callFunctionMap_["ElementNameClearElement"] = []() {
1802 std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1803 temp->ClearElement(GetParamElementName().get());
1804 };
1805 }
1806
RegisterOHOSApplication()1807 void fuzzTestManager::RegisterOHOSApplication()
1808 {
1809 callFunctionMap_.emplace("OHOSApplicationDumpApplication", []() {
1810 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1811 temp->DumpApplication();
1812 });
1813
1814 callFunctionMap_.emplace("OHOSApplicationSetAbilityRecordMgr", []() {
1815 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1816 auto ar = std::make_shared<OHOS::AppExecFwk::AbilityRecordMgr>();
1817 temp->SetAbilityRecordMgr(ar);
1818 });
1819
1820 callFunctionMap_.emplace("OHOSApplicationRegisterAbilityLifecycleCallbacks", []() {
1821 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1822 temp->RegisterAbilityLifecycleCallbacks(std::shared_ptr<OHOS::AppExecFwk::AbilityLifecycleCallbacks>(nullptr));
1823 });
1824
1825 callFunctionMap_.emplace("OHOSApplicationUnregisterAbilityLifecycleCallbacks", []() {
1826 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1827 temp->UnregisterAbilityLifecycleCallbacks(
1828 std::shared_ptr<OHOS::AppExecFwk::AbilityLifecycleCallbacks>(nullptr));
1829 });
1830
1831 callFunctionMap_.emplace("OHOSApplicationOnAbilityStart", []() {
1832 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1833 temp->OnAbilityStart(GetParamAbility());
1834 });
1835
1836 callFunctionMap_.emplace("OHOSApplicationOnAbilityInactive", []() {
1837 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1838 temp->OnAbilityInactive(GetParamAbility());
1839 });
1840
1841 callFunctionMap_.emplace("OHOSApplicationOnAbilityBackground", []() {
1842 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1843 temp->OnAbilityBackground(GetParamAbility());
1844 });
1845
1846 callFunctionMap_.emplace("OHOSApplicationOnAbilityForeground", []() {
1847 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1848 temp->OnAbilityForeground(GetParamAbility());
1849 });
1850
1851 callFunctionMap_.emplace("OHOSApplicationOnAbilityActive", []() {
1852 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1853 temp->OnAbilityActive(GetParamAbility());
1854 });
1855
1856 callFunctionMap_.emplace("OHOSApplicationOnAbilityStop", []() {
1857 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1858 temp->OnAbilityStop(GetParamAbility());
1859 });
1860
1861 callFunctionMap_.emplace("OHOSApplicationDispatchAbilitySavedState", []() {
1862 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1863 temp->DispatchAbilitySavedState(GetParamPacMap());
1864 });
1865
1866 callFunctionMap_.emplace("OHOSApplicationOnAbilitySaveState", []() {
1867 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1868 temp->OnAbilitySaveState(GetParamPacMap());
1869 });
1870
1871 callFunctionMap_.emplace("OHOSApplicationRegisterElementsCallbacks", []() {
1872 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1873 temp->RegisterElementsCallbacks(std::shared_ptr<OHOS::AppExecFwk::ElementsCallback>(nullptr));
1874 });
1875
1876 callFunctionMap_.emplace("OHOSApplicationUnregisterElementsCallbacks", []() {
1877 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1878 temp->UnregisterElementsCallbacks(std::shared_ptr<OHOS::AppExecFwk::ElementsCallback>(nullptr));
1879 });
1880
1881 callFunctionMap_.emplace("OHOSApplicationOnConfigurationUpdated", []() {
1882 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1883 temp->OnConfigurationUpdated(OHOS::AppExecFwk::Configuration());
1884 });
1885
1886 callFunctionMap_.emplace("OHOSApplicationOnMemoryLevel", []() {
1887 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1888 temp->OnMemoryLevel(GetIntParam());
1889 });
1890
1891 callFunctionMap_.emplace("OHOSApplicationOnForeground", []() {
1892 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1893 temp->OnForeground();
1894 });
1895
1896 callFunctionMap_.emplace("OHOSApplicationOnBackground", []() {
1897 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1898 temp->OnBackground();
1899 });
1900
1901 callFunctionMap_.emplace("OHOSApplicationOnStart", []() {
1902 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> temp = GetParamOHOSApplication();
1903 temp->OnStart();
1904 });
1905 }
1906
RegisterAbility()1907 void fuzzTestManager::RegisterAbility()
1908 {
1909 const int COLOR_R = 100;
1910 const int COLOR_G = 100;
1911 const int COLOR_B = 100;
1912
1913 callFunctionMap_.emplace("AbilityTerminateAbilityWant", []() {
1914 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1915 OHOS::AAFwk::Want param;
1916 temp->TerminateAbility(param);
1917 });
1918
1919 callFunctionMap_.emplace("AbilityAddActionRoute", []() {
1920 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1921 temp->AddActionRoute("", "");
1922 });
1923
1924 callFunctionMap_.emplace("AbilitySetWindowBackgroundColor", []() {
1925 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1926 temp->SetWindowBackgroundColor(COLOR_R, COLOR_G, COLOR_B);
1927 });
1928
1929 callFunctionMap_.emplace("AbilityTerminateAbility", []() {
1930 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1931 temp->TerminateAbility();
1932 });
1933
1934 callFunctionMap_.emplace("AbilityGetLifecycle", []() {
1935 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1936 temp->GetLifecycle();
1937 });
1938
1939 callFunctionMap_.emplace("AbilityGetResourceManager", []() {
1940 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1941 temp->GetResourceManager();
1942 });
1943
1944 callFunctionMap_.emplace("AbilitySetUIContentCC", []() {
1945 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1946 temp->SetUIContent(OHOS::AppExecFwk::ComponentContainer());
1947 });
1948
1949 callFunctionMap_.emplace("AbilitySetUIContentlayoutRes", []() {
1950 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1951 temp->SetUIContent(GetIntParam());
1952 });
1953
1954 callFunctionMap_.emplace("AbilityStartAbilityForResultWi", []() {
1955 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1956 temp->StartAbilityForResult(OHOS::AAFwk::Want(), GetIntParam());
1957 });
1958
1959 callFunctionMap_.emplace("AbilityStartAbilityForResultWiA", []() {
1960 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1961 temp->StartAbilityForResult(OHOS::AAFwk::Want(), GetIntParam(), OHOS::AppExecFwk::AbilityStartSetting());
1962 });
1963
1964 callFunctionMap_.emplace("AbilityStartAbility", []() {
1965 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1966 temp->StartAbility(OHOS::AAFwk::Want(), OHOS::AppExecFwk::AbilityStartSetting());
1967 });
1968
1969 callFunctionMap_.emplace("AbilityInitAOAI", []() {
1970 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1971
1972 auto server = sptr<OHOS::AppExecFwk::AbilityThread>(new OHOS::AppExecFwk::AbilityThread());
1973 auto ah = std::make_shared<OHOS::AppExecFwk::AbilityHandler>(OHOS::AppExecFwk::EventRunner::Create(), server);
1974 temp->Init(std::make_shared<OHOS::AppExecFwk::AbilityInfo>(),
1975 std::make_shared<OHOS::AppExecFwk::OHOSApplication>(),
1976 ah,
1977 sptr<IRemoteObject>());
1978 });
1979
1980 callFunctionMap_.emplace("AbilityOnStart", []() {
1981 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1982 temp->OnStart(OHOS::AAFwk::Want());
1983 });
1984
1985 callFunctionMap_.emplace("AbilityOnStop", []() {
1986 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1987 temp->OnStop();
1988 });
1989
1990 callFunctionMap_.emplace("AbilityOnActive", []() {
1991 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1992 temp->OnActive();
1993 });
1994
1995 callFunctionMap_.emplace("AbilityOnInactive", []() {
1996 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
1997 temp->OnInactive();
1998 });
1999
2000 callFunctionMap_.emplace("AbilityOnForeground", []() {
2001 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2002 temp->OnForeground(OHOS::AAFwk::Want());
2003 });
2004
2005 callFunctionMap_.emplace("AbilityOnBackground", []() {
2006 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2007 temp->OnBackground();
2008 });
2009
2010 callFunctionMap_.emplace("AbilityOnKeyDown", []() {
2011 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2012 temp->OnKeyDown(MMI::KeyEvent::Create());
2013 });
2014
2015 callFunctionMap_.emplace("AbilityOnKeyUp", []() {
2016 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2017 temp->OnKeyUp(MMI::KeyEvent::Create());
2018 });
2019
2020 callFunctionMap_.emplace("AbilityOnConnect", []() {
2021 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2022 temp->OnConnect(OHOS::AAFwk::Want());
2023 });
2024
2025 callFunctionMap_.emplace("AbilityOnDisconnect", []() {
2026 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2027 temp->OnDisconnect(OHOS::AAFwk::Want());
2028 });
2029
2030 callFunctionMap_.emplace("AbilitySetUIContentCCi", []() {
2031 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2032 std::shared_ptr<OHOS::AppExecFwk::Context> con = std::make_shared<OHOS::AppExecFwk::Ability>();
2033 temp->SetUIContent(OHOS::AppExecFwk::ComponentContainer(), con, GetIntParam());
2034 });
2035
2036 callFunctionMap_.emplace("AbilitySetUIContentlCi", []() {
2037 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2038 std::shared_ptr<OHOS::AppExecFwk::Context> con = std::make_shared<OHOS::AppExecFwk::Ability>();
2039 temp->SetUIContent(GetIntParam(), con, GetIntParam());
2040 });
2041
2042 callFunctionMap_.emplace("AbilityHasWindowFocus", []() {
2043 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2044 temp->HasWindowFocus();
2045 });
2046
2047 callFunctionMap_.emplace("AbilityOnKeyPressAndHold", []() {
2048 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2049 temp->OnKeyPressAndHold(1, std::shared_ptr<KeyEvent>());
2050 });
2051
2052 callFunctionMap_.emplace("AbilityOnRequestPermissionsFromUserResult", []() {
2053 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2054 temp->OnRequestPermissionsFromUserResult(1, std::vector<std::string>(), std::vector<int>());
2055 });
2056
2057 callFunctionMap_.emplace("AbilityOnLeaveForeground", []() {
2058 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2059 temp->OnLeaveForeground();
2060 });
2061
2062 callFunctionMap_.emplace("AbilityGetType", []() {
2063 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2064 temp->GetType(GetParamUri());
2065 });
2066
2067 callFunctionMap_.emplace("AbilityInsert", []() {
2068 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2069 temp->Insert(GetParamUri(), NativeRdb::ValuesBucket());
2070 });
2071
2072 callFunctionMap_.emplace("AbilityOnConfigurationUpdated", []() {
2073 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2074 temp->OnConfigurationUpdated(OHOS::AppExecFwk::Configuration());
2075 });
2076
2077 callFunctionMap_.emplace("AbilityOnMemoryLevel", []() {
2078 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2079 temp->OnMemoryLevel(GetIntParam());
2080 });
2081
2082 callFunctionMap_.emplace("AbilityOpenRawFile", []() {
2083 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2084 temp->OpenRawFile(GetParamUri(), std::string());
2085 });
2086
2087 callFunctionMap_.emplace("AbilityUpdate", []() {
2088 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2089 temp->Update(GetParamUri(), NativeRdb::ValuesBucket(), GetParamDataAbilityPredicates());
2090 });
2091
2092 callFunctionMap_.emplace("AbilityGetApplication", []() {
2093 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2094 temp->GetApplication();
2095 });
2096
2097 callFunctionMap_.emplace("AbilityGetAbilityName", []() {
2098 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2099 temp->GetAbilityName();
2100 });
2101
2102 callFunctionMap_.emplace("AbilityIsTerminating", []() {
2103 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2104 temp->IsTerminating();
2105 });
2106
2107 callFunctionMap_.emplace("AbilityOnAbilityResult", []() {
2108 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2109 temp->OnAbilityResult(GetIntParam(), GetIntParam(), OHOS::AAFwk::Want());
2110 });
2111
2112 callFunctionMap_.emplace("AbilityOnBackPressed", []() {
2113 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2114 temp->OnBackPressed();
2115 });
2116
2117 callFunctionMap_.emplace("AbilityOnNewWant", []() {
2118 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2119 temp->OnNewWant(OHOS::AAFwk::Want());
2120 });
2121
2122 callFunctionMap_.emplace("AbilityOnRestoreAbilityState", []() {
2123 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2124 temp->OnRestoreAbilityState(GetParamPacMap());
2125 });
2126
2127 callFunctionMap_.emplace("AbilityOnSaveAbilityState", []() {
2128 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2129 auto pm = GetParamPacMap();
2130 temp->OnSaveAbilityState(pm);
2131 });
2132
2133 callFunctionMap_.emplace("AbilityOnEventDispatch", []() {
2134 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2135 temp->OnEventDispatch();
2136 });
2137
2138 callFunctionMap_.emplace("AbilityOnWindowFocusChanged", []() {
2139 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2140 temp->OnWindowFocusChanged(GetBoolParam());
2141 });
2142
2143 callFunctionMap_.emplace("AbilitySetWant", []() {
2144 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2145 temp->SetWant(OHOS::AAFwk::Want());
2146 });
2147
2148 callFunctionMap_.emplace("AbilityGetWant", []() {
2149 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2150 temp->GetWant();
2151 });
2152
2153 callFunctionMap_.emplace("AbilitySetResult", []() {
2154 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2155 temp->SetResult(GetIntParam(), OHOS::AAFwk::Want());
2156 });
2157
2158 callFunctionMap_.emplace("AbilitySetVolumeTypeAdjustedByKey", []() {
2159 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2160 temp->SetVolumeTypeAdjustedByKey(GetIntParam());
2161 });
2162
2163 callFunctionMap_.emplace("AbilityOnCommand", []() {
2164 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2165 temp->OnCommand(OHOS::AAFwk::Want(), GetBoolParam(), GetIntParam());
2166 });
2167
2168 callFunctionMap_.emplace("AbilityDump", []() {
2169 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2170 temp->Dump("info");
2171 });
2172
2173 callFunctionMap_.emplace("AbilityKeepBackgroundRunning", []() {
2174 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2175 temp->KeepBackgroundRunning(GetIntParam(), OHOS::AppExecFwk::NotificationRequest());
2176 });
2177
2178 callFunctionMap_.emplace("AbilityCancelBackgroundRunning", []() {
2179 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2180 temp->CancelBackgroundRunning();
2181 });
2182
2183 callFunctionMap_.emplace("AbilityNormalizeUri", []() {
2184 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2185 temp->NormalizeUri(GetParamUri());
2186 });
2187
2188 callFunctionMap_.emplace("AbilityDelete", []() {
2189 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2190 temp->Delete(GetParamUri(), GetParamDataAbilityPredicates());
2191 });
2192
2193 callFunctionMap_.emplace("AbilityGetFileTypes", []() {
2194 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2195 temp->GetFileTypes(GetParamUri(), "* /jpg");
2196 });
2197
2198 callFunctionMap_.emplace("AbilityOpenFile", []() {
2199 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2200 temp->OpenFile(GetParamUri(), "r");
2201 });
2202
2203 callFunctionMap_.emplace("AbilityQuery", []() {
2204 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2205 temp->Query(GetParamUri(), std::vector<std::string>(), GetParamDataAbilityPredicates());
2206 });
2207
2208 callFunctionMap_.emplace("AbilitySetMainRoute", []() {
2209 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2210 temp->SetMainRoute("");
2211 });
2212
2213 callFunctionMap_.emplace("AbilityContinueAbilityReversiblyS", []() {
2214 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2215 temp->ContinueAbilityReversibly("id");
2216 });
2217
2218 callFunctionMap_.emplace("AbilityGetOriginalDeviceId", []() {
2219 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2220 temp->GetOriginalDeviceId();
2221 });
2222
2223 callFunctionMap_.emplace("AbilityGetContinuationState", []() {
2224 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2225 temp->GetContinuationState();
2226 });
2227
2228 callFunctionMap_.emplace("AbilityGetAbilityPackage", []() {
2229 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2230 temp->GetAbilityPackage();
2231 });
2232
2233 callFunctionMap_.emplace("AbilityDenormalizeUri", []() {
2234 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2235 temp->DenormalizeUri(GetParamUri());
2236 });
2237
2238 callFunctionMap_.emplace("AbilityReload", []() {
2239 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2240 temp->Reload(GetParamUri(), GetParamPacMap());
2241 });
2242
2243 callFunctionMap_.emplace("AbilityBatchInsert", []() {
2244 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2245 temp->BatchInsert(GetParamUri(), std::vector<NativeRdb::ValuesBucket>());
2246 });
2247
2248 callFunctionMap_.emplace("AbilityGetVolumeTypeAdjustedByKey", []() {
2249 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2250 temp->GetVolumeTypeAdjustedByKey();
2251 });
2252
2253 callFunctionMap_.emplace("AbilityGetState", []() {
2254 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2255 temp->GetState();
2256 });
2257
2258 callFunctionMap_.emplace("AbilityStartAbilityW", []() {
2259 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2260 temp->StartAbility(OHOS::AAFwk::Want());
2261 });
2262
2263 callFunctionMap_.emplace("AbilityConnectAbility", []() {
2264 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2265 temp->ConnectAbility(OHOS::AAFwk::Want(), sptr<AAFwk::IAbilityConnection>());
2266 });
2267
2268 callFunctionMap_.emplace("AbilityDisconnectAbility", []() {
2269 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2270 temp->DisconnectAbility(sptr<AAFwk::IAbilityConnection>());
2271 });
2272
2273 callFunctionMap_.emplace("AbilityStopAbility", []() {
2274 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2275 temp->StopAbility(OHOS::AAFwk::Want());
2276 });
2277
2278 callFunctionMap_.emplace("AbilityPostTask", []() {
2279 std::shared_ptr<OHOS::AppExecFwk::Ability> temp = GetParamAbility();
2280 temp->PostTask([]() {}, GetIntParam());
2281 });
2282 }
2283
RegisterDataAbilityHelper()2284 void fuzzTestManager::RegisterDataAbilityHelper()
2285 {
2286 callFunctionMap_.emplace("DataAbilityHelperRelease", []() {
2287 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2288 temp->Release();
2289 });
2290
2291 callFunctionMap_.emplace("DataAbilityHelperGetFileTypes", []() {
2292 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2293 auto uri = GetParamUri();
2294 temp->GetFileTypes(uri, "* /jpg");
2295 });
2296
2297 callFunctionMap_.emplace("DataAbilityHelperOpenFile", []() {
2298 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2299 auto uri = GetParamUri();
2300 temp->OpenFile(uri, "r");
2301 });
2302
2303 callFunctionMap_.emplace("DataAbilityHelperOpenRawFile", []() {
2304 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2305 auto uri = GetParamUri();
2306 temp->OpenRawFile(uri, "r");
2307 });
2308
2309 callFunctionMap_.emplace("DataAbilityHelperInsert", []() {
2310 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2311 auto uri = GetParamUri();
2312 temp->Insert(uri, NativeRdb::ValuesBucket());
2313 });
2314
2315 callFunctionMap_.emplace("DataAbilityHelperUpdate", []() {
2316 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2317 auto uri = GetParamUri();
2318 temp->Update(uri, NativeRdb::ValuesBucket(), GetParamDataAbilityPredicates());
2319 });
2320
2321 callFunctionMap_.emplace("DataAbilityHelperDelete", []() {
2322 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2323 auto uri = GetParamUri();
2324 temp->Delete(uri, GetParamDataAbilityPredicates());
2325 });
2326
2327 callFunctionMap_.emplace("DataAbilityHelperQuery", []() {
2328 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2329 auto uri = GetParamUri();
2330 std::vector<std::string> columns {};
2331 temp->Query(uri, columns, GetParamDataAbilityPredicates());
2332 });
2333
2334 callFunctionMap_.emplace("DataAbilityHelperGetType", []() {
2335 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2336 auto uri = GetParamUri();
2337 temp->GetType(uri);
2338 });
2339
2340 callFunctionMap_.emplace("DataAbilityHelperReload", []() {
2341 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2342 auto uri = GetParamUri();
2343 temp->Reload(uri, GetParamPacMap());
2344 });
2345
2346 callFunctionMap_.emplace("DataAbilityHelperBatchInsert", []() {
2347 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> temp = GetParamDataAbilityHelper();
2348 auto uri = GetParamUri();
2349 std::vector<NativeRdb::ValuesBucket> values {};
2350 temp->BatchInsert(uri, values);
2351 });
2352 }
2353
RegisterDataUriUtils()2354 void fuzzTestManager::RegisterDataUriUtils()
2355 {
2356 callFunctionMap_.emplace(
2357 "DataUriUtilsAttachId", []() { OHOS::AppExecFwk::DataUriUtils::AttachId(GetParamUri(), GetIntParam()); });
2358
2359 callFunctionMap_.emplace("DataUriUtilsGetId", []() { OHOS::AppExecFwk::DataUriUtils::GetId(GetParamUri()); });
2360
2361 callFunctionMap_.emplace("DataUriUtilsDeleteId", []() { OHOS::AppExecFwk::DataUriUtils::DeleteId(GetParamUri()); });
2362
2363 callFunctionMap_.emplace(
2364 "DataUriUtilsUpdateId", []() { OHOS::AppExecFwk::DataUriUtils::UpdateId(GetParamUri(), GetIntParam()); });
2365
2366 callFunctionMap_.emplace(
2367 "DataUriUtilsIsAttachedId", []() { OHOS::AppExecFwk::DataUriUtils::IsAttachedId(GetParamUri()); });
2368
2369 callFunctionMap_.emplace("DataUriUtilsIsNumber", []() { OHOS::AppExecFwk::DataUriUtils::IsNumber("a1"); });
2370
2371 callFunctionMap_.emplace(
2372 "DataUriUtilsUriUpateLastPath", []() { OHOS::AppExecFwk::DataUriUtils::UriUpateLastPath(GetParamUri(), "1"); });
2373 }
2374
RegisterLifeCycle()2375 void fuzzTestManager::RegisterLifeCycle()
2376 {
2377 callFunctionMap_.emplace("LifeCycleGetLifecycleState", []() {
2378 std::shared_ptr<OHOS::AppExecFwk::LifeCycle> temp = GetParamLifeCycle();
2379 temp->GetLifecycleState();
2380 });
2381
2382 callFunctionMap_.emplace("LifeCycleAddObserver", []() {
2383 std::shared_ptr<OHOS::AppExecFwk::LifeCycle> temp = GetParamLifeCycle();
2384 temp->AddObserver(nullptr);
2385 });
2386
2387 callFunctionMap_.emplace("LifeCycleDispatchLifecycleEW", []() {
2388 std::shared_ptr<OHOS::AppExecFwk::LifeCycle> temp = GetParamLifeCycle();
2389 temp->DispatchLifecycle(GetParamLifeCycleEvent(), OHOS::AppExecFwk::Want());
2390 });
2391
2392 callFunctionMap_.emplace("LifeCycleDispatchLifecycleE", []() {
2393 std::shared_ptr<OHOS::AppExecFwk::LifeCycle> temp = GetParamLifeCycle();
2394 temp->DispatchLifecycle(GetParamLifeCycleEvent());
2395 });
2396
2397 callFunctionMap_.emplace("LifeCycleRemoveObserver", []() {
2398 std::shared_ptr<OHOS::AppExecFwk::LifeCycle> temp = GetParamLifeCycle();
2399 temp->RemoveObserver(nullptr);
2400 });
2401 }
2402
RegisterAbilityContext()2403 void fuzzTestManager::RegisterAbilityContext()
2404 {
2405 callFunctionMap_.emplace("AbilityContextGetExternalCacheDir", []() {
2406 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2407 temp->GetExternalCacheDir();
2408 });
2409
2410 callFunctionMap_.emplace("AbilityContextGetExternalFilesDir", []() {
2411 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2412 std::string t {};
2413 temp->GetExternalFilesDir(t);
2414 });
2415
2416 callFunctionMap_.emplace("AbilityContextGetFilesDir", []() {
2417 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2418 temp->GetFilesDir();
2419 });
2420
2421 callFunctionMap_.emplace("AbilityContextGetNoBackupFilesDir", []() {
2422 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2423 temp->GetNoBackupFilesDir();
2424 });
2425
2426 callFunctionMap_.emplace("AbilityContextUnauthUriPermission", []() {
2427 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2428 temp->UnauthUriPermission("", GetParamUri(), GetIntParam());
2429 });
2430
2431 callFunctionMap_.emplace("AbilityContextGetDistributedDir", []() {
2432 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2433 temp->GetDistributedDir();
2434 });
2435
2436 callFunctionMap_.emplace("AbilityContextSetPattern", []() {
2437 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2438 temp->SetPattern(GetIntParam());
2439 });
2440
2441 callFunctionMap_.emplace("AbilityContextGetAbilityPackageContext", []() {
2442 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2443 temp->GetAbilityPackageContext();
2444 });
2445
2446 callFunctionMap_.emplace("AbilityContextGetProcessName", []() {
2447 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2448 temp->GetProcessName();
2449 });
2450
2451 callFunctionMap_.emplace("AbilityContextStartAbilityWi", []() {
2452 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2453 OHOS::AAFwk::Want param;
2454 temp->StartAbility(param, GetIntParam());
2455 });
2456
2457 callFunctionMap_.emplace("AbilityContextStartAbilityWiA", []() {
2458 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2459 OHOS::AAFwk::Want param1;
2460 OHOS::AppExecFwk::AbilityStartSetting param2;
2461 temp->StartAbility(param1, GetIntParam(), param2);
2462 });
2463
2464 callFunctionMap_.emplace("AbilityContextTerminateAbilityi", []() {
2465 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2466 temp->TerminateAbility(GetIntParam());
2467 });
2468
2469 callFunctionMap_.emplace("AbilityContextTerminateAbility", []() {
2470 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2471 temp->TerminateAbility();
2472 });
2473
2474 callFunctionMap_.emplace("AbilityContextGetCallingBundle", []() {
2475 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2476 temp->GetCallingBundle();
2477 });
2478
2479 callFunctionMap_.emplace("AbilityContextGetElementName", []() {
2480 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2481 temp->GetElementName();
2482 });
2483
2484 callFunctionMap_.emplace("AbilityContextGetCallingAbility", []() {
2485 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2486 temp->GetCallingAbility();
2487 });
2488
2489 callFunctionMap_.emplace("AbilityContextConnectAbility", []() {
2490 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2491 temp->ConnectAbility(OHOS::AppExecFwk::Want(), GetParamIAbilityConnection());
2492 });
2493
2494 callFunctionMap_.emplace("AbilityContextDisconnectAbility", []() {
2495 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2496 temp->DisconnectAbility(GetParamIAbilityConnection());
2497 });
2498
2499 callFunctionMap_.emplace("AbilityContextStopAbility", []() {
2500 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2501 temp->StopAbility(OHOS::AppExecFwk::Want());
2502 });
2503
2504 callFunctionMap_.emplace("AbilityContextGetApplicationInfo", []() {
2505 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2506 temp->GetApplicationInfo();
2507 });
2508
2509 callFunctionMap_.emplace("AbilityContextGetCacheDir", []() {
2510 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2511 temp->GetCacheDir();
2512 });
2513
2514 callFunctionMap_.emplace("AbilityContextGetCodeCacheDir", []() {
2515 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2516 temp->GetCodeCacheDir();
2517 });
2518
2519 callFunctionMap_.emplace("AbilityContextGetDatabaseDir", []() {
2520 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2521 temp->GetDatabaseDir();
2522 });
2523
2524 callFunctionMap_.emplace("AbilityContextGetDataDir", []() {
2525 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2526 temp->GetDataDir();
2527 });
2528
2529 callFunctionMap_.emplace("AbilityContextGetDir", []() {
2530 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2531 temp->GetDir(GetStringParam(), GetIntParam());
2532 });
2533
2534 callFunctionMap_.emplace("AbilityContextGetBundleManager", []() {
2535 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2536 temp->GetBundleManager();
2537 });
2538
2539 callFunctionMap_.emplace("AbilityContextGetBundleCodePath", []() {
2540 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2541 temp->GetBundleCodePath();
2542 });
2543
2544 callFunctionMap_.emplace("AbilityContextGetBundleName", []() {
2545 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2546 temp->GetBundleName();
2547 });
2548
2549 callFunctionMap_.emplace("AbilityContextGetBundleResourcePath", []() {
2550 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2551 temp->GetBundleResourcePath();
2552 });
2553
2554 callFunctionMap_.emplace("AbilityContextGetApplicationContext", []() {
2555 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2556 temp->GetApplicationContext();
2557 });
2558
2559 callFunctionMap_.emplace("AbilityContextGetContext", []() {
2560 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2561 temp->GetContext();
2562 });
2563
2564 callFunctionMap_.emplace("AbilityContextGetAbilityManager", []() {
2565 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2566 temp->GetAbilityManager();
2567 });
2568
2569 callFunctionMap_.emplace("AbilityContextGetProcessInfo", []() {
2570 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2571 temp->GetProcessInfo();
2572 });
2573
2574 callFunctionMap_.emplace("AbilityContextGetAppType", []() {
2575 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2576 temp->GetAppType();
2577 });
2578
2579 callFunctionMap_.emplace("AbilityContextGetAbilityInfo", []() {
2580 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2581 temp->GetAbilityInfo();
2582 });
2583
2584 callFunctionMap_.emplace("AbilityContextGetHapModuleInfo", []() {
2585 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2586 temp->GetHapModuleInfo();
2587 });
2588
2589 callFunctionMap_.emplace("AbilityContextCreateBundleContext", []() {
2590 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2591 temp->CreateBundleContext(GetStringParam(), GetIntParam());
2592 });
2593
2594 callFunctionMap_.emplace("AbilityContextGetResourceManager", []() {
2595 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2596 temp->GetResourceManager();
2597 });
2598
2599 callFunctionMap_.emplace("AbilityContextVerifySelfPermission", []() {
2600 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2601 temp->VerifySelfPermission(GetStringParam());
2602 });
2603
2604 callFunctionMap_.emplace("AbilityContextVerifyPermission", []() {
2605 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2606 temp->VerifyPermission(GetStringParam(), GetIntParam(), GetIntParam());
2607 });
2608
2609 callFunctionMap_.emplace("AbilityContextRequestPermissionsFromUser", []() {
2610 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2611 std::vector<std::string> permissions {};
2612 std::vector<int> permissionsState(permissions.size(), -1);
2613 temp->RequestPermissionsFromUser(permissions, permissionsState, GetIntParam());
2614 });
2615
2616 callFunctionMap_.emplace("AbilityContextDeleteFile", []() {
2617 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2618 temp->DeleteFile(GetStringParam());
2619 });
2620
2621 callFunctionMap_.emplace("AbilityContextSetCallingContext", []() {
2622 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2623 temp->SetCallingContext(GetStringParam(), GetStringParam(), GetStringParam());
2624 });
2625
2626 callFunctionMap_.emplace("AbilityContextGetCaller", []() {
2627 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2628 temp->GetCaller();
2629 });
2630
2631 callFunctionMap_.emplace("AbilityContextGetAbilityInfoType", []() {
2632 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> temp = GetParamAbilityContext();
2633 temp->GetAbilityInfoType();
2634 });
2635 }
2636
RegisterProcessInfo()2637 void fuzzTestManager::RegisterProcessInfo()
2638 {
2639 callFunctionMap_.emplace("ProcessInfoGetProcessName", []() {
2640 std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> temp = GetParamProcessInfo();
2641 temp->GetProcessName();
2642 });
2643
2644 callFunctionMap_.emplace("ProcessInfoGetPid", []() {
2645 std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> temp = GetParamProcessInfo();
2646 temp->GetPid();
2647 });
2648
2649 callFunctionMap_.emplace("ProcessInfoReadFromParcel", []() {
2650 std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> temp = GetParamProcessInfo();
2651 auto p = Parcel();
2652 temp->ReadFromParcel(p);
2653 });
2654
2655 callFunctionMap_.emplace("ProcessInfoMarshalling", []() {
2656 std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> temp = GetParamProcessInfo();
2657 auto p = Parcel();
2658 temp->Marshalling(p);
2659 });
2660
2661 callFunctionMap_.emplace("ProcessInfoUnmarshalling", []() {
2662 auto p = Parcel();
2663 OHOS::AppExecFwk::ProcessInfo::Unmarshalling(p);
2664 });
2665 }
2666
fuzzTestManager()2667 fuzzTestManager::fuzzTestManager()
2668 {
2669 RegisterAsyncCommonEventResult();
2670 RegisterCommonEventData();
2671 RegisterCommonEventManager();
2672 RegisterCommonEventPublishInfo();
2673 RegisterCommonEventSubscribeInfo();
2674 RegisterCommonEventSubscriber();
2675 RegisterCommonEventSupport();
2676 RegisterMatchingSkills();
2677 RegisterDumper();
2678 RegisterEventHandler();
2679 RegisterEventQueue();
2680 RegisterEventRunner();
2681 RegisterFileDescriptorListener();
2682 RegisterInnerEvent();
2683 RegisterEventRunnerNativeImplement();
2684 RegisterAbilityManager();
2685 RegisterWantParams();
2686 RegisterWant();
2687 RegisterElementName();
2688 RegisterBundleMgrProxy();
2689
2690 RegisterOHOSApplication();
2691 RegisterAbility();
2692 RegisterDataAbilityHelper();
2693 RegisterDataUriUtils();
2694 RegisterLifeCycle();
2695
2696 RegisterAbilityContext();
2697 RegisterProcessInfo();
2698 }
2699
SetJsonFunction(std::string functionName)2700 void fuzzTestManager::SetJsonFunction(std::string functionName)
2701 {
2702 remainderMap_.emplace(functionName, cycle_);
2703 }
2704
SetCycle(uint16_t cycle)2705 void fuzzTestManager::SetCycle(uint16_t cycle)
2706 {
2707 cycle_ = cycle;
2708 for_each(remainderMap_.begin(), remainderMap_.end(), [cycle](std::unordered_map<std::string, int>::reference temp) {
2709 temp.second = cycle;
2710 });
2711 }
2712
GetRandomInt(int minNum,int maxNum)2713 int GetRandomInt(int minNum, int maxNum)
2714 {
2715 return GetU16Param() % (maxNum - minNum + 1) + minNum;
2716 }
2717
action(int a)2718 void action(int a)
2719 {
2720 std::cout << "Interrupt signal (" << a << ") received.\n";
2721 }
2722
StartFuzzTest()2723 void fuzzTestManager::StartFuzzTest()
2724 {
2725 std::cout << __func__ << std::endl;
2726 OHOS::FuzzConfigParser jsonParser;
2727 OHOS::FuzzTestData tempData;
2728
2729 std::cout << "parseFromFile start" << std::endl;
2730 jsonParser.ParseFromFile4FuzzTest(FUZZ_TEST_CONFIG_FILE_PATH, tempData);
2731 std::cout << "flag :" << tempData.mainLoopFlag << std::endl;
2732 for_each(tempData.methodVec.begin(), tempData.methodVec.end(), [this](std::vector<std::string>::reference s) {
2733 SetJsonFunction(s);
2734 });
2735 SetCycle(tempData.mainLoopFlag);
2736
2737 std::vector<std::string> index;
2738 std::unordered_map<std::string, int>::iterator it = remainderMap_.begin();
2739 while (it != remainderMap_.end()) {
2740 if (it->second <= 0) {
2741 it = remainderMap_.erase(it);
2742 } else {
2743 index.push_back(it->first);
2744 it++;
2745 }
2746 }
2747
2748 std::cout << remainderMap_.size() << "--------fuzz test start--------" << callFunctionMap_.size() << std::endl;
2749 for (; remainderMap_.size() > 0;) {
2750 std::string functionName;
2751 int offset = GetRandomInt(0, index.size() - 1);
2752 functionName = index[offset];
2753 if (callFunctionMap_.find(functionName) != callFunctionMap_.end()) {
2754 std::cout << "call function : " << functionName << std::endl;
2755 callFunctionMap_[functionName]();
2756 std::cout << "function end :" << functionName << std::endl;
2757 } else {
2758 std::cout << "can't find function : " << functionName << std::endl;
2759 }
2760 remainderMap_[functionName]--;
2761 if (remainderMap_[functionName] <= 0) {
2762 remainderMap_.erase(functionName);
2763 index.erase(index.begin() + offset);
2764 };
2765 }
2766 std::cout << remainderMap_.size() << "--------fuzz test end--------" << std::endl;
2767 }
2768 } // namespace EventFwk
2769 } // namespace OHOS
2770