diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js index 82c721b1c7ae36d70dab3dc0c4b5b0f609500e64..2362398a97f483f89e1cc4f35b89dc558fd003f4 100644 --- a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js +++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js @@ -1817,6 +1817,76 @@ export default function AVSession() { }) + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100 + * @tc.name : OFFPLAY_0100 + * @tc.desc : Testing offPlay callback + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100', 0, async function (done) { + function callback1() { + console.info('TestLog: Play command registration1 success'); + expect(false).assertTrue(); + } + + function callback2() { + console.info('TestLog: Play command registration2 success'); + expect(false).assertTrue(); + } + + session.on('play', callback1); + + session.on('play', callback2); + + session.off('play'); + + await controller.sendControlCommand({ command: 'play' }).then(() => { + console.info('TestLog: Controller send command successfully'); + }).catch((err) => { + console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); + expect(true).assertTrue(); + }); + await sleep(500); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200 + * @tc.name : OFFPLAY_0200 + * @tc.desc : Testing offPlay callback + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200', 0, async function (done) { + function callback1() { + console.info('TestLog: Play command registration1 success'); + expect(false).assertTrue(); + } + + function callback2() { + console.info('TestLog: Play command registration2 success'); + expect(true).assertTrue(); + } + + session.on('play', callback1); + + session.on('play', callback2); + + session.off('play', callback1); + + await controller.sendControlCommand({ command: 'play' }).then(() => { + console.info('TestLog: Controller send command successfully'); + }).catch((err) => { + console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + await sleep(500); + done(); + }) + /* * * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPAUSE_0100 diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionCallback.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionCallback.test.js index bb0695ec806b1354d21254df767363b622388e6d..78a80b093ae28c0cd8777ec9ec7f33c925a55465 100644 --- a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionCallback.test.js +++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionCallback.test.js @@ -59,12 +59,7 @@ export default function AVSessionCallback() { expect(false).assertTrue(); }); - await avSession.createController(session.sessionId).then((data) => { - controller = data; - }).catch((err) => { - console.info(`TestLog: Controller created error: code: ${err.code}, message: ${err.message}`); - expect(false).assertTrue(); - }); + controller = await session.getController(); }) afterEach(async function (done) { diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js index abc6fde6250ad00e9296f74cb04f0086e63b2af0..03ebf84544456179841b8855f790890d8f7a814a 100644 --- a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js +++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js @@ -59,12 +59,7 @@ export default function AVSessionErrorCode() { expect(false).assertTrue(); }); - await avSession.createController(session.sessionId).then((data) => { - controller = data; - }).catch((err) => { - console.info(`TestLog: Controller create error: code: ${err.code}, message: ${err.message}`); - expect(false).assertTrue(); - }); + controller = await session.getController(); }) afterEach(async function (done) {