add mock for getCutoutInfo

Signed-off-by: xpeng <pengxin33@huawei.com>
Change-Id: I2ff8847d1cb9a04acbfdd3d5779cd6a507f0d0df
This commit is contained in:
xpeng 2022-08-06 16:58:23 +08:00
parent a2bcc90ab8
commit 214b3bc3aa

View File

@ -30,6 +30,29 @@ const DisplayType = {
change: 'change'
}
export const Rect = {
left: '[PC preview] unknow left',
top: '[PC preview] unknow top',
width: '[PC preview] unknow width',
height: '[PC preview] unknow height',
}
export const WaterfallDisplayAreaRects = {
left: Rect,
top: Rect,
width: Rect,
height: Rect
}
export const allBoudingRectsMock = [
Rect
]
export const CutoutInfo = {
boundingRects: allBoudingRectsMock,
waterfallDisplayAreaRects: WaterfallDisplayAreaRects
}
export const Display = {
id: '[PC preview] unknow id',
name: '[PC preview] unknow name',
@ -43,7 +66,19 @@ export const Display = {
densityPixels: '[PC preview] unknow densityPixels',
scaledDensity: '[PC preview] unknow scaledDensity',
xDPI: '[PC preview] unknow xDPI',
yDPI: '[PC preview] unknow yDPI'
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);
});
}
}
}
export function mockDisplay() {