提交 18fe0342 编写于 作者: L leiiyb 提交者: LeiiYB
上级 fc297464
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import avSession from '@ohos.multimedia.avsession'; import avSession from '@ohos.multimedia.avsession';
import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from '@ohos/hypium'; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
...@@ -25,11 +25,12 @@ export default function AVSession() { ...@@ -25,11 +25,12 @@ export default function AVSession() {
let type = 'audio'; let type = 'audio';
let session; let session;
let controller; let controller;
let keyItem = {code:0x49, pressedTime:123456789, deviceId:0}; let OutputDeviceInfo = { isRemote: false, audioDeviceId: [0], deviceName: ['LocalDevice'] };
let event = {action:2, key:keyItem, keys:[keyItem]}; let keyItem = { code: 0x49, pressedTime: 123456789, deviceId: 0 };
let event = { action: 2, key: keyItem, keys: [keyItem] };
let context = featureAbility.getContext(); let context = featureAbility.getContext();
function sleep (ms) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
} }
...@@ -37,7 +38,7 @@ export default function AVSession() { ...@@ -37,7 +38,7 @@ export default function AVSession() {
let color = new ArrayBuffer(96); let color = new ArrayBuffer(96);
let bufferArr = new Uint8Array(color); let bufferArr = new Uint8Array(color);
bufferArr.fill('3', 0, 95); bufferArr.fill('3', 0, 95);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, AlphaType: 3}; let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, AlphaType: 3 };
return image.createPixelMap(color, opts); return image.createPixelMap(color, opts);
} }
...@@ -445,7 +446,7 @@ export default function AVSession() { ...@@ -445,7 +446,7 @@ export default function AVSession() {
it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1000', 0, async function (done) { it('SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1000', 0, async function (done) {
let metadata9 = { let metadata9 = {
assetId: '121278', assetId: '121278',
publishDate: new Date(1994,1,1,1), publishDate: new Date(1994, 1, 1, 1),
}; };
await session.setAVMetadata(metadata9).then(() => { await session.setAVMetadata(metadata9).then(() => {
console.info('TestLog: Set publishDate successfully'); console.info('TestLog: Set publishDate successfully');
...@@ -669,7 +670,7 @@ export default function AVSession() { ...@@ -669,7 +670,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,
}; };
await session.setAVPlaybackState(PlaybackState1).then(() => { await session.setAVPlaybackState(PlaybackState1).then(() => {
console.info('TestLog: Set State successfully'); console.info('TestLog: Set State successfully');
...@@ -742,7 +743,7 @@ export default function AVSession() { ...@@ -742,7 +743,7 @@ export default function AVSession() {
*/ */
it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0300', 0, async function (done) { it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0300', 0, async function (done) {
let PlaybackState3 = { let PlaybackState3 = {
position:{elapsedTime:10, updateTime:(new Date()).getTime()}, position: { elapsedTime: 10, updateTime: (new Date()).getTime() },
}; };
await session.setAVPlaybackState(PlaybackState3).then(() => { await session.setAVPlaybackState(PlaybackState3).then(() => {
...@@ -816,7 +817,7 @@ export default function AVSession() { ...@@ -816,7 +817,7 @@ export default function AVSession() {
*/ */
it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0500', 0, async function (done) { it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0500', 0, async function (done) {
let PlaybackState5 = { let PlaybackState5 = {
loopMode:avSession.LoopMode.LOOP_MODE_SEQUENCE, loopMode: avSession.LoopMode.LOOP_MODE_SEQUENCE,
}; };
await session.setAVPlaybackState(PlaybackState5).then(() => { await session.setAVPlaybackState(PlaybackState5).then(() => {
...@@ -1003,7 +1004,7 @@ export default function AVSession() { ...@@ -1003,7 +1004,7 @@ export default function AVSession() {
let PlaybackState10 = { let PlaybackState10 = {
state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, state: avSession.PlaybackState.PLAYBACK_STATE_PLAY,
speed: 1.0, speed: 1.0,
position: {elapsedTime: 10, updateTime: (new Date()).getTime()}, position: { elapsedTime: 10, updateTime: (new Date()).getTime() },
bufferedTime: 1000, bufferedTime: 1000,
loopMode: avSession.LoopMode.LOOP_MODE_SINGLE, loopMode: avSession.LoopMode.LOOP_MODE_SINGLE,
isFavorite: true, isFavorite: true,
...@@ -1032,7 +1033,7 @@ export default function AVSession() { ...@@ -1032,7 +1033,7 @@ export default function AVSession() {
let PlaybackState11 = { let PlaybackState11 = {
state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, state: avSession.PlaybackState.PLAYBACK_STATE_PLAY,
speed: -2, speed: -2,
position: {elapsedTime: -2, updateTime: (new Date()).getTime()}, position: { elapsedTime: -2, updateTime: (new Date()).getTime() },
bufferedTime: -4, bufferedTime: -4,
loopMode: avSession.LoopMode.LOOP_MODE_SINGLE, loopMode: avSession.LoopMode.LOOP_MODE_SINGLE,
isFavorite: true, isFavorite: true,
...@@ -1055,11 +1056,11 @@ export default function AVSession() { ...@@ -1055,11 +1056,11 @@ export default function AVSession() {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100', 0, async function(done) { it('SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100', 0, async function (done) {
let wantAgentInfo = { let wantAgentInfo = {
wants : [ wants: [
{ {
bundleName : 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'com.example.myapplication.MainAbility' abilityName: 'com.example.myapplication.MainAbility'
} }
], ],
...@@ -1217,7 +1218,7 @@ export default function AVSession() { ...@@ -1217,7 +1218,7 @@ export default function AVSession() {
expect(true).assertTrue(); expect(true).assertTrue();
}); });
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}`);
...@@ -1241,7 +1242,7 @@ export default function AVSession() { ...@@ -1241,7 +1242,7 @@ export default function AVSession() {
expect(true).assertTrue(); expect(true).assertTrue();
}); });
await controller.sendControlCommand({command:'pause'}).then(() => { await controller.sendControlCommand({ command: 'pause' }).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}`);
...@@ -1265,7 +1266,7 @@ export default function AVSession() { ...@@ -1265,7 +1266,7 @@ export default function AVSession() {
expect(true).assertTrue(); expect(true).assertTrue();
}); });
await controller.sendControlCommand({command:'stop'}).then(() => { await controller.sendControlCommand({ command: 'stop' }).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}`);
...@@ -1289,7 +1290,7 @@ export default function AVSession() { ...@@ -1289,7 +1290,7 @@ export default function AVSession() {
expect(true).assertTrue(); expect(true).assertTrue();
}); });
await controller.sendControlCommand({command:'playNext'}).then(() => { await controller.sendControlCommand({ command: 'playNext' }).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}`);
...@@ -1313,7 +1314,7 @@ export default function AVSession() { ...@@ -1313,7 +1314,7 @@ export default function AVSession() {
expect(true).assertTrue(); expect(true).assertTrue();
}); });
await controller.sendControlCommand({command:'playPrevious'}).then(() => { await controller.sendControlCommand({ command: 'playPrevious' }).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}`);
...@@ -1337,7 +1338,7 @@ export default function AVSession() { ...@@ -1337,7 +1338,7 @@ export default function AVSession() {
expect(true).assertTrue(); expect(true).assertTrue();
}); });
await controller.sendControlCommand({command:'fastForward'}).then(() => { await controller.sendControlCommand({ command: 'fastForward' }).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}`);
...@@ -1361,7 +1362,7 @@ export default function AVSession() { ...@@ -1361,7 +1362,7 @@ export default function AVSession() {
expect(true).assertTrue(); expect(true).assertTrue();
}); });
await controller.sendControlCommand({command:'rewind'}).then(() => { await controller.sendControlCommand({ command: 'rewind' }).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}`);
...@@ -1390,7 +1391,7 @@ export default function AVSession() { ...@@ -1390,7 +1391,7 @@ export default function AVSession() {
} }
}); });
await controller.sendControlCommand({command:'seek', parameter:10}).then(() => { await controller.sendControlCommand({ command: 'seek', parameter: 10 }).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}`);
...@@ -1419,7 +1420,7 @@ export default function AVSession() { ...@@ -1419,7 +1420,7 @@ export default function AVSession() {
} }
}); });
await controller.sendControlCommand({command:'setSpeed', parameter:2.6}).then(() => { await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.6 }).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}`);
...@@ -1448,8 +1449,10 @@ export default function AVSession() { ...@@ -1448,8 +1449,10 @@ export default function AVSession() {
} }
}); });
await controller.sendControlCommand({command:'setLoopMode', parameter: await controller.sendControlCommand({
avSession.LoopMode.LOOP_MODE_SINGLE}).then(() => { command: 'setLoopMode', parameter:
avSession.LoopMode.LOOP_MODE_SINGLE
}).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}`);
...@@ -1479,7 +1482,7 @@ export default function AVSession() { ...@@ -1479,7 +1482,7 @@ export default function AVSession() {
} }
}); });
await controller.sendControlCommand({command:'toggleFavorite', parameter:'false'}).then(() => { await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).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}`);
...@@ -1563,7 +1566,7 @@ export default function AVSession() { ...@@ -1563,7 +1566,7 @@ export default function AVSession() {
session.off('play'); session.off('play');
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}`);
...@@ -1581,7 +1584,7 @@ export default function AVSession() { ...@@ -1581,7 +1584,7 @@ export default function AVSession() {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level2 * @tc.level : Level2
*/ */
it ('SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200', 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();
...@@ -1598,7 +1601,7 @@ export default function AVSession() { ...@@ -1598,7 +1601,7 @@ export default function AVSession() {
session.off('play', callback1); 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}`);
...@@ -1633,7 +1636,7 @@ export default function AVSession() { ...@@ -1633,7 +1636,7 @@ export default function AVSession() {
session.off('pause'); session.off('pause');
await controller.sendControlCommand({command:'pause'}).then(() => { await controller.sendControlCommand({ command: 'pause' }).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}`);
...@@ -1668,7 +1671,7 @@ export default function AVSession() { ...@@ -1668,7 +1671,7 @@ export default function AVSession() {
session.off('pause', callback1); session.off('pause', callback1);
await controller.sendControlCommand({command:'pause'}).then(() => { await controller.sendControlCommand({ command: 'pause' }).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}`);
...@@ -1704,7 +1707,7 @@ export default function AVSession() { ...@@ -1704,7 +1707,7 @@ export default function AVSession() {
session.off('stop'); session.off('stop');
await controller.sendControlCommand({command:'stop'}).then(() => { await controller.sendControlCommand({ command: 'stop' }).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}`);
...@@ -1739,7 +1742,7 @@ export default function AVSession() { ...@@ -1739,7 +1742,7 @@ export default function AVSession() {
session.off('stop', callback1) session.off('stop', callback1)
await controller.sendControlCommand({command:'stop'}).then(() => { await controller.sendControlCommand({ command: 'stop' }).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}`);
...@@ -1774,7 +1777,7 @@ export default function AVSession() { ...@@ -1774,7 +1777,7 @@ export default function AVSession() {
session.off('playNext'); session.off('playNext');
await controller.sendControlCommand({command:'playNext'}).then(() => { await controller.sendControlCommand({ command: 'playNext' }).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}`);
...@@ -1809,7 +1812,7 @@ export default function AVSession() { ...@@ -1809,7 +1812,7 @@ export default function AVSession() {
session.off('playNext', callback1); session.off('playNext', callback1);
await controller.sendControlCommand({command:'playNext'}).then(() => { await controller.sendControlCommand({ command: 'playNext' }).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}`);
...@@ -1844,7 +1847,7 @@ export default function AVSession() { ...@@ -1844,7 +1847,7 @@ export default function AVSession() {
session.off('playPrevious'); session.off('playPrevious');
await controller.sendControlCommand({command:'playPrevious'}).then(() => { await controller.sendControlCommand({ command: 'playPrevious' }).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}`);
...@@ -1879,7 +1882,7 @@ export default function AVSession() { ...@@ -1879,7 +1882,7 @@ export default function AVSession() {
session.off('playPrevious', callback1); session.off('playPrevious', callback1);
await controller.sendControlCommand({command:'playPrevious'}).then(() => { await controller.sendControlCommand({ command: 'playPrevious' }).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}`);
...@@ -1914,7 +1917,7 @@ export default function AVSession() { ...@@ -1914,7 +1917,7 @@ export default function AVSession() {
session.off('fastForward'); session.off('fastForward');
await controller.sendControlCommand({command:'fastForward'}).then(() => { await controller.sendControlCommand({ command: 'fastForward' }).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}`);
...@@ -1949,7 +1952,7 @@ export default function AVSession() { ...@@ -1949,7 +1952,7 @@ export default function AVSession() {
session.off('fastForward', callback1); session.off('fastForward', callback1);
await controller.sendControlCommand({command:'fastForward'}).then(() => { await controller.sendControlCommand({ command: 'fastForward' }).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}`);
...@@ -1984,7 +1987,7 @@ export default function AVSession() { ...@@ -1984,7 +1987,7 @@ export default function AVSession() {
session.off('rewind'); session.off('rewind');
await controller.sendControlCommand({command:'rewind'}).then(() => { await controller.sendControlCommand({ command: 'rewind' }).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}`);
...@@ -2019,7 +2022,7 @@ export default function AVSession() { ...@@ -2019,7 +2022,7 @@ export default function AVSession() {
session.off('rewind', callback1); session.off('rewind', callback1);
await controller.sendControlCommand({command:'rewind'}).then(() => { await controller.sendControlCommand({ command: 'rewind' }).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}`);
...@@ -2058,7 +2061,7 @@ export default function AVSession() { ...@@ -2058,7 +2061,7 @@ export default function AVSession() {
session.off('seek'); session.off('seek');
await controller.sendControlCommand({command:'seek', parameter:10}).then(() => { await controller.sendControlCommand({ command: 'seek', parameter: 10 }).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}`);
...@@ -2097,7 +2100,7 @@ export default function AVSession() { ...@@ -2097,7 +2100,7 @@ export default function AVSession() {
session.off('seek', callback1); session.off('seek', callback1);
await controller.sendControlCommand({command:'seek', parameter:10}).then(() => { await controller.sendControlCommand({ command: 'seek', parameter: 10 }).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}`);
...@@ -2136,7 +2139,7 @@ export default function AVSession() { ...@@ -2136,7 +2139,7 @@ export default function AVSession() {
session.off('setSpeed'); session.off('setSpeed');
await controller.sendControlCommand({command:'setSpeed', parameter:2.0}).then(() => { await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.0 }).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}`);
...@@ -2175,7 +2178,7 @@ export default function AVSession() { ...@@ -2175,7 +2178,7 @@ export default function AVSession() {
session.off('setSpeed', callback1); session.off('setSpeed', callback1);
await controller.sendControlCommand({command:'setSpeed', parameter:2.0}).then(() => { await controller.sendControlCommand({ command: 'setSpeed', parameter: 2.0 }).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}`);
...@@ -2214,8 +2217,10 @@ export default function AVSession() { ...@@ -2214,8 +2217,10 @@ export default function AVSession() {
session.off('setLoopMode'); session.off('setLoopMode');
await controller.sendControlCommand({command:'setLoopMode', await controller.sendControlCommand({
parameter:avSession.LoopMode.LOOP_MODE_SINGLE}).then(() => { command: 'setLoopMode',
parameter: avSession.LoopMode.LOOP_MODE_SINGLE
}).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}`);
...@@ -2254,8 +2259,10 @@ export default function AVSession() { ...@@ -2254,8 +2259,10 @@ export default function AVSession() {
session.off('setLoopMode', callback1); session.off('setLoopMode', callback1);
await controller.sendControlCommand({command:'setLoopMode', await controller.sendControlCommand({
parameter:avSession.LoopMode.LOOP_MODE_SINGLE}).then(() => { command: 'setLoopMode',
parameter: avSession.LoopMode.LOOP_MODE_SINGLE
}).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}`);
...@@ -2294,7 +2301,7 @@ export default function AVSession() { ...@@ -2294,7 +2301,7 @@ export default function AVSession() {
session.off('toggleFavorite'); session.off('toggleFavorite');
await controller.sendControlCommand({command:'toggleFavorite', parameter:'false'}).then(() => { await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).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}`);
...@@ -2333,7 +2340,7 @@ export default function AVSession() { ...@@ -2333,7 +2340,7 @@ export default function AVSession() {
session.off('toggleFavorite', callback1); session.off('toggleFavorite', callback1);
await controller.sendControlCommand({command:'toggleFavorite', parameter:'false'}).then(() => { await controller.sendControlCommand({ command: 'toggleFavorite', parameter: 'false' }).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}`);
...@@ -2429,5 +2436,111 @@ export default function AVSession() { ...@@ -2429,5 +2436,111 @@ export default function AVSession() {
await sleep(500); await sleep(500);
done(); 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) {
session.on('outputDeviceChange', (callback) => {
if (!callback.isRemote) {
console.info(callback.audioDeviceId.size);
console.info(callback.deviceName.size);
console.info('outputDeviceChange callback registration successful');
expect(true).assertTrue();
} else {
console.info('outputDeviceChange callback registration fail');
expect(false).assertTrue();
}
});
session.off('outputDeviceChange');
await session.getOutputDevice().then((data) => {
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('getOutputDevice successfully');
console.info('Get device information failed');
expect(false).assertTrue();
}
}).catch((err) => {
console.info(`Get device BusinessError: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
})
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) {
session.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_GETCONTROLLER_PROMISE_0100
* @tc.name : GETCONTROLLER_PROMISE_0100
* @tc.desc : Testing get controller
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100', 0, async function (done) {
await session.getController().then((data) => {
console.info('Get controller successfully');
expect(true).assertTrue();
}).catch((err) => {
console.info('Get controller failed');
console.info(`Get controller BusinessError: ${err.code}, message: ${err.message}`);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_CALLBACK_0100
* @tc.name : GETCONTROLLER_CALLBACK_0100
* @tc.desc : Testing get controller
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_CALLBACK_0100', 0, async function (done) {
session.getController((err, data) => {
if (err) {
console.info('Get controller failed');
expect(false).assertTrue();
} else {
console.info('Get controller successfully');
expect(true).assertTrue();
}
})
done();
})
}) })
} }
\ No newline at end of file
...@@ -1680,5 +1680,59 @@ export default function Controller() { ...@@ -1680,5 +1680,59 @@ export default function Controller() {
await sleep(500); await sleep(500);
done(); 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() { ...@@ -24,6 +24,11 @@ export default function AVSessionManager() {
let session; let session;
let controller; let controller;
let id = '9527'; let id = '9527';
let sessionId;
let pid = 100;
let uid = 200;
let audioDevices;
let sessionToken;
let keyItem = {code:10, pressedTime:123456789, deviceId:0}; let keyItem = {code:10, 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();
...@@ -1140,5 +1145,137 @@ export default function AVSessionManager() { ...@@ -1140,5 +1145,137 @@ export default function AVSessionManager() {
}); });
done(); 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'; ...@@ -18,6 +18,7 @@ import AVSessionManager from './AVSessionManager.test.js';
import AVSessionCallback from './AVSessionCallback.test.js'; import AVSessionCallback from './AVSessionCallback.test.js';
import AVSessionControllerCallback from './AVSessionControllerCallback.test.js'; import AVSessionControllerCallback from './AVSessionControllerCallback.test.js';
import AVSessionManagerCallback from './AVSessionManagerCallback.test.js'; import AVSessionManagerCallback from './AVSessionManagerCallback.test.js';
import AVSessionErrorCode from './AVSessionErrorCode.test';
export default function testsuite() { export default function testsuite() {
AVSession() AVSession()
...@@ -26,4 +27,5 @@ export default function testsuite() { ...@@ -26,4 +27,5 @@ export default function testsuite() {
AVSessionCallback() AVSessionCallback()
AVSessionControllerCallback() AVSessionControllerCallback()
AVSessionManagerCallback() 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.
先完成此消息的编辑!
想要评论请 注册