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

!8867 avsession新增接口用例合入

Merge pull request !8867 from 张乐杰/OpenHarmony-4.0-Beta1
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import avSession from '@ohos.multimedia.avsession';
import featureAbility from '@ohos.ability.featureAbility';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
const TAG = "[AVSessionJSTest]";
export default function AVSessionJsTest() {
describe("AVSessionJsTest", function () {
let session = null;
let controller = null;
let receivedCallback = false;
let receivedCallback2 = false;
let receivedString = null;
let receivedString2 = null;
let receivedParam = null;
let receivedParam2 = null;
const INVALID_STRING = "invalid string";
const UPDATE_LYRICS_EVENT = "dynamic_lyrics";
const UPDATE_LYRICS_WANT_PARAMS = {
lyric: "This is my lyrics"
};
const COMMON_COMMAND_STRING = "common_command";
const COMMON_COMMAND_PARAMS = {
command: "This is my command"
};
const CUSTOM_EXTRAS = {
extras: "This is custom media packet"
};
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 avSession.createController(session.sessionId).catch((err) => {
console.error(TAG + "Create controller error " + JSON.stringify(err));
expect().assertFail();
})
console.info(TAG + "Create session finished, beforeAll called");
})
afterAll(function () {
session.destroy();
console.info(TAG + 'afterAll called')
})
beforeEach(function () {
console.info(TAG + 'beforeEach called')
})
afterEach(function () {
console.info(TAG + 'afterEach called')
})
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
function commonCommandCallback1(command, args) {
console.log(TAG + "Callback1 received event: " + JSON.stringify(command));
console.log(TAG + "Callback1 received args: " + JSON.stringify(args));
if (command != COMMON_COMMAND_STRING) {
console.error(TAG + "Callback1 common command unmatch");
expect().assertFail();
}
receivedCallback = true;
receivedString = command;
receivedParam = args;
}
function commonCommandCallback2(command, args) {
console.log(TAG + "Callback2 received event: " + JSON.stringify(command));
console.log(TAG + "Callback2 received args: " + JSON.stringify(args));
if (command != COMMON_COMMAND_STRING) {
console.error(TAG + "Callback2 common command unmatch");
expect().assertFail();
}
receivedCallback2 = true;
receivedString2 = command;
receivedParam2 = args;
}
/*
* @tc.name:SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0100
* @tc.desc:Set session event - callback
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0100", 0, async function (done) {
session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS, (err) => {
if (err) {
console.error(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0100 error " + JSON.stringify(err));
expect().assertFail();
done();
}
console.info(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0100 finished");
expect(true).assertTrue();
done();
});
})
/*
* @tc.name:SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0200
* @tc.desc:Set session event - promise
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0200", 0, async function (done) {
await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0200 error " + JSON.stringify(err));
expect().assertFail();
done();
});
console.info(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0200 finished");
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0300
* @tc.desc:Set session event - one param
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0300", 0, async function (done) {
let errCode = 0;
await session.dispatchSessionEvent(UPDATE_LYRICS_EVENT).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0300 caught error" + err.code);
errCode = err.code;
});
sleep(200).then(() => {
expect(errCode == 401).assertTrue();
done();
})
})
/*
* @tc.name:SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0400
* @tc.desc:Set session event - invalid params
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0400", 0, async function (done) {
let errCode = 0;
await session.dispatchSessionEvent(UPDATE_LYRICS_WANT_PARAMS, UPDATE_LYRICS_WANT_PARAMS).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_DISPATCHSESSIONEVENT_0400 caught error" + err.code);
errCode = err.code;
});
sleep(200).then(() => {
expect(errCode == 401).assertTrue();
done();
})
})
/*
* @tc.name:SUB_MULTIMEDIA_SETEXTRAS_0100
* @tc.desc:Set extras - callback
* @tc.type: FUNC
* @tc.require: I6TD43
*/
it("SUB_MULTIMEDIA_SETEXTRAS_0100", 0, async function (done) {
session.setExtras(CUSTOM_EXTRAS, (err) => {
if (err) {
console.error(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0100 error " + JSON.stringify(err));
expect().assertFail();
done();
}
console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0100 finished");
expect(true).assertTrue();
done();
});
})
/*
* @tc.name:SUB_MULTIMEDIA_SETEXTRAS_0200
* @tc.desc:Set extras - promise
* @tc.type: FUNC
* @tc.require: I6TD43
*/
it("SUB_MULTIMEDIA_SETEXTRAS_0200", 0, async function (done) {
await session.setExtras(CUSTOM_EXTRAS).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0200 error " + JSON.stringify(err));
expect().assertFail();
done();
});
console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0200 finished");
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_SETEXTRAS_0300
* @tc.desc:Set extras - zero param
* @tc.type: FUNC
* @tc.require: I6TD43
*/
it("SUB_MULTIMEDIA_SETEXTRAS_0300", 0, async function (done) {
let errCode = 0;
await session.setExtras().catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0300 caught error" + err.code);
errCode = err.code;
});
sleep(200).then(() => {
expect(errCode == 401).assertTrue();
console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0300 finished");
done();
})
})
/*
* @tc.name:SUB_MULTIMEDIA_SETEXTRAS_0400
* @tc.desc:Set extras - invalid params
* @tc.type: FUNC
* @tc.require: I6TD43
*/
it("SUB_MULTIMEDIA_SETEXTRAS_0400", 0, async function (done) {
let errCode = 0;
await session.setExtras(INVALID_STRING).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0400 caught error" + err.code);
errCode = err.code;
});
sleep(200).then(() => {
expect(errCode == 401).assertTrue();
console.info(TAG + "SUB_MULTIMEDIA_SETEXTRAS_0400 finished");
done();
})
})
/*
* @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100
* @tc.desc:One on function - common command
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100", 0, async function (done) {
session.on('commonCommand', commonCommandCallback1);
await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100 error " + JSON.stringify(err));
expect().assertFail();
done();
});
sleep(200).then(() => {
if (receivedCallback) {
console.log(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100 Received common command");
expect(receivedString == COMMON_COMMAND_STRING).assertTrue();
expect(receivedParam.command == COMMON_COMMAND_PARAMS.command).assertTrue();
} else {
console.error(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0100 Common command not received");
expect().assertFail();
}
receivedCallback = false;
receivedString = null;
receivedParam = null;
done();
})
})
/*
* @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200
* @tc.desc:Two on functions - common command
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200", 0, async function (done) {
session.on('commonCommand', commonCommandCallback1);
session.on('commonCommand', commonCommandCallback2);
await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200 Send common command error " + JSON.stringify(err));
expect().assertFail();
done();
});
await sleep(200);
if (receivedCallback && receivedCallback2) {
console.log(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200 Received common command");
expect(receivedString == COMMON_COMMAND_STRING).assertTrue();
expect(receivedParam.command == COMMON_COMMAND_PARAMS.command).assertTrue();
expect(receivedString2 == COMMON_COMMAND_STRING).assertTrue();
expect(receivedParam2.command == COMMON_COMMAND_PARAMS.command).assertTrue();
expect(true).assertTrue();
} else {
console.error(TAG + "SUB_MULTIMEDIA_ONCOMMONCOMMAND_0200 Common command not received");
expect().assertFail();
}
receivedCallback = false;
receivedString = null;
receivedParam = null;
receivedCallback2 = false;
receivedString2 = null;
receivedParam2 = null;
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0300
* @tc.desc:One on functions - one param
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0300", 0, async function (done) {
try {
session.on('commonCommand');
} catch (err) {
expect(err.code == 401).assertTrue();
}
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0400
* @tc.desc:One on functions - three params
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0400", 0, async function (done) {
try {
session.on('sessionEventChange', commonCommandCallback1, commonCommandCallback2);
} catch (err) {
expect(err.code == 401).assertTrue();
}
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_ONCOMMONCOMMAND_0500
* @tc.desc:One on functions - invalid type
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_ONCOMMONCOMMAND_0500", 0, async function (done) {
try {
session.on('commonCommand', INVALID_STRING);
} catch (err) {
expect(err.code == 401).assertTrue();
}
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100
* @tc.desc:Two on functions and one off function
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100", 0, async function (done) {
session.on('commonCommand', commonCommandCallback1);
session.on('commonCommand', commonCommandCallback2);
session.off('commonCommand', commonCommandCallback2);
await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100 Send common command error" + JSON.stringify(err));
expect().assertFail();
done();
});
await sleep(200);
if (receivedCallback && !receivedCallback2) {
console.log(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100 finished");
expect(receivedString == COMMON_COMMAND_STRING).assertTrue();
expect(receivedParam.command == COMMON_COMMAND_PARAMS.command).assertTrue();
expect(true).assertTrue();
} else {
console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0100 failed");
expect().assertFail();
}
receivedCallback = false;
receivedString = null;
receivedParam = null;
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200
* @tc.desc:Two on functions and two off function
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200", 0, async function (done) {
session.on('commonCommand', commonCommandCallback1);
session.on('commonCommand', commonCommandCallback2);
session.off('commonCommand', commonCommandCallback1);
session.off('commonCommand', commonCommandCallback2);
await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200 Send common command error" + JSON.stringify(err));
expect().assertFail();
done();
});
await sleep(200);
if (!receivedCallback && !receivedCallback2) {
console.log(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200 finished");
expect(true).assertTrue();
} else {
console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0200 failed");
expect().assertFail();
}
receivedCallback = false;
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300
* @tc.desc:Two on functions and off all function
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300", 0, async function (done) {
session.on('commonCommand', commonCommandCallback1);
session.on('commonCommand', commonCommandCallback2);
session.off('commonCommand');
await controller.sendCommonCommand(COMMON_COMMAND_STRING, COMMON_COMMAND_PARAMS).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300 Send common command error" + JSON.stringify(err));
expect().assertFail();
done();
});
await sleep(200);
if (!receivedCallback && !receivedCallback2) {
console.log(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300 finished");
expect(true).assertTrue();
} else {
console.error(TAG + "SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0300 failed");
expect().assertFail();
}
receivedCallback = false;
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0400
* @tc.desc:Two on functions and off function - three params
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0400", 0, async function (done) {
try {
session.on('commonCommand', commonCommandCallback1);
session.on('commonCommand', commonCommandCallback2);
session.off('commonCommand', commonCommandCallback1, commonCommandCallback2);
} catch (err) {
expect(err.code == 401).assertTrue();
}
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0500
* @tc.desc:One on functions and off all function - invalid type
* @tc.type: FUNC
* @tc.require: I6ETY6
*/
it("SUB_MULTIMEDIA_OFFCOMMONCOMMAND_0500", 0, async function (done) {
try {
session.on('commonCommand', commonCommandCallback1);
session.off('commonCommand', INVALID_STRING);
} catch (err) {
expect(err.code == 401).assertTrue();
}
done();
})
})
}
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AVSessionManager from '@ohos.multimedia.avsession';
import featureAbility from '@ohos.ability.featureAbility';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
const TAG = "[AVSessionManagerJSTest]";
export default function AVSessionManagerJSTest() {
describe("AVSessionManagerJSTest", function () {
let session = null;
let controller = null;
let receivedCallback = false;
let receivedCallback2 = false;
let context = featureAbility.getContext();
const INVALID_STRING = "invalid string";
const UPDATE_LYRICS_EVENT = "dynamic_lyrics";
const UPDATE_LYRICS_WANT_PARAMS = {
lyrics: "This is my lyrics"
}
beforeAll(async function () {
console.info(TAG + "beforeAll called");
})
afterAll(function () {
console.info(TAG + 'afterAll called');
})
beforeEach(function () {
console.info(TAG + 'beforeEach called');
})
afterEach(function () {
console.info(TAG + 'afterEach called');
})
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
async function createSessionTask() {
session = await AVSessionManager.createAVSession(context, "AVSessionDemo", 'audio').catch((err) => {
console.error(TAG + "Create AVSession error " + JSON.stringify(err));
expect().assertFail();
});
console.info(TAG + "Create session finished");
}
function destroySessionTask() {
session.destroy();
console.info(TAG + 'Destroy session finished');
}
async function createControllerTask() {
controller = await AVSessionManager.createController(session.sessionId).catch((err) => {
console.error(TAG + "Create controller error " + JSON.stringify(err));
expect().assertFail();
});
console.info(TAG + "Create controller finished");
}
function destroyControllerTask() {
controller.destroy();
console.info(TAG + 'Destroy session finished');
}
/*
* @tc.name:SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0100
* @tc.desc:One on function - lyrics session event
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0100", 0, async function (done) {
await createSessionTask();
let descriptors = await AVSessionManager.getHistoricalSessionDescriptors().catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0100 error " + JSON.stringify(err));
expect().assertFail();
destroySessionTask();
done();
});
if (descriptors.length >= 1) {
console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].isActive : ${descriptors[0].isActive}`);
console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].type : ${descriptors[0].type}`);
console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].sessionTag : ${descriptors[0].sessionTag}`);
console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].sessionId : ${descriptors[0].sessionId}`);
console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].elementName.bundleName : ${descriptors[0].elementName.bundleName}`);
expect(true).assertTrue();
} else {
console.error(TAG + " SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0100 get history session number : " + descriptors.length + ", error ");
expect().assertFail();
}
destroySessionTask();
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0200
* @tc.desc:One on function - lyrics session event
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0200", 0, async function (done) {
await createSessionTask();
let descriptors = await AVSessionManager.getHistoricalSessionDescriptors(10).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0200 error " + JSON.stringify(err));
expect().assertFail();
destroySessionTask();
done();
});
if (descriptors.length >= 1) {
expect(true).assertTrue();
} else {
console.error(TAG + " SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0200 get history session number : " + descriptors.length + ", error ");
expect().assertFail();
}
destroySessionTask();
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0300
* @tc.desc:One on function - lyrics session event
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0300", 0, async function (done) {
await createSessionTask();
let descriptors = await AVSessionManager.getHistoricalSessionDescriptors(0).catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0300 error " + JSON.stringify(err));
expect().assertFail();
destroySessionTask();
done();
});
if (descriptors.length == 0) {
expect(true).assertTrue();
} else {
console.error(TAG + " SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0300 get history session number : " + descriptors.length + ", error ");
expect().assertFail();
}
destroySessionTask();
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0400
* @tc.desc:One on function - lyrics session event
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0400", 0, async function (done) {
let flag = false;
await createSessionTask();
let descriptors = await AVSessionManager.getHistoricalSessionDescriptors("0").catch((err) => {
flag = true;
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0400 param error " + JSON.stringify(err));
expect(true).assertTrue();
destroySessionTask();
done();
});
if (flag || (!descriptors)) {
console.error(TAG + " SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0400 error input param has callback , pass");
expect(true).assertTrue();
destroySessionTask();
done();
} else {
console.error(TAG + " SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0400 error input param should not return , error");
expect().assertFail();
destroySessionTask();
done();
}
})
/*
* @tc.name:SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0500
* @tc.desc:One on function - lyrics session event
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0500", 0, async function (done) {
await createSessionTask();
await AVSessionManager.getHistoricalSessionDescriptors((err, data) => {
if (err) {
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0500 error " + JSON.stringify(err));
expect().assertFail();
destroySessionTask();
done();
}
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0500 return :" + data);
if (data.length >= 1) {
expect(true).assertTrue();
} else {
console.error(TAG + " SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0500 get history session number : " + data.length + ", error ");
expect().assertFail();
}
destroySessionTask();
done();
});
})
/*
* @tc.name:SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0600
* @tc.desc:One on function - lyrics session event
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0600", 0, async function (done) {
await createSessionTask();
destroySessionTask();
let descriptors = await AVSessionManager.getHistoricalSessionDescriptors().catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0600 error " + JSON.stringify(err));
expect().assertFail();
destroySessionTask();
done();
});
if (descriptors.length >= 1) {
expect(true).assertTrue();
} else {
console.error(TAG + " SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0600 get history session number : " + descriptors.length + ", error ");
expect().assertFail();
}
destroySessionTask();
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0700
* @tc.desc:One on function - lyrics session event
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0700", 0, async function (done) {
let descriptors = await AVSessionManager.getHistoricalSessionDescriptors().catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0700 error " + JSON.stringify(err));
expect().assertFail();
done();
});
let size = descriptors.length;
await createSessionTask();
destroySessionTask();
let descriptorsRetry = await AVSessionManager.getHistoricalSessionDescriptors().catch((err) => {
console.error(TAG + "SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0700 retry error " + JSON.stringify(err));
expect().assertFail();
done();
});
if (descriptorsRetry.length >= size) {
expect(true).assertTrue();
} else {
console.error(TAG + " SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0700 get history session number : " + descriptors.length + ", error ");
expect().assertFail();
}
done();
})
/*
* @tc.name:SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0800
* @tc.desc:One on function - lyrics session event
* @tc.type: FUNC
* @tc.require: I6C6IN
*/
it("SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0800", 0, async function (done) {
await createSessionTask();
for (let i = 0; i < 100; i++) {
let descriptors = await AVSessionManager.getHistoricalSessionDescriptors().catch((err) => {
console.error(TAG + " loop : " + i + ", SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0800 error " + JSON.stringify(err));
expect().assertFail();
destroySessionTask();
done();
});
if (descriptors.length >= 1) {
expect(true).assertTrue();
} else {
console.error(TAG + " loop : " + i + ", SUB_MULTIMEDIA_GETHISTORICAL_SESSIONDESCRIPTORS_0800 get history session number : " + descriptors.length + ", error ");
expect().assertFail();
destroySessionTask();
done();
}
}
destroySessionTask();
done();
})
})
}
\ No newline at end of file
......@@ -17,6 +17,9 @@ import AVSessionManager from './AVSessionManager.test.js';
import AVSessionCallback from './AVSessionCallback.test.js';
import AVSessionManagerCallback from './AVSessionManagerCallback.test.js';
import AVSessionErrorCode from './AVSessionErrorCode.test';
import AVSessionControllerJSTest from './AVSessionControllerJSTest.js';
import AVSessionManagerJSTest from './AVSessionManagerJSTest.js';
import AVSessionJSTest from './AVSessionJSTest.js';
export default function testsuite() {
AVSession()
......@@ -24,4 +27,7 @@ export default function testsuite() {
AVSessionCallback()
AVSessionManagerCallback()
AVSessionErrorCode()
AVSessionJSTest ()
AVSessionManagerJSTest ()
AVSessionControllerJSTest ()
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册