未验证 提交 c6a76c66 编写于 作者: O openharmony_ci 提交者: Gitee

!5916 【窗口子系统】修改非法参数报错级别

Merge pull request !5916 from 华华小仙女/master
......@@ -47,7 +47,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
'TYPE_VOLUME_OVERLAY': 6,
'TYPE_NAVIGATION_BAR': 7,
'TYPE_FLOAT': 8,
'TYPE_FLOAT_CAMERA':9
'TYPE_FLOAT_CAMERA': 9
}
var windowLayoutModeArr = [];
var windowLayoutModeDic = {
......@@ -556,12 +556,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let contentColorIndex = cloneColorArr.SCC.indexOf(tempData.contentColor);
if (backgroundIndex >= 0) {
cloneColorArr.SBC.splice(backgroundIndex, 1);
}else{
} else {
console.log(msgStr + 'SBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor));
}
if (contentColorIndex >= 0) {
cloneColorArr.SCC.splice(contentColorIndex, 1);
}else{
} else {
console.log(msgStr + 'SCC tempData.contentColor:' + JSON.stringify(tempData.contentColor));
}
console.log(msgStr + 'compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.SCC.length) + ' ,cloneColorArr.SBC:' + JSON.stringify(cloneColorArr.SBC));
......@@ -1169,14 +1169,17 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let caseName = 'loadContentTest10';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.loadContent(null, (err, data) => {
if (err && err.code) {
expectedError(err, caseName, 'windowStage.loadContent', done, 1003);
try {
windowStage.loadContent(null, (err, data) => {
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
}
done();
});
expect(false).assertTrue();
});
} catch (err) {
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err' + JSON.stringify(err));
expect(err.code == 401).assertTrue();
}
console.log(msgStr + 'end');
done();
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_011
......@@ -1207,13 +1210,17 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let caseName = 'loadContentTest12';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.loadContent(null, abilityStorage, (err, data) => {
if (err && err.code) {
expectedError(err, caseName, 'windowStage.loadContent', done, 1003);
try {
windowStage.loadContent(null, abilityStorage, (err, data) => {
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
}
done();
});
expect(false).assertTrue();
});
} catch (err) {
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err ' + JSON.stringify(err));
expect(err.code === 401).assertTrue();
}
done();
})
/**
* @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_003
......@@ -1244,16 +1251,16 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let caseName = 'createSubWindowTest4';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.createSubWindow(null, (err, data) => {
if (err && err.code) {
expectedError(err, caseName, 'windowStage.createSubWindow', done, 1003);
try {
windowStage.createSubWindow(null, (err, data) => {
console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
} else {
expect(false).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow end data=' + JSON.stringify(data));
}
done();
});
});
} catch (err) {
expect(err.code === 401).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow(null) catch err=' + JSON.stringify(err));
}
done();
})
/**
* @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_002
......@@ -1434,7 +1441,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let currentDeviceDefaultDpi;
let currentDeviceDefault = null;
display.getDefaultDisplay(async(err, data) => {
display.getDefaultDisplay(async (err, data) => {
if (err.code) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
return;
......@@ -1442,16 +1449,16 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
currentDeviceDefault = data;
currentDeviceDefaultDpi = parseInt(currentDeviceDefault.densityDPI)
let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300,currentDeviceDefaultDpi];
let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300, currentDeviceDefaultDpi];
for (let i = 0;i < dpiItem.length; i++) {
await sleep(1000);
screens[0].setDensityDpi(dpiItem[i],(errDpi,dataDpi)=>{
screens[0].setDensityDpi(dpiItem[i], (errDpi, dataDpi) => {
if (errDpi.code) {
console.error('Failed to set DensityDpi. Cause: ' + JSON.stringify(err)+ dpiItem[i]);
console.error('Failed to set DensityDpi. Cause: ' + JSON.stringify(err) + dpiItem[i]);
return;
}
console.log(msgStr + 'screen.setDensityDpi success set DPI ' + dpiItem[i]);
display.getDefaultDisplay((error,result)=>{
display.getDefaultDisplay((error, result) => {
if (error.code) {
console.error(msgStr + 'screen.setDensityDpi display.getDefaultDisplay failed');
return;
......@@ -1482,15 +1489,15 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
});
console.log(msgStr + 'windowStage.getMainWindow' + JSON.stringify(mainWin));
expect(!!mainWin).assertTrue();
let orientationItem = ['UNSPECIFIED','LOCKED','PORTRAIT_UNSPECIFIED','PORTRAIT','LANDSCAPE','PORTRAIT_INVERTED','LANDSCAPE_INVERTED','AUTO_ROTATION','AUTO_ROTATION_PORTRAIT','AUTO_ROTATION_LANDSCAPE','AUTO_ROTATION_RESTRICTED','AUTO_ROTATION_PORTRAIT_RESTRICTED','AUTO_ROTATION_LANDSCAPE_RESTRICTED'];
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED', 'LANDSCAPE_INVERTED', 'AUTO_ROTATION', 'AUTO_ROTATION_PORTRAIT', 'AUTO_ROTATION_LANDSCAPE', 'AUTO_ROTATION_RESTRICTED', 'AUTO_ROTATION_PORTRAIT_RESTRICTED', 'AUTO_ROTATION_LANDSCAPE_RESTRICTED', 'LOCKED'];
for (let i = 0;i < orientationItem.length; i++) {
await sleep(1000);
let orientation=ohosWindow.Orientation[orientationItem[i]]
await mainWin.setPreferredOrientation(orientation,(err,data) => {
if(err.code){
let orientation = ohosWindow.Orientation[orientationItem[i]]
await mainWin.setPreferredOrientation(orientation, (err, data) => {
if (err.code) {
console.log(msgStr + 'window.setPreferredOrientation failed set error' + orientation);
}
console.log(msgStr + 'success set window.setPreferredOrientation ' + orientation+JSON.stringify(data));
console.log(msgStr + 'success set window.setPreferredOrientation ' + orientation + JSON.stringify(data));
})
}
console.log(msgStr + 'done ');
......@@ -1510,19 +1517,19 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
});
console.log(msgStr + 'windowStage.getMainWindow' + JSON.stringify(mainWin));
expect(!!mainWin).assertTrue();
await mainWin.setForbidSplitMove(true,(err,data) => {
if(err.code){
await mainWin.setForbidSplitMove(true, (err, data) => {
if (err.code) {
console.log(msgStr + 'failed set window.setForbidSplitMove drag is prohibited');
return;
}
console.log(msgStr + 'success set window.setForbidSplitMove drag is prohibited'+JSON.stringify(data));
console.log(msgStr + 'success set window.setForbidSplitMove drag is prohibited' + JSON.stringify(data));
})
await mainWin.setForbidSplitMove(false,(err,data) => {
if(err.code){
await mainWin.setForbidSplitMove(false, (err, data) => {
if (err.code) {
console.log(msgStr + 'failed set window.setForbidSplitMove you can drag it now');
return;
}
console.log(msgStr + 'success set window.setForbidSplitMove you can drag it now'+JSON.stringify(data));
console.log(msgStr + 'success set window.setForbidSplitMove you can drag it now' + JSON.stringify(data));
})
console.log(msgStr + 'done ');
done();
......@@ -1646,8 +1653,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
dpClass.getCutoutInfo((err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'displayClass.getCutoutInfo', done);
}else{
console.info(msgStr+'Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
} else {
console.info(msgStr + 'Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
done();
}
})
......@@ -1667,13 +1674,13 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
} else {
let tempWnd=data;
let tempWnd = data;
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue();
tempWnd.showWithAnimation((error, animationData) => {
if (error && error.code) {
unexpectedError(error, caseName, 'Failed to show the window with animation', done);
}else {
} else {
console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(animationData));
done();
}
......@@ -1700,11 +1707,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
ohosWindow.find(wndId, (findErr, findWnd) => {
if (findErr && findErr.code) {
unexpectedError(findErr, caseName, 'Failed to hide the window with animation', done);
}else {
} else {
findWnd.hideWithAnimation((err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'Failed to hide the window with animation', done);
}else {
} else {
console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data));
done();
}
......
......@@ -46,7 +46,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
'TYPE_VOLUME_OVERLAY': 6,
'TYPE_NAVIGATION_BAR': 7,
'TYPE_FLOAT': 8,
'TYPE_FLOAT_CAMERA':9
'TYPE_FLOAT_CAMERA': 9
}
var windowLayoutModeArr = [];
var windowLayoutModeDic = {
......@@ -1153,11 +1153,17 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'loadContentTest4';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let load4 = await windowStage.loadContent(null).catch((err) => {
expectedError(err, caseName, 'tempWnd.loadContent', done, 1003);
console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load4));
try {
let load4 = await windowStage.loadContent(null).catch((err) => {
expect(false).assertTrue();
console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load4));
}
catch (err) {
console.log(msgStr + 'tempWnd.loadContent catch err=' + JSON.stringify(err));
expectedError(err.code, caseName, 'tempWnd.loadContent', done, 401);
}
done();
})
/**
......@@ -1169,11 +1175,17 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'loadContentTest5';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let load5 = await windowStage.loadContent(null, abilityStorage).catch((err) => {
expectedError(err, caseName, 'tempWnd.loadContent', done, 1003);
console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load5));
try {
let load5 = await windowStage.loadContent(null, abilityStorage).catch((err) => {
expect(false).assertTrue();
console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load5));
}
catch (err) {
console.log(msgStr + 'tempWnd.loadContent catch err=' + JSON.stringify(err));
expectedError(err.code, caseName, 'tempWnd.loadContent', done, 401);
}
done();
})
/**
......@@ -1219,12 +1231,18 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'createSubWindowTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let subWindow = await windowStage.createSubWindow(null).catch((err) => {
expectedError(err, caseName, 'windowStage.createSubWindow', done, 1003);
console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
});
console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
try {
let subWindow = await windowStage.createSubWindow(null).catch((err) => {
expect(false).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
});
console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
}
catch (err) {
expectedError(err.code, caseName, 'windowStage.createSubWindow', done, 401);
console.log(msgStr + 'windowStage.createSubWindow catch err=' + JSON.stringify(err));
}
done();
})
/**
* @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_001
......@@ -1337,7 +1355,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay current device' + JSON.stringify(currentDeviceDefault));
let currentDeviceDefaultDpi = parseInt(currentDeviceDefault.densityDPI)
let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300,currentDeviceDefaultDpi];
let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300, currentDeviceDefaultDpi];
for (let i = 0;i < dpiItem.length; i++) {
await sleep(1000);
await screens[0].setDensityDpi(dpiItem[i]).then(async () => {
......@@ -1368,16 +1386,18 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let mainWin = await windowStage.getMainWindow().catch(err => {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
});
console.log(msgStr + 'windowStage.getMainWindow' + JSON.stringify(mainWin));
console.log(msgStr + 'windowStage.getMainWindow :' + JSON.stringify(mainWin));
expect(!!mainWin).assertTrue();
let orientationItem = ['UNSPECIFIED', 'LOCKED', 'PORTRAIT_UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED', 'LANDSCAPE_INVERTED', 'AUTO_ROTATION', 'AUTO_ROTATION_PORTRAIT', 'AUTO_ROTATION_LANDSCAPE', 'AUTO_ROTATION_RESTRICTED', 'AUTO_ROTATION_PORTRAIT_RESTRICTED', 'AUTO_ROTATION_LANDSCAPE_RESTRICTED'];
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED', 'LANDSCAPE_INVERTED', 'AUTO_ROTATION', 'AUTO_ROTATION_PORTRAIT', 'AUTO_ROTATION_LANDSCAPE', 'AUTO_ROTATION_RESTRICTED', 'AUTO_ROTATION_PORTRAIT_RESTRICTED', 'AUTO_ROTATION_LANDSCAPE_RESTRICTED', 'LOCKED'];
for (let i = 0;i < orientationItem.length; i++) {
await sleep(1000);
let orientation = ohosWindow.Orientation[orientationItem[i]]
console.log(msgStr + 'i : ' + i + ' ,orientation : ' + orientation);
console.log(msgStr + 'i : ' + i + ' ,ohosWindow.Orientation : ' + JSON.stringify(ohosWindow.Orientation));
await mainWin.setPreferredOrientation(orientation).then(() => {
console.log(msgStr + 'success set window.setPreferredOrientation ' + orientation);
console.log(msgStr + 'success set window.setPreferredOrientation : ' + orientation);
}).catch(err => {
console.log(msgStr + 'window.setPreferredOrientation failed set error' + orientation);
console.log(msgStr + 'window.setPreferredOrientation failed set error:' + orientation);
});
}
console.log(msgStr + 'done ');
......@@ -1441,9 +1461,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context));
let tempType = ohosWindow.WindowType.TYPE_DIALOG
let dialogTargetTouchTest1Win = await ohosWindow.create(context, 'dialogTargetTouchTest1', tempType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
})
let dialogTargetTouchTest1Win = await ohosWindow.create(context, 'dialogTargetTouchTest1', tempType)
.catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
})
expect(!!dialogTargetTouchTest1Win).assertTrue();
dialogTargetTouchTest1Win.destroy();
done();
......@@ -1460,7 +1481,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin ohosWindow==' + JSON.stringify(ohosWindow));
let wndId = 'animationForShownTest1';
let baseType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let tempWnd = await ohosWindow.create(context,wndId, baseType).catch((err) => {
let tempWnd = await ohosWindow.create(context, wndId, baseType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd);
......@@ -1503,7 +1524,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
dpClass.getCutoutInfo().then((data) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
done();
}).catch(err=>{
}).catch(err => {
unexpectedError(err, caseName, 'displayClass.getCutoutInfo', done);
});
})
......@@ -1518,16 +1539,16 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin context==' + JSON.stringify(context));
let wndId = 'showWithAnimationTest1';
let baseType = ohosWindow.WindowType.TYPE_FLOAT;
let tempWnd = await ohosWindow.create(context,wndId, baseType).catch((err) => {
let tempWnd = await ohosWindow.create(context, wndId, baseType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue();
console.info('showWithAnimationTest1 ****' + Reflect.has(tempWnd,'showWithAnimation'))
await tempWnd.showWithAnimation().then((data)=> {
console.info('showWithAnimationTest1 ****' + Reflect.has(tempWnd, 'showWithAnimation'))
await tempWnd.showWithAnimation().then((data) => {
console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
done();
}).catch((err)=>{
}).catch((err) => {
unexpectedError(err, caseName, 'Failed to show the window with animation', done);
})
})
......@@ -1542,7 +1563,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin context==' + JSON.stringify(context));
let wndId = 'hideWithAnimationTest1';
let baseType = ohosWindow.WindowType.TYPE_FLOAT;
let tempWnd = await ohosWindow.create(context,wndId, baseType).catch((err) => {
let tempWnd = await ohosWindow.create(context, wndId, baseType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd));
......@@ -1552,13 +1573,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
console.log(msgStr + 'find findWnd: ' + JSON.stringify(findWnd));
expect(!!findWnd).assertTrue();
console.info('hideWithAnimationTest1 ****' + Reflect.has(findWnd,'hideWithAnimation'))
console.info('hideWithAnimationTest1 ****' + Reflect.has(findWnd,'destroy'))
console.info('hideWithAnimationTest1 ****' + Reflect.has(findWnd, 'hideWithAnimation'))
console.info('hideWithAnimationTest1 ****' + Reflect.has(findWnd, 'destroy'))
let promise = findWnd.hideWithAnimation();
promise.then((data)=> {
promise.then((data) => {
console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data));
done();
}).catch((err)=>{
}).catch((err) => {
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
})
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册