1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http:// www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import avSession from '@ohos.multimedia.avsession'; 17import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'; 18import image from '@ohos.multimedia.image'; 19import ohosWantAgent from '@ohos.wantAgent'; 20import WantAgent from '@ohos.app.ability.wantAgent'; 21import featureAbility from '@ohos.ability.featureAbility'; 22 23export default function AVSession() { 24 describe('AVSession', function () { 25 let tag = 'ApplicationA'; 26 let type = 'audio'; 27 let session; 28 let controller; 29 let OutputDeviceInfo = { isRemote: false, audioDeviceId: [0], deviceName: ['LocalDevice'] }; 30 let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 }; 31 let event = { action: 2, key: keyItem, keys: [keyItem] }; 32 let context = featureAbility.getContext(); 33 let castControlCommandType = 'play'; 34 let deviceInfo = { 35 castCategory: 0, 36 deviceId: "deviceId", 37 deviceName: "deviceName", 38 } 39 let outputDeviceInfo = { 40 devices: [deviceInfo], 41 } 42 43 function sleep(ms) { 44 return new Promise(resolve => setTimeout(resolve, ms)); 45 } 46 47 async function init() { 48 await avSession.createAVSession(context, tag, type).then((data) => { 49 session = data; 50 session.sessionType = 'audio'; 51 }).catch((err) => { 52 console.info(`TestLog: Session create error: code: ${err.code}, message: ${err.message}`); 53 expect(false).assertTrue(); 54 }); 55 56 await session.activate().then(() => { 57 console.info('TestLog: Session activate'); 58 }).catch((err) => { 59 console.info(`TestLog: Session activate error: code: ${err.code}, message: ${err.message}`); 60 expect(false).assertTrue(); 61 }); 62 63 controller = await session.getController(); 64 } 65 66 async function destroy() { 67 await session.destroy().then(() => { 68 console.info('TestLog: Session destroy success'); 69 }).catch((err) => { 70 console.info(`TestLog: Session destroy error: code: ${err.code}, message: ${err.message}`); 71 expect(false).assertTrue(); 72 }); 73 await controller.destroy().then(() => { 74 console.info('TestLog: Controller destroy success'); 75 }).catch((err) => { 76 console.info(`TestLog: Controller destroy error: code: ${err.code}, message: ${err.message}`); 77 expect(false).assertTrue(); 78 }); 79 } 80 81 async function getPixelMap() { 82 let color = new ArrayBuffer(96); 83 let bufferArr = new Uint8Array(color); 84 bufferArr.fill('3', 0, 95); 85 let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, AlphaType: 3 }; 86 return image.createPixelMap(color, opts); 87 } 88 89 beforeAll(function () { 90 console.info('TestLog: Start Testing avSession Interfaces'); 91 }) 92 93 beforeEach(async function () { 94 console.info('TestLog: Init Session And Controller'); 95 await init() 96 }); 97 98 afterEach(async function (done) { 99 console.info('TestLog: Destroy Session And Controller'); 100 await destroy(); 101 done(); 102 }) 103 104 afterAll(function () { 105 console.info('TestLog: End Testing avSession Interfaces'); 106 }) 107 108 /* * 109 * @tc.number : SUB_MULTIMEDIA_AVSESSION_READ_SESSION_ID_0100 110 * @tc.name : read property sessionId of AVSession & Controler 111 * @tc.desc : Testing read property sessionId 112 * @tc.size : MediumTest 113 * @tc.type : Function 114 * @tc.level : Level2 115 */ 116 it('SUB_MULTIMEDIA_AVSESSION_READ_SESSION_ID_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 117 if (session.sessionId.length === 64 && controller.sessionId.length === 64) { 118 console.info('TestLog: Read AVSession & Controler sessionId successfully'); 119 expect(true).assertTrue(); 120 } else { 121 console.info('TestLog: Read sessionId failed'); 122 expect(false).assertTrue(); 123 } 124 done(); 125 }) 126 127 /* * 128 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100 129 * @tc.name : setAVMetadata - promise - set assetId 130 * @tc.desc : Testing call setAVMetadata(promise) set assetId 131 * @tc.size : MediumTest 132 * @tc.type : Function 133 * @tc.level : Level0 134 */ 135 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 136 let metadata0 = { 137 assetId: '121278', 138 }; 139 await session.setAVMetadata(metadata0).then(() => { 140 console.info('TestLog: Set assetId successfully'); 141 }).catch((err) => { 142 console.info(`TestLog: Set assetId error: code: ${err.code}, message: ${err.message}`); 143 expect(false).assertTrue(); 144 }); 145 146 await controller.getAVMetadata().then((data) => { 147 if (data.assetId === '121278') { 148 console.info('TestLog: Get assetId Successfully'); 149 expect(true).assertTrue(); 150 } else { 151 console.info('TestLog: Get assetId failed'); 152 console.info(`TestLog: assetId is: ${data.assetId}`); 153 expect(false).assertTrue(); 154 } 155 }).catch((err) => { 156 console.info(`TestLog: Get assetId error: code: ${err.code}, message: ${err.message}`); 157 expect(false).assertTrue(); 158 }); 159 done(); 160 }) 161 162 /* * 163 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0200 164 * @tc.name : setAVMetadata - promise - set artist 165 * @tc.desc : Testing call setAVMetadata(promise) set artist 166 * @tc.size : MediumTest 167 * @tc.type : Function 168 * @tc.level : Level2 169 */ 170 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 171 let metadata1 = { 172 assetId: '121278', 173 artist: 'Eminem', 174 }; 175 await session.setAVMetadata(metadata1).then(() => { 176 console.info('TestLog: Set artist successfully'); 177 }).catch((err) => { 178 console.info(`TestLog: Set artist error: code: ${err.code}, message: ${err.message}`); 179 expect(false).assertTrue(); 180 }); 181 182 await controller.getAVMetadata().then((data) => { 183 if (data.artist === metadata1.artist) { 184 expect(true).assertTrue(); 185 } else { 186 console.info('TestLog: Get artist failed'); 187 expect(false).assertTrue(); 188 } 189 }).catch((err) => { 190 console.info(`TestLog: Get artist error: code: ${err.code}, message: ${err.message}`); 191 expect(false).assertTrue(); 192 }); 193 done(); 194 }) 195 196 /* * 197 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0300 198 * @tc.name : setAVMetadata - promise - set author 199 * @tc.desc : Testing call setAVMetadata(promise) set author 200 * @tc.size : MediumTest 201 * @tc.type : Function 202 * @tc.level : Level2 203 */ 204 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 205 let metadata2 = { 206 assetId: '121278', 207 author: 'ST', 208 }; 209 await session.setAVMetadata(metadata2).then(() => { 210 console.info('TestLog: Set author successfully'); 211 }).catch((err) => { 212 console.info(`TestLog: Set author error: code: ${err.code}, message: ${err.message}`); 213 expect(false).assertTrue(); 214 }); 215 216 await controller.getAVMetadata().then((data) => { 217 if (data.author === metadata2.author) { 218 expect(true).assertTrue(); 219 } else { 220 console.info('TestLog: Get author failed'); 221 expect(false).assertTrue(); 222 } 223 }).catch((err) => { 224 console.info(`TestLog: Get author error: code: ${err.code}, message: ${err.message}`); 225 expect(false).assertTrue(); 226 }); 227 done(); 228 }) 229 230 /* * 231 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0400 232 * @tc.name : setAVMetadata - promise - set album 233 * @tc.desc : Testing call setAVMetadata(promise) set album 234 * @tc.size : MediumTest 235 * @tc.type : Function 236 * @tc.level : Level2 237 */ 238 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 239 let metadata3 = { 240 assetId: '121278', 241 album: 'Slim shady', 242 }; 243 await session.setAVMetadata(metadata3).then(() => { 244 console.info('TestLog: Set album successfully'); 245 }).catch((err) => { 246 console.info(`TestLog: Set album error: code: ${err.code}, message: ${err.message}`); 247 expect(false).assertTrue(); 248 }); 249 250 await controller.getAVMetadata().then((data) => { 251 if (data.album === metadata3.album) { 252 expect(true).assertTrue(); 253 } else { 254 console.info('TestLog: Get album failed'); 255 expect(false).assertTrue(); 256 } 257 }).catch((err) => { 258 console.info(`TestLog: Get album error: code: ${err.code}, message: ${err.message}`); 259 expect(false).assertTrue(); 260 }); 261 done(); 262 }) 263 264 /* * 265 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0500 266 * @tc.name : setAVMetadata - promise - set writer 267 * @tc.desc : Testing call setAVMetadata(promise) set writer 268 * @tc.size : MediumTest 269 * @tc.type : Function 270 * @tc.level : Level2 271 */ 272 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 273 let metadata4 = { 274 assetId: '121278', 275 writer: 'ST', 276 }; 277 await session.setAVMetadata(metadata4).then(() => { 278 console.info('TestLog: Set writer successfully'); 279 }).catch((err) => { 280 console.info(`TestLog: Set writer error: code: ${err.code}, message: ${err.message}`); 281 expect(false).assertTrue(); 282 }); 283 284 await controller.getAVMetadata().then((data) => { 285 if (data.writer === metadata4.writer) { 286 expect(true).assertTrue(); 287 } else { 288 console.info('TestLog: Get writer failed'); 289 expect(false).assertTrue(); 290 } 291 }).catch((err) => { 292 console.info(`TestLog: Get writer error: code: ${err.code}, message: ${err.message}`); 293 expect(false).assertTrue(); 294 }); 295 done(); 296 }) 297 298 /* * 299 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0600 300 * @tc.name : setAVMetadata - promise - set composer 301 * @tc.desc : Testing call setAVMetadata(promise) set composer 302 * @tc.size : MediumTest 303 * @tc.type : Function 304 * @tc.level : Level2 305 */ 306 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 307 let metadata5 = { 308 assetId: '121278', 309 composer: 'ST', 310 }; 311 await session.setAVMetadata(metadata5).then(() => { 312 console.info('TestLog: Set composer successfully'); 313 }).catch((err) => { 314 console.info(`TestLog: Set composer error: code: ${err.code}, message: ${err.message}`); 315 expect(false).assertTrue(); 316 }); 317 318 await controller.getAVMetadata().then((data) => { 319 if (data.composer === metadata5.composer) { 320 expect(true).assertTrue(); 321 } else { 322 console.info('TestLog: Get composer failed'); 323 expect(false).assertTrue(); 324 } 325 }).catch((err) => { 326 console.info(`TestLog: Get composer error: code: ${err.code}, message: ${err.message}`); 327 expect(false).assertTrue(); 328 }); 329 done(); 330 }) 331 332 /* * 333 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0700 334 * @tc.name : setAVMetadata - promise - set duration 335 * @tc.desc : Testing call setAVMetadata(promise) set duration 336 * @tc.size : MediumTest 337 * @tc.type : Function 338 * @tc.level : Level2 339 */ 340 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 341 let metadata6 = { 342 assetId: '121278', 343 duration: 2222, 344 }; 345 await session.setAVMetadata(metadata6).then(() => { 346 console.info('TestLog: Set duration successfully'); 347 }).catch((err) => { 348 console.info(`TestLog: Set duration error: code: ${err.code}, message: ${err.message}`); 349 expect(false).assertTrue(); 350 }); 351 352 await controller.getAVMetadata().then((data) => { 353 if (data.duration === metadata6.duration) { 354 expect(true).assertTrue(); 355 } else { 356 console.info('TestLog: Get duration failed'); 357 console.info(`TestLog: Get duration is: ${data.duration}`); 358 expect(false).assertTrue(); 359 } 360 }).catch((err) => { 361 console.info(`TestLog: Get duration error: code: ${err.code}, message: ${err.message}`); 362 expect(false).assertTrue(); 363 }); 364 done(); 365 }) 366 367 /* * 368 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0800 369 * @tc.name : setAVMetadata - promise - set mediaImage(url) 370 * @tc.desc : Testing call setAVMetadata(promise) set mediaImage(url) 371 * @tc.size : MediumTest 372 * @tc.type : Function 373 * @tc.level : Level2 374 */ 375 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 376 let metadata7 = { 377 assetId: '121278', 378 mediaImage: 'https://img2.baidu.com/it/u=3583435814,2833583486&fm=253&fmt=auto&app=138&f=JPEG?w=526&h=500', 379 }; 380 await session.setAVMetadata(metadata7).then(() => { 381 console.info('TestLog: Set mediaImage successfully'); 382 }).catch((err) => { 383 console.info(`TestLog: Set mediaImage error: code: ${err.code}, message: ${err.message}`); 384 expect(false).assertTrue(); 385 }); 386 387 await controller.getAVMetadata().then((data) => { 388 if (data.mediaImage === metadata7.mediaImage) { 389 expect(true).assertTrue(); 390 } else { 391 console.info('TestLog: Get mediaImage failed'); 392 expect(false).assertTrue(); 393 } 394 }).catch((err) => { 395 console.info(`TestLog: Get mediaImage error: code: ${err.code}, message: ${err.message}`); 396 expect(false).assertTrue(); 397 }); 398 done(); 399 }) 400 401 /* * 402 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0900 403 * @tc.name : setAVMetadata - promise - set mediaImage(pixelMap) 404 * @tc.desc : Testing call setAVMetadata(promise) set mediaImage(pixelMap) 405 * @tc.size : MediumTest 406 * @tc.type : Function 407 * @tc.level : Level2 408 */ 409 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 410 console.info('TestLog: Creat pixelmap'); 411 let pixelMap = await getPixelMap(); 412 let readBuffer0 = new ArrayBuffer(96); 413 await pixelMap.readPixelsToBuffer(readBuffer0); 414 let bufferArr0 = new Uint8Array(readBuffer0); 415 let metadata8 = { 416 assetId: '121278', 417 mediaImage: pixelMap, 418 }; 419 await session.setAVMetadata(metadata8).then(() => { 420 console.info('TestLog: Set pixelMap successfully'); 421 }).catch((err) => { 422 console.info(`TestLog: Set pixelMap error: code: ${err.code}, message: ${err.message}`); 423 expect(false).assertTrue(); 424 }); 425 let pixMap; 426 await controller.getAVMetadata().then((data) => { 427 if (data.assetId === '121278') { 428 pixMap = data.mediaImage; 429 } else { 430 console.info('TestLog: Get pixelMap failed'); 431 expect(false).assertTrue(); 432 } 433 }).catch((err) => { 434 console.info(`TestLog: Get pixelMap error: code: ${err.code}, message: ${err.message}`); 435 expect(false).assertTrue(); 436 }); 437 let pixelSize = pixMap.getPixelBytesNumber(); 438 console.info(`TestLog: pixelSize is: ${pixelSize}`); 439 let readBuffer = new ArrayBuffer(pixelSize); 440 await pixMap.readPixelsToBuffer(readBuffer); 441 let bufferArr2 = new Uint8Array(readBuffer); 442 for (let i = 0; i < bufferArr2.length; i++) { 443 if (bufferArr0[i] !== bufferArr2[i]) { 444 expect(false).assertTrue(); 445 } else { 446 expect(true).assertTrue(); 447 } 448 } 449 done(); 450 }) 451 452 /* * 453 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1000 454 * @tc.name : setAVMetadata - promise - set publishDate 455 * @tc.desc : Testing call setAVMetadata(promise) set publishDate 456 * @tc.size : MediumTest 457 * @tc.type : Function 458 * @tc.level : Level2 459 */ 460 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 461 let metadata9 = { 462 assetId: '121278', 463 publishDate: new Date(1994, 1, 1, 1), 464 }; 465 await session.setAVMetadata(metadata9).then(() => { 466 console.info('TestLog: Set publishDate successfully'); 467 }).catch((err) => { 468 console.info(`TestLog: Set publishDate error: code: ${err.code}, message: ${err.message}`); 469 expect(false).assertTrue(); 470 }); 471 472 await controller.getAVMetadata().then((data) => { 473 if (data.publishDate.getTime() === metadata9.publishDate.getTime()) { 474 expect(true).assertTrue(); 475 } else { 476 console.info('TestLog: Get publishDate failed'); 477 expect(false).assertTrue(); 478 } 479 }).catch((err) => { 480 console.info(`TestLog: Get publishDate error: code: ${err.code}, message: ${err.message}`); 481 expect(false).assertTrue(); 482 }); 483 done(); 484 }) 485 486 /* * 487 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1100 488 * @tc.name : setAVMetadata - promise - set subtitle 489 * @tc.desc : Testing call setAVMetadata(promise) set subtitle 490 * @tc.size : MediumTest 491 * @tc.type : Function 492 * @tc.level : Level2 493 */ 494 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 495 let metadata10 = { 496 assetId: '121278', 497 subtitle: '8 Mile', 498 }; 499 await session.setAVMetadata(metadata10).then(() => { 500 console.info('TestLog: Set subtitle successfully'); 501 }).catch((err) => { 502 console.info(`TestLog: Set subtitle error: code: ${err.code}, message: ${err.message}`); 503 expect(false).assertTrue(); 504 }); 505 506 await controller.getAVMetadata().then((data) => { 507 if (data.subtitle === metadata10.subtitle) { 508 expect(true).assertTrue(); 509 } else { 510 console.info('TestLog: Get subtitle failed'); 511 expect(false).assertTrue(); 512 } 513 }).catch((err) => { 514 console.info(`TestLog: Get subtitle error: code: ${err.code}, message: ${err.message}`); 515 expect(false).assertTrue(); 516 }); 517 done(); 518 }) 519 520 /* * 521 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1200 522 * @tc.name : setAVMetadata - promise - set description 523 * @tc.desc : Testing call setAVMetadata(promise) set description 524 * @tc.size : MediumTest 525 * @tc.type : Function 526 * @tc.level : Level2 527 */ 528 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 529 let metadata11 = { 530 assetId: '121278', 531 description: 'Rap', 532 }; 533 await session.setAVMetadata(metadata11).then(() => { 534 console.info('TestLog: Set description successfully'); 535 }).catch((err) => { 536 console.info(`TestLog: Set description error: code: ${err.code}, message: ${err.message}`); 537 expect(false).assertTrue(); 538 }); 539 540 await controller.getAVMetadata().then((data) => { 541 if (data.description === metadata11.description) { 542 expect(true).assertTrue(); 543 } else { 544 console.info('TestLog: Get description failed'); 545 expect(false).assertTrue(); 546 } 547 }).catch((err) => { 548 console.info(`TestLog: Get description error: code: ${err.code}, message: ${err.message}`); 549 expect(false).assertTrue(); 550 }); 551 done(); 552 }) 553 554 /* * 555 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1300 556 * @tc.name : setAVMetadata - promise - set lyric 557 * @tc.desc : Testing call setAVMetadata(promise) set lyric 558 * @tc.size : MediumTest 559 * @tc.type : Function 560 * @tc.level : Level2 561 */ 562 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 563 let metadata12 = { 564 assetId: '121278', 565 lyric: 'https://lyric.tingmall.com/lyric/58/970/589710004-LRC-LRC.lrc?t=1649918948000', 566 }; 567 await session.setAVMetadata(metadata12).then(() => { 568 console.info('TestLog: Set lyric successfully'); 569 }).catch((err) => { 570 console.info(`TestLog: Set lyric error: code: ${err.code}, message: ${err.message}`); 571 expect(false).assertTrue(); 572 }); 573 574 await controller.getAVMetadata().then((data) => { 575 if (data.lyric === metadata12.lyric) { 576 expect(true).assertTrue(); 577 } else { 578 console.info('TestLog: Get lyric failed'); 579 expect(false).assertTrue(); 580 } 581 }).catch((err) => { 582 console.info(`TestLog: Get lyric error: code: ${err.code}, message: ${err.message}`); 583 expect(false).assertTrue(); 584 }); 585 done(); 586 }) 587 588 /* * 589 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1400 590 * @tc.name : setAVMetadata - promise - set previousAssetId & nextAssetId 591 * @tc.desc : Testing call setAVMetadata(promise) set previousAssetId & nextAssetId 592 * @tc.size : MediumTest 593 * @tc.type : Function 594 * @tc.level : Level2 595 */ 596 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 597 let metadata13 = { 598 assetId: '121278', 599 previousAssetId: '121277', 600 nextAssetId: '121279', 601 }; 602 await session.setAVMetadata(metadata13).then(() => { 603 console.info('TestLog: Set assetId successfully'); 604 }).catch((err) => { 605 console.info(`TestLog: Set assetId error: code: ${err.code}, message: ${err.message}`); 606 expect(false).assertTrue(); 607 }); 608 609 await controller.getAVMetadata().then((data) => { 610 if (data.previousAssetId === metadata13.previousAssetId 611 && data.nextAssetId === metadata13.nextAssetId) { 612 expect(true).assertTrue(); 613 } else { 614 console.info('TestLog: Get assetId failed'); 615 expect(false).assertTrue(); 616 } 617 }).catch((err) => { 618 console.info(`TestLog: Get assetId error: code: ${err.code}, message: ${err.message}`); 619 expect(false).assertTrue(); 620 }); 621 done(); 622 }) 623 624 /* * 625 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1500 626 * @tc.name : setAVMetadata - promise - set filter(TYPE_CAST_PLUS_STREAM) 627 * @tc.desc : Testing call setAVMetadata(promise) set filter(TYPE_CAST_PLUS_STREAM) 628 * @tc.size : MediumTest 629 * @tc.type : Function 630 * @tc.level : Level2 631 */ 632 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 633 let metadata = { 634 assetId: '121278', 635 filter: avSession.ProtocolType.TYPE_CAST_PLUS_STREAM 636 }; 637 await session.setAVMetadata(metadata).then(() => { 638 console.info('TestLog: Set filter successfully'); 639 }).catch((err) => { 640 console.info(`TestLog: Set filter error: code: ${err.code}, message: ${err.message}`); 641 expect(false).assertTrue(); 642 }); 643 644 await controller.getAVMetadata().then((data) => { 645 if (data.filter === metadata.filter) { 646 expect(true).assertTrue(); 647 } else { 648 console.info('TestLog: Get filter failed'); 649 expect(false).assertTrue(); 650 } 651 }).catch((err) => { 652 console.info(`TestLog: Get filter error: code: ${err.code}, message: ${err.message}`); 653 expect(false).assertTrue(); 654 }); 655 done(); 656 }) 657 658 /* * 659 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1600 660 * @tc.name : setAVMetadata - promise - set filter(TYPE_LOCAL) 661 * @tc.desc : Testing call setAVMetadata(promise) set filter(TYPE_LOCAL) 662 * @tc.size : MediumTest 663 * @tc.type : Function 664 * @tc.level : Level2 665 */ 666 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 667 let metadata = { 668 assetId: '121278', 669 filter: avSession.ProtocolType.TYPE_LOCAL 670 }; 671 await session.setAVMetadata(metadata).then(() => { 672 console.info('TestLog: Set filter successfully'); 673 }).catch((err) => { 674 console.info(`TestLog: Set filter error: code: ${err.code}, message: ${err.message}`); 675 expect(false).assertTrue(); 676 }); 677 678 await controller.getAVMetadata().then((data) => { 679 if (data.filter === metadata.filter) { 680 expect(true).assertTrue(); 681 } else { 682 console.info('TestLog: Get filter failed'); 683 expect(false).assertTrue(); 684 } 685 }).catch((err) => { 686 console.info(`TestLog: Get filter error: code: ${err.code}, message: ${err.message}`); 687 expect(false).assertTrue(); 688 }); 689 done(); 690 }) 691 692 /* * 693 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1700 694 * @tc.name : setAVMetadata - promise - set filter(TYPE_CAST_PLUS_MIRROR) 695 * @tc.desc : Testing call setAVMetadata(promise) set filter(TYPE_CAST_PLUS_MIRROR) 696 * @tc.size : MediumTest 697 * @tc.type : Function 698 * @tc.level : Level2 699 */ 700 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 701 let metadata = { 702 assetId: '121278', 703 filter: avSession.ProtocolType.TYPE_CAST_PLUS_MIRROR 704 }; 705 await session.setAVMetadata(metadata).then(() => { 706 console.info('TestLog: Set filter successfully'); 707 }).catch((err) => { 708 console.info(`TestLog: Set filter error: code: ${err.code}, message: ${err.message}`); 709 expect(false).assertTrue(); 710 }); 711 712 await controller.getAVMetadata().then((data) => { 713 if (data.filter === metadata.filter) { 714 expect(true).assertTrue(); 715 } else { 716 console.info('TestLog: Get filter failed'); 717 expect(false).assertTrue(); 718 } 719 }).catch((err) => { 720 console.info(`TestLog: Get filter error: code: ${err.code}, message: ${err.message}`); 721 expect(false).assertTrue(); 722 }); 723 done(); 724 }) 725 726 /* * 727 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1800 728 * @tc.name : setAVMetadata - promise - set skipIntervals 729 * @tc.desc : Testing call setAVMetadata(promise) set skipIntervals 730 * @tc.size : MediumTest 731 * @tc.type : Function 732 * @tc.level : Level2 733 */ 734 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 735 let metadata = { 736 assetId: '121278', 737 skipIntervals: avSession.SkipIntervals.SECONDS_10 738 }; 739 await session.setAVMetadata(metadata).then(() => { 740 console.info('TestLog: Set skipIntervals successfully'); 741 }).catch((err) => { 742 console.info(`TestLog: Set skipIntervals error: code: ${err.code}, message: ${err.message}`); 743 expect(false).assertTrue(); 744 }); 745 746 await controller.getAVMetadata().then((data) => { 747 if (data.skipIntervals === metadata.skipIntervals) { 748 expect(true).assertTrue(); 749 } else { 750 console.info('TestLog: Get skipIntervals failed'); 751 expect(false).assertTrue(); 752 } 753 }).catch((err) => { 754 console.info(`TestLog: Get skipIntervals error: code: ${err.code}, message: ${err.message}`); 755 expect(false).assertTrue(); 756 }); 757 done(); 758 }) 759 760 /* * 761 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1900 762 * @tc.name : setAVMetadata - promise - set avQueueName、avQueueId、avQueueImage(pixelmap) 763 * @tc.desc : Testing call setAVMetadata(promise) set avQueueName、avQueueId、avQueueImage(pixelmap) 764 * @tc.size : MediumTest 765 * @tc.type : Function 766 * @tc.level : Level2 767 */ 768 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 769 console.info('TestLog: Creat pixelmap'); 770 let pixelMap = await getPixelMap(); 771 let readBuffer0 = new ArrayBuffer(96); 772 await pixelMap.readPixelsToBuffer(readBuffer0); 773 let bufferArr0 = new Uint8Array(readBuffer0); 774 let metadata = { 775 assetId: '121278', 776 avQueueName: '121278', 777 avQueueId: '121278', 778 avQueueImage: pixelMap 779 }; 780 await session.setAVMetadata(metadata).then(() => { 781 console.info('TestLog: Set avQueueName、avQueueId、avQueueImage successfully'); 782 }).catch((err) => { 783 console.info(`TestLog: Set avQueueName、avQueueId、avQueueImage error: code: ${err.code}, message: ${err.message}`); 784 expect(false).assertTrue(); 785 }); 786 let pixMap; 787 await controller.getAVMetadata().then((data) => { 788 if (data.assetId === '121278' && data.avQueueName === '121278' && data.avQueueId === '121278') { 789 pixMap = data.avQueueImage; 790 } else { 791 console.info('TestLog: getAVMetadata value error.'); 792 expect(false).assertTrue(); 793 } 794 }).catch((err) => { 795 console.info(`TestLog: getAVMetadata error: code: ${err.code}, message: ${err.message}`); 796 expect(false).assertTrue(); 797 }); 798 if (pixMap) { 799 let pixelSize = pixMap.getPixelBytesNumber(); 800 console.info(`TestLog: pixelSize is: ${pixelSize}`); 801 let readBuffer = new ArrayBuffer(pixelSize); 802 await pixMap.readPixelsToBuffer(readBuffer); 803 let bufferArr2 = new Uint8Array(readBuffer); 804 for (let i = 0; i < bufferArr2.length; i++) { 805 if (bufferArr0[i] !== bufferArr2[i]) { 806 expect(false).assertTrue(); 807 } else { 808 expect(true).assertTrue(); 809 } 810 } 811 } 812 done(); 813 }) 814 815 /* * 816 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2000 817 * @tc.name : setAVMetadata - promise - set avQueueName、avQueueId、avQueueImage(string) 818 * @tc.desc : Testing call setAVMetadata(promise) set avQueueName、avQueueId、avQueueImage(string) 819 * @tc.size : MediumTest 820 * @tc.type : Function 821 * @tc.level : Level2 822 */ 823 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 824 let metadata = { 825 assetId: '121278', 826 avQueueName: '121278', 827 avQueueId: '121278', 828 avQueueImage: 'https://img2.baidu.com/it/u=3583435814,2833583486&fm=253&fmt=auto&app=138&f=JPEG?w=526&h=500' 829 }; 830 await session.setAVMetadata(metadata).then(() => { 831 console.info('TestLog: Set avQueueName、avQueueId、avQueueImage successfully'); 832 }).catch((err) => { 833 console.info(`TestLog: Set avQueueName、avQueueId、avQueueImage error: code: ${err.code}, message: ${err.message}`); 834 expect(false).assertTrue(); 835 }); 836 await controller.getAVMetadata().then((data) => { 837 if (data) { 838 expect(data.assetId).assertEqual(metadata.assetId); 839 expect(data.avQueueName).assertEqual(metadata.avQueueName); 840 expect(data.avQueueId).assertEqual(metadata.avQueueId); 841 expect(data.avQueueImage).assertEqual(metadata.avQueueImage); 842 } else { 843 console.info('TestLog: getAVMetadata failed.'); 844 expect(false).assertTrue(); 845 } 846 }).catch((err) => { 847 console.info(`TestLog: getAVMetadata error: code: ${err.code}, message: ${err.message}`); 848 expect(false).assertTrue(); 849 }); 850 done(); 851 }) 852 853 /* * 854 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2100 855 * @tc.name : setAVMetadata - promise - set displayTags 856 * @tc.desc : Testing call setAVMetadata(promise) set displayTags 857 * @tc.size : MediumTest 858 * @tc.type : Function 859 * @tc.level : Level2 860 */ 861 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 862 let metadata = { 863 assetId: '121278', 864 displayTags: avSession.DisplayTag.TAG_AUDIO_VIVID 865 }; 866 await session.setAVMetadata(metadata).then(() => { 867 console.info('TestLog: Set displayTags successfully'); 868 }).catch((err) => { 869 console.info(`TestLog: Set displayTags error: code: ${err.code}, message: ${err.message}`); 870 expect(false).assertTrue(); 871 }); 872 await controller.getAVMetadata().then((data) => { 873 if (data) { 874 expect(data.assetId).assertEqual(metadata.assetId); 875 expect(data.displayTags).assertEqual(metadata.displayTags); 876 } else { 877 console.info('TestLog: getAVMetadata failed.'); 878 expect(false).assertTrue(); 879 } 880 }).catch((err) => { 881 console.info(`TestLog: getAVMetadata error: code: ${err.code}, message: ${err.message}`); 882 expect(false).assertTrue(); 883 }); 884 done(); 885 }) 886 887 /* * 888 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0100 889 * @tc.name : setAVPlaybackState - promise - set state & activeItemId 890 * @tc.desc : Testing call setAVPlaybackState(promise) set state & activeItemId 891 * @tc.size : MediumTest 892 * @tc.type : Function 893 * @tc.level : Level0 894 */ 895 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 896 let PlaybackState1 = { 897 state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, 898 activeItemId: 0, 899 }; 900 await session.setAVPlaybackState(PlaybackState1).then(() => { 901 console.info('TestLog: Set State successfully'); 902 }).catch((err) => { 903 console.info(`TestLog: Set State error: code: ${err.code}, message: ${err.message}`); 904 expect(false).assertTrue(); 905 }); 906 907 await controller.getAVPlaybackState().then((data) => { 908 if (data.state === 2) { 909 console.info('TestLog: Get State successfully'); 910 expect(true).assertTrue(); 911 } else { 912 console.info('TestLog: Get State failed'); 913 expect(false).assertTrue(); 914 } 915 }).catch((err) => { 916 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 917 expect(false).assertTrue(); 918 }); 919 done(); 920 }) 921 922 /* * 923 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0200 924 * @tc.name : setAVPlaybackState - promise - set speed 925 * @tc.desc : Testing call setAVPlaybackState(promise) set speed 926 * @tc.size : MediumTest 927 * @tc.type : Function 928 * @tc.level : Level2 929 */ 930 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 931 let PlaybackState2 = { 932 speed: 2.6, 933 }; 934 935 await session.setAVPlaybackState(PlaybackState2).then(() => { 936 console.info('TestLog: Set speed successfully'); 937 }).catch((err) => { 938 console.info(`TestLog: Set speed error: code: ${err.code}, message: ${err.message}`); 939 expect(false).assertTrue(); 940 }); 941 942 await controller.getAVPlaybackState().then((data) => { 943 if (data.speed === 2.6) { 944 console.info('TestLog: Get speed successfully'); 945 expect(true).assertTrue(); 946 } else { 947 console.info('TestLog: Get speed failed'); 948 expect(false).assertTrue(); 949 } 950 }).catch((err) => { 951 console.info(`TestLog: Get speed error: code: ${err.code}, message: ${err.message}`); 952 expect(false).assertTrue(); 953 }); 954 done(); 955 }) 956 957 /* * 958 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0300 959 * @tc.name : setAVPlaybackState - promise - set position 960 * @tc.desc : Testing call setAVPlaybackState(promise) set position 961 * @tc.size : MediumTest 962 * @tc.type : Function 963 * @tc.level : Level2 964 */ 965 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 966 let PlaybackState3 = { 967 position: { elapsedTime: 10, updateTime: (new Date()).getTime() }, 968 }; 969 970 await session.setAVPlaybackState(PlaybackState3).then(() => { 971 console.info('TestLog: Set position successfully'); 972 }).catch((err) => { 973 console.info(`TestLog: Set position error: code: ${err.code}, message: ${err.message}`); 974 expect(false).assertTrue(); 975 }); 976 977 await controller.getAVPlaybackState().then((data) => { 978 if (data.position.elapsedTime === 10) { 979 console.info('TestLog: Get position successfully'); 980 expect(true).assertTrue(); 981 } else { 982 console.info('TestLog: Get position failed'); 983 expect(false).assertTrue(); 984 } 985 }).catch((err) => { 986 console.info(`TestLog: Get position error: code: ${err.code}, message: ${err.message}`); 987 expect(false).assertTrue(); 988 }); 989 done(); 990 }) 991 992 /* * 993 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0400 994 * @tc.name : setAVPlaybackState - promise - set bufferedTime 995 * @tc.desc : Testing call setAVPlaybackState(promise) set bufferedTime 996 * @tc.size : MediumTest 997 * @tc.type : Function 998 * @tc.level : Level2 999 */ 1000 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1001 let PlaybackState4 = { 1002 bufferedTime: 1000, 1003 }; 1004 1005 await session.setAVPlaybackState(PlaybackState4).then(() => { 1006 console.info('TestLog: Set bufferedTime successfully'); 1007 }).catch((err) => { 1008 console.info(`TestLog: Set bufferedTime error: code: ${err.code}, message: ${err.message}`); 1009 expect(false).assertTrue(); 1010 }); 1011 1012 await controller.getAVPlaybackState().then((data) => { 1013 if (data.bufferedTime === 1000) { 1014 console.info('TestLog: Get bufferedTime successfully'); 1015 expect(true).assertTrue(); 1016 } else { 1017 console.info('TestLog: Get bufferedTime failed'); 1018 expect(false).assertTrue(); 1019 } 1020 }).catch((err) => { 1021 console.info(`TestLog: Get bufferedTime error: code: ${err.code}, message: ${err.message}`); 1022 expect(false).assertTrue(); 1023 }); 1024 done(); 1025 }) 1026 1027 /* * 1028 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0500 1029 * @tc.name : setAVPlaybackState - promise - set loopMode(LOOP_MODE_SEQUENCE) 1030 * @tc.desc : Testing call setAVPlaybackState(promise) set loopMode(LOOP_MODE_SEQUENCE) 1031 * @tc.size : MediumTest 1032 * @tc.type : Function 1033 * @tc.level : Level2 1034 */ 1035 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1036 let PlaybackState5 = { 1037 loopMode: avSession.LoopMode.LOOP_MODE_SEQUENCE, 1038 }; 1039 1040 await session.setAVPlaybackState(PlaybackState5).then(() => { 1041 console.info('TestLog: Set loopMode successfully'); 1042 }).catch((err) => { 1043 console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`); 1044 expect(false).assertTrue(); 1045 }); 1046 1047 await controller.getAVPlaybackState().then((data) => { 1048 if (data.loopMode === 0) { 1049 console.info('TestLog: Get loopMode successfully'); 1050 expect(true).assertTrue(); 1051 } else { 1052 console.info('TestLog: Get loopMode failed'); 1053 expect(false).assertTrue(); 1054 } 1055 }).catch((err) => { 1056 console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`); 1057 expect(false).assertTrue(); 1058 }); 1059 done(); 1060 }) 1061 1062 /* * 1063 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0600 1064 * @tc.name : setAVPlaybackState - promise - set loopMode(LOOP_MODE_SINGLE) 1065 * @tc.desc : Testing call setAVPlaybackState(promise) set loopMode(LOOP_MODE_SINGLE) 1066 * @tc.size : MediumTest 1067 * @tc.type : Function 1068 * @tc.level : Level2 1069 */ 1070 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1071 let PlaybackState6 = { 1072 loopMode: avSession.LoopMode.LOOP_MODE_SINGLE, 1073 }; 1074 1075 await session.setAVPlaybackState(PlaybackState6).then(() => { 1076 console.info('TestLog: Set loopMode successfully'); 1077 }).catch((err) => { 1078 console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`); 1079 expect(false).assertTrue(); 1080 }); 1081 1082 await controller.getAVPlaybackState().then((data) => { 1083 if (data.loopMode === 1) { 1084 console.info('TestLog: Get loopMode successfully'); 1085 expect(true).assertTrue(); 1086 } else { 1087 console.info('TestLog: Get loopMode failed'); 1088 expect(false).assertTrue(); 1089 } 1090 }).catch((err) => { 1091 console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`); 1092 expect(false).assertTrue(); 1093 }); 1094 done(); 1095 }) 1096 1097 /* * 1098 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0700 1099 * @tc.name : setAVPlaybackState - promise - set loopMode(LOOP_MODE_LIST) 1100 * @tc.desc : Testing call setAVPlaybackState(promise) set loopMode(LOOP_MODE_LIST) 1101 * @tc.size : MediumTest 1102 * @tc.type : Function 1103 * @tc.level : Level2 1104 */ 1105 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1106 let PlaybackState7 = { 1107 loopMode: avSession.LoopMode.LOOP_MODE_LIST, 1108 }; 1109 1110 await session.setAVPlaybackState(PlaybackState7).then(() => { 1111 console.info('TestLog: Set loopMode successfully'); 1112 }).catch((err) => { 1113 console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`); 1114 expect(false).assertTrue(); 1115 }); 1116 1117 await controller.getAVPlaybackState().then((data) => { 1118 if (data.loopMode === 2) { 1119 console.info('TestLog: Get loopMode successfully'); 1120 expect(true).assertTrue(); 1121 } else { 1122 console.info('TestLog: Get loopMode failed'); 1123 expect(false).assertTrue(); 1124 } 1125 }).catch((err) => { 1126 console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`); 1127 expect(false).assertTrue(); 1128 }); 1129 done(); 1130 }) 1131 1132 /* * 1133 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0800 1134 * @tc.name : setAVPlaybackState - promise - set loopMode(LOOP_MODE_SHUFFLE) 1135 * @tc.desc : Testing call setAVPlaybackState(promise) set loopMode(LOOP_MODE_SHUFFLE) 1136 * @tc.size : MediumTest 1137 * @tc.type : Function 1138 * @tc.level : Level2 1139 */ 1140 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1141 let PlaybackState8 = { 1142 loopMode: avSession.LoopMode.LOOP_MODE_SHUFFLE, 1143 }; 1144 1145 await session.setAVPlaybackState(PlaybackState8).then(() => { 1146 console.info('TestLog: Set loopMode successfully'); 1147 }).catch((err) => { 1148 console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`); 1149 expect(false).assertTrue(); 1150 }); 1151 1152 await controller.getAVPlaybackState().then((data) => { 1153 if (data.loopMode === 3) { 1154 console.info('TestLog: Get loopMode successfully'); 1155 expect(true).assertTrue(); 1156 } else { 1157 console.info('TestLog: Get loopMode failed'); 1158 expect(false).assertTrue(); 1159 } 1160 }).catch((err) => { 1161 console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`); 1162 expect(false).assertTrue(); 1163 }); 1164 done(); 1165 }) 1166 1167 /* * 1168 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0900 1169 * @tc.name : setAVPlaybackState - promise - set isFavorite 1170 * @tc.desc : Testing call setAVPlaybackState(promise) set isFavorite 1171 * @tc.size : MediumTest 1172 * @tc.type : Function 1173 * @tc.level : Level2 1174 */ 1175 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1176 let PlaybackState9 = { 1177 isFavorite: true, 1178 }; 1179 1180 await session.setAVPlaybackState(PlaybackState9).then(() => { 1181 console.info('TestLog: Set isFavorite successfully'); 1182 }).catch((err) => { 1183 console.info(`TestLog: Set isFavorite error: code: ${err.code}, message: ${err.message}`); 1184 expect(false).assertTrue(); 1185 }); 1186 1187 await controller.getAVPlaybackState().then((data) => { 1188 if (data.isFavorite === true) { 1189 console.info('TestLog: Get isFavorite successfully'); 1190 expect(true).assertTrue(); 1191 } else { 1192 console.info('TestLog: Get isFavorite failed'); 1193 expect(false).assertTrue(); 1194 } 1195 }).catch((err) => { 1196 console.info(`TestLog: Get isFavorite error: code: ${err.code}, message: ${err.message}`); 1197 expect(false).assertTrue(); 1198 }); 1199 done(); 1200 }) 1201 1202 /* * 1203 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1000 1204 * @tc.name : setAVPlaybackState - promise - set state(PLAYBACK_STATE_INITIAL) 1205 * @tc.desc : Testing call setAVPlaybackState(promise) set state(PLAYBACK_STATE_INITIAL) 1206 * @tc.size : MediumTest 1207 * @tc.type : Function 1208 * @tc.level : Level2 1209 */ 1210 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1211 let PlaybackState12 = { 1212 state: avSession.PlaybackState.PLAYBACK_STATE_INITIAL, 1213 }; 1214 await session.setAVPlaybackState(PlaybackState12).then(() => { 1215 console.info('TestLog: Set playbackState successfully'); 1216 expect(true).assertTrue(); 1217 }).catch((err) => { 1218 console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); 1219 expect(false).assertTrue(); 1220 }); 1221 1222 await controller.getAVPlaybackState().then((data) => { 1223 if (data.state === 0) { 1224 console.info('TestLog: Get State successfully'); 1225 expect(true).assertTrue(); 1226 } else { 1227 console.info('TestLog: Get State failed'); 1228 expect(false).assertTrue(); 1229 } 1230 }).catch((err) => { 1231 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 1232 expect(false).assertTrue(); 1233 }); 1234 done(); 1235 }) 1236 1237 /* * 1238 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1100 1239 * @tc.name : setAVPlaybackState - promise - set state(PLAYBACK_STATE_PREPARE) 1240 * @tc.desc : Testing call setAVPlaybackState(promise) set state(PLAYBACK_STATE_PREPARE) 1241 * @tc.size : MediumTest 1242 * @tc.type : Function 1243 * @tc.level : Level2 1244 */ 1245 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1246 let PlaybackState13 = { 1247 state: avSession.PlaybackState.PLAYBACK_STATE_PREPARE, 1248 }; 1249 await session.setAVPlaybackState(PlaybackState13).then(() => { 1250 console.info('TestLog: Set playbackState successfully'); 1251 expect(true).assertTrue(); 1252 }).catch((err) => { 1253 console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); 1254 expect(false).assertTrue(); 1255 }); 1256 1257 await controller.getAVPlaybackState().then((data) => { 1258 if (data.state === 1) { 1259 console.info('TestLog: Get State successfully'); 1260 expect(true).assertTrue(); 1261 } else { 1262 console.info('TestLog: Get State failed'); 1263 expect(false).assertTrue(); 1264 } 1265 }).catch((err) => { 1266 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 1267 expect(false).assertTrue(); 1268 }); 1269 done(); 1270 }) 1271 1272 /* * 1273 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1200 1274 * @tc.name : setAVPlaybackState - promise - set state(PLAYBACK_STATE_PAUSE) 1275 * @tc.desc : Testing call setAVPlaybackState(promise) set state(PLAYBACK_STATE_PAUSE) 1276 * @tc.size : MediumTest 1277 * @tc.type : Function 1278 * @tc.level : Level2 1279 */ 1280 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1281 let PlaybackState14 = { 1282 state: avSession.PlaybackState.PLAYBACK_STATE_PAUSE, 1283 }; 1284 await session.setAVPlaybackState(PlaybackState14).then(() => { 1285 console.info('TestLog: Set playbackState successfully'); 1286 expect(true).assertTrue(); 1287 }).catch((err) => { 1288 console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); 1289 expect(false).assertTrue(); 1290 }); 1291 1292 await controller.getAVPlaybackState().then((data) => { 1293 if (data.state === 3) { 1294 console.info('TestLog: Get State successfully'); 1295 expect(true).assertTrue(); 1296 } else { 1297 console.info('TestLog: Get State failed'); 1298 expect(false).assertTrue(); 1299 } 1300 }).catch((err) => { 1301 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 1302 expect(false).assertTrue(); 1303 }); 1304 done(); 1305 }) 1306 1307 /* * 1308 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1300 1309 * @tc.name : setAVPlaybackState - promise - set state(PLAYBACK_STATE_FAST_FORWARD) 1310 * @tc.desc : Testing call setAVPlaybackState(promise) set state(PLAYBACK_STATE_FAST_FORWARD) 1311 * @tc.size : MediumTest 1312 * @tc.type : Function 1313 * @tc.level : Level2 1314 */ 1315 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1316 let PlaybackState15 = { 1317 state: avSession.PlaybackState.PLAYBACK_STATE_FAST_FORWARD, 1318 }; 1319 await session.setAVPlaybackState(PlaybackState15).then(() => { 1320 console.info('TestLog: Set playbackState successfully'); 1321 expect(true).assertTrue(); 1322 }).catch((err) => { 1323 console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); 1324 expect(false).assertTrue(); 1325 }); 1326 1327 await controller.getAVPlaybackState().then((data) => { 1328 if (data.state === 4) { 1329 console.info('TestLog: Get State successfully'); 1330 expect(true).assertTrue(); 1331 } else { 1332 console.info('TestLog: Get State failed'); 1333 expect(false).assertTrue(); 1334 } 1335 }).catch((err) => { 1336 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 1337 expect(false).assertTrue(); 1338 }); 1339 done(); 1340 }) 1341 1342 /* * 1343 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1400 1344 * @tc.name : setAVPlaybackState - promise - set state(PLAYBACK_STATE_REWIND) 1345 * @tc.desc : Testing call setAVPlaybackState(promise) set state(PLAYBACK_STATE_REWIND) 1346 * @tc.size : MediumTest 1347 * @tc.type : Function 1348 * @tc.level : Level2 1349 */ 1350 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1351 let PlaybackState16 = { 1352 state: avSession.PlaybackState.PLAYBACK_STATE_REWIND, 1353 }; 1354 await session.setAVPlaybackState(PlaybackState16).then(() => { 1355 console.info('TestLog: Set playbackState successfully'); 1356 expect(true).assertTrue(); 1357 }).catch((err) => { 1358 console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); 1359 expect(false).assertTrue(); 1360 }); 1361 1362 await controller.getAVPlaybackState().then((data) => { 1363 if (data.state === 5) { 1364 console.info('TestLog: Get State successfully'); 1365 expect(true).assertTrue(); 1366 } else { 1367 console.info('TestLog: Get State failed'); 1368 expect(false).assertTrue(); 1369 } 1370 }).catch((err) => { 1371 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 1372 expect(false).assertTrue(); 1373 }); 1374 done(); 1375 }) 1376 1377 /* * 1378 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1500 1379 * @tc.name : setAVPlaybackState - promise - set state(PLAYBACK_STATE_STOP) 1380 * @tc.desc : Testing call setAVPlaybackState(promise) set state(PLAYBACK_STATE_STOP) 1381 * @tc.size : MediumTest 1382 * @tc.type : Function 1383 * @tc.level : Level2 1384 */ 1385 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1386 let PlaybackState17 = { 1387 state: avSession.PlaybackState.PLAYBACK_STATE_STOP, 1388 }; 1389 await session.setAVPlaybackState(PlaybackState17).then(() => { 1390 console.info('TestLog: Set playbackState successfully'); 1391 expect(true).assertTrue(); 1392 }).catch((err) => { 1393 console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); 1394 expect(false).assertTrue(); 1395 }); 1396 1397 await controller.getAVPlaybackState().then((data) => { 1398 if (data.state === 6) { 1399 console.info('TestLog: Get State successfully'); 1400 expect(true).assertTrue(); 1401 } else { 1402 console.info('TestLog: Get State failed'); 1403 expect(false).assertTrue(); 1404 } 1405 }).catch((err) => { 1406 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 1407 expect(false).assertTrue(); 1408 }); 1409 done(); 1410 }) 1411 1412 /* * 1413 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1600 1414 * @tc.name : setAVPlaybackState - promise - set state(PLAYBACK_STATE_IDLE) 1415 * @tc.desc : Testing call setAVPlaybackState(promise) set state(PLAYBACK_STATE_IDLE) 1416 * @tc.size : MediumTest 1417 * @tc.type : Function 1418 * @tc.level : Level2 1419 */ 1420 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1421 let PlaybackState18 = { 1422 state: avSession.PlaybackState.PLAYBACK_STATE_IDLE, 1423 }; 1424 await session.setAVPlaybackState(PlaybackState18).then(() => { 1425 console.info('TestLog: Set playbackState successfully'); 1426 expect(true).assertTrue(); 1427 }).catch((err) => { 1428 console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); 1429 expect(false).assertTrue(); 1430 }); 1431 await controller.getAVPlaybackState().then((data) => { 1432 if (data.state === 10) { 1433 console.info('TestLog: Get State successfully'); 1434 expect(true).assertTrue(); 1435 } else { 1436 console.info('TestLog: Get State failed'); 1437 expect(false).assertTrue(); 1438 } 1439 }).catch((err) => { 1440 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 1441 expect(false).assertTrue(); 1442 }); 1443 done(); 1444 }) 1445 1446 /* * 1447 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1700 1448 * @tc.name : setAVPlaybackState - promise - set state(PLAYBACK_STATE_BUFFERING) 1449 * @tc.desc : Testing call setAVPlaybackState(promise) set state(PLAYBACK_STATE_BUFFERING) 1450 * @tc.size : MediumTest 1451 * @tc.type : Function 1452 * @tc.level : Level2 1453 */ 1454 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1455 let playbackState = { 1456 state: avSession.PlaybackState.PLAYBACK_STATE_BUFFERING, 1457 }; 1458 await session.setAVPlaybackState(playbackState).then(() => { 1459 console.info('TestLog: Set playbackState successfully'); 1460 expect(true).assertTrue(); 1461 }).catch((err) => { 1462 console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); 1463 expect(false).assertTrue(); 1464 }); 1465 await controller.getAVPlaybackState().then((data) => { 1466 if (data.state === 11) { 1467 console.info('TestLog: Get State successfully'); 1468 expect(true).assertTrue(); 1469 } else { 1470 console.info('TestLog: Get State failed'); 1471 expect(false).assertTrue(); 1472 } 1473 }).catch((err) => { 1474 console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); 1475 expect(false).assertTrue(); 1476 }); 1477 done(); 1478 }) 1479 1480 /* * 1481 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1800 1482 * @tc.name : setAVPlaybackState - promise - set loopMode(LOOP_MODE_CUSTOM) 1483 * @tc.desc : Testing call setAVPlaybackState(promise) set loopMode(LOOP_MODE_CUSTOM) 1484 * @tc.size : MediumTest 1485 * @tc.type : Function 1486 * @tc.level : Level2 1487 */ 1488 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1489 let PlaybackState5 = { 1490 loopMode: avSession.LoopMode.LOOP_MODE_CUSTOM, 1491 }; 1492 1493 await session.setAVPlaybackState(PlaybackState5).then(() => { 1494 console.info('TestLog: Set loopMode successfully'); 1495 }).catch((err) => { 1496 console.info(`TestLog: Set loopMode error: code: ${err.code}, message: ${err.message}`); 1497 expect(false).assertTrue(); 1498 }); 1499 1500 await controller.getAVPlaybackState().then((data) => { 1501 if (data.loopMode === 4) { 1502 console.info('TestLog: Get loopMode successfully'); 1503 expect(true).assertTrue(); 1504 } else { 1505 console.info('TestLog: Get loopMode failed'); 1506 expect(false).assertTrue(); 1507 } 1508 }).catch((err) => { 1509 console.info(`TestLog: Get loopMode error: code: ${err.code}, message: ${err.message}`); 1510 expect(false).assertTrue(); 1511 }); 1512 done(); 1513 }) 1514 1515 /* * 1516 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1900 1517 * @tc.name : setAVPlaybackState - promise - set maxVolume 1518 * @tc.desc : Testing call setAVPlaybackState(promise) set maxVolume 1519 * @tc.size : MediumTest 1520 * @tc.type : Function 1521 * @tc.level : Level2 1522 */ 1523 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1524 let PlaybackState = { 1525 maxVolume: 6 1526 }; 1527 1528 await session.setAVPlaybackState(PlaybackState).then(() => { 1529 console.info('TestLog: Set maxVolume successfully'); 1530 }).catch((err) => { 1531 console.info(`TestLog: Set maxVolume error: code: ${err.code}, message: ${err.message}`); 1532 expect(false).assertTrue(); 1533 }); 1534 1535 await controller.getAVPlaybackState().then((data) => { 1536 if (data.maxVolume === PlaybackState.maxVolume) { 1537 console.info('TestLog: Get maxVolume successfully'); 1538 expect(true).assertTrue(); 1539 } else { 1540 console.info('TestLog: Get maxVolume failed'); 1541 expect(false).assertTrue(); 1542 } 1543 }).catch((err) => { 1544 console.info(`TestLog: Get maxVolume error: code: ${err.code}, message: ${err.message}`); 1545 expect(false).assertTrue(); 1546 }); 1547 done(); 1548 }) 1549 1550 /* * 1551 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_2000 1552 * @tc.name : setAVPlaybackState - promise - set muted 1553 * @tc.desc : Testing call setAVPlaybackState(promise) set muted 1554 * @tc.size : MediumTest 1555 * @tc.type : Function 1556 * @tc.level : Level2 1557 */ 1558 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_2000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1559 let PlaybackState = { 1560 muted: false 1561 }; 1562 1563 await session.setAVPlaybackState(PlaybackState).then(() => { 1564 console.info('TestLog: Set muted successfully'); 1565 }).catch((err) => { 1566 console.info(`TestLog: Set muted error: code: ${err.code}, message: ${err.message}`); 1567 expect(false).assertTrue(); 1568 }); 1569 1570 await controller.getAVPlaybackState().then((data) => { 1571 if (data.muted === PlaybackState.muted) { 1572 console.info('TestLog: Get muted successfully'); 1573 expect(true).assertTrue(); 1574 } else { 1575 console.info('TestLog: Get muted failed'); 1576 expect(false).assertTrue(); 1577 } 1578 }).catch((err) => { 1579 console.info(`TestLog: Get muted error: code: ${err.code}, message: ${err.message}`); 1580 expect(false).assertTrue(); 1581 }); 1582 done(); 1583 }) 1584 1585 /* * 1586 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_2100 1587 * @tc.name : setAVPlaybackState - promise - set videoWidth & videoHeight 1588 * @tc.desc : Testing call setAVPlaybackState(promise) set videoWidth & videoHeight 1589 * @tc.size : MediumTest 1590 * @tc.type : Function 1591 * @tc.level : Level2 1592 */ 1593 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_2100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1594 let PlaybackState = { 1595 videoWidth: 1920, 1596 videoHeight: 1080 1597 }; 1598 1599 await session.setAVPlaybackState(PlaybackState).then(() => { 1600 console.info('TestLog: Set videoWidth & videoHeight successfully'); 1601 }).catch((err) => { 1602 console.info(`TestLog: Set videoWidth & videoHeight error: code: ${err.code}, message: ${err.message}`); 1603 expect(false).assertTrue(); 1604 }); 1605 1606 await controller.getAVPlaybackState().then((data) => { 1607 if (data.videoWidth === PlaybackState.videoWidth && data.videoHeight === PlaybackState.videoHeight) { 1608 console.info('TestLog: Get videoWidth & videoHeight successfully'); 1609 expect(true).assertTrue(); 1610 } else { 1611 console.info('TestLog: Get videoWidth & videoHeight failed'); 1612 expect(false).assertTrue(); 1613 } 1614 }).catch((err) => { 1615 console.info(`TestLog: Get videoWidth & videoHeight error: code: ${err.code}, message: ${err.message}`); 1616 expect(false).assertTrue(); 1617 }); 1618 done(); 1619 }) 1620 1621 /* * 1622 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_2200 1623 * @tc.name : setAVPlaybackState - promise - set duration 1624 * @tc.desc : Testing call setAVPlaybackState(promise) set duration 1625 * @tc.size : MediumTest 1626 * @tc.type : Function 1627 * @tc.level : Level2 1628 */ 1629 it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_2200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1630 let PlaybackState = { 1631 duration: 100 1632 }; 1633 1634 await session.setAVPlaybackState(PlaybackState).then(() => { 1635 console.info('TestLog: Set duration successfully'); 1636 }).catch((err) => { 1637 console.info(`TestLog: Set duration error: code: ${err.code}, message: ${err.message}`); 1638 expect(false).assertTrue(); 1639 }); 1640 1641 await controller.getAVPlaybackState().then((data) => { 1642 if (data.duration === PlaybackState.duration) { 1643 console.info('TestLog: Get duration successfully'); 1644 expect(true).assertTrue(); 1645 } else { 1646 console.info('TestLog: Get duration failed'); 1647 expect(false).assertTrue(); 1648 } 1649 }).catch((err) => { 1650 console.info(`TestLog: Get duration error: code: ${err.code}, message: ${err.message}`); 1651 expect(false).assertTrue(); 1652 }); 1653 done(); 1654 }) 1655 1656 /* * 1657 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100 1658 * @tc.name : set session launchAbility - promise 1659 * @tc.desc : Testing call setLaunchAbility(promise) 1660 * @tc.size : MediumTest 1661 * @tc.type : Function 1662 * @tc.level : Level1 1663 */ 1664 it('SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1665 let wantAgentInfo = { 1666 wants: [ 1667 { 1668 bundleName: 'com.example.myapplication', 1669 abilityName: 'com.example.myapplication.MainAbility' 1670 } 1671 ], 1672 operationType: ohosWantAgent.OperationType.START_ABILITIES, 1673 requestCode: 0, 1674 wantAgentFlags: [WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] 1675 }; 1676 let agent; 1677 await WantAgent.getWantAgent(wantAgentInfo).then((callback) => { 1678 agent = callback; 1679 }); 1680 1681 await session.setLaunchAbility(agent).then(() => { 1682 console.info('TestLog: AVSessionTest : Set LaunchAbility'); 1683 }).catch((err) => { 1684 console.info(`TestLog: Set LaunchAbility error: code: ${err.code}, message: ${err.message}`); 1685 expect(false).assertTrue(); 1686 }); 1687 let wantagent; 1688 await controller.getLaunchAbility().then((data) => { 1689 wantagent = data; 1690 console.info('TestLog: Get launchAbility'); 1691 }).catch((err) => { 1692 console.info(`TestLog: Get LaunchAbility error: code: ${err.code}, message: ${err.message}`); 1693 expect(false).assertTrue(); 1694 }); 1695 await WantAgent.equal(agent, wantagent).then((bool) => { 1696 if (bool) { 1697 console.info('TestLog: AVSessionTest : Set LaunchAbility successfully'); 1698 expect(true).assertTrue(); 1699 } else { 1700 console.info('TestLog: AVSessionTest : Set LaunchAbility failed'); 1701 expect(false).assertTrue(); 1702 } 1703 }).catch((error) => { 1704 console.info(`TestLog: compare LaunchAbility error: code: ${err.code}, message: ${err.message}`); 1705 expect(false).assertTrue(); 1706 }); 1707 done(); 1708 }) 1709 1710 /* * 1711 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_PROMISE_0100 1712 * @tc.name : set session active - promise 1713 * @tc.desc : Testing set session active - promise 1714 * @tc.size : MediumTest 1715 * @tc.type : Function 1716 * @tc.level : Level1 1717 */ 1718 it('SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1719 await session.activate().then(() => { 1720 console.info('TestLog: Set session active successfully'); 1721 }).catch((err) => { 1722 console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`); 1723 expect(false).assertTrue(); 1724 }); 1725 1726 await controller.isActive().then((data) => { 1727 if (data) { 1728 console.info('TestLog: session is active'); 1729 expect(true).assertTrue(); 1730 } else { 1731 console.info('TestLog: session is directive'); 1732 expect(false).assertTrue(); 1733 } 1734 }).catch((err) => { 1735 console.info(`TestLog: AVSessionTest error: code: ${err.code}, message: ${err.message}`); 1736 expect(false).assertTrue(); 1737 }); 1738 done(); 1739 }) 1740 1741 /* * 1742 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_PROMISE_0100 1743 * @tc.name : set session deactivate - promise 1744 * @tc.desc : Testing set session deactivate - promise 1745 * @tc.size : MediumTest 1746 * @tc.type : Function 1747 * @tc.level : Level1 1748 */ 1749 it('SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1750 await session.activate().then(() => { 1751 console.info('TestLog: Set session active'); 1752 }).catch((err) => { 1753 console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`); 1754 expect(false).assertTrue(); 1755 }); 1756 1757 await session.deactivate().then(() => { 1758 console.info('TestLog: Deactivate session'); 1759 }).catch((err) => { 1760 console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`); 1761 expect(false).assertTrue(); 1762 }); 1763 1764 await controller.isActive().then((data) => { 1765 if (data) { 1766 console.info('TestLog: session deactivate failed'); 1767 expect(false).assertTrue(); 1768 } else { 1769 console.info('TestLog: session deactivate successfully'); 1770 expect(true).assertTrue(); 1771 } 1772 }).catch((err) => { 1773 console.info(`TestLog: AVSessionTest error: code: ${err.code}, message: ${err.message}`); 1774 expect(false).assertTrue(); 1775 }); 1776 done(); 1777 }) 1778 1779 /* * 1780 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_CALLBACK_0100 1781 * @tc.name : set session active - callback 1782 * @tc.desc : Testing set session active - callback 1783 * @tc.size : MediumTest 1784 * @tc.type : Function 1785 * @tc.level : Level2 1786 */ 1787 it('SUB_MULTIMEDIA_AVSESSION_SESSIONACTIVATE_CALLBACK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1788 try { 1789 session.activate((err) => { 1790 if (err) { 1791 console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`); 1792 expect(false).assertTrue(); 1793 } else { 1794 console.info('TestLog: Set session active successfully'); 1795 } 1796 }) 1797 } catch (err) { 1798 console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`); 1799 expect(false).assertTrue(); 1800 } 1801 1802 await sleep(500); 1803 await controller.isActive((err, isActive) => { 1804 if(err) { 1805 console.info(`TestLog: AVSessionTest error: code: ${err.code}, message: ${err.message}`); 1806 expect(false).assertTrue(); 1807 } else { 1808 if (isActive) { 1809 console.info('TestLog: session is active'); 1810 expect(true).assertTrue(); 1811 } else { 1812 console.info('TestLog: session is directive'); 1813 expect(false).assertTrue(); 1814 } 1815 } 1816 }) 1817 done(); 1818 }) 1819 1820 /* * 1821 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_CALLBACK_0100 1822 * @tc.name : set session deactivate - callback 1823 * @tc.desc : Testing set session deactivate - callback 1824 * @tc.size : MediumTest 1825 * @tc.type : Function 1826 * @tc.level : Level2 1827 */ 1828 it('SUB_MULTIMEDIA_AVSESSION_SESSIONDEACTIVATE_CALLBACK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1829 await session.activate().then(() => { 1830 console.info('TestLog: Set session active'); 1831 }).catch((err) => { 1832 console.info(`TestLog: Set active error: code: ${err.code}, message: ${err.message}`); 1833 expect(false).assertTrue(); 1834 }); 1835 1836 try { 1837 session.deactivate((err) => { 1838 if (err) { 1839 console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`); 1840 expect(false).assertTrue(); 1841 } else { 1842 console.info('TestLog: Deactivate session'); 1843 } 1844 }) 1845 } catch (err) { 1846 console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`); 1847 expect(false).assertTrue(); 1848 } 1849 await sleep(500); 1850 1851 await controller.isActive((err, isActive) => { 1852 if(err) { 1853 console.info(`TestLog: AVSessionTest error: code: ${err.code}, message: ${err.message}`); 1854 expect(false).assertTrue(); 1855 } else { 1856 if (isActive) { 1857 console.info('TestLog: session deactivate failed'); 1858 expect(false).assertTrue(); 1859 } else { 1860 console.info('TestLog: session deactivate successfully'); 1861 expect(true).assertTrue(); 1862 } 1863 } 1864 1865 }) 1866 done(); 1867 }) 1868 1869 /* * 1870 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100 1871 * @tc.name : bind callbacks on play events 1872 * @tc.desc : Testing onPlay callback 1873 * @tc.size : MediumTest 1874 * @tc.type : Function 1875 * @tc.level : Level2 1876 */ 1877 it('SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1878 session.on('play', () => { 1879 console.info('TestLog: Play command callback registration successful'); 1880 expect(true).assertTrue(); 1881 }); 1882 1883 await controller.sendControlCommand({ command: 'play' }).then(() => { 1884 console.info('TestLog: Controller send command successfully'); 1885 }).catch((err) => { 1886 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 1887 expect(false).assertTrue(); 1888 }); 1889 await sleep(500); 1890 done(); 1891 }) 1892 1893 /* * 1894 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPAUSE_0100 1895 * @tc.name : bind callbacks on pause events 1896 * @tc.desc : Testing onPause callback 1897 * @tc.size : MediumTest 1898 * @tc.type : Function 1899 * @tc.level : Level2 1900 */ 1901 it('SUB_MULTIMEDIA_AVSESSION_ONPAUSE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1902 session.on('pause', () => { 1903 console.info('TestLog: Pause command callback registration successful'); 1904 expect(true).assertTrue(); 1905 }); 1906 1907 await controller.sendControlCommand({ command: 'pause' }).then(() => { 1908 console.info('TestLog: Controller send command successfully'); 1909 }).catch((err) => { 1910 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 1911 expect(false).assertTrue(); 1912 }); 1913 await sleep(500); 1914 done(); 1915 }) 1916 1917 /* * 1918 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONSTOP_0100 1919 * @tc.name : bind callbacks on stop events 1920 * @tc.desc : Testing onStop callback 1921 * @tc.size : MediumTest 1922 * @tc.type : Function 1923 * @tc.level : Level2 1924 */ 1925 it('SUB_MULTIMEDIA_AVSESSION_ONSTOP_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1926 session.on('stop', () => { 1927 console.info('TestLog: Stop command callback registration successful'); 1928 expect(true).assertTrue(); 1929 }); 1930 1931 await controller.sendControlCommand({ command: 'stop' }).then(() => { 1932 console.info('TestLog: Controller send command successfully'); 1933 }).catch((err) => { 1934 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 1935 expect(false).assertTrue(); 1936 }); 1937 await sleep(500); 1938 done(); 1939 }) 1940 1941 /* * 1942 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAYNEXT_0100 1943 * @tc.name : bind callbacks on playNext events 1944 * @tc.desc : Testing onPlayNext callback 1945 * @tc.size : MediumTest 1946 * @tc.type : Function 1947 * @tc.level : Level2 1948 */ 1949 it('SUB_MULTIMEDIA_AVSESSION_ONPLAYNEXT_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1950 session.on('playNext', () => { 1951 console.info('TestLog: PlayNext command callback registration successful'); 1952 expect(true).assertTrue(); 1953 }); 1954 1955 await controller.sendControlCommand({ command: 'playNext' }).then(() => { 1956 console.info('TestLog: Controller send command successfully'); 1957 }).catch((err) => { 1958 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 1959 expect(false).assertTrue(); 1960 }); 1961 await sleep(500); 1962 done(); 1963 }) 1964 1965 /* * 1966 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAYPREVIOUS_0100 1967 * @tc.name : bind callbacks on playPrevious events 1968 * @tc.desc : Testing onPlayPrevious callback 1969 * @tc.size : MediumTest 1970 * @tc.type : Function 1971 * @tc.level : Level2 1972 */ 1973 it('SUB_MULTIMEDIA_AVSESSION_ONPLAYPREVIOUS_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1974 session.on('playPrevious', () => { 1975 console.info('TestLog: PlayPrevious command callback registration successful'); 1976 expect(true).assertTrue(); 1977 }); 1978 1979 await controller.sendControlCommand({ command: 'playPrevious' }).then(() => { 1980 console.info('TestLog: Controller send command successfully'); 1981 }).catch((err) => { 1982 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 1983 expect(false).assertTrue(); 1984 }); 1985 await sleep(500); 1986 done(); 1987 }) 1988 1989 /* * 1990 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0100 1991 * @tc.name : bind callbacks on fastForward events(no args) 1992 * @tc.desc : Testing onFastForward(no args) callback 1993 * @tc.size : MediumTest 1994 * @tc.type : Function 1995 * @tc.level : Level2 1996 */ 1997 it('SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 1998 session.on('fastForward', () => { 1999 console.info('TestLog: FastForward command callback registration successful'); 2000 expect(true).assertTrue(); 2001 }); 2002 2003 await controller.sendControlCommand({ command: 'fastForward' }).then(() => { 2004 console.info('TestLog: Controller send command successfully'); 2005 }).catch((err) => { 2006 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2007 expect(false).assertTrue(); 2008 }); 2009 await sleep(500); 2010 done(); 2011 }) 2012 2013 /* * 2014 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0200 2015 * @tc.name : bind callbacks on fastForward events(10s) 2016 * @tc.desc : Testing onFastForward(time 10s) callback 2017 * @tc.size : MediumTest 2018 * @tc.type : Function 2019 * @tc.level : Level2 2020 */ 2021 it('SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2022 session.on('fastForward', (time) => { 2023 if (time == avSession.SkipIntervals.SECONDS_10) { 2024 console.info('TestLog: FastForward command callback registration successful'); 2025 expect(true).assertTrue(); 2026 } else { 2027 expect(false).assertTrue(); 2028 } 2029 }); 2030 2031 await controller.sendControlCommand({ command: 'fastForward', parameter: avSession.SkipIntervals.SECONDS_10 }).then(() => { 2032 console.info('TestLog: Controller send command successfully'); 2033 }).catch((err) => { 2034 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2035 expect(false).assertTrue(); 2036 }); 2037 await sleep(500); 2038 done(); 2039 }) 2040 2041 /* * 2042 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0300 2043 * @tc.name : bind callbacks on fastForward events(15s) 2044 * @tc.desc : Testing onFastForward(time 15s) callback 2045 * @tc.size : MediumTest 2046 * @tc.type : Function 2047 * @tc.level : Level2 2048 */ 2049 it('SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2050 session.on('fastForward', (time) => { 2051 if (time == avSession.SkipIntervals.SECONDS_15) { 2052 console.info('TestLog: FastForward command callback registration successful'); 2053 expect(true).assertTrue(); 2054 } else { 2055 expect(false).assertTrue(); 2056 } 2057 }); 2058 2059 await controller.sendControlCommand({ command: 'fastForward', parameter: avSession.SkipIntervals.SECONDS_15 }).then(() => { 2060 console.info('TestLog: Controller send command successfully'); 2061 }).catch((err) => { 2062 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2063 expect(false).assertTrue(); 2064 }); 2065 await sleep(500); 2066 done(); 2067 }) 2068 2069 /* * 2070 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0400 2071 * @tc.name : bind callbacks on fastForward events(30s) 2072 * @tc.desc : Testing onFastForward(time 30s) callback 2073 * @tc.size : MediumTest 2074 * @tc.type : Function 2075 * @tc.level : Level2 2076 */ 2077 it('SUB_MULTIMEDIA_AVSESSION_ONFASTFORWARD_0400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2078 session.on('fastForward', (time) => { 2079 if (time == avSession.SkipIntervals.SECONDS_30) { 2080 console.info('TestLog: FastForward command callback registration successful'); 2081 expect(true).assertTrue(); 2082 } else { 2083 expect(false).assertTrue(); 2084 } 2085 }); 2086 2087 await controller.sendControlCommand({ command: 'fastForward', parameter: avSession.SkipIntervals.SECONDS_30 }).then(() => { 2088 console.info('TestLog: Controller send command successfully'); 2089 }).catch((err) => { 2090 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2091 expect(false).assertTrue(); 2092 }); 2093 await sleep(500); 2094 done(); 2095 }) 2096 2097 /* * 2098 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONREWIND_0100 2099 * @tc.name : bind callbacks on rewind events(no args) 2100 * @tc.desc : Testing onRewind callback 2101 * @tc.size : MediumTest 2102 * @tc.type : Function 2103 * @tc.level : Level2 2104 */ 2105 it('SUB_MULTIMEDIA_AVSESSION_ONREWIND_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2106 session.on('rewind', () => { 2107 console.info('TestLog: Rewind command callback registration successful'); 2108 expect(true).assertTrue(); 2109 }); 2110 2111 await controller.sendControlCommand({ command: 'rewind' }).then(() => { 2112 console.info('TestLog: Controller send command successfully'); 2113 }).catch((err) => { 2114 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2115 expect(false).assertTrue(); 2116 }); 2117 await sleep(500); 2118 done(); 2119 }) 2120 2121 /* * 2122 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONREWIND_0200 2123 * @tc.name : bind callbacks on rewind events(10s) 2124 * @tc.desc : Testing onRewind(time 10s) callback 2125 * @tc.size : MediumTest 2126 * @tc.type : Function 2127 * @tc.level : Level2 2128 */ 2129 it('SUB_MULTIMEDIA_AVSESSION_ONREWIND_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2130 session.on('rewind', (time) => { 2131 if (time == avSession.SkipIntervals.SECONDS_10) { 2132 console.info('TestLog: Rewind command callback registration successful'); 2133 expect(true).assertTrue(); 2134 } else { 2135 expect(false).assertTrue(); 2136 } 2137 }); 2138 2139 await controller.sendControlCommand({ command: 'rewind', parameter: avSession.SkipIntervals.SECONDS_10 }).then(() => { 2140 console.info('TestLog: Controller send command successfully'); 2141 }).catch((err) => { 2142 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2143 expect(false).assertTrue(); 2144 }); 2145 await sleep(500); 2146 done(); 2147 }) 2148 2149 /* * 2150 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONREWIND_0300 2151 * @tc.name : bind callbacks on rewind events(15s) 2152 * @tc.desc : Testing onRewind(time 15s) callback 2153 * @tc.size : MediumTest 2154 * @tc.type : Function 2155 * @tc.level : Level2 2156 */ 2157 it('SUB_MULTIMEDIA_AVSESSION_ONREWIND_0300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2158 session.on('rewind', (time) => { 2159 if (time == avSession.SkipIntervals.SECONDS_15) { 2160 console.info('TestLog: Rewind command callback registration successful'); 2161 expect(true).assertTrue(); 2162 } else { 2163 expect(false).assertTrue(); 2164 } 2165 }); 2166 2167 await controller.sendControlCommand({ command: 'rewind', parameter: avSession.SkipIntervals.SECONDS_15 }).then(() => { 2168 console.info('TestLog: Controller send command successfully'); 2169 }).catch((err) => { 2170 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2171 expect(false).assertTrue(); 2172 }); 2173 await sleep(500); 2174 done(); 2175 }) 2176 2177 /* * 2178 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONREWIND_0400 2179 * @tc.name : bind callbacks on rewind events(30s) 2180 * @tc.desc : Testing onRewind(time 30s) callback 2181 * @tc.size : MediumTest 2182 * @tc.type : Function 2183 * @tc.level : Level2 2184 */ 2185 it('SUB_MULTIMEDIA_AVSESSION_ONREWIND_0400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2186 session.on('rewind', (time) => { 2187 if (time == avSession.SkipIntervals.SECONDS_30) { 2188 console.info('TestLog: Rewind command callback registration successful'); 2189 expect(true).assertTrue(); 2190 } else { 2191 expect(false).assertTrue(); 2192 } 2193 }); 2194 2195 await controller.sendControlCommand({ command: 'rewind', parameter: avSession.SkipIntervals.SECONDS_30 }).then(() => { 2196 console.info('TestLog: Controller send command successfully'); 2197 }).catch((err) => { 2198 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2199 expect(false).assertTrue(); 2200 }); 2201 await sleep(500); 2202 done(); 2203 }) 2204 2205 /* * 2206 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONSEEK_0100 2207 * @tc.name : bind callbacks on seek events 2208 * @tc.desc : Testing onSeek callback 2209 * @tc.size : MediumTest 2210 * @tc.type : Function 2211 * @tc.level : Level2 2212 */ 2213 it('SUB_MULTIMEDIA_AVSESSION_ONSEEK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2214 session.on('seek', (callback) => { 2215 if (callback === 10) { 2216 console.info('TestLog: Seek command callback registration successful'); 2217 expect(true).assertTrue(); 2218 } else { 2219 console.info('TestLog: Seek command callback registration failed'); 2220 expect(false).assertTrue(); 2221 } 2222 }); 2223 2224 await controller.sendControlCommand({ command: 'seek', parameter: 10 }).then(() => { 2225 console.info('TestLog: Controller send command successfully'); 2226 }).catch((err) => { 2227 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2228 expect(false).assertTrue(); 2229 }); 2230 await sleep(500); 2231 done(); 2232 }) 2233 2234 /* * 2235 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONSETSPEED_0100 2236 * @tc.name : bind callbacks on setSpeed events 2237 * @tc.desc : Testing on setSpeed callback 2238 * @tc.size : MediumTest 2239 * @tc.type : Function 2240 * @tc.level : Level2 2241 */ 2242 it('SUB_MULTIMEDIA_AVSESSION_ONSETSPEED_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2243 session.on('setSpeed', (callback) => { 2244 if (callback === 2.6) { 2245 console.info('TestLog: SetSpeed command callback registration successful'); 2246 expect(true).assertTrue(); 2247 } else { 2248 console.info('TestLog: SetSpeed command callback registration error'); 2249 expect(false).assertTrue(); 2250 } 2251 }); 2252 2253 await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.6 }).then(() => { 2254 console.info('TestLog: Controller send command successfully'); 2255 }).catch((err) => { 2256 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2257 expect(false).assertTrue(); 2258 }); 2259 await sleep(500); 2260 done(); 2261 }) 2262 2263 /* * 2264 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONSETLOOPMODE_0100 2265 * @tc.name : bind callbacks on setLoopMode events 2266 * @tc.desc : Testing on setLoopMode callback 2267 * @tc.size : MediumTest 2268 * @tc.type : Function 2269 * @tc.level : Level2 2270 */ 2271 it('SUB_MULTIMEDIA_AVSESSION_ONSETLOOPMODE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2272 session.on('setLoopMode', (callback) => { 2273 if (callback === 1) { 2274 console.info('TestLog: Set LoopMode command callback registration successful'); 2275 expect(true).assertTrue(); 2276 } else { 2277 console.info('TestLog: Set LoopMode command callback registration error'); 2278 expect(false).assertTrue(); 2279 } 2280 }); 2281 2282 await controller.sendControlCommand({ 2283 command: 'setLoopMode', parameter: 2284 avSession.LoopMode.LOOP_MODE_SINGLE 2285 }).then(() => { 2286 console.info('TestLog: Controller send command successfully'); 2287 }).catch((err) => { 2288 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2289 expect(false).assertTrue(); 2290 }); 2291 await sleep(500); 2292 done(); 2293 }) 2294 2295 /* * 2296 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONTOGGLEFAVORITE_0100 2297 * @tc.name : bind callbacks on toggleFavorite events 2298 * @tc.desc : Testing on toggleFavorite callback 2299 * @tc.size : MediumTest 2300 * @tc.type : Function 2301 * @tc.level : Level2 2302 */ 2303 it('SUB_MULTIMEDIA_AVSESSION_ONTOGGLEFAVORITE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2304 session.on('toggleFavorite', (callback) => { 2305 if (callback === 'false') { 2306 console.info('TestLog: Set toggleFavorite command callback registration successful'); 2307 expect(true).assertTrue(); 2308 } 2309 else { 2310 console.info('TestLog: Set toggleFavorite command callback registration error'); 2311 expect(false).assertTrue(); 2312 } 2313 }); 2314 2315 await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).then(() => { 2316 console.info('TestLog: Controller send command successfully'); 2317 }).catch((err) => { 2318 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2319 expect(false).assertTrue(); 2320 }); 2321 await sleep(500); 2322 done(); 2323 }) 2324 2325 /* * 2326 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100 2327 * @tc.name : bind callbacks on handleKeyEvent events 2328 * @tc.desc : Testing on handleKeyEvent callback 2329 * @tc.size : MediumTest 2330 * @tc.type : Function 2331 * @tc.level : Level2 2332 */ 2333 it('SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2334 session.on('handleKeyEvent', (callback) => { 2335 if (callback.action === 2) { 2336 console.info('TestLog: Handle keyEvent callback registration successful'); 2337 expect(true).assertTrue(); 2338 } else { 2339 console.info('TestLog: Handle keyEvent callback registration error'); 2340 expect(false).assertTrue(); 2341 } 2342 }); 2343 2344 await controller.sendAVKeyEvent(event).then(() => { 2345 console.info('TestLog: Controller send AVKeyEvent successfully'); 2346 }).catch((err) => { 2347 console.info(`TestLog: Controller send AVKeyEvent error: code: ${err.code}, message: ${err.message}`); 2348 expect(false).assertTrue(); 2349 }); 2350 await sleep(500); 2351 done(); 2352 }) 2353 2354 /* * 2355 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONWRONGCALLBACK_0100 2356 * @tc.name : bind callbacks on wrongCall events 2357 * @tc.desc : Testing on wrongCall callback 2358 * @tc.size : MediumTest 2359 * @tc.type : Function 2360 * @tc.level : Level2 2361 */ 2362 it('SUB_MULTIMEDIA_AVSESSION_ONWRONGCALLBACK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function (done) { 2363 try { 2364 session.on('wrongCall', () => { 2365 console.info('TestLog: Wrong callback registration successful'); 2366 }); 2367 } catch (err) { 2368 console.info(`TestLog: Wrong callback registration error: code: ${err.code}, message: ${err.message}`); 2369 expect(true).assertTrue(); 2370 done(); 2371 } 2372 }) 2373 2374 /* * 2375 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100 2376 * @tc.name : unbind all callbacks on play events 2377 * @tc.desc : Testing off Play all callback 2378 * @tc.size : MediumTest 2379 * @tc.type : Function 2380 * @tc.level : Level2 2381 */ 2382 it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2383 function callback1() { 2384 console.info('TestLog: Play command registration1 success'); 2385 expect(false).assertTrue(); 2386 } 2387 2388 function callback2() { 2389 console.info('TestLog: Play command registration2 success'); 2390 expect(false).assertTrue(); 2391 } 2392 2393 session.on('play', callback1); 2394 2395 session.on('play', callback2); 2396 2397 session.off('play'); 2398 2399 await controller.sendControlCommand({ command: 'play' }).then(() => { 2400 console.info('TestLog: Controller send command successfully'); 2401 }).catch((err) => { 2402 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2403 expect(true).assertTrue(); 2404 }); 2405 await sleep(500); 2406 done(); 2407 }) 2408 2409 /* * 2410 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200 2411 * @tc.name : Unbind the specified callback on play events 2412 * @tc.desc : Testing off Play specified callback 2413 * @tc.size : MediumTest 2414 * @tc.type : Function 2415 * @tc.level : Level2 2416 */ 2417 it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2418 function callback1() { 2419 console.info('TestLog: Play command registration1 success'); 2420 expect(false).assertTrue(); 2421 } 2422 2423 function callback2() { 2424 console.info('TestLog: Play command registration2 success'); 2425 expect(true).assertTrue(); 2426 } 2427 2428 session.on('play', callback1); 2429 2430 session.on('play', callback2); 2431 2432 session.off('play', callback1); 2433 2434 await controller.sendControlCommand({ command: 'play' }).then(() => { 2435 console.info('TestLog: Controller send command successfully'); 2436 }).catch((err) => { 2437 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2438 expect(false).assertTrue(); 2439 }); 2440 await sleep(500); 2441 done(); 2442 }) 2443 2444 2445 /* * 2446 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0100 2447 * @tc.name : unbind all callbacks on pause events 2448 * @tc.desc : Testing off pause all callback 2449 * @tc.size : MediumTest 2450 * @tc.type : Function 2451 * @tc.level : Level2 2452 */ 2453 it('SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2454 function callback1() { 2455 console.info('TestLog: Pause command registration1 success'); 2456 expect(false).assertTrue(); 2457 } 2458 2459 function callback2() { 2460 console.info('TestLog: Pause command registration2 success'); 2461 expect(false).assertTrue(); 2462 } 2463 2464 session.on('pause', callback1); 2465 2466 session.on('pause', callback2); 2467 2468 session.off('pause'); 2469 2470 await controller.sendControlCommand({ command: 'pause' }).then(() => { 2471 console.info('TestLog: Controller send command successfully'); 2472 }).catch((err) => { 2473 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2474 expect(true).assertTrue(); 2475 }); 2476 await sleep(500); 2477 done(); 2478 }) 2479 2480 /* * 2481 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0200 2482 * @tc.name : Unbind the specified callback on pause events 2483 * @tc.desc : Testing off pause specified callback 2484 * @tc.size : MediumTest 2485 * @tc.type : Function 2486 * @tc.level : Level2 2487 */ 2488 it('SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2489 function callback1() { 2490 console.info('TestLog: Pause command registration1 success'); 2491 expect(false).assertTrue(); 2492 } 2493 2494 function callback2() { 2495 console.info('TestLog: Pause command registration2 success'); 2496 expect(true).assertTrue(); 2497 } 2498 2499 session.on('pause', callback1); 2500 2501 session.on('pause', callback2); 2502 2503 session.off('pause', callback1); 2504 2505 await controller.sendControlCommand({ command: 'pause' }).then(() => { 2506 console.info('TestLog: Controller send command successfully'); 2507 }).catch((err) => { 2508 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2509 expect(false).assertTrue(); 2510 }); 2511 await sleep(500); 2512 done(); 2513 }) 2514 2515 /* * 2516 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSTOP_0100 2517 * @tc.name : unbind all callbacks on stop events 2518 * @tc.desc : Testing off stop all callback 2519 * @tc.size : MediumTest 2520 * @tc.type : Function 2521 * @tc.level : Level2 2522 */ 2523 it('SUB_MULTIMEDIA_AVSESSION_OFFSTOP_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2524 function callback1() { 2525 console.info('TestLog: Stop command registration1 success'); 2526 expect(false).assertTrue(); 2527 } 2528 2529 function callback2() { 2530 console.info('TestLog: Stop command registration2 success'); 2531 expect(false).assertTrue(); 2532 } 2533 2534 session.on('stop', callback1) 2535 2536 session.on('stop', callback2) 2537 2538 session.off('stop'); 2539 2540 await controller.sendControlCommand({ command: 'stop' }).then(() => { 2541 console.info('TestLog: Controller send command successfully'); 2542 }).catch((err) => { 2543 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2544 expect(true).assertTrue(); 2545 }); 2546 await sleep(500); 2547 done(); 2548 }) 2549 2550 /* * 2551 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSTOP_0200 2552 * @tc.name : Unbind the specified callback on stop events 2553 * @tc.desc : Testing off stop specified callback 2554 * @tc.size : MediumTest 2555 * @tc.type : Function 2556 * @tc.level : Level2 2557 */ 2558 it('SUB_MULTIMEDIA_AVSESSION_OFFSTOP_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2559 function callback1() { 2560 console.info('TestLog: Stop command registration1 success'); 2561 expect(false).assertTrue(); 2562 } 2563 2564 function callback2() { 2565 console.info('TestLog: Stop command registration2 success'); 2566 expect(true).assertTrue(); 2567 } 2568 2569 session.on('stop', callback1) 2570 2571 session.on('stop', callback2) 2572 2573 session.off('stop', callback1) 2574 2575 await controller.sendControlCommand({ command: 'stop' }).then(() => { 2576 console.info('TestLog: Controller send command successfully'); 2577 }).catch((err) => { 2578 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2579 expect(false).assertTrue(); 2580 }); 2581 await sleep(500); 2582 done(); 2583 }) 2584 2585 /* * 2586 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAYNEXT_0100 2587 * @tc.name : unbind all callbacks on playNext events 2588 * @tc.desc : Testing off playNext all callback 2589 * @tc.size : MediumTest 2590 * @tc.type : Function 2591 * @tc.level : Level2 2592 */ 2593 it('SUB_MULTIMEDIA_AVSESSION_OFFPLAYNEXT_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2594 function callback1() { 2595 console.info('TestLog: PlayNext command registration1 success'); 2596 expect(false).assertTrue(); 2597 } 2598 2599 function callback2() { 2600 console.info('TestLog: PlayNext command registration2 success'); 2601 expect(false).assertTrue(); 2602 } 2603 2604 session.on('playNext', callback1); 2605 2606 session.on('playNext', callback2); 2607 2608 session.off('playNext'); 2609 2610 await controller.sendControlCommand({ command: 'playNext' }).then(() => { 2611 console.info('TestLog: Controller send command successfully'); 2612 }).catch((err) => { 2613 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2614 expect(true).assertTrue(); 2615 }); 2616 await sleep(500); 2617 done(); 2618 }) 2619 2620 /* * 2621 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAYNEXT_0200 2622 * @tc.name : Unbind the specified callback on playNext events 2623 * @tc.desc : Testing off playNext specified callback 2624 * @tc.size : MediumTest 2625 * @tc.type : Function 2626 * @tc.level : Level2 2627 */ 2628 it('SUB_MULTIMEDIA_AVSESSION_OFFPLAYNEXT_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2629 function callback1() { 2630 console.info('TestLog: PlayNext command registration1 success'); 2631 expect(false).assertTrue(); 2632 } 2633 2634 function callback2() { 2635 console.info('TestLog: PlayNext command registration2 success'); 2636 expect(true).assertTrue(); 2637 } 2638 2639 session.on('playNext', callback1); 2640 2641 session.on('playNext', callback2); 2642 2643 session.off('playNext', callback1); 2644 2645 await controller.sendControlCommand({ command: 'playNext' }).then(() => { 2646 console.info('TestLog: Controller send command successfully'); 2647 }).catch((err) => { 2648 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2649 expect(false).assertTrue(); 2650 }); 2651 await sleep(500); 2652 done(); 2653 }) 2654 2655 /* * 2656 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAYPREVIOUS_0100 2657 * @tc.name : unbind all callbacks on playPrevious events 2658 * @tc.desc : Testing off playPrevious all callback 2659 * @tc.size : MediumTest 2660 * @tc.type : Function 2661 * @tc.level : Level2 2662 */ 2663 it('SUB_MULTIMEDIA_AVSESSION_OFFPLAYPREVIOUS_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2664 function callback1() { 2665 console.info('TestLog: PlayPrevious command registration1 success'); 2666 expect(false).assertTrue(); 2667 } 2668 2669 function callback2() { 2670 console.info('TestLog: PlayPrevious command registration2 success'); 2671 expect(false).assertTrue(); 2672 } 2673 2674 session.on('playPrevious', callback1); 2675 2676 session.on('playPrevious', callback2); 2677 2678 session.off('playPrevious'); 2679 2680 await controller.sendControlCommand({ command: 'playPrevious' }).then(() => { 2681 console.info('TestLog: Controller send command successfully'); 2682 }).catch((err) => { 2683 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2684 expect(true).assertTrue(); 2685 }); 2686 await sleep(500); 2687 done(); 2688 }) 2689 2690 /* * 2691 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAYPREVIOUS_0200 2692 * @tc.name : Unbind the specified callback on playPrevious events 2693 * @tc.desc : Testing off playPrevious specified callback 2694 * @tc.size : MediumTest 2695 * @tc.type : Function 2696 * @tc.level : Level2 2697 */ 2698 it('SUB_MULTIMEDIA_AVSESSION_OFFPLAYPREVIOUS_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2699 function callback1() { 2700 console.info('TestLog: PlayPrevious command registration1 success'); 2701 expect(false).assertTrue(); 2702 } 2703 2704 function callback2() { 2705 console.info('TestLog: PlayPrevious command registration2 success'); 2706 expect(true).assertTrue(); 2707 } 2708 2709 session.on('playPrevious', callback1); 2710 2711 session.on('playPrevious', callback2); 2712 2713 session.off('playPrevious', callback1); 2714 2715 await controller.sendControlCommand({ command: 'playPrevious' }).then(() => { 2716 console.info('TestLog: Controller send command successfully'); 2717 }).catch((err) => { 2718 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2719 expect(false).assertTrue(); 2720 }); 2721 await sleep(500); 2722 done(); 2723 }) 2724 2725 /* * 2726 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFFASTFORWARD_0100 2727 * @tc.name : unbind all callbacks on fastForward events 2728 * @tc.desc : Testing off fastForward all callback 2729 * @tc.size : MediumTest 2730 * @tc.type : Function 2731 * @tc.level : Level2 2732 */ 2733 it('SUB_MULTIMEDIA_AVSESSION_OFFFASTFORWARD_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2734 function callback1() { 2735 console.info('TestLog: FastForward command registration1 success'); 2736 expect(false).assertTrue(); 2737 } 2738 2739 function callback2() { 2740 console.info('TestLog: FastForward command registration2 success'); 2741 expect(false).assertTrue(); 2742 } 2743 2744 session.on('fastForward', callback1); 2745 2746 session.on('fastForward', callback2); 2747 2748 session.off('fastForward'); 2749 2750 await controller.sendControlCommand({ command: 'fastForward' }).then(() => { 2751 console.info('TestLog: Controller send command successfully'); 2752 }).catch((err) => { 2753 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2754 expect(true).assertTrue(); 2755 }); 2756 await sleep(500); 2757 done(); 2758 }) 2759 2760 /* * 2761 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFFASTFORWARD_0200 2762 * @tc.name : Unbind the specified callback on fastForward events 2763 * @tc.desc : Testing off fastForward specified callback 2764 * @tc.size : MediumTest 2765 * @tc.type : Function 2766 * @tc.level : Level2 2767 */ 2768 it('SUB_MULTIMEDIA_AVSESSION_OFFFASTFORWARD_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2769 function callback1() { 2770 console.info('TestLog: FastForward command registration1 success'); 2771 expect(false).assertTrue(); 2772 } 2773 2774 function callback2() { 2775 console.info('TestLog: FastForward command registration2 success'); 2776 expect(true).assertTrue(); 2777 } 2778 2779 session.on('fastForward', callback1); 2780 2781 session.on('fastForward', callback2); 2782 2783 session.off('fastForward', callback1); 2784 2785 await controller.sendControlCommand({ command: 'fastForward' }).then(() => { 2786 console.info('TestLog: Controller send command successfully'); 2787 }).catch((err) => { 2788 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2789 expect(false).assertTrue(); 2790 }); 2791 await sleep(500); 2792 done(); 2793 }) 2794 2795 /* * 2796 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFREWIND_0100 2797 * @tc.name : unbind all callbacks on rewind events 2798 * @tc.desc : Testing off rewind all callback 2799 * @tc.size : MediumTest 2800 * @tc.type : Function 2801 * @tc.level : Level2 2802 */ 2803 it('SUB_MULTIMEDIA_AVSESSION_OFFREWIND_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2804 function callback1() { 2805 console.info('TestLog: Rewind command registration1 success'); 2806 expect(false).assertTrue(); 2807 } 2808 2809 function callback2() { 2810 console.info('TestLog: Rewind command registration2 success'); 2811 expect(false).assertTrue(); 2812 } 2813 2814 session.on('rewind', callback1); 2815 2816 session.on('rewind', callback2); 2817 2818 session.off('rewind'); 2819 2820 await controller.sendControlCommand({ command: 'rewind' }).then(() => { 2821 console.info('TestLog: Controller send command successfully'); 2822 }).catch((err) => { 2823 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2824 expect(true).assertTrue(); 2825 }); 2826 await sleep(500); 2827 done(); 2828 }) 2829 2830 /* * 2831 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFREWIND_0200 2832 * @tc.name : Unbind the specified callback on rewind events 2833 * @tc.desc : Testing off rewind specified callback 2834 * @tc.size : MediumTest 2835 * @tc.type : Function 2836 * @tc.level : Level2 2837 */ 2838 it('SUB_MULTIMEDIA_AVSESSION_OFFREWIND_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2839 function callback1() { 2840 console.info('TestLog: Rewind command registration1 success'); 2841 expect(false).assertTrue(); 2842 } 2843 2844 function callback2() { 2845 console.info('TestLog: Rewind command registration2 success'); 2846 expect(true).assertTrue(); 2847 } 2848 2849 session.on('rewind', callback1); 2850 2851 session.on('rewind', callback2); 2852 2853 session.off('rewind', callback1); 2854 2855 await controller.sendControlCommand({ command: 'rewind' }).then(() => { 2856 console.info('TestLog: Controller send command successfully'); 2857 }).catch((err) => { 2858 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2859 expect(false).assertTrue(); 2860 }); 2861 await sleep(500); 2862 done(); 2863 }) 2864 2865 /* * 2866 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSEEK_0100 2867 * @tc.name : unbind all callbacks on seek events 2868 * @tc.desc : Testing off seek all callback 2869 * @tc.size : MediumTest 2870 * @tc.type : Function 2871 * @tc.level : Level2 2872 */ 2873 it('SUB_MULTIMEDIA_AVSESSION_OFFSEEK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2874 function callback1(data) { 2875 if (data === 5) { 2876 console.info('TestLog: offSeek callback1 registration'); 2877 expect(false).assertTrue; 2878 } 2879 } 2880 2881 function callback2(data) { 2882 if (data === 10) { 2883 console.info('TestLog: offSeek callback2 registration'); 2884 expect(false).assertTrue; 2885 } 2886 } 2887 2888 session.on('seek', callback1); 2889 2890 session.on('seek', callback2); 2891 2892 session.off('seek'); 2893 2894 await controller.sendControlCommand({ command: 'seek', parameter: 10 }).then(() => { 2895 console.info('TestLog: Controller send command successfully'); 2896 }).catch((err) => { 2897 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2898 expect(true).assertTrue(); 2899 }); 2900 await sleep(500); 2901 done(); 2902 }) 2903 2904 /* * 2905 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSEEK_0200 2906 * @tc.name : Unbind the specified callback on seek events 2907 * @tc.desc : Testing off seek specified callback 2908 * @tc.size : MediumTest 2909 * @tc.type : Function 2910 * @tc.level : Level2 2911 */ 2912 it('SUB_MULTIMEDIA_AVSESSION_OFFSEEK_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2913 function callback1(data) { 2914 if (data === 5) { 2915 console.info('TestLog: offSeek callback1 registration'); 2916 expect(false).assertTrue; 2917 } 2918 } 2919 2920 function callback2(data) { 2921 if (data === 10) { 2922 console.info('TestLog: offSeek callback2 registration'); 2923 expect(true).assertTrue; 2924 } 2925 } 2926 2927 session.on('seek', callback1); 2928 2929 session.on('seek', callback2); 2930 2931 session.off('seek', callback1); 2932 2933 await controller.sendControlCommand({ command: 'seek', parameter: 10 }).then(() => { 2934 console.info('TestLog: Controller send command successfully'); 2935 }).catch((err) => { 2936 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2937 expect(false).assertTrue(); 2938 }); 2939 await sleep(500); 2940 done(); 2941 }) 2942 2943 /* * 2944 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSETSPEED_0100 2945 * @tc.name : unbind all callbacks on setSpeed events 2946 * @tc.desc : Testing off setSpeed all callback 2947 * @tc.size : MediumTest 2948 * @tc.type : Function 2949 * @tc.level : Level2 2950 */ 2951 it('SUB_MULTIMEDIA_AVSESSION_OFFSETSPEED_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2952 function callback1(data) { 2953 if (data === 1.0) { 2954 console.info('TestLog: SetSpend command registration1 success'); 2955 expect(false).assertTrue; 2956 } 2957 } 2958 2959 function callback2(data) { 2960 if (data === 2.0) { 2961 console.info('TestLog: SetSpend command registration2 success'); 2962 expect(false).assertTrue; 2963 } 2964 } 2965 2966 session.on('setSpeed', callback1); 2967 2968 session.on('setSpeed', callback2); 2969 2970 session.off('setSpeed'); 2971 2972 await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.0 }).then(() => { 2973 console.info('TestLog: Controller send command successfully'); 2974 }).catch((err) => { 2975 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 2976 expect(true).assertTrue(); 2977 }); 2978 await sleep(500); 2979 done(); 2980 }) 2981 2982 /* * 2983 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSETSPEED_0200 2984 * @tc.name : Unbind the specified callback on setSpeed events 2985 * @tc.desc : Testing off setSpeed specified callback 2986 * @tc.size : MediumTest 2987 * @tc.type : Function 2988 * @tc.level : Level2 2989 */ 2990 it('SUB_MULTIMEDIA_AVSESSION_OFFSETSPEED_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 2991 function callback1(data) { 2992 if (data === 1.0) { 2993 console.info('TestLog: SetSpend command registration1 success'); 2994 expect(false).assertTrue; 2995 } 2996 } 2997 2998 function callback2(data) { 2999 if (data === 2.0) { 3000 console.info('TestLog: SetSpend command registration2 success'); 3001 expect(true).assertTrue; 3002 } 3003 } 3004 3005 session.on('setSpeed', callback1); 3006 3007 session.on('setSpeed', callback2); 3008 3009 session.off('setSpeed', callback1); 3010 3011 await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.0 }).then(() => { 3012 console.info('TestLog: Controller send command successfully'); 3013 }).catch((err) => { 3014 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 3015 expect(false).assertTrue(); 3016 }); 3017 await sleep(500); 3018 done(); 3019 }) 3020 3021 /* * 3022 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSETLOOPMODE_0100 3023 * @tc.name : unbind all callbacks on setLoopMode events 3024 * @tc.desc : Testing off setLoopMode all callback 3025 * @tc.size : MediumTest 3026 * @tc.type : Function 3027 * @tc.level : Level2 3028 */ 3029 it('SUB_MULTIMEDIA_AVSESSION_OFFSETLOOPMODE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3030 function callback1(data) { 3031 if (data === 1) { 3032 console.info('TestLog: SetLoopMode command registration1 success'); 3033 expect(false).assertTrue; 3034 } 3035 } 3036 3037 function callback2(data) { 3038 if (data === 2) { 3039 console.info('TestLog: SetLoopMode command registration2 success'); 3040 expect(false).assertTrue; 3041 } 3042 } 3043 3044 session.on('setLoopMode', callback1); 3045 3046 session.on('setLoopMode', callback2); 3047 3048 session.off('setLoopMode'); 3049 3050 await controller.sendControlCommand({ 3051 command: 'setLoopMode', 3052 parameter: avSession.LoopMode.LOOP_MODE_SINGLE 3053 }).then(() => { 3054 console.info('TestLog: Controller send command successfully'); 3055 }).catch((err) => { 3056 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 3057 expect(true).assertTrue(); 3058 }); 3059 await sleep(500); 3060 done(); 3061 }) 3062 3063 /* * 3064 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFSETLOOPMODE_0200 3065 * @tc.name : Unbind the specified callback on setLoopMode events 3066 * @tc.desc : Testing off setLoopMode specified callback 3067 * @tc.size : MediumTest 3068 * @tc.type : Function 3069 * @tc.level : Level2 3070 */ 3071 it('SUB_MULTIMEDIA_AVSESSION_OFFSETLOOPMODE_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3072 function callback1(data) { 3073 if (data === 2) { 3074 console.info('TestLog: SetLoopMode command registration1 success'); 3075 expect(false).assertTrue; 3076 } 3077 } 3078 3079 function callback2(data) { 3080 if (data === 1) { 3081 console.info('TestLog: SetLoopMode command registration2 success'); 3082 expect(true).assertTrue; 3083 } 3084 } 3085 3086 session.on('setLoopMode', callback1); 3087 3088 session.on('setLoopMode', callback2); 3089 3090 session.off('setLoopMode', callback1); 3091 3092 await controller.sendControlCommand({ 3093 command: 'setLoopMode', 3094 parameter: avSession.LoopMode.LOOP_MODE_SINGLE 3095 }).then(() => { 3096 console.info('TestLog: Controller send command successfully'); 3097 }).catch((err) => { 3098 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 3099 expect(false).assertTrue(); 3100 }); 3101 await sleep(500); 3102 done(); 3103 }) 3104 3105 /* * 3106 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFTOGGLEFAVORITE_0100 3107 * @tc.name : unbind all callbacks on toggleFavorite events 3108 * @tc.desc : Testing off toggleFavorite all callback 3109 * @tc.size : MediumTest 3110 * @tc.type : Function 3111 * @tc.level : Level2 3112 */ 3113 it('SUB_MULTIMEDIA_AVSESSION_OFFTOGGLEFAVORITE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3114 function callback1(data) { 3115 if (data === 'true') { 3116 console.info('TestLog: ToggleFavorite command registration1 success'); 3117 expect(false).assertTrue; 3118 } 3119 } 3120 3121 function callback2(data) { 3122 if (data === 'false') { 3123 console.info('TestLog: ToggleFavorite command registration1 success'); 3124 expect(false).assertTrue; 3125 } 3126 } 3127 3128 session.on('toggleFavorite', callback1); 3129 3130 session.on('toggleFavorite', callback2); 3131 3132 session.off('toggleFavorite'); 3133 3134 await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).then(() => { 3135 console.info('TestLog: Controller send command successfully'); 3136 }).catch((err) => { 3137 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 3138 expect(true).assertTrue(); 3139 }); 3140 await sleep(500); 3141 done(); 3142 }) 3143 3144 /* * 3145 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFTOGGLEFAVORITE_0200 3146 * @tc.name : Unbind the specified callback on toggleFavorite events 3147 * @tc.desc : Testing off toggleFavorite specified callback 3148 * @tc.size : MediumTest 3149 * @tc.type : Function 3150 * @tc.level : Level2 3151 */ 3152 it('SUB_MULTIMEDIA_AVSESSION_OFFTOGGLEFAVORITE_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3153 function callback1(data) { 3154 if (data === 'true') { 3155 console.info('TestLog: ToggleFavorite command registration1 success'); 3156 expect(false).assertTrue; 3157 } 3158 } 3159 3160 function callback2(data) { 3161 if (data === 'false') { 3162 console.info('TestLog: ToggleFavorite command registration2 success'); 3163 expect(true).assertTrue; 3164 } 3165 } 3166 3167 session.on('toggleFavorite', callback1); 3168 3169 session.on('toggleFavorite', callback2); 3170 3171 session.off('toggleFavorite', callback1); 3172 3173 await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).then(() => { 3174 console.info('TestLog: Controller send command successfully'); 3175 }).catch((err) => { 3176 console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); 3177 expect(false).assertTrue(); 3178 }); 3179 await sleep(500); 3180 done(); 3181 }) 3182 3183 /* * 3184 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFHANDLEKEYEVENT_0100 3185 * @tc.name : unbind all callbacks on handleKeyEvent events 3186 * @tc.desc : Testing off handleKeyEvent all callback 3187 * @tc.size : MediumTest 3188 * @tc.type : Function 3189 * @tc.level : Level2 3190 */ 3191 it('SUB_MULTIMEDIA_AVSESSION_OFFHANDLEKEYEVENT_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3192 let flag = true; 3193 function callback1(data) { 3194 if (data.action === 1) { 3195 console.info('TestLog: HandleKeyEvent command registration1 success'); 3196 flag = false; 3197 } 3198 } 3199 3200 function callback2(data) { 3201 if (data.action === 2) { 3202 console.info('TestLog: HandleKeyEvent command registration2 success'); 3203 flag = false; 3204 } 3205 } 3206 3207 session.on('handleKeyEvent', callback1); 3208 3209 session.on('handleKeyEvent', callback2); 3210 3211 session.off('handleKeyEvent'); 3212 3213 await controller.sendAVKeyEvent(event).then(() => { 3214 console.info('TestLog: Controller send AVKeyEvent successfully'); 3215 }).catch((err) => { 3216 console.info(`TestLog: Controller send AVKeyEvent error: code: ${err.code}, message: ${err.message}`); 3217 expect(false).assertTrue(); 3218 }); 3219 await sleep(500); 3220 3221 if (flag) { 3222 console.info('TestLog: HandleKeyEvent command callback unRegistration successful'); 3223 expect(true).assertTrue(); 3224 } else { 3225 console.info('TestLog: HandleKeyEvent command callback unRegistration failed'); 3226 expect(false).assertTrue(); 3227 } 3228 done(); 3229 }) 3230 3231 /* * 3232 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFHANDLEKEYEVENT_0200 3233 * @tc.name : Unbind the specified callback on handleKeyEvent events 3234 * @tc.desc : Testing off handleKeyEvent specified callback 3235 * @tc.size : MediumTest 3236 * @tc.type : Function 3237 * @tc.level : Level2 3238 */ 3239 it('SUB_MULTIMEDIA_AVSESSION_OFFHANDLEKEYEVENT_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3240 function callback1(data) { 3241 if (data.action === 1) { 3242 console.info('TestLog: HandleKeyEvent command registration1 success'); 3243 expect(false).assertTrue(); 3244 } 3245 } 3246 3247 function callback2(data) { 3248 if (data.action === 2) { 3249 console.info('TestLog: HandleKeyEvent command registration2 success'); 3250 expect(true).assertTrue(); 3251 } 3252 } 3253 3254 session.on('handleKeyEvent', callback1); 3255 3256 session.on('handleKeyEvent', callback2); 3257 3258 session.off('handleKeyEvent', callback1); 3259 3260 await controller.sendAVKeyEvent(event).then(() => { 3261 console.info('TestLog: Controller send AVKeyEvent successfully'); 3262 }).catch((err) => { 3263 console.info(`TestLog: Controller send AVKeyEvent error: code: ${err.code}, message: ${err.message}`); 3264 expect(false).assertTrue(); 3265 }); 3266 await sleep(500); 3267 done(); 3268 }) 3269 3270 /* * 3271 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100 3272 * @tc.name : get session outputDevice - promise 3273 * @tc.desc : Testing call getOutputDevice(promise) 3274 * @tc.size : MediumTest 3275 * @tc.type : Function 3276 * @tc.level : Level2 3277 */ 3278 it('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3279 session.on('outputDeviceChange', (callback) => { 3280 if (!callback.isRemote) { 3281 console.info(callback.audioDeviceId.size); 3282 console.info(callback.deviceName.size); 3283 console.info('outputDeviceChange callback registration successful'); 3284 expect(true).assertTrue(); 3285 } else { 3286 console.info('outputDeviceChange callback registration fail'); 3287 expect(false).assertTrue(); 3288 } 3289 }); 3290 3291 session.off('outputDeviceChange'); 3292 3293 await session.getOutputDevice().then((data) => { 3294 if (!data.isRemote) { 3295 let deviceInfo = data.devices[0] 3296 if (deviceInfo && deviceInfo.castCategory !== undefined && deviceInfo.deviceId !== undefined && 3297 deviceInfo.deviceName !== undefined && deviceInfo.deviceType !== undefined && deviceInfo.ipAddress !== undefined && 3298 deviceInfo.providerId !== undefined && deviceInfo.supportedProtocols !== undefined && deviceInfo.authenticationStatus !== undefined) { 3299 expect(true).assertTrue(); 3300 } else { 3301 console.info('getOutputDevice value error.') 3302 expect(false).assertTrue(); 3303 } 3304 } else { 3305 console.info(avSession.OutputDeviceInfo.isRemote); 3306 console.info(avSession.OutputDeviceInfo.audioDeviceId.size); 3307 console.info(avSession.OutputDeviceInfo.deviceName.size); 3308 console.info('getOutputDevice successfully'); 3309 console.info('Get device information failed'); 3310 expect(false).assertTrue(); 3311 } 3312 }).catch((err) => { 3313 console.info(`Get device BusinessError: ${err.code}, message: ${err.message}`); 3314 expect(false).assertTrue(); 3315 }) 3316 done(); 3317 }) 3318 3319 /* * 3320 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100 3321 * @tc.name : get session outputDevice - callback 3322 * @tc.desc : Testing call getOutputDevice(callback) 3323 * @tc.size : MediumTest 3324 * @tc.type : Function 3325 * @tc.level : Level2 3326 */ 3327 it('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3328 try { 3329 session.getOutputDevice((err, value) => { 3330 if (err) { 3331 console.info(`Get device information BusinessError: ${err.code}, message: ${err.message}`); 3332 expect(false).assertTrue(); 3333 } else if (!value.isRemote) { 3334 console.info('Get device information successfully'); 3335 let deviceInfo = value.devices[0] 3336 if (deviceInfo && deviceInfo.castCategory !== undefined && deviceInfo.deviceId !== undefined && 3337 deviceInfo.deviceName !== undefined && deviceInfo.deviceType !== undefined && deviceInfo.ipAddress !== undefined && 3338 deviceInfo.providerId !== undefined && deviceInfo.supportedProtocols !== undefined && deviceInfo.authenticationStatus !== undefined) { 3339 expect(true).assertTrue(); 3340 } else { 3341 console.info('getOutputDevice value error.') 3342 expect(false).assertTrue(); 3343 } 3344 } else { 3345 console.info('Get device information failed'); 3346 expect(false).assertTrue(); 3347 } 3348 done(); 3349 }); 3350 } catch (err) { 3351 console.info(`Get device information unknownError: ${err.code}, message: ${err.message}`); 3352 expect(false).assertTrue(); 3353 done(); 3354 } 3355 }) 3356 3357 /* * 3358 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0200 3359 * @tc.name : get session outputDevice - callback 3360 * @tc.desc : Testing call getOutputDevice(callback) 3361 * @tc.size : MediumTest 3362 * @tc.type : Function 3363 * @tc.level : Level2 3364 */ 3365 it('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3366 try { 3367 session.getOutputDevice((err, value) => { 3368 if (err) { 3369 console.info(`Get device information BusinessError: ${err.code}, message: ${err.message}`); 3370 expect(false).assertTrue(); 3371 } else if (!value.isRemote) { 3372 console.info('Get device information successfully'); 3373 let deviceInfo = value.devices[0] 3374 console.info(`manufacturer:${deviceInfo.manufacturer},modelName:${deviceInfo.modelName}`); 3375 if (deviceInfo.manufacturer == null || deviceInfo.modelName == null || deviceInfo.manufacturer == undefined || deviceInfo.modelName == undefined) { 3376 expect(false).assertTrue(); 3377 } 3378 } else { 3379 console.info('Get device information failed'); 3380 expect(false).assertTrue(); 3381 } 3382 done(); 3383 }); 3384 } catch (err) { 3385 console.info(`Get device information unknownError: ${err.code}, message: ${err.message}`); 3386 expect(false).assertTrue(); 3387 done(); 3388 } 3389 }) 3390 3391 /* * 3392 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100 3393 * @tc.name : get session controller - promise 3394 * @tc.desc : Testing call getController(promise) 3395 * @tc.size : MediumTest 3396 * @tc.type : Function 3397 * @tc.level : Level2 3398 */ 3399 it('SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3400 await session.getController().then((data) => { 3401 console.info('Get controller successfully'); 3402 expect(true).assertTrue(); 3403 }).catch((err) => { 3404 console.info('Get controller failed'); 3405 console.info(`Get controller BusinessError: ${err.code}, message: ${err.message}`); 3406 expect(false).assertTrue(); 3407 }); 3408 done(); 3409 }) 3410 3411 /* * 3412 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_CALLBACK_0100 3413 * @tc.name : get session controller - callback 3414 * @tc.desc : Testing call getController(callback) 3415 * @tc.size : MediumTest 3416 * @tc.type : Function 3417 * @tc.level : Level2 3418 */ 3419 it('SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_CALLBACK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3420 try { 3421 session.getController((err, data) => { 3422 if (err) { 3423 console.info('Get controller failed'); 3424 expect(false).assertTrue(); 3425 } else { 3426 console.info('Get controller successfully'); 3427 expect(true).assertTrue(); 3428 } 3429 done(); 3430 }) 3431 } catch (err) { 3432 console.info(`Get controller failed, unknown error: code: ${err.code} message: ${err.message}.`); 3433 expect(false).assertTrue(); 3434 done(); 3435 } 3436 }) 3437 3438 /* * 3439 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_CALLBACK_0100 3440 * @tc.name : controller send AVKeyEvent - callback 3441 * @tc.desc : Testing call sendAVKeyEvent(callback) 3442 * @tc.size : MediumTest 3443 * @tc.type : Function 3444 * @tc.level : Level2 3445 */ 3446 it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_CALLBACK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3447 try { 3448 controller.sendAVKeyEvent(event, (err, data) => { 3449 if (err) { 3450 console.info(`TestLog: sendAVKeyEvent error: code: ${err.code}, message: ${err.message}`); 3451 expect(false).assertTrue(); 3452 } else { 3453 console.info('sendAVKeyEvent Successfully'); 3454 expect(true).assertTrue(); 3455 } 3456 done(); 3457 }) 3458 } catch (err) { 3459 console.info(`TestLog: sendAVKeyEvent unknownError: code: ${err.code}, message: ${err.message}`); 3460 expect(false).assertTrue(); 3461 done(); 3462 } 3463 }) 3464 3465 /* * 3466 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_PROMISE_0100 3467 * @tc.name : controller send AVKeyEvent - promise 3468 * @tc.desc : Testing call sendAVKeyEvent(promise) 3469 * @tc.size : MediumTest 3470 * @tc.type : Function 3471 * @tc.level : Level2 3472 */ 3473 it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3474 await controller.sendAVKeyEvent(event).then(() => { 3475 console.info('sendAVKeyEvent Successfully'); 3476 expect(true).assertTrue(); 3477 }).catch((err) => { 3478 console.info(`TestLog: sendAVKeyEvent error: code: ${err.code}, message: ${err.message}`); 3479 expect(false).assertTrue(); 3480 }); 3481 done(); 3482 }) 3483 3484 /* * 3485 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETREALPLAYBACKPOSITIONSYNC_0100 3486 * @tc.name : get controller real playbackPosition - async 3487 * @tc.desc : Testing call getRealPlaybackPositionSync 3488 * @tc.size : MediumTest 3489 * @tc.type : Function 3490 * @tc.level : Level2 3491 */ 3492 it('SUB_MULTIMEDIA_AVSESSION_GETREALPLAYBACKPOSITIONSYNC_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3493 let realPosition = -1; 3494 try { 3495 realPosition = controller.getRealPlaybackPositionSync(); 3496 } catch (err) { 3497 console.info(`TestLog: getRealPlaybackPositionSync error: code: ${err.code}, message: ${err.message}`); 3498 expect(false).assertTrue(); 3499 } 3500 if (realPosition < 0) { 3501 console.info(`TestLog: getRealPlaybackPositionSync error: code: ${err.code}, message: ${err.message}`); 3502 expect(false).assertTrue(); 3503 } else { 3504 console.info(`TestLog: getRealPlaybackPositionSync Successfully, positon: ${realPosition}`); 3505 expect(true).assertTrue(); 3506 } 3507 done(); 3508 }) 3509 3510 /* * 3511 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETVALIDCOMMANDS_PROMISE_0100 3512 * @tc.name : get session support commands - promise 3513 * @tc.desc : Testing call getValidCommands(promise) 3514 * @tc.size : MediumTest 3515 * @tc.type : Function 3516 * @tc.level : Level2 3517 */ 3518 it('SUB_MULTIMEDIA_AVSESSION_GETVALIDCOMMANDS_PROMISE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3519 session.on('play', () => {}); 3520 await sleep(500); 3521 await controller.getValidCommands().then((data) => { 3522 console.info(`TestLog: getValidCommands Successfully, the length ${data.length}`); 3523 expect(data[0]).assertEqual('play'); 3524 }).catch((err) => { 3525 console.info(`TestLog: getValidCommands error: code: ${err.code}, message: ${err.message}`); 3526 expect(false).assertTrue(); 3527 }); 3528 done(); 3529 }) 3530 3531 /* * 3532 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETVALIDCOMMANDS_CALLBACK_0100 3533 * @tc.name : get session support commands - callback 3534 * @tc.desc : Testing call getValidCommands(callback) 3535 * @tc.size : MediumTest 3536 * @tc.type : Function 3537 * @tc.level : Level2 3538 */ 3539 it('SUB_MULTIMEDIA_AVSESSION_GETVALIDCOMMANDS_CALLBACK_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3540 try { 3541 session.on('play', () => {}); 3542 await sleep(500); 3543 controller.getValidCommands((err, data) => { 3544 if (err) { 3545 console.info(`TestLog: getValidCommands error: code: ${err.code}, message: ${err.message}`); 3546 expect(false).assertTrue(); 3547 } else { 3548 console.info(`TestLog: getValidCommands Successfully, the length ${data.length}`); 3549 expect(data[0]).assertEqual('play'); 3550 } 3551 done(); 3552 }); 3553 } catch (err) { 3554 console.info(`TestLog: getValidCommands error: code: ${err.code}, message: ${err.message}`); 3555 expect(false).assertTrue(); 3556 done(); 3557 } 3558 }) 3559 3560 /* * 3561 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2200 3562 * @tc.name : setAVMetadata - promise - set filter(ProtocolType.TYPE_DLN) 3563 * @tc.desc : Testing call setAVMetadata(promise) set filter(ProtocolType.TYPE_DLN) 3564 * @tc.size : MediumTest 3565 * @tc.type : Function 3566 * @tc.level : Level2 3567 */ 3568 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3569 let metadata0 = { 3570 assetId: '121278', 3571 filter: avSession.ProtocolType.TYPE_DLNA 3572 }; 3573 await session.setAVMetadata(metadata0).then(() => { 3574 console.info('TestLog: Set assetId successfully'); 3575 }).catch((err) => { 3576 console.error(`TestLog: Set assetId error: code: ${err.code}, message: ${err.message}`); 3577 expect(false).assertTrue(); 3578 }); 3579 3580 await controller.getAVMetadata().then((data) => { 3581 if (data.filter === avSession.ProtocolType.TYPE_DLNA) { 3582 expect(true).assertTrue(); 3583 } else { 3584 console.info('TestLog: Get filter failed'); 3585 expect(false).assertTrue(); 3586 } 3587 }).catch((err) => { 3588 console.error(`TestLog: Get filter error: code: ${err.code}, message: ${err.message}`); 3589 expect(false).assertTrue(); 3590 }); 3591 done(); 3592 }) 3593 3594 /* * 3595 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2300 3596 * @tc.name : setAVMetadata - promise - set drmSchemes 3597 * @tc.desc : Testing call setAVMetadata(promise) set drmSchemes 3598 * @tc.size : MediumTest 3599 * @tc.type : Function 3600 * @tc.level : Level2 3601 */ 3602 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3603 let metadata = { 3604 assetId: '121278', 3605 drmSchemes: ["abcdefghjkl","asdfghjklqw"] 3606 }; 3607 await session.setAVMetadata(metadata).then(() => { 3608 console.info('TestLog: Set assetId successfully'); 3609 }).catch((err) => { 3610 console.error(`TestLog: Set assetId error: code: ${err.code}, message: ${err.message}`); 3611 expect(false).assertTrue(); 3612 }); 3613 3614 await controller.getAVMetadata().then((data) => { 3615 if (JSON.stringify(data.drmSchemes) === JSON.stringify(metadata.drmSchemes)) { 3616 expect(true).assertTrue(); 3617 } else { 3618 console.info('TestLog: Get filter failed'); 3619 expect(false).assertTrue(); 3620 } 3621 }).catch((err) => { 3622 console.error(`TestLog: Get filter error: code: ${err.code}, message: ${err.message}`); 3623 expect(false).assertTrue(); 3624 }); 3625 done(); 3626 }) 3627 3628 /* * 3629 * @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2400 3630 * @tc.name : setAVMetadata - promise - set singleLyricText 3631 * @tc.desc : Testing call setAVMetadata(promise) set singleLyricText 3632 * @tc.size : MediumTest 3633 * @tc.type : Function 3634 * @tc.level : Level2 3635 */ 3636 it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_2400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3637 let metadata = { 3638 assetId: '121278', 3639 singleLyricText: 'dream it possible' 3640 }; 3641 await session.setAVMetadata(metadata).then(() => { 3642 console.info('TestLog: Set singleLyricText successfully'); 3643 }).catch((err) => { 3644 console.error(`TestLog: Set singleLyricText error: code: ${err.code}, message: ${err.message}`); 3645 expect(false).assertTrue(); 3646 }); 3647 3648 await controller.getAVMetadata().then((data) => { 3649 if (JSON.stringify(data.singleLyricText) === JSON.stringify(metadata.singleLyricText)) { 3650 expect(true).assertTrue(); 3651 } else { 3652 console.info('TestLog: Get filter failed'); 3653 expect(false).assertTrue(); 3654 } 3655 }).catch((err) => { 3656 console.error(`TestLog: Get filter error: code: ${err.code}, message: ${err.message}`); 3657 expect(false).assertTrue(); 3658 }); 3659 done(); 3660 }) 3661 3662 /* * 3663 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_SUPPORTEDDRMCAPABILITIES_0100 3664 * @tc.name : get session outputDevice - callback 3665 * @tc.desc : Testing call getOutputDevice(supportedDrmCapabilities) 3666 * @tc.size : MediumTest 3667 * @tc.type : Function 3668 * @tc.level : Level2 3669 */ 3670 it('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_SUPPORTEDDRMCAPABILITIES_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3671 try { 3672 session.getOutputDevice((err, value) => { 3673 if (err) { 3674 console.error(`Get device information BusinessError: ${err.code}, message: ${err.message}`); 3675 expect(false).assertTrue(); 3676 } else if (!value.isRemote) { 3677 console.info('Get device information successfully'); 3678 let deviceInfo = value.devices[0] 3679 if (deviceInfo && Array.isArray(deviceInfo.supportedDrmCapabilities)) { 3680 expect(true).assertTrue(); 3681 } else { 3682 console.info('getOutputDevice value error.') 3683 expect(false).assertTrue(); 3684 } 3685 } else { 3686 console.info('Get device information failed'); 3687 expect(false).assertTrue(); 3688 } 3689 done(); 3690 }); 3691 } catch (err) { 3692 console.error(`Get device information unknownError: ${err.code}, message: ${err.message}`); 3693 expect(false).assertTrue(); 3694 done(); 3695 } 3696 }) 3697 3698 /* * 3699 * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETALLCASTDISPLAYS_0100 3700 * @tc.name : getAllCastDisplays 3701 * @tc.desc : Testing call getAllCastDisplays(6600101) 3702 * @tc.size : MediumTest 3703 * @tc.type : Function 3704 * @tc.level : Level2 3705 */ 3706 it('SUB_MULTIMEDIA_AVSESSION_GETALLCASTDISPLAYS_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { 3707 const isExtendedDisplayCast = canIUse('SystemCapability.Multimedia.AVSession.ExtendedDisplayCast'); 3708 if (isExtendedDisplayCast) { 3709 try { 3710 session.getAllCastDisplays().then((data) => { 3711 if (Array.isArray(data)) { 3712 console.info(`getAllCastDisplays success: ${JSON.stringify(data)}`); 3713 expect(true).assertTrue(); 3714 } else { 3715 console.info('getAllCastDisplays failed'); 3716 expect(false).assertTrue(); 3717 done(); 3718 } 3719 }).catch((err) => { 3720 expect(err.code).assertEqual(6600101); 3721 console.info(`getAllCastDisplays successfully: ${err.code}, message: ${err.message}`) 3722 }) 3723 done(); 3724 } catch (err) { 3725 console.error(`Session getAllCastDisplays: ${err.code}, message: ${err.message}`); 3726 expect(err.code).assertEqual(6600101); 3727 done(); 3728 } 3729 } else { 3730 console.info(`SystemCapability.Multimedia.AVSession.ExtendedDisplayCast false`); 3731 done(); 3732 } 3733 }) 3734 3735 }) 3736} 3737