From 595b1b43ab67cffaa277173d4c4e98e0bb19e3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyzxzzzzz=E2=80=9D?= <“995220224@qq.com”> Date: Tue, 20 Sep 2022 14:22:11 +0800 Subject: [PATCH] castaudio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “yzxzzzzz” <“995220224@qq.com”> --- .../main/js/test/AVSessionRemoteDfx.test.js | 64 +++++++++---------- .../src/main/js/test/baseLineConfig.json | 5 +- 2 files changed, 34 insertions(+), 35 deletions(-) mode change 100644 => 100755 multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/AVSessionRemoteDfx.test.js mode change 100644 => 100755 multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/baseLineConfig.json diff --git a/multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/AVSessionRemoteDfx.test.js b/multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/AVSessionRemoteDfx.test.js old mode 100644 new mode 100755 index 6deaf5634..23f22e915 --- a/multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/AVSessionRemoteDfx.test.js +++ b/multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/AVSessionRemoteDfx.test.js @@ -21,6 +21,7 @@ import audio from '@ohos.multimedia.audio'; import process from '@ohos.process'; import deviceManager from '@ohos.distributedHardware.deviceManager'; import traceConfig from './avsessionTraceIdConfig.json'; +import baseLineConfig from './baseLineConfig.json'; export default function AVSessionRemoteDfx() { describe('AVSessionRemoteDfx', function() { @@ -94,7 +95,7 @@ export default function AVSessionRemoteDfx() { console.info('beforeAll called avsession server'); function deviceManagerCallback(error, deviceManager) { - console.info('deviceManagerCallback_start') + console.info('deviceManagerCallback_start'); if (error) { console.error("got deviceManager: " + ", error: " + error); } else { @@ -103,12 +104,11 @@ export default function AVSessionRemoteDfx() { let deviceList = deviceManager.getTrustedDeviceListSync(); let deviceId = deviceList[0].deviceId; console.info("online device id: " + deviceId); - console.info("beforeAll done"); } deviceManager.createDeviceManager('com.example.myapplication', deviceManagerCallback); console.info("beforeAll done"); - await avSession.createAVSession(context, tag, type), then((data) => { - console.info(('createAVSession')); + await avSession.createAVSession(context, tag, type).then((data) => { + console.info(('createAVSession start')); session = data; sessionId = session.sessionId; sessionToken = { sessionId, pid, uid }; @@ -136,12 +136,12 @@ export default function AVSessionRemoteDfx() { await audio.getAudioManager().getRoutingManager().then((data) => { console.info('getAudioManager'); audioManager = data; - }) - await audio.getDevice(audio.DeviceFlag.DISTRIBUTED_OUTPUT_DEVICES_FLAG).then((data) => { + }); + await audioManager.getDevices(audio.DeviceFlag.DISTRIBUTED_OUTPUT_DEVICES_FLAG).then((data) => { audioDevices = data; deviceid = audioDevices[0].id; console.info(audioDevices[0].networkId); - console.info('AudioDeviceDescripter'); + console.info('AudioDeviceDescriptor'); devicename = "wgr"; audioDevices[0].name = devicename; audioDevices[0].address = "address"; @@ -154,7 +154,7 @@ export default function AVSessionRemoteDfx() { afterEach(async function(done) { console.info('afterEach called'); - await audioManager.getDevice(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { + await audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { console.info('get localDevice successfully'); localAudioDevice = data; localAudioDevice[0].name = 'name'; @@ -180,7 +180,7 @@ export default function AVSessionRemoteDfx() { }) afterAll(function() { - console.info('AVSessionRemoteDfx: End Testing AVSessionManager Interfaces'); + console.info('AVSessionRemoteDfx: End Testing AVSessionRemote Interfaces'); }) /* * @@ -196,15 +196,14 @@ export default function AVSessionRemoteDfx() { result = false; traceStart("castaudioCallback", traceId); avSession.castAudio(sessionToken, audioDevices, (error) => { - let result = traceEnd("castaudioCallback", traceId); + result = traceEnd("castaudioCallback", traceId); if (error) { console.info(`AVSessionRemoteDfx: Cast audio :ERROR : ${err.message}`); } else { console.info('AVSessionRemoteDfx: Cast audio'); } - expect(result).assertTrue(); }); - await sleep(10000); + await sleep(3000); expect(result).assertTrue(); } done(); @@ -269,15 +268,14 @@ export default function AVSessionRemoteDfx() { result = false; traceStart("castaudio_allCallback", traceId); avSession.castAudio("all", audioDevices, (error) => { - let result = traceEnd("castaudio_allCallback", traceId); + result = traceEnd("castaudio_allCallback", traceId); if (error) { console.info(`AVSessionRemoteDfx: Cast audio :ERROR : ${err.message}`); } else { console.info('AVSessionRemoteDfx: Cast audio'); } - expect(result).assertTrue(); }); - await sleep(10000); + await sleep(3000); expect(result).assertTrue(); } done(); @@ -295,10 +293,10 @@ export default function AVSessionRemoteDfx() { let result = false; let caseResult = true; session.on('outputDeviceChange', (device) => { - result = traceEnd("on_outputDeviceChange", traceId); + result = traceEnd("AVSession::on_outputDeviceChange", traceId); console.error(' ttt AVSessionPlayer[IndexPage] outputDeviceChange success callBack, is: ' + device.deviceName); }); - await audioManager.getDevice(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { + await audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { console.info('get localDevice successfully'); localAudioDevice = data; localAudioDevice[0].name = 'name'; @@ -308,19 +306,20 @@ export default function AVSessionRemoteDfx() { }); let cancel = true; for (let i = 0; i < runTimes; i++) { + let devices = localAudioDevice; cancel = !cancel; if (cancel = true) { devices = audioDevices; } cancel = !cancel; result = false; - traceStart("on_outputDeviceChange", traceId); + traceStart("AVSession::on_outputDeviceChange", traceId); await avSession.castAudio(sessionToken, devices).then(() => { console.info('AVSessionRemoteDfx: on_outputDeviceChange'); }).catch((err) => { console.info(`AVSessionRemoteDfx: on_outputDeviceChange : ERROR : ${err.message}`); }); - await sleep(2000); + await sleep(500); if (result == false) { caseResult = result; } @@ -347,10 +346,10 @@ export default function AVSessionRemoteDfx() { let result = false; let caseResult = true; controller.on('outputDeviceChange', (device) => { - result = traceEnd("on_outputDeviceChange", traceId); + result = traceEnd("AVSessionController::on_outputDeviceChange", traceId); console.error(' ttt AVSessionPlayer[IndexPage] outputDeviceChange success callBack, is: ' + device.deviceName); }); - await audioManager.getDevice(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { + await audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { console.info('get localDevice successfully'); localAudioDevice = data; localAudioDevice[0].name = 'name'; @@ -366,18 +365,18 @@ export default function AVSessionRemoteDfx() { } cancel = !cancel; result = false; - traceStart("on_outputDeviceChange", traceId); + traceStart("AVSessionController::on_outputDeviceChange", traceId); await avSession.castAudio(sessionToken, devices).then(() => { console.info('AVSessionRemoteDfx: on_outputDeviceChange'); }).catch((err) => { console.info(`AVSessionRemoteDfx: on_outputDeviceChange : ERROR : ${err.message}`); }); - await sleep(2000); + await sleep(5000); if (result == false) { caseResult = result; } } - controller.off('outputDevicechange'); + controller.off('outputDeviceChange'); await controller.destroy().then(() => { console.info('AVSessionRemoteDfx: Controller Destroy SUCCESS'); }).catch((err) => { @@ -461,14 +460,13 @@ export default function AVSessionRemoteDfx() { for (let i = 0; i < runTimes; i++) { result = false; traceStart("AVSessionController::getOutputDeviceCallback", traceId); - await controller.getOutputDevice(event, (error) => { - let result = traceEnd("AVSessionController::getOutputDeviceCallback", traceId); + await controller.getOutputDevice((error) => { + result = traceEnd("AVSessionController::getOutputDeviceCallback", traceId); if (error) { console.error('AVSessionRemoteDfx: get OutputDevice : ERROR : ' + error.message); } else { console.info('AVSessionRemoteDfx: get OutputDevice Successfully'); } - expect(result).assertTrue(); }); await sleep(300); expect(result).assertTrue(); @@ -537,14 +535,13 @@ export default function AVSessionRemoteDfx() { for (let i = 0; i < runTimes; i++) { result = false; traceStart("AVSession::getOutputDeviceCallback", traceId); - await avSession.getOutputDevice()(event, (error) => { - let result = traceEnd("AVSession::getOutputDeviceCallback", traceId); + await session.getOutputDevice((error) => { + result = traceEnd("AVSession::getOutputDeviceCallback", traceId); if (error) { console.error('AVSessionRemoteDfx: get OutputDevice : ERROR : ' + error.message); } else { console.info('AVSessionRemoteDfx: get OutputDevice Successfully'); } - expect(result).assertTrue(); }); await sleep(300); expect(result).assertTrue(); @@ -567,7 +564,7 @@ export default function AVSessionRemoteDfx() { }); for (let i = 0; i < runTimes; i++) { traceStart("AVSession::getOutputDevice", traceId); - await avSession.getOutputDevice().then(() => { + await session.getOutputDevice().then(() => { let result = traceEnd("AVSession::getOutputDevice", traceId); expect(result).assertTrue(); }).catch((err) => { @@ -632,14 +629,13 @@ export default function AVSessionRemoteDfx() { for (let i = 0; i < runTimes; i++) { result = false; traceStart("AVSession::getControllercallback", traceId); - await avSession.getController(event, (error) => { - let result = traceEnd("AVSession::getControllercallback", traceId); + await session.getController((error) => { + result = traceEnd("AVSession::getControllercallback", traceId); if (error) { console.error('AVSessionRemoteDfx: get controller : ERROR : ' + error.message); } else { console.info('AVSessionRemoteDfx: get controller Successfully'); } - expect(result).assertTrue(); }); await sleep(300); expect(result).assertTrue(); diff --git a/multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/baseLineConfig.json b/multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/baseLineConfig.json old mode 100644 new mode 100755 index 899eec21b..9e281f7bf --- a/multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/baseLineConfig.json +++ b/multimedia/avsession/avsession_js_standard/avsessionManagerDfx/src/main/js/test/baseLineConfig.json @@ -374,7 +374,10 @@ "castaudio_all": { "delay": 3000 }, - "on_outputDeviceChange": { + "AVSession::on_outputDeviceChange": { + "delay": 300 + }, + "AVSessionController::on_outputDeviceChange": { "delay": 300 }, "AVSession::off_outputDeviceChange": { -- Gitee