• 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_AUDIO_TRANS_TEST_UTILS_H
17 #define OHOS_AUDIO_TRANS_TEST_UTILS_H
18 
19 #include "iaudio_channel_listener.h"
20 #include "iaudio_ctrl_trans_callback.h"
21 #include "iaudio_channel.h"
22 
23 namespace OHOS {
24 namespace DistributedHardware {
25 constexpr size_t DATA_LEN = 128;
26 
27 class MockIAudioChannelListener : public IAudioChannelListener {
28 public:
MockIAudioChannelListener()29     MockIAudioChannelListener() {}
~MockIAudioChannelListener()30     ~MockIAudioChannelListener() {}
OnSessionOpened()31     void OnSessionOpened() override {};
OnSessionClosed()32     void OnSessionClosed() override {};
OnDataReceived(const std::shared_ptr<AudioData> & data)33     void OnDataReceived(const std::shared_ptr<AudioData> &data) override {};
OnEventReceived(const AudioEvent & event)34     void OnEventReceived(const AudioEvent &event) override {};
35 };
36 
37 class MockIAudioCtrlTransCallback : public IAudioCtrlTransCallback {
38 public:
MockIAudioCtrlTransCallback()39     MockIAudioCtrlTransCallback() {}
~MockIAudioCtrlTransCallback()40     ~MockIAudioCtrlTransCallback() {}
OnStateChange(int32_t state)41     void OnStateChange(int32_t state) override {};
OnEventReceived(const AudioEvent & event)42     void OnEventReceived(const AudioEvent &event) override {};
43 };
44 
45 class MockAudioCtrlChannel : public IAudioChannel {
46 public:
MockAudioCtrlChannel(std::string peerDevId)47     explicit MockAudioCtrlChannel(std::string peerDevId) : peerDevId_(peerDevId) {}
~MockAudioCtrlChannel()48     ~MockAudioCtrlChannel() {}
49 
CreateSession(const std::shared_ptr<IAudioChannelListener> & listener,const std::string & sessionName)50     int32_t CreateSession(const std::shared_ptr<IAudioChannelListener> &listener,
51         const std::string &sessionName) override
52     {
53         return 0;
54     }
ReleaseSession()55     int32_t ReleaseSession() override
56     {
57         return 0;
58     }
OpenSession()59     int32_t OpenSession() override
60     {
61         return 0;
62     }
CloseSession()63     int32_t CloseSession() override
64     {
65         return 0;
66     }
SendData(const std::shared_ptr<AudioData> & audioData)67     int32_t SendData(const std::shared_ptr<AudioData> &audioData) override
68     {
69         return 0;
70     }
SendEvent(const AudioEvent & audioEvent)71     int32_t SendEvent(const AudioEvent &audioEvent) override
72     {
73         return 0;
74     }
75 
76 private:
77     const std::string peerDevId_;
78 };
79 } // namespace DistributedHardware
80 } // namespace OHOS
81 #endif // OHOS_AUDIO_TRANS_TEST_UTILS_H