1 /* 2 * Copyright (C) 2023 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 #ifndef SOUNDPOOL_UNIT_TEST_H 16 #define SOUNDPOOL_UNIT_TEST_H 17 18 #include "gtest/gtest.h" 19 #include "soundpool_mock.h" 20 21 namespace OHOS { 22 namespace Media { 23 class SoundPoolUnitTest : public testing::Test { 24 public: 25 static void SetUpTestCase(void); 26 static void TearDownTestCase(void); 27 void SetUp(void); 28 void TearDown(void); 29 30 protected: 31 static const int32_t SOUND_NUM = 4; 32 static const int32_t waitTime1 = 1; 33 static const int32_t waitTime2 = 2; 34 static const int32_t waitTime3 = 3; 35 static const int32_t waitTime10 = 10; 36 static const int32_t waitTime20 = 20; 37 static const int32_t waitTime30 = 30; 38 int32_t loadNum_ = 0; 39 int32_t playNum_ = 0; 40 int32_t soundIDs_[SOUND_NUM]; 41 int32_t streamIDs_[SOUND_NUM]; 42 int32_t fds_[SOUND_NUM]; 43 std::shared_ptr<SoundPoolMock> soundPool_ = nullptr; 44 std::shared_ptr<SoundPoolParallelMock> soundPoolParallel_ = nullptr; 45 void create(int maxStreams); 46 void loadUrl(std::string fileName, int32_t loadNum); 47 void loadFd(std::string fileName, int32_t loadNum); 48 void functionTest043(std::shared_ptr<SoundPoolMock> soundPool1, std::shared_ptr<SoundPoolMock> soundPool2, 49 std::shared_ptr<SoundPoolCallbackTest> cb1, std::shared_ptr<SoundPoolCallbackTest> cb2); 50 void functionTest094(std::shared_ptr<SoundPoolMock> soundPool1, std::shared_ptr<SoundPoolMock> soundPool2, 51 std::shared_ptr<SoundPoolCallbackTest> cb1, std::shared_ptr<SoundPoolCallbackTest> cb2); 52 void functionTest095(std::shared_ptr<SoundPoolMock> soundPool1, std::shared_ptr<SoundPoolMock> soundPool2, 53 std::shared_ptr<SoundPoolCallbackTest> cb1, std::shared_ptr<SoundPoolCallbackTest> cb2); 54 55 void loadUrlParallel(std::string fileName, int32_t loadNum); 56 void loadFdParallel(std::string fileName, int32_t loadNum); 57 void functionTest086(std::shared_ptr<SoundPoolParallelMock> soundPool1, 58 std::shared_ptr<SoundPoolParallelMock> soundPool2, std::shared_ptr<SoundPoolCallbackTest> cb1, 59 std::shared_ptr<SoundPoolCallbackTest> cb2); 60 }; 61 } // namespace Media 62 } // namespace OHOS 63 #endif