1 /*
2 * Copyright (c) 2022-2024 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_PUBLISHER_LISTENER_PROXY_TEST_H
17 #define OHOS_PUBLISHER_LISTENER_PROXY_TEST_H
18
19 #include <string>
20 #include <memory>
21 #include <gtest/gtest.h>
22
23 #include "publisher_listener_proxy.h"
24 #include "distributed_hardware_errno.h"
25
26 namespace OHOS {
27 namespace DistributedHardware {
28 class PublisherListenerProxyTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 void SetUp();
33 void TearDown();
34 std::shared_ptr<PublisherListenerProxy> proxy_ = nullptr;
35 };
36
37 class MockIRemoteObject : public IRemoteObject {
38 public:
AsObject()39 sptr<IRemoteObject> AsObject()
40 {
41 return nullptr;
42 }
43
OnMessage(const DHTopic topic,const std::string & message)44 void OnMessage(const DHTopic topic, const std::string& message)
45 {
46 (void)topic;
47 (void)message;
48 }
49
GetObjectRefCount()50 int32_t GetObjectRefCount()
51 {
52 return DH_FWK_SUCCESS;
53 }
54
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)55 int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
56 {
57 (void)code;
58 (void)data;
59 (void)reply;
60 (void)option;
61 return DH_FWK_SUCCESS;
62 }
63
AddDeathRecipient(const sptr<DeathRecipient> & recipient)64 bool AddDeathRecipient(const sptr<DeathRecipient> &recipient)
65 {
66 (void)recipient;
67 return true;
68 }
69
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)70 bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient)
71 {
72 (void)recipient;
73 return true;
74 }
75
Dump(int fd,const std::vector<std::u16string> & args)76 int Dump(int fd, const std::vector<std::u16string> &args)
77 {
78 (void)fd;
79 (void)args;
80 return DH_FWK_SUCCESS;
81 }
82 };
83 } // namespace DistributedHardware
84 } // namespace OHOS
85 #endif // OHOS_PUBLISHER_LISTENER_PROXY_TEST_H