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 06d05988056197a103a053ab2fee1423f463f580..cfa9cefd0670d3c66369037f5343f08e1b79ae4b 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