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 2362398a97f483f89e1cc4f35b89dc558fd003f4..859ee74dfd6dea4eb07b1d3af62d4cf30abce776 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 @@ -29,6 +29,15 @@ export default function AVSession() { let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 }; let event = { action: 2, key: keyItem, keys: [keyItem] }; let context = featureAbility.getContext(); + let castControlCommandType = 'play'; + let deviceInfo = { + castCategory : 0, + deviceId : "deviceId", + deviceName : "deviceName", + } + let outputDeviceInfo = { + devices : [ deviceInfo ], + } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); @@ -50,6 +59,7 @@ export default function AVSession() { console.info('TestLog: Init Session And Controller'); await avSession.createAVSession(context, tag, type).then((data) => { session = data; + session.sessionType = 'audio'; }).catch((err) => { console.info(`TestLog: Session create error: code: ${err.code}, message: ${err.message}`); expect(false).assertTrue(); @@ -64,7 +74,7 @@ export default function AVSession() { controller = await session.getController(); }); - }) + afterEach(async function (done) { console.info('TestLog: Destroy Session And Controller'); @@ -667,6 +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, }; await session.setAVPlaybackState(PlaybackState1).then(() => { console.info('TestLog: Set State successfully'); @@ -2779,6 +2790,29 @@ export default function AVSession() { done(); }) + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0200 + * @tc.name : GETOUTPUTDEVICE_CALLBACK_0100 + * @tc.desc : Testing get output device + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0200', 0, async function (done) { + await session.getOutputDevice().then((data) => { + if (data.devices.length > 0) { + console.info('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0200' + JSON.stringify(data.devices[0].deviceid)) + console.info('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0200' + JSON.stringify(data.devices[0].deviceName)) + console.info('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0200' + JSON.stringify(data.devices[0].castCategory)) + expect(true).assertTrue(); + } + }).catch((err) => { + console.info(`Get device BusinessError: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }) + done(); + }) + /* * * @tc.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100 * @tc.name : GETCONTROLLER_PROMISE_0100 @@ -2939,4 +2973,5 @@ export default function AVSession() { } done(); }) - } + }) +} 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 2cd894f0ba43c350c7fc65e0d43426e7c6bff86e..c4af228e2a4f66bc3daadf1c194e64014e17b154 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 @@ -15,6 +15,8 @@ import avSession from '@ohos.multimedia.avsession'; import featureAbility from '@ohos.ability.featureAbility'; +//import image from '@ohos.multimedia.image'; +//import resourceManager from '@ohos.resourceManager'; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; @@ -31,6 +33,9 @@ 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 = { @@ -53,15 +58,49 @@ 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" + }; + const QUEUE_ITEM_DESCRIPTION_ERROR = { + 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" }; const QUEUE_ITEM = { itemId: QUEUE_ITEM_ID, description: QUEUE_ITEM_DESCRIPTION } + const QUEUE_ITEM_ERROR = { + itemId: QUEUE_ITEM_ID, + description: QUEUE_ITEM_DESCRIPTION_ERROR + } const ITEMS_ARRAY = [QUEUE_ITEM]; + const ITEMS_ARRAY_ERROR = [QUEUE_ITEM_ERROR]; const QUEUE_TITLE = "title"; const SKIP_ITEM_ID = 200; + + beforeAll(async function () { session = await avSession.createAVSession(featureAbility.getContext(), "AVSessionDemo", 'audio').catch((err) => { console.error(TAG + "Create AVSession error " + JSON.stringify(err)); @@ -1214,6 +1253,22 @@ export default function AVSessionControllerJsTest() { done(); }) + /* + * @tc.name:SUB_MULTIMEDIA_SETAVQUEUEITEMS_0300 + * @tc.desc:setAVQueueItems - error situation + * @tc.type: FUNC + * @tc.require: I6KTU4 + */ + it("SUB_MULTIMEDIA_SETAVQUEUEITEMS_0300", 0, async function (done) { + await session.setAVQueueItems(ITEMS_ARRAY_ERROR).catch((err) => { + console.error(TAG + "SUB_MULTIMEDIA_SETAVQUEUEITEMS_0300 error " + JSON.stringify(err)); + expect(err.code).assertEqual(401); + done(); + }); + await sleep(2000); + console.info(TAG + "SUB_MULTIMEDIA_SETAVQUEUEITEMS_0300 finished"); + done(); + }) /* * @tc.name:SUB_MULTIMEDIA_SETAVQUEUETITLE_0100 * @tc.desc:setAVQueueTitle - callback diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionEnum.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionEnum.test.js index 4883f1a33fde103bfa0f5f186e90dbf4b3f6e1fb..014dd73e8afa043bd3d777fb2046600a48dafd6a 100644 --- a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionEnum.test.js +++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionEnum.test.js @@ -83,8 +83,8 @@ export default function AVSessionEnum() { expect(avSession.DeviceType.DEVICE_TYPE_LOCAL).assertEqual(0); console.info(`DeviceType DEVICE_TYPE_TV is ${avSession.DeviceType.DEVICE_TYPE_TV}`); expect(avSession.DeviceType.DEVICE_TYPE_TV).assertEqual(2); - console.info(`DeviceType DEVICE_TYPE_SPEAKER is ${avSession.DeviceType.DEVICE_TYPE_SPEAKER}`); - expect(avSession.DeviceType.DEVICE_TYPE_SPEAKER).assertEqual(3); + console.info(`DeviceType DEVICE_TYPE_SPEAKER is ${avSession.DeviceType.DEVICE_TYPE_SMART_SPEAKER}`); + expect(avSession.DeviceType.DEVICE_TYPE_SMART_SPEAKER).assertEqual(3); console.info(`DeviceType DEVICE_TYPE_BLUETOOTH is ${avSession.DeviceType.DEVICE_TYPE_BLUETOOTH}`); expect(avSession.DeviceType.DEVICE_TYPE_BLUETOOTH).assertEqual(10); done(); @@ -116,12 +116,12 @@ export default function AVSessionEnum() { * @tc.type : Function * @tc.level : Level2 */ -// it('SUB_MULTIMEDIA_AVSESSION_ERROR_CODE_ENUM_0100', 0, async function (done) { -// console.info(`AVSessionErrorCode ERR_CODE_DEVICE_CONNECTION_FAILED is ${avSession.AVSessionErrorCode.ERR_CODE_DEVICE_CONNECTION_FAILED}`); -// expect(avSession.AVSessionErrorCode.ERR_CODE_DEVICE_CONNECTION_FAILED).assertEqual(undefined); -// console.info(`AVSessionErrorCode ERR_CODE_REMOTE_CONNECTION_NOT_EXIST is ${avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_NOT_EXIST}`); -// expect(avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_NOT_EXIST).assertEqual(6600109); -// done(); -// }) + it('SUB_MULTIMEDIA_AVSESSION_ERROR_CODE_ENUM_0100', 0, async function (done) { + console.info(`AVSessionErrorCode ERR_CODE_DEVICE_CONNECTION_FAILED is ${avSession.AVSessionErrorCode.ERR_CODE_DEVICE_CONNECTION_FAILED}`); + expect(avSession.AVSessionErrorCode.ERR_CODE_DEVICE_CONNECTION_FAILED).assertEqual(6600108); + console.info(`AVSessionErrorCode ERR_CODE_REMOTE_CONNECTION_NOT_EXIST is ${avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_NOT_EXIST}`); + expect(avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_NOT_EXIST).assertEqual(6600109); + done(); + }) }) } \ No newline at end of file