1fa7767c5Sopenharmony_ci/* 2fa7767c5Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License. 5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at 6fa7767c5Sopenharmony_ci * 7fa7767c5Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8fa7767c5Sopenharmony_ci * 9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and 13fa7767c5Sopenharmony_ci * limitations under the License. 14fa7767c5Sopenharmony_ci */ 15fa7767c5Sopenharmony_ci 16fa7767c5Sopenharmony_ci#include "gtest/gtest.h" 17fa7767c5Sopenharmony_ci#include "plugin/plugins/sink/audio_server_sink/audio_server_sink_plugin.h" 18fa7767c5Sopenharmony_ci 19fa7767c5Sopenharmony_ciusing namespace testing::ext; 20fa7767c5Sopenharmony_ciusing namespace OHOS::Media::Plugin; 21fa7767c5Sopenharmony_ciusing namespace OHOS::Media::Plugin::AuSrSinkPlugin; 22fa7767c5Sopenharmony_ci 23fa7767c5Sopenharmony_cinamespace OHOS { 24fa7767c5Sopenharmony_cinamespace Media { 25fa7767c5Sopenharmony_cinamespace Test { 26fa7767c5Sopenharmony_cistd::shared_ptr<AudioSinkPlugin> AudioServerSinkPluginCreate(const std::string& name) 27fa7767c5Sopenharmony_ci{ 28fa7767c5Sopenharmony_ci return std::make_shared<AudioServerSinkPlugin>(name); 29fa7767c5Sopenharmony_ci} 30fa7767c5Sopenharmony_ci 31fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_process, TestSize.Level1) 32fa7767c5Sopenharmony_ci{ 33fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("process"); 34fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 35fa7767c5Sopenharmony_ci auto initStatus = audioSinkPlugin->Init(); 36fa7767c5Sopenharmony_ci ASSERT_TRUE(initStatus == Status::OK); 37fa7767c5Sopenharmony_ci auto freeStatus = audioSinkPlugin->Deinit(); 38fa7767c5Sopenharmony_ci ASSERT_TRUE(freeStatus == Status::OK); 39fa7767c5Sopenharmony_ci} 40fa7767c5Sopenharmony_ci 41fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_get_parameter, TestSize.Level1) 42fa7767c5Sopenharmony_ci{ 43fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("get parameter"); 44fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 45fa7767c5Sopenharmony_ci ValueType para; 46fa7767c5Sopenharmony_ci auto sampleRateStatus = audioSinkPlugin->GetParameter(Tag::AUDIO_SAMPLE_RATE, para); 47fa7767c5Sopenharmony_ci ASSERT_TRUE(sampleRateStatus == Status::OK); 48fa7767c5Sopenharmony_ci auto outputChannelsStatus = audioSinkPlugin->GetParameter(Tag::AUDIO_OUTPUT_CHANNELS, para); 49fa7767c5Sopenharmony_ci ASSERT_TRUE(outputChannelsStatus == Status::OK); 50fa7767c5Sopenharmony_ci auto outputLayoutStatus = audioSinkPlugin->GetParameter(Tag::AUDIO_OUTPUT_CHANNEL_LAYOUT, para); 51fa7767c5Sopenharmony_ci ASSERT_TRUE(outputLayoutStatus == Status::OK); 52fa7767c5Sopenharmony_ci auto bitrateStatus = audioSinkPlugin->GetParameter(Tag::MEDIA_BITRATE, para); 53fa7767c5Sopenharmony_ci ASSERT_TRUE(bitrateStatus == Status::OK); 54fa7767c5Sopenharmony_ci auto sampleFormatStatus = audioSinkPlugin->GetParameter(Tag::AUDIO_SAMPLE_FORMAT, para); 55fa7767c5Sopenharmony_ci ASSERT_TRUE(sampleFormatStatus == Status::OK); 56fa7767c5Sopenharmony_ci} 57fa7767c5Sopenharmony_ci 58fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_get_allocator, TestSize.Level1) 59fa7767c5Sopenharmony_ci{ 60fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("get allocator"); 61fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 62fa7767c5Sopenharmony_ci auto allocator = audioSinkPlugin->GetAllocator(); 63fa7767c5Sopenharmony_ci ASSERT_TRUE(allocator == nullptr); 64fa7767c5Sopenharmony_ci} 65fa7767c5Sopenharmony_ci 66fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_get_mute, TestSize.Level1) 67fa7767c5Sopenharmony_ci{ 68fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("get mute"); 69fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 70fa7767c5Sopenharmony_ci bool mute = false; 71fa7767c5Sopenharmony_ci auto muteStatus = audioSinkPlugin->GetMute(mute); 72fa7767c5Sopenharmony_ci ASSERT_TRUE(muteStatus == Status::OK); 73fa7767c5Sopenharmony_ci} 74fa7767c5Sopenharmony_ci 75fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_set_mute, TestSize.Level1) 76fa7767c5Sopenharmony_ci{ 77fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("set mute"); 78fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 79fa7767c5Sopenharmony_ci bool mute = false; 80fa7767c5Sopenharmony_ci auto muteStatus = audioSinkPlugin->SetMute(mute); 81fa7767c5Sopenharmony_ci ASSERT_TRUE(muteStatus == Status::OK); 82fa7767c5Sopenharmony_ci} 83fa7767c5Sopenharmony_ci 84fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_get_speed, TestSize.Level1) 85fa7767c5Sopenharmony_ci{ 86fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("get speed"); 87fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 88fa7767c5Sopenharmony_ci float speed; 89fa7767c5Sopenharmony_ci auto speedStatus = audioSinkPlugin->GetSpeed(speed); 90fa7767c5Sopenharmony_ci ASSERT_TRUE(speedStatus == Status::OK); 91fa7767c5Sopenharmony_ci} 92fa7767c5Sopenharmony_ci 93fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_set_speed, TestSize.Level1) 94fa7767c5Sopenharmony_ci{ 95fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("set speed"); 96fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 97fa7767c5Sopenharmony_ci float speed = 0.0f; 98fa7767c5Sopenharmony_ci auto speedStatus = audioSinkPlugin->SetSpeed(speed); 99fa7767c5Sopenharmony_ci ASSERT_TRUE(speedStatus == Status::OK); 100fa7767c5Sopenharmony_ci} 101fa7767c5Sopenharmony_ci 102fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_get_frame_size, TestSize.Level1) 103fa7767c5Sopenharmony_ci{ 104fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("get frame size"); 105fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 106fa7767c5Sopenharmony_ci size_t frameSize; 107fa7767c5Sopenharmony_ci auto frameSizeStatus = audioSinkPlugin->GetFrameSize(frameSize); 108fa7767c5Sopenharmony_ci ASSERT_TRUE(frameSizeStatus == Status::OK); 109fa7767c5Sopenharmony_ci} 110fa7767c5Sopenharmony_ci 111fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_set_frame_count, TestSize.Level1) 112fa7767c5Sopenharmony_ci{ 113fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("set frame count"); 114fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 115fa7767c5Sopenharmony_ci uint32_t frameCount; 116fa7767c5Sopenharmony_ci auto frameCountStatus = audioSinkPlugin->GetFrameCount(frameCount); 117fa7767c5Sopenharmony_ci ASSERT_TRUE(frameCountStatus == Status::OK); 118fa7767c5Sopenharmony_ci} 119fa7767c5Sopenharmony_ci 120fa7767c5Sopenharmony_ciHWTEST(TestAudioSinkPlugin, find_audio_sink_plugins_get_latency, TestSize.Level1) 121fa7767c5Sopenharmony_ci{ 122fa7767c5Sopenharmony_ci std::shared_ptr<AudioSinkPlugin> audioSinkPlugin = AudioServerSinkPluginCreate("get latency"); 123fa7767c5Sopenharmony_ci ASSERT_TRUE(audioSinkPlugin != nullptr); 124fa7767c5Sopenharmony_ci uint64_t hstTime; 125fa7767c5Sopenharmony_ci auto latencyStatus = audioSinkPlugin->GetLatency(hstTime); 126fa7767c5Sopenharmony_ci ASSERT_TRUE(latencyStatus == Status::OK); 127fa7767c5Sopenharmony_ci} 128fa7767c5Sopenharmony_ci 129fa7767c5Sopenharmony_ci} // namespace Test 130fa7767c5Sopenharmony_ci} // namespace Media 131fa7767c5Sopenharmony_ci} // namespace OHOS