diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index 348402f1af202a70827859ffe203fdb19d1e8a29..eb24b9c1317d16d9805aece68fa431bad54d91f0 100755 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -16,7 +16,9 @@ import("//test/xts/tools/build/suite.gni") group("multimedia") { testonly = true if (is_standard_system) { - deps = [ "audio/audioPlayer:audio_player_js_hap" ] + deps = [ + "audio/audio_js_standard/audioPlayer:audio_player_js_hap" , + "audio/audio_js_standard/audioPlayer_API:audio_player_api_js_hap"] } else { deps = [ #"audio/audio_hap_test:MediaAudio_test_hap", diff --git a/multimedia/audio/audio_js_standard/BUILD.gn b/multimedia/audio/audio_js_standard/audioManager/BUILD.gn old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/BUILD.gn rename to multimedia/audio/audio_js_standard/audioManager/BUILD.gn diff --git a/multimedia/audio/audio_js_standard/Test.json b/multimedia/audio/audio_js_standard/audioManager/Test.json old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/Test.json rename to multimedia/audio/audio_js_standard/audioManager/Test.json diff --git a/multimedia/audio/audioPlayer/hap/entry-debug-rich-signed.hap b/multimedia/audio/audio_js_standard/audioManager/hap/entry-debug-rich-signed.hap similarity index 100% rename from multimedia/audio/audioPlayer/hap/entry-debug-rich-signed.hap rename to multimedia/audio/audio_js_standard/audioManager/hap/entry-debug-rich-signed.hap diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/config.json b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/config.json similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/config.json rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/config.json diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/js/default/app.js b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/app.js similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/js/default/app.js rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/app.js diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/js/default/i18n/en-US.json b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/i18n/en-US.json similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/js/default/i18n/en-US.json rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/i18n/en-US.json diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/js/default/i18n/zh-CN.json b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/i18n/zh-CN.json similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/js/default/i18n/zh-CN.json rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/i18n/zh-CN.json diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/js/default/pages/index/index.css b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/pages/index/index.css similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/js/default/pages/index/index.css rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/pages/index/index.css diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/js/default/pages/index/index.hml b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/pages/index/index.hml similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/js/default/pages/index/index.hml rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/pages/index/index.hml diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/js/default/pages/index/index.js b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/pages/index/index.js similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/js/default/pages/index/index.js rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/default/pages/index/index.js diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/test/AudioManager.test.js b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/test/AudioManager.test.js old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/test/AudioManager.test.js rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/test/AudioManager.test.js diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/test/AudioPlayer.test.js b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/test/AudioPlayer.test.js old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/test/AudioPlayer.test.js rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/test/AudioPlayer.test.js diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/test/List.test.js b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/test/List.test.js old mode 100755 new mode 100644 similarity index 92% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/test/List.test.js rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/test/List.test.js index 8f03c948b37228a207b1f46f90385fed429dcfe2..08238ae1053836d4439d138937162358b0949890 --- a/multimedia/audio/audio_js_standard/project/entry/src/main/js/test/List.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/js/test/List.test.js @@ -1,16 +1,16 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + require('./AudioManager.test.js') \ No newline at end of file diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/resources/base/element/string.json b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/resources/base/element/string.json similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/resources/base/element/string.json rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/resources/base/element/string.json diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/resources/base/media/icon.png b/multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/resources/base/media/icon.png similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/resources/base/media/icon.png rename to multimedia/audio/audio_js_standard/audioManager/project/entry/src/main/resources/base/media/icon.png diff --git a/multimedia/audio/audioPlayer/BUILD.gn b/multimedia/audio/audio_js_standard/audioPlayer/BUILD.gn similarity index 92% rename from multimedia/audio/audioPlayer/BUILD.gn rename to multimedia/audio/audio_js_standard/audioPlayer/BUILD.gn index d11bfe3d12c47c5628d0eeaf46299be1d049bfbc..8d16acc895e8b289306fe5a191925ef648aaef2f 100644 --- a/multimedia/audio/audioPlayer/BUILD.gn +++ b/multimedia/audio/audio_js_standard/audioPlayer/BUILD.gn @@ -14,5 +14,5 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("audio_player_js_hap") { test_hap_name = "AudioPlayerJsTest" - hap_source_path = "hap/entry-debug-rich-signed.hap" + hap_source_path = "hap/AudioPlayer_JS.hap" } diff --git a/multimedia/audio/audioPlayer/Test.json b/multimedia/audio/audio_js_standard/audioPlayer/Test.json similarity index 100% rename from multimedia/audio/audioPlayer/Test.json rename to multimedia/audio/audio_js_standard/audioPlayer/Test.json diff --git a/multimedia/audio/audio_js_standard/audioPlayer/hap/AudioPlayer_JS.hap b/multimedia/audio/audio_js_standard/audioPlayer/hap/AudioPlayer_JS.hap new file mode 100644 index 0000000000000000000000000000000000000000..4d204d275043026c0b56c6394db8ce3ec3274f85 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioPlayer/hap/AudioPlayer_JS.hap differ diff --git a/multimedia/audio/audio_js_standard/hap/entry-debug-rich-signed.hap b/multimedia/audio/audio_js_standard/audioPlayer/hap/entry-debug-rich-signed.hap old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/hap/entry-debug-rich-signed.hap rename to multimedia/audio/audio_js_standard/audioPlayer/hap/entry-debug-rich-signed.hap diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/config.json b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/config.json old mode 100755 new mode 100644 similarity index 95% rename from multimedia/audio/audio_js_standard/project/entry/src/main/config.json rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/config.json index eba0ed436c4133ee365d9fd1ae7aa157993d918f..a8e2d584e4ea8e23f13d19881a48d7b5b7b0dca8 --- a/multimedia/audio/audio_js_standard/project/entry/src/main/config.json +++ b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/config.json @@ -1,59 +1,59 @@ -{ - "app": { - "bundleName": "ohos.acts.multimedia.audio.function", - "vendor": "acts", - "version": { - "code": 1000000, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 4 - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.acts.multimedia.audio.function", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "ohos.acts.multimedia.audio.function.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} +{ + "app": { + "bundleName": "ohos.acts.multimedia.audio.function", + "vendor": "acts", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 4 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.multimedia.audio.function", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "ohos.acts.multimedia.audio.function.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/default/app.js b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/app.js old mode 100755 new mode 100644 similarity index 97% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/default/app.js rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/app.js index 1042ce48dcb55db5df48244110bf77278996003c..e0b2e05a461ecda7b070d1bb20829b7bde8d5a8a --- a/multimedia/audio/audio_js_standard/project/entry/src/main/js/default/app.js +++ b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/app.js @@ -1,25 +1,25 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import device from '@system.device'; - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import device from '@system.device'; + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/default/i18n/en-US.json b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/i18n/en-US.json old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/default/i18n/en-US.json rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/i18n/en-US.json diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/default/i18n/zh-CN.json b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/i18n/zh-CN.json old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/default/i18n/zh-CN.json rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/i18n/zh-CN.json diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/default/pages/index/index.css b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/pages/index/index.css old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/default/pages/index/index.css rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/pages/index/index.css diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/default/pages/index/index.hml b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/pages/index/index.hml old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/default/pages/index/index.hml rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/pages/index/index.hml diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/js/default/pages/index/index.js b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/pages/index/index.js old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/project/entry/src/main/js/default/pages/index/index.js rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/default/pages/index/index.js diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/js/test/List.test.js b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/test/List.test.js similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/js/test/List.test.js rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/test/List.test.js diff --git a/multimedia/audio/audioPlayer/project/entry/src/main/js/test/PlayerLocalTestAudioFUNC.test.js b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/test/PlayerLocalTestAudioFUNC.test.js similarity index 100% rename from multimedia/audio/audioPlayer/project/entry/src/main/js/test/PlayerLocalTestAudioFUNC.test.js rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/js/test/PlayerLocalTestAudioFUNC.test.js diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/resources/base/element/string.json b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 similarity index 94% rename from multimedia/audio/audio_js_standard/project/entry/src/main/resources/base/element/string.json rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/resources/base/element/string.json index d405647b90183b99fb4e15025a9fe12c85c495d4..2f9470d82c49675a64972657d8d367cd95e51c63 --- a/multimedia/audio/audio_js_standard/project/entry/src/main/resources/base/element/string.json +++ b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/resources/base/element/string.json @@ -1,12 +1,12 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MyApplication" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/project/entry/src/main/resources/base/media/icon.png b/multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/resources/base/media/icon.png old mode 100755 new mode 100644 similarity index 100% rename from multimedia/audio/audio_js_standard/project/entry/src/main/resources/base/media/icon.png rename to multimedia/audio/audio_js_standard/audioPlayer/project/entry/src/main/resources/base/media/icon.png diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/BUILD.gn b/multimedia/audio/audio_js_standard/audioPlayer_API/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3ebe551c6226eb5554fdb7fbd65f7d6caa2dbc74 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("audio_player_api_js_hap") { + test_hap_name = "AudioPlayerApiJsTest" + hap_source_path = "hap/AudioPlayer_Api_JS.hap" +} diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/Test.json b/multimedia/audio/audio_js_standard/audioPlayer_API/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..e992b4d6748b850f841ca17e916fad0e9fd18139 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for audio manager Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "21600000", + "package": "ohos.acts.multimedia.audio.function", + "shell-timeout": "21600000" + }, + "kits": [ + { + "test-file-name": [ + "AudioPlayerApiJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/hap/AudioPlayer_Api_JS.hap b/multimedia/audio/audio_js_standard/audioPlayer_API/hap/AudioPlayer_Api_JS.hap new file mode 100644 index 0000000000000000000000000000000000000000..370140caddca20a5e480daa6b1e030f7b2ed44c1 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioPlayer_API/hap/AudioPlayer_Api_JS.hap differ diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/config.json b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a8e2d584e4ea8e23f13d19881a48d7b5b7b0dca8 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/config.json @@ -0,0 +1,59 @@ +{ + "app": { + "bundleName": "ohos.acts.multimedia.audio.function", + "vendor": "acts", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 4 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.multimedia.audio.function", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "ohos.acts.multimedia.audio.function.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/app.js b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..e0b2e05a461ecda7b070d1bb20829b7bde8d5a8a --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/app.js @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import device from '@system.device'; + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/i18n/en-US.json b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/i18n/zh-CN.json b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.css b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.hml b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.js b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0ee24b27cd17b79470c04ca0609a842056b1a236 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import file from '@system.file' +import app from '@system.app' +import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + const reportExtend = new ReportExtend(file) + core.addService('expect', expectExtend) + core.addService('report', reportExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + }, +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/test/List.test.js b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..adda94a055de2bada294b2152fb6f0d38dbfd5b9 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/test/List.test.js @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +require('./PlayerLocalTestAudioAPI.test.js') \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/test/PlayerLocalTestAudioAPI.test.js b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/test/PlayerLocalTestAudioAPI.test.js new file mode 100644 index 0000000000000000000000000000000000000000..477555dae4aa0e2a1e821ec2669f9bc8a14ee9e6 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/js/test/PlayerLocalTestAudioAPI.test.js @@ -0,0 +1,1124 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import media from '@ohos.multimedia.media' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe('PlayerLocalTestAudioAPI', function () { + var audioPlayer = media.createAudioPlayer(); + var audioSource = "data/media/audio/Homey.mp3"; + var PLAY_TIME = 3000; + var ENDSTATE = 0; + var SRCSTATE = 1; + var PLAYSTATE = 2; + var PAUSESTATE = 3; + var STOPSTATE = 4; + var RESETSTATE = 5; + var SEEKSTATE = 6; + var VOLUMESTATE = 7; + var RELEASESTATE = 8; + var ERRORSTATE = 9; + var FINISHSTATE = 10; + var LOOPSTATE = 11; + var NOERROR = 0; + var DURATION_TIME = 89239; + var SEEK_TIME = 5000; + var VOLUMEVALUE = 0.1; + var DELTA_TIME = 1000; + var SRCERROR = 'sourceError'; + var SEEKERROR = 'seekError'; + var PAUSEERROR = 'pauseError'; + var PLAYERROR = 'playError'; + var STOPERROR = 'stopError'; + var errCode = NOERROR; + var ERRSTEP = 38; + var ERRSRC = 22; + beforeAll(function () { + console.info("beforeAll case"); + }) + + beforeEach(function () { + console.info("beforeEach case"); + }) + + afterEach(function () { + console.info("afterEach case"); + errCode = NOERROR; + }) + + afterAll(function () { + console.info("afterAll case"); + }) + + var sleep = function(time) { + for(var t = Date.now();Date.now() - t <= time;); + }; + + var initAudioPlayer = function() { + audioPlayer.release(); + audioPlayer = media.createAudioPlayer(); + } + + var nextStep = function(mySteps, done) { + if (mySteps[0] == ENDSTATE) { + if (mySteps[1] == false || mySteps[1] == true) { + expect(audioPlayer.loop).assertEqual(mySteps[1]); + } + done(); + return; + } + switch (mySteps[0]) { + case SRCSTATE: + console.info(`case to prepare`); + audioPlayer.src = audioSource; + break; + case PLAYSTATE: + console.info(`case to play`); + audioPlayer.play(); + break; + case PAUSESTATE: + console.info(`case to pause`); + audioPlayer.pause(); + break; + case STOPSTATE: + console.info(`case to stop`); + audioPlayer.stop(); + break; + case RESETSTATE: + console.info(`case to reset`); + audioPlayer.reset(); + break; + case SEEKSTATE: + console.info(`case seek to time is ${mySteps[1]}`); + audioPlayer.seek(mySteps[1]); + break; + case VOLUMESTATE: + console.info(`case to setVolume`); + audioPlayer.setVolume(mySteps[1]); + break; + case RELEASESTATE: + console.info(`case to release`); + mySteps.shift(); + audioPlayer.release(); + nextStep(mySteps, done); + break; + case LOOPSTATE: + audioPlayer.loop = mySteps[1]; + mySteps.shift(); + mySteps.shift(); + nextStep(mySteps, done); + break; + default: + break; + } + } + var setCallback = function(mySteps, done) { + console.info(`case setCallback`); + audioPlayer.on('dataLoad', () => { + mySteps.shift(); + console.info(`case dataLoad called`); + expect(audioPlayer.currentTime).assertEqual(0); + expect(audioPlayer.duration).assertEqual(DURATION_TIME); + expect(audioPlayer.state).assertEqual('paused'); + nextStep(mySteps, done); + }); + + audioPlayer.on('play', () => { + mySteps.shift(); + console.info(`case play called`); + console.info(`case play currentTime is ${audioPlayer.currentTime}`); + expect(audioPlayer.duration).assertEqual(DURATION_TIME); + if (mySteps[0] == FINISHSTATE) { + console.info(`case wait for finish`); + return; + } + expect(audioPlayer.state).assertEqual('playing'); + nextStep(mySteps, done); + }); + + audioPlayer.on('pause', () => { + mySteps.shift(); + console.info(`case pause called`); + console.info(`case pause currentTime is ${audioPlayer.currentTime}`); + expect(audioPlayer.duration).assertEqual(DURATION_TIME); + expect(audioPlayer.state).assertEqual('paused'); + nextStep(mySteps, done); + }); + + audioPlayer.on('reset', () => { + mySteps.shift(); + console.info(`case reset called`); + expect(audioPlayer.state).assertEqual('idle'); + nextStep(mySteps, done); + }); + + audioPlayer.on('stop', () => { + mySteps.shift(); + console.info(`case stop called`); + expect(audioPlayer.currentTime).assertEqual(0); + expect(audioPlayer.duration).assertEqual(DURATION_TIME); + expect(audioPlayer.state).assertEqual('stopped'); + nextStep(mySteps, done); + }); + + audioPlayer.on('timeUpdate', (seekDoneTime) => { + if (typeof (seekDoneTime) == "undefined") { + console.info(`case seek filed,errcode is ${seekDoneTime}`); + return; + } + mySteps.shift(); + mySteps.shift(); + console.info(`case seekDoneTime is ${seekDoneTime}`); + console.info(`case seek called`); + expect(audioPlayer.currentTime + DELTA_TIME).assertClose(seekDoneTime + DELTA_TIME, DELTA_TIME); + console.info(`case loop is ${audioPlayer.loop}`); + if ((audioPlayer.loop == true) && (seekDoneTime == DURATION_TIME)) { + console.info('case loop is true'); + sleep(PLAYSTATE); + } + if (seekDoneTime < audioPlayer.duration || audioPlayer.state == "paused") { + nextStep(mySteps, done); + } + }); + + audioPlayer.on('volumeChange', () => { + console.info(`case setvolume called`); + mySteps.shift(); + mySteps.shift(); + if (audioPlayer.state == "playing") { + sleep(PLAY_TIME); + } + nextStep(mySteps, done); + }); + + audioPlayer.on('finish', () => { + mySteps.shift(); + expect(audioPlayer.state).assertEqual('stopped'); + expect(audioPlayer.currentTime).assertClose(audioPlayer.duration, DELTA_TIME); + console.info(`case finish called`); + nextStep(mySteps, done); + }); + + audioPlayer.on('error', (err) => { + console.info(`case error called,errName is ${err.name}`); + console.info(`case error called,errCode is ${err.code}`); + console.info(`case error called,errMessage is ${err.message}`); + expect(err.code).assertEqual(errCode); + if ((mySteps[0] == SEEKSTATE) || (mySteps[0] == VOLUMESTATE)) { + expect(mySteps[2]).assertEqual(ERRORSTATE); + expect(err.message).assertEqual(mySteps[3]); + mySteps.shift(); + mySteps.shift(); + mySteps.shift(); + mySteps.shift(); + } else { + expect(mySteps[1]).assertEqual(ERRORSTATE); + expect(err.message).assertEqual(mySteps[2]); + mySteps.shift(); + mySteps.shift(); + mySteps.shift(); + } + nextStep(mySteps, done); + }); + }; + + /* * + * @tc.number : SUB_MEDIA_PLAYER_createAudioPlayer_API_0100 + * @tc.name : 01.创建一个音频播放器createAudioPlayer() + * @tc.desc : testcreateAudioPlayer + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 0 + */ + it('SUB_MEDIA_PLAYER_createAudioPlayer_API_0100', 0, async function (done) { + var audioPlayerTest = media.createAudioPlayer(); + expect(audioPlayerTest != null).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0100 + * @tc.name : 01.play操作在createAudioPlayer之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 0 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0100', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(PLAYSTATE, ERRORSTATE, PLAYERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.play(); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0200 + * @tc.name : 02.play操作在pause之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0200', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, PLAYSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0300 + * @tc.name : 03.play操作在stop之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0300', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, PLAYSTATE, ERRORSTATE, PLAYERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0400 + * @tc.name : 04.play操作在seek之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0400', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, SEEKSTATE, SEEK_TIME, PLAYSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0800 + * @tc.name : 08.play操作在reset之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0800', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, RESETSTATE, PLAYSTATE, ERRORSTATE, PLAYERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0900 + * @tc.name : 09.play操作在release之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0900', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, RELEASESTATE, PLAYSTATE, ERRORSTATE, PLAYERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0100 + * @tc.name : 01.pause操作在createAudioPlayer之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0100', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(PAUSESTATE, ERRORSTATE, PAUSEERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.pause(); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0200 + * @tc.name : 02.pause操作在play之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0200', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0300 + * @tc.name : 02.pause操作在stop之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0300', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(PLAYSTATE, STOPSTATE, PAUSESTATE, ERRORSTATE, PAUSEERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0400 + * @tc.name : 04.pause操作在seek之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0400', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, PAUSESTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0800 + * @tc.name : 08.pause操作在reset之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0800', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, RESETSTATE, PAUSESTATE, ERRORSTATE, PAUSEERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0900 + * @tc.name : 09.pause操作在release之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0900', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, RELEASESTATE, PAUSESTATE, ERRORSTATE, PAUSEERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0100 + * @tc.name : 01.stop操作在createAudioPlayer之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0100', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(STOPSTATE, ERRORSTATE, STOPERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.stop(); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0200 + * @tc.name : 02.stop操作在play之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0200', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0300 + * @tc.name : 03.stop操作在pause之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0300', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, STOPSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0400 + * @tc.name : 04.stop操作在seek之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0400', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, STOPSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0800 + * @tc.name : 08.stop操作在reset之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0800', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, PLAYSTATE, RESETSTATE, STOPSTATE, ERRORSTATE, STOPERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0900 + * @tc.name : 09.stop操作在release之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0900', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, PLAYSTATE, RELEASESTATE, STOPSTATE, ERRORSTATE, STOPERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0100 + * @tc.name : 01.seek操作在createAudioPlayer之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0100', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SEEKSTATE, SEEK_TIME, ERRORSTATE, SEEKERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + var seekTime = SEEK_TIME; + audioPlayer.seek(seekTime); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0200 + * @tc.name : 02.seek操作在play之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0200', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300 + * @tc.name : 03.seek操作在pause之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, SEEKSTATE, SEEK_TIME, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0500 + * @tc.name : 05.seek操作在stop之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0500', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, SEEKSTATE, SEEK_TIME, ERRORSTATE, SEEKERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0700 + * @tc.name : 07.seek操作调用3次 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0700', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, SEEKSTATE, 6000, SEEKSTATE, 7000, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0800 + * @tc.name : 08.seek到码流任意某一点(0~码流时长) + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0800', 0, async function (done) { + var randomTime = parseInt(Math.random()*(audioPlayer.duration + 1),10); + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, randomTime, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0900 + * @tc.name : 9.seek到起始位置(0) + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0900', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, 0, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_1000 + * @tc.name : 10.seek到结束位置(码流时长) + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_1000', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, DURATION_TIME, FINISHSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_1100 + * @tc.name : 11.seek操作在reset之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_1100', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, PLAYSTATE, RESETSTATE, SEEKSTATE, SEEK_TIME, + ERRORSTATE, SEEKERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_1200 + * @tc.name : 12.seek操作在release之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_1200', 0, async function (done) { + errCode = ERRSTEP; + var mySteps = new Array(SRCSTATE, PLAYSTATE, RELEASESTATE, SEEKSTATE, SEEK_TIME, + ERRORSTATE, SEEKERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_1400 + * @tc.name : 14.seek到超出码流时长 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_1400', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, DURATION_TIME + DURATION_TIME, FINISHSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0200 + * @tc.name : 02.reset操作在play之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0200', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, RESETSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0300 + * @tc.name : 03.reset操作在pause之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0300', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, RESETSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0400 + * @tc.name : 04.reset操作在stop之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0400', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, RESETSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0500 + * @tc.name : 05.reset操作在seek之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0500', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, RESETSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0100 + * @tc.name : 01.release操作在createAudioPlayer之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0100', 0, async function (done) { + var mySteps = new Array(RELEASESTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.release(); + done(); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0200 + * @tc.name : 02.release操作在play之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0200', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, RELEASESTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0300 + * @tc.name : 03.release操作在pause之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0300', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, RELEASESTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400 + * @tc.name : 04.release操作在stop之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, RELEASESTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0500 + * @tc.name : 05.release操作在seek之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0500', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, RELEASESTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0700 + * @tc.name : 07.release操作在reset之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0700', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, RESETSTATE, RELEASESTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_URI_API_0300 + * @tc.name : 003.播放文件名超长(255)的本地音频素材 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 0 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_URI_API_0300', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = "data/media/audio/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.mp3"; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_URI_API_0500 + * @tc.name : 005.播放文件名为“” + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 0 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_URI_API_0500', 0, async function (done) { + errCode = ERRSRC; + var mySteps = new Array(SRCSTATE, ERRORSTATE, SRCERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = ""; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_URI_API_0800 + * @tc.name : 008. 传入的地址不存在 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 0 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_URI_API_0800', 0, async function (done) { + errCode = 331350552; + var mySteps = new Array(SRCSTATE, ERRORSTATE, SRCERROR, ENDSTATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = "data/media/audio/no.mp3"; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0100 + * @tc.name : 01.set loop true操作在createAudioPlayer之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0100', 0, async function (done) { + initAudioPlayer(); + audioPlayer.loop = true; + expect(audioPlayer.loop).assertEqual(false); + done(); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0200 + * @tc.name : 02.set loop true操作在play之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0200', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, LOOPSTATE, true, ENDSTATE, true); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0300 + * @tc.name : 03.set loop true操作在pause之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0300', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, LOOPSTATE, true, ENDSTATE, true); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0400 + * @tc.name : 04.set loop true操作在stop之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0400', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, LOOPSTATE, true, ENDSTATE, true); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0500 + * @tc.name : 05.set loop true操作在seek之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0500', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, LOOPSTATE, true, ENDSTATE, true); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0700 + * @tc.name : 07.set loop true操作在reset之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0700', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, RESETSTATE, LOOPSTATE, true, ENDSTATE, false); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0800 + * @tc.name : 08.set loop false操作在createAudioPlayer之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0800', 0, async function (done) { + initAudioPlayer(); + audioPlayer.loop = false; + expect(audioPlayer.loop).assertEqual(false); + done(); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0900 + * @tc.name : 09.set loop false操作在play之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_0900', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, LOOPSTATE, false, ENDSTATE, false); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_1000 + * @tc.name : 10.set loop false操作在pause之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_1000', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, LOOPSTATE, false, ENDSTATE, false); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_1100 + * @tc.name : 11.set loop false操作在stop之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_1100', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, LOOPSTATE, false, ENDSTATE, false); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_1200 + * @tc.name : 12.set loop false操作在seek之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_1200', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, LOOPSTATE, false, ENDSTATE, false); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_1400 + * @tc.name : 14.set loop false操作在reset之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Loop_API_1400', 0, async function (done) { + var mySteps = new Array(SRCSTATE, PLAYSTATE, RESETSTATE, LOOPSTATE, false, ENDSTATE, false); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = audioSource; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0100 + * @tc.name : 01.获取参数操作在createAudioPlayer之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0100', 0, async function (done) { + initAudioPlayer(); + expect(audioPlayer.src).assertEqual(undefined); + expect(audioPlayer.duration).assertEqual(undefined); + expect(audioPlayer.currentTime).assertEqual(undefined); + expect(audioPlayer.state).assertEqual('idle'); + expect(audioPlayer.loop).assertEqual(false); + done(); + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200 + * @tc.name : 02.获取参数操作在setsrc之后 + * @tc.desc : + * @tc.size : MEDIUM + * @tc.type : API Test + * @tc.level : Level 2 + */ + it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200', 0, async function (done) { + initAudioPlayer(); + audioPlayer.src = audioSource; + sleep(PLAY_TIME); + expect(audioPlayer.src).assertEqual(audioSource); + expect(audioPlayer.currentTime).assertEqual(0); + expect(audioPlayer.duration).assertEqual(DURATION_TIME); + expect(audioPlayer.state).assertEqual('paused'); + expect(audioPlayer.loop).assertEqual(false); + done(); + }) + +}) diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/resources/base/element/string.json b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2f9470d82c49675a64972657d8d367cd95e51c63 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/resources/base/media/icon.png b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioPlayer_API/project/entry/src/main/resources/base/media/icon.png differ diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/BUILD.gn b/multimedia/audio/audio_native_standard/media_cpp_test_standard/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..dc4e9709ccc700c2cfa50c47a86702c381e28ef4 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/BUILD.gn @@ -0,0 +1,70 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") +module_output_path = "hit/ActsMediaCppStandardTest" + +############################################################################### +config("media_cpp_config") { + visibility = [ ":*" ] + include_dirs = [ + "include", + "//multimedia/media_standard/frameworks/innerkitsimpl/native/player/include", + ] +} + +ohos_moduletest_suite("ActsMediaCppStandardTest") { + module_out_path = module_output_path + sources = [ + "recorder/src/fuction/ActsVideoRecorderTest.cpp", + "recorder/src/fuction/ActsAudioRecoederTest.cpp", + "player/Testplayer.cpp", + "player/src/function/ActsPlayerFuncTest.cpp", + "player/src/function/ActsPlayerFuncAsyncTest.cpp", + "player/src/function/ActsPlayerStateTest.cpp", + "player/src/function/ActsPlayerStateAsyncTest.cpp", + "player/src/api/01.SetSource.cpp", + "player/src/api/02.Prepare.cpp", + "player/src/api/03.Play.cpp", + "player/src/api/04.Pause.cpp", + "player/src/api/05.Stop.cpp", + "player/src/api/06.Reset.cpp", + "player/src/api/07.Seek.cpp", + "player/src/api/08.SetVolume.cpp", + "player/src/api/09.SetLooping.cpp", + "player/src/api/10.SetPlaybackSpeed.cpp", + "player/src/api/11.PrepareAsync.cpp", + "player/src/api/12.GetCurrentTime.cpp", + ] + include_dirs = [ + "include", + "player/include", + "recorder/include", + "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", + ] + cflags = [ + "-Wall" + ] + cflags_cc = cflags + deps = [ + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//foundation/graphic/standard:libwms_client", + "//third_party/googletest:gtest_main", + "//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara", + ] + external_deps = [ + "ipc:ipc_core", + "multimedia_media_standard:media_client", + ] + configs = [ ":media_cpp_config" ] +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/Test.json b/multimedia/audio/audio_native_standard/media_cpp_test_standard/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..f2e652539c924538878034075b1a24e5bacf074a --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/Test.json @@ -0,0 +1,21 @@ +{ + "kits": [ + { + "push": [ + "ActsMediaCppStandardTest->/data/local/tmp/ActsMediaCppStandardTest" + ], + "type": "PushKit", + "post-push": [ + "chmod -R 777 /data/local/tmp/*" + ] + } + ], + "driver": { + "native-test-timeout": "120000", + "type": "CppTest", + "module-name": "ActsMediaCppStandardTest", + "runtime-hint": "1s", + "native-test-device-path": "/data/local/tmp" + }, + "description": "Configuration for ActsMediaCppStandardTest Tests" +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/include/mediatest_log.h b/multimedia/audio/audio_native_standard/media_cpp_test_standard/include/mediatest_log.h new file mode 100644 index 0000000000000000000000000000000000000000..6fbf44067eb9903debabae33a59e524638bdd2af --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/include/mediatest_log.h @@ -0,0 +1,51 @@ + +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "media_log.h" + +#define MEDIA_DEBUG_LOG(fmt, ...) \ +do { \ + printf(fmt, ##__VA_ARGS__); \ + printf("\n"); \ + __MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Debug, fmt, ##__VA_ARGS__); \ +} while (0) \ + +#define MEDIA_INFO_LOG(fmt, ...) \ +do { \ + printf(fmt, ##__VA_ARGS__); \ + printf("\n"); \ + __MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Info, fmt, ##__VA_ARGS__); \ +} while (0) \ + +#define MEDIA_ERROR_LOG(fmt, ...) \ +do { \ + printf(fmt, ##__VA_ARGS__); \ + printf("\n"); \ + __MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Error, fmt, ##__VA_ARGS__); \ +} while (0) \ + +namespace { + constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "MediaTest"}; +} + +namespace MediaTest { + constexpr int SURFACE_QUEUE_SIZE = 5; + const float VOLUME = 0.5f; + const int FIRST_ARG_IDX = 1; + const int SECOND_ARG_IDX = 2; + const int THIRD_ARG = 3; + const int HEIGHT = 720; + const int WIDTH = 1280; +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/Testplayer.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/Testplayer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..51f2301ee10db5a067784f95edfc535404e23461 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/Testplayer.cpp @@ -0,0 +1,384 @@ + +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Testplayer.h" +#include "parameter.h" + +using namespace OHOS; +using namespace OHOS::Media; +using namespace PlayerNameSpace; + +namespace PlayerNameSpace { +std::string GetUri() +{ + char path[256] = "/data/1.mp4"; + GetParameter("sys.media.test.stream.path", "/data/1.mp4", &path[0], 256); + MEDIA_INFO_LOG("PATH : %s", path); + return path; +} +} +TestPlayer::TestPlayer(PlayerSignal *test) + : test_(test) +{ +} +TestPlayer::~TestPlayer() +{ +} +bool TestPlayer::CreatePlayer() +{ + player = PlayerFactory::CreatePlayer(); + if (player == nullptr) { + return false; + } + return true; +} +int32_t TestPlayer::SetSource(const std::string &uri) +{ + return player->SetSource(uri); +} + +int32_t TestPlayer::Play() +{ + int32_t ret = player->Play(); + if (test_->mutexFlag_ == true && test_->state_ != PLAYER_STARTED) { + std::unique_lock lockPlay(test_->mutexPlay_); + test_->condVarPlay_.wait_for(lockPlay, std::chrono::seconds(WAITSECOND)); + if (test_->state_ != PLAYER_STARTED) { + return -1; + } + } + return ret; +} + +int32_t TestPlayer::Prepare() +{ + int32_t ret = player->Prepare(); + if (test_->mutexFlag_ == true && test_->state_ != PLAYER_PREPARED) { + std::unique_lock lockPrepare(test_->mutexPrepare_); + test_->condVarPrepare_.wait_for(lockPrepare, std::chrono::seconds(WAITSECOND)); + if (test_->state_ != PLAYER_PREPARED) { + return -1; + } + } + return ret; +} + +int32_t TestPlayer::PrepareAsync() +{ + int32_t ret = player->PrepareAsync(); + if (test_->mutexFlag_ == true && test_->state_ != PLAYER_PREPARED) { + std::unique_lock lockPrepare(test_->mutexPrepare_); + test_->condVarPrepare_.wait_for(lockPrepare, std::chrono::seconds(WAITSECOND)); + if (test_->state_ != PLAYER_PREPARED) { + return -1; + } + } + return ret; +} + +int32_t TestPlayer::Pause() +{ + int32_t ret = player->Pause(); + if (test_->mutexFlag_ == true && test_->state_ != PLAYER_PAUSED) { + std::unique_lock lockPause(test_->mutexPause_); + test_->condVarPause_.wait_for(lockPause, std::chrono::seconds(WAITSECOND)); + if (test_->state_ != PLAYER_PAUSED) { + return -1; + } + } + return ret; +} + +int32_t TestPlayer::Stop() +{ + int32_t ret = player->Stop(); + if (test_->mutexFlag_ == true && test_->state_ != PLAYER_STOPPED) { + std::unique_lock lockStop(test_->mutexStop_); + test_->condVarStop_.wait_for(lockStop, std::chrono::seconds(WAITSECOND)); + if (test_->state_ != PLAYER_STOPPED) { + return -1; + } + } + return ret; +} + +int32_t TestPlayer::Reset() +{ + int32_t ret = player->Reset(); + if (test_->mutexFlag_ == true && test_->state_ != PLAYER_IDLE) { + std::unique_lock lockReset(test_->mutexReset_); + test_->condVarReset_.wait_for(lockReset, std::chrono::seconds(WAITSECOND)); + if (test_->state_ != PLAYER_IDLE) { + return -1; + } + } + return ret; +} + +int32_t TestPlayer::Release() +{ + return player->Release(); +} + +int32_t TestPlayer::SetVolume(float leftVolume, float rightVolume) +{ + return player->SetVolume(leftVolume, rightVolume); +} + +int32_t TestPlayer::Seek(int32_t mseconds, PlayerSeekMode mode) +{ + test_->seekDoneFlag_ = false; + test_->seekPositon_ = mseconds; + int32_t ret = player->Seek(mseconds, mode); + if (test_->mutexFlag_ == true && test_->seekDoneFlag_ == false) { + std::unique_lock lockSeek(test_->mutexSeek_); + test_->condVarSeek_.wait_for(lockSeek, std::chrono::seconds(WAITSECOND)); + if (test_->seekDoneFlag_ != true) { + return -1; + } + } + return ret; +} + +int32_t TestPlayer::GetCurrentTime(int32_t ¤tTime) +{ + return player->GetCurrentTime(currentTime); +} + +int32_t TestPlayer::GetDuration(int32_t &duration) +{ + return player->GetDuration(duration); +} + +int32_t TestPlayer::SetPlaybackSpeed(PlaybackRateMode mode) +{ + return player->SetPlaybackSpeed(mode); +} + +int32_t TestPlayer::GetPlaybackSpeed(PlaybackRateMode &mode) +{ + return player->GetPlaybackSpeed(mode); +} +sptr TestPlayer::GetVideoSurface(WindowConfig sub_config) +{ + char surface[256] = "null"; + GetParameter("sys.media.test.surface", "null", &surface[0], 256); + mwindow = WindowManager::GetInstance()->CreateWindow(&g_config); + if (mwindow == nullptr) { + MEDIA_ERROR_LOG("Create mwindow failed!!!"); + return nullptr; + } + sptr videoSurface = nullptr; + if (strcmp(surface, "null") == 0) { + return videoSurface; + } + if (strcmp(surface, "subwindow") == 0) { + InitSubWindow(sub_config); + videoSurface = window->GetSurface(); + } else if (strcmp(surface, "window") == 0) { + videoSurface = mwindow->GetSurface(); + videoSurface->SetUserData(SURFACE_FORMAT, std::to_string(PIXEL_FMT_RGBA_8888)); + std::string format = videoSurface->GetUserData(SURFACE_FORMAT); + MEDIA_INFO_LOG("SetUserData SURFACE_FORMAT = %s", format.c_str()); + } + return videoSurface; +} +int32_t TestPlayer::SetVideoSurface(const sptr surface) +{ + char parameter[256] = "null"; + GetParameter("sys.media.test.surface", "null", ¶meter[0], 256); + if (strcmp(parameter, "null") == 0) { + MEDIA_INFO_LOG("sys.media.test.surface null"); + return 0; + } + return player->SetVideoSurface(surface); +} + +bool TestPlayer::IsPlaying() +{ + return player->IsPlaying(); +} + +bool TestPlayer::IsLooping() +{ + return player->IsLooping(); +} + +int32_t TestPlayer::SetLooping(bool loop) +{ + return player->SetLooping(loop); +} + +int32_t TestPlayer::SetPlayerCallback(const std::shared_ptr &callback) +{ + return player->SetPlayerCallback(callback); +} + +void TestPlayer::InitSubWindow(WindowConfig sub_config) +{ + sptr buffer; + BufferRequestConfig requestConfig; + int32_t releaseFence; + mwindow->GetRequestConfig(requestConfig); + (void)mwindow->GetSurface()->RequestBuffer(buffer, releaseFence, requestConfig); + uint32_t buffSize = buffer->GetSize(); + void *bufferVirAddr = buffer->GetVirAddr(); + (void)memset_s(bufferVirAddr, buffSize, 0, buffSize); + BufferFlushConfig flushConfig = { + .damage = { + .x = 0, + .y = 0, + .w = requestConfig.width, + .h = requestConfig.height, + }, + .timestamp = 0, + }; + if (mwindow->GetSurface()->FlushBuffer(buffer, -1, flushConfig) != 0) { + MEDIA_ERROR_LOG("FlushBuffer failed"); + } + window = WindowManager::GetInstance()->CreateSubWindow(mwindow->GetWindowID(), &sub_config); + ASSERT_NE(nullptr, window); + if (window == nullptr) { + MEDIA_ERROR_LOG("Create window failed!!!"); + return; + } + return; +} + +TestPlayerCallback::TestPlayerCallback(PlayerSignal *test) + : test_(test) +{ +} +TestPlayerCallback::~TestPlayerCallback() +{ +} +void TestPlayerCallback::OnError(PlayerErrorType errorType, int32_t errorCode) +{ + errorNum++; + errorType_ = errorType; + errorCode_ = errorCode; + MEDIA_INFO_LOG("TestPlayerCallback: OnError errorType is %d, errorCode is %d", errorType_, errorCode_); +} +void TestPlayerCallback::OnInfo(PlayerOnInfoType type, int32_t extra, const Format &InfoBody) +{ + switch (type) { + case INFO_TYPE_SEEKDONE: + seekDoneFlag = true; + test_->SetSeekResult(true); + MEDIA_INFO_LOG("TestPlayerCallback: OnSeekDone currentPositon is %d", extra); + if (abs(test_->seekPositon_ - extra) <= DELTA_TIME) { + test_->condVarSeek_.notify_all(); + } else { + test_->SetSeekResult(false); + } + break; + case INFO_TYPE_EOS: + MEDIA_INFO_LOG("TestPlayerCallback: OnEndOfStream isLooping is %d", extra); + break; + case INFO_TYPE_STATE_CHANGE: + state_ = static_cast(extra); + test_->SetState(state_); + PrintState(state_); + break; + case INFO_TYPE_POSITION_UPDATE: + postion_ = extra; + break; + case INFO_TYPE_MESSAGE: + MEDIA_INFO_LOG("TestPlayerCallback: OnMessage type is %d", extra); + break; + default: + break; + } +} + +int TestPlayerCallback::WaitForSeekDone(int32_t currentPositon) +{ + int64_t waitTime = 0; + seekDoneFlag = false; + while (seekDoneFlag != true && waitTime < WAITSECOND * 1000) { + usleep(1000); + waitTime += 1; + } + seekDoneFlag = false; + if (waitTime >= WAITSECOND * 1000) { + MEDIA_INFO_LOG("Failed to seek [%d]s ", currentPositon); + return -1; + } + return 0; +} + +int TestPlayerCallback::WaitForState(PlayerStates state) +{ + int64_t waitTime = 0; + while (state_ != state && waitTime < WAITSECOND * 1000) { + usleep(1000); + waitTime += 1; + } + if (waitTime >= WAITSECOND * 1000) { + MEDIA_INFO_LOG("Failed to wait for state[%d] down", state); + return -1; + } + return 0; +} +void TestPlayerCallback::PrintState(PlayerStates state) +{ + switch (state) { + case PLAYER_STATE_ERROR: + MEDIA_INFO_LOG("State: Error"); + break; + case PLAYER_IDLE: + MEDIA_INFO_LOG("State: IDLE"); + test_->condVarReset_.notify_all(); + break; + case PLAYER_INITIALIZED: + MEDIA_INFO_LOG("State: Initialized"); + break; + case PLAYER_PREPARING: + MEDIA_INFO_LOG("State: Preparing"); + break; + case PLAYER_PREPARED: + MEDIA_INFO_LOG("State: Prepared"); + test_->condVarPrepare_.notify_all(); + break; + case PLAYER_STARTED: + MEDIA_INFO_LOG("State: Started"); + test_->condVarPlay_.notify_all(); + break; + case PLAYER_PAUSED: + MEDIA_INFO_LOG("State: Paused"); + test_->condVarPause_.notify_all(); + break; + case PLAYER_STOPPED: + MEDIA_INFO_LOG("State: Stopped"); + test_->condVarStop_.notify_all(); + break; + case PLAYER_PLAYBACK_COMPLETE: + MEDIA_INFO_LOG("State: Complete"); + break; + default: + MEDIA_INFO_LOG("Invalid state"); + break; + } +} + +void PlayerSignal::SetState(PlayerStates state) +{ + state_ = state; +} +void PlayerSignal::SetSeekResult(bool seekDoneFlag) +{ + seekDoneFlag_ = seekDoneFlag; +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/ActsPlayerAPITest.h b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/ActsPlayerAPITest.h new file mode 100644 index 0000000000000000000000000000000000000000..0757235bb3c2c7e86731923f881285bf4a752045 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/ActsPlayerAPITest.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef PLAYER_API_TEST_H +#define PLAYER_API_TEST_H + +#include "Testplayer.h" + +namespace OHOS { +namespace Media { +class ActsPlayerAPITest : public testing::Test { +public: + // SetUpTestCase: before all testcasee + static void SetUpTestCase(void) + { + MEDIA_INFO_LOG("ActsPlayerAPITest::SetUpTestCase"); + }; + // TearDownTestCase: after all testcase + static void TearDownTestCase(void) + { + MEDIA_INFO_LOG("ActsPlayerAPITest::TearDownTestCase"); + }; + // SetUp + void SetUp(void) + { + MEDIA_INFO_LOG("ActsPlayerAPITest::SetUp"); + }; + // TearDown + void TearDown(void) + { + MEDIA_INFO_LOG("ActsPlayerAPITest::TearDown"); + }; + void LocalPlayFunc(const std::string uri, bool isAsync, WindowConfig config = g_config); +}; +} +} +#endif diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h new file mode 100644 index 0000000000000000000000000000000000000000..58b453f624fdcf627a9383cb1deb61ed622d6bb4 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef PLAYER_FUNC_TEST_H +#define PLAYER_FUNC_TEST_H + +#include "Testplayer.h" + +namespace OHOS { +namespace Media { +class ActsPlayerFuncTest : public testing::Test { +public: + // SetUpTestCase: before all testcasee + static void SetUpTestCase(void) + { + MEDIA_INFO_LOG("ActsPlayerFuncTest::SetUpTestCase"); + }; + // TearDownTestCase: after all testcase + static void TearDownTestCase(void) + { + MEDIA_INFO_LOG("ActsPlayerFuncTest::TearDownTestCase"); + }; + // SetUp + void SetUp(void) + { + MEDIA_INFO_LOG("ActsPlayerFuncTest::SetUp"); + }; + // TearDown + void TearDown(void) + { + MEDIA_INFO_LOG("ActsPlayerFuncTest::TearDown"); + }; + static void LocalPlayFunc(const std::string uri, bool isAsync, WindowConfig config = g_sub_config); + static void *LocalMulitPlayFunc(void *threadarg); +}; +} +} +#endif diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/Testplayer.h b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/Testplayer.h new file mode 100644 index 0000000000000000000000000000000000000000..4017d54bcf3aa06f6532fee0c5a081d98447a3b0 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/Testplayer.h @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "securec.h" +#include "common.h" +#include "player.h" +#include "mediatest_log.h" +#include "window_manager.h" +#include "surface_type.h" +#include "display_type.h" + +namespace PlayerNameSpace { + static const int MAX_THREADS = 16; + static const int32_t PLAYING_TIME = 3; + static const int32_t PAUSED_TIME = 1; + static const int32_t SEEK_TIME_5_SEC = 5000; + static const int32_t SEEK_TIME_2_SEC = 2000; + static const int DELTA_TIME = 1000; + static const int WAITSECOND = 2; + static const int MAXTIME = 20; + static const int RET_OK = 0; + static const int32_t FILE_BEGIN = 0; + std::string GetUri(); +} + +namespace OHOS { +namespace Media { +static const std::string SURFACE_STRIDE_ALIGNMENT = "SURFACE_STRIDE_ALIGNMENT"; +static const std::string SURFACE_FORMAT = "SURFACE_FORMAT"; +static WindowConfig g_config = { + 1920, + 1080, + PIXEL_FMT_RGBA_8888, + 0, + 0, + WINDOW_TYPE_NORMAL +}; +static WindowConfig g_sub_config = { + 720, + 480, + PIXEL_FMT_YCRCB_420_SP, + 0, + 0, + WINDOW_TYPE_VIDEO, +}; + +class PlayerSignal { +public: + PlayerStates state_ = PLAYER_IDLE; + int32_t seekPositon_; + bool seekDoneFlag_; + bool mutexFlag_ = true; + std::mutex mutexSeek_; + std::mutex mutexReset_; + std::mutex mutexPrepare_; + std::mutex mutexPlay_; + std::mutex mutexPause_; + std::mutex mutexStop_; + std::condition_variable condVarSeek_; + std::condition_variable condVarReset_; + std::condition_variable condVarPrepare_; + std::condition_variable condVarPlay_; + std::condition_variable condVarPause_; + std::condition_variable condVarStop_; + + void SetState(PlayerStates state); + void SetSeekResult(bool seekDoneFlag); +}; +class TestPlayer { +public: + std::shared_ptr player; + std::unique_ptr mwindow; + std::unique_ptr window; + explicit TestPlayer(PlayerSignal *test); + ~TestPlayer(); + bool CreatePlayer(); + int32_t SetSource(const std::string &uri); + int32_t Play(); + int32_t Prepare(); + int32_t PrepareAsync(); + int32_t Pause(); + int32_t Stop(); + int32_t Reset(); + int32_t Release(); + int32_t SetVolume(float leftVolume, float rightVolume); + int32_t Seek(int32_t mseconds, PlayerSeekMode mode); + int32_t GetCurrentTime(int32_t ¤tTime); + int32_t GetDuration(int32_t &duration); + int32_t SetPlaybackSpeed(PlaybackRateMode mode); + int32_t GetPlaybackSpeed(PlaybackRateMode &mode); + sptr GetVideoSurface(WindowConfig g_sub_config); + int32_t SetVideoSurface(sptr surface); + bool IsPlaying(); + bool IsLooping(); + int32_t SetLooping(bool loop); + int32_t SetPlayerCallback(const std::shared_ptr &callback); +private: + void InitSubWindow(WindowConfig sub_config); + + PlayerSignal *test_; +}; +class TestPlayerCallback : public PlayerCallback { +public: + int errorNum = 0; + PlayerStates state_ = PLAYER_STATE_ERROR; + explicit TestPlayerCallback(PlayerSignal *test); + ~TestPlayerCallback(); + void OnError(PlayerErrorType errorType, int32_t errorCode); + int WaitForSeekDone(int32_t currentPositon); + void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &InfoBody = {}); + int WaitForState(PlayerStates state); +private: + PlayerErrorType errorType_ = PLAYER_ERROR_UNKNOWN; + int32_t errorCode_ = -1; + bool seekDoneFlag = false; + int32_t postion_ = 0; + void PrintState(PlayerStates state); + + PlayerSignal *test_; +}; +} +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/common.h b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/common.h new file mode 100644 index 0000000000000000000000000000000000000000..a3655b3e1aff98ccad39e1857c47200a88a1a00b --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/include/common.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" + +#define MOUNT_147 "/data/147" +#define MOUNT_189 "/data/189" + diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/01.SetSource.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/01.SetSource.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bf316c67928618958f5c275743e44659b22ba9d2 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/01.SetSource.cpp @@ -0,0 +1,333 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0100 + * @tc.name : 01.SetSource操作在new之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0200 + * @tc.name : 02.SetSource操作在PrepareAsync之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0300 + * @tc.name : 03.SetSource操作在Prepare之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0400 + * @tc.name : 04.SetSource操作在Play之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0500 + * @tc.name : 05.SetSource操作在Pause之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0600 + * @tc.name : 06.SetSource操作在Seek之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0700 + * @tc.name : 07.SetSource操作在Stop之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0700, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0800 + * @tc.name : 08.SetSource操作在Reset之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0900 + * @tc.name : 09.SetSource操作在SetVideoSurface之后 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + EXPECT_NE(RET_OK, player->SetSource(uri)); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_1000 + * @tc.name : 10.SetSource操作调用3次 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_NE(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetSource_1100 + * @tc.name : 11.SetSource操作在每个可进行的操作后都调用一次 + * @tc.desc : test SetSource +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->SetSource(uri)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, player->Reset()); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/02.Prepare.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/02.Prepare.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4401f6894ed8932ac68e42677253b8c3bf9cd93e --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/02.Prepare.cpp @@ -0,0 +1,351 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0100 + * @tc.name : 01.Prepare操作在new之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0100, Reliability | SmallTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + EXPECT_NE(RET_OK, player->Prepare()); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0200 + * @tc.name : 02.Prepare操作在PrepareAsync之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0300 + * @tc.name : 03.Prepare操作在SetSource之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + player->SetVideoSurface(videoSurface); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0400 + * @tc.name : 04.Prepare操作在Play之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0500 + * @tc.name : 05.Prepare操作在Pause之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0600 + * @tc.name : 06.Prepare操作在Seek之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0700 + * @tc.name : 07.Prepare操作在Stop之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0700, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0800 + * @tc.name : 08.Prepare操作在Reset之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0900 + * @tc.name : 09.Prepare操作在SetVideoSurface之后 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_1000 + * @tc.name : 10.Prepare操作调用3次 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Prepare_1100 + * @tc.name : 11.Prepare操作在每个可进行的操作后都调用一次 + * @tc.desc : test Prepare +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/03.Play.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/03.Play.cpp new file mode 100644 index 0000000000000000000000000000000000000000..72616a595edea990e06f37555262a3677fd103e8 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/03.Play.cpp @@ -0,0 +1,375 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0100 + * @tc.name : 01.Play操作在new之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0100, Reliability | SmallTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + EXPECT_NE(RET_OK, player->Prepare()); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0200 + * @tc.name : 02.Play操作在PrepareAsync之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0300 + * @tc.name : 03.Play操作在Prepare之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0400 + * @tc.name : 03.Play操作在SetSource之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + int32_t time; + EXPECT_NE(RET_OK, player->Play()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(2000, time); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0500 + * @tc.name : 05.Play操作在Pause之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0600 + * @tc.name : 06.Play操作在Seek之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0700 + * @tc.name : 07.Play操作在Stop之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0700, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Play()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0800 + * @tc.name : 08.Play操作在Reset之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_0900 + * @tc.name : 09.Play操作在SetVideoSurface之后 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + EXPECT_NE(RET_OK, player->Play()); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_1000 + * @tc.name : 10.Play操作调用3次 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Play_1100 + * @tc.name : 11.Play操作在每个可进行的操作后都调用一次 + * @tc.desc : test Play +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/04.Pause.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/04.Pause.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ac788bda8837549897e1775823da33503e9970b --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/04.Pause.cpp @@ -0,0 +1,319 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_0100 + * @tc.name : 01.Pause操作在new之后 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0100, Reliability | SmallTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + EXPECT_NE(RET_OK, player->Pause()); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_0200 + * @tc.name : 02.Pause操作在PrepareAsync之后 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_0300 + * @tc.name : 03.Pause操作在Prepare之后 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_0500 + * @tc.name : 05.Pause操作在Play之后 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_0600 + * @tc.name : 06.Pause操作在Seek之后 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_0700 + * @tc.name : 07.Pause操作在Stop之后 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0700, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_0800 + * @tc.name : 08.Pause操作在Reset之后 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_0900 + * @tc.name : 09.Pause操作在SetVideoSurface之后 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_1000 + * @tc.name : 10.Pause操作调用3次 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Pause_1100 + * @tc.name : 10.Pause操作在每个可进行的操作后都调用一次 + * @tc.desc : test Pause +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + EXPECT_NE(RET_OK, player->Pause()); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->Pause()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/05.Stop.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/05.Stop.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc618006b84d5f3c6c0645faea366d4f293731bb --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/05.Stop.cpp @@ -0,0 +1,300 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_0100 + * @tc.name : 01.Stop操作在new之后 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0100, Reliability | SmallTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + EXPECT_NE(RET_OK, player->Stop()); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_0200 + * @tc.name : 02.Stop操作在PrepareAsync之后 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_0300 + * @tc.name : 03.Stop操作在Prepare之后 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_0400 + * @tc.name : 04.Stop操作在Play之后 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_0500 + * @tc.name : 05.Stop操作在Pause之后 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_0600 + * @tc.name : 06.Stop操作在Seek之后 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_0800 + * @tc.name : 08.Stop操作在Reset之后 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_0900 + * @tc.name : 09.Stop操作在SetVideoSurface之后 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_1000 + * @tc.name : 10.Stop操作调用3次 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Stop_1100 + * @tc.name : 11.Stop操作在每个可进行的操作后都调用一次 + * @tc.desc : test Stop +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + EXPECT_NE(RET_OK, player->Stop()); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->Stop()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_NE(RET_OK, player->Play()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/06.Reset.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/06.Reset.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eb8ac59f8e70c01efe2369145285ea9efb90d0fc --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/06.Reset.cpp @@ -0,0 +1,248 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_0100 + * @tc.name : 01.Reset操作在new之后 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0100, Reliability | SmallTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + EXPECT_EQ(RET_OK, player->Reset()); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_0200 + * @tc.name : 02.Reset操作在PrepareAsync之后 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_0300 + * @tc.name : 03.Reset操作在Prepare之后 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Reset()); + + ASSERT_EQ(RET_OK, player->SetSource(uri)); + videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_0400 + * @tc.name : 04.Reset操作在Play之后 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_0500 + * @tc.name : 05.Reset操作在Pause之后 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_0600 + * @tc.name : 06.Reset操作在Seek之后 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_0700 + * @tc.name : 07.Reset操作在Stop之后 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0700, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_0900 + * @tc.name : 09.Reset操作在SetVideoSurface之后 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Reset_1000 + * @tc.name : 10.Reset操作调用3次 + * @tc.desc : test Reset +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/07.Seek.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/07.Seek.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1a2468b4b455878d65626e9d3690912035ed58d4 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/07.Seek.cpp @@ -0,0 +1,568 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_0100 + * @tc.name : 01.Seek操作在new之后 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_0100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_0200 + * @tc.name : 02.Seek操作在PrepareAsync之后 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_0300 + * @tc.name : 03.Seek操作在Prepare之后 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_0400 + * @tc.name : 04.Seek操作在Play之后 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_0500 + * @tc.name : 05.Seek操作在Stop之后 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_0600 + * @tc.name : 06.Seek操作在Pause之后 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_0800 + * @tc.name : 08.Seek操作在Reset之后 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_0900 + * @tc.name : 09.Seek操作在SetVideoSurface之后 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_NE(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1000 + * @tc.name : 10.Seek操作调用3次 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1100 + * @tc.name : 11.seek到码流任意某一点(0~码流时长) + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + int32_t duration; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + time = duration * 2 / 3; + EXPECT_EQ(RET_OK, player->Seek(time, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(duration * 2 / 3, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1200 + * @tc.name : 12.seek到起始位置(0) + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Seek(FILE_BEGIN, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1300 + * @tc.name : 13.seek到结束位置(码流时长),播放 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + int32_t duration; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(RET_OK, player->Seek(duration, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(duration, time); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1325 + * @tc.name : 13.seek到结束位置(码流时长),暂停 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1325, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + int32_t duration; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(RET_OK, player->Seek(duration, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(duration, time); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1350 + * @tc.name : 13.seek到结束位置(码流时长),再seek随机位置播放, + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1350, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + int32_t duration; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(RET_OK, player->Seek(duration, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(duration, time); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1375 + * @tc.name : 13.seek到结束位置(码流时长),再seek随机位置暂停 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1375, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + int32_t duration; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(RET_OK, player->Seek(duration, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(duration, time); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1400 + * @tc.name : 14.seek不存在的时间点 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + int32_t duration; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(-1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(FILE_BEGIN, time); + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(RET_OK, player->Seek(duration + 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(duration, time); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1500 + * @tc.name : 15.seek操作在每个可进行的操作后都调用一次 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Seek_1500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/08.SetVolume.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/08.SetVolume.cpp new file mode 100644 index 0000000000000000000000000000000000000000..847d69adf113cab353fc0147622a7bb370e075d6 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/08.SetVolume.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetVolume_0100 + * @tc.name : 01.SetVolume 0 0 + * @tc.desc : test SetVolume +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetVolume_0100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->SetVolume(0, 0)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetVolume_0200 + * @tc.name : 02.SetVolume 1.0 1.0 + * @tc.desc : test SetVolume +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetVolume_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->SetVolume(1.0, 1.0)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/09.SetLooping.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/09.SetLooping.cpp new file mode 100644 index 0000000000000000000000000000000000000000..46f368f1523c8f79e9fc28fdb9b52d47a650f126 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/09.SetLooping.cpp @@ -0,0 +1,447 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0100 + * @tc.name : 01.set loop true操作在createAudioPlayer之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + EXPECT_NE(RET_OK, player->SetLooping(true)); + EXPECT_FALSE(player->IsLooping()); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0200 + * @tc.name : 02.set loop true操作在play之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0300 + * @tc.name : 03.set loop true操作在pause之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0400 + * @tc.name : 04.set loop true操作在stop之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0500 + * @tc.name : 05.set loop true操作在seek之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0600 + * @tc.name : 06.set loop true操作在set loop true之后的每个可进行的操作后都调用一次 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0700 + * @tc.name : 07.set loop true操作调用3次 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0700, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0800 + * @tc.name : 08.set loop false操作在play之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0900 + * @tc.name : 09.set loop false操作在pause之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_1000 + * @tc.name : 010.set loop false操作在stop之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_1100 + * @tc.name : 011.set loop false操作在seek之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_1200 + * @tc.name : 012.set loop false操作在set loop false之后的每个可进行的操作后都调用一次 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_1200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->SetLooping(false)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_1300 + * @tc.name : 013.set loop false操作调用3次 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_1300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/10.SetPlaybackSpeed.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/10.SetPlaybackSpeed.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79658fa8be5bd6479636c78a3c6ce4d727f5d643 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/10.SetPlaybackSpeed.cpp @@ -0,0 +1,380 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0100 + * @tc.name : 01.SetPlaybackSpeed操作在createAudioPlayer之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + PlaybackRateMode mode; + EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_NE(RET_OK, player->GetPlaybackSpeed(mode)); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0200 + * @tc.name : 02.SetPlaybackSpeed操作在play之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + PlaybackRateMode mode; + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0300 + * @tc.name : 03.SetPlaybackSpeed操作在pause之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + PlaybackRateMode mode; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0400 + * @tc.name : 04.SetPlaybackSpeed操作在stop之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + PlaybackRateMode mode; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0500 + * @tc.name : 05.SetPlaybackSpeed操作在seek之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + PlaybackRateMode mode; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0600 + * @tc.name : 06.SetPlaybackSpeed操作在SetPlaybackSpeed之后的每个可进行的操作后都调用一次 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + PlaybackRateMode mode; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0700 + * @tc.name : 07.SetPlaybackSpeed操作调用3次 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0700, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + PlaybackRateMode mode; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_1_25_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_1_25_X, mode); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_1_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_1_75_X, mode); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_2_00_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_2_00_X, mode); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0800 + * @tc.name : 08.SetPlaybackSpeed操作在Prepare之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + PlaybackRateMode mode; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0900 + * @tc.name : 08.SetPlaybackSpeed操作在PrepareAsync之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + PlaybackRateMode mode; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1000 + * @tc.name : 10.SetPlaybackSpeed操作在SetSource之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + PlaybackRateMode mode; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_NE(RET_OK, player->GetPlaybackSpeed(mode)); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1100 + * @tc.name : 10.SetPlaybackSpeed操作在PLAYER_PLAYBACK_COMPLETE之后 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + PlaybackRateMode mode; + int32_t durationTime; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1200 + * @tc.name : 10.SetPlaybackSpeed操作在PLAYER_PLAYBACK_COMPLETE之后,loop=1 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + PlaybackRateMode mode; + int32_t durationTime; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X)); + EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode)); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); + sleep(PLAYING_TIME); + EXPECT_EQ(SPEED_FORWARD_0_75_X, mode); +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/11.PrepareAsync.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/11.PrepareAsync.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28634362503ab57788f713b2d3c865d78995688f --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/11.PrepareAsync.cpp @@ -0,0 +1,352 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0100 + * @tc.name : 01.PrepareAsync操作在new之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0100, Reliability | SmallTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + EXPECT_NE(RET_OK, player->PrepareAsync()); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0200 + * @tc.name : 02.PrepareAsync操作在PrepareAsync之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0200, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0300 + * @tc.name : 03.PrepareAsync操作在SetSource之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0300, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_NE(RET_OK, player->SetVideoSurface(videoSurface)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0400 + * @tc.name : 04.PrepareAsync操作在Play之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0400, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0500 + * @tc.name : 05.PrepareAsync操作在Pause之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0500, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0600 + * @tc.name : 06.PrepareAsync操作在Seek之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0600, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0700 + * @tc.name : 07.PrepareAsync操作在Stop之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0700, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0800 + * @tc.name : 08.PrepareAsync操作在Reset之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0800, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0900 + * @tc.name : 09.PrepareAsync操作在SetVideoSurface之后 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0900, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_1000 + * @tc.name : 10.PrepareAsync操作调用3次 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_1000, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_1100 + * @tc.name : 11.PrepareAsync操作在每个可进行的操作后都调用一次 + * @tc.desc : test PrepareAsync +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_1100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/12.GetCurrentTime.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/12.GetCurrentTime.cpp new file mode 100644 index 0000000000000000000000000000000000000000..77a1d7a5d491e9c8b2177edb64b59d0f552be850 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/api/12.GetCurrentTime.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerAPITest.h" +#include "player.h" +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_API_Seek_1500 + * @tc.name : 15.GET操作在每个可进行的操作后都调用一次 + * @tc.desc : test Seek +*/ +HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_GetParameter_0100, Reliability | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + int32_t duration; + int32_t defaultDuration; + EXPECT_NE(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(0, time); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + EXPECT_NE(RET_OK, player->GetCurrentTime(time)); + EXPECT_NE(RET_OK, player->GetDuration(duration)); + EXPECT_FALSE(player->IsPlaying()); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + EXPECT_NE(RET_OK, player->GetCurrentTime(time)); + EXPECT_NE(RET_OK, player->GetDuration(duration)); + EXPECT_FALSE(player->IsPlaying()); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + EXPECT_NE(RET_OK, player->GetCurrentTime(time)); + EXPECT_NE(RET_OK, player->GetDuration(duration)); + EXPECT_FALSE(player->IsPlaying()); + // prepare + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(FILE_BEGIN, time); + EXPECT_EQ(RET_OK, player->GetDuration(defaultDuration)); + EXPECT_FALSE(player->IsPlaying()); + // play + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(defaultDuration, duration); + EXPECT_TRUE(player->IsPlaying()); + // seek + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(defaultDuration, duration); + // pause + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(defaultDuration, duration); + // seek duration + EXPECT_EQ(RET_OK, player->Seek(defaultDuration + 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(defaultDuration, time); + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(defaultDuration, duration); + // stop + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->GetDuration(duration)); + EXPECT_EQ(defaultDuration, duration); + EXPECT_FALSE(player->IsPlaying()); + // reset + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_NE(RET_OK, player->GetCurrentTime(time)); + EXPECT_NE(RET_OK, player->GetDuration(duration)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerFuncAsyncTest.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerFuncAsyncTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d202970ea25f146a455f0a8b8c658de7c9bd1937 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerFuncAsyncTest.cpp @@ -0,0 +1,1203 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ActsPlayerFuncTest.h" +#include "securec.h" + +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0100 + * @tc.name : 001.进行播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0100, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0200 + * @tc.name : 002.进行暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0200, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0300 + * @tc.name : 003.进行恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0300, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0400 + * @tc.name : 004.进行停止播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0400, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0500 + * @tc.name : 005.进行结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0500, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0600 + * @tc.name : 006.暂停后恢复播放,再次暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0600, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0700 + * @tc.name : 007.暂停后结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0700, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0800 + * @tc.name : 008.暂停后恢复播放,再结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0800, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_0900 + * @tc.name : 009.停止播放后重新开始播放,暂停后恢复播放,再结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_0900, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1000 + * @tc.name : 010.停止播放后重新开始播放,暂停后结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1000, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1100 + * @tc.name : 011.停止播放后重新开始播放,再次结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1100, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1300 + * @tc.name : 013.停止播放后暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1300, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1400 + * @tc.name : 014.开始播放,进行Seek,再暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1400, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1500 + * @tc.name : 015.开始播放,暂停后进行Seek,再恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1500, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1600 + * @tc.name : 016.开始播放,暂停后恢复播放,进行Seek,再暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1600, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + for (int32_t i = 1; i < 4; i++) { + EXPECT_EQ(RET_OK, player->Seek(i * 1000, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(i * 1000, time, DELTA_TIME); + } + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1700 + * @tc.name : 017.开始播放,进行Seek + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1700, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1800 + * @tc.name : 018.开始播放,进行Seek,停止播放, + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1800, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_1900 + * @tc.name : 019.开始播放,停止播放,进行Seek + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_1900, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2000 + * @tc.name : 020.开始播放,暂停后进行Seek + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2000, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + for (int32_t i = 0; i < durationTime; i = i + (durationTime / 3) + 1) { + EXPECT_EQ(RET_OK, player->Seek(i, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(i, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + } + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2100 + * @tc.name : 021.开始播放,暂停后进行Seek,停止播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2100, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + for (int32_t i = 0; i < durationTime; i = i + (durationTime / 3) + 1) { + EXPECT_EQ(RET_OK, player->Seek(i, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(i, time, DELTA_TIME); + } + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2200 + * @tc.name : 022.开始播放,暂停后恢复播放,进行Seek + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2200, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000 + SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2300 + * @tc.name : 023.开始播放,暂停后恢复播放,进行Seek,停止播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2300, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2400 + * @tc.name : 024.开始播放,停止播放,进行Seek,重新播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2400, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2500 + * @tc.name : 025.进行Seek,Seek到文件开始的位置 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2500, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Seek(FILE_BEGIN, SEEK_PREVIOUS_SYNC)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2600 + * @tc.name : 026.开始播放,停止播放,进行Seek,再暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2600, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->Pause()); + + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2700 + * @tc.name : 027.开始播放,停止播放,进行Seek,再进行恢复播放操作 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2700, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2800 + * @tc.name : 028.进行Seek,Seek到文件结尾的位置 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2800, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_2900 + * @tc.name : 029.进行Seek,Seek到超过文件结尾的位置 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_2900, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_3000 + * @tc.name : 030.进行Seek,Seek到文件随机的位置 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_3000, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime / 3, SEEK_PREVIOUS_SYNC)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(durationTime / 3, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_3100 + * @tc.name : 031.进行Seek,seek后开始进行基本播控操作 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_3100, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + for (int32_t i = 0; i < durationTime; i = i + (durationTime / 3) + 1) { + EXPECT_EQ(RET_OK, player->Seek(i, SEEK_PREVIOUS_SYNC)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(i, time, DELTA_TIME); + } + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_3200 + * @tc.name : 032.暂停时Seek到文件开始,恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_3200, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(FILE_BEGIN, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_3300 + * @tc.name : 033.暂停时Seek到文件结尾,恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_3300, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + sleep(PLAYING_TIME); + + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_03_3400 + * @tc.name : 034.暂停时Seek到超过文件结尾的位置,恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_03_3400, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerFuncTest.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerFuncTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6758776748ed2af6a9a95f76b16bec7890fca393 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerFuncTest.cpp @@ -0,0 +1,1231 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsPlayerFuncTest.h" +#include "securec.h" + +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0100 + * @tc.name : 001.进行播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0100, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0200 + * @tc.name : 002.进行暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0200, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0300 + * @tc.name : 003.进行恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0300, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0400 + * @tc.name : 004.进行停止播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0400, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0500 + * @tc.name : 005.进行结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0500, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0600 + * @tc.name : 006.暂停后恢复播放,再次暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0600, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0700 + * @tc.name : 007.暂停后结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0700, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0800 + * @tc.name : 008.暂停后恢复播放,再结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0800, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_0900 + * @tc.name : 009.停止播放后重新开始播放,暂停后恢复播放,再结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_0900, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1000 + * @tc.name : 010.停止播放后重新开始播放,暂停后结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1000, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1100 + * @tc.name : 011.停止播放后重新开始播放,再次结束播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1100, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1300 + * @tc.name : 013.停止播放后暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1300, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1400 + * @tc.name : 014.开始播放,进行Seek,再暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1400, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1500 + * @tc.name : 015.开始播放,暂停后进行Seek,再恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1500, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1600 + * @tc.name : 016.开始播放,暂停后恢复播放,进行Seek,再暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1600, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + for (int32_t i = 1; i < 4; i++) { + EXPECT_EQ(RET_OK, player->Seek(i * 1000, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(i * 1000, time, DELTA_TIME); + } + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1700 + * @tc.name : 017.开始播放,进行Seek + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1700, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1800 + * @tc.name : 018.开始播放,进行Seek,停止播放, + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1800, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_1900 + * @tc.name : 019.开始播放,停止播放,进行Seek + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_1900, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2000 + * @tc.name : 020.开始播放,暂停后进行Seek + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2000, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + for (int32_t i = 0; i < durationTime; i = i + (durationTime / 3) + 1) { + EXPECT_EQ(RET_OK, player->Seek(i, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(i, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + } + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2100 + * @tc.name : 021.开始播放,暂停后进行Seek,停止播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2100, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + for (int32_t i = 0; i < durationTime; i = i + (durationTime / 3) + 1) { + EXPECT_EQ(RET_OK, player->Seek(i, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(i, time, DELTA_TIME); + } + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2200 + * @tc.name : 022.开始播放,暂停后恢复播放,进行Seek + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2200, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000 + SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2300 + * @tc.name : 023.开始播放,暂停后恢复播放,进行Seek,停止播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2300, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2400 + * @tc.name : 024.开始播放,停止播放,进行Seek,重新播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2400, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2500 + * @tc.name : 025.进行Seek,Seek到文件开始的位置 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2500, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Seek(FILE_BEGIN, SEEK_PREVIOUS_SYNC)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2600 + * @tc.name : 026.开始播放,停止播放,进行Seek,再暂停 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2600, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_NE(RET_OK, player->Pause()); + + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2700 + * @tc.name : 027.开始播放,停止播放,进行Seek,再进行恢复播放操作 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2700, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2800 + * @tc.name : 028.进行Seek,Seek到文件结尾的位置 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2800, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_2900 + * @tc.name : 029.进行Seek,Seek到超过文件结尾的位置 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_2900, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_3000 + * @tc.name : 030.进行Seek,Seek到文件随机的位置 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_3000, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime / 3, SEEK_PREVIOUS_SYNC)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(durationTime / 3, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_3100 + * @tc.name : 031.进行Seek,seek后开始进行基本播控操作 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_3100, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + for (int32_t i = 0; i < durationTime; i = i + (durationTime / 3) + 1) { + EXPECT_EQ(RET_OK, player->Seek(i, SEEK_PREVIOUS_SYNC)); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(i, time, DELTA_TIME); + } + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_3200 + * @tc.name : 032.暂停时Seek到文件开始,恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_3200, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Seek(FILE_BEGIN, SEEK_PREVIOUS_SYNC)); + + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_3300 + * @tc.name : 033.暂停时Seek到文件结尾,恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_3300, Function | MediumTest | Level2) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + sleep(PLAYING_TIME); + + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_03_3400 + * @tc.name : 034.暂停时Seek到超过文件结尾的位置,恢复播放 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_03_3400, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerStateAsyncTest.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerStateAsyncTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..78e6bdd538bb923cb25857e3c5a4691c01792b4a --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerStateAsyncTest.cpp @@ -0,0 +1,1158 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ActsPlayerFuncTest.h" +#include "securec.h" + +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_0100 + * @tc.name : 001.prepare-reset,销毁播放器 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_0100, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_0200 + * @tc.name : 002.prepare-reset,不销毁播放器 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_0200, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_0300 + * @tc.name : 003.prepare-stop-reset,销毁播放器 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_0300, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_0400 + * @tc.name : 004.prepare-stop-reset,不销毁播放器 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_0400, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_0600 + * @tc.name : 006.prepare-play-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_0600, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(time, PLAYING_TIME * 1000, 1000); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_0700 + * @tc.name : 007.prepare-seek-play-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_0700, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(time, PLAYING_TIME * 1000, 1000); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_0800 + * @tc.name : 008.prepare-seek-play-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_0800, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(time, SEEK_TIME_5_SEC + PLAYING_TIME * 1000, 1000); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_0900 + * @tc.name : 009.prepare-play-seek-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_0900, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1000 + * @tc.name : 010.prepare-play-seek-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1000, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1100 + * @tc.name : 011.prepare-play-seek-pause-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1100, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1200 + * @tc.name : 012.prepare-play-seek-pause-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1200, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1300 + * @tc.name : 013.prepare-play-seek-pause-stop-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1300, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1400 + * @tc.name : 014.prepare-play-seek-pause-stop-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1400, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1500 + * @tc.name : 015.prepare-play-stop-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1500, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1600 + * @tc.name : 016.prepare-play-stop-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1600, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1700 + * @tc.name : 017.prepare-stop,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1700, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1800 + * @tc.name : 018.pause-GetCurrentTime-play-GetCurrentTime + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1800, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000 * 2, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_1900 + * @tc.name : 019.pause-GetCurrentTime-seek-play-GetCurrentTime + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_1900, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC + PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2000 + * @tc.name : 020.play-seek EOS-GetCurrentTime-进入PlaybackCompleted,loop=0 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2000, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_FALSE(player->IsLooping()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(FILE_BEGIN, time); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2100 + * @tc.name : 021.seek EOS-GetCurrentTime-进入PlaybackCompleted,loop=0 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2100, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_FALSE(player->IsLooping()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(FILE_BEGIN, time); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2200 + * @tc.name : 022.play-seek EOS-GetCurrentTime,loop=1 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2200, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time_before; + int32_t time_after; + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsLooping()); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_before)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_after)); + EXPECT_NEAR(time_after - time_before, PLAYING_TIME * 1000, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2300 + * @tc.name : 023.prepare-play-seek EOS-GetCurrentTime-进入PlaybackCompleted-stop,loop=0 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2300, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + + EXPECT_FALSE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2400 + * @tc.name : 024.seek,seek随机+EOS附近 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2400, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime - 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(durationTime, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2500 + * @tc.name : 025.pause-seek-resume,不等seek完成 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2500, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC + PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2600 + * @tc.name : 026.seek,不等seek完成,seek + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2600, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2625 + * @tc.name : 026.seek,不等seek完成,pause + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2625, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2650 + * @tc.name : 026.seek,不等seek完成,GetDuration + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2650, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2651 + * @tc.name : 026.seek,不等seek完成,GetCurrentTime + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2651, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2675 + * @tc.name : 026.seek,不等seek完成,play + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2675, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2700 + * @tc.name : 027.prepare-seek未完成-seek eos-start-seek eos-start-stop + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2700, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2800 + * @tc.name : 028.prepare-start-pause-seek eos-stop-prepare-start-stop + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2800, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Stop()); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_2900 + * @tc.name : 029.prepare-seek eos-start-stop-prepare-seek eos-start-stop,loop=1 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_2900, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t time_before; + int32_t time_after; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->Stop()); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_before)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_after)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Async_Function_04_3000 + * @tc.name : 030.prepare-start-pause-seek eos-start-stop-prepare-start-pause-seek-start-stop,loop=1 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Async_Function_04_3000, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t time_before; + int32_t time_after; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_before)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_after)); + EXPECT_NEAR(time_after - time_before, PLAYING_TIME * 1000, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + ASSERT_EQ(RET_OK, player->PrepareAsync()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(SEEK_TIME_2_SEC, time); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(FILE_BEGIN, time); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerStateTest.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerStateTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..41e6a21094c607dd15d3727964e513c72f2cc1a3 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/player/src/function/ActsPlayerStateTest.cpp @@ -0,0 +1,1166 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ActsPlayerFuncTest.h" +#include "securec.h" + +using namespace std; +using namespace OHOS; +using namespace OHOS::Media; +using namespace testing::ext; +using namespace PlayerNameSpace; + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_0100 + * @tc.name : 001.prepare-reset,销毁播放器 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_0100, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_0200 + * @tc.name : 002.prepare-reset,不销毁播放器 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_0200, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_0300 + * @tc.name : 003.prepare-stop-reset,销毁播放器 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_0300, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_0400 + * @tc.name : 004.prepare-stop-reset,不销毁播放器 + * @tc.desc : 播控 +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_0400, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_0600 + * @tc.name : 006.prepare-play-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_0600, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_TRUE(player->IsPlaying()); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(time, PLAYING_TIME * 1000, 1000); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_0700 + * @tc.name : 007.prepare-seek-play-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_0700, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(time, PLAYING_TIME * 1000, 1000); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_0800 + * @tc.name : 008.prepare-seek-play-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_0800, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(time, SEEK_TIME_5_SEC + PLAYING_TIME * 1000, 1000); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_0900 + * @tc.name : 009.prepare-play-seek-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_0900, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1000 + * @tc.name : 010.prepare-play-seek-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1000, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1100 + * @tc.name : 011.prepare-play-seek-pause-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1100, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1200 + * @tc.name : 012.prepare-play-seek-pause-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1200, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1300 + * @tc.name : 013.prepare-play-seek-pause-stop-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1300, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1400 + * @tc.name : 014.prepare-play-seek-pause-stop-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1400, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1500 + * @tc.name : 015.prepare-play-stop-reset,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1500, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1600 + * @tc.name : 016.prepare-play-stop-reset,销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1600, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Release()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1700 + * @tc.name : 017.prepare-stop,不销毁播放器 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1700, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1800 + * @tc.name : 018.pause-GetCurrentTime-play-GetCurrentTime + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1800, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000 * 2, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_1900 + * @tc.name : 019.pause-GetCurrentTime-seek-play-GetCurrentTime + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_1900, Function | MediumTest | Level0) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + int32_t time; + ASSERT_EQ(RET_OK, player->SetSource(uri)); + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_FALSE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_2_SEC + PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2000 + * @tc.name : 020.play-seek EOS-GetCurrentTime-进入PlaybackCompleted,loop=0 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2000, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_FALSE(player->IsLooping()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(FILE_BEGIN, time); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2100 + * @tc.name : 021.seek EOS-GetCurrentTime-进入PlaybackCompleted,loop=0 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2100, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_FALSE(player->IsLooping()); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(FILE_BEGIN, time); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2200 + * @tc.name : 022.play-seek EOS-GetCurrentTime,loop=1 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2200, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time_before; + int32_t time_after; + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsLooping()); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_before)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_after)); + EXPECT_NEAR(time_after - time_before, PLAYING_TIME * 1000, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2300 + * @tc.name : 023.prepare-play-seek EOS-GetCurrentTime-进入PlaybackCompleted-stop,loop=0 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2300, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->SetLooping(false)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime + 1, SEEK_PREVIOUS_SYNC)); + + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + + EXPECT_FALSE(player->IsLooping()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2400 + * @tc.name : 024.seek,seek随机+EOS附近 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2400, Function | MediumTest | Level1) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime - 1, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(durationTime, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2500 + * @tc.name : 025.pause-seek-resume,不等seek完成 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2500, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_GE(time, SEEK_TIME_5_SEC); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2600 + * @tc.name : 026.seek,不等seek完成,seek + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2600, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_5_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(SEEK_TIME_5_SEC, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2625 + * @tc.name : 026.seek,不等seek完成,pause + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2625, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2650 + * @tc.name : 026.seek,不等seek完成,GetDuration + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2650, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2651 + * @tc.name : 026.seek,不等seek完成,GetCurrentTime + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2651, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2675 + * @tc.name : 026.seek,不等seek完成,play + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2675, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + testObj.mutexFlag_ = false; + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + testObj.mutexFlag_ = true; + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_NEAR(PLAYING_TIME * 1000, time, DELTA_TIME); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2700 + * @tc.name : 027.prepare-seek未完成-seek eos-start-seek eos-start-stop + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2700, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_FALSE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2800 + * @tc.name : 028.prepare-start-pause-seek eos-stop-prepare-start-stop + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2800, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Pause()); + + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Stop()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + sleep(PLAYING_TIME); + EXPECT_TRUE(player->IsPlaying()); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_2900 + * @tc.name : 029.prepare-seek eos-start-stop-prepare-seek eos-start-stop,loop=1 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_2900, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t time_before; + int32_t time_after; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->Stop()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_before)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_after)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} + +/** + * @tc.number : SUB_MEDIA_PLAYER_Local_Function_04_3000 + * @tc.name : 030.prepare-start-pause-seek eos-start-stop-prepare-start-pause-seek-start-stop,loop=1 + * @tc.desc : +*/ +HWTEST_F(ActsPlayerFuncTest, SUB_MEDIA_PLAYER_Local_Function_04_3000, Function | MediumTest | Level3) +{ + PlayerSignal testObj; + std::shared_ptr player = std::make_shared(&testObj); + ASSERT_NE(nullptr, player); + ASSERT_EQ(true, player->CreatePlayer()); + int32_t time; + int32_t time_before; + int32_t time_after; + int32_t durationTime; + std::string uri = GetUri(); + ASSERT_EQ(RET_OK, player->SetSource(uri)); + + sptr videoSurface = player->GetVideoSurface(g_sub_config); + EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface)); + std::shared_ptr testCallback = std::make_shared(&testObj); + EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback)); + + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->SetLooping(true)); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->GetDuration(durationTime)); + EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(durationTime, time); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_before)); + sleep(PLAYING_TIME); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time_after)); + EXPECT_NEAR(time_after - time_before, PLAYING_TIME * 1000, DELTA_TIME); + EXPECT_EQ(RET_OK, player->Stop()); + ASSERT_EQ(RET_OK, player->Prepare()); + EXPECT_EQ(RET_OK, player->Play()); + EXPECT_EQ(RET_OK, player->Pause()); + EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC)); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(SEEK_TIME_2_SEC, time); + EXPECT_EQ(RET_OK, player->Stop()); + EXPECT_EQ(RET_OK, player->GetCurrentTime(time)); + EXPECT_EQ(FILE_BEGIN, time); + EXPECT_EQ(RET_OK, player->Reset()); + EXPECT_EQ(RET_OK, testCallback->errorNum); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/include/ActsAudioRecoederTest.h b/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/include/ActsAudioRecoederTest.h new file mode 100644 index 0000000000000000000000000000000000000000..82fd9211484274de148281246a98aa6b172d9ad6 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/include/ActsAudioRecoederTest.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef RECODER_DEMO_TEST_H +#define RECODER_DEMO_TEST_H + +#include "gtest/gtest.h" +#include "recorder.h" + +namespace OHOS { +namespace Media { +struct AudioRecorderConfig { + int32_t audioSourceId; + int32_t audioEncodingBitRate; + int32_t channelCount; + int32_t duration; + std::string outPath; + int32_t sampleRate; + AudioCodecFormat audioFormat; + AudioSourceType inputSource; + OutputFormatType outPutFormat; +}; + +class ActsAudioRecorderTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(void); + void TearDown(void); + void ConfigAudioRecorder(std::shared_ptr recorder, AudioRecorderConfig audioConfig); + void AudioRecorderStart(std::shared_ptr recorder); +}; + +class TestAudioRecorderCallback : public RecorderCallback { +public: + void OnError(int32_t errorType, int32_t errorCode); + void OnInfo(int32_t type, int32_t extra); +}; +} +} +#endif \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/include/ActsVideoRecorderTest.h b/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/include/ActsVideoRecorderTest.h new file mode 100644 index 0000000000000000000000000000000000000000..404a9d956671c2b29a9e18c0ea06670091c01d93 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/include/ActsVideoRecorderTest.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef RECODER_VIDEO_TEST_H +#define RECODER_VIDEO_TEST_H + +#include "gtest/gtest.h" +#include "recorder.h" + +namespace OHOS { +namespace Media { +struct VideoRecorderConfig { + int32_t audioSourceId; + int32_t videoSourceId; + int32_t audioEncodingBitRate; + int32_t channelCount; + int32_t duration; + int32_t width; + int32_t height; + int32_t frameRate; + int32_t videoEncodingBitRate; + int32_t sampleRate; + double captureFps; + std::string outPath; + AudioCodecFormat audioFormat; + AudioSourceType aSource; + OutputFormatType outPutFormat; + VideoSourceType vSource; + VideoCodecFormat videoFormat; +}; + +class ActsVideoRecorderTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(void); + void TearDown(void); + void ConfigvideoRecorder(std::shared_ptr recorder, VideoRecorderConfig videoConfig, bool isAudio); + void VideoRecorderStart(std::shared_ptr recorder); +}; + +class TestVideoRecorderCallback : public RecorderCallback { +public: + void OnError(int32_t errorType, int32_t errorCode); + void OnInfo(int32_t type, int32_t extra); +}; +} +} +#endif \ No newline at end of file diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/src/fuction/ActsAudioRecoederTest.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/src/fuction/ActsAudioRecoederTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dd26dc5628d69ebbd89b1822a941505f13a20732 --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/src/fuction/ActsAudioRecoederTest.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsAudioRecoederTest.h" +#include "mediatest_log.h" + +using namespace std; +using namespace OHOS::Media; +using namespace testing::ext; + +static AudioRecorderConfig g_audioRecorderConfig = { + 0, + 48000, + 2, + 60, + "/data/recorder", + 48000, + AAC_LC, + AUDIO_MIC, + FORMAT_M4A, +}; + +void TestAudioRecorderCallback::OnError(int32_t errorType, int32_t errorCode) +{ + MEDIA_INFO_LOG("OnError errorType is %d, errorCode is %d", errorType, errorCode); +} + +void TestAudioRecorderCallback::OnInfo(int32_t type, int32_t extra) +{ + MEDIA_INFO_LOG("OnInfo type is %d, extra is %d", type, extra); +} + +void ActsAudioRecorderTest::SetUpTestCase(void) +{ + MEDIA_INFO_LOG("ActsAudioRecorderTest::SetUpTestCase"); +} + +void ActsAudioRecorderTest::TearDownTestCase(void) +{ + MEDIA_INFO_LOG("ActsAudioRecorderTest::TearDownTestCase"); +} + +void ActsAudioRecorderTest::SetUp(void) +{ + MEDIA_INFO_LOG("ActsAudioRecorderTest::SetUp"); +} + +void ActsAudioRecorderTest::TearDown(void) +{ + MEDIA_INFO_LOG("ActsAudioRecorderTest::TearDown"); +} + +void ActsAudioRecorderTest::ConfigAudioRecorder(std::shared_ptr recorder, AudioRecorderConfig audioConfig) +{ + std::shared_ptr testCallback = std::make_shared(); + ASSERT_NE(nullptr, testCallback); + EXPECT_EQ(0, recorder->SetAudioSource(audioConfig.inputSource, audioConfig.audioSourceId)); + EXPECT_EQ(0, recorder->SetOutputFormat(audioConfig.outPutFormat)); + EXPECT_EQ(0, recorder->SetAudioEncoder(audioConfig.audioSourceId, audioConfig.audioFormat)); + EXPECT_EQ(0, recorder->SetAudioSampleRate(audioConfig.audioSourceId, audioConfig.sampleRate)); + EXPECT_EQ(0, recorder->SetAudioChannels(audioConfig.audioSourceId, audioConfig.channelCount)); + EXPECT_EQ(0, recorder->SetAudioEncodingBitRate(audioConfig.audioSourceId, audioConfig.audioEncodingBitRate)); + EXPECT_EQ(0, recorder->SetMaxDuration(audioConfig.duration)); + EXPECT_EQ(0, recorder->SetOutputPath(audioConfig.outPath)); + EXPECT_EQ(0, recorder->SetRecorderCallback(testCallback)); +} + +void ActsAudioRecorderTest::AudioRecorderStart(std::shared_ptr recorder) +{ + EXPECT_EQ(0, recorder->Prepare()); + EXPECT_EQ(0, recorder->Start()); + sleep(2); + EXPECT_EQ(0, recorder->Stop(false)); + EXPECT_EQ(0, recorder->Reset()); + EXPECT_EQ(0, recorder->Release()); +} + +/* * + * @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0100 + * @tc.name : 01.set audio format to AAC + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsAudioRecorderTest, SUB_MEDIA_RECORDER_Codec_AAC_Function_0100, Function | MediumTest | Level0) +{ + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsAudioRecorderTest::ConfigAudioRecorder(recorder, g_audioRecorderConfig); + ActsAudioRecorderTest::AudioRecorderStart(recorder); +} + +/* * + * @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0300 + * @tc.name : 03.Set different samplerate 8-96KHz + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsAudioRecorderTest, SUB_MEDIA_RECORDER_Codec_AAC_Function_0300, Function | MediumTest | Level0) +{ + for (int i = 8000; i < 96000; i = i + 10000) { + g_audioRecorderConfig.sampleRate = i; + g_audioRecorderConfig.outPath = "/data/recorder"; + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsAudioRecorderTest::ConfigAudioRecorder(recorder, g_audioRecorderConfig); + ActsAudioRecorderTest::AudioRecorderStart(recorder); + } +} + +/* * + * @tc.number : SUB_MEDIA_RECORDER_Format_MP4_Function_05_0200 + * @tc.name : 02.Set outPutFormat to FORMAT_MPEG_4 + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsAudioRecorderTest, SUB_MEDIA_RECORDER_Format_MP4_Function_05_0200, Function | MediumTest | Level0) +{ + g_audioRecorderConfig.outPutFormat = FORMAT_MPEG_4; + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsAudioRecorderTest::ConfigAudioRecorder(recorder, g_audioRecorderConfig); + ActsAudioRecorderTest::AudioRecorderStart(recorder); +} + +/* * + * @tc.number : SUB_MEDIA_RECORDER_Function_09_01_0100 + * @tc.name : 001.Stopping Recording in DRAIN Mode When Recording Pure Audio Files + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsAudioRecorderTest, SUB_MEDIA_RECORDER_Function_09_01_0100, Function | MediumTest | Level0) +{ + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsAudioRecorderTest::ConfigAudioRecorder(recorder, g_audioRecorderConfig); + EXPECT_EQ(0, recorder->Prepare()); + EXPECT_EQ(0, recorder->Start()); + sleep(5); + EXPECT_EQ(0, recorder->Stop(true)); + EXPECT_EQ(0, recorder->Release()); +} diff --git a/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/src/fuction/ActsVideoRecorderTest.cpp b/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/src/fuction/ActsVideoRecorderTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f954d4ce4ffba8c3978b0e9956b63fc31badf65a --- /dev/null +++ b/multimedia/audio/audio_native_standard/media_cpp_test_standard/recorder/src/fuction/ActsVideoRecorderTest.cpp @@ -0,0 +1,239 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ActsVideoRecorderTest.h" +#include "mediatest_log.h" + +using namespace std; +using namespace OHOS::Media; +using namespace testing::ext; + +static VideoRecorderConfig g_videoRecorderConfig = { + 0, + 0, + 48000, + 2, + 60, + 1920, + 1080, + 30, + 48000, + 48000, + 30, + "/data/recorder", + AAC_LC, + AUDIO_MIC, + FORMAT_MPEG_4, + VIDEO_SOURCE_SURFACE_ES, + H264, +}; + +static int g_videoWidth[3] = {1920, 1280, 720}; +static int g_videoHeight[3] = {1080, 720, 480}; + +void TestVideoRecorderCallback::OnError(int32_t errorType, int32_t errorCode) +{ + MEDIA_INFO_LOG("OnError errorType is %d, errorCode is %d", errorType, errorCode); +} + +void TestVideoRecorderCallback::OnInfo(int32_t type, int32_t extra) +{ + MEDIA_INFO_LOG("OnInfo type is %d, extra is %d", type, extra); +} + +void ActsVideoRecorderTest::SetUpTestCase(void) +{ + MEDIA_INFO_LOG("ActsAudioRecorderTest::SetUpTestCase"); +} + +void ActsVideoRecorderTest::TearDownTestCase(void) +{ + MEDIA_INFO_LOG("ActsAudioRecorderTest::TearDownTestCase"); +} + +void ActsVideoRecorderTest::SetUp(void) +{ + MEDIA_INFO_LOG("ActsAudioRecorderTest::SetUp"); +} + +void ActsVideoRecorderTest::TearDown(void) +{ + MEDIA_INFO_LOG("ActsAudioRecorderTest::TearDown"); +} + +void ActsVideoRecorderTest::ConfigvideoRecorder(std::shared_ptr recorder, + VideoRecorderConfig videoConfig, bool isAudio) +{ + std::shared_ptr testCallback = std::make_shared(); + ASSERT_NE(nullptr, testCallback); + EXPECT_EQ(0, recorder->SetVideoSource(videoConfig.vSource, videoConfig.videoSourceId)); + if (isAudio) { + EXPECT_EQ(0, recorder->SetAudioSource(videoConfig.aSource, videoConfig.audioSourceId)); + } + EXPECT_EQ(0, recorder->SetOutputFormat(videoConfig.outPutFormat)); + EXPECT_EQ(0, recorder->SetVideoEncoder(videoConfig.videoSourceId, videoConfig.videoFormat)); + EXPECT_EQ(0, recorder->SetVideoSize(videoConfig.videoSourceId, videoConfig.width, videoConfig.height)); + EXPECT_EQ(0, recorder->SetVideoFrameRate(videoConfig.videoSourceId, videoConfig.frameRate)); + EXPECT_EQ(0, recorder->SetVideoEncodingBitRate(videoConfig.videoSourceId, videoConfig.videoEncodingBitRate)); + EXPECT_EQ(0, recorder->SetCaptureRate(videoConfig.videoSourceId, videoConfig.captureFps)); + if (isAudio) { + EXPECT_EQ(0, recorder->SetAudioEncoder(videoConfig.audioSourceId, videoConfig.audioFormat)); + EXPECT_EQ(0, recorder->SetAudioSampleRate(videoConfig.audioSourceId, videoConfig.sampleRate)); + EXPECT_EQ(0, recorder->SetAudioChannels(videoConfig.audioSourceId, videoConfig.channelCount)); + EXPECT_EQ(0, recorder->SetAudioEncodingBitRate(videoConfig.audioSourceId, videoConfig.audioEncodingBitRate)); + } + EXPECT_EQ(0, recorder->SetMaxDuration(videoConfig.duration)); + EXPECT_EQ(0, recorder->SetOutputPath(videoConfig.outPath)); + EXPECT_EQ(0, recorder->SetRecorderCallback(testCallback)); +} + +void ActsVideoRecorderTest::VideoRecorderStart(std::shared_ptr recorder) +{ + EXPECT_EQ(0, recorder->Prepare()); + EXPECT_EQ(0, recorder->Start()); + sleep(5); + EXPECT_EQ(0, recorder->Stop(false)); + EXPECT_EQ(0, recorder->Reset()); + EXPECT_EQ(0, recorder->Release()); +} + +/** + * @tc.number : SUB_MEDIA_RECORDER_Codec_H264_Function_03_0100 + * @tc.name : 01.Local recording H264 + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsVideoRecorderTest, SUB_MEDIA_RECORDER_Codec_H264_Function_03_0100, Function | MediumTest | Level0) +{ + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsVideoRecorderTest::ConfigvideoRecorder(recorder, g_videoRecorderConfig, true); + ActsVideoRecorderTest::VideoRecorderStart(recorder); +} + +/** + * @tc.number : SUB_MEDIA_RECORDER_Codec_H264_Function_03_0200 + * @tc.name : 02.Local recording H264_1080P/720P/480P + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsVideoRecorderTest, SUB_MEDIA_RECORDER_Codec_H264_Function_03_0200, Function | MediumTest | Level0) +{ + for (int i = 0; i < 3; i++) { + g_videoRecorderConfig.width = g_videoWidth[i]; + g_videoRecorderConfig.height = g_videoHeight[i]; + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsVideoRecorderTest::ConfigvideoRecorder(recorder, g_videoRecorderConfig, true); + ActsVideoRecorderTest::VideoRecorderStart(recorder); + } +} + +/** + * @tc.number : SUB_MEDIA_RECORDER_Codec_H264_Function_03_0400 + * @tc.name : 04.Local recording H264_BitRate + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsVideoRecorderTest, SUB_MEDIA_RECORDER_Codec_H264_Function_03_0400, Function | MediumTest | Level0) +{ + g_videoRecorderConfig.audioEncodingBitRate = 96000; + g_videoRecorderConfig.videoEncodingBitRate = 96000; + g_videoRecorderConfig.sampleRate = 96000; + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsVideoRecorderTest::ConfigvideoRecorder(recorder, g_videoRecorderConfig, true); + ActsVideoRecorderTest::VideoRecorderStart(recorder); +} + +/** + * @tc.number : SUB_MEDIA_RECORDER_Format_MP4_Function_05_0100 + * @tc.name : 01.Local recording H264 + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsVideoRecorderTest, SUB_MEDIA_RECORDER_Format_MP4_Function_05_0100, Function | MediumTest | Level0) +{ + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsVideoRecorderTest::ConfigvideoRecorder(recorder, g_videoRecorderConfig, false); + ActsVideoRecorderTest::VideoRecorderStart(recorder); +} + +/** + * @tc.number : SUB_MEDIA_RECORDER_Format_MP4_Function_05_0300 + * @tc.name : 03.Local recording H264 and AAC + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsVideoRecorderTest, SUB_MEDIA_RECORDER_Format_MP4_Function_05_0300, Function | MediumTest | Level0) +{ + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsVideoRecorderTest::ConfigvideoRecorder(recorder, g_videoRecorderConfig, true); + ActsVideoRecorderTest::VideoRecorderStart(recorder); +} + +/** + * @tc.number : SUB_MEDIA_RECORDER_Function_06_0100 + * @tc.name : 001.Start + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsVideoRecorderTest, SUB_MEDIA_RECORDER_Function_06_0100, Function | MediumTest | Level0) +{ + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsVideoRecorderTest::ConfigvideoRecorder(recorder, g_videoRecorderConfig, true); + EXPECT_EQ(0, recorder->Prepare()); + EXPECT_EQ(0, recorder->Start()); + sleep(5); + EXPECT_EQ(0, recorder->Release()); +} + +/** + * @tc.number : SUB_MEDIA_RECORDER_Function_06_0400 + * @tc.name : 004.Start-Stop + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsVideoRecorderTest, SUB_MEDIA_RECORDER_Function_06_0400, Function | MediumTest | Level0) +{ + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsVideoRecorderTest::ConfigvideoRecorder(recorder, g_videoRecorderConfig, true); + EXPECT_EQ(0, recorder->Prepare()); + EXPECT_EQ(0, recorder->Start()); + sleep(5); + EXPECT_EQ(0, recorder->Stop(false)); + EXPECT_EQ(0, recorder->Release()); +} + +/** + * @tc.number : SUB_MEDIA_RECORDER_Function_06_0500 + * @tc.name : 005.Start-Reset + * @tc.desc : The test case is successfully executed. + The video file can be played properly. +*/ +HWTEST_F(ActsVideoRecorderTest, SUB_MEDIA_RECORDER_Function_06_0500, Function | MediumTest | Level0) +{ + std::shared_ptr recorder = RecorderFactory::CreateRecorder(); + ASSERT_NE(nullptr, recorder); + ActsVideoRecorderTest::ConfigvideoRecorder(recorder, g_videoRecorderConfig, true); + EXPECT_EQ(0, recorder->Prepare()); + EXPECT_EQ(0, recorder->Start()); + sleep(5); + EXPECT_EQ(0, recorder->Reset()); + EXPECT_EQ(0, recorder->Release()); +} \ No newline at end of file