fix JS API Mock bug

Signed-off-by: hwx1119949 <3052854011@qq.com>
Change-Id: I46d94609aaa021a99899c1992a6b4b8e46a47bec
This commit is contained in:
hwx1119949
2021-12-30 19:57:00 +08:00
parent d2a8bc1a90
commit e5241224db
8 changed files with 2579 additions and 2601 deletions
+10 -14
View File
@@ -1258,13 +1258,11 @@ export function mockAbilityContinuationRegisterManager() {
console.warn("ability.ContinuationRegisterManager.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 (args[0] === 'deviceConnect') {
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, ContinuationResultMock)
}
} else {
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramStringMock)
if(typeof args[len -1]==='function'){
if(args[0] ==='deviceConnect'){
args[len-1].call(this,ContinuationResultMock)
}else{
args[len-1].call(this,paramMock.paramStringMock)
}
}
},
@@ -1272,13 +1270,11 @@ export function mockAbilityContinuationRegisterManager() {
console.warn("ability.ContinuationRegisterManager.off 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 (args[0] === 'deviceConnect') {
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, ContinuationResultMock)
}
} else {
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramStringMock)
if(typeof args[len -1]==='function'){
if(args[0] ==='deviceConnect'){
args[len-1].call(this,ContinuationResultMock)
}else{
args[len-1].call(this,paramMock.paramStringMock)
}
}
},
@@ -167,8 +167,6 @@ export function mockAccessibility() {
const len = args.length;
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, StateEventMock);
} else {
return;
}
},
getAbilityLists: function(...args) {
@@ -230,37 +230,30 @@ export function mockMultimediaMedia() {
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.")
return
},
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.")
return
},
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.")
return
},
reset: 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.")
return
},
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.")
return
},
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.")
return
},
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.")
return
},
src: "[PC Preview] unknow src",
loop: "[PC Preview] unknow loop",
@@ -403,27 +396,22 @@ export function mockMultimediaMedia() {
start: function (...args) {
console.warn("MediaDecoder.start interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return
},
seek: function (...args) {
console.warn("MediaDecoder.seek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return
},
stop: function () {
console.warn("MediaDecoder.stop interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return
},
release: function () {
console.warn("MediaDecoder.release interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return
},
requestFrame: function () {
console.warn("MediaDecoder.requestFrame interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return
},
on: function (...args) {
console.warn("MediaDecoder.on interface mocked in the Previewer. How this interface works on the Previewer" +
@@ -679,12 +667,10 @@ export function mockMultimediaMedialibrary() {
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.")
return
},
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.")
return
}
}
const FetchFileResultMock = {
@@ -701,7 +687,6 @@ export function mockMultimediaMedialibrary() {
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.")
return
},
getFirstObject: function (...args) {
console.warn("FetchFileResult.getFirstObject interface mocked in the Previewer. How this interface works on the" +
@@ -1,317 +1,317 @@
import {paramMock} from "../../utils"
import { paramMock } from "../../utils"
const ModuleInfoMock = {
moduleName: '[PC preview] unknow moduleName',
moduleSourceDir: '[PC preview] unknow moduleSourceDir',
moduleName: '[PC preview] unknow moduleName',
moduleSourceDir: '[PC preview] unknow moduleSourceDir',
}
export const AbilityInfoMock = {
bundleName: '[PC preview] unknow bundleName',
name: '[PC preview] unknow name',
label: '[PC preview] unknow label',
description: '[PC preview] unknow description',
icon: '[PC preview] unknow icon',
labelId: '[PC preview] unknow labelId',
descriptionId: '[PC preview] unknow descriptionId',
iconId: '[PC preview] unknow iconId',
moduleName: '[PC preview] unknow moduleName',
process: '[PC preview] unknow process',
targetAbility: '[PC preview] unknow targetAbility',
backgroundModes: '[PC preview] unknow backgroundModes',
isVisible: '[PC preview] unknow isVisible',
abilityTypeMock: '[PC preview] unknow abilityTypeMock',
AbilitySubTypeMock: '[PC preview] unknow AbilitySubTypeMock',
DisplayOrientationMock: '[PC preview] unknow DisplayOrientationMock',
launchModeMock: '[PC preview] unknow launchModeMock',
formEnabled: '[PC preview] unknow formEnabled',
permissions: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
deviceCapabilities: [paramMock.paramStringMock],
readPermission: '[PC preview] unknow readPermission',
writePermission: '[PC preview] unknow writePermission',
applicationInfo: applicationInfoMock,
formEntity: '[PC preview] unknow formEntity',
minFormHeight: '[PC preview] unknow minFormHeight',
defaultFormHeight: '[PC preview] unknow defaultFormHeight',
minFormWidth: '[PC preview] unknow minFormWidth',
defaultFormWidth: '[PC preview] unknow defaultFormWidth',
uri: '[PC preview] unknow uri',
customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]])
bundleName: '[PC preview] unknow bundleName',
name: '[PC preview] unknow name',
label: '[PC preview] unknow label',
description: '[PC preview] unknow description',
icon: '[PC preview] unknow icon',
labelId: '[PC preview] unknow labelId',
descriptionId: '[PC preview] unknow descriptionId',
iconId: '[PC preview] unknow iconId',
moduleName: '[PC preview] unknow moduleName',
process: '[PC preview] unknow process',
targetAbility: '[PC preview] unknow targetAbility',
backgroundModes: '[PC preview] unknow backgroundModes',
isVisible: '[PC preview] unknow isVisible',
abilityTypeMock: '[PC preview] unknow abilityTypeMock',
AbilitySubTypeMock: '[PC preview] unknow AbilitySubTypeMock',
DisplayOrientationMock: '[PC preview] unknow DisplayOrientationMock',
launchModeMock: '[PC preview] unknow launchModeMock',
formEnabled: '[PC preview] unknow formEnabled',
permissions: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
deviceCapabilities: [paramMock.paramStringMock],
readPermission: '[PC preview] unknow readPermission',
writePermission: '[PC preview] unknow writePermission',
applicationInfo: applicationInfoMock,
formEntity: '[PC preview] unknow formEntity',
minFormHeight: '[PC preview] unknow minFormHeight',
defaultFormHeight: '[PC preview] unknow defaultFormHeight',
minFormWidth: '[PC preview] unknow minFormWidth',
defaultFormWidth: '[PC preview] unknow defaultFormWidth',
uri: '[PC preview] unknow uri',
customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]])
}
const applicationInfoMock = {
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
descriptionId: '[PC preview] unknow descriptionId',
systemApp: '[PC preview] unknow systemApp',
enabled: '[PC preview] unknow enabled',
label: '[PC preview] unknow label',
labelId: '[PC preview] unknow labelId',
icon: '[PC preview] unknow icon',
iconId: '[PC preview] unknow iconId',
process: '[PC preview] unknow process',
supportedModes: '[PC preview] unknow supportedModes',
moduleSourceDirs: [paramMock.paramStringMock],
permissions: [paramMock.paramStringMock],
moduleInfo: [ModuleInfoMock],
entryDir: '[PC preview] unknow entryDir',
codepath: '[PC preview] unknow codepath',
removable: '[PC preview] unknow removable',
customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]])
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
descriptionId: '[PC preview] unknow descriptionId',
systemApp: '[PC preview] unknow systemApp',
enabled: '[PC preview] unknow enabled',
label: '[PC preview] unknow label',
labelId: '[PC preview] unknow labelId',
icon: '[PC preview] unknow icon',
iconId: '[PC preview] unknow iconId',
process: '[PC preview] unknow process',
supportedModes: '[PC preview] unknow supportedModes',
moduleSourceDirs: [paramMock.paramStringMock],
permissions: [paramMock.paramStringMock],
moduleInfo: [ModuleInfoMock],
entryDir: '[PC preview] unknow entryDir',
codepath: '[PC preview] unknow codepath',
removable: '[PC preview] unknow removable',
customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]])
}
const HapModuleInfoMock = {
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
descriptionId: '[PC preview] unknow descriptionId',
icon: '[PC preview] unknow icon',
label: '[PC preview] unknow label',
labelId: '[PC preview] unknow labelId',
iconId: '[PC preview] unknow iconId',
backgroundImg: '[PC preview] unknow backgroundImg',
supportedModes: '[PC preview] unknow supportedModes',
reqCapabilities: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
abilityInfo: AbilityInfoMock,
moduleName: '[PC preview] unknow moduleName',
mainAbilityName: '[PC preview] unknow mainAbilityName',
installationFree: '[PC preview] unknow installationFree',
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
descriptionId: '[PC preview] unknow descriptionId',
icon: '[PC preview] unknow icon',
label: '[PC preview] unknow label',
labelId: '[PC preview] unknow labelId',
iconId: '[PC preview] unknow iconId',
backgroundImg: '[PC preview] unknow backgroundImg',
supportedModes: '[PC preview] unknow supportedModes',
reqCapabilities: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
abilityInfo: AbilityInfoMock,
moduleName: '[PC preview] unknow moduleName',
mainAbilityName: '[PC preview] unknow mainAbilityName',
installationFree: '[PC preview] unknow installationFree',
}
const screenDensityMock = {
SCREEN_SDPI: '[PC preview] unknow SCREEN_SDPI',
SCREEN_MDPI: '[PC preview] unknow SCREEN_MDPI',
SCREEN_LDPI: '[PC preview] unknow SCREEN_LDPI',
SCREEN_XLDPI: '[PC preview] unknow SCREEN_XLDPI',
SCREEN_XXLDPI: '[PC preview] unknow SCREEN_XXLDPI',
SCREEN_XXXLDPI: '[PC preview] unknow SCREEN_XXXLDPI'
SCREEN_SDPI: '[PC preview] unknow SCREEN_SDPI',
SCREEN_MDPI: '[PC preview] unknow SCREEN_MDPI',
SCREEN_LDPI: '[PC preview] unknow SCREEN_LDPI',
SCREEN_XLDPI: '[PC preview] unknow SCREEN_XLDPI',
SCREEN_XXLDPI: '[PC preview] unknow SCREEN_XXLDPI',
SCREEN_XXXLDPI: '[PC preview] unknow SCREEN_XXXLDPI'
}
const deviceTypeMock = {
DEVICE_TYPE_PHONE: '[PC preview] unknow DEVICE_TYPE_PHONE',
DEVICE_TYPE_TABLET: '[PC preview] unknow DEVICE_TYPE_TABLET',
DEVICE_TYPE_CAR: '[PC preview] unknow DEVICE_TYPE_CAR',
DEVICE_TYPE_PC: '[PC preview] unknow DEVICE_TYPE_PC',
DEVICE_TYPE_TV: '[PC preview] unknow DEVICE_TYPE_TV',
DEVICE_TYPE_WEARABLE: '[PC preview] unknow DEVICE_TYPE_WEARABLE'
DEVICE_TYPE_PHONE: '[PC preview] unknow DEVICE_TYPE_PHONE',
DEVICE_TYPE_TABLET: '[PC preview] unknow DEVICE_TYPE_TABLET',
DEVICE_TYPE_CAR: '[PC preview] unknow DEVICE_TYPE_CAR',
DEVICE_TYPE_PC: '[PC preview] unknow DEVICE_TYPE_PC',
DEVICE_TYPE_TV: '[PC preview] unknow DEVICE_TYPE_TV',
DEVICE_TYPE_WEARABLE: '[PC preview] unknow DEVICE_TYPE_WEARABLE'
}
const DeviceCapabilityClass = class DeviceCapability {
constructor() {
console.warn('DeviceCapability.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
screenDensity = screenDensityMock,
deviceType = deviceTypeMock
}
constructor() {
console.warn('DeviceCapability.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.screenDensity = screenDensityMock;
this.deviceType = deviceTypeMock;
}
}
const configurationClass = class configuration{
constructor() {
console.warn('configuration.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
directionMock = '[PC preview] unknow directionMock',
locale = '[PC preview] unknow locale'
}
const configurationClass = class configuration {
constructor() {
console.warn('configuration.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.directionMock = '[PC preview] unknow directionMock';
this.locale = '[PC preview] unknow locale';
}
}
const resourceManagerMock = {
getString: function (...args) {
console.warn("ResourceManager.getString 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);
})
}
},
getStringArray: function (...args) {
console.warn("ResourceManager.getStringArray 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]);
})
}
},
getMedia: function (...args) {
console.warn("ResourceManager.getMedia 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, new Uint8Array());
} else {
return new Promise((resolve, reject) => {
resolve(new Uint8Array());
})
}
},
getMediaBase64: function (...args) {
console.warn("ResourceManager.getMediaBase64 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);
})
}
},
getDeviceCapability: function (...args) {
console.warn("ResourceManager.getDeviceCapability 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, new DeviceCapabilityClass());
} else {
return new Promise((resolve, reject) => {
resolve(new DeviceCapabilityClass());
})
}
},
getConfiguration: function (...args) {
console.warn("ResourceManager.getConfiguration 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, new configurationClass());
} else {
return new Promise((resolve, reject) => {
resolve(new configurationClass());
})
}
},
getPluralString: function (...args) {
console.warn("ResourceManager.getPluralString 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);
})
}
},
getRawFile: function (...args) {
console.warn("ResourceManager.getRawFile 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, new Uint8Array());
} else {
return new Promise((resolve, reject) => {
resolve(new Uint8Array());
})
}
},
getString: function (...args) {
console.warn("ResourceManager.getString 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);
})
}
},
getStringArray: function (...args) {
console.warn("ResourceManager.getStringArray 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]);
})
}
},
getMedia: function (...args) {
console.warn("ResourceManager.getMedia 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, new Uint8Array());
} else {
return new Promise((resolve, reject) => {
resolve(new Uint8Array());
})
}
},
getMediaBase64: function (...args) {
console.warn("ResourceManager.getMediaBase64 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);
})
}
},
getDeviceCapability: function (...args) {
console.warn("ResourceManager.getDeviceCapability 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, new DeviceCapabilityClass());
} else {
return new Promise((resolve, reject) => {
resolve(new DeviceCapabilityClass());
})
}
},
getConfiguration: function (...args) {
console.warn("ResourceManager.getConfiguration 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, new configurationClass());
} else {
return new Promise((resolve, reject) => {
resolve(new configurationClass());
})
}
},
getPluralString: function (...args) {
console.warn("ResourceManager.getPluralString 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);
})
}
},
getRawFile: function (...args) {
console.warn("ResourceManager.getRawFile 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, new Uint8Array());
} else {
return new Promise((resolve, reject) => {
resolve(new Uint8Array());
})
}
},
}
export const contextClass = class context{
constructor() {
console.warn('context.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.resourceManager = resourceManagerMock;
this.applicationInfo = applicationInfoMock;
this.HapModuleInfo = HapModuleInfoMock;
this.cacheDir = '[PC preview] unknow cacheDir';
this.tempDir = '[PC preview] unknow tempDir';
this.filesDir = '[PC preview] unknow filesDir';
this.databaseDir = '[PC preview] unknow databaseDir';
this.storageDir = '[PC preview] unknow storageDir';
this.bundleCodeDir = '[PC preview] unknow bundleCodeDir';
this.distributedFilesDir = '[PC preview] unknow distributedFilesDir';
}
export const contextClass = class context {
constructor() {
console.warn('context.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.resourceManager = resourceManagerMock;
this.applicationInfo = applicationInfoMock;
this.HapModuleInfo = HapModuleInfoMock;
this.cacheDir = '[PC preview] unknow cacheDir';
this.tempDir = '[PC preview] unknow tempDir';
this.filesDir = '[PC preview] unknow filesDir';
this.databaseDir = '[PC preview] unknow databaseDir';
this.storageDir = '[PC preview] unknow storageDir';
this.bundleCodeDir = '[PC preview] unknow bundleCodeDir';
this.distributedFilesDir = '[PC preview] unknow distributedFilesDir';
}
};
export const abilityStageContextClass = class abilityStageContext extends contextClass{
constructor() {
super();
console.warn('Context.abilityStageContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.currentHapModuleInfo = HapModuleInfoMock;
}
export const abilityStageContextClass = class abilityStageContext extends contextClass {
constructor() {
super();
console.warn('Context.abilityStageContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.currentHapModuleInfo = HapModuleInfoMock;
}
}
export const ExtensionContextClass = class ExtensionContext extends contextClass {
constructor() {
super();
console.warn('Context.ExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
}
constructor() {
super();
console.warn('Context.ExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
}
};
export const AbilityResultMock = {
resultCode: "[PC Preview] unknow resultCode",
resultCode: "[PC Preview] unknow resultCode",
}
export const AbilityContextClass = class AbilityContext extends contextClass {
constructor() {
super();
console.warn('Ability.AbilityContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.abilityInfo = AbilityInfoMock;
this.currentHapModuleInfo = HapModuleInfoMock;
this.startAbility = function (...args) {
console.warn("Ability.AbilityContext.startAbility 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();
})
}
};
this.startAbilityForResult = function (...args) {
console.warn("Ability.AbilityContext.startAbilityForResult 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, AbilityResultMock);
} else {
return new Promise((resolve, reject) => {
resolve(AbilityResultMock);
})
}
};
this.terminateSelf = function (...args) {
console.warn("Ability.AbilityContext.terminateSelf 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();
})
}
};
this.terminateSelfWithResult = function (...args) {
console.warn("Ability.AbilityContext.terminateSelfWithResult 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();
})
}
};
this.connectAbility = function (...args) {
console.warn("Ability.AbilityContext.connectAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.disconnectAbility = function (...args) {
console.warn("Ability.AbilityContext.disconnectAbility 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();
})
}
};
}
constructor() {
super();
console.warn('Ability.AbilityContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.abilityInfo = AbilityInfoMock;
this.currentHapModuleInfo = HapModuleInfoMock;
this.startAbility = function (...args) {
console.warn("Ability.AbilityContext.startAbility 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();
})
}
};
this.startAbilityForResult = function (...args) {
console.warn("Ability.AbilityContext.startAbilityForResult 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, AbilityResultMock);
} else {
return new Promise((resolve, reject) => {
resolve(AbilityResultMock);
})
}
};
this.terminateSelf = function (...args) {
console.warn("Ability.AbilityContext.terminateSelf 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();
})
}
};
this.terminateSelfWithResult = function (...args) {
console.warn("Ability.AbilityContext.terminateSelfWithResult 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();
})
}
};
this.connectAbility = function (...args) {
console.warn("Ability.AbilityContext.connectAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.disconnectAbility = function (...args) {
console.warn("Ability.AbilityContext.disconnectAbility 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 mockAbilityContext() {
return new AbilityContextClass();
return new AbilityContextClass();
}
@@ -1,60 +1,60 @@
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/abilityContext"
export function mockFormExtension(){
const formBindingDataMock = {
data: paramMock.paramObjectMock
}
const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn('formExtension.formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.updateForm = function (...args) {
console.warn("formExtension.formExtensionContext.updateForm 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 mockFormExtension() {
const formBindingDataMock = {
data: paramMock.paramObjectMock
}
const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn('formExtension.formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.updateForm = function (...args) {
console.warn("formExtension.formExtensionContext.updateForm 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 formExtensionClass = class formExtension {
constructor() {
console.warn('application.formExtension.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new formExtensionContextClass();
this.onCreate = function (...args) {
console.warn("application.formExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return formBindingDataMock
};
this.onCastToNormal = function (...args) {
console.warn("application.formExtension.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
this.onUpdate = function (...args) {
console.warn("application.formExtension.onUpdate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
this.onVisibilityChange = function (...args) {
console.warn("application.formExtension.onVisibilityChange interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
this.onEvent = function (...args) {
console.warn("application.formExtension.onEvent interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
this.onDestroy = function (...args) {
console.warn("application.formExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
}
const formExtensionClass = class formExtension {
constructor() {
console.warn('application.formExtension.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new formExtensionContextClass();
this.onCreate = function (...args) {
console.warn("application.formExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return formBindingDataMock
};
this.onCastToNormal = function (...args) {
console.warn("application.formExtension.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onUpdate = function (...args) {
console.warn("application.formExtension.onUpdate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onVisibilityChange = function (...args) {
console.warn("application.formExtension.onVisibilityChange interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onEvent = function (...args) {
console.warn("application.formExtension.onEvent interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onDestroy = function (...args) {
console.warn("application.formExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
return new formExtensionClass();
}
return new formExtensionClass();
}
@@ -1,201 +1,201 @@
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/abilityContext"
export function mockServiceExtension(){
const IRemoteBrokerMock = {
asObject: function () {
console.warn("IRemoteBroker.asObject interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteObjectMock;
},
export function mockServiceExtension() {
const IRemoteBrokerMock = {
asObject: function () {
console.warn("IRemoteBroker.asObject interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteObjectMock;
},
}
const IRemoteObjectMock = {
queryLocalInterface: function () {
console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteBrokerMock;
},
sendRequest: function (...args) {
console.warn("IRemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
},
addDeathRecipient: function () {
console.warn("IRemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
removeDeathRecipient: function () {
console.warn("IRemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getInterfaceDescriptor: function () {
console.warn("IRemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
isObjectDead: function () {
console.warn("IRemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
}
const IRemoteObjectMock = {
queryLocalInterface: function () {
console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteBrokerMock;
},
sendRequest: function (...args) {
console.warn("IRemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
},
addDeathRecipient: function () {
console.warn("IRemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
removeDeathRecipient: function () {
console.warn("IRemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getInterfaceDescriptor: function () {
console.warn("IRemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
isObjectDead: function () {
console.warn("IRemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
}
const RemoteObjectClass = class RemoteObject {
constructor() {
console.warn('RemoteObject.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.queryLocalInterface = function () {
console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteBrokerMock;
};
this.sendRequest = function (...args) {
console.warn("RemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
};
this.addDeathRecipient = function () {
console.warn("RemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.removeDeathRecipient = function () {
console.warn("RemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.getInterfaceDescriptor = function () {
console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.isObjectDead = function () {
console.warn("RemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.queryLocalInterface = function (...args) {
console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteObjectMock
};
this.getInterfaceDescriptor = function () {
console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock
};
this.onRemoteRequest = function (...args) {
console.warn("RemoteObject.onRemoteRequest interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock
};
this.sendRequest = function (...args) {
console.warn("RemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
};
this.getCallingPid = function () {
console.warn("RemoteObject.getCallingPid interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.getCallingUid = function () {
console.warn("RemoteObject.getCallingUid interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.attachLocalInterface = function (...args) {
console.warn("RemoteObject.attachLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
const serviceExtensionContextClass = class serviceExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn('ServiceExtension.serviceExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.startAbility = function (...args) {
console.warn("ServiceExtension.serviceExtensionContext.startAbility 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 RemoteObjectClass = class RemoteObject {
constructor() {
console.warn('RemoteObject.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.queryLocalInterface = function () {
console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteBrokerMock;
},
this.sendRequest = function (...args) {
console.warn("RemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
},
this.addDeathRecipient = function () {
console.warn("RemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
this.removeDeathRecipient = function () {
console.warn("RemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
this.getInterfaceDescriptor = function () {
console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
this.isObjectDead = function () {
console.warn("RemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
}
this.queryLocalInterface = function (...args) {
console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteObjectMock
},
this.getInterfaceDescriptor = function () {
console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock
},
this.onRemoteRequest = function (...args) {
console.warn("RemoteObject.onRemoteRequest interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock
},
this.sendRequest = function (...args) {
console.warn("RemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
};
this.getCallingPid = function () {
console.warn("RemoteObject.getCallingPid interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.getCallingUid = function () {
console.warn("RemoteObject.getCallingUid interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.attachLocalInterface = function (...args) {
console.warn("RemoteObject.attachLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
};
this.terminateSelf = function (...args) {
console.warn("ServiceExtension.serviceExtensionContext.terminateSelf 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 serviceExtensionContextClass = class serviceExtensionContext extends ExtensionContextClass{
constructor() {
super();
console.warn('ServiceExtension.serviceExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.startAbility = function (...args) {
console.warn("ServiceExtension.serviceExtensionContext.startAbility 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();
})
}
};
this.terminateSelf = function (...args) {
console.warn("ServiceExtension.serviceExtensionContext.terminateSelf 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();
})
}
};
this.connectAbility = function (...args) {
console.warn("ServiceExtension.serviceExtensionContext.connectAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.disconnectAbility = function (...args) {
console.warn("ServiceExtension.serviceExtensionContext.disconnectAbility 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();
})
}
}
};
this.connectAbility = function (...args) {
console.warn("ServiceExtension.serviceExtensionContext.connectAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.disconnectAbility = function (...args) {
console.warn("ServiceExtension.serviceExtensionContext.disconnectAbility 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 ServiceExtensionClass = class ServiceExtension {
constructor() {
console.warn('application.ServiceExtension.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new serviceExtensionContextClass();
this.onCreate = function (...args) {
console.warn("application.ServiceExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
this.onDestroy = function () {
console.warn("application.ServiceExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
this.onRequest = function (...args) {
console.warn("application.ServiceExtension.onRequest interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
this.onConnect = function (...args) {
console.warn("application.ServiceExtension.onConnect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new RemoteObjectClass();
},
this.onDisconnect = function (...args) {
console.warn("application.ServiceExtension.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
this.onReconnect = function (...args) {
console.warn("application.ServiceExtension.onReconnect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
}
const ServiceExtensionClass = class ServiceExtension {
constructor() {
console.warn('application.ServiceExtension.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new serviceExtensionContextClass();
this.onCreate = function (...args) {
console.warn("application.ServiceExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onDestroy = function () {
console.warn("application.ServiceExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onRequest = function (...args) {
console.warn("application.ServiceExtension.onRequest interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onConnect = function (...args) {
console.warn("application.ServiceExtension.onConnect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new RemoteObjectClass();
};
this.onDisconnect = function (...args) {
console.warn("application.ServiceExtension.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onReconnect = function (...args) {
console.warn("application.ServiceExtension.onReconnect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
return new ServiceExtensionClass();
}
return new ServiceExtensionClass();
}
+326 -326
View File
@@ -1,334 +1,334 @@
import { paramMock } from "../utils"
export function mockOhosBluetooth() {
const connectedBLEDevicesMock = [
{
connectedBLEDevice: "[PC Preview] unknow connectedBLEDevice",
}
const connectedBLEDevicesMock = [
{
connectedBLEDevice: "[PC Preview] unknow connectedBLEDevice",
}
]
const gattServiceMock = {
serviceUuid: "[PC preview] unknown serviceUuid",
isPrimary: "[PC preview] unknown isPrimary",
characteristics: [
BLECharacteristicMock
],
includeServices: [
gattServiceMock
]
const gattServiceMock = {
serviceUuid: "[PC preview] unknown serviceUuid",
isPrimary: "[PC preview] unknown isPrimary",
characteristics: [
BLECharacteristicMock
],
includeServices: [
gattServiceMock
]
}
const BLECharacteristicMock = {
serviceUuid: "[PC preview] unknown serviceUuid",
characteristicUuid: "[PC preview] unknown characteristicUuid",
characteristicValue: "[PC preview] unknown characteristicValue",
descriptors: [
BLEDescriptorMock
]
}
const BLEDescriptorMock = {
serviceUuid: "[PC preview] unknown serviceUuid",
characteristicUuid: "[PC preview] unknown characteristicUuid",
descriptorUuid: "[PC preview] unknown descriptorUuid",
descriptorValue: "[PC preview] unknown descriptorValue"
}
const gattServicesMock = [
gattServiceMock
}
const BLECharacteristicMock = {
serviceUuid: "[PC preview] unknown serviceUuid",
characteristicUuid: "[PC preview] unknown characteristicUuid",
characteristicValue: "[PC preview] unknown characteristicValue",
descriptors: [
BLEDescriptorMock
]
const scanResultMock = {
deviceId: "[PC preview] unknown deviceId",
rssi: "[PC preview] unknown rssi",
data: "[PC preview] unknown data"
}
const characteristicReadReqMock = {
deviceId: "[PC preview] unknown deviceId",
transId: "[PC preview] unknown transId",
offset: "[PC preview] unknown offset",
characteristicUuid: "[PC preview] unknown characteristicUuid",
serviceUuid: "[PC preview] unknown serviceUuid"
}
const characteristicWriteReqMock = {
deviceId: "[PC preview] unknown deviceId",
transId: "[PC preview] unknown transId",
offset: "[PC preview] unknown offset",
isPrep: "[PC preview] unknown isPrep",
needRsp: "[PC preview] unknown needRsp",
value: "[PC preview] unknown value",
characteristicUuid: "[PC preview] unknown characteristicUuid",
serviceUuid: "[PC preview] unknown serviceUuid"
}
const descriptorReadReqMock = {
deviceId: "[PC preview] unknown v",
transId: "[PC preview] unknown transId",
offset: "[PC preview] unknown offset",
descriptorUuid: "[PC preview] unknown descriptorUuid",
characteristicUuid: "[PC preview] unknown characteristicUuid",
serviceUuid: "[PC preview] unknown serviceUuid"
}
const descriptorWriteReqMock = {
deviceId: "[PC preview] unknown deviceId",
transId: "[PC preview] unknown transId",
offset: "[PC preview] unknown offset",
isPrep: "[PC preview] unknown isPrep",
needRsp: "[PC preview] unknown needRsp",
value: "[PC preview] unknown value",
descriptorUuid: "[PC preview] unknown descriptorUuid",
characteristicUuid: "[PC preview] unknown characteristicUuid",
serviceUuid: "[PC preview] unknown serviceUuid"
}
const BLEConnectChangedStateMock = {
deviceId: "[PC preview] unknown deviceId",
state: "[PC preview] unknown state"
}
const GattServerMock = {
startAdvertising: function (...args) {
console.warn("GattServer.startAdvertising interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
stopAdvertising: function () {
console.warn("GattServer.stopAdvertising interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
addService: function (...args) {
console.warn("GattServer.addService interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
removeService: function (...args) {
console.warn("GattServer.removeService 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 () {
console.warn("GattServer.close interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
notifyCharacteristicChanged: function (...args) {
console.warn("GattServer.notifyCharacteristicChanged interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
sendResponse: function (...args) {
console.warn("GattServer.sendResponse interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
on: function (...args) {
console.warn("GattServer.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] == 'characteristicRead') {
args[len - 1].call(this, characteristicReadReqMock);
} else if (args[0] == 'characteristicWrite') {
args[len - 1].call(this, characteristicWriteReqMock);
} else if (args[0] == 'descriptorRead') {
args[len - 1].call(this, descriptorReadReqMock);
} else if (args[0] == 'descriptorWrite') {
args[len - 1].call(this, descriptorWriteReqMock);
} else if (args[0] == 'connectStateChange') {
args[len - 1].call(this, BLEConnectChangedStateMock);
}
}
},
off: function (...args) {
console.warn("GattServer.off 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] == 'characteristicRead') {
args[len - 1].call(this, characteristicReadReqMock);
} else if (args[0] == 'characteristicWrite') {
args[len - 1].call(this, characteristicWriteReqMock);
} else if (args[0] == 'descriptorRead') {
args[len - 1].call(this, descriptorReadReqMock);
} else if (args[0] == 'descriptorWrite') {
args[len - 1].call(this, descriptorWriteReqMock);
} else if (args[0] == 'connectStateChange') {
args[len - 1].call(this, BLEConnectChangedStateMock);
}
}
},
}
const GattClientDeviceMock = {
connect: function () {
console.warn("GattClientDevice.connect interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
disconnect: function () {
console.warn("GattClientDevice.disconnect 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 () {
console.warn("GattClientDevice.close interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
getDeviceName: function (...args) {
console.warn("GattClientDevice.getDeviceName 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);
})
}
},
getServices: function (...args) {
console.warn("GattClientDevice.getServices 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, gattServicesMock);
} else {
return new Promise((resolve, reject) => {
resolve(gattServicesMock);
})
}
},
readCharacteristicValue: function (...args) {
console.warn("GattClientDevice.readCharacteristicValue 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, BLECharacteristicMock);
} else {
return new Promise((resolve, reject) => {
resolve(BLECharacteristicMock);
})
}
},
readDescriptorValue: function (...args) {
console.warn("GattClientDevice.readDescriptorValue 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, BLEDescriptorMock);
} else {
return new Promise((resolve, reject) => {
resolve(BLEDescriptorMock);
})
}
},
writeCharacteristicValue: function (...args) {
console.warn("GattClientDevice.writeCharacteristicValue interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
writeDescriptorValue: function (...args) {
console.warn("GattClientDevice.writeDescriptorValue interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
getRssiValue: function (...args) {
console.warn("GattClientDevice.getRssiValue 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);
})
}
},
setBLEMtuSize: function (...args) {
console.warn("GattClientDevice.setBLEMtuSize interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
setNotifyCharacteristicChanged: function (...args) {
console.warn("GattClientDevice.setNotifyCharacteristicChanged interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
on: function (...args) {
console.warn("GattClientDevice.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] == 'BLECharacteristicChange') {
args[len - 1].call(this, BLECharacteristicMock);
} else if (args[0] == 'BLEConnectionStateChange') {
args[len - 1].call(this, BLEConnectChangedStateMock);
}
}
},
off: function (...args) {
console.warn("GattClientDevice.off 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] == 'BLECharacteristicChange') {
args[len - 1].call(this, BLECharacteristicMock);
} else if (args[0] == 'BLEConnectionStateChange') {
args[len - 1].call(this, BLEConnectChangedStateMock);
}
}
},
}
global.ohosplugin.bluetooth = {
getState: function () {
console.warn("bluetooth.getState interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
},
getBtConnectionState: function () {
console.warn("bluetooth.getBtConnectionState interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
},
pairDevice: function (...args) {
console.warn("bluetooth.pairDevice interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
}
const BLEDescriptorMock = {
serviceUuid: "[PC preview] unknown serviceUuid",
characteristicUuid: "[PC preview] unknown characteristicUuid",
descriptorUuid: "[PC preview] unknown descriptorUuid",
descriptorValue: "[PC preview] unknown descriptorValue"
}
const gattServicesMock = [
gattServiceMock
]
const scanResultMock = {
deviceId: "[PC preview] unknown deviceId",
rssi: "[PC preview] unknown rssi",
data: "[PC preview] unknown data"
}
const characteristicReadReqMock = {
deviceId: "[PC preview] unknown deviceId",
transId: "[PC preview] unknown transId",
offset: "[PC preview] unknown offset",
characteristicUuid: "[PC preview] unknown characteristicUuid",
serviceUuid: "[PC preview] unknown serviceUuid"
}
const characteristicWriteReqMock = {
deviceId: "[PC preview] unknown deviceId",
transId: "[PC preview] unknown transId",
offset: "[PC preview] unknown offset",
isPrep: "[PC preview] unknown isPrep",
needRsp: "[PC preview] unknown needRsp",
value: "[PC preview] unknown value",
characteristicUuid: "[PC preview] unknown characteristicUuid",
serviceUuid: "[PC preview] unknown serviceUuid"
}
const descriptorReadReqMock = {
deviceId: "[PC preview] unknown v",
transId: "[PC preview] unknown transId",
offset: "[PC preview] unknown offset",
descriptorUuid: "[PC preview] unknown descriptorUuid",
characteristicUuid: "[PC preview] unknown characteristicUuid",
serviceUuid: "[PC preview] unknown serviceUuid"
}
const descriptorWriteReqMock = {
deviceId: "[PC preview] unknown deviceId",
transId: "[PC preview] unknown transId",
offset: "[PC preview] unknown offset",
isPrep: "[PC preview] unknown isPrep",
needRsp: "[PC preview] unknown needRsp",
value: "[PC preview] unknown value",
descriptorUuid: "[PC preview] unknown descriptorUuid",
characteristicUuid: "[PC preview] unknown characteristicUuid",
serviceUuid: "[PC preview] unknown serviceUuid"
}
const BLEConnectChangedStateMock = {
deviceId: "[PC preview] unknown deviceId",
state: "[PC preview] unknown state"
}
const GattServerMock = {
startAdvertising: function (...args) {
console.warn("GattServer.startAdvertising interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
global.ohosplugin.bluetooth.BLE = {
createGattServer: function () {
console.warn("bluetooth.BLE.createGattServer interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return GattServerMock
},
createGattClientDevice: function (...args) {
console.warn("bluetooth.BLE.createGattClientDevice interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return GattClientDeviceMock
},
getConnectedBLEDevices: function () {
console.warn("bluetooth.BLE.getConnectedBLEDevices interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return connectedBLEDevicesMock
},
startBLEScan: function (...args) {
console.warn("bluetooth.BLE.startBLEScan interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
stopBLEScan: function () {
console.warn("bluetooth.BLE.stopBLEScan 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("bluetooth.BLE.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] == 'BLEDeviceFind') {
args[len - 1].call(this, [scanResultMock]);
}
}
},
off: function (...args) {
console.warn("bluetooth.BLE.off 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] == 'BLEDeviceFind') {
args[len - 1].call(this, [scanResultMock]);
}
}
},
stopAdvertising: function () {
console.warn("GattServer.stopAdvertising interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
addService: function (...args) {
console.warn("GattServer.addService interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
removeService: function (...args) {
console.warn("GattServer.removeService 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 () {
console.warn("GattServer.close interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
notifyCharacteristicChanged: function (...args) {
console.warn("GattServer.notifyCharacteristicChanged interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
sendResponse: function (...args) {
console.warn("GattServer.sendResponse interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
on: function (...args) {
console.warn("GattServer.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] == 'characteristicRead') {
args[len - 1].call(this, characteristicReadReqMock);
} else if (args[0] == 'characteristicWrite') {
args[len - 1].call(this, characteristicWriteReqMock);
} else if (args[0] == 'descriptorRead') {
args[len - 1].call(this, descriptorReadReqMock);
} else if (args[0] == 'descriptorWrite') {
args[len - 1].call(this, descriptorWriteReqMock);
} else if (args[0] == 'connectStateChange') {
args[len - 1].call(this, BLEConnectChangedStateMock);
}
}
},
off: function (...args) {
console.warn("GattServer.off 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] == 'characteristicRead') {
args[len - 1].call(this, characteristicReadReqMock);
} else if (args[0] == 'characteristicWrite') {
args[len - 1].call(this, characteristicWriteReqMock);
} else if (args[0] == 'descriptorRead') {
args[len - 1].call(this, descriptorReadReqMock);
} else if (args[0] == 'descriptorWrite') {
args[len - 1].call(this, descriptorWriteReqMock);
} else if (args[0] == 'connectStateChange') {
args[len - 1].call(this, BLEConnectChangedStateMock);
}
}
},
}
const GattClientDeviceMock = {
connect: function () {
console.warn("GattClientDevice.connect interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
disconnect: function () {
console.warn("GattClientDevice.disconnect 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 () {
console.warn("GattClientDevice.close interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
getDeviceName: function (...args) {
console.warn("GattClientDevice.getDeviceName 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);
})
}
},
getServices: function (...args) {
console.warn("GattClientDevice.getServices 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, gattServicesMock);
} else {
return new Promise((resolve, reject) => {
resolve(gattServicesMock);
})
}
},
readCharacteristicValue: function (...args) {
console.warn("GattClientDevice.readCharacteristicValue 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, BLECharacteristicMock);
} else {
return new Promise((resolve, reject) => {
resolve(BLECharacteristicMock);
})
}
},
readDescriptorValue: function (...args) {
console.warn("GattClientDevice.readDescriptorValue 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, BLEDescriptorMock);
} else {
return new Promise((resolve, reject) => {
resolve(BLEDescriptorMock);
})
}
},
writeCharacteristicValue: function (...args) {
console.warn("GattClientDevice.writeCharacteristicValue interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
writeDescriptorValue: function (...args) {
console.warn("GattClientDevice.writeDescriptorValue interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
getRssiValue: function (...args) {
console.warn("GattClientDevice.getRssiValue 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);
})
}
},
setBLEMtuSize: function (...args) {
console.warn("GattClientDevice.setBLEMtuSize interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
setNotifyCharacteristicChanged: function (...args) {
console.warn("GattClientDevice.setNotifyCharacteristicChanged interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
on: function (...args) {
console.warn("GattClientDevice.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] == 'BLECharacteristicChange') {
args[len - 1].call(this, BLECharacteristicMock);
} else if (args[0] == 'BLEConnectionStateChange') {
args[len - 1].call(this, BLEConnectChangedStateMock);
}
}
},
off: function (...args) {
console.warn("GattClientDevice.off 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] == 'BLECharacteristicChange') {
args[len - 1].call(this, BLECharacteristicMock);
} else if (args[0] == 'BLEConnectionStateChange') {
args[len - 1].call(this, BLEConnectChangedStateMock);
}
}
},
}
global.ohosplugin.bluetooth = {
getState: function () {
console.warn("bluetooth.getState interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
},
getBtConnectionState: function () {
console.warn("bluetooth.getBtConnectionState interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
},
pairDevice: function (...args) {
console.warn("bluetooth.pairDevice interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
}
global.ohosplugin.bluetooth.BLE = {
createGattServer: function () {
console.warn("bluetooth.BLE.createGattServer interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return GattServerMock
},
createGattClientDevice: function (...args) {
console.warn("bluetooth.BLE.createGattClientDevice interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return GattClientDeviceMock
},
getConnectedBLEDevices: function () {
console.warn("bluetooth.BLE.getConnectedBLEDevices interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return connectedBLEDevicesMock
},
startBLEScan: function (...args) {
console.warn("bluetooth.BLE.startBLEScan interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
stopBLEScan: function () {
console.warn("bluetooth.BLE.stopBLEScan 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("bluetooth.BLE.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] == 'BLEDeviceFind') {
args[len - 1].call(this, [scanResultMock]);
}
}
},
off: function (...args) {
console.warn("bluetooth.BLE.off 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] == 'BLEDeviceFind') {
args[len - 1].call(this, [scanResultMock]);
}
}
},
}
}
File diff suppressed because it is too large Load Diff