mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-18 20:44:48 -04:00
补充 mock
Signed-off-by: zhouyaoying <zhouyaoying@huawei.com> Change-Id: If8a2ff8ff635f196e4e48f00df00d692b0f9b858
This commit is contained in:
@@ -1,88 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 mockDisplay() {
|
||||
const displayMock = {
|
||||
densityDPI: '[PC preview] unknow densityDPI',
|
||||
densityPixels: '[PC preview] unknow densityPixels',
|
||||
scaledDensity: '[PC preview] unknow scaledDensity',
|
||||
xDPI: '[PC preview] unknow xDPI',
|
||||
yDPI: '[PC preview] unknow yDPI',
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height',
|
||||
alive: '[PC preview] unknow alive',
|
||||
refreshRate: '[PC preview] unknow refreshRate',
|
||||
id: '[PC preview] unknow id',
|
||||
state: '[PC preview] unknow state',
|
||||
rotation: '[PC preview] unknow rotation',
|
||||
name: '[PC preview] unknow name'
|
||||
}
|
||||
const allDisplayMock = [{
|
||||
densityDPI: '[PC preview] unknow densityDPI',
|
||||
densityPixels: '[PC preview] unknow densityPixels',
|
||||
scaledDensity: '[PC preview] unknow scaledDensity',
|
||||
xDPI: '[PC preview] unknow xDPI',
|
||||
yDPI: '[PC preview] unknow yDPI',
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height',
|
||||
alive: '[PC preview] unknow alive',
|
||||
refreshRate: '[PC preview] unknow refreshRate',
|
||||
id: '[PC preview] unknow id',
|
||||
state: '[PC preview] unknow state',
|
||||
rotation: '[PC preview] unknow rotation',
|
||||
name: '[PC preview] unknow name'
|
||||
}]
|
||||
const display = {
|
||||
getDefaultDisplay: function (...args) {
|
||||
console.warn("display.getDefaultDisplay 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, displayMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(displayMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllDisplay: function (...args) {
|
||||
console.warn("display.getAllDisplay 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, allDisplayMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(allDisplayMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("display.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
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("display.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
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
}
|
||||
return display
|
||||
/*
|
||||
* Copyright (c) 2021 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 DisplayState = {
|
||||
STATE_UNKNOWN: 0,
|
||||
STATE_OFF: 1,
|
||||
STATE_ON: 2,
|
||||
STATE_DOZE: 3,
|
||||
STATE_DOZE_SUSPEND: 4,
|
||||
STATE_VR: 5,
|
||||
STATE_ON_SUSPEND: 6
|
||||
}
|
||||
const DisplayType = {
|
||||
add: 'add',
|
||||
remove: 'remove',
|
||||
change: 'change'
|
||||
}
|
||||
|
||||
export const Display = {
|
||||
id: '[PC preview] unknow id',
|
||||
name: '[PC preview] unknow name',
|
||||
alive: '[PC preview] unknow alive',
|
||||
state: '[PC preview] unknow state',
|
||||
refreshRate: '[PC preview] unknow refreshRate',
|
||||
rotation: '[PC preview] unknow rotation',
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height',
|
||||
densityDPI: '[PC preview] unknow densityDPI',
|
||||
densityPixels: '[PC preview] unknow densityPixels',
|
||||
scaledDensity: '[PC preview] unknow scaledDensity',
|
||||
xDPI: '[PC preview] unknow xDPI',
|
||||
yDPI: '[PC preview] unknow yDPI'
|
||||
}
|
||||
|
||||
export function mockDisplay() {
|
||||
|
||||
const display = {
|
||||
getDefaultDisplay: function (...args) {
|
||||
console.warn("Display.getDefaultDisplay 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, Display)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Display)
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllDisplay: function (...args) {
|
||||
console.warn("Display.getAllDisplay 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, [Display])
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([Display])
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("Display.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 (len!==2){
|
||||
console.warn("Display.on:please check params !")
|
||||
return
|
||||
}
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === DisplayType.add|| args[0] === DisplayType.remove || args[0] === DisplayType.change){
|
||||
console.warn(`Display.on: you has registered ${args[0]} event.`)
|
||||
} else {
|
||||
console.warn("Display.on:please check first param!")
|
||||
}
|
||||
} else {
|
||||
console.warn("Display.on:please check params, the second parma must be a function!")
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("Display.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 (len!==2){
|
||||
console.warn("Display.off:please check params!")
|
||||
return
|
||||
}
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === DisplayType.add|| args[0] === DisplayType.remove || args[0] === DisplayType.change){
|
||||
console.warn(`Display.off: you has registered ${args[0]} event`)
|
||||
} else {
|
||||
console.warn("Display.off:please check first param!")
|
||||
}
|
||||
} else {
|
||||
console.warn("Display.off:please check params, the second parma must be a function!")
|
||||
}
|
||||
},
|
||||
DisplayState: DisplayState,
|
||||
Type: DisplayType
|
||||
}
|
||||
return display
|
||||
}
|
||||
@@ -1,211 +1,224 @@
|
||||
/*
|
||||
* 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 const OrientationMock = {
|
||||
UNSPECIFIED: 0,
|
||||
VERTICAL: 1,
|
||||
HORIZONTAL: 2,
|
||||
REVERSE_VERTICAL: 3,
|
||||
REVERSE_HORIZONTAL: 4,
|
||||
SENSOR: 5,
|
||||
SENSOR_VERTICAL: 6,
|
||||
SENSOR_HORIZONTAL: 7
|
||||
};
|
||||
|
||||
export const screenMock = {
|
||||
id: 'PC preview] unknown id',
|
||||
parent: '[PC preview] unknown parent',
|
||||
supportedModeInfo: supportedModeInfoMock,
|
||||
activeModeIndex: '[PC preview] unknown activeModeIndex',
|
||||
orientation: OrientationMock,
|
||||
setOrientation: function(...args) {
|
||||
console.warn('Screen.setOrientation 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
setScreenActiveMode: function(...args) {
|
||||
console.warn('Screen.setScreenActiveMode 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
setDensityDpi: function(...args) {
|
||||
console.warn('Screen.setDensityDpi 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const allScreenMock = [
|
||||
screenMock
|
||||
];
|
||||
|
||||
export const ExpandOptionMock = {
|
||||
screenId: '[PC preview] unknown screenId',
|
||||
startX: '[PC preview] unknown startX',
|
||||
startY: '[PC preview] unknown startY'
|
||||
};
|
||||
|
||||
export const VirtualScreenOptionMock = {
|
||||
name: '[PC preview] unknown name',
|
||||
width: '[PC preview] unknown width',
|
||||
height: '[PC preview] unknown height',
|
||||
density: '[PC preview] unknown density',
|
||||
surfaceId: '[PC preview] unknown surfaceId'
|
||||
};
|
||||
|
||||
export const screenModeInfoMock = {
|
||||
id: '[PC preview] unknown id',
|
||||
width: '[PC preview] unknown width',
|
||||
height: '[PC preview] unknown height',
|
||||
refreshRate: '[PC preview] unknown refreshRate'
|
||||
};
|
||||
|
||||
export const supportedModeInfoMock = [
|
||||
screenModeInfoMock
|
||||
]
|
||||
|
||||
export function mockScreen() {
|
||||
const screen = {
|
||||
ExpandOption: ExpandOptionMock,
|
||||
VirtualScreenOption: VirtualScreenOptionMock,
|
||||
Orientation: OrientationMock,
|
||||
ScreenModeInfo: screenModeInfoMock,
|
||||
getAllScreens: function(...args) {
|
||||
console.warn('Screen.getAllScreens 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, allScreenMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(allScreenMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function(...args) {
|
||||
console.warn('Screen.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] === 'connect' || args[0] === 'disconnect' || args[0] === 'change') {
|
||||
console.warn(`you has registered ${args[0]} event`)
|
||||
} else {
|
||||
console.warn('on: please check first param!')
|
||||
}
|
||||
} else {
|
||||
console.warn('on: please check param!')
|
||||
}
|
||||
},
|
||||
off: function(...args) {
|
||||
console.warn('Screen.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] === 'connect' || args[0] === 'disconnect' || args[0] === 'change') {
|
||||
console.warn(`you has registered ${args[0]} event`)
|
||||
} else {
|
||||
console.warn('off: please check first param!')
|
||||
}
|
||||
} else {
|
||||
console.warn('off: please check param!')
|
||||
}
|
||||
},
|
||||
makeExpand: function(...args) {
|
||||
console.warn('Screen.makeExpand 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
makeMirror: function(...args) {
|
||||
console.warn('Screen.makeMirror 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
createVirtualScreen: function(...args) {
|
||||
console.warn('Screen.createVirtualScreen 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, screenMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(screenMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
destroyVirtualScreen: function(...args) {
|
||||
console.warn('Screen.destroyVirtualScreen 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
setVirtualScreenSurface: function(...args) {
|
||||
console.warn('Screen.setVirtualScreenSurface 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return screen
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 const Orientation = {
|
||||
UNSPECIFIED: 0,
|
||||
VERTICAL: 1,
|
||||
HORIZONTAL: 2,
|
||||
REVERSE_VERTICAL: 3,
|
||||
REVERSE_HORIZONTAL: 4,
|
||||
SENSOR: 5,
|
||||
SENSOR_VERTICAL: 6,
|
||||
SENSOR_HORIZONTAL: 7
|
||||
};
|
||||
|
||||
export const Screen = {
|
||||
id: 'PC preview] unknown id',
|
||||
parent: '[PC preview] unknown parent',
|
||||
supportedModeInfo: supportedModeInfoArray,
|
||||
activeModeIndex: '[PC preview] unknown activeModeIndex',
|
||||
orientation: Orientation,
|
||||
setOrientation: function(...args) {
|
||||
console.warn('Screen.setOrientation 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
setScreenActiveMode: function(...args) {
|
||||
console.warn('Screen.setScreenActiveMode 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
setDensityDpi: function(...args) {
|
||||
console.warn('Screen.setDensityDpi 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const allScreenMock = [
|
||||
Screen
|
||||
];
|
||||
|
||||
export const ExpandOption = {
|
||||
screenId: '[PC preview] unknown screenId',
|
||||
startX: '[PC preview] unknown startX',
|
||||
startY: '[PC preview] unknown startY'
|
||||
};
|
||||
|
||||
export const VirtualScreenOption = {
|
||||
name: '[PC preview] unknown name',
|
||||
width: '[PC preview] unknown width',
|
||||
height: '[PC preview] unknown height',
|
||||
density: '[PC preview] unknown density',
|
||||
surfaceId: '[PC preview] unknown surfaceId'
|
||||
};
|
||||
|
||||
export const ScreenModeInfo = {
|
||||
id: '[PC preview] unknown id',
|
||||
width: '[PC preview] unknown width',
|
||||
height: '[PC preview] unknown height',
|
||||
refreshRate: '[PC preview] unknown refreshRate'
|
||||
};
|
||||
|
||||
export const supportedModeInfoArray = [
|
||||
ScreenModeInfo
|
||||
]
|
||||
const EventTypeMock = {
|
||||
connect: 'connect',
|
||||
disconnect: 'disconnect',
|
||||
change: 'change'
|
||||
}
|
||||
export function mockScreen() {
|
||||
const screen = {
|
||||
ExpandOption: ExpandOption,
|
||||
VirtualScreenOption: VirtualScreenOption,
|
||||
Orientation: Orientation,
|
||||
ScreenModeInfo: ScreenModeInfo,
|
||||
EventType: EventTypeMock,
|
||||
getAllScreens: function(...args) {
|
||||
console.warn(
|
||||
'Screen.getAllScreens 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, allScreenMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(allScreenMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function(...args) {
|
||||
console.warn(
|
||||
'Screen.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 (len!==2){
|
||||
console.warn("Screen.on please check params!")
|
||||
return
|
||||
}
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === EventTypeMock.connect || args[0] === EventTypeMock.disconnect || args[0] === EventTypeMock.change) {
|
||||
console.warn(`Screen.on you has registered ${args[0]} event`)
|
||||
} else {
|
||||
console.warn('Screen.on please check first param!')
|
||||
}
|
||||
} else {
|
||||
console.warn('Screen.on please check param!')
|
||||
}
|
||||
},
|
||||
off: function(...args) {
|
||||
console.warn(
|
||||
'Screen.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 (len!==2){
|
||||
console.warn("Screen.off please check params!")
|
||||
return
|
||||
}
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === EventTypeMock.connect || args[0] === EventTypeMock.disconnect || args[0] === EventTypeMock.change) {
|
||||
console.warn(`Screen.off you has registered ${args[0]} event`)
|
||||
} else {
|
||||
console.warn('Screen.off please check first param!')
|
||||
}
|
||||
} else {
|
||||
console.warn('Screen.off please check param!')
|
||||
}
|
||||
},
|
||||
makeExpand: function(...args) {
|
||||
console.warn(
|
||||
'Screen.makeExpand 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
makeMirror: function(...args) {
|
||||
console.warn(
|
||||
'Screen.makeMirror 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
createVirtualScreen: function(...args) {
|
||||
console.warn(
|
||||
'Screen.createVirtualScreen 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, Screen);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(Screen);
|
||||
});
|
||||
}
|
||||
},
|
||||
destroyVirtualScreen: function(...args) {
|
||||
console.warn(
|
||||
'Screen.destroyVirtualScreen 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
setVirtualScreenSurface: function(...args) {
|
||||
console.warn(
|
||||
'Screen.setVirtualScreenSurface 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return screen
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user