!623 Add mock for getCutoutInfo

Merge pull request !623 from X PN/dev-cutout-mock
This commit is contained in:
openharmony_ci 2022-08-09 01:41:39 +00:00 committed by Gitee
commit e93206882f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -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" +