diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js index 7ed81ae397239aff9ca9fe9c511504b4c55ab2d3..c05f15d30bdec982f54a8a2e199fe3b6f5d7441e 100644 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js +++ b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js @@ -19,6 +19,11 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from describe('audioTonePlayer',function() { let tonePlayerCallback = null; let name; + let TagTone = 'AudioTonePlayerTest'; + let stringParameter = "invalid_parameter"; + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } beforeAll(function(){ console.log('beforeAll test suit is executed'); }) @@ -1128,4 +1133,180 @@ describe('audioTonePlayer',function() { }, 2000) }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100 + *@tc.name : AudioTonePlayer-create + *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100', 2, function(done) { + audio.createTonePlayer(stringParameter).then(async (result) => { + console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result)); + await result.release().then(() => { + console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); + console.info('recPromiseFail ---------RELEASE---------'); + }).catch((err) => { + console.error("recPromiseFail call release fail " + JSON.stringify(err)); + }); + expect(false).assertTrue(); + }).catch((err) => { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagTone}: load : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagTone}: load : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100 + *@tc.name : AudioTonePlayer-create + *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0200', 2, function(done) { + audio.createTonePlayer(stringParameter, async (err, data)=>{ + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagTone}: load : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagTone}: load : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } else { + await data.release().then(() => { + console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); + console.info('recPromiseFail ---------RELEASE---------'); + }).catch((err) => { + console.error("recPromiseFail call release fail " + JSON.stringify(err)); + }); + expect(false).assertTrue(); + } + done(); + }) + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0100 + *@tc.name : AudioTonePlayer-create-load-stop-release success + *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0100', 2, async function(done) { + let tPlayer = null; + let audioRendererInfo = { + "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, + "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, + "rendererFlags": 0 + } + + await audio.createTonePlayer(audioRendererInfo).then((result) => { + console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result)); + tPlayer = result; + }).catch((err) => { + console.error("recPromiseFail call createTonePlayer fail err: "+ JSON.stringify(err)+ ' tPlayer: '+ tPlayer); + console.error("recPromiseFail call createTonePlayer ---fail"); + }); + + await tPlayer.load(stringParameter).then(() => { + console.info('AudioFrameworkRecLog: ---------LOAD---------'); + expect(false).assertTrue(); + }).catch((err) => { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagTone}: load : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagTone}: load : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }); + + await tPlayer.stop().then(() => { + console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS'); + console.info('AudioFrameworkRecLog: ---------STOP---------'); + }).catch((err) => { + console.error(`promise call stop ---fail error. ${err.message}`); + }); + + await tPlayer.release().then(() => { + console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); + console.info('recPromiseFail ---------RELEASE---------'); + }).catch((err) => { + console.error("recPromiseFail call release fail " + JSON.stringify(err)); + }); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0200 + *@tc.name : AudioTonePlayer-create-load-stop-release success + *@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0200', 2, async function(done) { + let time1 = (new Date()).getTime(); + let tPlayer = null; + let audioRendererInfo = { + "contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION, + "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, + "rendererFlags": 0 + } + + await audio.createTonePlayer(audioRendererInfo).then((result) => { + console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result)); + tPlayer = result; + }).catch((err) => { + console.error("recPromiseFail call createTonePlayer fail err: "+ JSON.stringify(err)+ ' tPlayer: '+ tPlayer); + console.error("recPromiseFail call createTonePlayer ---fail"); + }); + + await tPlayer.load(stringParameter, (err, data)=>{ + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagTone}: load : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagTone}: load : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } else { + console.info('AudioFrameworkRecLog: ---------LOAD---------'); + expect(false).assertTrue(); + } + }); + await sleep(1000); + await tPlayer.stop().then(() => { + console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS'); + console.info('AudioFrameworkRecLog: ---------STOP---------'); + }).catch((err) => { + console.error(`promise call stop ---fail error. ${err.message}`); + }); + + await tPlayer.release().then(() => { + console.info('recPromiseFail TonePlayer : RELEASE SUCCESS'); + console.info('recPromiseFail ---------RELEASE---------'); + }).catch((err) => { + console.error("recPromiseFail call release fail " + JSON.stringify(err)); + }); + + let time2 = (new Date).getTime(); + console.info('time: ' + (time2 - time1)); + done(); + }) }) \ No newline at end of file