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 #ifndef FUZZTESTMANAGER_H 16 #define FUZZTESTMANAGER_H 17 18 #include <memory> 19 #include <string> 20 #include <map> 21 #include <unordered_map> 22 23 #include "nlohmann/json.hpp" 24 namespace OHOS { 25 namespace EventFwk { 26 class fuzzTestManager { 27 public: 28 typedef std::shared_ptr<fuzzTestManager> Ptr; 29 ~fuzzTestManager()30 ~fuzzTestManager() 31 {} 32 33 /** 34 * Obtains the instance of the fuzz test. 35 * 36 * @return the instance of the fuzz test 37 */ GetInstance()38 static Ptr GetInstance() 39 { 40 if (instance_ == nullptr) { 41 instance_ = std::shared_ptr<fuzzTestManager>(new fuzzTestManager); 42 } 43 return instance_; 44 } 45 46 /** 47 * Starts the fuzz test. 48 */ 49 void StartFuzzTest(); 50 51 private: 52 void SetJsonFunction(std::string functionName); 53 void SetCycle(uint16_t cycle); 54 fuzzTestManager(); 55 fuzzTestManager(fuzzTestManager &) = delete; 56 fuzzTestManager &operator=(const fuzzTestManager &) = delete; 57 static Ptr instance_; 58 uint16_t cycle_ {}; 59 std::unordered_map<std::string, int> remainderMap_ {}; 60 std::unordered_map<std::string, std::function<void()>> callFunctionMap_ {}; 61 62 const int COLOR_R = 100; 63 const int COLOR_G = 100; 64 const int COLOR_B = 100; 65 66 void RegisterAsyncCommonEventResult(); 67 void RegisterCommonEventData(); 68 void RegisterCommonEventManager(); 69 void RegisterCommonEventPublishInfo(); 70 void RegisterCommonEventSubscribeInfo(); 71 void RegisterCommonEventSubscriber(); 72 void RegisterCommonEventSupport(); 73 void RegisterMatchingSkills(); 74 void RegisterDumper(); 75 void RegisterEventHandler(); 76 void RegisterEventQueue(); 77 void RegisterEventRunner(); 78 void RegisterFileDescriptorListener(); 79 void RegisterInnerEvent(); 80 void RegisterEventRunnerNativeImplement(); 81 void RegisterAbilityManager(); 82 void RegisterWantParams(); 83 void RegisterWant(); 84 void RegisterElementName(); 85 void RegisterBundleMgrProxy(); 86 87 void RegisterProcessInfo(); 88 }; 89 } // namespace EventFwk 90 } // namespace OHOS 91 92 #endif