diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn
index e5184a47356ea704ad695b7abba1952e6530e6fb..78258f024e254da701cafb9321c49cb85e3288f6 100644
--- a/multimedia/BUILD.gn
+++ b/multimedia/BUILD.gn
@@ -27,6 +27,7 @@ group("multimedia") {
"audio/audio_js_standard/audioManager:audio_manager_js_hap",
"audio/audio_js_standard/audioRenderer:audio_renderer_js_hap",
"audio/audio_js_standard/audioVoip:audio_voip_js_hap",
+ "avsession/avsession_js_standard/avsessionManager:avsession_framework_js_hap",
"camera/camera_js_standard:camera_framework_ets_hap",
"image/image_js_standard/image:image_js_hap",
"image/image_js_standard/imageColorspace:image_colorspace_js_hap",
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/BUILD.gn b/multimedia/avsession/avsession_js_standard/avsessionManager/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..5cc046fdc81560514001d54afcd90c37b83100fe
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/BUILD.gn
@@ -0,0 +1,33 @@
+# Copyright (c) 2022 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("avsession_framework_js_hap") {
+ hap_profile = "./src/main/config.json"
+ deps = [
+ ":avsession_framework_js_assets",
+ ":avsession_framework_resources",
+ ]
+ certificate_profile = "./signature/openharmony_sx.p7b"
+ hap_name = "ActsAvsessionFrameworkJsTest"
+}
+ohos_js_assets("avsession_framework_js_assets") {
+ js2abc = true
+ hap_profile = "./src/main/config.json"
+ source_dir = "./src/main/js"
+}
+ohos_resources("avsession_framework_resources") {
+ sources = [ "./src/main/resources" ]
+ hap_profile = "./src/main/config.json"
+}
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/Test.json b/multimedia/avsession/avsession_js_standard/avsessionManager/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..fabbe7fee6ecccd5e406731f24095fa5637b9ca3
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/Test.json
@@ -0,0 +1,20 @@
+{
+ "description": "Configuration for avsession manager Tests",
+ "driver": {
+ "type": "OHJSUnitTest",
+ "test-timeout": "1800000",
+ "shell-timeout": "900000",
+ "bundle-name": "com.example.myapplication",
+ "package-name": "com.example.myapplication",
+ "testcase-timeout": "20000"
+ },
+ "kits": [
+ {
+ "test-file-name": [
+ "ActsAvsessionFrameworkJsTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/signature/openharmony_sx.p7b b/multimedia/avsession/avsession_js_standard/avsessionManager/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..a3d0ec3c5e5f4733697633cd69642cb53a3ed533
Binary files /dev/null and b/multimedia/avsession/avsession_js_standard/avsessionManager/signature/openharmony_sx.p7b differ
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/config.json b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..a7ad1d6d79f4a7492085ebb2d481f008a9b12875
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/config.json
@@ -0,0 +1,105 @@
+{
+ "app": {
+ "apiVersion": {
+ "compatible": 8,
+ "releaseType": "Beta1",
+ "target": 9
+ },
+ "vendor": "acts",
+ "bundleName": "com.example.myapplication",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ }
+ },
+ "deviceConfig": {
+ "default": {
+ "debug": true
+ }
+ },
+ "module": {
+ "package": "com.example.myapplication",
+ "name": ".MyApplication",
+ "mainAbility": ".MainAbility",
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "formsEnabled": false,
+ "name": ".MainAbility",
+ "srcLanguage": "js",
+ "srcPath": "MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:MainAbility_desc",
+ "label": "$string:MainAbility_label",
+ "type": "page",
+ "visible": true,
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "formsEnabled": false,
+ "name": ".TestAbility",
+ "srcLanguage": "js",
+ "srcPath": "TestAbility",
+ "icon": "$media:icon",
+ "description": "$string:TestAbility_desc",
+ "label": "$string:TestAbility_label",
+ "type": "page",
+ "visible": true,
+ "launchType": "standard"
+ }
+ ],
+ "deviceType": [
+ "tablet",
+ "default"
+ ],
+ "distro": {
+ "moduleType": "entry",
+ "installationFree": false,
+ "deliveryWithInstall": true,
+ "moduleName": "entry"
+ },
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.MANAGE_MEDIA_RESOURCES",
+ "reason": "use ohos.permission.MANAGE_MEDIA_RESOURCES"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ },
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": ".TestAbility",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
+ ],
+ "testRunner": {
+ "name": "OpenHarmonyTestRunner",
+ "srcPath": "TestRunner"
+ }
+ }
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/app.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..f052c8a909b68f6e497443771496a070ecbccb1c
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/app.js
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+export default {
+ onCreate() {
+ console.info('AceApplication onCreate');
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/i18n/en-US.json b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/i18n/en-US.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ }
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/i18n/zh-CN.json b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/i18n/zh-CN.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ }
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.css b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..5bd7567028568bd522193b2519d545ca6dcf397d
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.css
@@ -0,0 +1,46 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("/common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.hml b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..f3287ba7ab2297bff2f34e3715548ce213a88bc4
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/MainAbility/pages/index/index.js
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ },
+ onReady() {
+ },
+};
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/app.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..c3f64fa8cf44b319ee6cfbef2517a18d70647a0e
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/app.js
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
+import { Hypium } from '@ohos/hypium';
+import testsuite from '../test/List.test';
+
+export default {
+ onCreate() {
+ console.info('TestApplication onCreate');
+ var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
+ console.info('start run testcase!!!');
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
+ },
+ onDestroy() {
+ console.info("TestApplication onDestroy");
+ }
+};
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/i18n/en-US.json b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/i18n/en-US.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/i18n/zh-CN.json b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/i18n/zh-CN.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.css b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..b21c92c6290ea747bd891e2ab673721afc5521ed
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.css
@@ -0,0 +1,30 @@
+.container {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ left: 0px;
+ top: 0px;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 60px;
+ text-align: center;
+ width: 100%;
+ height: 40%;
+ margin: 10px;
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.hml b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..d94b75c085fa1c16a0b2721609b18c57a7295476
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestAbility/pages/index/index.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ }
+}
+
+
+
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestRunner/OpenHarmonyTestRunner.js
new file mode 100644
index 0000000000000000000000000000000000000000..1bba9fed6051920069f7869f418ceb5a89ad43e2
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/TestRunner/OpenHarmonyTestRunner.js
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
+
+function translateParamsToString(parameters) {
+ const keySet = new Set([
+ '-s class', '-s notClass', '-s suite', '-s itName',
+ '-s level', '-s testType', '-s size', '-s timeout',
+ '-s package', '-s dryRun'
+ ])
+ let targetParams = '';
+ for (const key in parameters) {
+ if (keySet.has(key)) {
+ targetParams += ' ' + key + ' ' + parameters[key];
+ }
+ }
+ return targetParams.trim();
+}
+
+ export default {
+ onPrepare() {
+ console.info('OpenHarmonyTestRunner OnPrepare')
+ },
+ onRun() {
+ console.log('OpenHarmonyTestRunner onRun run')
+ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+
+ var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility';
+
+ var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName;
+ cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
+ var debug = abilityDelegatorArguments.parameters["-D"];
+ console.info('debug value : '+ debug);
+ if (debug == 'true') {
+ cmd += ' -D';
+ }
+ console.info('cmd : '+ cmd);
+ abilityDelegator.executeShellCommand(cmd, (err, data) => {
+ console.info('executeShellCommand : err : ' + JSON.stringify(err));
+ console.info('executeShellCommand : data : ' + data.stdResult);
+ console.info('executeShellCommand : data : ' + data.exitCode);
+ });
+ }
+};
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..2362398a97f483f89e1cc4f35b89dc558fd003f4
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js
@@ -0,0 +1,2942 @@
+/*
+ * Copyright (c) 2022 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 avSession from '@ohos.multimedia.avsession';
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
+import image from '@ohos.multimedia.image';
+import WantAgent from '@ohos.wantAgent';
+import featureAbility from '@ohos.ability.featureAbility';
+
+export default function AVSession() {
+ describe('AVSession', function () {
+ let tag = 'ApplicationA';
+ let type = 'audio';
+ let session;
+ let controller;
+ let OutputDeviceInfo = { isRemote: false, audioDeviceId: [0], deviceName: ['LocalDevice'] };
+ let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 };
+ let event = { action: 2, key: keyItem, keys: [keyItem] };
+ let context = featureAbility.getContext();
+
+ function sleep(ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+ }
+
+ async function getPixelMap() {
+ let color = new ArrayBuffer(96);
+ let bufferArr = new Uint8Array(color);
+ bufferArr.fill('3', 0, 95);
+ let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, AlphaType: 3 };
+ return image.createPixelMap(color, opts);
+ }
+
+ beforeAll(function () {
+ console.info('TestLog: Start Testing avSession Interfaces');
+ })
+
+ beforeEach(async function () {
+ console.info('TestLog: Init Session And Controller');
+ await avSession.createAVSession(context, tag, type).then((data) => {
+ session = data;
+ }).catch((err) => {
+ console.info(`TestLog: Session create error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await session.activate().then(() => {
+ console.info('TestLog: Session activate');
+ }).catch((err) => {
+ console.info(`TestLog: Session activate error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ controller = await session.getController();
+ });
+ })
+
+ afterEach(async function (done) {
+ console.info('TestLog: Destroy Session And Controller');
+ await session.destroy().then(() => {
+ console.info('TestLog: Session destroy success');
+ }).catch((err) => {
+ console.info(`TestLog: Session destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await controller.destroy().then(() => {
+ console.info('TestLog: Controller destroy success');
+ }).catch((err) => {
+ console.info(`TestLog: Controller destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ afterAll(function () {
+ console.info('TestLog: End Testing avSession Interfaces');
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_READ_SESSION_ID_0100
+ * @tc.name : READ_SESSION_ID_0100
+ * @tc.desc : Testing read sessionId
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_READ_SESSION_ID_0100', 0, async function (done) {
+ if (session.sessionId.length === 64) {
+ console.info('TestLog: Read sessionId successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Read sessionId failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100
+ * @tc.name : SETMETADATA_0100
+ * @tc.desc : Testing set assetId - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level0
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100', 0, async function (done) {
+ let metadata0 = {
+ assetId: '121278',
+ };
+ await session.setAVMetadata(metadata0).then(() => {
+ console.info('TestLog: Set assetId successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set assetId error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.assetId === '121278') {
+ console.info('TestLog: Get assetId Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get assetId failed');
+ console.info(`TestLog: assetId is: ${data.assetId}`);
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get assetId error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0200
+ * @tc.name : SETMETADATA_0200
+ * @tc.desc : Testing set artist - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0200', 0, async function (done) {
+ let metadata1 = {
+ assetId: '121278',
+ artist: 'Eminem',
+ };
+ await session.setAVMetadata(metadata1).then(() => {
+ console.info('TestLog: Set artist successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set artist error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.artist === metadata1.artist) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get artist failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get artist error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0300
+ * @tc.name : SETMETADATA_0300
+ * @tc.desc : Testing set author - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0300', 0, async function (done) {
+ let metadata2 = {
+ assetId: '121278',
+ author: 'ST',
+ };
+ await session.setAVMetadata(metadata2).then(() => {
+ console.info('TestLog: Set author successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set author error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.author === metadata2.author) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get author failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get author error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0400
+ * @tc.name : SETMETADATA_0400
+ * @tc.desc : Testing set album - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0400', 0, async function (done) {
+ let metadata3 = {
+ assetId: '121278',
+ album: 'Slim shady',
+ };
+ await session.setAVMetadata(metadata3).then(() => {
+ console.info('TestLog: Set album successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set album error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.album === metadata3.album) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get album failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get album error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0500
+ * @tc.name : SETMETADATA_0500
+ * @tc.desc : Testing set writer - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0500', 0, async function (done) {
+ let metadata4 = {
+ assetId: '121278',
+ writer: 'ST',
+ };
+ await session.setAVMetadata(metadata4).then(() => {
+ console.info('TestLog: Set writer successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set writer error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.writer === metadata4.writer) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get writer failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get writer error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0600
+ * @tc.name : SETMETADATA_0600
+ * @tc.desc : Testing set composer - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0600', 0, async function (done) {
+ let metadata5 = {
+ assetId: '121278',
+ composer: 'ST',
+ };
+ await session.setAVMetadata(metadata5).then(() => {
+ console.info('TestLog: Set composer successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set composer error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.composer === metadata5.composer) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get composer failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get composer error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0700
+ * @tc.name : SETMETADATA_0700
+ * @tc.desc : Testing set duration - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0700', 0, async function (done) {
+ let metadata6 = {
+ assetId: '121278',
+ duration: 2222,
+ };
+ await session.setAVMetadata(metadata6).then(() => {
+ console.info('TestLog: Set duration successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set duration error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.duration === metadata6.duration) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get duration failed');
+ console.info(`TestLog: Get duration is: ${data.duration}`);
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get duration error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0800
+ * @tc.name : SETMETADATA_0800
+ * @tc.desc : Testing set mediaImage - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0800', 0, async function (done) {
+ let metadata7 = {
+ assetId: '121278',
+ mediaImage: 'https://img2.baidu.com/it/u=3583435814,2833583486&fm=253&fmt=auto&app=138&f=JPEG?w=526&h=500',
+ };
+ await session.setAVMetadata(metadata7).then(() => {
+ console.info('TestLog: Set mediaImage successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set mediaImage error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.mediaImage === metadata7.mediaImage) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get mediaImage failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get mediaImage error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0900
+ * @tc.name : SETMETADATA_0900
+ * @tc.desc : Testing set mediaImage - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0900', 0, async function (done) {
+ console.info('TestLog: Creat pixelmap');
+ let pixelMap = await getPixelMap();
+ let readBuffer0 = new ArrayBuffer(96);
+ await pixelMap.readPixelsToBuffer(readBuffer0);
+ let bufferArr0 = new Uint8Array(readBuffer0);
+ let metadata8 = {
+ assetId: '121278',
+ mediaImage: pixelMap,
+ };
+ await session.setAVMetadata(metadata8).then(() => {
+ console.info('TestLog: Set pixelMap successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set pixelMap error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ let pixMap;
+ await controller.getAVMetadata().then((data) => {
+ if (data.assetId === '121278') {
+ pixMap = data.mediaImage;
+ } else {
+ console.info('TestLog: Get pixelMap failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get pixelMap error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ let pixelSize = pixMap.getPixelBytesNumber();
+ console.info(`TestLog: pixelSize is: ${pixelSize}`);
+ let readBuffer = new ArrayBuffer(pixelSize);
+ await pixMap.readPixelsToBuffer(readBuffer);
+ let bufferArr2 = new Uint8Array(readBuffer);
+ for (let i = 0; i < bufferArr2.length; i++) {
+ if (bufferArr0[i] !== bufferArr2[i]) {
+ expect(false).assertTrue();
+ } else {
+ expect(true).assertTrue();
+ }
+ }
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1000
+ * @tc.name : SETMETADATA_1000
+ * @tc.desc : Testing set publishDate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1000', 0, async function (done) {
+ let metadata9 = {
+ assetId: '121278',
+ publishDate: new Date(1994, 1, 1, 1),
+ };
+ await session.setAVMetadata(metadata9).then(() => {
+ console.info('TestLog: Set publishDate successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set publishDate error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.publishDate.getTime() === metadata9.publishDate.getTime()) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get publishDate failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get publishDate error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1100
+ * @tc.name : SETMETADATA_1100
+ * @tc.desc : Testing set subtitle - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1100', 0, async function (done) {
+ let metadata10 = {
+ assetId: '121278',
+ subtitle: '8 Mile',
+ };
+ await session.setAVMetadata(metadata10).then(() => {
+ console.info('TestLog: Set subtitle successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set subtitle error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.subtitle === metadata10.subtitle) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get subtitle failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get subtitle error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1200
+ * @tc.name : SETMETADATA_1200
+ * @tc.desc : Testing set description - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1200', 0, async function (done) {
+ let metadata11 = {
+ assetId: '121278',
+ description: 'Rap',
+ };
+ await session.setAVMetadata(metadata11).then(() => {
+ console.info('TestLog: Set description successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set description error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.description === metadata11.description) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get description failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get description error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1300
+ * @tc.name : SETMETADATA_1300
+ * @tc.desc : Testing set lyric - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1300', 0, async function (done) {
+ let metadata12 = {
+ assetId: '121278',
+ lyric: 'https://lyric.tingmall.com/lyric/58/970/589710004-LRC-LRC.lrc?t=1649918948000',
+ };
+ await session.setAVMetadata(metadata12).then(() => {
+ console.info('TestLog: Set lyric successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set lyric error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.lyric === metadata12.lyric) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get lyric failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get lyric error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1400
+ * @tc.name : SETMETADATA_1400
+ * @tc.desc : Testing set assetId - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1400', 0, async function (done) {
+ let metadata13 = {
+ assetId: '121278',
+ previousAssetId: '121277',
+ nextAssetId: '121279',
+ };
+ await session.setAVMetadata(metadata13).then(() => {
+ console.info('TestLog: Set assetId successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set assetId error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVMetadata().then((data) => {
+ if (data.previousAssetId === metadata13.previousAssetId
+ && data.nextAssetId === metadata13.nextAssetId) {
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get assetId failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get assetId error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1500
+ * @tc.name : SETMETADATA_1500
+ * @tc.desc : Testing set metadata - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1500', 0, async function (done) {
+ let metadata14 = {
+ assetId: '121278',
+ };
+ await session.destroy();
+ await sleep(500);
+ await session.setAVMetadata(metadata14).then(() => {
+ console.info('TestLog: Set metadata successfully');
+ expect(false).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set metadata error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1600
+ * @tc.name : SETMETADATA_1600
+ * @tc.desc : Testing set error metadata - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1600', 0, async function (done) {
+ let metadata15 = {
+ assetId: '121278',
+ duration: -2,
+ };
+ await session.setAVMetadata(metadata15).then(() => {
+ console.info('TestLog: Set duration successfully');
+ expect(false).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set duration error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0100
+ * @tc.name : SETAVPLAYBACKSTATE_0100
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level0
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0100', 0, async function (done) {
+ let PlaybackState1 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_PLAY,
+ };
+ await session.setAVPlaybackState(PlaybackState1).then(() => {
+ console.info('TestLog: Set State successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.state === 2) {
+ console.info('TestLog: Get State successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get State failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0200
+ * @tc.name : SETAVPLAYBACKSTATE_0200
+ * @tc.desc : Testing set speed - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0200', 0, async function (done) {
+ let PlaybackState2 = {
+ speed: 2.6,
+ };
+
+ await session.setAVPlaybackState(PlaybackState2).then(() => {
+ console.info('TestLog: Set speed successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set speed error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.speed === 2.6) {
+ console.info('TestLog: Get speed successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get speed failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get speed error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0300
+ * @tc.name : SETAVPLAYBACKSTATE_0300
+ * @tc.desc : Testing set position - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0300', 0, async function (done) {
+ let PlaybackState3 = {
+ position: { elapsedTime: 10, updateTime: (new Date()).getTime() },
+ };
+
+ await session.setAVPlaybackState(PlaybackState3).then(() => {
+ console.info('TestLog: Set position successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set position error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.position.elapsedTime === 10) {
+ console.info('TestLog: Get position successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get position failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get position error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0400
+ * @tc.name : SETAVPLAYBACKSTATE_0400
+ * @tc.desc : Testing set bufferedTime - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0400', 0, async function (done) {
+ let PlaybackState4 = {
+ bufferedTime: 1000,
+ };
+
+ await session.setAVPlaybackState(PlaybackState4).then(() => {
+ console.info('TestLog: Set bufferedTime successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set bufferedTime error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.bufferedTime === 1000) {
+ console.info('TestLog: Get bufferedTime successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get bufferedTime failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get bufferedTime error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0500
+ * @tc.name : SETAVPLAYBACKSTATE_0500
+ * @tc.desc : Testing set loopMode - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0500', 0, async function (done) {
+ let PlaybackState5 = {
+ loopMode: avSession.LoopMode.LOOP_MODE_SEQUENCE,
+ };
+
+ await session.setAVPlaybackState(PlaybackState5).then(() => {
+ console.info('TestLog: Set loopMode successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.loopMode === 0) {
+ console.info('TestLog: Get loopMode successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get loopMode failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0600
+ * @tc.name : SETAVPLAYBACKSTATE_0600
+ * @tc.desc : Testing set loopMode - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0600', 0, async function (done) {
+ let PlaybackState6 = {
+ loopMode: avSession.LoopMode.LOOP_MODE_SINGLE,
+ };
+
+ await session.setAVPlaybackState(PlaybackState6).then(() => {
+ console.info('TestLog: Set loopMode successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.loopMode === 1) {
+ console.info('TestLog: Get loopMode successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get loopMode failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0700
+ * @tc.name : SETAVPLAYBACKSTATE_0700
+ * @tc.desc : Testing set loopMode - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0700', 0, async function (done) {
+ let PlaybackState7 = {
+ loopMode: avSession.LoopMode.LOOP_MODE_LIST,
+ };
+
+ await session.setAVPlaybackState(PlaybackState7).then(() => {
+ console.info('TestLog: Set loopMode successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.loopMode === 2) {
+ console.info('TestLog: Get loopMode successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get loopMode failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0800
+ * @tc.name : SETAVPLAYBACKSTATE_0800
+ * @tc.desc : Testing set loopMode - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0800', 0, async function (done) {
+ let PlaybackState8 = {
+ loopMode: avSession.LoopMode.LOOP_MODE_SHUFFLE,
+ };
+
+ await session.setAVPlaybackState(PlaybackState8).then(() => {
+ console.info('TestLog: Set loopMode successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.loopMode === 3) {
+ console.info('TestLog: Get loopMode successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get loopMode failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0900
+ * @tc.name : SETAVPLAYBACKSTATE_0900
+ * @tc.desc : Testing set isFavorite - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0900', 0, async function (done) {
+ let PlaybackState9 = {
+ isFavorite: true,
+ };
+
+ await session.setAVPlaybackState(PlaybackState9).then(() => {
+ console.info('TestLog: Set isFavorite successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set isFavorite error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.isFavorite === true) {
+ console.info('TestLog: Get isFavorite successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get isFavorite failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get isFavorite error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1000
+ * @tc.name : SETAVPLAYBACKSTATE_1000
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1000', 0, async function (done) {
+ let PlaybackState10 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_PLAY,
+ speed: 1.0,
+ position: { elapsedTime: 10, updateTime: (new Date()).getTime() },
+ bufferedTime: 1000,
+ loopMode: avSession.LoopMode.LOOP_MODE_SINGLE,
+ isFavorite: true,
+ };
+ await session.destroy();
+ await sleep(500);
+ await session.setAVPlaybackState(PlaybackState10).then(() => {
+ console.info('TestLog: Set playbackState successfully');
+ expect(false).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1100
+ * @tc.name : SETAVPLAYBACKSTATE_1100
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1100', 0, async function (done) {
+ let PlaybackState11 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_PLAY,
+ speed: -2,
+ position: { elapsedTime: -2, updateTime: (new Date()).getTime() },
+ bufferedTime: -4,
+ loopMode: avSession.LoopMode.LOOP_MODE_SINGLE,
+ isFavorite: true,
+ };
+ await session.setAVPlaybackState(PlaybackState11).then(() => {
+ console.info('TestLog: Set playbackState successfully');
+ expect(false).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1200
+ * @tc.name : SETAVPLAYBACKSTATE_1200
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1200', 0, async function (done) {
+ let PlaybackState12 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_INITIAL,
+ };
+ await session.setAVPlaybackState(PlaybackState12).then(() => {
+ console.info('TestLog: Set playbackState successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.state === 0) {
+ console.info('TestLog: Get State successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get State failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1300
+ * @tc.name : SETAVPLAYBACKSTATE_1300
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1300', 0, async function (done) {
+ let PlaybackState13 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_PREPARE,
+ };
+ await session.setAVPlaybackState(PlaybackState13).then(() => {
+ console.info('TestLog: Set playbackState successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.state === 1) {
+ console.info('TestLog: Get State successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get State failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1400
+ * @tc.name : SETAVPLAYBACKSTATE_1400
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1400', 0, async function (done) {
+ let PlaybackState14 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_PAUSE,
+ };
+ await session.setAVPlaybackState(PlaybackState14).then(() => {
+ console.info('TestLog: Set playbackState successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.state === 3) {
+ console.info('TestLog: Get State successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get State failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1500
+ * @tc.name : SETAVPLAYBACKSTATE_1500
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1500', 0, async function (done) {
+ let PlaybackState15 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_FAST_FORWARD,
+ };
+ await session.setAVPlaybackState(PlaybackState15).then(() => {
+ console.info('TestLog: Set playbackState successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.state === 4) {
+ console.info('TestLog: Get State successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get State failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1600
+ * @tc.name : SETAVPLAYBACKSTATE_1600
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1600', 0, async function (done) {
+ let PlaybackState16 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_REWIND,
+ };
+ await session.setAVPlaybackState(PlaybackState16).then(() => {
+ console.info('TestLog: Set playbackState successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.state === 5) {
+ console.info('TestLog: Get State successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get State failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1700
+ * @tc.name : SETAVPLAYBACKSTATE_1700
+ * @tc.desc : Testing set playbackstate - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1700', 0, async function (done) {
+ let PlaybackState17 = {
+ state: avSession.PlaybackState.PLAYBACK_STATE_STOP,
+ };
+ await session.setAVPlaybackState(PlaybackState17).then(() => {
+ console.info('TestLog: Set playbackState successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await sleep(500);
+
+ await controller.getAVPlaybackState().then((data) => {
+ if (data.state === 6) {
+ console.info('TestLog: Get State successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get State failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100
+ * @tc.name : SETLAUNCHABILITY_0100
+ * @tc.desc : Testing set LaunchAbility - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level1
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100', 0, async function (done) {
+ let wantAgentInfo = {
+ wants: [
+ {
+ bundleName: 'com.example.myapplication',
+ abilityName: 'com.example.myapplication.MainAbility'
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags: [WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+ };
+ let agent;
+ await WantAgent.getWantAgent(wantAgentInfo).then((callback) => {
+ agent = callback;
+ });
+
+ await session.setLaunchAbility(agent).then(() => {
+ console.info('TestLog: AVSessionTest : Set LaunchAbility');
+ }).catch((err) => {
+ console.info(`TestLog: Set LaunchAbility error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ let wantagent;
+ await controller.getLaunchAbility().then((data) => {
+ wantagent = data;
+ console.info('TestLog: Get launchAbility');
+ }).catch((err) => {
+ console.info(`TestLog: Get LaunchAbility error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await WantAgent.equal(agent, wantagent).then((bool) => {
+ if (bool) {
+ console.info('TestLog: AVSessionTest : Set LaunchAbility successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: AVSessionTest : Set LaunchAbility failed');
+ expect(false).assertTrue();
+ }
+ }).catch((error) => {
+ console.info(`TestLog: compare LaunchAbility error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_PROMISE_0100
+ * @tc.name : SESSIONACTIVATE_PROMISE_0100
+ * @tc.desc : Testing set session active - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level1
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_PROMISE_0100', 0, async function (done) {
+ await session.activate().then(() => {
+ console.info('TestLog: Set session active successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ await controller.isActive().then((data) => {
+ if (data) {
+ console.info('TestLog: session is active');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: session is directive');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: AVSessionTest error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_PROMISE_0100
+ * @tc.name : SESSIONDEACTIVATE_PROMISE_0100
+ * @tc.desc : Testing deactivate session- promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level1
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_PROMISE_0100', 0, async function (done) {
+ await session.activate().then(() => {
+ console.info('TestLog: Set session active');
+ }).catch((err) => {
+ console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+
+ await session.deactivate().then(() => {
+ console.info('TestLog: Deactivate session');
+ }).catch((err) => {
+ console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+
+ await controller.isActive().then((data) => {
+ if (data) {
+ console.info('TestLog: session deactivate failed');
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: session deactivate successfully');
+ expect(true).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: AVSessionTest error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_CALLBACK_0100
+ * @tc.name : SESSIONACTIVATE_CALLBACK_0100
+ * @tc.desc : Testing set session active - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_CALLBACK_0100', 0, async function (done) {
+ try {
+ session.activate((err) => {
+ if (err) {
+ console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set session active successfully');
+ }
+ })
+ } catch (err) {
+ console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+
+ await sleep(500);
+ await controller.isActive().then((data) => {
+ if (data) {
+ console.info('TestLog: session is active');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: session is directive');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: AVSessionTest error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_CALLBACK_0100
+ * @tc.name : SESSIONDEACTIVATE_CALLBACK_0100
+ * @tc.desc : Testing deactivate session- callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_CALLBACK_0100', 0, async function (done) {
+ await session.activate().then(() => {
+ console.info('TestLog: Set session active');
+ }).catch((err) => {
+ console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+
+ try{
+ session.deactivate((err) => {
+ if (err) {
+ console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Deactivate session');
+ }
+ })
+ } catch (err) {
+ console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ await sleep(500);
+
+ await controller.isActive().then((data) => {
+ if (data) {
+ console.info('TestLog: session deactivate failed');
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: session deactivate successfully');
+ expect(true).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: AVSessionTest error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100
+ * @tc.name : ONPLAY_0100
+ * @tc.desc : Testing onPlay callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100', 0, async function (done) {
+ session.on('play', () => {
+ console.info('TestLog: Play command callback registration successful');
+ expect(true).assertTrue();
+ });
+
+ await controller.sendControlCommand({ command: 'play' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPAUSE_0100
+ * @tc.name : ONPAUSE_0100
+ * @tc.desc : Testing onPause callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONPAUSE_0100', 0, async function (done) {
+ session.on('pause', () => {
+ console.info('TestLog: Pause command callback registration successful');
+ expect(true).assertTrue();
+ });
+
+ await controller.sendControlCommand({ command: 'pause' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONSTOP_0100
+ * @tc.name : ONSTOP_0100
+ * @tc.desc : Testing onStop callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONSTOP_0100', 0, async function (done) {
+ session.on('stop', () => {
+ console.info('TestLog: Stop command callback registration successful');
+ expect(true).assertTrue();
+ });
+
+ await controller.sendControlCommand({ command: 'stop' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAYNEXT_0100
+ * @tc.name : ONPLAYNEXT_0100
+ * @tc.desc : Testing onPlayNext callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONPLAYNEXT_0100', 0, async function (done) {
+ session.on('playNext', () => {
+ console.info('TestLog: PlayNext command callback registration successful');
+ expect(true).assertTrue();
+ });
+
+ await controller.sendControlCommand({ command: 'playNext' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAYPREVIOUS_0100
+ * @tc.name : ONPLAYPREVIOUS_0100
+ * @tc.desc : Testing onPlayPrevious callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONPLAYPREVIOUS_0100', 0, async function (done) {
+ session.on('playPrevious', () => {
+ console.info('TestLog: PlayPrevious command callback registration successful');
+ expect(true).assertTrue();
+ });
+
+ await controller.sendControlCommand({ command: 'playPrevious' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0100
+ * @tc.name : ONFASTFORWARD_0100
+ * @tc.desc : Testing onFastForward callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0100', 0, async function (done) {
+ session.on('fastForward', () => {
+ console.info('TestLog: FastForward command callback registration successful');
+ expect(true).assertTrue();
+ });
+
+ await controller.sendControlCommand({ command: 'fastForward' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONREWIND_0100
+ * @tc.name : ONREWIND_0100
+ * @tc.desc : Testing onRewind callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONREWIND_0100', 0, async function (done) {
+ session.on('rewind', () => {
+ console.info('TestLog: Rewind command callback registration successful');
+ expect(true).assertTrue();
+ });
+
+ await controller.sendControlCommand({ command: 'rewind' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONSEEK_0100
+ * @tc.name : ONSEEK_0100
+ * @tc.desc : Testing onSeek callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONSEEK_0100', 0, async function (done) {
+ session.on('seek', (callback) => {
+ if (callback === 10) {
+ console.info('TestLog: Seek command callback registration successful');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Seek command callback registration failed');
+ expect(false).assertTrue();
+ }
+ });
+
+ await controller.sendControlCommand({ command: 'seek', parameter: 10 }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONSETSPEED_0100
+ * @tc.name : ONSETSPEED_0100
+ * @tc.desc : Testing Set Speed callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONSETSPEED_0100', 0, async function (done) {
+ session.on('setSpeed', (callback) => {
+ if (callback === 2.6) {
+ console.info('TestLog: SetSpeed command callback registration successful');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: SetSpeed command callback registration error');
+ expect(false).assertTrue();
+ }
+ });
+
+ await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.6 }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONSETLOOPMODE_0100
+ * @tc.name : ONSETLOOPMODE_0100
+ * @tc.desc : Testing Set LoopMode callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONSETLOOPMODE_0100', 0, async function (done) {
+ session.on('setLoopMode', (callback) => {
+ if (callback === 1) {
+ console.info('TestLog: Set LoopMode command callback registration successful');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Set LoopMode command callback registration error');
+ expect(false).assertTrue();
+ }
+ });
+
+ await controller.sendControlCommand({
+ command: 'setLoopMode', parameter:
+ avSession.LoopMode.LOOP_MODE_SINGLE
+ }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONTOGGLEFAVORITE_0100
+ * @tc.name : ONTOGGLEFAVORITE_0100
+ * @tc.desc : Testing Set toggleFavorite callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONTOGGLEFAVORITE_0100', 0, async function (done) {
+ session.on('toggleFavorite', (callback) => {
+ if (callback === 'false') {
+ console.info('TestLog: Set toggleFavorite command callback registration successful');
+ expect(true).assertTrue();
+ }
+ else {
+ console.info('TestLog: Set toggleFavorite command callback registration error');
+ expect(false).assertTrue();
+ }
+ });
+
+ await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100
+ * @tc.name : ONHANDLEKEYEVENT_0100
+ * @tc.desc : Testing Handle KeyEvent callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100', 0, async function (done) {
+ session.on('handleKeyEvent', (callback) => {
+ if (callback.action === 2) {
+ console.info('TestLog: Handle keyEvent callback registration successful');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Handle keyEvent callback registration error');
+ expect(false).assertTrue();
+ }
+ });
+
+ await controller.sendAVKeyEvent(event).then(() => {
+ console.info('TestLog: Controller send AVKeyEvent successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send AVKeyEvent error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONWRONGCALLBACK_0100
+ * @tc.name : ONWRONGCALLBACK_0100
+ * @tc.desc : Testing wrong callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONWRONGCALLBACK_0100', 0, function (done) {
+ try {
+ session.on('wrongCall', () => {
+ console.info('TestLog: Wrong callback registration successful');
+ });
+ } catch (err) {
+ console.info(`TestLog: Wrong callback registration error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ done();
+ }
+ })
+
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100
+ * @tc.name : OFFPLAY_0100
+ * @tc.desc : Testing offPlay callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Play command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: Play command registration2 success');
+ expect(false).assertTrue();
+ }
+
+ session.on('play', callback1);
+
+ session.on('play', callback2);
+
+ session.off('play');
+
+ await controller.sendControlCommand({ command: 'play' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200
+ * @tc.name : OFFPLAY_0200
+ * @tc.desc : Testing offPlay callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Play command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: Play command registration2 success');
+ expect(true).assertTrue();
+ }
+
+ session.on('play', callback1);
+
+ session.on('play', callback2);
+
+ session.off('play', callback1);
+
+ await controller.sendControlCommand({ command: 'play' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0100
+ * @tc.name : OFFPAUSE_0100
+ * @tc.desc : Testing offPause callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0100', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Pause command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: Pause command registration2 success');
+ expect(false).assertTrue();
+ }
+
+ session.on('pause', callback1);
+
+ session.on('pause', callback2);
+
+ session.off('pause');
+
+ await controller.sendControlCommand({ command: 'pause' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0200
+ * @tc.name : OFFPAUSE_0200
+ * @tc.desc : Testing offPause callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0200', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Pause command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: Pause command registration2 success');
+ expect(true).assertTrue();
+ }
+
+ session.on('pause', callback1);
+
+ session.on('pause', callback2);
+
+ session.off('pause', callback1);
+
+ await controller.sendControlCommand({ command: 'pause' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSTOP_0100
+ * @tc.name : OFFSTOP_0100
+ * @tc.desc : Testing offStop callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFSTOP_0100', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Stop command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: Stop command registration2 success');
+ expect(false).assertTrue();
+ }
+
+ session.on('stop', callback1)
+
+ session.on('stop', callback2)
+
+ session.off('stop');
+
+ await controller.sendControlCommand({ command: 'stop' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSTOP_0200
+ * @tc.name : OFFSTOP_0200
+ * @tc.desc : Testing offStop callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFSTOP_0200', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Stop command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: Stop command registration2 success');
+ expect(true).assertTrue();
+ }
+
+ session.on('stop', callback1)
+
+ session.on('stop', callback2)
+
+ session.off('stop', callback1)
+
+ await controller.sendControlCommand({ command: 'stop' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAYNEXT_0100
+ * @tc.name : OFFPLAYNEXT_0100
+ * @tc.desc : Testing offPlayNext callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPLAYNEXT_0100', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: PlayNext command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: PlayNext command registration2 success');
+ expect(false).assertTrue();
+ }
+
+ session.on('playNext', callback1);
+
+ session.on('playNext', callback2);
+
+ session.off('playNext');
+
+ await controller.sendControlCommand({ command: 'playNext' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAYNEXT_0200
+ * @tc.name : OFFPLAYNEXT_0200
+ * @tc.desc : Testing offPlayNext callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPLAYNEXT_0200', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: PlayNext command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: PlayNext command registration2 success');
+ expect(true).assertTrue();
+ }
+
+ session.on('playNext', callback1);
+
+ session.on('playNext', callback2);
+
+ session.off('playNext', callback1);
+
+ await controller.sendControlCommand({ command: 'playNext' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAYPREVIOUS_0100
+ * @tc.name : OFFPLAYPREVIOUS_0100
+ * @tc.desc : Testing offPlayPrevious callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPLAYPREVIOUS_0100', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: PlayPrevious command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: PlayPrevious command registration2 success');
+ expect(false).assertTrue();
+ }
+
+ session.on('playPrevious', callback1);
+
+ session.on('playPrevious', callback2);
+
+ session.off('playPrevious');
+
+ await controller.sendControlCommand({ command: 'playPrevious' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAYPREVIOUS_0200
+ * @tc.name : OFFPLAYPREVIOUS_0200
+ * @tc.desc : Testing offPlayPrevious callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPLAYPREVIOUS_0200', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: PlayPrevious command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: PlayPrevious command registration2 success');
+ expect(true).assertTrue();
+ }
+
+ session.on('playPrevious', callback1);
+
+ session.on('playPrevious', callback2);
+
+ session.off('playPrevious', callback1);
+
+ await controller.sendControlCommand({ command: 'playPrevious' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFFASTFORWARD_0100
+ * @tc.name : OFFFASTFORWARD_0100
+ * @tc.desc : Testing offFastForward callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFFASTFORWARD_0100', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: FastForward command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: FastForward command registration2 success');
+ expect(false).assertTrue();
+ }
+
+ session.on('fastForward', callback1);
+
+ session.on('fastForward', callback2);
+
+ session.off('fastForward');
+
+ await controller.sendControlCommand({ command: 'fastForward' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFFASTFORWARD_0200
+ * @tc.name : OFFFASTFORWARD_0200
+ * @tc.desc : Testing offFastForward callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFFASTFORWARD_0200', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: FastForward command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: FastForward command registration2 success');
+ expect(true).assertTrue();
+ }
+
+ session.on('fastForward', callback1);
+
+ session.on('fastForward', callback2);
+
+ session.off('fastForward', callback1);
+
+ await controller.sendControlCommand({ command: 'fastForward' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFREWIND_0100
+ * @tc.name : OFFREWIND_0100
+ * @tc.desc : Testing offRewind callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFREWIND_0100', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Rewind command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: Rewind command registration2 success');
+ expect(false).assertTrue();
+ }
+
+ session.on('rewind', callback1);
+
+ session.on('rewind', callback2);
+
+ session.off('rewind');
+
+ await controller.sendControlCommand({ command: 'rewind' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFREWIND_0200
+ * @tc.name : OFFREWIND_0200
+ * @tc.desc : Testing offRewind callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFREWIND_0200', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Rewind command registration1 success');
+ expect(false).assertTrue();
+ }
+
+ function callback2() {
+ console.info('TestLog: Rewind command registration2 success');
+ expect(true).assertTrue();
+ }
+
+ session.on('rewind', callback1);
+
+ session.on('rewind', callback2);
+
+ session.off('rewind', callback1);
+
+ await controller.sendControlCommand({ command: 'rewind' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSEEK_0100
+ * @tc.name : OFFSEEK_0100
+ * @tc.desc : Testing offSeek callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFSEEK_0100', 0, async function (done) {
+ function callback1(data) {
+ if (data === 5) {
+ console.info('TestLog: offSeek callback1 registration');
+ expect(false).assertTrue;
+ }
+ }
+
+ function callback2(data) {
+ if (data === 10) {
+ console.info('TestLog: offSeek callback2 registration');
+ expect(false).assertTrue;
+ }
+ }
+
+ session.on('seek', callback1);
+
+ session.on('seek', callback2);
+
+ session.off('seek');
+
+ await controller.sendControlCommand({ command: 'seek', parameter: 10 }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSEEK_0200
+ * @tc.name : OFFSEEK_0200
+ * @tc.desc : Testing offSeek callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFSEEK_0200', 0, async function (done) {
+ function callback1(data) {
+ if (data === 5) {
+ console.info('TestLog: offSeek callback1 registration');
+ expect(false).assertTrue;
+ }
+ }
+
+ function callback2(data) {
+ if (data === 10) {
+ console.info('TestLog: offSeek callback2 registration');
+ expect(true).assertTrue;
+ }
+ }
+
+ session.on('seek', callback1);
+
+ session.on('seek', callback2);
+
+ session.off('seek', callback1);
+
+ await controller.sendControlCommand({ command: 'seek', parameter: 10 }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSETSPEED_0100
+ * @tc.name : OFFSETSPEED_0100
+ * @tc.desc : Testing offSetSpeed callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFSETSPEED_0100', 0, async function (done) {
+ function callback1(data) {
+ if (data === 1.0) {
+ console.info('TestLog: SetSpend command registration1 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ function callback2(data) {
+ if (data === 2.0) {
+ console.info('TestLog: SetSpend command registration2 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ session.on('setSpeed', callback1);
+
+ session.on('setSpeed', callback2);
+
+ session.off('setSpeed');
+
+ await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.0 }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSETSPEED_0200
+ * @tc.name : OFFSETSPEED_0200
+ * @tc.desc : Testing offSetSpeed callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFSETSPEED_0200', 0, async function (done) {
+ function callback1(data) {
+ if (data === 1.0) {
+ console.info('TestLog: SetSpend command registration1 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ function callback2(data) {
+ if (data === 2.0) {
+ console.info('TestLog: SetSpend command registration2 success');
+ expect(true).assertTrue;
+ }
+ }
+
+ session.on('setSpeed', callback1);
+
+ session.on('setSpeed', callback2);
+
+ session.off('setSpeed', callback1);
+
+ await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.0 }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSETLOOPMODE_0100
+ * @tc.name : OFFSETLOOPMODE_0100
+ * @tc.desc : Testing offSetLoopMode callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFSETLOOPMODE_0100', 0, async function (done) {
+ function callback1(data) {
+ if (data === 1) {
+ console.info('TestLog: SetLoopMode command registration1 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ function callback2(data) {
+ if (data === 2) {
+ console.info('TestLog: SetLoopMode command registration2 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ session.on('setLoopMode', callback1);
+
+ session.on('setLoopMode', callback2);
+
+ session.off('setLoopMode');
+
+ await controller.sendControlCommand({
+ command: 'setLoopMode',
+ parameter: avSession.LoopMode.LOOP_MODE_SINGLE
+ }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSETLOOPMODE_0200
+ * @tc.name : OFFSETLOOPMODE_0200
+ * @tc.desc : Testing offSetLoopMode callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFSETLOOPMODE_0200', 0, async function (done) {
+ function callback1(data) {
+ if (data === 2) {
+ console.info('TestLog: SetLoopMode command registration1 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ function callback2(data) {
+ if (data === 1) {
+ console.info('TestLog: SetLoopMode command registration2 success');
+ expect(true).assertTrue;
+ }
+ }
+
+ session.on('setLoopMode', callback1);
+
+ session.on('setLoopMode', callback2);
+
+ session.off('setLoopMode', callback1);
+
+ await controller.sendControlCommand({
+ command: 'setLoopMode',
+ parameter: avSession.LoopMode.LOOP_MODE_SINGLE
+ }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFTOGGLEFAVORITE_0100
+ * @tc.name : OFFTOGGLEFAVORITE_0100
+ * @tc.desc : Testing offToggleFavorite callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFTOGGLEFAVORITE_0100', 0, async function (done) {
+ function callback1(data) {
+ if (data === 'true') {
+ console.info('TestLog: ToggleFavorite command registration1 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ function callback2(data) {
+ if (data === 'false') {
+ console.info('TestLog: ToggleFavorite command registration1 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ session.on('toggleFavorite', callback1);
+
+ session.on('toggleFavorite', callback2);
+
+ session.off('toggleFavorite');
+
+ await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFTOGGLEFAVORITE_0200
+ * @tc.name : OFFTOGGLEFAVORITE_0200
+ * @tc.desc : Testing offToggleFavorite callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFTOGGLEFAVORITE_0200', 0, async function (done) {
+ function callback1(data) {
+ if (data === 'true') {
+ console.info('TestLog: ToggleFavorite command registration1 success');
+ expect(false).assertTrue;
+ }
+ }
+
+ function callback2(data) {
+ if (data === 'false') {
+ console.info('TestLog: ToggleFavorite command registration2 success');
+ expect(true).assertTrue;
+ }
+ }
+
+ session.on('toggleFavorite', callback1);
+
+ session.on('toggleFavorite', callback2);
+
+ session.off('toggleFavorite', callback1);
+
+ await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFHANDLEKEYEVENT_0100
+ * @tc.name : OFFHANDLEKEYEVENT_0100
+ * @tc.desc : Testing offHandleKeyEvent callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFHANDLEKEYEVENT_0100', 0, async function (done) {
+ let flag = true;
+ function callback1(data) {
+ if (data.action === 1) {
+ console.info('TestLog: HandleKeyEvent command registration1 success');
+ flag = false;
+ }
+ }
+
+ function callback2(data) {
+ if (data.action === 2) {
+ console.info('TestLog: HandleKeyEvent command registration2 success');
+ flag = false;
+ }
+ }
+
+ session.on('handleKeyEvent', callback1);
+
+ session.on('handleKeyEvent', callback2);
+
+ session.off('handleKeyEvent');
+
+ await controller.sendAVKeyEvent(event).then(() => {
+ console.info('TestLog: Controller send AVKeyEvent successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send AVKeyEvent error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+
+ if (flag) {
+ console.info('TestLog: HandleKeyEvent command callback unRegistration successful');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: HandleKeyEvent command callback unRegistration failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFHANDLEKEYEVENT_0200
+ * @tc.name : OFFHANDLEKEYEVENT_0200
+ * @tc.desc : Testing offHandleKeyEvent callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFHANDLEKEYEVENT_0200', 0, async function (done) {
+ function callback1(data) {
+ if (data.action === 1) {
+ console.info('TestLog: HandleKeyEvent command registration1 success');
+ expect(false).assertTrue();
+ }
+ }
+
+ function callback2(data) {
+ if (data.action === 2) {
+ console.info('TestLog: HandleKeyEvent command registration2 success');
+ expect(true).assertTrue();
+ }
+ }
+
+ session.on('handleKeyEvent', callback1);
+
+ session.on('handleKeyEvent', callback2);
+
+ session.off('handleKeyEvent', callback1);
+
+ await controller.sendAVKeyEvent(event).then(() => {
+ console.info('TestLog: Controller send AVKeyEvent successfully');
+ }).catch((err) => {
+ console.info(`TestLog: Controller send AVKeyEvent error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100
+ * @tc.name : GETOUTPUTDEVICE_PROMISE_0100
+ * @tc.desc : Testing get output device
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100', 0, async function (done) {
+ session.on('outputDeviceChange', (callback) => {
+ if (!callback.isRemote) {
+ console.info(callback.audioDeviceId.size);
+ console.info(callback.deviceName.size);
+ console.info('outputDeviceChange callback registration successful');
+ expect(true).assertTrue();
+ } else {
+ console.info('outputDeviceChange callback registration fail');
+ expect(false).assertTrue();
+ }
+ });
+
+ session.off('outputDeviceChange');
+
+ await session.getOutputDevice().then((data) => {
+ if (!data.isRemote) {
+ expect(true).assertTrue();
+ } else {
+ console.info(avSession.OutputDeviceInfo.isRemote);
+ console.info(avSession.OutputDeviceInfo.audioDeviceId.size);
+ console.info(avSession.OutputDeviceInfo.deviceName.size);
+ console.info('getOutputDevice successfully');
+ console.info('Get device information failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`Get device BusinessError: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ })
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100
+ * @tc.name : GETOUTPUTDEVICE_CALLBACK_0100
+ * @tc.desc : Testing get output device
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100', 0, async function (done) {
+ session.getOutputDevice((err, value) => {
+ if (err) {
+ console.info(`Get device information BusinessError: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (!value.isRemote) {
+ console.info('Get device information successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('Get device information failed');
+ expect(false).assertTrue();
+ }
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100
+ * @tc.name : GETCONTROLLER_PROMISE_0100
+ * @tc.desc : Testing get controller
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100', 0, async function (done) {
+ await session.getController().then((data) => {
+ console.info('Get controller successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info('Get controller failed');
+ console.info(`Get controller BusinessError: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_CALLBACK_0100
+ * @tc.name : GETCONTROLLER_CALLBACK_0100
+ * @tc.desc : Testing get controller
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_CALLBACK_0100', 0, async function (done) {
+ session.getController((err, data) => {
+ if (err) {
+ console.info('Get controller failed');
+ expect(false).assertTrue();
+ } else {
+ console.info('Get controller successfully');
+ expect(true).assertTrue();
+ }
+ })
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_CALLBACK_0100
+ * @tc.name : SENDAVKEYEVENT_CALLBACK_0100
+ * @tc.desc : Testing set key event
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_CALLBACK_0100', 0, async function (done) {
+ let keyItem = {code: 0x49, pressedTime: 123456789, deviceId: 0};
+ let event = {action: 2, key: keyItem, keys: [keyItem]};
+ try {
+ controller.sendAVKeyEvent(event, (err, data) => {
+ if (err) {
+ console.info(`TestLog: sendAVKeyEvent error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('sendAVKeyEvent Successfully');
+ expect(true).assertTrue();
+ }
+ })
+ } catch (err) {
+ console.info(`TestLog: sendAVKeyEvent error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_PROMISE_0100
+ * @tc.name : SENDAVKEYEVENT_PROMISE_0100
+ * @tc.desc : Testing set key event
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_PROMISE_0100', 0, async function (done) {
+ let keyItem = {code: 0x49, pressedTime: 123456789, deviceId: 0};
+ let event = {action: 2, key: keyItem, keys: [keyItem]};
+ await controller.sendAVKeyEvent(event).then(() => {
+ console.info('sendAVKeyEvent Successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: sendAVKeyEvent error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETREALPLAYBACKPOSITIONSYNC_0100
+ * @tc.name : GETREALPLAYBACKPOSITIONSYNC_0100
+ * @tc.desc : Testing get real playback position
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_GETREALPLAYBACKPOSITIONSYNC_0100', 0, async function (done) {
+ let realPosition = -1;
+ try {
+ realPosition= controller.getRealPlaybackPositionSync();
+ } catch (err) {
+ console.info(`TestLog: getRealPlaybackPositionSync error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ if (realPosition < 0) {
+ console.info(`TestLog: getRealPlaybackPositionSync error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info(`TestLog: getRealPlaybackPositionSync Successfully, positon: ${realPosition}`);
+ expect(true).assertTrue();
+ }
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETVALIDCOMMANDS_PROMISE_0100
+ * @tc.name : GETVALIDCOMMANDS_PROMISE_0100
+ * @tc.desc : Testing get valid commands - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_GETVALIDCOMMANDS_PROMISE_0100', 0, async function (done) {
+ await controller.getValidCommands().then((data) => {
+ console.info(`TestLog: getValidCommands Successfully, the length ${data.length}`);
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.info(`TestLog: getValidCommands error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETVALIDCOMMANDS_CALLBACK_0100
+ * @tc.name : GETVALIDCOMMANDS_CALLBACK_0100
+ * @tc.desc : Testing get valid commands - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_GETVALIDCOMMANDS_CALLBACK_0100', 0, async function (done) {
+ try {
+ controller.getValidCommands((err, data) => {
+ if (err) {
+ console.info(`TestLog: getValidCommands error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info(`TestLog: getValidCommands Successfully, the length ${data.length}`);
+ expect(true).assertTrue();
+ }
+ })
+ } catch (err) {
+ console.info(`TestLog: getValidCommands error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ }
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionCallback.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionCallback.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..78a80b093ae28c0cd8777ec9ec7f33c925a55465
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionCallback.test.js
@@ -0,0 +1,1243 @@
+/*
+ * Copyright (c) 2022 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 avSession from '@ohos.multimedia.avsession';
+import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from '@ohos/hypium';
+import image from '@ohos.multimedia.image';
+import WantAgent from '@ohos.wantAgent';
+import featureAbility from '@ohos.ability.featureAbility';
+
+export default function AVSessionCallback() {
+ describe('AVSessionCallback', function () {
+ let tag = 'ApplicationA';
+ let type = 'audio';
+ let session;
+ let controller;
+ let context = featureAbility.getContext();
+
+ function sleep (ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+ }
+
+ async function getPixelMap() {
+ let color = new ArrayBuffer(96);
+ let bufferArr = new Uint8Array(color);
+ bufferArr.fill('3', 0, 95);
+ let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, AlphaType: 3};
+ return image.createPixelMap(color, opts);
+ }
+
+ beforeAll(function () {
+ console.info('TestLog: Start Testing AVSession Interfaces');
+ })
+
+ beforeEach(async function () {
+ console.info('TestLog: Init Session And Controller');
+ await avSession.createAVSession(context, tag, type).then((data) => {
+ session = data;
+ }).catch((err) => {
+ console.info(`TestLog: Session created error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await session.activate().then(() => {
+ console.info('TestLog: Session activate');
+ }).catch((err) => {
+ console.info(`TestLog: Session activate error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ controller = await session.getController();
+ })
+
+ afterEach(async function (done) {
+ console.info('TestLog: Destroy Session And Controller');
+ await session.destroy().then(() => {
+ console.info('TestLog: Session Destroy SUCCESS');
+ }).catch((err) => {
+ console.info(`TestLog: Session Destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await controller.destroy().then(() => {
+ console.info('TestLog: Controller Destroy SUCCESS');
+ }).catch((err) => {
+ console.info(`TestLog: Controller Destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ afterAll(function () {
+ console.info('TestLog: End Testing AVSession Interfaces');
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0100
+ * @tc.name : SETMETADATA_0100
+ * @tc.desc : Testing set assetId - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0100', 0, async function (done) {
+ let metadata0 = {
+ assetId: '121278',
+ };
+
+ session.setAVMetadata(metadata0, (err) => {
+ if (err) {
+ console.info(`TestLog: Set assetId error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ });
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get assetId error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.assetId === metadata0.assetId) {
+ console.info('TestLog: Get assetId Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get assetId failed: ${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0200
+ * @tc.name : SETMETADATA_0200
+ * @tc.desc : Testing set artist - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0200', 0, async function (done) {
+ let metadata1 = {
+ assetId: '121278',
+ artist: 'Eminem',
+ };
+ session.setAVMetadata(metadata1, (err) => {
+ if (err) {
+ console.info(`TestLog: Set artist error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ });
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get artist error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.artist === metadata1.artist) {
+ console.info('TestLog: Get artist Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get artist failed' ${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0300
+ * @tc.name : SETMETADATA_0300
+ * @tc.desc : Testing set author - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0300', 0, async function (done) {
+ let metadata2 = {
+ assetId: '121278',
+ author: 'ST',
+ };
+ session.setAVMetadata(metadata2, (err) => {
+ if (err) {
+ console.info(`TestLog: Set author error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get author error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.author === metadata2.author) {
+ console.info('TestLog: Get author Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get author failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0400
+ * @tc.name : SETMETADATA_0400
+ * @tc.desc : Testing set album - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0400', 0, async function (done) {
+ let metadata3 = {
+ assetId: '121278',
+ album: 'Slim shady',
+ };
+ session.setAVMetadata(metadata3, (err) => {
+ if (err) {
+ console.info(`TestLog: Set album error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get album error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.album === metadata3.album) {
+ console.info('TestLog: Get album Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get album failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0500
+ * @tc.name : SETMETADATA_0500
+ * @tc.desc : Testing set writer - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0500', 0, async function (done) {
+ let metadata4 = {
+ assetId: '121278',
+ writer: 'ST',
+ };
+ session.setAVMetadata(metadata4, (err) => {
+ if (err) {
+ console.info(`TestLog: Set writer error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get writer error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.writer === metadata4.writer) {
+ console.info('TestLog: Get writer Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get writer failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0600
+ * @tc.name : SETMETADATA_0600
+ * @tc.desc : Testing set composer - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0600', 0, async function (done) {
+ let metadata5 = {
+ assetId: '121278',
+ composer: 'ST',
+ };
+ session.setAVMetadata(metadata5, (err) => {
+ if (err) {
+ console.info(`TestLog: Set composer error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get composer error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.composer === metadata5.composer) {
+ console.info('TestLog: Get composer Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get composer failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0700
+ * @tc.name : SETMETADATA_0700
+ * @tc.desc : Testing set duration - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0700', 0, async function (done) {
+ let metadata6 = {
+ assetId: '121278',
+ duration: 2222,
+ };
+ session.setAVMetadata(metadata6, (err) => {
+ if (err) {
+ console.info(`TestLog: Set duration error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get duration error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.duration === metadata6.duration) {
+ console.info('TestLog: Get duration Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get duration failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0800
+ * @tc.name : SETMETADATA_0800
+ * @tc.desc : Testing set mediaImage - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0800', 0, async function (done) {
+ let metadata7 = {
+ assetId: '121278',
+ mediaImage: 'https://img2.baidu.com/it/u=3583435814,2833583486&fm=253&fmt=auto&app=138&f=JPEG?w=526&h=500',
+ };
+ session.setAVMetadata(metadata7, (err) => {
+ if (err) {
+ console.info(`TestLog: Set mediaImage error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get mediaImage error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.mediaImage === metadata7.mediaImage) {
+ console.info('TestLog: Get mediaImage Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get mediaImage failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0900
+ * @tc.name : SETMETADATA_0900
+ * @tc.desc : Testing set mediaImage - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_0900', 0, async function (done) {
+ console.info('TestLog: Create pixelmap');
+ let pixelMap = await getPixelMap();
+ let readBuffer0 = new ArrayBuffer(96);
+ await pixelMap.readPixelsToBuffer(readBuffer0);
+ let bufferArr0 = new Uint8Array(readBuffer0);
+ let metadata8 = {
+ assetId: '121278',
+ mediaImage: pixelMap,
+ };
+ session.setAVMetadata(metadata8, (err) => {
+ if (err) {
+ console.info(`TestLog: Set pixelMap error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ let pixMap;
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get pixelMap error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.assetId === metadata8.assetId) {
+ console.info('TestLog: Get pixelMap Successfully');
+ pixMap = value.mediaImage;
+ } else {
+ console.info(`TestLog: Get pixelMap failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ let pixelSize = pixMap.getPixelBytesNumber();
+ console.info(`TestLog: pixelSize is:${pixelSize}`);
+ let readBuffer = new ArrayBuffer(pixelSize);
+ pixMap.readPixelsToBuffer(readBuffer);
+ await sleep(500);
+ let bufferArr2 = new Uint8Array(readBuffer);
+ for (let i = 0; i < bufferArr2.length; i++) {
+ if (bufferArr0[i] !== bufferArr2[i]) {
+ expect(false).assertTrue();
+ } else {
+ expect(true).assertTrue();
+ }
+ }
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1000
+ * @tc.name : SETMETADATA_1000
+ * @tc.desc : Testing set publishDate - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1000', 0, async function (done) {
+ let metadata9 = {
+ assetId: '121278',
+ publishDate: new Date(1994,1,1,1),
+ };
+ session.setAVMetadata(metadata9, (err) => {
+ if (err) {
+ console.info(`TestLog: Set publishDate error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set publishDate : successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get publishDate error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.publishDate.getTime() === metadata9.publishDate.getTime()) {
+ console.info('TestLog: Get publishDate Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get publishDate failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1100
+ * @tc.name : SETMETADATA_1100
+ * @tc.desc : Testing set subtitle - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1100', 0, async function (done) {
+ let metadata10 = {
+ assetId: '121278',
+ subtitle: '8 Mile',
+ };
+
+ session.setAVMetadata(metadata10, (err) => {
+ if (err) {
+ console.info(`TestLog: Set subtitle error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set subtitle successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get subtitle error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.subtitle === metadata10.subtitle) {
+ console.info('TestLog: Get subtitle Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get subtitle failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1200
+ * @tc.name : SETMETADATA_1200
+ * @tc.desc : Testing set description - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1200', 0, async function (done) {
+ let metadata11 = {
+ assetId: '121278',
+ description: 'Rap',
+ };
+ session.setAVMetadata(metadata11, (err) => {
+ if (err) {
+ console.info(`TestLog: Set description error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get description error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.description === metadata11.description) {
+ console.info('TestLog: Get description Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get description failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1300
+ * @tc.name : SETMETADATA_1300
+ * @tc.desc : Testing set lyric - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1300', 0, async function (done) {
+ let metadata12 = {
+ assetId: '121278',
+ lyric: 'https://lyric.tingmall.com/lyric/58/970/58970104-LRC-LRC.lrc?t=1649918948000',
+ };
+
+ session.setAVMetadata(metadata12, (err) => {
+ if (err) {
+ console.info(`TestLog: Set lyric error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get lyric error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.lyric === metadata12.lyric) {
+ console.info('TestLog: Get lyric Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get lyric failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1400
+ * @tc.name : SETMETADATA_1400
+ * @tc.desc : Testing set assetId - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1400', 0, async function (done) {
+ let metadata13 = {
+ assetId: '121278',
+ previousAssetId: '121277',
+ nextAssetId: '121279',
+ };
+
+ session.setAVMetadata(metadata13, (err) => {
+ if (err) {
+ console.info(`TestLog: Set assetId error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ })
+ await sleep(500);
+ controller.getAVMetadata((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get assetId error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value.previousAssetId === metadata13.previousAssetId
+ && value.nextAssetId === metadata13.nextAssetId) {
+ console.info('TestLog: Get assetId Successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: Get assetId failed:${value}`);
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1500
+ * @tc.name : SETMETADATA_1500
+ * @tc.desc : Testing set metadata - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1500', 0, async function (done) {
+ let metadata14 = {
+ assetId: '121278',
+ };
+ session.destroy((err) => {
+ if (err) {
+ console.info('TestLog: session destroy failed');
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: session destroy successfully');
+ }
+ });
+ await sleep(500);
+ session.setAVMetadata(metadata14, (err) => {
+ if (err) {
+ console.info(`TestLog: Set metadata error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Set metadata : successfully');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1600
+ * @tc.name : SETMETADATA_1600
+ * @tc.desc : Testing set error metadata - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETMETADATA_CALLBACK_1600', 0, async function (done) {
+ let metadata15 = {
+ assetId: '121278',
+ duration: -2,
+ };
+
+ session.setAVMetadata(metadata15, (err) => {
+ if (err) {
+ console.info(`TestLog: Set duration error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Set duration : successfully');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0100
+ * @tc.name : SETAVPLAYBACKSTATE_0100
+ * @tc.desc : Testing set playbackstate - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0100', 0, async function (done) {
+ let PlaybackState1 = {
+ state:avSession.PlaybackState.PLAYBACK_STATE_PLAY,
+ };
+ session.setAVPlaybackState(PlaybackState1, (err) => {
+ if (err) {
+ console.info(`TestLog: Set State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set State successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.state === 2) {
+ console.info('TestLog: Get State successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get State failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0200
+ * @tc.name : SETAVPLAYBACKSTATE_0200
+ * @tc.desc : Testing set speed - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0200', 0, async function (done) {
+ let PlaybackState2 = {
+ speed: 2.6,
+ };
+
+ session.setAVPlaybackState(PlaybackState2, (err) => {
+ if (err) {
+ console.info(`TestLog: Set speed error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set speed successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get speed error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.speed === 2.6) {
+ console.info('TestLog: Get speed successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get speed failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0300
+ * @tc.name : SETAVPLAYBACKSTATE_0300
+ * @tc.desc : Testing set position - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0300', 0, async function (done) {
+ let PlaybackState3 = {
+ position:{elapsedTime:10, updateTime:(new Date()).getTime()},
+ };
+
+ session.setAVPlaybackState(PlaybackState3, (err) => {
+ if (err) {
+ console.info(`TestLog: Set position error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set position successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get position error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.position.elapsedTime === 10) {
+ console.info('TestLog: Get position successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get position failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0400
+ * @tc.name : SETAVPLAYBACKSTATE_0400
+ * @tc.desc : Testing set bufferedTime - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0400', 0, async function (done) {
+ let PlaybackState4 = {
+ bufferedTime: 1000,
+ };
+
+ session.setAVPlaybackState(PlaybackState4, (err) => {
+ if (err) {
+ console.info(`TestLog: Set bufferedTime error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set bufferedTime successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get bufferedTime error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.bufferedTime === 1000) {
+ console.info('TestLog: Get bufferedTime successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get bufferedTime failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0500
+ * @tc.name : SETAVPLAYBACKSTATE_0500
+ * @tc.desc : Testing set loopMode - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0500', 0, async function (done) {
+ let PlaybackState5 = {
+ loopMode:avSession.LoopMode.LOOP_MODE_SEQUENCE,
+ };
+
+ session.setAVPlaybackState(PlaybackState5, (err) => {
+ if (err) {
+ console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set loopMode successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.loopMode === 0) {
+ console.info('TestLog: Get loopMode successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get loopMode failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(1000);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0600
+ * @tc.name : SETAVPLAYBACKSTATE_0600
+ * @tc.desc : Testing set loopMode - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0600', 0, async function (done) {
+ let PlaybackState6 = {
+ loopMode:avSession.LoopMode.LOOP_MODE_SINGLE,
+ };
+
+ session.setAVPlaybackState(PlaybackState6, (err) => {
+ if (err) {
+ console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set loopMode successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.loopMode === 1) {
+ console.info('TestLog: Get loopMode successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get loopMode failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(1000);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0700
+ * @tc.name : SETAVPLAYBACKSTATE_0700
+ * @tc.desc : Testing set loopMode - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0700', 0, async function (done) {
+ let PlaybackState7 = {
+ loopMode:avSession.LoopMode.LOOP_MODE_LIST,
+ };
+
+ session.setAVPlaybackState(PlaybackState7, (err) => {
+ if (err) {
+ console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set loopMode successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.loopMode === 2) {
+ console.info('TestLog: Get loopMode successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get loopMode failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(1000);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0800
+ * @tc.name : SETAVPLAYBACKSTATE_0800
+ * @tc.desc : Testing set loopMode - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0800', 0, async function (done) {
+ let PlaybackState8 = {
+ loopMode:avSession.LoopMode.LOOP_MODE_SHUFFLE,
+ };
+
+ session.setAVPlaybackState(PlaybackState8, (err) => {
+ if (err) {
+ console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set loopMode successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.loopMode === 3) {
+ console.info('TestLog: Get loopMode successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get loopMode failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(1000);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0900
+ * @tc.name : SETAVPLAYBACKSTATE_0900
+ * @tc.desc : Testing set isFavorite - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_0900', 0, async function (done) {
+ let PlaybackState9 = {
+ isFavorite:true,
+ };
+
+ session.setAVPlaybackState(PlaybackState9, (err) => {
+ if (err) {
+ console.info(`TestLog: Set isFavorite error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set isFavorite successfully');
+ }
+ })
+ await sleep(500);
+ controller.getAVPlaybackState((err, value) => {
+ if (err) {
+ console.info(`TestLog: Get isFavorite error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }else if (value.isFavorite === true) {
+ console.info('TestLog: Get isFavorite successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Get isFavorite failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(1000);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_1000
+ * @tc.name : SETAVPLAYBACKSTATE_1000
+ * @tc.desc : Testing set playbackstate - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_1000', 0, async function (done) {
+ let PlaybackState10 = {
+ state:avSession.PlaybackState.PLAYBACK_STATE_PLAY,
+ speed: 1.0,
+ position:{elapsedTime:10, updateTime:(new Date()).getTime()},
+ bufferedTime:1000,
+ loopMode:avSession.LoopMode.LOOP_MODE_SINGLE,
+ isFavorite:true,
+ };
+ session.destroy((err) => {
+ if (err) {
+ console.info(`TestLog: session destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ }
+ });
+ await sleep(500);
+ session.setAVPlaybackState(PlaybackState10, (err) => {
+ if (err) {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Set playbackState successfully');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_1100
+ * @tc.name : SETAVPLAYBACKSTATE_1100
+ * @tc.desc : Testing set playbackstate - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_CALLBACK_1100', 0, async function (done) {
+ let PlaybackState11 = {
+ state:avSession.PlaybackState.PLAYBACK_STATE_PLAY,
+ speed: -2,
+ position:{elapsedTime:-2, updateTime:(new Date()).getTime()},
+ bufferedTime:-4,
+ loopMode:avSession.LoopMode.LOOP_MODE_SINGLE,
+ isFavorite:true,
+ };
+ session.setAVPlaybackState(PlaybackState11, (err) => {
+ if (err) {
+ console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Set playbackState successfully');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_CALLBACK_0100
+ * @tc.name : SETLAUNCHABILITY_0100
+ * @tc.desc : Testing set LaunchAbility - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_CALLBACK_0100', 0, async function(done) {
+ let wantAgentInfo = {
+ wants : [
+ {
+ bundleName : 'com.example.myapplication',
+ abilityName: 'com.example.myapplication.MainAbility'
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags: [WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+ };
+ let agent;
+ await WantAgent.getWantAgent(wantAgentInfo).then((callback) => {
+ agent = callback;
+ });
+
+ session.setLaunchAbility(agent, (err) => {
+ if (err) {
+ console.info(`TestLog: Set launchAbility error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Set launchAbility successfully');
+ }
+ });
+
+ await sleep(500);
+ let wantagent;
+ controller.getLaunchAbility((err, value) => {
+ if (err) {
+ console.info(`TestLog: error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Get launchAbility');
+ wantagent = value;
+ }
+ });
+ await sleep(500);
+ await WantAgent.equal(agent, wantagent).then((bool) => {
+ if (bool) {
+ console.info('AVSessionTest : Set LaunchAbility successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('AVSessionTest : Set LaunchAbility failed');
+ expect(false).assertTrue();
+ }
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_CALLBACK_0100
+ * @tc.name : SESSIONACTIVATE_0100
+ * @tc.desc : Testing set session active - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_CALLBACK_0100', 0, async function (done) {
+ controller.isActive((err, value) => {
+ if (err) {
+ console.info(`TestLog: error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value) {
+ console.info('TestLog: session is active');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: session is directive');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_CALLBACK_0100
+ * @tc.name : SESSIONDEACTIVATE_0100
+ * @tc.desc : Testing deactivate session- callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_CALLBACK_0100', 0, async function (done) {
+ session.deactivate((err) => {
+ if (err) {
+ console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Deactivate session');
+ }
+
+ });
+ await sleep(500);
+
+ await controller.isActive((err, value) => {
+ if (err) {
+ console.info(`TestLog: error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else if (value === false) {
+ console.info('TestLog: session deactivate successfully');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: session deactivate failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ await sleep(500);
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONDESTROY_CALLBACK_0100
+ * @tc.name : SESSIONDESTROY_0100
+ * @tc.desc : Testing destroy session - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SESSIONDESTROY_CALLBACK_0100', 0, async function (done) {
+ let flag = false;
+ controller.on('sessionDestroy', () => {
+ console.info('TestLog: Session destroyed successfully');
+ flag = true;
+ });
+
+ session.destroy((err) => {
+ if (err) {
+ console.info(`TestLog: Session destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ } else {
+ console.info('TestLog: Session destroy');
+ }
+ });
+
+ await sleep(500);
+
+ if (flag) {
+ console.info('TestLog: Session destroyed successful');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Session destroyed failed');
+ expect(false).assertTrue();
+ }
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionControllerJSTest.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionControllerJSTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..2cd894f0ba43c350c7fc65e0d43426e7c6bff86e
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionControllerJSTest.js
@@ -0,0 +1,1483 @@
+/*
+ * Copyright (c) 2023 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 avSession from '@ohos.multimedia.avsession';
+import featureAbility from '@ohos.ability.featureAbility';
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
+
+
+const TAG = "[AVSessionControllerJSTest]";
+export default function AVSessionControllerJsTest() {
+ describe("AVSessionControllerJsTest", function () {
+ let session = null;
+ let controller = null;
+ let receivedCallback = false;
+ let receivedCallback2 = false;
+ let receivedString = null;
+ let receivedString2 = null;
+ let receivedParam = null;
+ let receivedParam2 = null;
+ let receivedExtras = null;
+ let receivedExtras2 = null;
+ const INVALID_STRING = "invalid string";
+ const UPDATE_LYRICS_EVENT = "dynamic_lyrics";
+ const UPDATE_LYRICS_WANT_PARAMS = {
+ lyrics: "This is my lyrics"
+ };
+ const COMMON_COMMAND_STRING = "common_command";
+ const COMMON_COMMAND_PARAMS = {
+ command: "This is my command"
+ };
+ const CUSTOM_EXTRAS = {
+ extrasKey: "This is custom media packet"
+ };
+ const QUEUE_ITEM_ID = 666;
+ const QUEUE_ITEM_LENGTH = 1;
+ const QUEUE_ITEM_KEY_WORD = "QUEUE_ITEM_RELATE";
+ const EXTRAS = {
+ "items_author": "name"
+ };
+ const QUEUE_ITEM_DESCRIPTION = {
+ mediaId: QUEUE_ITEM_KEY_WORD,
+ title: QUEUE_ITEM_KEY_WORD,
+ extras: EXTRAS,
+ };
+ const QUEUE_ITEM = {
+ itemId: QUEUE_ITEM_ID,
+ description: QUEUE_ITEM_DESCRIPTION
+ }
+ const ITEMS_ARRAY = [QUEUE_ITEM];
+ const QUEUE_TITLE = "title";
+ const SKIP_ITEM_ID = 200;
+
+ beforeAll(async function () {
+ session = await avSession.createAVSession(featureAbility.getContext(), "AVSessionDemo", 'audio').catch((err) => {
+ console.error(TAG + "Create AVSession error " + JSON.stringify(err));
+ expect().assertFail();
+ });
+ session.activate();
+
+ controller = await session.getController();
+
+ console.info(TAG + "Create session and controller finished, beforeAll called");
+ })
+
+ afterAll(function () {
+ controller.destroy();
+ session.destroy();
+ console.info(TAG + 'afterAll called');
+ })
+
+ beforeEach(function () {
+ console.info(TAG + 'beforeEach called');
+ })
+
+ afterEach(function () {
+ console.info(TAG + 'afterEach called');
+ })
+
+ function sleep(time) {
+ return new Promise((resolve) => setTimeout(resolve, time));
+ }
+
+ function dynamicLyricsCallback1(sessionEvent, args) {
+ console.log(TAG + "Callback1 received event: " + JSON.stringify(sessionEvent));
+ console.log(TAG + "Callback1 received args: " + JSON.stringify(args));
+ if (sessionEvent != UPDATE_LYRICS_EVENT) {
+ console.error(TAG + "Callback1 lyrics event unmatch");
+ expect().assertFail();
+ }
+ receivedCallback = true;
+ receivedString = sessionEvent;
+ receivedParam = args;
+ }
+
+ function dynamicLyricsCallback2(sessionEvent, args) {
+ console.log(TAG + "Callback2 received event: " + JSON.stringify(sessionEvent));
+ console.log(TAG + "Callback2 received args: " + JSON.stringify(args));
+ if (sessionEvent != UPDATE_LYRICS_EVENT) {
+ console.error(TAG + "Callback2 lyrics event unmatch");
+ expect().assertFail();
+ }
+ receivedCallback2 = true;
+ receivedString2 = sessionEvent;
+ receivedParam2 = args;
+ }
+
+ function extrasChangeCallback1(extras) {
+ console.log(TAG + "Callback1 received args: " + JSON.stringify(extras));
+ if (extras.extrasKey != CUSTOM_EXTRAS.extrasKey) {
+ console.error(TAG + "Callback1 extras unmatch");
+ expect().assertFail();
+ }
+ receivedCallback = true;
+ receivedExtras = extras;
+ }
+
+ function extrasChangeCallback2(extras) {
+ console.log(TAG + "Callback2 received args: " + JSON.stringify(extras));
+ if (extras.extrasKey != CUSTOM_EXTRAS.extrasKey) {
+ console.error(TAG + "Callback2 extras unmatch");
+ expect().assertFail();
+ }
+ receivedCallback2 = true;
+ receivedExtras2 = extras;
+ }
+
+ function queueTitleCallback1(title) {
+ console.log(TAG + "queueTitleCallback1 received Title " + JSON.stringify(title));
+ if (title != QUEUE_TITLE) {
+ console.error(TAG + "queueTitleCallback1 received Title unmatch");
+ expect().assertFail();
+ }
+ receivedCallback = true;
+ }
+
+ function queueTitleCallback2(title) {
+ console.log(TAG + "queueTitleCallback2 received Title " + JSON.stringify(title));
+ if (title != QUEUE_TITLE) {
+ console.error(TAG + "queueTitleCallback2 received Title unmatch");
+ expect().assertFail();
+ }
+ receivedCallback2 = true;
+ }
+
+ function queueItemsCallback1(items) {
+ console.log(TAG + "queueItemsCallback1 received items length: " + items.length);
+ console.log(TAG + "queueItemsCallback1 received items id: " + items[0].itemId);
+ console.log(TAG + "queueItemsCallback1 received items title: " + items[0].description.title);
+ if (items.length != QUEUE_ITEM_LENGTH) {
+ console.error(TAG + "queueItemsCallback1 received items length unmatch");
+ expect().assertFail();
+ return;
+ }
+ if (items[0].itemId != QUEUE_ITEM_ID) {
+ console.error(TAG + "queueItemsCallback1 received items id unmatch");
+ expect().assertFail();
+ return;
+ }
+ if (items[0].description.title != QUEUE_ITEM_KEY_WORD) {
+ console.error(TAG + "queueItemsCallback1 received items key word unmatch");
+ expect().assertFail();
+ return;
+ }
+ receivedCallback = true;
+ }
+
+ function queueItemsCallback2(items) {
+ console.log(TAG + "queueItemsCallback2 received items length: " + items.length);
+ console.log(TAG + "queueItemsCallback2 received items id: " + items[0].itemId);
+ console.log(TAG + "queueItemsCallback2 received items title: " + items[0].description.title);
+ if (items.length != QUEUE_ITEM_LENGTH) {
+ console.error(TAG + "queueItemsCallback2 received items length unmatch");
+ expect().assertFail();
+ return;
+ }
+ if (items[0].itemId != QUEUE_ITEM_ID) {
+ console.error(TAG + "queueItemsCallback2 received items id unmatch");
+ expect().assertFail();
+ return;
+ }
+ if (items[0].description.title != QUEUE_ITEM_KEY_WORD) {
+ console.error(TAG + "queueItemsCallback2 received items key word unmatch");
+ expect().assertFail();
+ return;
+ }
+ receivedCallback2 = true;
+ }
+
+ function skipToQueueItemCallback1(itemId) {
+ console.log(TAG + "skipToQueueItemCallback1 received itemid " + itemId);
+ if (itemId != SKIP_ITEM_ID) {
+ console.error(TAG + "skipToQueueItemCallback1 received uid unmatch");
+ expect().assertFail();
+ }
+ receivedCallback = true;
+ }
+
+ function skipToQueueItemCallback2(itemId) {
+ console.log(TAG + "skipToQueueItemCallback2 received itemid " + itemId);
+ if (itemId != SKIP_ITEM_ID) {
+ console.error(TAG + "skipToQueueItemCallback2 received uid unmatch");
+ expect().assertFail();
+ }
+ receivedCallback2 = true;
+ }
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSESSIONEVENT_0100
+ * @tc.desc:One on function - lyrics session event
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_ONSESSIONEVENT_0100", 0, async function (done) {
+ controller.on('sessionEvent', dynamicLyricsCallback1);
+ await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONSESSIONEVENT_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ sleep(200).then(() => {
+ if (receivedCallback) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONSESSIONEVENT_0100 Received session event change event");
+ expect(receivedString == UPDATE_LYRICS_EVENT).assertTrue();
+ expect(receivedParam.lyrics == UPDATE_LYRICS_WANT_PARAMS.lyrics).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONSESSIONEVENT_0100 Session event change event not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedString = null;
+ receivedParam = null;
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSESSIONEVENT_0200
+ * @tc.desc:Two on functions - lyrics session event
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_ONSESSIONEVENT_0200", 0, async function (done) {
+ controller.on('sessionEvent', dynamicLyricsCallback1);
+ controller.on('sessionEvent', dynamicLyricsCallback2);
+ await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONSESSIONEVENT_0200 Set session event error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONSESSIONEVENT_0200 Received session event change event");
+ expect(receivedString == UPDATE_LYRICS_EVENT).assertTrue();
+ expect(receivedParam.lyrics == UPDATE_LYRICS_WANT_PARAMS.lyrics).assertTrue();
+ expect(receivedString2 == UPDATE_LYRICS_EVENT).assertTrue();
+ expect(receivedParam2.lyrics == UPDATE_LYRICS_WANT_PARAMS.lyrics).assertTrue();
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONSESSIONEVENT_0200 Session event change event not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedCallback2 = false;
+ receivedString2 = null;
+ receivedParam2 = null;
+ receivedString2 = null;
+ receivedParam2 = null;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSESSIONEVENT_0300
+ * @tc.desc:One on functions - one param
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_ONSESSIONEVENT_0300", 0, async function (done) {
+ try {
+ controller.on('sessionEvent');
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSESSIONEVENT_0400
+ * @tc.desc:One on functions - three params
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_ONSESSIONEVENT_0400", 0, async function (done) {
+ try {
+ controller.on('sessionEvent', dynamicLyricsCallback1, dynamicLyricsCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSESSIONEVENT_0500
+ * @tc.desc:One on functions - invalid type
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_ONSESSIONEVENT_0500", 0, async function (done) {
+ try {
+ controller.on('sessionEvent', INVALID_STRING);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFSESSIONEVENT_0100
+ * @tc.desc:Two on functions and one off function - lyrics session event
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_OFFSESSIONEVENT_0100", 0, async function (done) {
+ controller.on('sessionEvent', dynamicLyricsCallback1);
+ controller.on('sessionEvent', dynamicLyricsCallback2);
+ controller.off('sessionEvent', dynamicLyricsCallback2);
+ await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
+ console.error(TAG + "Set session event error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && !receivedCallback2) {
+ console.log(TAG + "Received session event change event");
+ expect(receivedString == UPDATE_LYRICS_EVENT).assertTrue();
+ expect(receivedParam.lyrics == UPDATE_LYRICS_WANT_PARAMS.lyrics).assertTrue();
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "Session event change event not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedString = null;
+ receivedParam = null;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFSESSIONEVENT_0200
+ * @tc.desc:Two on functions and two off function - lyrics session event
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_OFFSESSIONEVENT_0200", 0, async function (done) {
+ controller.on('sessionEvent', dynamicLyricsCallback1);
+ controller.on('sessionEvent', dynamicLyricsCallback2);
+ controller.off('sessionEvent', dynamicLyricsCallback1);
+ controller.off('sessionEvent', dynamicLyricsCallback2);
+
+ await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
+ console.error(TAG + "Set session event error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "Received session event change event");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "Session event change event not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFSESSIONEVENT_0300
+ * @tc.desc:Two on functions and off all function - lyrics session event
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_OFFSESSIONEVENT_0300", 0, async function (done) {
+ controller.on('sessionEvent', dynamicLyricsCallback1);
+ controller.on('sessionEvent', dynamicLyricsCallback2);
+ controller.off('sessionEvent');
+
+ await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
+ console.error(TAG + "Set session event error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "Received session event change event");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "Session event change event not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFSESSIONEVENT_0400
+ * @tc.desc:Two on functions and off function - three params
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_OFFSESSIONEVENT_0400", 0, async function (done) {
+ try {
+ controller.on('sessionEvent', dynamicLyricsCallback1);
+ controller.on('sessionEvent', dynamicLyricsCallback2);
+ controller.off('sessionEvent', dynamicLyricsCallback1, dynamicLyricsCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFSESSIONEVENT_0500
+ * @tc.desc:One on functions and off all function - invalid type
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_OFFSESSIONEVENT_0500", 0, async function (done) {
+ try {
+ controller.on('sessionEvent', dynamicLyricsCallback1);
+ controller.off('sessionEvent', INVALID_STRING);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0100
+ * @tc.desc:Send common command - callback
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0100", 0, async function (done) {
+ controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS, (err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0200
+ * @tc.desc:Send common command - promise
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0200", 0, async function (done) {
+ await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0200 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0300
+ * @tc.desc:Set common command - one param
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0300", 0, async function (done) {
+ let errCode = 0;
+ await controller.sendCommonCommand(COMMON_COMMAND_STRING).catch((err) => {
+ console.info(TAG + "SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0300 caught error" + err.code);
+ errCode = err.code;
+ });
+ sleep(200).then(() => {
+ expect(errCode == 401).assertTrue();
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0400
+ * @tc.desc:Send common command - invalid params
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0400", 0, async function (done) {
+ let errCode = 0;
+ await controller.sendCommonCommand(COMMON_COMMAND_PARAMS, COMMON_COMMAND_PARAMS).catch((err) => {
+ console.info(TAG + "SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0400 caught error" + err.code);
+ errCode = err.code;
+ });
+ sleep(200).then(() => {
+ expect(errCode == 401).assertTrue();
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0500
+ * @tc.desc:Send common command - deactive
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_SENDCOMMONCOMMAND_0500", 0, async function (done) {
+ try {
+ session.deactivate(async () => {
+ await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS);
+ });
+ } catch (err) {
+ expect(err.code == 6600106).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_GETEXTRAS_0100
+ * @tc.desc:Get extras - callback
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_GETEXTRAS_0100", 0, async function (done) {
+ console.info(TAG + "SUB_MULTIMEDIA_GETEXTRAS_0100 start");
+ await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_GETEXTRAS_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ });
+
+ controller.getExtras((err, extras) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_GETEXTRAS_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ expect(extras.extrasKey == CUSTOM_EXTRAS.extrasKey).assertTrue();
+ console.info(TAG + "SUB_MULTIMEDIA_GETEXTRAS_0100 finished");
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_GETEXTRAS_0200
+ * @tc.desc:Get extras - promise
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_GETEXTRAS_0200", 0, async function (done) {
+ console.info(TAG + "SUB_MULTIMEDIA_GETEXTRAS_0200 start");
+ await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_GETEXTRAS_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ });
+
+ let extras = await controller.getExtras().catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_GETEXTRAS_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ })
+ expect(extras.extrasKey == CUSTOM_EXTRAS.extrasKey).assertTrue();
+ console.info(TAG + "SUB_MULTIMEDIA_GETEXTRAS_0200 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONEXTRASCHANGE_0100
+ * @tc.desc:One on function - extras change
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_ONEXTRASCHANGE_0100", 0, async function (done) {
+ console.info(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0100 start");
+ controller.on('extrasChange', extrasChangeCallback1);
+ await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ sleep(200).then(() => {
+ if (receivedCallback) {
+ console.log(TAG + "Received extras change event");
+ expect(receivedExtras.extrasKey == CUSTOM_EXTRAS.extrasKey).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0100 extras change event not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedExtras = null;
+ console.info(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0100 finished");
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONEXTRASCHANGE_0200
+ * @tc.desc:Two on function - extras change
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_ONEXTRASCHANGE_0200", 0, async function (done) {
+ console.info(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0200 start");
+ controller.on('extrasChange', extrasChangeCallback1);
+ controller.on('extrasChange', extrasChangeCallback2);
+ await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ sleep(200).then(() => {
+ if (receivedCallback && receivedCallback2) {
+ console.log(TAG + "Received extras change event");
+ expect(receivedExtras.extrasKey == CUSTOM_EXTRAS.extrasKey).assertTrue();
+ expect(receivedExtras2.extrasKey == CUSTOM_EXTRAS.extrasKey).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0200 extras change event not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedCallback2 = false;
+ receivedExtras = null;
+ receivedExtras2 = null;
+ console.info(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0200 finished");
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONEXTRASCHANGE_0300
+ * @tc.desc:One on functions - one param
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_ONEXTRASCHANGE_0300", 0, async function (done) {
+ try {
+ controller.on('extrasChange');
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0300 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONEXTRASCHANGE_0400
+ * @tc.desc:One on functions - three params
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_ONEXTRASCHANGE_0400", 0, async function (done) {
+ try {
+ controller.on('extrasChange', extrasChangeCallback1, extrasChangeCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0400 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONEXTRASCHANGE_0500
+ * @tc.desc:One on functions - invalid type
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_ONEXTRASCHANGE_0500", 0, async function (done) {
+ try {
+ controller.on('extrasChange', INVALID_STRING);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_ONEXTRASCHANGE_0500 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFEXTRASCHANGE_0100
+ * @tc.desc:Two on functions and one off function - extras change
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_OFFEXTRASCHANGE_0100", 0, async function (done) {
+ controller.on('extrasChange', extrasChangeCallback1);
+ controller.on('extrasChange', extrasChangeCallback2);
+ controller.off('extrasChange', extrasChangeCallback2);
+ await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && !receivedCallback2) {
+ console.log(TAG + "Received extras change event");
+ expect(receivedExtras.extrasKey == CUSTOM_EXTRAS.extrasKey).assertTrue();
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0100 Extras change event not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedExtras = null;
+ console.info(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0100 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFEXTRASCHANGE_0200
+ * @tc.desc:Two on functions and two off function - extras change
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_OFFEXTRASCHANGE_0200", 0, async function (done) {
+ controller.on('extrasChange', extrasChangeCallback1);
+ controller.on('extrasChange', extrasChangeCallback2);
+ controller.off('extrasChange', extrasChangeCallback1);
+ controller.off('extrasChange', extrasChangeCallback2);
+ await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0200 Success, not received extras change event");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0200 failed, extras change event received");
+ expect().assertFail();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0200 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFEXTRASCHANGE_0300
+ * @tc.desc:Two on functions and off all function - extras change
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_OFFEXTRASCHANGE_0300", 0, async function (done) {
+ controller.on('extrasChange', extrasChangeCallback1);
+ controller.on('extrasChange', extrasChangeCallback2);
+ controller.off('extrasChange');
+ await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0300 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0300Success, not received extras change event");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0300 failed, extras change event received");
+ expect().assertFail();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0300 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFEXTRASCHANGE_0400
+ * @tc.desc:Two on functions and off function - three params
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_OFFEXTRASCHANGE_0400", 0, async function (done) {
+ try {
+ controller.on('extrasChange', extrasChangeCallback1);
+ controller.on('extrasChange', extrasChangeCallback2);
+ controller.off('extrasChange', extrasChangeCallback1, extrasChangeCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0400 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFEXTRASCHANGE_0500
+ * @tc.desc:One on functions and off all function - invalid type
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_OFFEXTRASCHANGE_0500", 0, async function (done) {
+ try {
+ controller.on('extrasChange', extrasChangeCallback1);
+ controller.off('extrasChange', INVALID_STRING);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_OFFEXTRASCHANGE_0500 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0100
+ * @tc.desc:One on function - queue items change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0100", 0, async function (done) {
+ controller.on('queueItemsChange', queueItemsCallback1);
+ await session.setAVQueueItems(ITEMS_ARRAY).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0100 setAVQueueItems error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ sleep(200).then(() => {
+ if (receivedCallback) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0100 Received queue items change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0100 Session queue items change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0200
+ * @tc.desc:One on function - queue items change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0200", 0, async function (done) {
+ controller.on('queueItemsChange', queueItemsCallback1);
+ controller.on('queueItemsChange', queueItemsCallback2);
+ await session.setAVQueueItems(ITEMS_ARRAY).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0200 Received queue items change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0200 Session queue items change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedCallback2 = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0300
+ * @tc.desc:One on functions - one param
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0300", 0, async function (done) {
+ try {
+ controller.on('queueItemsChange');
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0300
+ * @tc.desc:One on functions - three params
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONQUEUEITEMSCHANGE_0300", 0, async function (done) {
+ try {
+ controller.on('queueItemsChange', queueItemsCallback1, queueItemsCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0100
+ * @tc.desc:One on function - queue title change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0100", 0, async function (done) {
+ controller.on('queueTitleChange', queueTitleCallback1);
+ await session.setAVQueueTitle(QUEUE_TITLE).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0100 setAVQueueTitle error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ sleep(200).then(() => {
+ if (receivedCallback) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0100 Received queue Title change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0100 Session queue Title change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0200
+ * @tc.desc:One on function - queue title change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0200", 0, async function (done) {
+ controller.on('queueTitleChange', queueTitleCallback1);
+ controller.on('queueTitleChange', queueTitleCallback2);
+ await session.setAVQueueTitle(QUEUE_TITLE).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0200 Received queue Title change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0200 Session queue Title change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedCallback2 = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0300
+ * @tc.desc:One on functions - one param
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0300", 0, async function (done) {
+ try {
+ controller.on('queueTitleChange');
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0400
+ * @tc.desc:One on functions - three params
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONQUEUETITLECHANGE_0400", 0, async function (done) {
+ try {
+ controller.on('queueTitleChange', queueTitleCallback1, queueTitleCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0100
+ * @tc.desc:Two on functions and one off function - queue items change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0100", 0, async function (done) {
+ controller.on('queueItemsChange', queueItemsCallback1);
+ controller.on('queueItemsChange', queueItemsCallback2);
+ controller.off('queueItemsChange', queueItemsCallback2);
+ await session.setAVQueueItems(ITEMS_ARRAY).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0100 setAVQueueItems error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0100 Received queue items change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0100 Session queue items change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0200
+ * @tc.desc:Two on functions and two off function - queue items change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0200", 0, async function (done) {
+ controller.on('queueItemsChange', queueItemsCallback1);
+ controller.on('queueItemsChange', queueItemsCallback2);
+ controller.off('queueItemsChange', queueItemsCallback1);
+ controller.off('queueItemsChange', queueItemsCallback2);
+ await session.setAVQueueItems(ITEMS_ARRAY).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0200 setAVQueueItems error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0200 Received queue items change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0200 Session queue items change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0300
+ * @tc.desc:Two on functions and off all function - queue items change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0300", 0, async function (done) {
+ controller.on('queueItemsChange', queueItemsCallback1);
+ controller.on('queueItemsChange', queueItemsCallback2);
+ controller.off('queueItemsChange');
+ await session.setAVQueueItems(ITEMS_ARRAY).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0300 setAVQueueItems error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0300 Received queue items change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0300 Session queue items change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0400
+ * @tc.desc:Two on functions and off function - three params
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_OFFQUEUEITEMSCHANGE_0400", 0, async function (done) {
+ try {
+ controller.on('queueItemsChange', queueItemsCallback1);
+ controller.on('queueItemsChange', queueItemsCallback2);
+ controller.off('queueItemsChange', queueItemsCallback1, queueItemsCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0100
+ * @tc.desc:Two on functions and one off function - queue title change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0100", 0, async function (done) {
+ controller.on('queueTitleChange', queueTitleCallback1);
+ controller.on('queueTitleChange', queueTitleCallback2);
+ controller.off('queueTitleChange', queueTitleCallback2);
+ await session.setAVQueueTitle(QUEUE_TITLE).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0100 setAVQueueTitle error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0100 Received queue Title change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0100 Session queue Title change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0200
+ * @tc.desc:Two on functions and two off function - queue title change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0200", 0, async function (done) {
+ controller.on('queueTitleChange', queueTitleCallback1);
+ controller.on('queueTitleChange', queueTitleCallback2);
+ controller.off('queueTitleChange', queueTitleCallback1);
+ controller.off('queueTitleChange', queueTitleCallback2);
+
+ await session.setAVQueueTitle(QUEUE_TITLE).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0200 setAVQueueTitle error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0200 Received queue Title change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0200 Session queue Title change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0300
+ * @tc.desc:Two on functions and off all function - queue title change
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0300", 0, async function (done) {
+ controller.on('queueTitleChange', queueTitleCallback1);
+ controller.on('queueTitleChange', queueTitleCallback2);
+ controller.off('queueTitleChange');
+
+ await session.setAVQueueTitle(QUEUE_TITLE).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0300 setAVQueueTitle error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0300 Received queue Title change");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0300 Session queue Title change not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0400
+ * @tc.desc:Two on functions and off function - three params
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_OFFQUEUETITLECHANGE_0400", 0, async function (done) {
+ try {
+ controller.on('queueTitleChange', queueTitleCallback1);
+ controller.on('queueTitleChange', queueTitleCallback2);
+ controller.off('queueTitleChange', queueTitleCallback1, queueTitleCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SETAVQUEUEITEMS_0100
+ * @tc.desc:setAVQueueItems - callback
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+
+ it("SUB_MULTIMEDIA_SETAVQUEUEITEMS_0100", 0, async function (done) {
+ session.setAVQueueItems(ITEMS_ARRAY, (err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_SETAVQUEUEITEMS_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_SETAVQUEUEITEMS_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SETAVQUEUEITEMS_0200
+ * @tc.desc:setAVQueueItems - promise
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_SETAVQUEUEITEMS_0200", 0, async function (done) {
+ await session.setAVQueueItems(ITEMS_ARRAY).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_SETAVQUEUEITEMS_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_SETAVQUEUEITEMS_0200 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SETAVQUEUETITLE_0100
+ * @tc.desc:setAVQueueTitle - callback
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_SETAVQUEUETITLE_0100", 0, async function (done) {
+ session.setAVQueueTitle(QUEUE_TITLE, (err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_SETAVQUEUETITLE_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_SETAVQUEUETITLE_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SETAVQUEUETITLE_0200
+ * @tc.desc:setAVQueueTitle - promise
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_SETAVQUEUETITLE_0200", 0, async function (done) {
+ await session.setAVQueueTitle(QUEUE_TITLE).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_SETAVQUEUETITLE_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_SETAVQUEUETITLE_0200 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SKIPTOQUEUEITEM_0100
+ * @tc.desc:SkipToQueueItem - callback
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_SKIPTOQUEUEITEM_0100", 0, async function (done) {
+ controller.skipToQueueItem(QUEUE_ITEM_ID, (err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_SKIPTOQUEUEITEM_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_SKIPTOQUEUEITEM_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SKIPTOQUEUEITEM_0200
+ * @tc.desc:SkipToQueueItem - promise
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_SKIPTOQUEUEITEM_0200", 0, async function (done) {
+ await controller.skipToQueueItem(QUEUE_ITEM_ID).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_SKIPTOQUEUEITEM_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_SKIPTOQUEUEITEM_0200 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0100
+ * @tc.desc:One on function - skip to queue items
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0100", 0, async function (done) {
+ session.on('skipToQueueItem', skipToQueueItemCallback1);
+ await controller.skipToQueueItem(SKIP_ITEM_ID).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ sleep(200).then(() => {
+ if (receivedCallback) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0100 Received skipToQueueItem ");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0100 skipToQueueItem not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0200
+ * @tc.desc:One on function - skip to queue items
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0200", 0, async function (done) {
+ session.on('skipToQueueItem', skipToQueueItemCallback1);
+ session.on('skipToQueueItem', skipToQueueItemCallback2);
+ await controller.skipToQueueItem(SKIP_ITEM_ID).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0200 Received skipToQueueItem ");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0200skipToQueueItem not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedCallback2 = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0300
+ * @tc.desc:One on functions - one param
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0300", 0, async function (done) {
+ try {
+ session.on('skipToQueueItem');
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0400
+ * @tc.desc:One on functions - three params
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_ONSKIPTOQUEUEITEM_0400", 0, async function (done) {
+ try {
+ session.on('skipToQueueItem', skipToQueueItemCallback1, skipToQueueItemCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_GETAVQUEUEITEMS_0100
+ * @tc.desc:GetAVQueueItems - callback
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_GETAVQUEUEITEMS_0100", 0, async function (done) {
+ session.setAVQueueItems(ITEMS_ARRAY, (err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_GETAVQUEUEITEMS_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_GETAVQUEUEITEMS_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ await sleep(200);
+ controller.getAVQueueItems((err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_GETAVQUEUEITEMS_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_GETAVQUEUEITEMS_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ await sleep(200);
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_GETAVQUEUEITEMS_0200
+ * @tc.desc:GetAVQueueItems - promise
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_GETAVQUEUEITEMS_0200", 0, async function (done) {
+ await session.setAVQueueItems(ITEMS_ARRAY).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_GETAVQUEUEITEMS_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_GETAVQUEUEITEMS_0200 finished");
+ done();
+ await sleep(200);
+ await controller.getAVQueueItems().catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_GETAVQUEUEITEMS_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_GETAVQUEUEITEMS_0200 finished");
+ done();
+ await sleep(200);
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_GETAVQUEUETITLE_0100
+ * @tc.desc:GetAVQueueTitle - callback
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_GETAVQUEUETITLE_0100", 0, async function (done) {
+ session.setAVQueueTitle(QUEUE_TITLE, (err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_GETAVQUEUETITLE_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_GETAVQUEUETITLE_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ await sleep(200);
+ controller.getAVQueueTitle((err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_GETAVQUEUETITLE_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_GETAVQUEUETITLE_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ await sleep(200);
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_GETAVQUEUETITLE_0200
+ * @tc.desc:GetAVQueueTitle - promise
+ * @tc.type: FUNC
+ * @tc.require: I6KTU4
+ */
+ it("SUB_MULTIMEDIA_GETAVQUEUETITLE_0200", 0, async function (done) {
+ await session.setAVQueueTitle(QUEUE_TITLE).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_GETAVQUEUETITLE_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_GETAVQUEUETITLE_0200 finished");
+ done();
+ await sleep(200);
+ await controller.getAVQueueTitle().catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_GETAVQUEUETITLE_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_GETAVQUEUETITLE_0200 finished");
+ done();
+ await sleep(200);
+ })
+
+ })
+}
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..03ebf84544456179841b8855f790890d8f7a814a
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2022 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 avSession from '@ohos.multimedia.avsession';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
+import featureAbility from '@ohos.ability.featureAbility';
+
+export default function AVSessionErrorCode() {
+ describe('AVSessionErrorCode', function () {
+ let tag = 'ApplicationA';
+ let type = 'audio';
+ let session;
+ let pid = 100;
+ let uid = 200;
+ let audioDevices;
+ let sessionToken;
+ let controller;
+ let id = '9527';
+ let sessionId;
+ let keyItem = {code:10, pressedTime:123456789, deviceId:0};
+ let event = {action:2, key:keyItem, keys:[keyItem]};
+ let context = featureAbility.getContext();
+
+ function sleep (ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+ }
+
+ beforeAll(function () {
+ console.info('TestLog: Start Testing avSession Interfaces');
+ })
+
+ beforeEach(async function () {
+ console.info('TestLog: Init Session And Controller');
+ await avSession.createAVSession(context, tag, type).then((data) => {
+ session = data;
+ }).catch((err) => {
+ expect(err.code == 6600101).assertTrue();
+ console.info(avSession.AVSessionErrorCode.ERR_CODE_SERVICE_EXCEPTION);
+ console.info(`TestLog: Session create error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ await session.activate().then(() => {
+ console.info('TestLog: Session activate');
+ }).catch((err) => {
+ console.info(`TestLog: Session activate error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+
+ controller = await session.getController();
+ })
+
+ afterEach(async function (done) {
+ console.info('TestLog: Destroy Session And Controller');
+ await session.destroy().then(() => {
+ console.info('TestLog: Session destroy success');
+ }).catch((err) => {
+ console.info(`TestLog: Session destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await controller.destroy().then(() => {
+ console.info('TestLog: Controller destroy success');
+ }).catch((err) => {
+ console.info(`TestLog: Controller destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ afterAll(function () {
+ console.info('TestLog: End Testing avSession Interfaces');
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100
+ * @tc.name : SETMETADATA_0100
+ * @tc.desc : Testing set metadata - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100', 0, async function (done) {
+ let metadata1 = {
+ assetId: '121278',
+ };
+
+ await sleep(500);
+ await session.setAVMetadata(metadata1).then(() => {
+ console.info('TestLog: Set metadata successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ expect(err.code == 6600102).assertTrue();
+ console.info(avSession.AVSessionErrorCode.ERR_CODE_SESSION_NOT_EXIST);
+ console.info(`TestLog: Set metadata error: code: ${err.code}, message: ${err.message}`);
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_DESTROYCONTROLLER_PROMISE_0100
+ * @tc.name : DESTROYCONTROLLER_0100
+ * @tc.desc : Testing destroy the controller - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level1
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_DESTROYCONTROLLER_PROMISE_0100', 0, async function (done) {
+ await controller.destroy().then(() => {
+ console.info('TestLog: Controller destroy successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ expect(err.code == 6600103).assertTrue();
+ console.info(avSession.AVSessionErrorCode.ERR_CODE_CONTROLLER_NOT_EXIST);
+ console.info(`TestLog: Controller destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100
+ * @tc.name : OFFPLAY_0100
+ * @tc.desc : Testing offPlay callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100', 0, async function (done) {
+ function callback1() {
+ console.info('TestLog: Play command registration1 success');
+ expect(true).assertTrue();
+ }
+
+ session.on('play', callback1);
+
+ await controller.sendControlCommand({ command: 'play' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ expect(err.code == 6600105).assertTrue();
+ console.info(avSession.AVSessionErrorCode.ERR_CODE_COMMAND_INVALID);
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100
+ * @tc.name : CAST_AUDIO_0100
+ * @tc.desc : Testing cast audio
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100', 0, async function (done) {
+ sessionId = session.sessionId;
+ sessionToken = { sessionId, pid, uid };
+
+ try {
+ await avSession.castAudio(sessionToken, audioDevices).then(() => {
+ console.info('Cast audio to remote');
+ }).catch((err) => {
+ console.info(avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_ERR);
+ console.info(`Cast audio to remote BusinessError: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ } catch (err) {
+ console.info(`Testing has failed BusinessError: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ }
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100
+ * @tc.name : ONHANDLEKEYEVENT_0100
+ * @tc.desc : Testing Handle KeyEvent callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100', 0, async function (done) {
+ session.on('handleKeyEvent', (callback) => {
+ if (callback.action === 2) {
+ console.info('TestLog: Handle keyEvent callback registration successful');
+ expect(true).assertTrue();
+ } else {
+ console.info('TestLog: Handle keyEvent callback registration error');
+ expect(false).assertTrue();
+ }
+ });
+
+ await controller.sendAVKeyEvent(event).then(() => {
+ console.info('TestLog: Controller send AVKeyEvent successfully');
+ }).catch((err) => {
+ expect(err.code == 6600106).assertTrue();
+ console.info(avSession.AVSessionErrorCode.ERR_CODE_SESSION_INACTIVE);
+ console.info(`TestLog: Controller send AVKeyEvent error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100
+ * @tc.name : ONPLAY_0100
+ * @tc.desc : Testing onPlay callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100', 0, async function (done) {
+ session.on('play', () => {
+ console.info('TestLog: Play command callback registration successful');
+ expect(true).assertTrue();
+ });
+
+ await controller.sendControlCommand({ command: 'play' }).then(() => {
+ console.info('TestLog: Controller send command successfully');
+ }).catch((err) => {
+ expect(err.code == 6600107).assertTrue();
+ console.info(avSession.AVSessionErrorCode.ERR_CODE_MESSAGE_OVERLOAD);
+ console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await sleep(500);
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionJSTest.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionJSTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..8d63e590fd6d6d28ea3d3f12699cf509c4a2e2ae
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionJSTest.js
@@ -0,0 +1,469 @@
+/*
+ * Copyright (c) 2023 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 avSession from '@ohos.multimedia.avsession';
+import featureAbility from '@ohos.ability.featureAbility';
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
+
+
+const TAG = "[AVSessionJSTest]";
+export default function AVSessionJsTest() {
+ describe("AVSessionJsTest", function () {
+ let session = null;
+ let controller = null;
+ let receivedCallback = false;
+ let receivedCallback2 = false;
+ let receivedString = null;
+ let receivedString2 = null;
+ let receivedParam = null;
+ let receivedParam2 = null;
+ const INVALID_STRING = "invalid string";
+ const UPDATE_LYRICS_EVENT = "dynamic_lyrics";
+ const UPDATE_LYRICS_WANT_PARAMS = {
+ lyric: "This is my lyrics"
+ };
+ const COMMON_COMMAND_STRING = "common_command";
+ const COMMON_COMMAND_PARAMS = {
+ command: "This is my command"
+ };
+ const CUSTOM_EXTRAS = {
+ extras: "This is custom media packet"
+ };
+
+ beforeAll(async function () {
+ session = await avSession.createAVSession(featureAbility.getContext(), "AVSessionDemo", 'audio').catch((err) => {
+ console.error(TAG + "Create AVSession error " + JSON.stringify(err));
+ expect().assertFail();
+ });
+ session.activate();
+ controller = await session.getController();
+ console.info(TAG + "Create session finished, beforeAll called");
+ })
+
+ afterAll(function () {
+ session.destroy();
+ console.info(TAG + 'afterAll called')
+ })
+
+ beforeEach(function () {
+ console.info(TAG + 'beforeEach called')
+ })
+
+ afterEach(function () {
+ console.info(TAG + 'afterEach called')
+ })
+
+ function sleep(time) {
+ return new Promise((resolve) => setTimeout(resolve, time));
+ }
+
+ function commonCommandCallback1(command, args) {
+ console.log(TAG + "Callback1 received event: " + JSON.stringify(command));
+ console.log(TAG + "Callback1 received args: " + JSON.stringify(args));
+ if (command != COMMON_COMMAND_STRING) {
+ console.error(TAG + "Callback1 common command unmatch");
+ expect().assertFail();
+ }
+ receivedCallback = true;
+ receivedString = command;
+ receivedParam = args;
+ }
+
+ function commonCommandCallback2(command, args) {
+ console.log(TAG + "Callback2 received event: " + JSON.stringify(command));
+ console.log(TAG + "Callback2 received args: " + JSON.stringify(args));
+ if (command != COMMON_COMMAND_STRING) {
+ console.error(TAG + "Callback2 common command unmatch");
+ expect().assertFail();
+ }
+ receivedCallback2 = true;
+ receivedString2 = command;
+ receivedParam2 = args;
+ }
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0100
+ * @tc.desc:Set session event - callback
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0100", 0, async function (done) {
+ session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS, (err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0200
+ * @tc.desc:Set session event - promise
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0200", 0, async function (done) {
+ await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0200 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0300
+ * @tc.desc:Set session event - one param
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0300", 0, async function (done) {
+ let errCode = 0;
+ await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT).catch((err) => {
+ console.info(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0300 caught error" + err.code);
+ errCode = err.code;
+ });
+ sleep(200).then(() => {
+ expect(errCode == 401).assertTrue();
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0400
+ * @tc.desc:Set session event - invalid params
+ * @tc.type: FUNC
+ * @tc.require: I6C6IN
+ */
+ it("SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0400", 0, async function (done) {
+ let errCode = 0;
+ await session.dispatchSessionEvent(UPDATE_LYRICS_WANT_PARAMS, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
+ console.info(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0400 caught error" + err.code);
+ errCode = err.code;
+ });
+ sleep(200).then(() => {
+ expect(errCode == 401).assertTrue();
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SETEXTRAS_0100
+ * @tc.desc:Set extras - callback
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_SETEXTRAS_0100", 0, async function (done) {
+ session.setExtras(CUSTOM_EXTRAS, (err) => {
+ if (err) {
+ console.error(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ }
+ console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0100 finished");
+ expect(true).assertTrue();
+ done();
+ });
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SETEXTRAS_0200
+ * @tc.desc:Set extras - promise
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_SETEXTRAS_0200", 0, async function (done) {
+ await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0200 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0200 finished");
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SETEXTRAS_0300
+ * @tc.desc:Set extras - zero param
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_SETEXTRAS_0300", 0, async function (done) {
+ let errCode = 0;
+ await session.setExtras().catch((err) => {
+ console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0300 caught error" + err.code);
+ errCode = err.code;
+ });
+ sleep(200).then(() => {
+ expect(errCode == 401).assertTrue();
+ console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0300 finished");
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_SETEXTRAS_0400
+ * @tc.desc:Set extras - invalid params
+ * @tc.type: FUNC
+ * @tc.require: I6TD43
+ */
+ it("SUB_MULTIMEDIA_SETEXTRAS_0400", 0, async function (done) {
+ let errCode = 0;
+ await session.setExtras(INVALID_STRING).catch((err) => {
+ console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0400 caught error" + err.code);
+ errCode = err.code;
+ });
+ sleep(200).then(() => {
+ expect(errCode == 401).assertTrue();
+ console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0400 finished");
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100
+ * @tc.desc:One on function - common command
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100", 0, async function (done) {
+ session.on('commonCommand', commonCommandCallback1);
+ await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100 error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ sleep(200).then(() => {
+ if (receivedCallback) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100 Received common command");
+ expect(receivedString == COMMON_COMMAND_STRING).assertTrue();
+ expect(receivedParam.command == COMMON_COMMAND_PARAMS.command).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100 Common command not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedString = null;
+ receivedParam = null;
+ done();
+ })
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200
+ * @tc.desc:Two on functions - common command
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200", 0, async function (done) {
+ session.on('commonCommand', commonCommandCallback1);
+ session.on('commonCommand', commonCommandCallback2);
+ await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200 Send common command error " + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200 Received common command");
+ expect(receivedString == COMMON_COMMAND_STRING).assertTrue();
+ expect(receivedParam.command == COMMON_COMMAND_PARAMS.command).assertTrue();
+ expect(receivedString2 == COMMON_COMMAND_STRING).assertTrue();
+ expect(receivedParam2.command == COMMON_COMMAND_PARAMS.command).assertTrue();
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200 Common command not received");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedString = null;
+ receivedParam = null;
+ receivedCallback2 = false;
+ receivedString2 = null;
+ receivedParam2 = null;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0300
+ * @tc.desc:One on functions - one param
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0300", 0, async function (done) {
+ try {
+ session.on('commonCommand');
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0400
+ * @tc.desc:One on functions - three params
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0400", 0, async function (done) {
+ try {
+ session.on('sessionEventChange', commonCommandCallback1, commonCommandCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0500
+ * @tc.desc:One on functions - invalid type
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0500", 0, async function (done) {
+ try {
+ session.on('commonCommand', INVALID_STRING);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100
+ * @tc.desc:Two on functions and one off function
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100", 0, async function (done) {
+ session.on('commonCommand', commonCommandCallback1);
+ session.on('commonCommand', commonCommandCallback2);
+ session.off('commonCommand', commonCommandCallback2);
+ await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100 Send common command error" + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100 finished");
+ expect(receivedString == COMMON_COMMAND_STRING).assertTrue();
+ expect(receivedParam.command == COMMON_COMMAND_PARAMS.command).assertTrue();
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100 failed");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ receivedString = null;
+ receivedParam = null;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200
+ * @tc.desc:Two on functions and two off function
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200", 0, async function (done) {
+ session.on('commonCommand', commonCommandCallback1);
+ session.on('commonCommand', commonCommandCallback2);
+ session.off('commonCommand', commonCommandCallback1);
+ session.off('commonCommand', commonCommandCallback2);
+ await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200 Send common command error" + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200 finished");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200 failed");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300
+ * @tc.desc:Two on functions and off all function
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300", 0, async function (done) {
+ session.on('commonCommand', commonCommandCallback1);
+ session.on('commonCommand', commonCommandCallback2);
+ session.off('commonCommand');
+
+ await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300 Send common command error" + JSON.stringify(err));
+ expect().assertFail();
+ done();
+ });
+ await sleep(200);
+ if (!receivedCallback && !receivedCallback2) {
+ console.log(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300 finished");
+ expect(true).assertTrue();
+ } else {
+ console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300 failed");
+ expect().assertFail();
+ }
+ receivedCallback = false;
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0400
+ * @tc.desc:Two on functions and off function - three params
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0400", 0, async function (done) {
+ try {
+ session.on('commonCommand', commonCommandCallback1);
+ session.on('commonCommand', commonCommandCallback2);
+ session.off('commonCommand', commonCommandCallback1, commonCommandCallback2);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /*
+ * @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0500
+ * @tc.desc:One on functions and off all function - invalid type
+ * @tc.type: FUNC
+ * @tc.require: I6ETY6
+ */
+ it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0500", 0, async function (done) {
+ try {
+ session.on('commonCommand', commonCommandCallback1);
+ session.off('commonCommand', INVALID_STRING);
+ } catch (err) {
+ expect(err.code == 401).assertTrue();
+ }
+ done();
+ })
+ })
+}
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionManager.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionManager.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..dff82c575ef8b436639ffcd06abd96005a34e4fe
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionManager.test.js
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2022 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 avSession from '@ohos.multimedia.avsession';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
+import featureAbility from '@ohos.ability.featureAbility';
+
+export default function AVSessionManager() {
+ describe('AVSessionManager', function () {
+ let tag = 'ApplicationA';
+ let type = 'audio';
+ let session;
+ let context = featureAbility.getContext();
+
+ function sleep (ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+ }
+
+ beforeAll(function () {
+ console.info('TestLog: Start Testing avSessionManager Interfaces');
+ })
+
+ beforeEach(function () {
+ console.info('TestLog: Start testing testcase');
+ })
+
+ afterEach(function () {
+ console.info('TestLog: End testing testcase');
+ })
+
+ afterAll(function () {
+ console.info('TestLog: End Testing avSessionManager Interfaces');
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_PROMISE_0100
+ * @tc.name : CREATEAVSESSION_0100
+ * @tc.desc : Testing createavSession with right parameter - promise
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level0
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_PROMISE_0100', 0, async function (done) {
+ await avSession.createAVSession(context, tag, type).then((data) => {
+ session = data;
+ if(session.sessionId.length === 64) {
+ console.info('TestLog: avSession create successfully');
+ expect(true).assertTrue();
+ }
+ else {
+ console.info('TestLog: avSession create failed');
+ expect(false).assertTrue();
+ }
+ }).catch((err) => {
+ console.info(`TestLog: avSession create error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ await session.destroy().then(() => {
+ console.info('TestLog: Session Destroy SUCCESS');
+ }).catch((err) => {
+ console.info(`TestLog: Session Destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_PROMISE_0200
+ * @tc.name : CREATEAVSESSION_0200
+ * @tc.desc : Testing createavSession with wrong type
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_PROMISE_0200', 0, async function (done) {
+ await avSession.createAVSession(context, tag, 'aaa').then((data) => {
+ console.info('TestLog: avSession create successfully');
+ }).catch((err) => {
+ console.info(`TestLog: avSession create error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_PROMISE_0300
+ * @tc.name : CREATEAVSESSION_0300
+ * @tc.desc : Testing createavSession with wrong parameter
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_PROMISE_0300', 0, async function (done) {
+ await avSession.createAVSession(context, '', type).then((data) => {
+ console.info('TestLog: avSession create successfully');
+ }).catch((err) => {
+ console.info(`TestLog: avSession create error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ });
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionManagerCallback.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionManagerCallback.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..6b7d37477e3e7a9ba977cc4f8dcb50073645f683
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionManagerCallback.test.js
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2022 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 avSession from '@ohos.multimedia.avsession';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
+import featureAbility from '@ohos.ability.featureAbility';
+
+export default function AVSessionManagerCallback() {
+ describe('AVSessionManagerCallback', function () {
+ let tag = 'ApplicationA';
+ let type = 'audio';
+ let context = featureAbility.getContext();
+
+ function sleep (ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+ }
+
+ beforeAll(function () {
+ console.info('TestLog: Start Testing AVSessionManager Interfaces');
+ })
+
+ beforeEach(function () {
+ console.info('TestLog: Start testing testcase');
+ })
+
+ afterEach(async function (done) {
+ console.info('TestLog: End testing testcase');
+ await sleep(1000);
+ done();
+ })
+
+ afterAll(function () {
+ console.info('TestLog: End Testing AVSessionManager Interfaces');
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_CALLBACK_0100
+ * @tc.name : CREATEAVSESSION_0100
+ * @tc.desc : Testing createAVSession with right parameter - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_CALLBACK_0100', 0, async function (done) {
+ let session;
+ avSession.createAVSession(context, tag, type, (err, value) => {
+ if (err) {
+ console.info(`TestLog: AVSession created error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue()
+ } else if (value.sessionId.length === 64){
+ session = value;
+ console.info(`TestLog: AVSession :${session.sessionId}created successfully`);
+ expect(true).assertTrue()
+ } else {
+ console.info('TestLog: AVSession created failed');
+ expect(false).assertTrue();
+ }
+ });
+ await sleep(500);
+ await session.destroy().then(() => {
+ console.info('TestLog: Session Destroy SUCCESS');
+ console.info(`TestLog: AVSession :${session.sessionId}destroyed successfully`);
+ }).catch((err) => {
+ console.info(`TestLog: Session Destroy error: code: ${err.code}, message: ${err.message}`);
+ expect(false).assertTrue();
+ });
+ done();
+ })
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_CALLBACK_0200
+ * @tc.name : CREATEAVSESSION_0200
+ * @tc.desc : Testing createAVSession with wrong type - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_CALLBACK_0200', 0, async function (done) {
+ avSession.createAVSession(context, tag, 'aaa', (err, data) => {
+ if (err) {
+ console.info(`TestLog: AVSession created error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: AVSession ${data.sessionId} created successfully`);
+ expect(false).assertTrue();
+ }
+ });
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_CALLBACK_0300
+ * @tc.name : CREATEAVSESSION_0300
+ * @tc.desc : Testing createAVSession with wrong parameter - callback
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level2
+ */
+ it('SUB_MULTIMEDIA_AVSESSION_CREATEAVSESSION_CALLBACK_0300', 0, async function (done) {
+ avSession.createAVSession(context, '', type, (err, data) => {
+ if (err) {
+ console.info(`TestLog: AVSession created error: code: ${err.code}, message: ${err.message}`);
+ expect(true).assertTrue();
+ } else {
+ console.info(`TestLog: AVSession ${data.sessionId} created successfully`);
+ expect(false).assertTrue();
+ }
+ done();
+ });
+ })
+ })
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/List.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..edc8fdb0bae09de2ac7dc7f3976f776f33a24472
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/List.test.js
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 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 AVSession from './AVSession.test.js';
+import AVSessionManager from './AVSessionManager.test.js';
+import AVSessionCallback from './AVSessionCallback.test.js';
+import AVSessionManagerCallback from './AVSessionManagerCallback.test.js';
+import AVSessionErrorCode from './AVSessionErrorCode.test';
+import AVSessionControllerJSTest from './AVSessionControllerJSTest.js';
+import AVSessionJSTest from './AVSessionJSTest.js';
+
+export default function testsuite() {
+ AVSession()
+ AVSessionManager()
+ AVSessionCallback()
+ AVSessionManagerCallback()
+ AVSessionErrorCode()
+ AVSessionJSTest ()
+ AVSessionControllerJSTest ()
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/resources/base/element/string.json b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..a623995ebcce57029cbc4c1ad45d9abf5649ef77
--- /dev/null
+++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainAbility_description",
+ "value": "JS_Empty Ability"
+ },
+ {
+ "name": "MainAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "MainAbility_label",
+ "value": "label"
+ },
+ {
+ "name": "TestAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "TestAbility_label",
+ "value": "label"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/resources/base/media/icon.png b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/resources/base/media/icon.png differ