From 58244004d711535ae509b810494d1d4a9785cf0b Mon Sep 17 00:00:00 2001 From: leiiyb Date: Tue, 8 Nov 2022 12:46:37 +0800 Subject: [PATCH] add setplaybackstate cases Signed-off-by: leiiyb --- .../src/main/js/test/AVSession.test.js | 222 ++++++++++++++++++ 1 file changed, 222 insertions(+) diff --git a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js index 06d059880..cfa9cefd0 100755 --- a/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js +++ b/multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js @@ -1048,6 +1048,228 @@ export default function AVSession() { done(); }) + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1200 + * @tc.name : SETAVPLAYBACKSTATE_1200 + * @tc.desc : Testing set playbackstate - promise + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1200', 0, async function (done) { + let PlaybackState12 = { + state: avSession.PlaybackState.PLAYBACK_STATE_INITIAL, + }; + await session.setAVPlaybackState(PlaybackState12).then(() => { + console.info('TestLog: Set playbackState successfully'); + expect(true).assertTrue(); + }).catch((err) => { + console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + + await sleep(500); + + await controller.getAVPlaybackState().then((data) => { + if (data.state === 0) { + console.info('TestLog: Get State successfully'); + expect(true).assertTrue(); + } else { + console.info('TestLog: Get State failed'); + expect(false).assertTrue(); + } + }).catch((err) => { + console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1300 + * @tc.name : SETAVPLAYBACKSTATE_1300 + * @tc.desc : Testing set playbackstate - promise + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1300', 0, async function (done) { + let PlaybackState13 = { + state: avSession.PlaybackState.PLAYBACK_STATE_PREPARE, + }; + await session.setAVPlaybackState(PlaybackState13).then(() => { + console.info('TestLog: Set playbackState successfully'); + expect(true).assertTrue(); + }).catch((err) => { + console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + + await sleep(500); + + await controller.getAVPlaybackState().then((data) => { + if (data.state === 1) { + console.info('TestLog: Get State successfully'); + expect(true).assertTrue(); + } else { + console.info('TestLog: Get State failed'); + expect(false).assertTrue(); + } + }).catch((err) => { + console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1400 + * @tc.name : SETAVPLAYBACKSTATE_1400 + * @tc.desc : Testing set playbackstate - promise + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1400', 0, async function (done) { + let PlaybackState14 = { + state: avSession.PlaybackState.PLAYBACK_STATE_PAUSE, + }; + await session.setAVPlaybackState(PlaybackState14).then(() => { + console.info('TestLog: Set playbackState successfully'); + expect(true).assertTrue(); + }).catch((err) => { + console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + + await sleep(500); + + await controller.getAVPlaybackState().then((data) => { + if (data.state === 3) { + console.info('TestLog: Get State successfully'); + expect(true).assertTrue(); + } else { + console.info('TestLog: Get State failed'); + expect(false).assertTrue(); + } + }).catch((err) => { + console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1500 + * @tc.name : SETAVPLAYBACKSTATE_1500 + * @tc.desc : Testing set playbackstate - promise + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1500', 0, async function (done) { + let PlaybackState15 = { + state: avSession.PlaybackState.PLAYBACK_STATE_FAST_FORWARD, + }; + await session.setAVPlaybackState(PlaybackState15).then(() => { + console.info('TestLog: Set playbackState successfully'); + expect(true).assertTrue(); + }).catch((err) => { + console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + + await sleep(500); + + await controller.getAVPlaybackState().then((data) => { + if (data.state === 4) { + console.info('TestLog: Get State successfully'); + expect(true).assertTrue(); + } else { + console.info('TestLog: Get State failed'); + expect(false).assertTrue(); + } + }).catch((err) => { + console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1600 + * @tc.name : SETAVPLAYBACKSTATE_1600 + * @tc.desc : Testing set playbackstate - promise + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1600', 0, async function (done) { + let PlaybackState16 = { + state: avSession.PlaybackState.PLAYBACK_STATE_REWIND, + }; + await session.setAVPlaybackState(PlaybackState16).then(() => { + console.info('TestLog: Set playbackState successfully'); + expect(true).assertTrue(); + }).catch((err) => { + console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + + await sleep(500); + + await controller.getAVPlaybackState().then((data) => { + if (data.state === 5) { + console.info('TestLog: Get State successfully'); + expect(true).assertTrue(); + } else { + console.info('TestLog: Get State failed'); + expect(false).assertTrue(); + } + }).catch((err) => { + console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1700 + * @tc.name : SETAVPLAYBACKSTATE_1700 + * @tc.desc : Testing set playbackstate - promise + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_1700', 0, async function (done) { + let PlaybackState17 = { + state: avSession.PlaybackState.PLAYBACK_STATE_STOP, + }; + await session.setAVPlaybackState(PlaybackState17).then(() => { + console.info('TestLog: Set playbackState successfully'); + expect(true).assertTrue(); + }).catch((err) => { + console.info(`TestLog: Set playbackState error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + + await sleep(500); + + await controller.getAVPlaybackState().then((data) => { + if (data.state === 6) { + console.info('TestLog: Get State successfully'); + expect(true).assertTrue(); + } else { + console.info('TestLog: Get State failed'); + expect(false).assertTrue(); + } + }).catch((err) => { + console.info(`TestLog: Get State error: code: ${err.code}, message: ${err.message}`); + expect(false).assertTrue(); + }); + done(); + }) + /* * * @tc.number : SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100 * @tc.name : SETLAUNCHABILITY_0100 -- GitLab