From 737cb920992c27d89f01edcc54d36836269c80d7 Mon Sep 17 00:00:00 2001 From: hangliebe Date: Mon, 1 Aug 2022 22:36:56 +0800 Subject: [PATCH] audio mock Signed-off-by: hangliebe --- .../napi/ohos_multimedia_audio.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js index af10a417..23c6aaba 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js @@ -33,6 +33,9 @@ export function mockMultimediaAudio() { sampleRates: [paramMock.paramNumberMock], channelCounts: [paramMock.paramNumberMock], channelMasks: [paramMock.paramNumberMock], + networkId: [paramMock.paramStringMock], + interruptGroupId: [paramMock.paramNumberMock], + volumeGroupId: [paramMock.paramNumberMock], } const DeviceChangeAction = { type: "[PC Preview] unknow type", @@ -94,6 +97,11 @@ export function mockMultimediaAudio() { capturerState: AudioState, deviceDescriptors: [AudioDeviceDescriptor], } + const AudioRendererFilter = { + uid: "[PC Preview] unknow uid", + rendererInfo: AudioRendererInfo, + rendererId: "[PC Preview] unknow rendererId", + } const AudioCapturer = { state: "[PC Preview] unknow state", getCapturerInfo: function (...args) { @@ -641,6 +649,18 @@ export function mockMultimediaAudio() { resolve(AudioStreamManager); }) } + }, + getRoutingManager: function (...args) { + console.warn("AudioManager.getRoutingManager interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AudioRoutingManager); + } else { + return new Promise((resolve, reject) => { + resolve(AudioStreamManager); + }) + } } } const AudioStreamManager = { @@ -687,6 +707,42 @@ export function mockMultimediaAudio() { } } } + const AudioRoutingManager = { + on: function (...args) { + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'deviceChange') { + console.warn("AudioRoutingManager.on_deviceChange interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + } + } + }, + off: function (...args) { + console.warn("AudioRoutingManager.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + getDevices: function (...args) { + console.warn("AudioRoutingManager.getDevices interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var AudioDeviceDescriptors = new Array(AudioDeviceDescriptor) + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AudioDeviceDescriptors); + } else { + return new Promise((resolve, reject) => { + resolve(AudioDeviceDescriptors); + }) + } + }, + selectOutputDevice: function (...args) { + console.warn("AudioRoutingManager.selectOutputDevice interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + selectOutputDeviceByFilter: function (...args) { + console.warn("AudioRoutingManager.selectOutputDeviceByFilter interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + } const audio = { AudioState: { STATE_INVALID: -1,