1 /*
2  * Copyright (C) 2021-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 TELEPHONY_IMS_UNIT_TEST_H
17 #define TELEPHONY_IMS_UNIT_TEST_H
18 
19 #include <map>
20 
21 #include "ims_call_interface.h"
22 #include "ims_call_ipc_interface_code.h"
23 #include "ims_core_service_interface.h"
24 #include "ims_sms_interface.h"
25 #include "ims_sms_ipc_interface_code.h"
26 
27 #include "singleton.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 class ImsUnitTest {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     void SetUp();
36     void TearDown();
37 
38     /****************** basic ******************/
39     int32_t Dial(const sptr<ImsCallInterface> &imsCallSerivce) const;
40     int32_t HangUp(const sptr<ImsCallInterface> &imsCallSerivce) const;
41     int32_t RejectWithReason(const sptr<ImsCallInterface> &imsCallSerivce) const;
42     int32_t Answer(const sptr<ImsCallInterface> &imsCallSerivce) const;
43     int32_t HoldCall(const sptr<ImsCallInterface> &imsCallSerivce) const;
44     int32_t UnHoldCall(const sptr<ImsCallInterface> &imsCallSerivce) const;
45     int32_t SwitchCall(const sptr<ImsCallInterface> &imsCallSerivce) const;
46     int32_t CombineConference(const sptr<ImsCallInterface> &imsCallSerivce) const;
47     int32_t InviteToConference(const sptr<ImsCallInterface> &imsCallSerivce) const;
48     int32_t KickOutFromConference(const sptr<ImsCallInterface> &imsCallSerivce) const;
49     int32_t UpdateImsCallMode(const sptr<ImsCallInterface> &imsCallSerivce) const;
50     int32_t GetImsCallsDataRequest(const sptr<ImsCallInterface> &imsCallSerivce) const;
51     int32_t GetLastCallFailReason(const sptr<ImsCallInterface> &imsCallSerivce) const;
52     int32_t StartDtmf(const sptr<ImsCallInterface> &imsCallSerivce) const;
53     int32_t SendDtmf(const sptr<ImsCallInterface> &imsCallSerivce) const;
54     int32_t StopDtmf(const sptr<ImsCallInterface> &imsCallSerivce) const;
55     int32_t StartRtt(const sptr<ImsCallInterface> &imsCallSerivce) const;
56     int32_t StopRtt(const sptr<ImsCallInterface> &imsCallSerivce) const;
57 
58     /****************** ims config ******************/
59     int32_t SetDomainPreferenceMode(const sptr<ImsCallInterface> &imsCallSerivce) const;
60     int32_t GetDomainPreferenceMode(const sptr<ImsCallInterface> &imsCallSerivce) const;
61     int32_t SetImsSwitchStatus(const sptr<ImsCallInterface> &imsCallSerivce) const;
62     int32_t GetImsSwitchStatus(const sptr<ImsCallInterface> &imsCallSerivce) const;
63     int32_t SetImsConfigString(const sptr<ImsCallInterface> &imsCallSerivce) const;
64     int32_t SetImsConfigInt(const sptr<ImsCallInterface> &imsCallSerivce) const;
65     int32_t GetImsConfig(const sptr<ImsCallInterface> &imsCallSerivce) const;
66     int32_t SetImsFeatureValue(const sptr<ImsCallInterface> &imsCallSerivce) const;
67     int32_t GetImsFeatureValue(const sptr<ImsCallInterface> &imsCallSerivce) const;
68     int32_t SetMute(const sptr<ImsCallInterface> &imsCallSerivce) const;
69     int32_t GetMute(const sptr<ImsCallInterface> &imsCallSerivce) const;
70 
71     /****************** video call ******************/
72     int32_t CtrlCamera(const sptr<ImsCallInterface> &imsCallSerivce) const;
73     int32_t SetPreviewWindow(const sptr<ImsCallInterface> &imsCallSerivce) const;
74     int32_t SetDisplayWindow(const sptr<ImsCallInterface> &imsCallSerivce) const;
75     int32_t SetCameraZoom(const sptr<ImsCallInterface> &imsCallSerivce) const;
76     int32_t SetPauseImage(const sptr<ImsCallInterface> &imsCallSerivce) const;
77     int32_t SetDeviceDirection(const sptr<ImsCallInterface> &imsCallSerivce) const;
78 
79     /****************** supplement ******************/
80     int32_t GetClip(const sptr<ImsCallInterface> &imsCallSerivce) const;
81     int32_t SetClir(const sptr<ImsCallInterface> &imsCallSerivce) const;
82     int32_t GetClir(const sptr<ImsCallInterface> &imsCallSerivce) const;
83     int32_t SetCallTransfer(const sptr<ImsCallInterface> &imsCallSerivce) const;
84     int32_t GetCallTransfer(const sptr<ImsCallInterface> &imsCallSerivce) const;
85     int32_t SetCallRestriction(const sptr<ImsCallInterface> &imsCallSerivce) const;
86     int32_t GetCallRestriction(const sptr<ImsCallInterface> &imsCallSerivce) const;
87     int32_t SetCallWaiting(const sptr<ImsCallInterface> &imsCallSerivce) const;
88     int32_t GetCallWaiting(const sptr<ImsCallInterface> &imsCallSerivce) const;
89 
90     // sms & core_service
91     int32_t SetSmsConfig(const sptr<ImsSmsInterface> &imsSmsSerivce) const;
92     int32_t GetSmsConfig(const sptr<ImsSmsInterface> &imsSmsSerivce) const;
93     int32_t SendMessage(const sptr<ImsSmsInterface> &imsSmsSerivce) const;
94     int32_t GetImsRegistrationStatus(const sptr<ImsCoreServiceInterface> &imsCoreSerivce) const;
95 
96     int32_t ImsCallTest() const;
97     int32_t ImsSmsTest() const;
98     int32_t ImsCoreServiceTest() const;
99 
100 private:
101     /**
102      * InitBasicFuncMap
103      */
104     void InitBasicFuncMap();
105 
106     /**
107      * InitConfigFuncMap
108      */
109     void InitConfigFuncMap();
110 
111     /**
112      * InitVideoCallFuncMap
113      */
114     void InitVideoCallFuncMap();
115 
116     /**
117      * InitSupplementFuncMap
118      */
119     void InitSupplementFuncMap();
120 
121     /**
122      * InitSmsFuncMap
123      */
124     void InitSmsFuncMap();
125 
126     /**
127      * InitCoreServiceFuncMap
128      */
129     void InitCoreServiceFuncMap();
130 
131 private:
132     using RequestCallFuncType = int32_t (ImsUnitTest::*)(const sptr<ImsCallInterface> &imsCallSerivce) const;
133     using RequestSmsFuncType = int32_t (ImsUnitTest::*)(const sptr<ImsSmsInterface> &imsCallSerivce) const;
134     using RequestCoreServiceFuncType = int32_t (ImsUnitTest::*)(
135         const sptr<ImsCoreServiceInterface> &imsCallSerivce) const;
136     std::map<int32_t, RequestCallFuncType> requestCallFuncMap_;
137     std::map<int32_t, RequestSmsFuncType> requestSmsFuncMap_;
138     std::map<int32_t, RequestCoreServiceFuncType> requestCoreServiceFuncMap_;
139 };
140 } // namespace Telephony
141 } // namespace OHOS
142 #endif // TELEPHONY_IMS_UNIT_TEST_H
143