mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 14:33:33 -04:00
!241 add multimedia mock js api for ide
Merge pull request !241 from AOL/OpenHarmony-3.1-API9-SDK-Canary
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -43,12 +43,6 @@ import { mockFile } from './file'
|
||||
import { mockGeolocation } from './geolocation'
|
||||
import { mockInputMethod } from './inputMethod'
|
||||
import { mockInputMethodEngine } from './inputMethodEngine'
|
||||
import {
|
||||
mockMultimediaImage,
|
||||
mockMultimediaMedia,
|
||||
mockMultimediaMedialibrary,
|
||||
mockMultimediaAudio
|
||||
} from './multimedia'
|
||||
import { mockNetwork } from './network'
|
||||
import { mockOhosNfc } from './ohos/nfc'
|
||||
import { mockNotification } from './notification'
|
||||
@@ -131,10 +125,6 @@ export function mockSystemPlugin() {
|
||||
mockInputMethod()
|
||||
mockInputMethodEngine()
|
||||
mockOhosRequest()
|
||||
mockMultimediaImage()
|
||||
mockMultimediaMedia()
|
||||
mockMultimediaMedialibrary()
|
||||
mockMultimediaAudio()
|
||||
mockCall()
|
||||
mockData()
|
||||
mockRadio()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -90,6 +90,13 @@ import { mockStack } from './stack'
|
||||
import { mockTreeMap } from './treemap'
|
||||
import { mockTreeSet } from './treeset'
|
||||
import { mockVector } from './vector'
|
||||
import { mockMultimediaCamera } from './multimediaCamera'
|
||||
import { mockMultimediaAudio } from './multimediaAudio'
|
||||
import { mockMultimediaImage } from './multimediaImage'
|
||||
import { mockMultimediaMedia } from './multimediaMedia'
|
||||
import { mockMultimediaMediaLibrary } from './multimediaMediaLibrary'
|
||||
|
||||
|
||||
|
||||
export function mockRequireNapiFun() {
|
||||
global.requireNapi = function (...args) {
|
||||
@@ -248,6 +255,16 @@ export function mockRequireNapiFun() {
|
||||
return mockTreeSet();
|
||||
case "util.Vector":
|
||||
return mockVector();
|
||||
case "multimedia.mediaLibrary":
|
||||
return mockMultimediaMediaLibrary();
|
||||
case "multimedia.media":
|
||||
return mockMultimediaMedia();
|
||||
case "multimedia.image":
|
||||
return mockMultimediaImage();
|
||||
case "multimedia.camera":
|
||||
return mockMultimediaCamera();
|
||||
case "multimedia.audio":
|
||||
return mockMultimediaAudio();
|
||||
default:
|
||||
return global.requireNapiPreview(...args);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,703 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockMultimediaAudio() {
|
||||
const interruptActionMock = {
|
||||
actionType: "[PC Preview] unknow actionType",
|
||||
type: "[PC Preview] unknow type",
|
||||
hint: "[PC Preview] unknow hint",
|
||||
activated: "[PC Preview] unknow activated",
|
||||
}
|
||||
const DeviceRoleMock = "[PC Preview] unknow DeviceRole"
|
||||
const DeviceTypeMock = "[PC Preview] unknow DeviceType"
|
||||
const AudioDeviceDescriptorMock = {
|
||||
deviceRole: DeviceRoleMock,
|
||||
deviceType: DeviceTypeMock,
|
||||
}
|
||||
const DeviceChangeActionMock = {
|
||||
type: "[PC Preview] unknow type",
|
||||
deviceDescriptors: AudioDeviceDescriptorMock,
|
||||
}
|
||||
const AudioRingModeMock = '[PC Preview] unknow AudioRingMode'
|
||||
const VolumeEventMock = {
|
||||
volumeType: "[PC Preview] unknow volumeType",
|
||||
volume: "[PC Preview] unknow volume",
|
||||
updateUi: "[PC Preview] unknow updateUi",
|
||||
}
|
||||
const AudioSceneMock = '[PC Preview] unknow AudioScene'
|
||||
const AudioStreamInfoMock = {
|
||||
samplingRate: "[PC Preview] unknow samplingRate",
|
||||
channels: "[PC Preview] unknow channels",
|
||||
sampleFormat: "[PC Preview] unknow sampleFormat",
|
||||
encodingType: "[PC Preview] unknow encodingType",
|
||||
}
|
||||
const AudioRendererInfoMock = {
|
||||
content: "[PC Preview] unknow content",
|
||||
usage: "[PC Preview] unknow usage",
|
||||
rendererFlags: "[PC Preview] unknow rendererFlags",
|
||||
}
|
||||
const AudioRendererOptionsMock = {
|
||||
streamInfo: AudioStreamInfoMock,
|
||||
rendererInfo: AudioRendererInfoMock,
|
||||
}
|
||||
const AudioCapturerInfoMock = {
|
||||
source: "[PC Preview] unknow source",
|
||||
capturerFlags: "[PC Preview] unknow capturerFlags",
|
||||
}
|
||||
const AudioCapturerOptionsMock = {
|
||||
streamInfo: AudioStreamInfoMock,
|
||||
capturerInfo: AudioCapturerInfoMock,
|
||||
}
|
||||
const AudioStateMock = '[PC Preview] unknow AudioState'
|
||||
const AudioRendererRateMock = '[PC Preview] unknow AudioRendererRate'
|
||||
const InterruptEventMock = '[PC Preview] unknow InterruptEvent'
|
||||
const AudioCapturerMock = {
|
||||
state: "[PC Preview] unknow state",
|
||||
getCapturerInfo: function (...args) {
|
||||
console.warn("AudioCapturer.getCapturerInfo 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, AudioCapturerInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioCapturerInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getStreamInfo: function (...args) {
|
||||
console.warn("AudioCapturer.getStreamInfo 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, AudioStreamInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioStreamInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
start: function (...args) {
|
||||
console.warn("AudioCapturer.start 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
read: function (...args) {
|
||||
console.warn("AudioCapturer.read 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, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAudioTime: function (...args) {
|
||||
console.warn("AudioCapturer.getAudioTime 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
stop: function (...args) {
|
||||
console.warn("AudioCapturer.stop 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("AudioCapturer.release 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getBufferSize: function (...args) {
|
||||
console.warn("AudioCapturer.getBufferSize 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("AudioCapturer.on 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("AudioCapturer.off interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
const AudioRendererMock ={
|
||||
state: "[PC Preview] unknow state",
|
||||
getRendererInfo: function (...args) {
|
||||
console.warn("AudioRenderer.getRendererInfo 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, AudioRendererInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioRendererInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getStreamInfo: function (...args) {
|
||||
console.warn("AudioRenderer.getStreamInfo 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, AudioStreamInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioStreamInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
start: function (...args) {
|
||||
console.warn("AudioRenderer.start 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
write: function (...args) {
|
||||
console.warn("AudioRenderer.write 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAudioTime: function (...args) {
|
||||
console.warn("AudioRenderer.getAudioTime 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
drain: function (...args) {
|
||||
console.warn("AudioRenderer.drain 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
pause: function (...args) {
|
||||
console.warn("AudioRenderer.pause 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
stop: function (...args) {
|
||||
console.warn("AudioRenderer.stop 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("AudioRenderer.release 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getBufferSize: function (...args) {
|
||||
console.warn("AudioRenderer.getBufferSize 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setRenderRate: function (...args) {
|
||||
console.warn("AudioRenderer.setRenderRate 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getRenderRate: function (...args) {
|
||||
console.warn("AudioRenderer.getRenderRate 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, AudioRendererRateMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioRendererRateMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("AudioRenderer.on 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("AudioRenderer.off interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
const audioManagerMock = {
|
||||
on: function (...args) {
|
||||
console.warn("AudioManager.on 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') {
|
||||
if (args[0] == 'interrupt') {
|
||||
args[len - 1].call(this, interruptActionMock);
|
||||
} else if (args[0] == 'deviceChange') {
|
||||
args[len - 1].call(this, DeviceChangeActionMock);
|
||||
} else if (args[0] == 'volumeChange') {
|
||||
args[len - 1].call(this, VolumeEventMock);
|
||||
} else if (args[0] == 'ringerModeChange') {
|
||||
args[len - 1].call(this, AudioRingModeMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("AudioManager.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("AudioManager.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(AudioDeviceDescriptorMock)
|
||||
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);
|
||||
})
|
||||
}
|
||||
},
|
||||
isDeviceActive: function (...args) {
|
||||
console.warn("AudioManager.isDeviceActive 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, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setDeviceActive: function (...args) {
|
||||
console.warn("AudioManager.setDeviceActive 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setRingerMode: function (...args) {
|
||||
console.warn("AudioManager.setRingerMode 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setAudioParameter: function (...args) {
|
||||
console.warn("AudioManager.setAudioParameter 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setVolume: function (...args) {
|
||||
console.warn("AudioManager.setVolume 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getVolume: function (...args) {
|
||||
console.warn("AudioManager.getVolume 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMinVolume: function (...args) {
|
||||
console.warn("AudioManager.getMinVolume 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMaxVolume: function (...args) {
|
||||
console.warn("AudioManager.getMaxVolume 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isMute: function (...args) {
|
||||
console.warn("AudioManager.isMute 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, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
mute: function (...args) {
|
||||
console.warn("AudioManager.mute 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
isActive: function (...args) {
|
||||
console.warn("AudioManager.isActive 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, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isMicrophoneMute: function (...args) {
|
||||
console.warn("AudioManager.isMicrophoneMute 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, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setMicrophoneMute: function (...args) {
|
||||
console.warn("AudioManager.setMicrophoneMute 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getAudioParameter: function (...args) {
|
||||
console.warn("AudioManager.getAudioParameter 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, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getRingerMode: function (...args) {
|
||||
console.warn("AudioManager.getRingerMode 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, AudioRingModeMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioRingModeMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setAudioScene: function (...args) {
|
||||
console.warn("AudioManager.setAudioScene 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getAudioScene: function (...args) {
|
||||
console.warn("AudioManager.getAudioScene 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, AudioSceneMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioSceneMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
const audio = {
|
||||
AudioState: {
|
||||
STATE_INVALID: -1,
|
||||
STATE_NEW: 0,
|
||||
STATE_PREPARED: 1,
|
||||
STATE_RUNNING: 2,
|
||||
STATE_STOPPED: 3,
|
||||
STATE_RELEASED:4,
|
||||
STATE_PAUSED: 5,
|
||||
},
|
||||
AudioVolumeType: {
|
||||
VOICE_CALL: 0,
|
||||
RINGTONE: 2,
|
||||
MEDIA: 3,
|
||||
VOICE_ASSISTANT: 9,
|
||||
},
|
||||
ContentType: {
|
||||
CONTENT_TYPE_UNKNOWN: 0,
|
||||
CONTENT_TYPE_SPEECH: 1,
|
||||
CONTENT_TYPE_MUSIC: 2,
|
||||
CONTENT_TYPE_MOVIE: 3,
|
||||
CONTENT_TYPE_SONIFICATION: 4,
|
||||
CONTENT_TYPE_RINGTONE: 5,
|
||||
},
|
||||
StreamUsage: {
|
||||
STREAM_USAGE_UNKNOWN: 0,
|
||||
STREAM_USAGE_MEDIA: 1,
|
||||
STREAM_USAGE_VOICE_COMMUNICATION: 2,
|
||||
STREAM_USAGE_NOTIFICATION_RINGTONE: 6,
|
||||
},
|
||||
DeviceFlag: {
|
||||
OUTPUT_DEVICES_FLAG: 1,
|
||||
INPUT_DEVICES_FLAG: 2,
|
||||
ALL_DEVICES_FLAG: 3,
|
||||
},
|
||||
ActiveDeviceType: {
|
||||
SPEAKER: 2,
|
||||
BLUETOOTH_SCO: 7,
|
||||
},
|
||||
AudioRingMode: {
|
||||
RINGER_MODE_NORMAL: 2,
|
||||
RINGER_MODE_SILENT: 0,
|
||||
RINGER_MODE_VIBRATE: 1,
|
||||
},
|
||||
AudioSampleFormat: {
|
||||
SAMPLE_FORMAT_INVALID: -1,
|
||||
SAMPLE_FORMAT_U8: 0,
|
||||
SAMPLE_FORMAT_S16LE: 1,
|
||||
SAMPLE_FORMAT_S24LE: 2,
|
||||
SAMPLE_FORMAT_S32LE: 3,
|
||||
},
|
||||
AudioChannel: {
|
||||
CHANNEL_1: 1,
|
||||
CHANNEL_2: 2,
|
||||
},
|
||||
AudioSamplingRate: {
|
||||
SAMPLE_RATE_8000: 8000,
|
||||
SAMPLE_RATE_11025: 11025,
|
||||
SAMPLE_RATE_12000: 12000,
|
||||
SAMPLE_RATE_16000: 16000,
|
||||
SAMPLE_RATE_22050: 22050,
|
||||
SAMPLE_RATE_24000: 24000,
|
||||
SAMPLE_RATE_32000: 32000,
|
||||
SAMPLE_RATE_44100: 44100,
|
||||
SAMPLE_RATE_48000: 48000,
|
||||
SAMPLE_RATE_64000: 64000,
|
||||
SAMPLE_RATE_96000: 96000,
|
||||
},
|
||||
AudioEncodingType: {
|
||||
ENCODING_TYPE_INVALID: -1,
|
||||
ENCODING_TYPE_RAW: 0,
|
||||
},
|
||||
AudioRendererRate: {
|
||||
RENDER_RATE_NORMAL: 0,
|
||||
RENDER_RATE_DOUBLE: 1,
|
||||
RENDER_RATE_HALF: 2,
|
||||
},
|
||||
SourceType: {
|
||||
SOURCE_TYPE_INVALID: -1,
|
||||
SOURCE_TYPE_MIC: 0,
|
||||
SOURCE_TYPE_VOICE_COMMUNICATION: 7,
|
||||
},
|
||||
AudioScene: {
|
||||
AUDIO_SCENE_DEFAULT: 0,
|
||||
AUDIO_SCENE_RINGING: 1,
|
||||
AUDIO_SCENE_PHONE_CALL: 2,
|
||||
AUDIO_SCENE_VOICE_CHAT: 3,
|
||||
},
|
||||
AudioSampleFormat: {
|
||||
SAMPLE_FORMAT_INVALID: -1,
|
||||
SAMPLE_FORMAT_U8: 0,
|
||||
SAMPLE_FORMAT_S16LE: 1,
|
||||
SAMPLE_FORMAT_S24LE: 2,
|
||||
SAMPLE_FORMAT_S32LE: 3,
|
||||
},
|
||||
InterruptType: {
|
||||
INTERRUPT_TYPE_BEGIN: 1,
|
||||
INTERRUPT_TYPE_END: 2,
|
||||
},
|
||||
InterruptForceType: {
|
||||
INTERRUPT_FORCE: 0,
|
||||
INTERRUPT_SHARE: 1,
|
||||
},
|
||||
getAudioManager: function () {
|
||||
console.warn("audio.getAudioManager interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return audioManagerMock;
|
||||
},
|
||||
createAudioCapturer: function (...args) {
|
||||
console.warn("audio.createAudioCapturer 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, AudioCapturerMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioCapturerMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
createAudioRenderer: function (...args) {
|
||||
console.warn("audio.createAudioRenderer 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, AudioRendererMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AudioRendererMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return audio;
|
||||
}
|
||||
@@ -0,0 +1,474 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockMultimediaCamera() {
|
||||
const Camera = {
|
||||
cameraId: '[PC preview] unknow pid',
|
||||
cameraPosition: '[PC preview] unknow cameraPosition',
|
||||
cameraType: '[PC preview] unknow cameraType',
|
||||
connectionType: '[PC preview] unknow connectionType'
|
||||
}
|
||||
const FlashMode = '[PC preview] unknow flashMode'
|
||||
const FocusMode = '[PC preview] unknow focusMode'
|
||||
const multimediaCameraMock = {
|
||||
getCameraManager: function (...args) {
|
||||
console.warn('camera.getCameraManager 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, CameraManager);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(CameraManager);
|
||||
});
|
||||
}
|
||||
},
|
||||
createCaptureSession: function (...args) {
|
||||
console.warn('camera.createCaptureSession 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, CaptureSession);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(CaptureSession);
|
||||
});
|
||||
}
|
||||
},
|
||||
createPreviewOutput: function (...args) {
|
||||
console.warn('camera.createPreviewOutput 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, PreviewOutput);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(PreviewOutput);
|
||||
});
|
||||
}
|
||||
},
|
||||
createPhotoOutput: function (...args) {
|
||||
console.warn('camera.createPreviewOutput 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, PhotoOutput);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(PhotoOutput);
|
||||
});
|
||||
}
|
||||
},
|
||||
createVideoOutput: function (...args) {
|
||||
console.warn('camera.createVideoOutput 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, VideoOutput);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(VideoOutput);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
const CameraManager = {
|
||||
getCameras: function (...args) {
|
||||
console.warn('CameraManager.getCameras 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, [Camera]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([Camera]);
|
||||
});
|
||||
}
|
||||
},
|
||||
createCameraInput: function (...args) {
|
||||
console.warn('CameraManager.createCameraInput 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, CameraInput);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(CameraInput);
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn('CameraManager.on interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
}
|
||||
}
|
||||
const CameraInput = {
|
||||
getCameraId: function (...args) {
|
||||
console.warn('CameraInput.getCameraId 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, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
hasFlash: function (...args) {
|
||||
console.warn('CameraInput.hasFlash 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, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
isFlashModeSupported: function (...args) {
|
||||
console.warn('CameraInput.isFlashModeSupported 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, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getFlashMode: function (...args) {
|
||||
console.warn('CameraInput.getFlashMode 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, FlashMode);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(FlashMode);
|
||||
});
|
||||
}
|
||||
},
|
||||
setFlashMode: function (...args) {
|
||||
console.warn('CameraInput.setFlashMode 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
isFocusModeSupported: function (...args) {
|
||||
console.warn('CameraInput.isFocusModeSupported 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, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getFocusMode: function (...args) {
|
||||
console.warn('CameraInput.getFocusMode 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, FocusMode);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(FocusMode);
|
||||
});
|
||||
}
|
||||
},
|
||||
setFocusMode: function (...args) {
|
||||
console.warn('CameraInput.setFocusMode 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getZoomRatioRange: function (...args) {
|
||||
console.warn('CameraInput.getZoomRatioRange 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, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
getZoomRatio: function (...args) {
|
||||
console.warn('CameraInput.getZoomRatioRange 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setZoomRatio: function (...args) {
|
||||
console.warn('CameraInput.setZoomRatio 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn('CameraInput.release 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn('CameraInput.on interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
}
|
||||
}
|
||||
const CaptureSession = {
|
||||
beginConfig: function (...args) {
|
||||
console.warn('CaptureSession.beginConfig 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
commitConfig: function (...args) {
|
||||
console.warn('CaptureSession.commitConfig 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
addInput: function (...args) {
|
||||
console.warn('CaptureSession.addInput 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
addOutput: function (...args) {
|
||||
console.warn('CaptureSession.addOutput 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
removeInput: function (...args) {
|
||||
console.warn('CaptureSession.removeInput 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
removeOutput: function (...args) {
|
||||
console.warn('CaptureSession.removeInput 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
start: function (...args) {
|
||||
console.warn('CaptureSession.start 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
stop: function (...args) {
|
||||
console.warn('CaptureSession.stop 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn('CaptureSession.release 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn('CaptureSession.on interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
}
|
||||
}
|
||||
const PreviewOutput = {
|
||||
release: function (...args) {
|
||||
console.warn('PreviewOutput.release 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn('PreviewOutput.release interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
},
|
||||
}
|
||||
const PhotoOutput = {
|
||||
capture: function (...args) {
|
||||
console.warn('PhotoOutput.capture 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn('PhotoOutput.release 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn('PhotoOutput.on interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
}
|
||||
}
|
||||
const VideoOutput = {
|
||||
start: function (...args) {
|
||||
console.warn('VideoOutput.start 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
stop: function (...args) {
|
||||
console.warn('VideoOutput.stop 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn('VideoOutput.release 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn('VideoOutput.on interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
}
|
||||
}
|
||||
return multimediaCameraMock
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
const SizeMock = {
|
||||
height: "[PC Preview] unknow height",
|
||||
width: "[PC Preview] unknow width"
|
||||
}
|
||||
const ImageInfoMock = {
|
||||
size: SizeMock
|
||||
}
|
||||
|
||||
export const PixelMapMock = {
|
||||
isEditable: "[PC Preview] unknow isEditable",
|
||||
readPixelsToBuffer: function (...args) {
|
||||
console.warn("PixelMap.readPixelsToBuffer 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
readPixels: function (...args) {
|
||||
console.warn("PixelMap.readPixels 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
writePixels: function (...args) {
|
||||
console.warn("PixelMap.writePixels 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
writeBufferToPixels: function (...args) {
|
||||
console.warn("PixelMap.writeBufferToPixels 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getImageInfo: function (...args) {
|
||||
console.warn("PixelMap.getImageInfo 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ImageInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(ImageInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getBytesNumberPerRow: function (...args) {
|
||||
console.warn("PixelMap.getBytesNumberPerRow interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getPixelBytesNumber: function (...args) {
|
||||
console.warn("PixelMap.getPixelBytesNumber interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("PixelMap.release 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockMultimediaImage() {
|
||||
const RegionMock = {
|
||||
size: SizeMock,
|
||||
x: "[PC Preview] unknow x",
|
||||
y: "[PC Preview] unknow y"
|
||||
}
|
||||
const PositionAreaMock = {
|
||||
pixels: "[PC Preview] unknow pixels",
|
||||
offset: "[PC Preview] unknow offset",
|
||||
stride: "[PC Preview] unknow stride",
|
||||
region: RegionMock
|
||||
}
|
||||
const PackingOptionMock = {
|
||||
format: "[PC Preview] unknow format",
|
||||
quality: "[PC Preview] unknow quality"
|
||||
}
|
||||
const GetImagePropertyOptionsMock = {
|
||||
index: "[PC Preview] unknow index",
|
||||
defaultValue: "[PC Preview] unknow defaultValue"
|
||||
}
|
||||
const DecodingOptionsMock = {
|
||||
index: "[PC Preview] unknow index",
|
||||
sampleSize: "[PC Preview] unknow sampleSize",
|
||||
rotate: "[PC Preview] unknow rotate",
|
||||
editable: "[PC Preview] unknow editable",
|
||||
desiredSize: SizeMock,
|
||||
desiredRegion: RegionMock,
|
||||
desiredPixelFormat: "[PC Preview] unknow desiredPixelFormat"
|
||||
}
|
||||
const ComponentMock = {
|
||||
componentType: "[PC Preview] unknow componentType",
|
||||
rowStride: "[PC Preview] unknow rowStride",
|
||||
pixelStride: "[PC Preview] unknow pixelStride",
|
||||
byteBuffer: "[PC Preview] unknow pixelStride"
|
||||
}
|
||||
const InitializationOptionsMock = {
|
||||
size: SizeMock,
|
||||
pixelFormat: "[PC Preview] unknow pixelFormat",
|
||||
editable: "[PC Preview] unknow editable",
|
||||
alphaType: "[PC Preview] unknow alphaType",
|
||||
scaleMode: "[PC Preview] unknow scaleMode"
|
||||
}
|
||||
|
||||
const ImageSourceMock = {
|
||||
getImageInfo: function (...args) {
|
||||
console.warn("ImageSource.getImageInfo 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, ImageInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(ImageInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("ImageSource.release 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
createPixelMap: function (...args) {
|
||||
console.warn("ImageSource.createPixelMap 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PixelMapMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getImageProperty: function (...args) {
|
||||
console.warn("ImageSource.getImageProperty 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("ImageSource.release 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
supportedFormats: "[PC Preview] unknow supportedFormats"
|
||||
}
|
||||
const ImagePackerMock = {
|
||||
packing: function (...args) {
|
||||
console.warn("ImagePacker.packing 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, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("ImagePacker.release 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
supportedFormats: "[PC Preview] unknow supportedFormats"
|
||||
}
|
||||
const ImageMock = {
|
||||
clipRect: RegionMock,
|
||||
size: SizeMock,
|
||||
format: "[PC Preview] unknow format",
|
||||
getComponent: function (...args) {
|
||||
console.warn("Image.getComponent 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,ComponentMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(ComponentMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("Image.release 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
const ImageReceiverMock = {
|
||||
size: SizeMock,
|
||||
capacity: "[PC Preview] unknow width",
|
||||
format: "[PC Preview] unknow format",
|
||||
getReceivingSurfaceId: function (...args) {
|
||||
console.warn("ImageReceiver.getReceivingSurfaceId 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
readLatestImage: function (...args) {
|
||||
console.warn("ImageReceiver.readLatestImage 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.ImageMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.ImageMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
readLatestImage: function (...args) {
|
||||
console.warn("ImageReceiver.readLatestImage 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.ImageMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.ImageMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("ImageReceiver.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("ImageReceiver.release 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
const image = {
|
||||
PixelMapFormat: {
|
||||
UNKNOWN: 0,
|
||||
RGB_565: 2,
|
||||
RGBA_8888: 3,
|
||||
},
|
||||
PropertyKey: {
|
||||
BITS_PER_SAMPLE: "BitsPerSample",
|
||||
ORIENTATION: "Orientation",
|
||||
IMAGE_LENGTH: "ImageLength",
|
||||
IMAGE_WIDTH: "ImageWidth",
|
||||
GPS_LATITUDE: "GPSLatitude",
|
||||
GPS_LONGITUDE: "GPSLongitude",
|
||||
GPS_LATITUDE_REF: "GPSLatitudeRef",
|
||||
GPS_LONGITUDE_REF: "GPSLongitudeRef",
|
||||
},
|
||||
ImageFormat: {
|
||||
YCBCR_422_SP: 1000,
|
||||
JPEG: 2000,
|
||||
},
|
||||
AlphaType: {
|
||||
UNKNOWN: 0,
|
||||
OPAQUE: 1,
|
||||
PREMUL: 2,
|
||||
UNPREMUL: 3,
|
||||
},
|
||||
ScaleMode: {
|
||||
CENTER_CROP: 1,
|
||||
FIT_TARGET_SIZE: 2,
|
||||
},
|
||||
ComponentType: {
|
||||
YUV_Y: 1,
|
||||
YUV_U: 2,
|
||||
YUV_V: 3,
|
||||
JPEG: 4,
|
||||
},
|
||||
createPixelMap: function (...args) {
|
||||
console.warn("image.createPixelMap 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PixelMapMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
createImageSource: function () {
|
||||
console.warn("image.createImageSource interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return ImageSourceMock;
|
||||
},
|
||||
createImagePacker: function () {
|
||||
console.warn("image.createImagePacker interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return ImagePackerMock;
|
||||
},
|
||||
createImageReceiver: function () {
|
||||
console.warn("image.createImageReceiver interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return ImageReceiverMock;
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
@@ -0,0 +1,511 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockMultimediaMedia() {
|
||||
const audioPlayerMock = {
|
||||
play: function () {
|
||||
console.warn("AudioPlayer.play interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
pause: function () {
|
||||
console.warn("AudioPlayer.pause interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
stop: function () {
|
||||
console.warn("AudioPlayer.stop interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
reset: function () {
|
||||
console.warn("AudioPlayer.reset interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
seek: function (...args) {
|
||||
console.warn("AudioPlayer.seek interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setVolume: function (...args) {
|
||||
console.warn("AudioPlayer.setVolume interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
release: function () {
|
||||
console.warn("AudioPlayer.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
getTrackDescription: function(...args) {
|
||||
console.warn("AudioPlayer.getTrackDescription 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, [mediaDescriptionMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([mediaDescriptionMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
src: '[PC Preview] unknow src',
|
||||
loop: '[PC Preview] unknow loop',
|
||||
currentTime: '[PC Preview] unknow currentTime',
|
||||
duration: '[PC Preview] unknow duration',
|
||||
state: '[PC Preview] unknow state',
|
||||
on: function (...args) {
|
||||
console.warn("AudioPlayer.on interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
const locationMock = {
|
||||
latitude: '[PC Preview] unknow latitude',
|
||||
longitude: '[PC Preview] unknow longitude',
|
||||
}
|
||||
const audioRecorderConfigMock = {
|
||||
audioEncoder: '[PC Preview] unknow audioEncoder',
|
||||
audioEncodeBitRate: '[PC Preview] unknow audioEncodeBitRate',
|
||||
audioSampleRate: '[PC Preview] unknow audioSampleRate',
|
||||
numberOfChannels: '[PC Preview] unknow numberOfChannels',
|
||||
format: '[PC Preview] unknow format',
|
||||
uri: '[PC Preview] unknow uri',
|
||||
location: locationMock,
|
||||
audioEncoderMime: '[PC Preview] unknow audioEncoderMime',
|
||||
fileFormat: '[PC Preview] unknow fileFormat',
|
||||
}
|
||||
const audioRecorderMock = {
|
||||
prepare: function (...args) {
|
||||
console.warn("AudioRecorder.prepare interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
start: function () {
|
||||
console.warn("AudioRecorder.start interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
pause: function () {
|
||||
console.warn("AudioRecorder.pause interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
resume: function () {
|
||||
console.warn("AudioRecorder.resume interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stop: function () {
|
||||
console.warn("AudioRecorder.stop interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
release: function () {
|
||||
console.warn("AudioRecorder.release interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
reset: function () {
|
||||
console.warn("AudioRecorder.reset interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("AudioRecorder.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
const videoRecorderMock = {
|
||||
prepare: function (...args) {
|
||||
console.warn("VideoRecorder.prepare 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getInputSurface: function (...args) {
|
||||
console.warn("VideoRecorder.getInputSurface 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, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
start: function (...args) {
|
||||
console.warn("VideoRecorder.start 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
pause: function (...args) {
|
||||
console.warn("VideoRecorder.pause 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
resume: function (...args) {
|
||||
console.warn("VideoRecorder.resume 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
stop: function (...args) {
|
||||
console.warn("VideoRecorder.stop 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("VideoRecorder.release 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
reset: function (...args) {
|
||||
console.warn("VideoRecorder.reset 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("AudioRecorder.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
state: paramMock.paramStringMock,
|
||||
}
|
||||
const videoPlayerMock = {
|
||||
url: '[PC Preview] unknow url',
|
||||
loop: '[PC Preview] unknow loop',
|
||||
currentTime: '[PC Preview] unknow currentTime',
|
||||
duration: '[PC Preview] unknow duration',
|
||||
state: '[PC Preview] unknow state',
|
||||
width: '[PC Preview] unknow width',
|
||||
height: '[PC Preview] unknow height',
|
||||
setDisplaySurface: function (...args) {
|
||||
console.warn("VideoPlayer.setDisplaySurface 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
prepare: function (...args) {
|
||||
console.warn("VideoPlayer.prepare 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
play: function (...args) {
|
||||
console.warn("VideoPlayer.play 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
pause: function (...args) {
|
||||
console.warn("VideoPlayer.pause 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
stop: function (...args) {
|
||||
console.warn("VideoPlayer.stop 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
reset: function (...args) {
|
||||
console.warn("VideoPlayer.reset 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
seek: function (...args) {
|
||||
console.warn("VideoPlayer.seek 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setVolume: function (...args) {
|
||||
console.warn("VideoPlayer.setVolume 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("VideoPlayer.release 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);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getTrackDescription: function (...args) {
|
||||
console.warn("VideoPlayer.getTrackDescription 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, [mediaDescriptionMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([mediaDescriptionMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
setSpeed: function (...args) {
|
||||
console.warn("VideoPlayer.setSpeed 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.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("VideoPlayer.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
const videoRecorderProfileMock = {
|
||||
audioBitrate: '[PC Preview] unknow audioBitrate',
|
||||
audioChannels: '[PC Preview] unknow audioChannels',
|
||||
audioCodec: '[PC Preview] unknow audioCodec',
|
||||
audioSampleRate: '[PC Preview] unknow audioSampleRate',
|
||||
fileFormat: '[PC Preview] unknow fileFormat',
|
||||
videoBitrate: '[PC Preview] unknow videoBitrate',
|
||||
videoCodec: '[PC Preview] unknow videoCodec',
|
||||
videoFrameWidth: '[PC Preview] unknow videoFrameWidth',
|
||||
videoFrameHeight: '[PC Preview] unknow videoFrameHeight',
|
||||
videoFrameRate: '[PC Preview] unknow videoFrameRate',
|
||||
}
|
||||
const videoRecorderConfigMock = {
|
||||
audioSourceType: '[PC Preview] unknow audioSourceType',
|
||||
videoSourceType: '[PC Preview] unknow videoSourceType',
|
||||
profile: '[PC Preview] unknow profile',
|
||||
url: '[PC Preview] unknow url',
|
||||
rotation: '[PC Preview] unknow rotation',
|
||||
location: locationMock,
|
||||
}
|
||||
const mediaDescriptionMock = {
|
||||
key: '[PC Preview] unknow key',
|
||||
}
|
||||
const multimediaMediaMock = {
|
||||
MediaErrorCode : {
|
||||
MSERR_OK: 0,
|
||||
MSERR_NO_MEMORY: 1,
|
||||
MSERR_OPERATION_NOT_PERMIT: 2,
|
||||
MSERR_INVALID_VAL: 3,
|
||||
MSERR_IO: 4,
|
||||
MSERR_TIMEOUT: 5,
|
||||
MSERR_UNKNOWN: 6,
|
||||
MSERR_SERVICE_DIED: 7,
|
||||
MSERR_INVALID_STATE: 8,
|
||||
MSERR_UNSUPPORTED: 9
|
||||
},
|
||||
BufferingInfoType : {
|
||||
BUFFERING_START: 1,
|
||||
BUFFERING_END: 2,
|
||||
BUFFERING_PERCENT: 3,
|
||||
CACHED_DURATION: 4
|
||||
},
|
||||
AudioEncoder : {
|
||||
DEFAULT: 0,
|
||||
AMR_NB: 1,
|
||||
AMR_WB: 2,
|
||||
AAC_LC: 3,
|
||||
HE_AAC: 4
|
||||
},
|
||||
AudioOutputFormat : {
|
||||
DEFAULT: 0,
|
||||
MPEG_4: 2,
|
||||
AMR_NB: 3,
|
||||
AMR_WB: 4,
|
||||
AAC_ADTS: 6
|
||||
},
|
||||
CodecMimeType : {
|
||||
VIDEO_H263: 'video/h263',
|
||||
VIDEO_AVC: 'video/avc',
|
||||
VIDEO_MPEG2: 'video/mpeg2',
|
||||
VIDEO_MPEG4: 'video/mp4v-es',
|
||||
VIDEO_VP8: 'video/x-vnd.on2.vp8',
|
||||
AUDIO_AAC: 'audio/mp4a-latm',
|
||||
AUDIO_VORBIS: 'audio/vorbis',
|
||||
AUDIO_FLAC: 'audio/flac',
|
||||
},
|
||||
PlaybackSpeed : {
|
||||
SPEED_FORWARD_0_75_X: 0,
|
||||
SPEED_FORWARD_1_00_X: 1,
|
||||
SPEED_FORWARD_1_25_X: 2,
|
||||
SPEED_FORWARD_1_75_X: 3,
|
||||
SPEED_FORWARD_2_00_X: 4,
|
||||
},
|
||||
ContainerFormatType : {
|
||||
CFT_MPEG_4: "mp4",
|
||||
CFT_MPEG_4A: "m4a",
|
||||
},
|
||||
MediaType : {
|
||||
MEDIA_TYPE_AUD: 0,
|
||||
MEDIA_TYPE_VID: 1,
|
||||
},
|
||||
MediaDescriptionKey : {
|
||||
MD_KEY_TRACK_INDEX: "track_index",
|
||||
MD_KEY_TRACK_TYPE: "track_type",
|
||||
MD_KEY_CODEC_MIME: "codec_mime",
|
||||
MD_KEY_DURATION: "duration",
|
||||
MD_KEY_BITRATE: "bitrate",
|
||||
MD_KEY_WIDTH: "width",
|
||||
MD_KEY_HEIGHT: "height",
|
||||
MD_KEY_FRAME_RATE: "frame_rate",
|
||||
MD_KEY_AUD_CHANNEL_COUNT: "channel_count",
|
||||
MD_KEY_AUD_SAMPLE_RATE: "sample_rate",
|
||||
},
|
||||
AudioSourceType : {
|
||||
AUDIO_SOURCE_TYPE_DEFAULT: 0,
|
||||
AUDIO_SOURCE_TYPE_MIC: 1,
|
||||
},
|
||||
VideoSourceType : {
|
||||
VIDEO_SOURCE_TYPE_SURFACE_YUV: 0,
|
||||
VIDEO_SOURCE_TYPE_SURFACE_ES: 1,
|
||||
},
|
||||
SeekMode : {
|
||||
SEEK_NEXT_SYNC: 0,
|
||||
SEEK_PREV_SYNC: 1,
|
||||
},
|
||||
AudioState: '[PC Preview] unknow AudioState',
|
||||
VideoRecordState: '[PC Preview] unknow VideoRecordState',
|
||||
VideoPlayState: '[PC Preview] unknow VideoPlayState',
|
||||
createAudioPlayer: function () {
|
||||
console.warn("media.createAudioPlayer interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return audioPlayerMock;
|
||||
},
|
||||
createAudioRecorder: function () {
|
||||
console.warn("media.createAudioRecorder interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return audioRecorderMock;
|
||||
},
|
||||
createVideoPlayer: function () {
|
||||
console.warn("media.createVideoPlayer 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, videoPlayerMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(videoPlayerMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
createVideoRecorder: function () {
|
||||
console.warn("media.createVideoRecorder 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, videoRecorderMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(videoRecorderMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
return multimediaMediaMock;
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
import { PixelMapMock } from "./multimediaImage"
|
||||
|
||||
export function mockMultimediaMediaLibrary() {
|
||||
const mockFileAsset = {
|
||||
id: "[PC Preview] unknow id",
|
||||
uri: "[PC Preview] unknow uri",
|
||||
mimeType: "[PC Preview] unknow mimeType",
|
||||
mediaType: "[PC Preview] unknow mediaType",
|
||||
displayName: "[PC Preview] unknow displayName",
|
||||
title: "[PC Preview] unknow title",
|
||||
relativePath: "[PC Preview] unknow relativePath",
|
||||
parent: "[PC Preview] unknow parent",
|
||||
size: "[PC Preview] unknow size",
|
||||
dateAdded: "[PC Preview] unknow dateAdded",
|
||||
dateModified: "[PC Preview] unknow dateModified",
|
||||
dateTaken: "[PC Preview] unknow dateTaken",
|
||||
artist: "[PC Preview] unknow artist",
|
||||
audioAlbum: "[PC Preview] unknow audioAlbum",
|
||||
width: "[PC Preview] unknow width",
|
||||
height: "[PC Preview] unknow height",
|
||||
orientation: "[PC Preview] unknow orientation",
|
||||
duration: "[PC Preview] unknow duration",
|
||||
albumId: "[PC Preview] unknow albumId",
|
||||
albumUri: "[PC Preview] unknow albumUri",
|
||||
albumName: "[PC Preview] unknow albumName",
|
||||
isDirectory: function(...args) {
|
||||
console.warn("FileAsset.isDirectory 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
commitModify: function(...args) {
|
||||
console.warn("FileAsset.commitModify 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
open: function(...args) {
|
||||
console.warn("FileAsset.open 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
close: function(...args) {
|
||||
console.warn("FileAsset.close 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
getThumbnail: function(...args) {
|
||||
console.warn("FileAsset.getThumbnail 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, mockImagePixelMap)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(mockImagePixelMap)
|
||||
})
|
||||
}
|
||||
},
|
||||
favorite: function(...args) {
|
||||
console.warn("FileAsset.favorite 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
isFavorite: function(...args) {
|
||||
console.warn("FileAsset.isFavorite 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
trash: function(...args) {
|
||||
console.warn("FileAsset.trash 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
isTrash: function(...args) {
|
||||
console.warn("FileAsset.isTrash 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const mockFetchFileResult = {
|
||||
getCount: function(...args) {
|
||||
console.warn("FetchFileResult.getCount interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
isAfterLast: function(...args) {
|
||||
console.warn("FetchFileResult.isAfterLast interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
close: function(...args) {
|
||||
console.warn("FetchFileResult.close interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getFirstObject: function(...args) {
|
||||
console.warn("FetchFileResult.getFirstObject 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(mockFileAsset)
|
||||
})
|
||||
}
|
||||
},
|
||||
getNextObject: function(...args) {
|
||||
console.warn("FetchFileResult.getNextObject 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(mockFileAsset)
|
||||
})
|
||||
}
|
||||
},
|
||||
getLastObject: function(...args) {
|
||||
console.warn("FetchFileResult.getLastObject 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(mockFileAsset)
|
||||
})
|
||||
}
|
||||
},
|
||||
getPositionObject: function(...args) {
|
||||
console.warn("FetchFileResult.getPositionObject 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(mockFileAsset)
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllObject: function(...args) {
|
||||
console.warn("FetchFileResult.getPositionObject 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [mockFileAsset])
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([mockFileAsset])
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const mockPeerInfo = {
|
||||
deviceName: "[PC Preview] unknow deviceName",
|
||||
networkId: "[PC Preview] unknow networkId",
|
||||
deviceType: "[PC Preview] unknow deviceType",
|
||||
isOnline: "[PC Preview] unknow isOnline"
|
||||
};
|
||||
|
||||
const mockImagePixelMap = PixelMapMock;
|
||||
|
||||
const mockAlbum = {
|
||||
albumId: "[PC Preview] unknow albumId",
|
||||
albumName: "[PC Preview] unknow albumName",
|
||||
albumUri: "[PC Preview] unknow albumUri",
|
||||
dateModified: "[PC Preview] unknow dateModified",
|
||||
count: "[PC Preview] unknow count",
|
||||
relativePath: "[PC Preview] unknow relativePath",
|
||||
coverUri: "[PC Preview] unknow coverUri",
|
||||
commitModify: function(...args) {
|
||||
console.warn("Album.commitModify 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
getFileAssets: function(...args) {
|
||||
console.warn("Album.getFileAssets 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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, mockFetchFileResult);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(mockFetchFileResult)
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const mockMediaLibrary = {
|
||||
getPublicDirectory: function(...args) {
|
||||
console.warn("MediaLibrary.getPublicDirectory 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, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getFileAssets: function(...args) {
|
||||
console.warn("MediaLibrary.getFileAssets 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, mockFetchFileResult);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(mockFetchFileResult)
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function(...args) {
|
||||
console.warn("MediaLibrary.on 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("MediaLibrary.off interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
createAsset: function(...args) {
|
||||
console.warn("MediaLibrary.createAsset 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, mockFileAsset);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(mockFileAsset)
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteAsset: function(...args) {
|
||||
console.warn("MediaLibrary.deleteAsset 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
getAlbums: function(...args) {
|
||||
console.warn("MediaLibrary.getAlbums 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, [mockAlbum]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([mockAlbum])
|
||||
})
|
||||
}
|
||||
},
|
||||
storeMediaAsset: function(...args) {
|
||||
console.warn("MediaLibrary.storeMediaAsset 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, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
startImagePreview: function(...args) {
|
||||
console.warn("MediaLibrary.startImagePreview 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
startMediaSelect: function(...args) {
|
||||
console.warn("MediaLibrary.startMediaSelect 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, [paramMock.paramStringMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramStringMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getActivePeers: function(...args) {
|
||||
console.warn("MediaLibrary.getActivePeers 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, [mockPeerInfo]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([mockPeerInfo])
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllPeers: function(...args) {
|
||||
console.warn("MediaLibrary.getAllPeers 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, [mockPeerInfo]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([mockPeerInfo])
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function(...args) {
|
||||
console.warn("MediaLibrary.startImagePreview 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);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const mediaLibrary = {
|
||||
MediaType: {
|
||||
FILE: 0,
|
||||
IMAGE: 1,
|
||||
VIDEO: 2,
|
||||
AUDIO: 3
|
||||
},
|
||||
FileKey: {
|
||||
ID: "file_id",
|
||||
RELATIVE_PATH: "relative_path",
|
||||
DISPLAY_NAME: "display_name",
|
||||
PARENT: "parent",
|
||||
MIME_TYPE: "mime_type",
|
||||
MEDIA_TYPE: "media_type",
|
||||
SIZE: "size",
|
||||
DATE_ADDED: "date_added",
|
||||
DATE_MODIFIED: "date_modified",
|
||||
DATE_TAKEN: "date_taken",
|
||||
TITLE: "title",
|
||||
ARTIST: "artist",
|
||||
AUDIOALBUM: "audio_album",
|
||||
DURATION: "duration",
|
||||
WIDTH: "width",
|
||||
HEIGHT: "height",
|
||||
ORIENTATION: "orientation",
|
||||
ALBUM_ID: "bucket_id",
|
||||
ALBUM_NAME: "bucket_display_name"
|
||||
},
|
||||
DirectoryType: {
|
||||
DIR_CAMERA: 0,
|
||||
DIR_VIDEO: 1,
|
||||
DIR_IMAGE: 2,
|
||||
DIR_AUDIO: 3,
|
||||
DIR_DOCUMENTS: 4,
|
||||
DIR_DOWNLOAD: 5
|
||||
},
|
||||
DeviceType: {
|
||||
TYPE_UNKNOWN: 0,
|
||||
TYPE_LAPTOP: 1,
|
||||
TYPE_PHONE: 2,
|
||||
TYPE_TABLET: 3,
|
||||
TYPE_WATCH: 4,
|
||||
TYPE_CAR: 5,
|
||||
TYPE_TV: 6
|
||||
},
|
||||
getMediaLibrary: function(...args) {
|
||||
console.warn("mediaLibrary.getMediaLibrary interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return mockMediaLibrary;
|
||||
}
|
||||
};
|
||||
|
||||
return mediaLibrary;
|
||||
}
|
||||
Reference in New Issue
Block a user