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

!9626 AVSession枚举值覆盖

Merge pull request !9626 from 杜蕊/OpenHarmony-4.0-Beta2
......@@ -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();
......@@ -63,8 +73,8 @@ 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');
......@@ -1447,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}`);
......@@ -1477,7 +1488,7 @@ export default function AVSession() {
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100
......@@ -1817,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();
})
/* *
......@@ -2741,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();
......@@ -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
......@@ -2829,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) {
......@@ -2857,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();
......@@ -2880,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();
......@@ -2939,4 +2973,5 @@ export default function AVSession() {
}
done();
})
}
})
}
......@@ -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';
......@@ -53,22 +55,55 @@ export default function AVSessionControllerJsTest() {
mediaId: QUEUE_ITEM_KEY_WORD,
title: QUEUE_ITEM_KEY_WORD,
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 = {
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));
expect().assertFail();
});
session.activate();
controller = await session.getController();
console.info(TAG + "Create session and controller finished, beforeAll called");
......@@ -1214,6 +1249,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
......
......@@ -66,7 +66,7 @@ export default function AVSessionEnum() {
console.info(`AVCastCategory CATEGORY_LOCAL is ${avSession.AVCastCategory.CATEGORY_LOCAL}`);
expect(avSession.AVCastCategory.CATEGORY_LOCAL).assertEqual(0);
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();
})
......@@ -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
......@@ -39,6 +39,7 @@ export default function AVSessionErrorCode() {
beforeAll(function () {
console.info('TestLog: Start Testing avSession Interfaces');
})
beforeEach(async function () {
......@@ -175,7 +176,6 @@ export default function AVSessionErrorCode() {
}).catch((err) => {
console.info(avSession.AVSessionErrorCode.ERR_CODE_REMOTE_CONNECTION_ERR);
console.info(`Cast audio to remote BusinessError: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
} catch (err) {
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.
先完成此消息的编辑!
想要评论请 注册