From 785e3d664e7fe5ba3829f4b34b155c8ceda9b858 Mon Sep 17 00:00:00 2001 From: durui Date: Mon, 31 Jul 2023 19:07:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E5=80=BC=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: durui --- .../src/main/js/test/AVSession.test.js | 39 ++++++++++++- .../main/js/test/AVSessionControllerJSTest.js | 55 +++++++++++++++++++ .../src/main/js/test/AVSessionEnum.test.js | 18 +++--- 3 files changed, 101 insertions(+), 11 deletions(-) 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 2362398a9..859ee74df 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 2cd894f0b..c4af228e2 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 4883f1a33..014dd73e8 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 -- GitLab