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