• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 OHOS_MOCK_SESSION_IMPL_H
17 #define OHOS_MOCK_SESSION_IMPL_H
18 
19 #include <string>
20 
21 #include <gtest/gtest.h>
22 #include <gmock/gmock.h>
23 
24 #include "Session.h"
25 
26 using Communication::SoftBus::Session;
27 
28 namespace OHOS {
29 class MockSessionImpl : public std::enable_shared_from_this<MockSessionImpl>, public Session {
30 public:
31     MockSessionImpl() = default;
32     ~MockSessionImpl() = default;
33     MOCK_CONST_METHOD0(GetMySessionName, const std::string &());
34     MOCK_CONST_METHOD0(GetPeerSessionName, const std::string &());
35     MOCK_CONST_METHOD0(GetDeviceId, const std::string &());
36     MOCK_CONST_METHOD0(GetPeerDeviceId, const std::string &());
37     MOCK_CONST_METHOD0(GetChannelId, int64_t());
38     MOCK_CONST_METHOD0(GetPeerUid, uid_t());
39     MOCK_CONST_METHOD0(GetPeerPid, pid_t());
40     MOCK_CONST_METHOD0(IsServerSide, bool());
41     MOCK_CONST_METHOD2(SendBytes, int(const void *buf, ssize_t len));
42     MOCK_CONST_METHOD0(GetSessionId, int());
43     MOCK_METHOD1(SetSessionId, void(int sessionId));
44     MOCK_METHOD1(SetMySessionName, void(const std::string &name));
45     MOCK_METHOD1(SetPeerSessionName, void(const std::string &name));
46     MOCK_METHOD1(SetPeerDeviceId, void(const std::string &name));
47     MOCK_METHOD1(SetDeviceId, void(const std::string &name));
48     MOCK_METHOD1(SetIsServer, void(bool isServer));
49     MOCK_METHOD1(SetPeerUid, void(uid_t peerUid));
50     MOCK_METHOD1(SetPeerPid, void(pid_t peerPid));
51 }; // namespace OHOS
52 }
53 #endif // OHOS_MOCK_SESSION_IMPL_H
54