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 859ee74dfd6dea4eb07b1d3af62d4cf30abce776..b79fef5922ae9ba45f9417dee5c71c9d157bcfd1 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 @@ -31,12 +31,12 @@ export default function AVSession() { let context = featureAbility.getContext(); let castControlCommandType = 'play'; let deviceInfo = { - castCategory : 0, - deviceId : "deviceId", - deviceName : "deviceName", + castCategory: 0, + deviceId: "deviceId", + deviceName: "deviceName", } let outputDeviceInfo = { - devices : [ deviceInfo ], + devices: [deviceInfo], } function sleep(ms) { @@ -73,7 +73,7 @@ export default function AVSession() { }); controller = await session.getController(); - }); + }); afterEach(async function (done) { @@ -677,7 +677,7 @@ export default function AVSession() { it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0100', 0, async function (done) { let PlaybackState1 = { state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, - activeItemId : 0, + activeItemId: 0, }; await session.setAVPlaybackState(PlaybackState1).then(() => { console.info('TestLog: Set State successfully'); @@ -1458,7 +1458,7 @@ export default function AVSession() { }); await sleep(500); - try{ + try { session.deactivate((err) => { if (err) { console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`); @@ -1488,7 +1488,7 @@ export default function AVSession() { done(); }) - + /* * * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100 @@ -1828,75 +1828,75 @@ export default function AVSession() { }) - /* * - * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100 - * @tc.name : OFFPLAY_0100 + /* * + * @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_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(); - }) + 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(); + }) /* * @@ -2752,9 +2752,9 @@ export default function AVSession() { if (!data.isRemote) { expect(true).assertTrue(); } else { - console.info(avSession.OutputDeviceInfo.isRemote); - console.info(avSession.OutputDeviceInfo.audioDeviceId.size); - console.info(avSession.OutputDeviceInfo.deviceName.size); + console.info(avSession.OutputDeviceInfo.isRemote); + console.info(avSession.OutputDeviceInfo.audioDeviceId.size); + console.info(avSession.OutputDeviceInfo.deviceName.size); console.info('getOutputDevice successfully'); console.info('Get device information failed'); expect(false).assertTrue(); @@ -2863,8 +2863,8 @@ export default function AVSession() { * @tc.level : Level2 */ it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_CALLBACK_0100', 0, async function (done) { - let keyItem = {code: 0x49, pressedTime: 123456789, deviceId: 0}; - let event = {action: 2, key: keyItem, keys: [keyItem]}; + let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 }; + let event = { action: 2, key: keyItem, keys: [keyItem] }; try { controller.sendAVKeyEvent(event, (err, data) => { if (err) { @@ -2891,8 +2891,8 @@ export default function AVSession() { * @tc.level : Level2 */ it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_PROMISE_0100', 0, async function (done) { - let keyItem = {code: 0x49, pressedTime: 123456789, deviceId: 0}; - let event = {action: 2, key: keyItem, keys: [keyItem]}; + let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 }; + let event = { action: 2, key: keyItem, keys: [keyItem] }; await controller.sendAVKeyEvent(event).then(() => { console.info('sendAVKeyEvent Successfully'); expect(true).assertTrue(); @@ -2914,7 +2914,7 @@ export default function AVSession() { it('SUB_MULTIMEDIA_AVSESSION_GETREALPLAYBACKPOSITIONSYNC_0100', 0, async function (done) { let realPosition = -1; try { - realPosition= controller.getRealPlaybackPositionSync(); + realPosition = controller.getRealPlaybackPositionSync(); } catch (err) { console.info(`TestLog: getRealPlaybackPositionSync error: code: ${err.code}, message: ${err.message}`); expect(false).assertTrue(); diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionControllerJSTest.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionControllerJSTest.js index c4af228e2a4f66bc3daadf1c194e64014e17b154..f600550777a214a2eada505726d6c401aa3dea68 100644 --- a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionControllerJSTest.js +++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionControllerJSTest.js @@ -33,9 +33,6 @@ export default function AVSessionControllerJsTest() { let receivedParam2 = null; let receivedExtras = null; let receivedExtras2 = null; -// let value = Uint8Array = resourceManager.getRawFileContent('IMAGE_URI'); -// let imageSource = imageImageSource = image.createImageSource(value.buffer); -// let imagePixel = image.PixelMap = imageSource.createPixelMap({desiredSize:{width: 150, height: 150}}); const INVALID_STRING = "invalid string"; const UPDATE_LYRICS_EVENT = "dynamic_lyrics"; const UPDATE_LYRICS_WANT_PARAMS = { @@ -58,17 +55,16 @@ export default function AVSessionControllerJsTest() { mediaId: QUEUE_ITEM_KEY_WORD, title: QUEUE_ITEM_KEY_WORD, extras: EXTRAS, -// icon: undefined, iconUri: "iconUri", mediaSize: 10, albumTitle: "albumTitle", - albumCoverUri : "albumCoverUri", - lyricContent : "lyricContent", - lyricUri : "lyricUri", - mediaUri : "mediaUri", - startPosition : 0, - creditsPosition : 0, - appName : "appName" + albumCoverUri: "albumCoverUri", + lyricContent: "lyricContent", + lyricUri: "lyricUri", + mediaUri: "mediaUri", + startPosition: 0, + creditsPosition: 0, + appName: "appName" }; const QUEUE_ITEM_DESCRIPTION_ERROR = { mediaId: QUEUE_ITEM_KEY_WORD, @@ -78,13 +74,13 @@ export default function AVSessionControllerJsTest() { iconUri: "iconUri", mediaSize: 10, albumTitle: "albumTitle", - albumCoverUri : "albumCoverUri", - lyricContent : "lyricContent", - lyricUri : "lyricUri", - mediaUri : "mediaUri", - startPosition : 0, - creditsPosition : 0, - appName : "appName" + albumCoverUri: "albumCoverUri", + lyricContent: "lyricContent", + lyricUri: "lyricUri", + mediaUri: "mediaUri", + startPosition: 0, + creditsPosition: 0, + appName: "appName" }; const QUEUE_ITEM = { itemId: QUEUE_ITEM_ID, @@ -107,7 +103,7 @@ export default function AVSessionControllerJsTest() { expect().assertFail(); }); session.activate(); - + controller = await session.getController(); console.info(TAG + "Create session and controller finished, beforeAll called");