1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_FORM_FWK_MOCK_ECOLOGICAL_RULE_MANAGER_H
17 #define OHOS_FORM_FWK_MOCK_ECOLOGICAL_RULE_MANAGER_H
18 
19 #include <vector>
20 
21 #include "erms_mgr_interface.h"
22 #include "erms_mgr_param.h"
23 #include "gmock/gmock.h"
24 #include "iremote_proxy.h"
25 #include "iremote_stub.h"
26 #include "want.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 using Want = OHOS::AAFwk::Want;
31 
32 class EcologicalRuleMgrProxy : public OHOS::IRemoteProxy<IEcologicalRuleManager> {
33 public:
EcologicalRuleMgrProxy(const sptr<IRemoteObject> & impl)34     explicit EcologicalRuleMgrProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IEcologicalRuleManager>(impl)
35     {}
~EcologicalRuleMgrProxy()36     virtual ~EcologicalRuleMgrProxy()
37     {}
38 
QueryFreeInstallExperience(const Want & want,const ErmsParams::CallerInfo & callerInfo,ErmsParams::ExperienceRule & rule)39     virtual int32_t QueryFreeInstallExperience(const Want &want,
40         const ErmsParams::CallerInfo &callerInfo, ErmsParams::ExperienceRule &rule)
41     {
42         return 0;
43     }
44 
EvaluateResolveInfos(const Want & want,const ErmsParams::CallerInfo & callerInfo,int32_t type,std::vector<AbilityInfo> & abilityInfos,std::vector<ExtensionAbilityInfo> extensionInfos)45     virtual int32_t EvaluateResolveInfos(const Want &want, const ErmsParams::CallerInfo &callerInfo, int32_t type,
46         std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> extensionInfos)
47     {
48         return 0;
49     }
50 
QueryStartExperience(const Want & want,const ErmsParams::CallerInfo & callerInfo,ErmsParams::ExperienceRule & rule)51     virtual int32_t QueryStartExperience(const Want &want,
52         const ErmsParams::CallerInfo &callerInfo, ErmsParams::ExperienceRule &rule)
53     {
54         return 0;
55     }
56 
QueryPublishFormExperience(const Want & want,ErmsParams::ExperienceRule & rule)57     virtual int32_t QueryPublishFormExperience(const Want &want, ErmsParams::ExperienceRule &rule)
58     {
59         return 0;
60     }
61 
IsSupportPublishForm(const Want & want,const ErmsParams::CallerInfo & callerInfo,ErmsParams::ExperienceRule & rule)62     virtual int32_t IsSupportPublishForm(const Want &want, const ErmsParams::CallerInfo &callerInfo,
63         ErmsParams::ExperienceRule &rule)
64     {
65         return 0;
66     }
67 
QueryLastSyncTime()68     virtual long QueryLastSyncTime()
69     {
70         return 0;
71     }
72 };
73 
74 class EcologicalRuleMgrStub : public OHOS::IRemoteStub<IEcologicalRuleManager> {
75 public:
EcologicalRuleMgrStub()76     EcologicalRuleMgrStub() {};
77     virtual ~EcologicalRuleMgrStub() = default;
78 
QueryFreeInstallExperience(const Want & want,const ErmsParams::CallerInfo & callerInfo,ErmsParams::ExperienceRule & rule)79     virtual int32_t QueryFreeInstallExperience(const Want &want,
80         const ErmsParams::CallerInfo &callerInfo, ErmsParams::ExperienceRule &rule)
81     {
82         return 0;
83     }
84 
EvaluateResolveInfos(const Want & want,const ErmsParams::CallerInfo & callerInfo,int32_t type,std::vector<AbilityInfo> & abilityInfos,std::vector<ExtensionAbilityInfo> extensionInfos)85     virtual int32_t EvaluateResolveInfos(const Want &want, const ErmsParams::CallerInfo &callerInfo, int32_t type,
86         std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> extensionInfos)
87     {
88         return 0;
89     }
90 
QueryStartExperience(const Want & want,const ErmsParams::CallerInfo & callerInfo,ErmsParams::ExperienceRule & rule)91     virtual int32_t QueryStartExperience(const Want &want,
92         const ErmsParams::CallerInfo &callerInfo, ErmsParams::ExperienceRule &rule)
93     {
94         return 0;
95     }
96 
QueryPublishFormExperience(const Want & want,ErmsParams::ExperienceRule & rule)97     virtual int32_t QueryPublishFormExperience(const Want &want, ErmsParams::ExperienceRule &rule)
98     {
99         return 0;
100     }
101 
IsSupportPublishForm(const Want & want,const ErmsParams::CallerInfo & callerInfo,ErmsParams::ExperienceRule & rule)102     virtual int32_t IsSupportPublishForm(const Want &want, const ErmsParams::CallerInfo &callerInfo,
103         ErmsParams::ExperienceRule &rule)
104     {
105         return 0;
106     }
107 
QueryLastSyncTime()108     virtual long QueryLastSyncTime()
109     {
110         return 0;
111     }
112 };
113 
114 class EcologicalRuleMgrService : public EcologicalRuleMgrStub {
115 public:
EcologicalRuleMgrService()116     EcologicalRuleMgrService() {};
117     virtual ~EcologicalRuleMgrService() = default;
118 
119     MOCK_METHOD3(QueryFreeInstallExperience, int32_t(const Want &want,
120         const ErmsParams::CallerInfo &callerInfo, ErmsParams::ExperienceRule &rule));
121     MOCK_METHOD5(EvaluateResolveInfos, int32_t(const Want &want, const ErmsParams::CallerInfo &callerInfo,
122         int32_t type, std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> extensionInfos));
123     MOCK_METHOD3(QueryStartExperience, int32_t(const Want &want, const ErmsParams::CallerInfo &callerInfo,
124         ErmsParams::ExperienceRule &rule));
125     MOCK_METHOD2(QueryPublishFormExperience, int32_t(const Want &want, ErmsParams::ExperienceRule &rule));
126     MOCK_METHOD3(IsSupportPublishForm, int32_t(const Want &want, const ErmsParams::CallerInfo &callerInfo,
127         ErmsParams::ExperienceRule &rule));
128     MOCK_METHOD0(QueryLastSyncTime, long());
129 };
130 
131 class MockEcologicalRuleMgrService : public EcologicalRuleMgrService {
132 public:
133     MockEcologicalRuleMgrService() = default;
134     virtual ~MockEcologicalRuleMgrService() = default;
135 };
136 } // namespace AppExecFwk
137 } // namespace OHOS
138 
139 #endif // OHOS_FORM_FWK_MOCK_ECOLOGICAL_RULE_MANAGER_H
140