• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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 CALL_MANAGER_SPECIAL_MOCK_H
17 #define CALL_MANAGER_SPECIAL_MOCK_H
18 
19 #define private public
20 #define protected public
21 
22 #include <gmock/gmock.h>
23 #include <cstdint>
24 
25 #include "call_manager_service_proxy.h"
26 #include "iremote_object.h"
27 #include "want.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 class MockRemoteObject : public IRemoteObject {
32 public:
MockRemoteObject(int command)33     explicit MockRemoteObject(int command) : IRemoteObject(u"default")
34     {
35         command_ = command;
36     }
37 
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)38     int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
39     {
40         if (command_ == -1) {
41             return -1;
42         }
43         reply.WriteInt32(0);
44         if (command_ == 0) {
45             std::vector<std::u16string> responseBuffer{u"0"};
46             reply.WriteString16Vector(responseBuffer);
47         }
48         return 0;
49     }
50 
GetObjectRefCount()51     int32_t GetObjectRefCount()
52     {
53         return 0;
54     }
55 
AddDeathRecipient(const sptr<DeathRecipient> & recipient)56     bool AddDeathRecipient(const sptr<DeathRecipient> &recipient)
57     {
58         return true;
59     }
60 
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)61     bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient)
62     {
63         return true;
64     }
65 
IsObjectDead()66     bool IsObjectDead() const
67     {
68         return command_ != 0 && command_ != 1;
69     }
70 
Dump(int fd,const std::vector<std::u16string> & args)71     int Dump(int fd, const std::vector<std::u16string> &args)
72     {
73         return 0;
74     }
75 private:
76     int command_;
77 }; // class MockRemoteObject
78 } // namespace OHOS
79 } // namespace Telephony
80 
81 namespace OHOS {
82 namespace AAFwk {
83 class ExtensionManagerClient {
84 public:
GetInstance()85     static ExtensionManagerClient& GetInstance()
86     {
87         static ExtensionManagerClient extensionManagerClient;
88         return extensionManagerClient;
89     }
90 
ConnectServiceExtensionAbility(const Want & want,const sptr<IRemoteObject> & connect,int32_t userId)91     int32_t ConnectServiceExtensionAbility(const Want &want, const sptr<IRemoteObject> &connect, int32_t userId)
92     {
93         return -1;
94     }
95 
DisconnectAbility(const sptr<IRemoteObject> & connect)96     int32_t DisconnectAbility(const sptr<IRemoteObject> &connect)
97     {
98         return -1;
99     }
100 }; // class ExtensionManagerClient
101 } // namespace AAFwk
102 } // namespace OHOS
103 
104 #endif // CALL_MANAGER_SPECIAL_MOCK_H
105