未验证 提交 4dd8c9b2 编写于 作者: O openharmony_ci 提交者: Gitee

!9626 AVSession枚举值覆盖

Merge pull request !9626 from 杜蕊/OpenHarmony-4.0-Beta2
...@@ -29,6 +29,15 @@ export default function AVSession() { ...@@ -29,6 +29,15 @@ export default function AVSession() {
let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 }; let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 };
let event = { action: 2, key: keyItem, keys: [keyItem] }; let event = { action: 2, key: keyItem, keys: [keyItem] };
let context = featureAbility.getContext(); let context = featureAbility.getContext();
let castControlCommandType = 'play';
let deviceInfo = {
castCategory: 0,
deviceId: "deviceId",
deviceName: "deviceName",
}
let outputDeviceInfo = {
devices: [deviceInfo],
}
function sleep(ms) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
...@@ -50,6 +59,7 @@ export default function AVSession() { ...@@ -50,6 +59,7 @@ export default function AVSession() {
console.info('TestLog: Init Session And Controller'); console.info('TestLog: Init Session And Controller');
await avSession.createAVSession(context, tag, type).then((data) => { await avSession.createAVSession(context, tag, type).then((data) => {
session = data; session = data;
session.sessionType = 'audio';
}).catch((err) => { }).catch((err) => {
console.info(`TestLog: Session create error: code: ${err.code}, message: ${err.message}`); console.info(`TestLog: Session create error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -63,8 +73,8 @@ export default function AVSession() { ...@@ -63,8 +73,8 @@ export default function AVSession() {
}); });
controller = await session.getController(); controller = await session.getController();
}); });
})
afterEach(async function (done) { afterEach(async function (done) {
console.info('TestLog: Destroy Session And Controller'); console.info('TestLog: Destroy Session And Controller');
...@@ -667,6 +677,7 @@ export default function AVSession() { ...@@ -667,6 +677,7 @@ export default function AVSession() {
it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0100', 0, async function (done) { it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0100', 0, async function (done) {
let PlaybackState1 = { let PlaybackState1 = {
state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, state: avSession.PlaybackState.PLAYBACK_STATE_PLAY,
activeItemId: 0,
}; };
await session.setAVPlaybackState(PlaybackState1).then(() => { await session.setAVPlaybackState(PlaybackState1).then(() => {
console.info('TestLog: Set State successfully'); console.info('TestLog: Set State successfully');
...@@ -1447,7 +1458,7 @@ export default function AVSession() { ...@@ -1447,7 +1458,7 @@ export default function AVSession() {
}); });
await sleep(500); await sleep(500);
try{ try {
session.deactivate((err) => { session.deactivate((err) => {
if (err) { if (err) {
console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`); console.info(`TestLog: Deactivate session error: code: ${err.code}, message: ${err.message}`);
...@@ -1477,7 +1488,7 @@ export default function AVSession() { ...@@ -1477,7 +1488,7 @@ export default function AVSession() {
done(); done();
}) })
/* * /* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100 * @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100
...@@ -1817,75 +1828,75 @@ export default function AVSession() { ...@@ -1817,75 +1828,75 @@ export default function AVSession() {
}) })
/* * /* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100 * @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100
* @tc.name : 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.desc : Testing offPlay callback
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function * @tc.type : Function
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100', 0, async function (done) { it('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200', 0, async function (done) {
function callback1() { function callback1() {
console.info('TestLog: Play command registration1 success'); console.info('TestLog: Play command registration1 success');
expect(false).assertTrue(); expect(false).assertTrue();
} }
function callback2() { function callback2() {
console.info('TestLog: Play command registration2 success'); console.info('TestLog: Play command registration2 success');
expect(false).assertTrue(); expect(true).assertTrue();
} }
session.on('play', callback1); session.on('play', callback1);
session.on('play', callback2); session.on('play', callback2);
session.off('play'); session.off('play', callback1);
await controller.sendControlCommand({ command: 'play' }).then(() => { await controller.sendControlCommand({ command: 'play' }).then(() => {
console.info('TestLog: Controller send command successfully'); console.info('TestLog: Controller send command successfully');
}).catch((err) => { }).catch((err) => {
console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`); console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
expect(true).assertTrue(); expect(false).assertTrue();
}); });
await sleep(500); await sleep(500);
done(); 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();
})
/* * /* *
...@@ -2741,9 +2752,9 @@ export default function AVSession() { ...@@ -2741,9 +2752,9 @@ export default function AVSession() {
if (!data.isRemote) { if (!data.isRemote) {
expect(true).assertTrue(); expect(true).assertTrue();
} else { } else {
console.info(avSession.OutputDeviceInfo.isRemote); console.info(avSession.OutputDeviceInfo.isRemote);
console.info(avSession.OutputDeviceInfo.audioDeviceId.size); console.info(avSession.OutputDeviceInfo.audioDeviceId.size);
console.info(avSession.OutputDeviceInfo.deviceName.size); console.info(avSession.OutputDeviceInfo.deviceName.size);
console.info('getOutputDevice successfully'); console.info('getOutputDevice successfully');
console.info('Get device information failed'); console.info('Get device information failed');
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -2779,6 +2790,29 @@ export default function AVSession() { ...@@ -2779,6 +2790,29 @@ export default function AVSession() {
done(); 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.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100
* @tc.name : GETCONTROLLER_PROMISE_0100 * @tc.name : GETCONTROLLER_PROMISE_0100
...@@ -2829,8 +2863,8 @@ export default function AVSession() { ...@@ -2829,8 +2863,8 @@ export default function AVSession() {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_CALLBACK_0100', 0, async function (done) { it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_CALLBACK_0100', 0, async function (done) {
let keyItem = {code: 0x49, pressedTime: 123456789, deviceId: 0}; let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 };
let event = {action: 2, key: keyItem, keys: [keyItem]}; let event = { action: 2, key: keyItem, keys: [keyItem] };
try { try {
controller.sendAVKeyEvent(event, (err, data) => { controller.sendAVKeyEvent(event, (err, data) => {
if (err) { if (err) {
...@@ -2857,8 +2891,8 @@ export default function AVSession() { ...@@ -2857,8 +2891,8 @@ export default function AVSession() {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_PROMISE_0100', 0, async function (done) { it('SUB_MULTIMEDIA_AVSESSION_SENDAVKEYEVENT_PROMISE_0100', 0, async function (done) {
let keyItem = {code: 0x49, pressedTime: 123456789, deviceId: 0}; let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 };
let event = {action: 2, key: keyItem, keys: [keyItem]}; let event = { action: 2, key: keyItem, keys: [keyItem] };
await controller.sendAVKeyEvent(event).then(() => { await controller.sendAVKeyEvent(event).then(() => {
console.info('sendAVKeyEvent Successfully'); console.info('sendAVKeyEvent Successfully');
expect(true).assertTrue(); expect(true).assertTrue();
...@@ -2880,7 +2914,7 @@ export default function AVSession() { ...@@ -2880,7 +2914,7 @@ export default function AVSession() {
it('SUB_MULTIMEDIA_AVSESSION_GETREALPLAYBACKPOSITIONSYNC_0100', 0, async function (done) { it('SUB_MULTIMEDIA_AVSESSION_GETREALPLAYBACKPOSITIONSYNC_0100', 0, async function (done) {
let realPosition = -1; let realPosition = -1;
try { try {
realPosition= controller.getRealPlaybackPositionSync(); realPosition = controller.getRealPlaybackPositionSync();
} catch (err) { } catch (err) {
console.info(`TestLog: getRealPlaybackPositionSync error: code: ${err.code}, message: ${err.message}`); console.info(`TestLog: getRealPlaybackPositionSync error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -2939,4 +2973,5 @@ export default function AVSession() { ...@@ -2939,4 +2973,5 @@ export default function AVSession() {
} }
done(); done();
}) })
} })
}
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
import avSession from '@ohos.multimedia.avsession'; import avSession from '@ohos.multimedia.avsession';
import featureAbility from '@ohos.ability.featureAbility'; 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'; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
...@@ -53,22 +55,55 @@ export default function AVSessionControllerJsTest() { ...@@ -53,22 +55,55 @@ export default function AVSessionControllerJsTest() {
mediaId: QUEUE_ITEM_KEY_WORD, mediaId: QUEUE_ITEM_KEY_WORD,
title: QUEUE_ITEM_KEY_WORD, title: QUEUE_ITEM_KEY_WORD,
extras: EXTRAS, extras: EXTRAS,
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 = { const QUEUE_ITEM = {
itemId: QUEUE_ITEM_ID, itemId: QUEUE_ITEM_ID,
description: QUEUE_ITEM_DESCRIPTION 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 = [QUEUE_ITEM];
const ITEMS_ARRAY_ERROR = [QUEUE_ITEM_ERROR];
const QUEUE_TITLE = "title"; const QUEUE_TITLE = "title";
const SKIP_ITEM_ID = 200; const SKIP_ITEM_ID = 200;
beforeAll(async function () { beforeAll(async function () {
session = await avSession.createAVSession(featureAbility.getContext(), "AVSessionDemo", 'audio').catch((err) => { session = await avSession.createAVSession(featureAbility.getContext(), "AVSessionDemo", 'audio').catch((err) => {
console.error(TAG + "Create AVSession error " + JSON.stringify(err)); console.error(TAG + "Create AVSession error " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
session.activate(); session.activate();
controller = await session.getController(); controller = await session.getController();
console.info(TAG + "Create session and controller finished, beforeAll called"); console.info(TAG + "Create session and controller finished, beforeAll called");
...@@ -1214,6 +1249,22 @@ export default function AVSessionControllerJsTest() { ...@@ -1214,6 +1249,22 @@ export default function AVSessionControllerJsTest() {
done(); 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.name:SUB_MULTIMEDIA_SETAVQUEUETITLE_0100
* @tc.desc:setAVQueueTitle - callback * @tc.desc:setAVQueueTitle - callback
......
...@@ -66,7 +66,7 @@ export default function AVSessionEnum() { ...@@ -66,7 +66,7 @@ export default function AVSessionEnum() {
console.info(`AVCastCategory CATEGORY_LOCAL is ${avSession.AVCastCategory.CATEGORY_LOCAL}`); console.info(`AVCastCategory CATEGORY_LOCAL is ${avSession.AVCastCategory.CATEGORY_LOCAL}`);
expect(avSession.AVCastCategory.CATEGORY_LOCAL).assertEqual(0); expect(avSession.AVCastCategory.CATEGORY_LOCAL).assertEqual(0);
console.info(`AVCastCategory CATEGORY_REMOTE is ${avSession.AVCastCategory.CATEGORY_REMOTE}`); console.info(`AVCastCategory CATEGORY_REMOTE is ${avSession.AVCastCategory.CATEGORY_REMOTE}`);
expect(avSession.AVCastCategory.CATEGORY_REMOTE).assertEqual(undefined); expect(avSession.AVCastCategory.CATEGORY_REMOTE).assertEqual(1);
done(); done();
}) })
...@@ -83,8 +83,8 @@ export default function AVSessionEnum() { ...@@ -83,8 +83,8 @@ export default function AVSessionEnum() {
expect(avSession.DeviceType.DEVICE_TYPE_LOCAL).assertEqual(0); expect(avSession.DeviceType.DEVICE_TYPE_LOCAL).assertEqual(0);
console.info(`DeviceType DEVICE_TYPE_TV is ${avSession.DeviceType.DEVICE_TYPE_TV}`); console.info(`DeviceType DEVICE_TYPE_TV is ${avSession.DeviceType.DEVICE_TYPE_TV}`);
expect(avSession.DeviceType.DEVICE_TYPE_TV).assertEqual(2); expect(avSession.DeviceType.DEVICE_TYPE_TV).assertEqual(2);
console.info(`DeviceType DEVICE_TYPE_SPEAKER is ${avSession.DeviceType.DEVICE_TYPE_SPEAKER}`); console.info(`DeviceType DEVICE_TYPE_SPEAKER is ${avSession.DeviceType.DEVICE_TYPE_SMART_SPEAKER}`);
expect(avSession.DeviceType.DEVICE_TYPE_SPEAKER).assertEqual(3); expect(avSession.DeviceType.DEVICE_TYPE_SMART_SPEAKER).assertEqual(3);
console.info(`DeviceType DEVICE_TYPE_BLUETOOTH is ${avSession.DeviceType.DEVICE_TYPE_BLUETOOTH}`); console.info(`DeviceType DEVICE_TYPE_BLUETOOTH is ${avSession.DeviceType.DEVICE_TYPE_BLUETOOTH}`);
expect(avSession.DeviceType.DEVICE_TYPE_BLUETOOTH).assertEqual(10); expect(avSession.DeviceType.DEVICE_TYPE_BLUETOOTH).assertEqual(10);
done(); done();
...@@ -116,12 +116,12 @@ export default function AVSessionEnum() { ...@@ -116,12 +116,12 @@ export default function AVSessionEnum() {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level2 * @tc.level : Level2
*/ */
// it('SUB_MULTIMEDIA_AVSESSION_ERROR_CODE_ENUM_0100', 0, async function (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}`); 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); 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}`); 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); expect(avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_NOT_EXIST).assertEqual(6600109);
// done(); done();
// }) })
}) })
} }
\ No newline at end of file
...@@ -39,6 +39,7 @@ export default function AVSessionErrorCode() { ...@@ -39,6 +39,7 @@ export default function AVSessionErrorCode() {
beforeAll(function () { beforeAll(function () {
console.info('TestLog: Start Testing avSession Interfaces'); console.info('TestLog: Start Testing avSession Interfaces');
}) })
beforeEach(async function () { beforeEach(async function () {
...@@ -175,7 +176,6 @@ export default function AVSessionErrorCode() { ...@@ -175,7 +176,6 @@ export default function AVSessionErrorCode() {
}).catch((err) => { }).catch((err) => {
console.info(avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_ERR); console.info(avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_ERR);
console.info(`Cast audio to remote BusinessError: ${err.code}, message: ${err.message}`); console.info(`Cast audio to remote BusinessError: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
}); });
} catch (err) { } catch (err) {
console.info(`Testing has failed BusinessError: ${err.code}, message: ${err.message}`); console.info(`Testing has failed BusinessError: ${err.code}, message: ${err.message}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册