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

!6400 新增XTS覆盖分布式接口

Merge pull request !6400 from LeiiYB/cherry-pick-1667784913
......@@ -1680,5 +1680,59 @@ export default function Controller() {
await sleep(500);
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100
* @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_0100', 0, async function (done) {
controller.on('outputDeviceChange', (callback) => {
if (!callback.isRemote) {
console.info('outputDeviceChange callback registration successful');
expect(true).assertTrue();
} else {
console.info('outputDeviceChange callback registration fail');
expect(false).assertTrue();
}
});
controller.off('outputDeviceChange');
controller.getOutputDevice((err, value) => {
if (err) {
console.info(`Get device information BusinessError: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
} else if (!value.isRemote) {
console.info('Get device information successfully');
expect(true).assertTrue();
} else {
console.info('Get device information failed');
expect(false).assertTrue();
}
});
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100
* @tc.name : GETOUTPUTDEVICE_PROMISE_0100
* @tc.desc : Testing get output device
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100', 0, async function (done) {
await controller.getOutputDevice().then((value) => {
console.info('Get device information successfully');
expect(true).assertTrue();
}).catch((err) => {
console.info(`Get device BusinessError: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
})
done();
})
})
}
\ No newline at end of file
/*
* Copyright (c) 2022 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
import featureAbility from '@ohos.ability.featureAbility';
export default function AVSessionErrorCode() {
describe('AVSessionErrorCode', function () {
let tag = 'ApplicationA';
let type = 'audio';
let session;
let pid = 100;
let uid = 200;
let audioDevices;
let sessionToken;
let controller;
let id = '9527';
let sessionId;
let keyItem = {code:10, pressedTime:123456789, deviceId:0};
let event = {action:2, key:keyItem, keys:[keyItem]};
let context = featureAbility.getContext();
function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
beforeAll(function () {
console.info('TestLog: Start Testing avSession Interfaces');
})
beforeEach(async function () {
console.info('TestLog: Init Session And Controller');
await avSession.createAVSession(context, tag, type).then((data) => {
session = data;
}).catch((err) => {
expect(err.code == 6600101).assertTrue();
console.info(avSession.AVSessionErrorCode.ERR_CODE_SERVICE_EXCEPTION);
console.info(`TestLog: Session create error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
await session.activate().then(() => {
console.info('TestLog: Session activate');
}).catch((err) => {
console.info(`TestLog: Session activate error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
await avSession.createController(session.sessionId).then((data) => {
controller = data;
}).catch((err) => {
console.info(`TestLog: Controller create error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
})
afterEach(async function (done) {
console.info('TestLog: Destroy Session And Controller');
await session.destroy().then(() => {
console.info('TestLog: Session destroy success');
}).catch((err) => {
console.info(`TestLog: Session destroy error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
await controller.destroy().then(() => {
console.info('TestLog: Controller destroy success');
}).catch((err) => {
console.info(`TestLog: Controller destroy error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
done();
})
afterAll(function () {
console.info('TestLog: End Testing avSession Interfaces');
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100
* @tc.name : SETMETADATA_0100
* @tc.desc : Testing set metadata - promise
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100', 0, async function (done) {
let metadata1 = {
assetId: '121278',
};
await sleep(500);
await session.setAVMetadata(metadata1).then(() => {
console.info('TestLog: Set metadata successfully');
expect(true).assertTrue();
}).catch((err) => {
expect(err.code == 6600102).assertTrue();
console.info(avSession.AVSessionErrorCode.ERR_CODE_SESSION_NOT_EXIST);
console.info(`TestLog: Set metadata error: code: ${err.code}, message: ${err.message}`);
});
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_DESTROYCONTROLLER_PROMISE_0100
* @tc.name : DESTROYCONTROLLER_0100
* @tc.desc : Testing destroy the controller - promise
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
*/
it('SUB_MULTIMEDIA_AVSESSION_DESTROYCONTROLLER_PROMISE_0100', 0, async function (done) {
await controller.destroy().then(() => {
console.info('TestLog: Controller destroy successfully');
expect(true).assertTrue();
}).catch((err) => {
expect(err.code == 6600103).assertTrue();
console.info(avSession.AVSessionErrorCode.ERR_CODE_CONTROLLER_NOT_EXIST);
console.info(`TestLog: Controller destroy error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
done();
})
/* *
* @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(true).assertTrue();
}
session.on('play', callback1);
await controller.sendControlCommand({ command: 'play' }).then(() => {
console.info('TestLog: Controller send command successfully');
expect(true).assertTrue();
}).catch((err) => {
expect(err.code == 6600105).assertTrue();
console.info(avSession.AVSessionErrorCode.ERR_CODE_COMMAND_INVALID);
console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
});
await sleep(500);
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100
* @tc.name : CAST_AUDIO_0100
* @tc.desc : Testing cast audio
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100', 0, async function (done) {
sessionId = session.sessionId;
sessionToken = { sessionId, pid, uid };
try {
await avSession.castAudio(sessionToken, audioDevices).then(() => {
console.info('Cast audio to remote');
}).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}`);
expect(true).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100
* @tc.name : ONHANDLEKEYEVENT_0100
* @tc.desc : Testing Handle KeyEvent callback
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100', 0, async function (done) {
session.on('handleKeyEvent', (callback) => {
if (callback.action === 2) {
console.info('TestLog: Handle keyEvent callback registration successful');
expect(true).assertTrue();
} else {
console.info('TestLog: Handle keyEvent callback registration error');
expect(false).assertTrue();
}
});
await controller.sendAVKeyEvent(event).then(() => {
console.info('TestLog: Controller send AVKeyEvent successfully');
}).catch((err) => {
expect(err.code == 6600106).assertTrue();
console.info(avSession.AVSessionErrorCode.ERR_CODE_SESSION_INACTIVE);
console.info(`TestLog: Controller send AVKeyEvent error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
await sleep(500);
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100
* @tc.name : ONPLAY_0100
* @tc.desc : Testing onPlay callback
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100', 0, async function (done) {
session.on('play', () => {
console.info('TestLog: Play command callback registration successful');
expect(true).assertTrue();
});
await controller.sendControlCommand({ command: 'play' }).then(() => {
console.info('TestLog: Controller send command successfully');
}).catch((err) => {
expect(err.code == 6600107).assertTrue();
console.info(avSession.AVSessionErrorCode.ERR_CODE_MESSAGE_OVERLOAD);
console.info(`TestLog: Controller send command error: code: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
await sleep(500);
done();
})
})
}
\ No newline at end of file
......@@ -24,6 +24,11 @@ export default function AVSessionManager() {
let session;
let controller;
let id = '9527';
let sessionId;
let pid = 100;
let uid = 200;
let audioDevices;
let sessionToken;
let keyItem = {code:10, pressedTime:123456789, deviceId:0};
let event = {action:2, key:keyItem, keys:[keyItem]};
let context = featureAbility.getContext();
......@@ -1140,5 +1145,137 @@ export default function AVSessionManager() {
});
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100
* @tc.name : CAST_AUDIO_PROMISE_0100
* @tc.desc : Testing cast audio
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100', 0, async function (done) {
await avSession.createAVSession(context, tag, type).then((data) => {
session = data;
sessionId = session.sessionId;
sessionToken = { sessionId, pid, uid };
}).catch((err) => {
console.info(`Session create BusinessError: ${err.code}, message: ${err.message}`);
});
await avSession.castAudio(sessionToken, audioDevices).then(() => {
console.info('Cast audio to remote');
}).catch((err) => {
console.info(`Cast audio to remote BusinessError: ${err.code}, message: ${err.message}`);
expect(true).assertTrue();
});
await session.destroy().then(() => {
console.info('TestLog: Session Destroy SUCCESS');
}).catch((err) => {
console.info(`TestLog: Session Destroy error: code: ${err.code}, message: ${err.message}`);
});
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0200
* @tc.name : CAST_AUDIO_PROMISE_0200
* @tc.desc : Testing cast audio with all session
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0200', 0, async function (done) {
await avSession.createAVSession(context, tag, type).then((data) => {
session = data;
sessionId = session.sessionId;
sessionToken = { sessionId, pid, uid };
}).catch((err) => {
console.info(`Session create BusinessError: ${err.code}, message: ${err.message}`);
});
await avSession.castAudio('all', audioDevices).then(() => {
console.info('Cast audio to remote');
}).catch((err) => {
console.info(`Cast audio to remote BusinessError: ${err.code}, message: ${err.message}`);
expect(true).assertTrue();
});
await session.destroy().then(() => {
console.info('TestLog: Session Destroy SUCCESS');
}).catch((err) => {
console.info(`TestLog: Session Destroy error: code: ${err.code}, message: ${err.message}`);
});
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_CALLBACK_0100
* @tc.name : CAST_AUDIO_CALLBACK_0100
* @tc.desc : Testing cast audio
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_CALLBACK_0100', 0, async function (done) {
await avSession.createAVSession(context, tag, type).then((data) => {
session = data;
sessionId = session.sessionId;
sessionToken = { sessionId, pid, uid };
}).catch((err) => {
console.info(`Session create BusinessError: ${err.code}, message: ${err.message}`);
});
avSession.castAudio(sessionToken, audioDevices, (err) => {
if (err) {
console.info(`Cast audio to remote BusinessError: ${err.code}, message: ${err.message}`);
expect(true).assertTrue();
} else {
console.info('Cast audio to remote device');
}
});
await session.destroy().then(() => {
console.info('TestLog: Session Destroy SUCCESS');
}).catch((err) => {
console.info(`TestLog: Session Destroy error: code: ${err.code}, message: ${err.message}`);
});
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_CALLBACK_0200
* @tc.name : CAST_AUDIO_CALLBACK_0200
* @tc.desc : Testing cast audio
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_CALLBACK_0200', 0, async function (done) {
await avSession.createAVSession(context, tag, type).then((data) => {
session = data;
sessionId = session.sessionId;
sessionToken = { sessionId, pid, uid };
}).catch((err) => {
console.info(`Session create BusinessError: ${err.code}, message: ${err.message}`);
});
avSession.castAudio('all', audioDevices, (err) => {
if (err) {
console.info(`Cast audio to remote BusinessError: ${err.code}, message: ${err.message}`);
expect(true).assertTrue();
} else {
console.info('Cast audio to remote device');
}
});
await session.destroy().then(() => {
console.info('TestLog: Session Destroy SUCCESS');
}).catch((err) => {
console.info(`TestLog: Session Destroy error: code: ${err.code}, message: ${err.message}`);
});
done();
})
})
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ import AVSessionManager from './AVSessionManager.test.js';
import AVSessionCallback from './AVSessionCallback.test.js';
import AVSessionControllerCallback from './AVSessionControllerCallback.test.js';
import AVSessionManagerCallback from './AVSessionManagerCallback.test.js';
import AVSessionErrorCode from './AVSessionErrorCode.test';
export default function testsuite() {
AVSession()
......@@ -26,4 +27,5 @@ export default function testsuite() {
AVSessionCallback()
AVSessionControllerCallback()
AVSessionManagerCallback()
AVSessionErrorCode()
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册