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_DAUDIO_DECODE_TRANS_TEST_H 17 #define OHOS_DAUDIO_DECODE_TRANS_TEST_H 18 19 #include <gtest/gtest.h> 20 21 #define private public 22 #include "audio_decode_transport.h" 23 #undef private 24 25 #include "iaudio_channel.h" 26 #include "iaudio_datatrans_callback.h" 27 #include "daudio_errorcode.h" 28 29 namespace OHOS { 30 namespace DistributedHardware { 31 class DecodeTransportTest : public testing::Test { 32 public: 33 static void SetUpTestCase(void); 34 static void TearDownTestCase(void); 35 void SetUp(); 36 void TearDown(); 37 38 std::shared_ptr<IAudioDataTransCallback> transCallback_ = nullptr; 39 std::shared_ptr<AudioDecodeTransport> decodeTrans_ = nullptr; 40 }; 41 42 class MockIAudioChannel : public IAudioChannel { 43 public: CreateSession(const std::shared_ptr<IAudioChannelListener> & listener,const std::string & sessionName)44 int32_t CreateSession(const std::shared_ptr<IAudioChannelListener> &listener, 45 const std::string &sessionName) override 46 { 47 return DH_SUCCESS; 48 } ReleaseSession()49 int32_t ReleaseSession() override 50 { 51 return ERR_DH_AUDIO_FAILED; 52 } OpenSession()53 virtual int32_t OpenSession() override 54 { 55 return ERR_DH_AUDIO_FAILED; 56 } CloseSession()57 virtual int32_t CloseSession() override 58 { 59 return DH_SUCCESS; 60 } SendData(const std::shared_ptr<AudioData> & data)61 int32_t SendData(const std::shared_ptr<AudioData> &data) override 62 { 63 return DH_SUCCESS; 64 } SendEvent(const AudioEvent & event)65 int32_t SendEvent(const AudioEvent &event) override 66 { 67 return DH_SUCCESS; 68 } 69 }; 70 } // namespace DistributedHardware 71 } // namespace OHOS 72 #endif // OHOS_DAUDIO_DECODE_TRANS_TEST_H 73