• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "soundpool_unit_test.h"
17 #include "media_errors.h"
18 #include "stream_id_manager.h"
19 
20 using namespace OHOS;
21 using namespace OHOS::Media;
22 using namespace testing::ext;
23 using namespace std;
24 
25 static const std::string g_fileName[6] = {
26     {"/data/test/test_06.ogg"},
27     {"/data/test/test_02.mp3"},
28     {"/data/test/test_01.mp3"},
29     {"/data/test/test_05.ogg"},
30     {"/data/test/test_03.mp3"},
31     {"/data/test/test_04.mp3"},
32 };
33 
34 const int32_t MAX_STREAMS = 3;
35 
36 namespace OHOS {
37 namespace Media {
SetUpTestCase(void)38 void SoundPoolUnitTest::SetUpTestCase(void) {}
39 
TearDownTestCase(void)40 void SoundPoolUnitTest::TearDownTestCase(void) {}
41 
SetUp(void)42 void SoundPoolUnitTest::SetUp(void)
43 {
44     soundPool_ = std::make_shared<SoundPoolMock>();
45     ASSERT_NE(nullptr, soundPool_);
46     soundPoolParallel_ = std::make_shared<SoundPoolParallelMock>();
47     ASSERT_NE(nullptr, soundPoolParallel_);
48 }
49 
TearDown(void)50 void SoundPoolUnitTest::TearDown(void)
51 {
52     for (auto soundId : soundIDs_) {
53         if (soundId != 0) {
54             soundId = 0;
55         }
56     }
57     for (auto streamId : streamIDs_) {
58         if (streamId != 0) {
59             streamId = 0;
60         }
61     }
62     for (auto fd : fds_) {
63         if (fd != 0) {
64             fd = 0;
65         }
66     }
67     if (loadNum_ != 0 || playNum_ != 0) {
68         loadNum_ = 0;
69         playNum_ = 0;
70     }
71 
72     if (soundPool_ != nullptr) {
73         int32_t ret = soundPool_->Release();
74         soundPool_ = nullptr;
75         EXPECT_EQ(MSERR_OK, ret);
76     }
77     if (soundPoolParallel_ != nullptr) {
78         int32_t ret = soundPoolParallel_->Release();
79         soundPoolParallel_ = nullptr;
80         EXPECT_EQ(MSERR_OK, ret);
81     }
82     sleep(waitTime1);
83 }
84 
create(int maxStreams)85 void SoundPoolUnitTest::create(int maxStreams)
86 {
87     AudioStandard::AudioRendererInfo audioRenderInfo;
88     audioRenderInfo.contentType = CONTENT_TYPE_MUSIC;
89     audioRenderInfo.streamUsage = STREAM_USAGE_MUSIC;
90     audioRenderInfo.rendererFlags = 0;
91     if (soundPool_ == nullptr) {
92         cout << "create soundpool failed" << endl;
93     } else {
94         EXPECT_TRUE(soundPool_->CreateSoundPool(maxStreams, audioRenderInfo));
95     }
96     if (soundPoolParallel_ == nullptr) {
97         cout << "create soundPoolParallel_ failed" << endl;
98     } else {
99         EXPECT_TRUE(soundPoolParallel_->CreateParallelSoundPool(maxStreams, audioRenderInfo));
100     }
101 }
102 
loadUrl(std::string fileName,int32_t loadNum)103 void SoundPoolUnitTest::loadUrl(std::string fileName, int32_t loadNum)
104 {
105     fds_[loadNum] = open(fileName.c_str(), O_RDWR);
106     if (fds_[loadNum] > 0) {
107         std::string url = "fd://" + std::to_string(fds_[loadNum]);
108         soundIDs_[loadNum] = soundPool_->Load(url);
109     } else {
110         cout << "Url open failed, g_fileName " << fileName.c_str() << ", fd: " << fds_[loadNum] << endl;
111     }
112     EXPECT_GT(soundIDs_[loadNum], 0);
113 }
114 
loadFd(std::string fileName,int32_t loadNum)115 void SoundPoolUnitTest::loadFd(std::string fileName, int32_t loadNum)
116 {
117     fds_[loadNum] = open(fileName.c_str(), O_RDONLY);
118     if (fds_[loadNum] < 0) {
119         cout << "Fd open failed, g_fileName " << fileName.c_str() << ", Fd: " << fds_[loadNum] << endl;
120     }
121     size_t filesize = soundPool_->GetFileSize(fileName);
122     EXPECT_NE(filesize, 0);
123     soundIDs_[loadNum] = soundPool_->Load(fds_[loadNum], 0, filesize);
124     EXPECT_GT(soundIDs_[loadNum], 0);
125 }
126 
loadUrlParallel(std::string fileName,int32_t loadNum)127 void SoundPoolUnitTest::loadUrlParallel(std::string fileName, int32_t loadNum)
128 {
129     fds_[loadNum] = open(fileName.c_str(), O_RDWR);
130     if (fds_[loadNum] > 0) {
131         std::string url = "fd://" + std::to_string(fds_[loadNum]);
132         soundIDs_[loadNum] = soundPoolParallel_->Load(url);
133     } else {
134         cout << "Url open failed, g_fileName " << fileName.c_str() << ", fd: " << fds_[loadNum] << endl;
135     }
136     EXPECT_GT(soundIDs_[loadNum], 0);
137 }
138 
loadFdParallel(std::string fileName,int32_t loadNum)139 void SoundPoolUnitTest::loadFdParallel(std::string fileName, int32_t loadNum)
140 {
141     fds_[loadNum] = open(fileName.c_str(), O_RDONLY);
142     if (fds_[loadNum] < 0) {
143         cout << "Fd open failed, g_fileName " << fileName.c_str() << ", Fd: " << fds_[loadNum] << endl;
144     }
145     size_t filesize = soundPoolParallel_->GetFileSize(fileName);
146     EXPECT_NE(filesize, 0);
147     soundIDs_[loadNum] = soundPoolParallel_->Load(fds_[loadNum], 0, filesize);
148     EXPECT_GT(soundIDs_[loadNum], 0);
149 }
150 
151 /**
152  * @tc.name: soundpool_function_001
153  * @tc.desc: function test Load Url one more time
154  * @tc.type: FUNC
155  * @tc.require:
156  */
157 HWTEST_F(SoundPoolUnitTest, soundpool_function_001, TestSize.Level2)
158 {
159     MEDIA_LOGI("soundpool_unit_test soundpool_function_001 before");
160     int maxStreams = 3;
161     create(maxStreams);
162     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
163     ASSERT_TRUE(cb != nullptr);
164     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
165     ASSERT_TRUE(ret == 0);
166     loadUrl(g_fileName[loadNum_], loadNum_);
167     loadNum_++;
168     loadUrl(g_fileName[loadNum_], loadNum_);
169     loadNum_++;
170     loadUrl(g_fileName[1], loadNum_);
171     loadNum_++;
172     loadUrl(g_fileName[1], loadNum_);
173     sleep(waitTime3);
174     ASSERT_TRUE(cb->WaitLoadedSoundNum(4));
175     cb->ResetHaveLoadedSoundNum();
176     MEDIA_LOGI("soundpool_unit_test soundpool_function_001 after");
177 }
178 
179 /**
180  * @tc.name: soundpool_function_002
181  * @tc.desc: function test Load Url with invalid path
182  * @tc.type: FUNC
183  * @tc.require:
184  */
185 HWTEST_F(SoundPoolUnitTest, soundpool_function_002, TestSize.Level2)
186 {
187     MEDIA_LOGI("soundpool_unit_test soundpool_function_002 before");
188     int maxStreams = 3;
189     create(maxStreams);
190     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
191     ASSERT_TRUE(cb != nullptr);
192     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
193     ASSERT_TRUE(ret == 0);
194     // test invalid path
195     std::string fileName = "/data/test/test_05.mp3";
196     fds_[loadNum_] = open(fileName.c_str(), O_RDWR);
197     std::string url = "fd://" + std::to_string(fds_[loadNum_]);
198     soundIDs_[loadNum_] = soundPool_->Load(url);
199     sleep(waitTime3);
200     if (fds_[loadNum_] == -1) {
201         cout << "Url open a invalid path: " << fileName.c_str() << endl;
202     }
203     EXPECT_EQ(soundIDs_[loadNum_], -1);
204     MEDIA_LOGI("soundpool_unit_test soundpool_function_002 after");
205 }
206 
207 /**
208  * @tc.name: soundpool_function_003
209  * @tc.desc: function test Load Url when no callback
210  * @tc.type: FUNC
211  * @tc.require:
212  */
213 HWTEST_F(SoundPoolUnitTest, soundpool_function_003, TestSize.Level2)
214 {
215     MEDIA_LOGI("soundpool_unit_test soundpool_function_003 before");
216     int maxStreams = 3;
217     create(maxStreams);
218     // test no callback to load
219     loadUrl(g_fileName[loadNum_], loadNum_);
220     sleep(waitTime3);
221     MEDIA_LOGI("soundpool_unit_test soundpool_function_003 after");
222 }
223 
224 /**
225  * @tc.name: soundpool_function_004
226  * @tc.desc: function test Load Url after play
227  * @tc.type: FUNC
228  * @tc.require:
229  */
230 HWTEST_F(SoundPoolUnitTest, soundpool_function_004, TestSize.Level2)
231 {
232     MEDIA_LOGI("soundpool_unit_test soundpool_function_004 before");
233     int maxStreams = 3;
234     create(maxStreams);
235     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
236     ASSERT_TRUE(cb != nullptr);
237     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
238     ASSERT_TRUE(ret == 0);
239     loadUrl(g_fileName[loadNum_], loadNum_);
240     sleep(waitTime3);
241     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
242     cb->ResetHaveLoadedSoundNum();
243     struct PlayParams playParameters;
244     if (soundIDs_[loadNum_] > 0) {
245         soundPool_->Play(soundIDs_[loadNum_], playParameters);
246         sleep(waitTime1);
247         loadNum_++;
248         loadUrl(g_fileName[loadNum_], loadNum_);
249         sleep(waitTime3);
250     } else {
251         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
252     }
253     cb->ResetHavePlayedSoundNum();
254     MEDIA_LOGI("soundpool_unit_test soundpool_function_004 after");
255 }
256 
257 /**
258  * @tc.name: soundpool_function_005
259  * @tc.desc: function test Load Fd one more time
260  * @tc.type: FUNC
261  * @tc.require:
262  */
263 HWTEST_F(SoundPoolUnitTest, soundpool_function_005, TestSize.Level2)
264 {
265     MEDIA_LOGI("soundpool_unit_test soundpool_function_005 before");
266     int maxStreams = 3;
267     create(maxStreams);
268     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
269     ASSERT_TRUE(cb != nullptr);
270     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
271     ASSERT_TRUE(ret == 0);
272     loadFd(g_fileName[loadNum_], loadNum_);
273     loadNum_++;
274     loadFd(g_fileName[loadNum_], loadNum_);
275     loadNum_++;
276     loadFd(g_fileName[1], loadNum_);
277     loadNum_++;
278     loadFd(g_fileName[1], loadNum_);
279     sleep(waitTime3);
280     ASSERT_TRUE(cb->WaitLoadedSoundNum(4));
281     cb->ResetHaveLoadedSoundNum();
282     MEDIA_LOGI("soundpool_unit_test soundpool_function_005 after");
283 }
284 
285 /**
286  * @tc.name: soundpool_function_006
287  * @tc.desc: function test Load Fd with invalid path
288  * @tc.type: FUNC
289  * @tc.require:
290  */
291 HWTEST_F(SoundPoolUnitTest, soundpool_function_006, TestSize.Level2)
292 {
293     MEDIA_LOGI("soundpool_unit_test soundpool_function_006 before");
294     int maxStreams = 3;
295     create(maxStreams);
296     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
297     ASSERT_TRUE(cb != nullptr);
298     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
299     ASSERT_TRUE(ret == 0);
300     std::string fileName = "/data/test/test_05.mp3";
301     fds_[loadNum_] = open(fileName.c_str(), O_RDONLY);
302     size_t filesize = soundPool_->GetFileSize(fileName);
303     EXPECT_EQ(filesize, 0);
304     soundIDs_[loadNum_] = soundPool_->Load(fds_[loadNum_], 0, filesize);
305     sleep(waitTime3);
306     if (fds_[loadNum_] == -1) {
307         cout << "Fd open a invalid path: " << fileName.c_str() << endl;
308     }
309     EXPECT_EQ(soundIDs_[loadNum_], -1);
310     MEDIA_LOGI("soundpool_unit_test soundpool_function_006 after");
311 }
312 
313 /**
314  * @tc.name: soundpool_function_007
315  * @tc.desc: function test Load Fd when no callback
316  * @tc.type: FUNC
317  * @tc.require:
318  */
319 HWTEST_F(SoundPoolUnitTest, soundpool_function_007, TestSize.Level2)
320 {
321     MEDIA_LOGI("soundpool_unit_test soundpool_function_007 before");
322     int maxStreams = 3;
323     create(maxStreams);
324     // test no callback to load
325     loadFd(g_fileName[loadNum_], loadNum_);
326     sleep(waitTime3);
327     MEDIA_LOGI("soundpool_unit_test soundpool_function_007 after");
328 }
329 
330 /**
331  * @tc.name: soundpool_function_008
332  * @tc.desc: function test Load Fd after paly
333  * @tc.type: FUNC
334  * @tc.require:
335  */
336 HWTEST_F(SoundPoolUnitTest, soundpool_function_008, TestSize.Level2)
337 {
338     MEDIA_LOGI("soundpool_unit_test soundpool_function_008 before");
339     int maxStreams = 3;
340     create(maxStreams);
341     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
342     ASSERT_TRUE(cb != nullptr);
343     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
344     ASSERT_TRUE(ret == 0);
345     loadFd(g_fileName[loadNum_], loadNum_);
346     sleep(waitTime3);
347     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
348     cb->ResetHaveLoadedSoundNum();
349     struct PlayParams playParameters;
350     if (soundIDs_[loadNum_] > 0) {
351         soundPool_->Play(soundIDs_[loadNum_], playParameters);
352         sleep(waitTime1);
353         loadNum_++;
354         loadFd(g_fileName[loadNum_], loadNum_);
355         sleep(waitTime3);
356     } else {
357         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
358     }
359     cb->ResetHavePlayedSoundNum();
360     MEDIA_LOGI("soundpool_unit_test soundpool_function_008 after");
361 }
362 
363 /**
364  * @tc.name: soundpool_function_009
365  * @tc.desc: function test UnLoad
366  * @tc.type: FUNC
367  * @tc.require:
368  */
369 HWTEST_F(SoundPoolUnitTest, soundpool_function_009, TestSize.Level2)
370 {
371     MEDIA_LOGI("soundpool_unit_test soundpool_function_009 before");
372     int maxStreams = 3;
373     create(maxStreams);
374     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
375     ASSERT_TRUE(cb != nullptr);
376     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
377     ASSERT_TRUE(ret == 0);
378     loadUrl(g_fileName[loadNum_], loadNum_);
379     loadNum_++;
380     loadUrl(g_fileName[loadNum_], loadNum_);
381     loadNum_++;
382     loadFd(g_fileName[loadNum_], loadNum_);
383     loadNum_++;
384     loadFd(g_fileName[loadNum_], loadNum_);
385     sleep(waitTime3);
386 
387     ASSERT_TRUE(cb->WaitLoadedSoundNum(4));
388     cb->ResetHaveLoadedSoundNum();
389     EXPECT_EQ(MSERR_OK, soundPool_->Unload(soundIDs_[0]));
390     EXPECT_EQ(MSERR_OK, soundPool_->Unload(soundIDs_[1]));
391     EXPECT_EQ(MSERR_OK, soundPool_->Unload(soundIDs_[2]));
392     EXPECT_EQ(MSERR_OK, soundPool_->Unload(soundIDs_[3]));
393     MEDIA_LOGI("soundpool_unit_test soundpool_function_009 after");
394 }
395 
396 /**
397  * @tc.name: soundpool_function_010
398  * @tc.desc: function test UnLoad with error path
399  * @tc.type: FUNC
400  * @tc.require:
401  */
402 HWTEST_F(SoundPoolUnitTest, soundpool_function_010, TestSize.Level2)
403 {
404     MEDIA_LOGI("soundpool_unit_test soundpool_function_010 before");
405     int maxStreams = 3;
406     create(maxStreams);
407     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
408     ASSERT_TRUE(cb != nullptr);
409     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
410     ASSERT_TRUE(ret == 0);
411     std::string fileName = "/data/test/test_05.mp3";
412     fds_[loadNum_] = open(fileName.c_str(), O_RDWR);
413     std::string url = "fd://" + std::to_string(fds_[loadNum_]);
414     soundIDs_[loadNum_] = soundPool_->Load(url);
415     if (fds_[loadNum_] == -1) {
416         cout << "Url open a invalid path: " << fileName.c_str() << endl;
417     }
418     EXPECT_EQ(soundIDs_[loadNum_], -1);
419     loadNum_++;
420     fds_[loadNum_] = open(fileName.c_str(), O_RDONLY);
421     size_t filesize = soundPool_->GetFileSize(fileName);
422     EXPECT_EQ(filesize, 0);
423     soundIDs_[loadNum_] = soundPool_->Load(fds_[loadNum_], 0, filesize);
424     sleep(waitTime3);
425     if (fds_[loadNum_] == -1) {
426         cout << "Fd open a invalid path: " << fileName.c_str() << endl;
427     }
428     EXPECT_EQ(soundIDs_[loadNum_], -1);
429     // test UnLoad a invalid-path return soundId
430     int32_t unload = soundPool_->Unload(soundIDs_[0]);
431     EXPECT_EQ(MSERR_NO_MEMORY, unload);
432     unload = soundPool_->Unload(soundIDs_[1]);
433     EXPECT_EQ(MSERR_NO_MEMORY, unload);
434     MEDIA_LOGI("soundpool_unit_test soundpool_function_010 after");
435 }
436 
437 /**
438  * @tc.name: soundpool_function_011
439  * @tc.desc: function test UnLoad with -1/5
440  * @tc.type: FUNC
441  * @tc.require:
442  */
443 HWTEST_F(SoundPoolUnitTest, soundpool_function_011, TestSize.Level2)
444 {
445     MEDIA_LOGI("soundpool_unit_test soundpool_function_011 before");
446     int maxStreams = 3;
447     create(maxStreams);
448     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
449     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
450     if (ret != 0) {
451         cout << "set callback failed" << endl;
452     }
453     // test unload -1
454     int32_t unload = soundPool_->Unload(-1);
455     EXPECT_EQ(MSERR_NO_MEMORY, unload);
456     // test unload 5
457     unload = soundPool_->Unload(5);
458     EXPECT_EQ(MSERR_NO_MEMORY, unload);
459     MEDIA_LOGI("soundpool_unit_test soundpool_function_011 after");
460 }
461 
462 /**
463  * @tc.name: soundpool_function_012
464  * @tc.desc: function test Play with undefault playParameters
465  * @tc.type: FUNC
466  * @tc.require:
467  */
468 HWTEST_F(SoundPoolUnitTest, soundpool_function_012, TestSize.Level2)
469 {
470     MEDIA_LOGI("soundpool_unit_test soundpool_function_012 before");
471     int maxStreams = 3;
472     create(maxStreams);
473     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
474     ASSERT_TRUE(cb != nullptr);
475     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
476     ASSERT_TRUE(ret == 0);
477 
478     loadUrl(g_fileName[loadNum_], loadNum_);
479     sleep(waitTime3);
480     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
481     cb->ResetHaveLoadedSoundNum();
482     struct PlayParams playParameters;
483     playParameters.loop = -1;
484     playParameters.rate = 1;
485     playParameters.leftVolume = 0.5;
486     playParameters.rightVolume = 0.3;
487     playParameters.priority = 1;
488     playParameters.parallelPlayFlag = true;
489     if (soundIDs_[loadNum_] > 0) {
490         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
491         EXPECT_GT(streamIDs_[playNum_], 0);
492         sleep(waitTime3);
493     }
494     cb->ResetHavePlayedSoundNum();
495     MEDIA_LOGI("soundpool_unit_test soundpool_function_012 after");
496 }
497 
498 /**
499  * @tc.name: soundpool_function_013
500  * @tc.desc: function test Play with default playParameters
501  * @tc.type: FUNC
502  * @tc.require:
503  */
504 HWTEST_F(SoundPoolUnitTest, soundpool_function_013, TestSize.Level2)
505 {
506     MEDIA_LOGI("soundpool_unit_test soundpool_function_013 before");
507     int maxStreams = 3;
508     create(maxStreams);
509     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
510     ASSERT_TRUE(cb != nullptr);
511     soundPool_->SetSoundPoolCallback(cb);
512     loadUrl(g_fileName[loadNum_], loadNum_);
513     sleep(waitTime3);
514     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
515     cb->ResetHaveLoadedSoundNum();
516     struct PlayParams playParameters;
517     if (soundIDs_[loadNum_] > 0) {
518         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
519         EXPECT_GT(streamIDs_[playNum_], 0);
520         sleep(waitTime3);
521         playNum_++;
522         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
523         EXPECT_GT(streamIDs_[playNum_], 0);
524         sleep(waitTime3);
525         playNum_++;
526         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
527         EXPECT_GT(streamIDs_[playNum_], 0);
528         sleep(waitTime3);
529         playNum_++;
530         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
531         EXPECT_GT(streamIDs_[playNum_], 0);
532         sleep(waitTime3);
533     } else {
534         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
535     }
536     cb->ResetHavePlayedSoundNum();
537     MEDIA_LOGI("soundpool_unit_test soundpool_function_013 after");
538 }
539 
540 /**
541  * @tc.name: soundpool_function_014
542  * @tc.desc: function test Play with error soundID
543  * @tc.type: FUNC
544  * @tc.require:
545  */
546 HWTEST_F(SoundPoolUnitTest, soundpool_function_014, TestSize.Level2)
547 {
548     MEDIA_LOGI("soundpool_unit_test soundpool_function_014 before");
549     int maxStreams = 3;
550     create(maxStreams);
551     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
552     ASSERT_TRUE(cb != nullptr);
553     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
554     ASSERT_TRUE(ret == 0);
555     struct PlayParams playParameters;
556     streamIDs_[playNum_] = soundPool_->Play(5, playParameters);
557     cout << "soundId 5 play, result: " << streamIDs_[playNum_] << endl;
558     EXPECT_EQ(streamIDs_[playNum_], -1);
559     sleep(waitTime1);
560     cb->ResetHavePlayedSoundNum();
561     MEDIA_LOGI("soundpool_unit_test soundpool_function_014 after");
562 }
563 
564 /**
565  * @tc.name: soundpool_function_015
566  * @tc.desc: function test Play with not load number -1
567  * @tc.type: FUNC
568  * @tc.require:
569  */
570 HWTEST_F(SoundPoolUnitTest, soundpool_function_015, TestSize.Level2)
571 {
572     MEDIA_LOGI("soundpool_unit_test soundpool_function_015 before");
573     int maxStreams = 3;
574     create(maxStreams);
575     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
576     ASSERT_TRUE(cb != nullptr);
577     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
578     ASSERT_TRUE(ret == 0);
579     struct PlayParams playParameters;
580     streamIDs_[playNum_] = soundPool_->Play(-1, playParameters);
581     cout << "soundId -1 play, result: " << streamIDs_[playNum_] << endl;
582     EXPECT_EQ(streamIDs_[playNum_], -1);
583     sleep(waitTime1);
584     cb->ResetHavePlayedSoundNum();
585     MEDIA_LOGI("soundpool_unit_test soundpool_function_015 after");
586 }
587 
588 /**
589  * @tc.name: soundpool_function_016
590  * @tc.desc: function test Play with different soundID
591  * @tc.type: FUNC
592  * @tc.require:
593  */
594 HWTEST_F(SoundPoolUnitTest, soundpool_function_016, TestSize.Level2)
595 {
596     MEDIA_LOGI("soundpool_unit_test soundpool_function_016 before");
597     int maxStreams = 3;
598     create(maxStreams);
599     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
600     ASSERT_TRUE(cb != nullptr);
601     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
602     ASSERT_TRUE(ret == 0);
603     loadUrl(g_fileName[loadNum_], loadNum_);
604     loadNum_++;
605     loadUrl(g_fileName[loadNum_], loadNum_);
606     sleep(waitTime3);
607     ASSERT_TRUE(cb->WaitLoadedSoundNum(2));
608     cb->ResetHaveLoadedSoundNum();
609     struct PlayParams playParameters;
610     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
611     EXPECT_GT(streamIDs_[playNum_], 0);
612     sleep(waitTime1);
613     playNum_++;
614     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
615     EXPECT_GT(streamIDs_[playNum_], 0);
616     cb->ResetHavePlayedSoundNum();
617     MEDIA_LOGI("soundpool_unit_test soundpool_function_016 after");
618 }
619 
620 /**
621  * @tc.name: soundpool_function_017
622  * @tc.desc: function test Stop with same streamId
623  * @tc.type: FUNC
624  * @tc.require:
625  */
626 HWTEST_F(SoundPoolUnitTest, soundpool_function_017, TestSize.Level2)
627 {
628     MEDIA_LOGI("soundpool_unit_test soundpool_function_017 before");
629     int maxStreams = 3;
630     create(maxStreams);
631     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
632     ASSERT_TRUE(cb != nullptr);
633     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
634     ASSERT_TRUE(ret == 0);
635     loadUrl(g_fileName[loadNum_], loadNum_);
636     sleep(waitTime3);
637     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
638     cb->ResetHaveLoadedSoundNum();
639     struct PlayParams playParameters;
640     if (soundIDs_[loadNum_] > 0) {
641         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
642         EXPECT_GT(streamIDs_[playNum_], 0);
643         sleep(waitTime1);
644     }
645     cb->ResetHavePlayedSoundNum();
646     if (streamIDs_[playNum_] > 0) {
647         int32_t stopResult = soundPool_->Stop(streamIDs_[playNum_]);
648         EXPECT_EQ(MSERR_OK, stopResult);
649         sleep(waitTime1);
650         int32_t stopResult1 = soundPool_->Stop(streamIDs_[playNum_]);
651         EXPECT_EQ(MSERR_OK, stopResult1);
652     }
653     MEDIA_LOGI("soundpool_unit_test soundpool_function_017 after");
654 }
655 
656 /**
657  * @tc.name: soundpool_function_018
658  * @tc.desc: function test Stop with different streamId
659  * @tc.type: FUNC
660  * @tc.require:
661  */
662 HWTEST_F(SoundPoolUnitTest, soundpool_function_018, TestSize.Level2)
663 {
664     MEDIA_LOGI("soundpool_unit_test soundpool_function_018 before");
665     int maxStreams = 3;
666     create(maxStreams);
667     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
668     ASSERT_TRUE(cb != nullptr);
669     soundPool_->SetSoundPoolCallback(cb);
670     loadUrl(g_fileName[loadNum_], loadNum_);
671     loadNum_++;
672     loadFd(g_fileName[loadNum_], loadNum_);
673     sleep(waitTime3);
674     ASSERT_TRUE(cb->WaitLoadedSoundNum(2));
675     cb->ResetHaveLoadedSoundNum();
676     struct PlayParams playParameters;
677     if (soundIDs_[0] > 0) {
678         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
679         EXPECT_GT(streamIDs_[playNum_], 0);
680         sleep(waitTime1);
681     }
682     playNum_++;
683     if (soundIDs_[1] > 0) {
684         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
685         EXPECT_GT(streamIDs_[playNum_], 0);
686         sleep(waitTime1);
687     }
688     cb->ResetHavePlayedSoundNum();
689     if (streamIDs_[0] > 0) {
690         EXPECT_EQ(MSERR_OK, soundPool_->Stop(streamIDs_[0]));
691     }
692     if (streamIDs_[1] > 0) {
693         EXPECT_EQ(MSERR_OK, soundPool_->Stop(streamIDs_[1]));
694     }
695     MEDIA_LOGI("soundpool_unit_test soundpool_function_018 after");
696 }
697 
698 /**
699  * @tc.name: soundpool_function_019
700  * @tc.desc: function test not Stop all streamId
701  * @tc.type: FUNC
702  * @tc.require:
703  */
704 HWTEST_F(SoundPoolUnitTest, soundpool_function_019, TestSize.Level2)
705 {
706     MEDIA_LOGI("soundpool_unit_test soundpool_function_019 before");
707     int maxStreams = 3;
708     create(maxStreams);
709     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
710     ASSERT_TRUE(cb != nullptr);
711     soundPool_->SetSoundPoolCallback(cb);
712     loadUrl(g_fileName[loadNum_], loadNum_);
713     loadNum_++;
714     loadFd(g_fileName[loadNum_], loadNum_);
715     loadNum_++;
716     loadUrl(g_fileName[loadNum_], loadNum_);
717     sleep(waitTime3);
718     ASSERT_TRUE(cb->WaitLoadedSoundNum(3));
719     cb->ResetHaveLoadedSoundNum();
720     struct PlayParams playParameters;
721     if (soundIDs_[0] > 0) {
722         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
723         EXPECT_GT(streamIDs_[playNum_], 0);
724     }
725     playNum_++;
726     if (soundIDs_[1] > 0) {
727         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
728         EXPECT_GT(streamIDs_[playNum_], 0);
729         sleep(waitTime1);
730     }
731     playNum_++;
732     if (soundIDs_[2] > 0) {
733         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[2], playParameters);
734         EXPECT_GT(streamIDs_[playNum_], 0);
735         sleep(waitTime1);
736     }
737     cb->ResetHavePlayedSoundNum();
738     EXPECT_EQ(MSERR_OK, soundPool_->Stop(streamIDs_[0]));
739     EXPECT_EQ(MSERR_OK, soundPool_->Stop(streamIDs_[2]));
740     MEDIA_LOGI("soundpool_unit_test soundpool_function_019 after");
741 }
742 
743 /**
744  * @tc.name: soundpool_function_020
745  * @tc.desc: function test Stop with -1
746  * @tc.type: FUNC
747  * @tc.require:
748  */
749 HWTEST_F(SoundPoolUnitTest, soundpool_function_020, TestSize.Level2)
750 {
751     MEDIA_LOGI("soundpool_unit_test soundpool_function_020 before");
752     int maxStreams = 3;
753     create(maxStreams);
754     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
755     ASSERT_TRUE(cb != nullptr);
756     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
757     ASSERT_TRUE(ret == 0);
758     loadUrl(g_fileName[loadNum_], loadNum_);
759     sleep(waitTime3);
760     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
761     cb->ResetHaveLoadedSoundNum();
762     int32_t stopResult = soundPool_->Stop(-1);
763     EXPECT_EQ(MSERR_INVALID_OPERATION, stopResult);
764     MEDIA_LOGI("soundpool_unit_test soundpool_function_020 after");
765 }
766 
767 /**
768  * @tc.name: soundpool_function_021
769  * @tc.desc: function test SetLoop
770  * @tc.type: FUNC
771  * @tc.require:
772  */
773 HWTEST_F(SoundPoolUnitTest, soundpool_function_021, TestSize.Level2)
774 {
775     MEDIA_LOGI("soundpool_unit_test soundpool_function_021 before");
776     int maxStreams = 3;
777     create(maxStreams);
778     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
779     ASSERT_TRUE(cb != nullptr);
780     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
781     ASSERT_TRUE(ret == 0);
782     loadUrl(g_fileName[loadNum_], loadNum_);
783     sleep(waitTime3);
784     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
785     cb->ResetHaveLoadedSoundNum();
786     struct PlayParams playParameters;
787     playParameters.loop = 0;
788     int32_t loop = -1;
789     if (soundIDs_[loadNum_] > 0) {
790         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
791         EXPECT_GT(streamIDs_[playNum_], 0);
792         sleep(waitTime1);
793         int32_t setPool = soundPool_->SetLoop(streamIDs_[playNum_], loop);
794         EXPECT_EQ(MSERR_OK, setPool);
795         sleep(waitTime1);
796     } else {
797         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
798     }
799     cb->ResetHavePlayedSoundNum();
800     EXPECT_EQ(MSERR_OK, soundPool_->Unload(soundIDs_[loadNum_]));
801     MEDIA_LOGI("soundpool_unit_test soundpool_function_021 after");
802 }
803 
804 /**
805  * @tc.name: soundpool_function_022
806  * @tc.desc: function test SetLoop 3
807  * @tc.type: FUNC
808  * @tc.require:
809  */
810 HWTEST_F(SoundPoolUnitTest, soundpool_function_022, TestSize.Level2)
811 {
812     MEDIA_LOGI("soundpool_unit_test soundpool_function_022 before");
813     int maxStreams = 3;
814     create(maxStreams);
815     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
816     ASSERT_TRUE(cb != nullptr);
817     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
818     ASSERT_TRUE(ret == 0);
819     loadUrl(g_fileName[loadNum_], loadNum_);
820     sleep(waitTime3);
821     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
822     cb->ResetHaveLoadedSoundNum();
823     struct PlayParams playParameters;
824     playParameters.loop = 0;
825     int32_t loop = 3;
826     if (soundIDs_[loadNum_] > 0) {
827         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
828         EXPECT_GT(streamIDs_[playNum_], 0);
829         sleep(waitTime1);
830         int32_t setPool = soundPool_->SetLoop(streamIDs_[playNum_], loop);
831         EXPECT_EQ(MSERR_OK, setPool);
832         sleep(waitTime1);
833     } else {
834         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
835     }
836     cb->ResetHavePlayedSoundNum();
837     MEDIA_LOGI("soundpool_unit_test soundpool_function_022 after");
838 }
839 
840 /**
841  * @tc.name: soundpool_function_023
842  * @tc.desc: function test SetLoop -2
843  * @tc.type: FUNC
844  * @tc.require:
845  */
846 HWTEST_F(SoundPoolUnitTest, soundpool_function_023, TestSize.Level2)
847 {
848     MEDIA_LOGI("soundpool_unit_test soundpool_function_023 before");
849     int maxStreams = 3;
850     create(maxStreams);
851     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
852     ASSERT_TRUE(cb != nullptr);
853     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
854     ASSERT_TRUE(ret == 0);
855     loadUrl(g_fileName[loadNum_], loadNum_);
856     sleep(waitTime3);
857     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
858     cb->ResetHaveLoadedSoundNum();
859     struct PlayParams playParameters;
860     playParameters.loop = 0;
861     int32_t loop = -2;
862     if (soundIDs_[loadNum_] > 0) {
863         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
864         EXPECT_GT(streamIDs_[playNum_], 0);
865         sleep(waitTime1);
866         int32_t setPool = soundPool_->SetLoop(streamIDs_[playNum_], loop);
867         EXPECT_EQ(MSERR_OK, setPool);
868         sleep(waitTime1);
869     } else {
870         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
871     }
872     cb->ResetHavePlayedSoundNum();
873     MEDIA_LOGI("soundpool_unit_test soundpool_function_023 after");
874 }
875 
876 /**
877  * @tc.name: soundpool_function_024
878  * @tc.desc: function test SetLoop -1, streamID is -1
879  * @tc.type: FUNC
880  * @tc.require:
881  */
882 HWTEST_F(SoundPoolUnitTest, soundpool_function_024, TestSize.Level2)
883 {
884     MEDIA_LOGI("soundpool_unit_test soundpool_function_024 before");
885     int maxStreams = 3;
886     create(maxStreams);
887     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
888     ASSERT_TRUE(cb != nullptr);
889     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
890     ASSERT_TRUE(ret == 0);
891     loadUrl(g_fileName[loadNum_], loadNum_);
892     sleep(waitTime3);
893     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
894     cb->ResetHaveLoadedSoundNum();
895     struct PlayParams playParameters;
896     playParameters.loop = 0;
897     int32_t loop = -1;
898     if (soundIDs_[loadNum_] > 0) {
899         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
900         EXPECT_GT(streamIDs_[playNum_], 0);
901         sleep(waitTime1);
902         int32_t setPool = soundPool_->SetLoop(-1, loop);
903         EXPECT_EQ(MSERR_INVALID_OPERATION, setPool);
904         sleep(waitTime1);
905     } else {
906         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
907     }
908     cb->ResetHavePlayedSoundNum();
909     MEDIA_LOGI("soundpool_unit_test soundpool_function_024 after");
910 }
911 
912 /**
913  * @tc.name: soundpool_function_025
914  * @tc.desc: function test SetLoop 2 with different streamId
915  * @tc.type: FUNC
916  * @tc.require:
917  */
918 HWTEST_F(SoundPoolUnitTest, soundpool_function_025, TestSize.Level2)
919 {
920     MEDIA_LOGI("soundpool_unit_test soundpool_function_025 before");
921     int maxStreams = 3;
922     create(maxStreams);
923     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
924     ASSERT_TRUE(cb != nullptr);
925     soundPool_->SetSoundPoolCallback(cb);
926     loadUrl(g_fileName[loadNum_], loadNum_);
927     loadNum_++;
928     loadUrl(g_fileName[loadNum_], loadNum_);
929     sleep(waitTime3);
930     ASSERT_TRUE(cb->WaitLoadedSoundNum(2));
931     cb->ResetHaveLoadedSoundNum();
932     struct PlayParams playParameters;
933     int32_t loop = 2;
934     if (soundIDs_[0] > 0) {
935         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
936         EXPECT_GT(streamIDs_[playNum_], 0);
937         sleep(waitTime1);
938         int32_t setPool = soundPool_->SetLoop(streamIDs_[playNum_], loop);
939         EXPECT_EQ(MSERR_OK, setPool);
940         sleep(waitTime3);
941         playNum_++;
942         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
943         EXPECT_GT(streamIDs_[playNum_], 0);
944         sleep(waitTime1);
945         int32_t setPool1 = soundPool_->SetLoop(streamIDs_[playNum_], loop);
946         EXPECT_EQ(MSERR_OK, setPool1);
947         sleep(waitTime3);
948     } else {
949         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
950     }
951     cb->ResetHavePlayedSoundNum();
952     MEDIA_LOGI("soundpool_unit_test soundpool_function_025 after");
953 }
954 
955 /**
956  * @tc.name: soundpool_function_026
957  * @tc.desc: function test SetLoop different loop with different streamId
958  * @tc.type: FUNC
959  * @tc.require:
960  */
961 HWTEST_F(SoundPoolUnitTest, soundpool_function_026, TestSize.Level2)
962 {
963     MEDIA_LOGI("soundpool_unit_test soundpool_function_026 before");
964     int maxStreams = 3;
965     create(maxStreams);
966     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
967     ASSERT_TRUE(cb != nullptr);
968     soundPool_->SetSoundPoolCallback(cb);
969     loadUrl(g_fileName[loadNum_], loadNum_);
970     loadNum_++;
971     loadUrl(g_fileName[loadNum_], loadNum_);
972     sleep(waitTime3);
973     ASSERT_TRUE(cb->WaitLoadedSoundNum(2));
974     cb->ResetHaveLoadedSoundNum();
975     struct PlayParams playParameters;
976     int32_t loop = 2;
977     if (soundIDs_[0] > 0) {
978         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
979         EXPECT_GT(streamIDs_[playNum_], 0);
980         sleep(waitTime1);
981         int32_t setPool = soundPool_->SetLoop(streamIDs_[playNum_], loop);
982         EXPECT_EQ(MSERR_OK, setPool);
983         sleep(waitTime3);
984         playNum_++;
985         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
986         EXPECT_GT(streamIDs_[playNum_], 0);
987         sleep(waitTime1);
988         int32_t setPool1 = soundPool_->SetLoop(streamIDs_[playNum_], -1);
989         EXPECT_EQ(MSERR_OK, setPool1);
990         sleep(waitTime3);
991     } else {
992         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
993     }
994     cb->ResetHavePlayedSoundNum();
995     MEDIA_LOGI("soundpool_unit_test soundpool_function_026 after");
996 }
997 
998 /**
999  * @tc.name: soundpool_function_027
1000  * @tc.desc: function test SetRate with different rate
1001  * @tc.type: FUNC
1002  * @tc.require:
1003  */
1004 HWTEST_F(SoundPoolUnitTest, soundpool_function_027, TestSize.Level2)
1005 {
1006     MEDIA_LOGI("soundpool_unit_test soundpool_function_027 before");
1007     int maxStreams = 3;
1008     create(maxStreams);
1009     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1010     ASSERT_TRUE(cb != nullptr);
1011     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
1012     ASSERT_TRUE(ret == 0);
1013     loadUrl(g_fileName[loadNum_], loadNum_);
1014     sleep(waitTime3);
1015     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
1016     cb->ResetHaveLoadedSoundNum();
1017     struct PlayParams playParameters;
1018     playParameters.loop = -1;
1019     if (soundIDs_[loadNum_] > 0) {
1020         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
1021         EXPECT_GT(streamIDs_[playNum_], 0);
1022         sleep(waitTime1);
1023         int32_t setRateResult = soundPool_->SetRate(streamIDs_[playNum_], AudioRendererRate::RENDER_RATE_DOUBLE);
1024         EXPECT_EQ(MSERR_OK, setRateResult);
1025         sleep(waitTime3);
1026         int32_t setRateResult1 = soundPool_->SetRate(streamIDs_[playNum_], AudioRendererRate::RENDER_RATE_HALF);
1027         EXPECT_EQ(MSERR_OK, setRateResult1);
1028         sleep(waitTime3);
1029     } else {
1030         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
1031     }
1032 
1033     cb->ResetHavePlayedSoundNum();
1034     MEDIA_LOGI("soundpool_unit_test soundpool_function_027 after");
1035 }
1036 
1037 /**
1038  * @tc.name: soundpool_function_028
1039  * @tc.desc: function test SetRate with different rate and streamID
1040  * @tc.type: FUNC
1041  * @tc.require:
1042  */
1043 HWTEST_F(SoundPoolUnitTest, soundpool_function_028, TestSize.Level2)
1044 {
1045     MEDIA_LOGI("soundpool_unit_test soundpool_function_028 before");
1046     int maxStreams = 3;
1047     create(maxStreams);
1048     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1049     ASSERT_TRUE(cb != nullptr);
1050     soundPool_->SetSoundPoolCallback(cb);
1051     loadUrl(g_fileName[loadNum_], loadNum_);
1052     loadNum_++;
1053     loadUrl(g_fileName[loadNum_], loadNum_);
1054     sleep(waitTime3);
1055     ASSERT_TRUE(cb->WaitLoadedSoundNum(2));
1056     cb->ResetHaveLoadedSoundNum();
1057     struct PlayParams playParameters;
1058     if (soundIDs_[0] > 0) {
1059         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1060         EXPECT_GT(streamIDs_[playNum_], 0);
1061         sleep(waitTime1);
1062         int32_t setRateResult = soundPool_->SetRate(streamIDs_[playNum_], AudioRendererRate::RENDER_RATE_DOUBLE);
1063         EXPECT_EQ(MSERR_OK, setRateResult);
1064         sleep(waitTime3);
1065     }
1066     playNum_++;
1067     if (soundIDs_[1] > 0) {
1068         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1069         EXPECT_GT(streamIDs_[playNum_], 0);
1070         sleep(waitTime1);
1071         int32_t setRateResult = soundPool_->SetRate(streamIDs_[playNum_], AudioRendererRate::RENDER_RATE_HALF);
1072         EXPECT_EQ(MSERR_OK, setRateResult);
1073         sleep(waitTime3);
1074     }
1075     cb->ResetHavePlayedSoundNum();
1076     MEDIA_LOGI("soundpool_unit_test soundpool_function_028 after");
1077 }
1078 
1079 /**
1080  * @tc.name: soundpool_function_029
1081  * @tc.desc: function test SetRate with different streamID and same rate
1082  * @tc.type: FUNC
1083  * @tc.require:
1084  */
1085 HWTEST_F(SoundPoolUnitTest, soundpool_function_029, TestSize.Level2)
1086 {
1087     MEDIA_LOGI("soundpool_unit_test soundpool_function_029 before");
1088     int maxStreams = 3;
1089     create(maxStreams);
1090     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1091     ASSERT_TRUE(cb != nullptr);
1092     soundPool_->SetSoundPoolCallback(cb);
1093     loadUrl(g_fileName[loadNum_], loadNum_);
1094     loadNum_++;
1095     loadUrl(g_fileName[loadNum_], loadNum_);
1096     sleep(waitTime3);
1097     ASSERT_TRUE(cb->WaitLoadedSoundNum(2));
1098     cb->ResetHaveLoadedSoundNum();
1099     struct PlayParams playParameters;
1100     playParameters.loop = -1;
1101     if (soundIDs_[0] > 0) {
1102         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1103         EXPECT_GT(streamIDs_[playNum_], 0);
1104         sleep(waitTime1);
1105         int32_t setRateResult = soundPool_->SetRate(streamIDs_[playNum_], AudioRendererRate::RENDER_RATE_DOUBLE);
1106         EXPECT_EQ(MSERR_OK, setRateResult);
1107         sleep(waitTime3);
1108     }
1109     playNum_++;
1110     if (soundIDs_[1] > 0) {
1111         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1112         EXPECT_GT(streamIDs_[playNum_], 0);
1113         sleep(waitTime1);
1114         int32_t setRateResult = soundPool_->SetRate(streamIDs_[playNum_], AudioRendererRate::RENDER_RATE_DOUBLE);
1115         EXPECT_EQ(MSERR_OK, setRateResult);
1116         sleep(waitTime3);
1117     }
1118     cb->ResetHavePlayedSoundNum();
1119     MEDIA_LOGI("soundpool_unit_test soundpool_function_029 after");
1120 }
1121 
1122 /**
1123  * @tc.name: soundpool_function_030
1124  * @tc.desc: function test SetVolume 0.5
1125  * @tc.type: FUNC
1126  * @tc.require:
1127  */
1128 HWTEST_F(SoundPoolUnitTest, soundpool_function_030, TestSize.Level2)
1129 {
1130     MEDIA_LOGI("soundpool_unit_test soundpool_function_030 before");
1131     int maxStreams = 3;
1132     create(maxStreams);
1133     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1134     ASSERT_TRUE(cb != nullptr);
1135     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
1136     ASSERT_TRUE(ret == 0);
1137     loadUrl(g_fileName[loadNum_], loadNum_);
1138     sleep(waitTime3);
1139     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
1140     cb->ResetHaveLoadedSoundNum();
1141     struct PlayParams playParameters;
1142     float leftVolume = 0.5;
1143     float rightVolume = 0.5;
1144     if (soundIDs_[loadNum_] > 0) {
1145         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
1146         EXPECT_GT(streamIDs_[playNum_], 0);
1147         sleep(waitTime1);
1148         int32_t setVol = soundPool_->SetVolume(streamIDs_[playNum_], leftVolume, rightVolume);
1149         EXPECT_EQ(MSERR_OK, setVol);
1150         sleep(waitTime1);
1151     } else {
1152         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
1153     }
1154     cb->ResetHavePlayedSoundNum();
1155     MEDIA_LOGI("soundpool_unit_test soundpool_function_030 after");
1156 }
1157 
1158 /**
1159  * @tc.name: soundpool_function_031
1160  * @tc.desc: function test SetVolume deifferent leftVolume
1161  * @tc.type: FUNC
1162  * @tc.require:
1163  */
1164 HWTEST_F(SoundPoolUnitTest, soundpool_function_031, TestSize.Level2)
1165 {
1166     MEDIA_LOGI("soundpool_unit_test soundpool_function_031 before");
1167     int maxStreams = 3;
1168     create(maxStreams);
1169     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1170     ASSERT_TRUE(cb != nullptr);
1171     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
1172     ASSERT_TRUE(ret == 0);
1173     loadUrl(g_fileName[loadNum_], loadNum_);
1174     sleep(waitTime3);
1175     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
1176     cb->ResetHaveLoadedSoundNum();
1177     struct PlayParams playParameters;
1178     float leftVolume = 0.1;
1179     if (soundIDs_[loadNum_] > 0) {
1180         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
1181         EXPECT_GT(streamIDs_[playNum_], 0);
1182         sleep(waitTime1);
1183         int32_t setVol = soundPool_->SetVolume(streamIDs_[playNum_], leftVolume, 0.0);
1184         EXPECT_EQ(MSERR_OK, setVol);
1185         sleep(waitTime3);
1186         int32_t setVol1 = soundPool_->SetVolume(streamIDs_[playNum_], 1.0, 0.0);
1187         EXPECT_EQ(MSERR_OK, setVol1);
1188         sleep(waitTime1);
1189     } else {
1190         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
1191     }
1192     cb->ResetHavePlayedSoundNum();
1193     MEDIA_LOGI("soundpool_unit_test soundpool_function_031 after");
1194 }
1195 
1196 /**
1197  * @tc.name: soundpool_function_032
1198  * @tc.desc: function test SetVolume leftVolume -1
1199  * @tc.type: FUNC
1200  * @tc.require:
1201  */
1202 HWTEST_F(SoundPoolUnitTest, soundpool_function_032, TestSize.Level2)
1203 {
1204     MEDIA_LOGI("soundpool_unit_test soundpool_function_032 before");
1205     int maxStreams = 3;
1206     create(maxStreams);
1207     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1208     ASSERT_TRUE(cb != nullptr);
1209     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
1210     ASSERT_TRUE(ret == 0);
1211     loadUrl(g_fileName[loadNum_], loadNum_);
1212     sleep(waitTime3);
1213     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
1214     cb->ResetHaveLoadedSoundNum();
1215     struct PlayParams playParameters;
1216     float leftVolume = -1;
1217     if (soundIDs_[loadNum_] > 0) {
1218         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
1219         EXPECT_GT(streamIDs_[playNum_], 0);
1220         sleep(waitTime1);
1221         int32_t setVol = soundPool_->SetVolume(streamIDs_[playNum_], leftVolume, 0.0);
1222         EXPECT_EQ(MSERR_OK, setVol);
1223         sleep(waitTime1);
1224     } else {
1225         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
1226     }
1227     cb->ResetHavePlayedSoundNum();
1228     MEDIA_LOGI("soundpool_unit_test soundpool_function_032 after");
1229 }
1230 
1231 /**
1232  * @tc.name: soundpool_function_033
1233  * @tc.desc: function test SetVolume rightVolume 2.0
1234  * @tc.type: FUNC
1235  * @tc.require:
1236  */
1237 HWTEST_F(SoundPoolUnitTest, soundpool_function_033, TestSize.Level2)
1238 {
1239     MEDIA_LOGI("soundpool_unit_test soundpool_function_033 before");
1240     int maxStreams = 3;
1241     create(maxStreams);
1242     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1243     ASSERT_TRUE(cb != nullptr);
1244     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
1245     ASSERT_TRUE(ret == 0);
1246     loadUrl(g_fileName[loadNum_], loadNum_);
1247     sleep(waitTime3);
1248     ASSERT_TRUE(cb->WaitLoadedSoundNum(1));
1249     cb->ResetHaveLoadedSoundNum();
1250     struct PlayParams playParameters;
1251     float rightVolume = 2.0;
1252     if (soundIDs_[loadNum_] > 0) {
1253         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[loadNum_], playParameters);
1254         EXPECT_GT(streamIDs_[playNum_], 0);
1255         sleep(waitTime1);
1256         int32_t setVol = soundPool_->SetVolume(streamIDs_[playNum_], 0.0, rightVolume);
1257         EXPECT_EQ(MSERR_OK, setVol);
1258         sleep(waitTime1);
1259     } else {
1260         cout << "Get soundId failed, please try to get soundId: " << soundIDs_[loadNum_] << endl;
1261     }
1262     cb->ResetHavePlayedSoundNum();
1263     MEDIA_LOGI("soundpool_unit_test soundpool_function_033 after");
1264 }
1265 
1266 /**
1267  * @tc.name: soundpool_function_034
1268  * @tc.desc: function test SetPriority 1
1269  * @tc.type: FUNC
1270  * @tc.require:
1271  */
1272 HWTEST_F(SoundPoolUnitTest, soundpool_function_034, TestSize.Level2)
1273 {
1274     MEDIA_LOGI("soundpool_unit_test soundpool_function_034 before");
1275     int maxStreams = 1;
1276     create(maxStreams);
1277     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1278     ASSERT_TRUE(cb != nullptr);
1279     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
1280     ASSERT_TRUE(ret == 0);
1281     loadUrl(g_fileName[loadNum_], loadNum_);
1282     loadNum_++;
1283     loadUrl(g_fileName[loadNum_], loadNum_);
1284     sleep(waitTime3);
1285     ASSERT_TRUE(cb->WaitLoadedSoundNum(2));
1286     cb->ResetHaveLoadedSoundNum();
1287     struct PlayParams playParameters;
1288     playParameters.loop = -1;
1289     int32_t priority  = 1;
1290     if (soundIDs_[0] > 0) {
1291         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1292         EXPECT_GT(streamIDs_[playNum_], 0);
1293         sleep(waitTime3);
1294     }
1295     playNum_++;
1296     if (soundIDs_[1] > 0) {
1297         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1298         EXPECT_GT(streamIDs_[playNum_], 0);
1299         sleep(waitTime3);
1300         int32_t setPriority = soundPool_->SetPriority(streamIDs_[playNum_], priority);
1301         EXPECT_EQ(MSERR_OK, setPriority);
1302         sleep(waitTime1);
1303     }
1304     cb->ResetHavePlayedSoundNum();
1305     MEDIA_LOGI("soundpool_unit_test soundpool_function_034 after");
1306 }
1307 
1308 
1309 /**
1310  * @tc.name: soundpool_function_035
1311  * @tc.desc: function test SetPriority
1312  * @tc.type: FUNC
1313  * @tc.require:
1314  */
1315 HWTEST_F(SoundPoolUnitTest, soundpool_function_035, TestSize.Level2)
1316 {
1317     MEDIA_LOGI("soundpool_unit_test soundpool_function_035 before");
1318     int maxStreams = 1;
1319     create(maxStreams);
1320     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1321     ASSERT_TRUE(cb != nullptr);
1322     soundPool_->SetSoundPoolCallback(cb);
1323     loadUrl(g_fileName[loadNum_], loadNum_);
1324     loadNum_++;
1325     loadUrl(g_fileName[loadNum_], loadNum_);
1326     sleep(waitTime3);
1327     ASSERT_TRUE(cb->WaitLoadedSoundNum(2));
1328     cb->ResetHaveLoadedSoundNum();
1329     struct PlayParams playParameters;
1330     playParameters.priority = 1;
1331     playParameters.loop = -1;
1332     int32_t priority  = -1;
1333     if (soundIDs_[0] > 0) {
1334         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1335         EXPECT_GT(streamIDs_[playNum_], 0);
1336         sleep(waitTime3);
1337     }
1338     playNum_++;
1339     if (soundIDs_[1] > 0) {
1340         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1341         EXPECT_GT(streamIDs_[1], 0);
1342         sleep(waitTime3);
1343     }
1344     int32_t setPriority = soundPool_->SetPriority(streamIDs_[0], priority);
1345     sleep(waitTime1);
1346     EXPECT_EQ(MSERR_OK, setPriority);
1347     cb->ResetHavePlayedSoundNum();
1348     MEDIA_LOGI("soundpool_unit_test soundpool_function_035 after");
1349 }
1350 
1351 /**
1352  * @tc.name: soundpool_function_036
1353  * @tc.desc: function test Priority
1354  * @tc.type: FUNC
1355  * @tc.require:
1356  */
1357 HWTEST_F(SoundPoolUnitTest, soundpool_function_036, TestSize.Level2)
1358 {
1359     MEDIA_LOGI("soundpool_unit_test soundpool_function_036 before");
1360     int maxStreams = 3;
1361     create(maxStreams);
1362     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1363     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
1364     if (ret != 0) {
1365         cout << "set callback failed" << endl;
1366     }
1367     loadUrl(g_fileName[1], loadNum_);
1368     loadNum_++;
1369     loadUrl(g_fileName[1], loadNum_);
1370     loadNum_++;
1371     loadUrl(g_fileName[1], loadNum_);
1372     loadNum_++;
1373     loadUrl(g_fileName[0], loadNum_);
1374     sleep(waitTime3);
1375     struct PlayParams playParameters;
1376     playParameters.priority = 3;
1377     if (soundIDs_[0] > 0) {
1378         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1379         EXPECT_GT(streamIDs_[playNum_], 0);
1380         sleep(waitTime2);
1381     }
1382     playNum_++;
1383     if (soundIDs_[1] > 0) {
1384         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1385         EXPECT_GT(streamIDs_[playNum_], 0);
1386         sleep(waitTime2);
1387     }
1388     playNum_++;
1389     if (soundIDs_[2] > 0) {
1390         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[2], playParameters);
1391         EXPECT_GT(streamIDs_[playNum_], 0);
1392         sleep(waitTime2);
1393     }
1394     playNum_++;
1395     playParameters.priority = 5;
1396     if (soundIDs_[3] > 0) {
1397         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[3], playParameters);
1398         EXPECT_GT(streamIDs_[playNum_], 0);
1399         sleep(waitTime2);
1400     }
1401     sleep(15);
1402     cb->ResetHavePlayedSoundNum();
1403     MEDIA_LOGI("soundpool_unit_test soundpool_function_036 after");
1404 }
1405 
1406 /**
1407  * @tc.name: soundpool_function_037
1408  * @tc.desc: function test Priority
1409  * @tc.type: FUNC
1410  * @tc.require:
1411  */
1412 HWTEST_F(SoundPoolUnitTest, soundpool_function_037, TestSize.Level2)
1413 {
1414     MEDIA_LOGI("soundpool_unit_test soundpool_function_037 before");
1415     int maxStreams = 3;
1416     create(maxStreams);
1417     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1418     int32_t ret = soundPool_->SetSoundPoolCallback(cb);
1419     if (ret != 0) {
1420         cout << "set callback failed" << endl;
1421     }
1422     loadUrl(g_fileName[1], loadNum_);
1423     loadNum_++;
1424     loadUrl(g_fileName[1], loadNum_);
1425     loadNum_++;
1426     loadUrl(g_fileName[1], loadNum_);
1427     loadNum_++;
1428     loadUrl(g_fileName[0], loadNum_);
1429     sleep(waitTime3);
1430     struct PlayParams playParameters;
1431     playParameters.priority = 3;
1432     if (soundIDs_[0] > 0) {
1433         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1434         EXPECT_GT(streamIDs_[playNum_], 0);
1435         sleep(waitTime2);
1436     }
1437     playNum_++;
1438     if (soundIDs_[1] > 0) {
1439         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1440         EXPECT_GT(streamIDs_[playNum_], 0);
1441         sleep(waitTime2);
1442     }
1443     playNum_++;
1444     if (soundIDs_[2] > 0) {
1445         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[2], playParameters);
1446         EXPECT_GT(streamIDs_[playNum_], 0);
1447         sleep(waitTime2);
1448     }
1449     playNum_++;
1450     playParameters.priority = 1;
1451     if (soundIDs_[3] > 0) {
1452         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[3], playParameters);
1453         EXPECT_GT(streamIDs_[playNum_], 0);
1454         sleep(waitTime2);
1455     }
1456     sleep(15);
1457     cb->ResetHavePlayedSoundNum();
1458     MEDIA_LOGI("soundpool_unit_test soundpool_function_037 after");
1459 }
1460 
1461 
1462 /**
1463  * @tc.name: soundpool_function_038
1464  * @tc.desc: function test MaxStreams
1465  * @tc.type: FUNC
1466  * @tc.require:
1467  */
1468 HWTEST_F(SoundPoolUnitTest, soundpool_function_038, TestSize.Level2)
1469 {
1470     MEDIA_LOGI("soundpool_unit_test soundpool_function_038 before");
1471 
1472     int maxStreams = 3;
1473     create(maxStreams);
1474     maxStreams = -1;
1475     AudioStandard::AudioRendererInfo audioRenderInfo;
1476     audioRenderInfo.contentType = CONTENT_TYPE_MUSIC;
1477     audioRenderInfo.streamUsage = STREAM_USAGE_MUSIC;
1478     audioRenderInfo.rendererFlags = 0;
1479     EXPECT_FALSE(soundPool_->CreateSoundPool(maxStreams, audioRenderInfo));
1480     maxStreams = 256;
1481     EXPECT_TRUE(soundPool_->CreateSoundPool(maxStreams, audioRenderInfo));
1482 
1483     MEDIA_LOGI("soundpool_unit_test soundpool_function_038 after");
1484 }
1485 
1486 /**
1487  * @tc.name: soundpool_function_039
1488  * @tc.desc: function test CacheBuffer DoPlay fail
1489  * @tc.type: FUNC
1490  * @tc.require:
1491  */
1492 HWTEST_F(SoundPoolUnitTest, soundpool_function_039, TestSize.Level2)
1493 {
1494     MEDIA_LOGI("soundpool_unit_test soundpool_function_039 before");
1495 
1496     int maxStreams = 3;
1497     create(maxStreams);
1498     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1499     soundPool_->SetSoundPoolCallback(cb);
1500     loadUrl(g_fileName[1], loadNum_);
1501     sleep(5);
1502     struct PlayParams playParameters;
1503     if (soundIDs_[0] > 0) {
1504         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1505         EXPECT_GT(streamIDs_[playNum_], 0);
1506         sleep(waitTime1);
1507         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1508         EXPECT_GT(streamIDs_[playNum_], 0);
1509         sleep(waitTime1);
1510         streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1511         EXPECT_GT(streamIDs_[playNum_], 0);
1512         sleep(waitTime1);
1513     }
1514     cb->ResetHavePlayedSoundNum();
1515 
1516     MEDIA_LOGI("soundpool_unit_test soundpool_function_039 after");
1517 }
1518 
1519 /**
1520  * @tc.name: soundpool_function_040
1521  * @tc.desc: function test play Priority
1522  * @tc.type: FUNC
1523  * @tc.require:
1524  */
1525 HWTEST_F(SoundPoolUnitTest, soundpool_function_040, TestSize.Level2)
1526 {
1527     MEDIA_LOGI("soundpool_unit_test soundpool_function_040 before");
1528 
1529     int maxStreams = 4;
1530     create(maxStreams);
1531     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1532     soundPool_->SetSoundPoolCallback(cb);
1533     loadUrl(g_fileName[2], loadNum_++);
1534     loadUrl(g_fileName[1], loadNum_++);
1535     loadUrl(g_fileName[4], loadNum_++);
1536     loadUrl(g_fileName[5], loadNum_++);
1537     sleep(5);
1538     struct PlayParams playParameters;
1539     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1540     EXPECT_GT(streamIDs_[playNum_], 0);
1541     int32_t setPriority = soundPool_->SetPriority(streamIDs_[0], 1);
1542     EXPECT_EQ(MSERR_OK, setPriority);
1543     playNum_++;
1544     sleep(waitTime1);
1545 
1546     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1547     EXPECT_GT(streamIDs_[playNum_], 0);
1548     setPriority = soundPool_->SetPriority(streamIDs_[1], 2);
1549     EXPECT_EQ(MSERR_OK, setPriority);
1550     playNum_++;
1551     sleep(waitTime1);
1552 
1553     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[2], playParameters);
1554     EXPECT_GT(streamIDs_[playNum_], 0);
1555     setPriority = soundPool_->SetPriority(streamIDs_[2], 3);
1556     EXPECT_EQ(MSERR_OK, setPriority);
1557     playNum_++;
1558     sleep(waitTime1);
1559 
1560     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[3], playParameters);
1561     EXPECT_GT(streamIDs_[playNum_], 0);
1562     setPriority = soundPool_->SetPriority(streamIDs_[3], 4);
1563     EXPECT_EQ(MSERR_OK, setPriority);
1564     playNum_++;
1565     sleep(waitTime10);
1566 
1567     MEDIA_LOGI("soundpool_unit_test soundpool_function_040 after");
1568 }
1569 
1570 /**
1571  * @tc.name: soundpool_function_041
1572  * @tc.desc: function test willplay Priority
1573  * @tc.type: FUNC
1574  * @tc.require:
1575  */
1576 HWTEST_F(SoundPoolUnitTest, soundpool_function_041, TestSize.Level2)
1577 {
1578     MEDIA_LOGI("soundpool_unit_test soundpool_function_041 before");
1579 
1580     int maxStreams = 1;
1581     create(maxStreams);
1582     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1583     soundPool_->SetSoundPoolCallback(cb);
1584     loadUrl(g_fileName[2], loadNum_++);
1585     loadUrl(g_fileName[1], loadNum_++);
1586     loadUrl(g_fileName[4], loadNum_++);
1587     loadUrl(g_fileName[5], loadNum_++);
1588     sleep(5);
1589     struct PlayParams playParameters;
1590     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1591     EXPECT_GT(streamIDs_[playNum_], 0);
1592     int32_t setPriority = soundPool_->SetPriority(streamIDs_[0], 1);
1593     EXPECT_EQ(MSERR_OK, setPriority);
1594     playNum_++;
1595     sleep(waitTime1);
1596 
1597     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1598     EXPECT_GT(streamIDs_[playNum_], 0);
1599     setPriority = soundPool_->SetPriority(streamIDs_[1], 2);
1600     EXPECT_EQ(MSERR_OK, setPriority);
1601     playNum_++;
1602     sleep(waitTime1);
1603 
1604     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[2], playParameters);
1605     EXPECT_GT(streamIDs_[playNum_], 0);
1606     setPriority = soundPool_->SetPriority(streamIDs_[2], 3);
1607     EXPECT_EQ(MSERR_OK, setPriority);
1608     playNum_++;
1609     sleep(waitTime1);
1610 
1611     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[3], playParameters);
1612     EXPECT_GT(streamIDs_[playNum_], 0);
1613     setPriority = soundPool_->SetPriority(streamIDs_[3], 4);
1614     EXPECT_EQ(MSERR_OK, setPriority);
1615     playNum_++;
1616     sleep(waitTime30);
1617 
1618     MEDIA_LOGI("soundpool_unit_test soundpool_function_041 after");
1619 }
1620 
1621 
1622 /**
1623  * @tc.name: soundpool_function_042
1624  * @tc.desc: function test playFinished with streamId
1625  * @tc.type: FUNC
1626  * @tc.require:
1627  */
1628 HWTEST_F(SoundPoolUnitTest, soundpool_function_042, TestSize.Level2)
1629 {
1630     MEDIA_LOGI("soundpool_unit_test soundpool_function_042 before");
1631     int maxStreams = 3;
1632     create(maxStreams);
1633     std::shared_ptr<SoundPoolCallbackTest> cb = std::make_shared<SoundPoolCallbackTest>(soundPool_);
1634     soundPool_->SetSoundPoolCallback(cb);
1635     loadUrl(g_fileName[4], loadNum_++);
1636     loadUrl(g_fileName[5], loadNum_++);
1637     sleep(waitTime3);
1638     struct PlayParams playParameters;
1639     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[0], playParameters);
1640     EXPECT_GT(streamIDs_[playNum_], 0);
1641     sleep(waitTime1);
1642     playNum_++;
1643     streamIDs_[playNum_] = soundPool_->Play(soundIDs_[1], playParameters);
1644     EXPECT_GT(streamIDs_[playNum_], 0);
1645     int32_t totalNum = playNum_ + 1;
1646     int32_t matchNum = 0;
1647     sleep(waitTime10);
1648 
1649     std::vector<int32_t> vector = cb->GetHavePlayedStreamID();
1650     EXPECT_EQ(totalNum, vector.size());
1651     for (int32_t i = 0; i < totalNum; ++i) {
1652         for (int32_t playStreamId : vector) {
1653             if (playStreamId == streamIDs_[i]) {
1654                 matchNum++;
1655             }
1656         }
1657     }
1658     EXPECT_EQ(totalNum, matchNum);
1659 
1660     cb->ResetHavePlayedStreamID();
1661     cb->ResetHavePlayedSoundNum();
1662     MEDIA_LOGI("soundpool_unit_test soundpool_function_042 after");
1663 }
1664 
1665 /**
1666  * @tc.name: soundpool_function_043
1667  * @tc.desc: function test soundpool multi instance
1668  * @tc.type: FUNC
1669  * @tc.require:
1670  */
1671 HWTEST_F(SoundPoolUnitTest, soundpool_function_043, TestSize.Level2)
1672 {
1673     MEDIA_LOGI("soundpool_unit_test soundpool_function_043 before");
1674     int maxStreams = 3;
1675     create(maxStreams);
1676     AudioStandard::AudioRendererInfo audioRenderInfo;
1677     audioRenderInfo.contentType = CONTENT_TYPE_MUSIC;
1678     audioRenderInfo.streamUsage = STREAM_USAGE_MUSIC;
1679     audioRenderInfo.rendererFlags = 0;
1680 
1681     std::shared_ptr<SoundPoolMock> soundPool1 = std::make_shared<SoundPoolMock>();
1682     std::shared_ptr<SoundPoolMock> soundPool2 = std::make_shared<SoundPoolMock>();
1683     EXPECT_TRUE(soundPool1->CreateSoundPool(maxStreams, audioRenderInfo));
1684     EXPECT_TRUE(soundPool2->CreateSoundPool(maxStreams, audioRenderInfo));
1685     std::shared_ptr<SoundPoolCallbackTest> cb1 = std::make_shared<SoundPoolCallbackTest>(soundPool1);
1686     soundPool1->SetSoundPoolCallback(cb1);
1687     std::shared_ptr<SoundPoolCallbackTest> cb2 = std::make_shared<SoundPoolCallbackTest>(soundPool2);
1688     soundPool2->SetSoundPoolCallback(cb2);
1689 
1690     functionTest043(soundPool1, soundPool2, cb1, cb2);
1691 
1692     MEDIA_LOGI("soundpool_unit_test soundpool_function_043 after");
1693 }
1694 
functionTest043(std::shared_ptr<SoundPoolMock> soundPool1,std::shared_ptr<SoundPoolMock> soundPool2,std::shared_ptr<SoundPoolCallbackTest> cb1,std::shared_ptr<SoundPoolCallbackTest> cb2)1695 void SoundPoolUnitTest::functionTest043(std::shared_ptr<SoundPoolMock> soundPool1,
1696     std::shared_ptr<SoundPoolMock> soundPool2, std::shared_ptr<SoundPoolCallbackTest> cb1,
1697     std::shared_ptr<SoundPoolCallbackTest> cb2)
1698 {
1699     int32_t soundNum = 2;
1700     int32_t num0 = 0;
1701     int32_t num1 = 1;
1702     int32_t num2 = 2;
1703     int32_t num3 = 3;
1704     fds_[num0] = open(g_fileName[num0].c_str(), O_RDWR);
1705     fds_[num1] = open(g_fileName[num1].c_str(), O_RDWR);
1706     std::string url0 = "fd://" + std::to_string(fds_[num0]);
1707     std::string url1 = "fd://" + std::to_string(fds_[num1]);
1708     soundIDs_[num0] = soundPool1->Load(url0);
1709     soundIDs_[num1] = soundPool1->Load(url1);
1710     EXPECT_GT(soundIDs_[num0], 0);
1711     EXPECT_GT(soundIDs_[num1], 0);
1712 
1713     fds_[num2] = open(g_fileName[num2].c_str(), O_RDWR);
1714     fds_[num3] = open(g_fileName[num3].c_str(), O_RDWR);
1715     std::string url2 = "fd://" + std::to_string(fds_[num2]);
1716     std::string url3 = "fd://" + std::to_string(fds_[num3]);
1717     soundIDs_[num2] = soundPool2->Load(url2);
1718     soundIDs_[num3] = soundPool2->Load(url3);
1719     EXPECT_GT(soundIDs_[num2], 0);
1720     EXPECT_GT(soundIDs_[num3], 0);
1721     sleep(waitTime3);
1722 
1723     struct PlayParams playParameters;
1724     streamIDs_[num0] = soundPool1->Play(soundIDs_[num0], playParameters);
1725     streamIDs_[num1] = soundPool1->Play(soundIDs_[num1], playParameters);
1726     EXPECT_GT(streamIDs_[num0], 0);
1727     EXPECT_GT(streamIDs_[num1], 0);
1728     streamIDs_[num2] = soundPool2->Play(soundIDs_[num2], playParameters);
1729     streamIDs_[num3] = soundPool2->Play(soundIDs_[num3], playParameters);
1730     EXPECT_GT(streamIDs_[num2], 0);
1731     EXPECT_GT(streamIDs_[num3], 0);
1732     sleep(waitTime3);
1733 
1734     EXPECT_EQ(MSERR_OK, soundPool1->Stop(streamIDs_[num0]));
1735     EXPECT_EQ(MSERR_OK, soundPool1->Stop(streamIDs_[num1]));
1736     EXPECT_EQ(MSERR_OK, soundPool2->Stop(streamIDs_[num2]));
1737     EXPECT_EQ(MSERR_OK, soundPool2->Stop(streamIDs_[num3]));
1738 
1739     ASSERT_TRUE(cb1->WaitLoadedSoundNum(soundNum));
1740     EXPECT_EQ(soundNum, cb1->GetHavePlayedSoundNum());
1741     ASSERT_TRUE(cb2->WaitLoadedSoundNum(soundNum));
1742     EXPECT_EQ(soundNum, cb2->GetHavePlayedSoundNum());
1743 
1744     EXPECT_EQ(MSERR_OK, soundPool1->Unload(soundIDs_[num0]));
1745     EXPECT_EQ(MSERR_OK, soundPool1->Unload(soundIDs_[num1]));
1746     EXPECT_EQ(MSERR_OK, soundPool2->Unload(soundIDs_[num2]));
1747     EXPECT_EQ(MSERR_OK, soundPool2->Unload(soundIDs_[num3]));
1748 
1749     EXPECT_EQ(MSERR_OK, soundPool1->Release());
1750     EXPECT_EQ(MSERR_OK, soundPool2->Release());
1751 }
1752 
1753 /**
1754  * @tc.name: soundpool_function_094
1755  * @tc.desc: function test soundpool multi instance
1756  * @tc.type: FUNC
1757  * @tc.require:
1758  */
1759 HWTEST_F(SoundPoolUnitTest, soundpool_function_094, TestSize.Level2)
1760 {
1761     MEDIA_LOGI("soundpool_unit_test soundpool_function_094 before");
1762     int maxStreams = 3;
1763     create(maxStreams);
1764     AudioStandard::AudioRendererInfo audioRenderInfo;
1765     audioRenderInfo.contentType = CONTENT_TYPE_MUSIC;
1766     audioRenderInfo.streamUsage = STREAM_USAGE_MEDIA;
1767     audioRenderInfo.rendererFlags = 0;
1768 
1769     std::shared_ptr<SoundPoolMock> soundPool1 = std::make_shared<SoundPoolMock>();
1770     std::shared_ptr<SoundPoolMock> soundPool2 = std::make_shared<SoundPoolMock>();
1771     EXPECT_TRUE(soundPool1->CreateSoundPool(maxStreams, audioRenderInfo));
1772     EXPECT_TRUE(soundPool2->CreateSoundPool(maxStreams, audioRenderInfo));
1773     std::shared_ptr<SoundPoolCallbackTest> cb1 = std::make_shared<SoundPoolCallbackTest>(soundPool1);
1774     soundPool1->SetSoundPoolCallback(cb1);
1775     std::shared_ptr<SoundPoolCallbackTest> cb2 = std::make_shared<SoundPoolCallbackTest>(soundPool2);
1776     soundPool2->SetSoundPoolCallback(cb2);
1777 
1778     functionTest094(soundPool1, soundPool2, cb1, cb2);
1779 
1780     MEDIA_LOGI("soundpool_unit_test soundpool_function_094 after");
1781 }
1782 
functionTest094(std::shared_ptr<SoundPoolMock> soundPool1,std::shared_ptr<SoundPoolMock> soundPool2,std::shared_ptr<SoundPoolCallbackTest> cb1,std::shared_ptr<SoundPoolCallbackTest> cb2)1783 void SoundPoolUnitTest::functionTest094(std::shared_ptr<SoundPoolMock> soundPool1,
1784     std::shared_ptr<SoundPoolMock> soundPool2, std::shared_ptr<SoundPoolCallbackTest> cb1,
1785     std::shared_ptr<SoundPoolCallbackTest> cb2)
1786 {
1787     int32_t soundNum = 2;
1788     int32_t num0 = 0;
1789     int32_t num1 = 1;
1790     int32_t num2 = 2;
1791     int32_t num3 = 3;
1792     fds_[num0] = open(g_fileName[num0].c_str(), O_RDWR);
1793     fds_[num1] = open(g_fileName[num1].c_str(), O_RDWR);
1794     std::string url0 = "fd://" + std::to_string(fds_[num0]);
1795     std::string url1 = "fd://" + std::to_string(fds_[num1]);
1796     soundIDs_[num0] = soundPool1->Load(url0);
1797     soundIDs_[num1] = soundPool1->Load(url1);
1798     EXPECT_GT(soundIDs_[num0], 0);
1799     EXPECT_GT(soundIDs_[num1], 0);
1800 
1801     fds_[num2] = open(g_fileName[num2].c_str(), O_RDWR);
1802     fds_[num3] = open(g_fileName[num3].c_str(), O_RDWR);
1803     std::string url2 = "fd://" + std::to_string(fds_[num2]);
1804     std::string url3 = "fd://" + std::to_string(fds_[num3]);
1805     soundIDs_[num2] = soundPool2->Load(url2);
1806     soundIDs_[num3] = soundPool2->Load(url3);
1807     EXPECT_GT(soundIDs_[num2], 0);
1808     EXPECT_GT(soundIDs_[num3], 0);
1809     sleep(waitTime3);
1810 
1811     struct PlayParams playParameters;
1812     streamIDs_[num0] = soundPool1->Play(soundIDs_[num0], playParameters);
1813     streamIDs_[num1] = soundPool1->Play(soundIDs_[num1], playParameters);
1814     EXPECT_GT(streamIDs_[num0], 0);
1815     EXPECT_GT(streamIDs_[num1], 0);
1816     streamIDs_[num2] = soundPool2->Play(soundIDs_[num2], playParameters);
1817     streamIDs_[num3] = soundPool2->Play(soundIDs_[num3], playParameters);
1818     EXPECT_GT(streamIDs_[num2], 0);
1819     EXPECT_GT(streamIDs_[num3], 0);
1820     sleep(waitTime3);
1821 
1822     EXPECT_EQ(MSERR_OK, soundPool1->Stop(streamIDs_[num0]));
1823     EXPECT_EQ(MSERR_OK, soundPool1->Stop(streamIDs_[num1]));
1824     EXPECT_EQ(MSERR_OK, soundPool2->Stop(streamIDs_[num2]));
1825     EXPECT_EQ(MSERR_OK, soundPool2->Stop(streamIDs_[num3]));
1826 
1827     EXPECT_EQ(soundNum, cb1->GetHaveLoadedSoundNum());
1828     EXPECT_EQ(soundNum, cb1->GetHavePlayedSoundNum());
1829     EXPECT_EQ(soundNum, cb2->GetHaveLoadedSoundNum());
1830     EXPECT_EQ(soundNum, cb2->GetHavePlayedSoundNum());
1831 
1832     EXPECT_EQ(MSERR_OK, soundPool1->Unload(soundIDs_[num0]));
1833     EXPECT_EQ(MSERR_OK, soundPool1->Unload(soundIDs_[num1]));
1834     EXPECT_EQ(MSERR_OK, soundPool2->Unload(soundIDs_[num2]));
1835     EXPECT_EQ(MSERR_OK, soundPool2->Unload(soundIDs_[num3]));
1836 
1837     EXPECT_EQ(MSERR_OK, soundPool1->Release());
1838     EXPECT_EQ(MSERR_OK, soundPool2->Release());
1839 }
1840 
1841 /**
1842  * @tc.name: soundpool_function_095
1843  * @tc.desc: function test soundpool multi instance
1844  * @tc.type: FUNC
1845  * @tc.require:
1846  */
1847 HWTEST_F(SoundPoolUnitTest, soundpool_function_095, TestSize.Level2)
1848 {
1849     MEDIA_LOGI("soundpool_unit_test soundpool_function_095 before");
1850     int maxStreams = 3;
1851     create(maxStreams);
1852     AudioStandard::AudioRendererInfo audioRenderInfo;
1853     audioRenderInfo.streamUsage = STREAM_USAGE_MOVIE;
1854     audioRenderInfo.rendererFlags = 0;
1855 
1856     std::shared_ptr<SoundPoolMock> soundPool1 = std::make_shared<SoundPoolMock>();
1857     std::shared_ptr<SoundPoolMock> soundPool2 = std::make_shared<SoundPoolMock>();
1858     EXPECT_TRUE(soundPool1->CreateSoundPool(maxStreams, audioRenderInfo));
1859     EXPECT_TRUE(soundPool2->CreateSoundPool(maxStreams, audioRenderInfo));
1860     std::shared_ptr<SoundPoolCallbackTest> cb1 = std::make_shared<SoundPoolCallbackTest>(soundPool1);
1861     soundPool1->SetSoundPoolCallback(cb1);
1862     std::shared_ptr<SoundPoolCallbackTest> cb2 = std::make_shared<SoundPoolCallbackTest>(soundPool2);
1863     soundPool2->SetSoundPoolCallback(cb2);
1864 
1865     functionTest095(soundPool1, soundPool2, cb1, cb2);
1866 
1867     MEDIA_LOGI("soundpool_unit_test soundpool_function_095 after");
1868 }
1869 
functionTest095(std::shared_ptr<SoundPoolMock> soundPool1,std::shared_ptr<SoundPoolMock> soundPool2,std::shared_ptr<SoundPoolCallbackTest> cb1,std::shared_ptr<SoundPoolCallbackTest> cb2)1870 void SoundPoolUnitTest::functionTest095(std::shared_ptr<SoundPoolMock> soundPool1,
1871     std::shared_ptr<SoundPoolMock> soundPool2, std::shared_ptr<SoundPoolCallbackTest> cb1,
1872     std::shared_ptr<SoundPoolCallbackTest> cb2)
1873 {
1874     int32_t soundNum = 2;
1875     int32_t num0 = 0;
1876     int32_t num1 = 1;
1877     int32_t num2 = 2;
1878     int32_t num3 = 3;
1879     fds_[num0] = open(g_fileName[num0].c_str(), O_RDWR);
1880     fds_[num1] = open(g_fileName[num1].c_str(), O_RDWR);
1881     std::string url0 = "fd://" + std::to_string(fds_[num0]);
1882     std::string url1 = "fd://" + std::to_string(fds_[num1]);
1883     soundIDs_[num0] = soundPool1->Load(url0);
1884     soundIDs_[num1] = soundPool1->Load(url1);
1885     EXPECT_GT(soundIDs_[num0], 0);
1886     EXPECT_GT(soundIDs_[num1], 0);
1887 
1888     fds_[num2] = open(g_fileName[num2].c_str(), O_RDWR);
1889     fds_[num3] = open(g_fileName[num3].c_str(), O_RDWR);
1890     std::string url2 = "fd://" + std::to_string(fds_[num2]);
1891     std::string url3 = "fd://" + std::to_string(fds_[num3]);
1892     soundIDs_[num2] = soundPool2->Load(url2);
1893     soundIDs_[num3] = soundPool2->Load(url3);
1894     EXPECT_GT(soundIDs_[num2], 0);
1895     EXPECT_GT(soundIDs_[num3], 0);
1896     sleep(waitTime3);
1897 
1898     struct PlayParams playParameters;
1899     streamIDs_[num0] = soundPool1->Play(soundIDs_[num0], playParameters);
1900     streamIDs_[num1] = soundPool1->Play(soundIDs_[num1], playParameters);
1901     EXPECT_GT(streamIDs_[num0], 0);
1902     EXPECT_GT(streamIDs_[num1], 0);
1903     streamIDs_[num2] = soundPool2->Play(soundIDs_[num2], playParameters);
1904     streamIDs_[num3] = soundPool2->Play(soundIDs_[num3], playParameters);
1905     EXPECT_GT(streamIDs_[num2], 0);
1906     EXPECT_GT(streamIDs_[num3], 0);
1907     sleep(waitTime3);
1908 
1909     EXPECT_EQ(MSERR_OK, soundPool1->Stop(streamIDs_[num0]));
1910     EXPECT_EQ(MSERR_OK, soundPool1->Stop(streamIDs_[num1]));
1911     EXPECT_EQ(MSERR_OK, soundPool2->Stop(streamIDs_[num2]));
1912     EXPECT_EQ(MSERR_OK, soundPool2->Stop(streamIDs_[num3]));
1913 
1914     EXPECT_EQ(soundNum, cb1->GetHaveLoadedSoundNum());
1915     EXPECT_EQ(soundNum, cb1->GetHavePlayedSoundNum());
1916     EXPECT_EQ(soundNum, cb2->GetHaveLoadedSoundNum());
1917     EXPECT_EQ(soundNum, cb2->GetHavePlayedSoundNum());
1918 
1919     EXPECT_EQ(MSERR_OK, soundPool1->Unload(soundIDs_[num0]));
1920     EXPECT_EQ(MSERR_OK, soundPool1->Unload(soundIDs_[num1]));
1921     EXPECT_EQ(MSERR_OK, soundPool2->Unload(soundIDs_[num2]));
1922     EXPECT_EQ(MSERR_OK, soundPool2->Unload(soundIDs_[num3]));
1923 
1924     EXPECT_EQ(MSERR_OK, soundPool1->Release());
1925     EXPECT_EQ(MSERR_OK, soundPool2->Release());
1926 }
1927 
1928 /**
1929  * @tc.name: soundpool_function_96
1930  * @tc.desc: function test SetSoundPoolFrameWriteCallback
1931  * @tc.type: FUNC
1932  * @tc.require:
1933  */
1934 HWTEST_F(SoundPoolUnitTest, soundpool_function_096, TestSize.Level2)
1935 {
1936     MEDIA_LOGI("soundpool_unit_test soundpool_function_044 before");
1937     create(MAX_STREAMS);
1938     std::shared_ptr<SoundPoolFrameWriteCallbackTest> cb = std::make_shared<SoundPoolFrameWriteCallbackTest>();
1939     int32_t ret = soundPool_->soundPool_->SetSoundPoolFrameWriteCallback(cb);
1940     EXPECT_EQ(MSERR_OK, ret);
1941     MEDIA_LOGI("soundpool_unit_test soundpool_function_044 after");
1942 }
1943 
1944 } // namespace Media
1945 } // namespace OHOS