• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 NOTIFICATION_FUZZTESTMANAGER_H
16 #define NOTIFICATION_FUZZTESTMANAGER_H
17 
18 #include <map>
19 #include <unordered_map>
20 
21 #include "nlohmann/json.hpp"
22 namespace OHOS {
23 namespace Notification {
24 class NotificationFuzzTestManager {
25 public:
26     using Ptr = std::shared_ptr<NotificationFuzzTestManager>;
27 
28     /**
29      * @brief Default deconstructor used to deconstruct.
30      */
~NotificationFuzzTestManager()31     ~NotificationFuzzTestManager()
32     {}
33 
34     /**
35      * @brief Obtains the instance of the fuzz test.
36      *
37      * @return Returns the instance of the fuzz test.
38      */
GetInstance()39     static Ptr GetInstance()
40     {
41         if (instance == nullptr) {
42             NotificationFuzzTestManager* pObj = new NotificationFuzzTestManager();
43             instance = std::shared_ptr<NotificationFuzzTestManager>(pObj);
44         }
45         return instance;
46     }
47 
48     /**
49      * @brief Starts the fuzz test.
50      */
51     void StartFuzzTest();
52 
53 private:
54     void SetJsonFunction(std::string functionName);
55     void SetCycle(uint16_t cycle);
56     NotificationFuzzTestManager();
57     NotificationFuzzTestManager(const NotificationFuzzTestManager &) = delete;
58     NotificationFuzzTestManager &operator=(const NotificationFuzzTestManager &) = delete;
59     static Ptr instance;
60     uint16_t cycle_ = 0;
61     std::unordered_map<std::string, int> remainderMap_ {};
62     std::unordered_map<std::string, std::function<void()>> callFunctionMap_ {};
63 
64     const int COLOR_R = 100;
65     const int COLOR_G = 100;
66     const int COLOR_B = 100;
67     void RegisterNotificationHelper();
68     void RegisterNotificationSorting();
69     void RegisterNotificationSortingMap();
70     void RegisterNotificationSubscribeInfo();
71     void RegisterNotificationSubscriber();
72     void RegisterWantAgentHelper();
73     void RegisterLauncherService();
74     void RegisterNapiBundlemgr();
75     void RegisterIAbilityContinuation();
76     void RegisterRevocable();
77     void RegisterTaskDispatcher();
78     void RegisterAbility();
79     void RegisterAbilityContext();
80     void RegisterContext();
81     void RegisterAbilityLifecycleCallbacks();
82     void RegisterIAbilityManager();
83     friend class TestAnsSubscriber;
84 };
85 }  // namespace EventFwk
86 }  // namespace OHOS
87 
88 #endif