mirror of
https://gitee.com/openharmony/third_party_jsframework
synced 2024-11-27 00:40:37 +00:00
!623 Add mock for getCutoutInfo
Merge pull request !623 from X PN/dev-cutout-mock
This commit is contained in:
commit
e93206882f
@ -30,24 +30,54 @@ const DisplayType = {
|
||||
change: 'change'
|
||||
}
|
||||
|
||||
export const Display = {
|
||||
id: '[PC preview] unknow id',
|
||||
name: '[PC preview] unknow name',
|
||||
alive: '[PC preview] unknow alive',
|
||||
state: DisplayState,
|
||||
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 Rect = {
|
||||
left: '[PC preview] unknow left',
|
||||
top: '[PC preview] unknow top',
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height',
|
||||
}
|
||||
|
||||
const WaterfallDisplayAreaRects = {
|
||||
left: Rect,
|
||||
top: Rect,
|
||||
width: Rect,
|
||||
height: Rect
|
||||
}
|
||||
|
||||
const CutoutInfo = {
|
||||
boundingRects: Array(Rect),
|
||||
waterfallDisplayAreaRects: WaterfallDisplayAreaRects
|
||||
}
|
||||
|
||||
const Display = {
|
||||
id: '[PC preview] unknow id',
|
||||
name: '[PC preview] unknow name',
|
||||
alive: '[PC preview] unknow alive',
|
||||
state: DisplayState,
|
||||
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',
|
||||
getCutoutInfo: function(...args) {
|
||||
console.warn('Display.getCutoutInfo 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, CutoutInfo);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(CutoutInfo);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const display = {
|
||||
getDefaultDisplay: function (...args) {
|
||||
console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the" +
|
||||
|
Loading…
Reference in New Issue
Block a user