提交 785e3d66 编写于 作者: D durui

枚举值覆盖

Signed-off-by: Ndurui <durui15@huawei.com>
上级 130ddd7e
......@@ -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();
})
}
})
}
......@@ -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
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册