提交 a952eed7 编写于 作者: 华华小仙女

添加try catch

Signed-off-by: N华华小仙女 <zhurong18@h-partners.com>
上级 a40bbd31
...@@ -42,7 +42,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -42,7 +42,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
'TYPE_VOLUME_OVERLAY': 6, 'TYPE_VOLUME_OVERLAY': 6,
'TYPE_NAVIGATION_BAR': 7, 'TYPE_NAVIGATION_BAR': 7,
'TYPE_FLOAT': 8, 'TYPE_FLOAT': 8,
// 'TYPE_FLOAT_CAMERA': 9 // 'TYPE_FLOAT_CAMERA': 9
} }
var windowLayoutModeArr = []; var windowLayoutModeArr = [];
var windowLayoutModeDic = { var windowLayoutModeDic = {
...@@ -104,7 +104,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -104,7 +104,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
function unexpectedError(error, caseName, apiName, done) { function unexpectedError(error, caseName, apiName, done) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: '; let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error)); console.log(msgStr + JSON.stringify(error));
expect(TRUE_FLAG).assertFail(); try {
expect(TRUE_FLAG).assertFail();
} catch (error) {
console.info(`unexpectedError catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
...@@ -125,7 +130,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -125,7 +130,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
display.getAllDisplays().then((data) => { display.getAllDisplays().then((data) => {
console.info(msgStr+'Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
expect(data[0].id != null).assertTrue(); expect(data[0].id != null).assertTrue();
expect(data[0].refreshRate != null).assertTrue(); expect(data[0].refreshRate != null).assertTrue();
expect(data[0].width != null).assertTrue(); expect(data[0].width != null).assertTrue();
...@@ -136,12 +141,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -136,12 +141,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
expect(data[0].alive).assertTrue(); expect(data[0].alive).assertTrue();
expect(data[0].state != null).assertTrue(); expect(data[0].state != null).assertTrue();
expect(data[0].densityPixels != null).assertTrue(); expect(data[0].densityPixels != null).assertTrue();
expect(data[0].scaledDensity !=null).assertTrue(); expect(data[0].scaledDensity != null).assertTrue();
expect(data[0].xDPI != null).assertTrue(); expect(data[0].xDPI != null).assertTrue();
expect(data[0].yDPI != null).assertTrue(); expect(data[0].yDPI != null).assertTrue();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(msgStr+'Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
...@@ -157,12 +162,16 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -157,12 +162,16 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
display.getAllDisplays((err, data) => { display.getAllDisplays((err, data) => {
if (err.code) { if (err.code) {
console.error(msgStr+'Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`display.getAllDisplays catch error: ${JSON.stringify(error)}`)
}
done(); done();
return; return;
} }
console.info(msgStr+'Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
expect(data[0].refreshRate != null).assertTrue(); expect(data[0].refreshRate != null).assertTrue();
expect(data[0].width != null).assertTrue(); expect(data[0].width != null).assertTrue();
expect(data[0].height != null).assertTrue(); expect(data[0].height != null).assertTrue();
...@@ -172,7 +181,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -172,7 +181,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
expect(data[0].alive).assertTrue(); expect(data[0].alive).assertTrue();
expect(data[0].state != null).assertTrue(); expect(data[0].state != null).assertTrue();
expect(data[0].densityPixels != null).assertTrue(); expect(data[0].densityPixels != null).assertTrue();
expect(data[0].scaledDensity !=null).assertTrue(); expect(data[0].scaledDensity != null).assertTrue();
expect(data[0].xDPI != null).assertTrue(); expect(data[0].xDPI != null).assertTrue();
expect(data[0].yDPI != null).assertTrue(); expect(data[0].yDPI != null).assertTrue();
done(); done();
...@@ -190,14 +199,20 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -190,14 +199,20 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let loopCount = systemWindowTypeDicArr.length; let loopCount = systemWindowTypeDicArr.length;
console.log(msgStr + 'loopCount: ' + loopCount); console.log(msgStr + 'loopCount: ' + loopCount);
let num =0 let num = 0
for (let i = 0; i < loopCount; i++) { for (let i = 0; i < loopCount; i++) {
sleep(500) sleep(500)
let tempType = Number(ohosWindow.WindowType[systemWindowTypeDicArr[i]]) let tempType = Number(ohosWindow.WindowType[systemWindowTypeDicArr[i]])
let windId = 'createWindowTest1' + i; let windId = 'createWindowTest1' + i;
console.log(msgStr + 'ohosWindow.createWindow: ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.createWindow: ' + tempType + ' start');
let windowConfig = {name: windId, windowType: tempType, ctx: context, displayId: 0, parentId: 0}; let windowConfig = {
try{ name: windId,
windowType: tempType,
ctx: context,
displayId: 0,
parentId: 0
};
try {
let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => {
console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'catched, err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'catched, err: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
...@@ -205,10 +220,11 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -205,10 +220,11 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'finished, wnd: ' + JSON.stringify(tempWnd)); console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'finished, wnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
num++; num++;
if(num==loopCount) done(); if (num == loopCount) done();
} catch (exception) { } catch (exception) {
console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
} }
}) })
...@@ -222,14 +238,16 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -222,14 +238,16 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowId = 'createWindowSameidsTest2' let windowId = 'createWindowSameidsTest2'
let windowConfig = {name: windowId, windowType: 1, ctx: context}; let windowConfig = {
try{ name: windowId, windowType: 1, ctx: context
};
try {
let ohosData = await ohosWindow.createWindow(windowConfig).catch((err) => { let ohosData = await ohosWindow.createWindow(windowConfig).catch((err) => {
console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
}) })
expect(!!ohosData).assertTrue(); expect(!!ohosData).assertTrue();
try{ try {
let ohosDataError = await ohosWindow.createWindow(windowConfig).catch((errSencond) => { let ohosDataError = await ohosWindow.createWindow(windowConfig).catch((errSencond) => {
console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(errSencond)); console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(errSencond));
expect(errSencond.code).assertEqual(1300002) expect(errSencond.code).assertEqual(1300002)
...@@ -237,11 +255,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -237,11 +255,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
}) })
console.log(msgStr + 'ohosWindow.createWindow 1 twice ohosDataError: ' + JSON.stringify(ohosDataError)); console.log(msgStr + 'ohosWindow.createWindow 1 twice ohosDataError: ' + JSON.stringify(ohosDataError));
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
...@@ -258,17 +278,25 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -258,17 +278,25 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let windId = 'createWindowTest4_0'; let windId = 'createWindowTest4_0';
let windIdTwo = 'createWindowTest4_1'; let windIdTwo = 'createWindowTest4_1';
console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start');
let windowConfig = {name: windId, windowType: tempType, ctx: context}; let windowConfig = {
let windowConfigTwo = {name: windIdTwo, windowType: tempType, ctx: context}; name: windId, windowType: tempType, ctx: context
try{ };
let windowConfigTwo = {
name: windIdTwo, windowType: tempType, ctx: context
};
try {
ohosWindow.createWindow(windowConfig, (err, data) => { ohosWindow.createWindow(windowConfig, (err, data) => {
if (err && err.code) { if (err && err.code) {
console.log(msgStr + 'ohosWindow.createWindow err.code==' + JSON.stringify(err.code)) console.log(msgStr + 'ohosWindow.createWindow err.code==' + JSON.stringify(err.code))
return; return;
} }
console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
expect(!!data).assertTrue(); try {
try{ expect(!!data).assertTrue();
} catch (error) {
console.info(`ohosWindow.crreateWindow catch error: ${JSON.stringify(error)}`)
}
try {
ohosWindow.createWindow(windowConfigTwo, (err, dataTwo) => { ohosWindow.createWindow(windowConfigTwo, (err, dataTwo) => {
console.log(msgStr + 'ohosWindow.createWindow two twice' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.createWindow two twice' + JSON.stringify(err));
if (err && err.code) { if (err && err.code) {
...@@ -279,13 +307,15 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -279,13 +307,15 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
done(); done();
} }
}) })
}catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_005 * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_005
...@@ -301,14 +331,20 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -301,14 +331,20 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let windId = 'createWindowTest5'; let windId = 'createWindowTest5';
console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start');
let windowConfig = {name: windId, windowType: tempType, ctx: context}; let windowConfig = {
try{ name: windId, windowType: tempType, ctx: context
};
try {
ohosWindow.createWindow(windowConfig, (err, data) => { ohosWindow.createWindow(windowConfig, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done);
return; return;
} }
expect(!!data).assertTrue(); try {
expect(!!data).assertTrue();
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
let tempWnd = data let tempWnd = data
console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' wnd: ' + tempWnd);
try { try {
...@@ -317,12 +353,14 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -317,12 +353,14 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
expect(proData.type == tempType).assertTrue(); expect(proData.type == tempType).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_006 * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_006
...@@ -334,35 +372,47 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -334,35 +372,47 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowId = 'createWindowSameidTest6' let windowId = 'createWindowSameidTest6'
let winsowConfig = {name: windowId, windowType:1, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: 1, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (err, data) => { ohosWindow.createWindow(winsowConfig, (err, data) => {
console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err));
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
return return
} }
expect(!!data).assertTrue(); try {
try{ expect(!!data).assertTrue();
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
try {
ohosWindow.createWindow(winsowConfig, (err, dataTwo) => { ohosWindow.createWindow(winsowConfig, (err, dataTwo) => {
console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(err));
if (err && err.code) { if (err && err.code) {
console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo)); console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo));
expect(err.code).assertEqual(1300002) try {
expect(err.code).assertEqual(1300002)
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo)); console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo));
} }
}) })
}catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
...@@ -373,7 +423,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -373,7 +423,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('getWindowAvoidAreaTest1', 0, async function (done) { it('getWindowAvoidAreaTest1', 0, async function (done) {
let caseName = 'getWindowAvoidAreaTest1'; let caseName = 'getWindowAvoidAreaTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
try{ try {
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
try { try {
...@@ -387,13 +437,15 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -387,13 +437,15 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
expect(avoidArea.leftRect != null).assertTrue(); expect(avoidArea.leftRect != null).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the area. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the area. Cause:' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
...@@ -404,7 +456,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -404,7 +456,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('getWindowAvoidAreaTest2', 0, async function (done) { it('getWindowAvoidAreaTest2', 0, async function (done) {
let caseName = 'getWindowAvoidAreaTest2'; let caseName = 'getWindowAvoidAreaTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
try{ try {
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(tempWnd != null).assertTrue(); expect(tempWnd != null).assertTrue();
try { try {
...@@ -418,14 +470,16 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -418,14 +470,16 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
expect(avoidArea.leftRect != null).assertTrue(); expect(avoidArea.leftRect != null).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the area. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the area. Cause:' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_003 * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_003
...@@ -435,7 +489,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -435,7 +489,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('getWindowAvoidAreaTest3', 0, async function (done) { it('getWindowAvoidAreaTest3', 0, async function (done) {
let caseName = 'getWindowAvoidAreaTest3'; let caseName = 'getWindowAvoidAreaTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
try{ try {
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
try { try {
...@@ -449,13 +503,15 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -449,13 +503,15 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
expect(avoidArea.leftRect != null).assertTrue(); expect(avoidArea.leftRect != null).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the area. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the area. Cause:' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_004 * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_004
...@@ -465,7 +521,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -465,7 +521,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('getWindowAvoidAreaTest4', 0, async function (done) { it('getWindowAvoidAreaTest4', 0, async function (done) {
let caseName = 'getWindowAvoidAreaTest4'; let caseName = 'getWindowAvoidAreaTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
try{ try {
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
try { try {
...@@ -479,13 +535,15 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -479,13 +535,15 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
expect(avoidArea.leftRect != null).assertTrue(); expect(avoidArea.leftRect != null).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the area. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the area. Cause:' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_GETWINDOWPROPERTIES_JSAPI_001 * @tc.number SUB_WINDOW_GETWINDOWPROPERTIES_JSAPI_001
...@@ -495,34 +553,36 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -495,34 +553,36 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('getWindowPropertiesTest1', 0, async function (done) { it('getWindowPropertiesTest1', 0, async function (done) {
let caseName = 'getWindowPropertiesTest1'; let caseName = 'getWindowPropertiesTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
try{ try {
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
try { try {
let data = tempWnd.getWindowProperties(); let data = tempWnd.getWindowProperties();
console.log(msgStr + 'ohosWindow.getWindowProperties ' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.getWindowProperties ' + JSON.stringify(data));
expect(data.type != null).assertTrue(); expect(data.type != null).assertTrue();
expect(data.windowRect.height != null).assertTrue(); expect(data.windowRect.height != null).assertTrue();
expect(data.windowRect.left != null).assertTrue(); expect(data.windowRect.left != null).assertTrue();
expect(data.windowRect.top != null).assertTrue(); expect(data.windowRect.top != null).assertTrue();
expect(data.windowRect.width != null).assertTrue(); expect(data.windowRect.width != null).assertTrue();
expect(data.isFullScreen!= null).assertTrue(); expect(data.isFullScreen != null).assertTrue();
expect(data.isLayoutFullScreen!= null).assertTrue(); expect(data.isLayoutFullScreen != null).assertTrue();
expect(data.focusable!= null).assertTrue(); expect(data.focusable != null).assertTrue();
expect(data.touchable!= null).assertTrue(); expect(data.touchable != null).assertTrue();
expect(data.isKeepScreenOn!= null).assertTrue(); expect(data.isKeepScreenOn != null).assertTrue();
expect(data.isTransparent != null).assertTrue(); expect(data.isTransparent != null).assertTrue();
expect(data.brightness != null).assertTrue(); expect(data.brightness != null).assertTrue();
expect(data.dimBehindValue).assertEqual(0); expect(data.dimBehindValue).assertEqual(0);
expect(data.isRoundCorner!= null).assertTrue(); expect(data.isRoundCorner != null).assertTrue();
expect(data.isPrivacyMode != null).assertTrue(); expect(data.isPrivacyMode != null).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the main window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_001 * @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_001
...@@ -533,17 +593,18 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -533,17 +593,18 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let caseName = 'getLastWindowTest1'; let caseName = 'getLastWindowTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let proData=null let proData = null
try{ try {
let lastWindow = await ohosWindow.getLastWindow(context).catch((err)=>{ let lastWindow = await ohosWindow.getLastWindow(context).catch((err) => {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done);
}) })
expect(lastWindow != null).assertTrue(); expect(lastWindow != null).assertTrue();
done(); done();
}catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_002 * @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_002
...@@ -566,7 +627,8 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -566,7 +627,8 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_001 * @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_001
...@@ -579,24 +641,27 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -579,24 +641,27 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let baseWndType = 1; let baseWndType = 1;
let windowId = 'showWindowTest1'; let windowId = 'showWindowTest1';
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
let tempWnd =null; name: windowId, windowType: baseWndType, ctx: context
try{ };
let tempWnd = null;
try {
tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
}); });
console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + JSON.stringify(tempWnd)); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
tempWnd.showWindow().then((data)=> { tempWnd.showWindow().then((data) => {
console.info(msgStr +'Succeeded in showing the window. Data: ' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data));
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to show the window. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to show the window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.showWindow', done); unexpectedError(err, caseName, 'ohosWindow.showWindow', done);
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_002 * @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_002
...@@ -609,28 +674,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -609,28 +674,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let baseWndType = 1; let baseWndType = 1;
let windowId = 'showWindowTest2'; let windowId = 'showWindowTest2';
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: baseWndType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { ohosWindow.createWindow(winsowConfig, (create_err, create_data) => {
console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data));
if (create_err && create_err.code) { if (create_err && create_err.code) {
unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done);
return; return;
} }
expect(!!create_data).assertTrue(); try {
expect(!!create_data).assertTrue();
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
create_data.showWindow((err, data) => { create_data.showWindow((err, data) => {
if (err.code) { if (err.code) {
console.error(msgStr +'Failed to show the window. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to show the window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
return; return;
} }
console.info(msgStr +'Succeeded in showing the window. Data: ' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data));
done(); done();
}) })
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_001 * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_001
...@@ -643,28 +715,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -643,28 +715,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'moveWindowToTest1'; let windowId = 'moveWindowToTest1';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
name: windowId, windowType: baseWndType, ctx: context
};
try { try {
ohosWindow.createWindow(windowConfig).then((wnd)=> { ohosWindow.createWindow(windowConfig).then((wnd) => {
console.info(msgStr +'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd));
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.moveWindowTo(300, 300).then(()=> { wnd.moveWindowTo(300, 300).then(() => {
console.info(msgStr +'Succeeded in moving the window.'); console.info(msgStr + 'Succeeded in moving the window.');
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to move the window. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to move the window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done);
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
}).catch((err)=>{ ;
console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); }).catch((err) => {
console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_002 * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_002
...@@ -677,28 +753,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -677,28 +753,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'moveWindowToTest2'; let windowId = 'moveWindowToTest2';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
name: windowId, windowType: baseWndType, ctx: context
};
try { try {
ohosWindow.createWindow(windowConfig).then((wnd)=> { ohosWindow.createWindow(windowConfig).then((wnd) => {
console.info(msgStr +'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd));
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.moveWindowTo(100, 50).then(()=> { wnd.moveWindowTo(100, 50).then(() => {
console.info(msgStr +'Succeeded in moving the window.'); console.info(msgStr + 'Succeeded in moving the window.');
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to move the window. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to move the window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done);
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
}).catch((err)=>{ ;
console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); }).catch((err) => {
console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_003 * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_003
...@@ -711,28 +791,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -711,28 +791,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'moveWindowToTest3'; let windowId = 'moveWindowToTest3';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
name: windowId, windowType: baseWndType, ctx: context
};
try { try {
ohosWindow.createWindow(windowConfig).then((wnd)=> { ohosWindow.createWindow(windowConfig).then((wnd) => {
console.info(msgStr +'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd));
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.moveWindowTo(20000, 20000).then(()=> { wnd.moveWindowTo(20000, 20000).then(() => {
console.info(msgStr +'Succeeded in moving the window.'); console.info(msgStr + 'Succeeded in moving the window.');
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to move the window. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to move the window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done);
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
}).catch((err)=>{ ;
console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); }).catch((err) => {
console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_004 * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_004
...@@ -745,28 +829,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -745,28 +829,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'moveWindowToTest4'; let windowId = 'moveWindowToTest4';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
name: windowId, windowType: baseWndType, ctx: context
};
try { try {
ohosWindow.createWindow(windowConfig).then((wnd)=> { ohosWindow.createWindow(windowConfig).then((wnd) => {
console.info(msgStr +'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd));
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.moveWindowTo(-200, -200).then(()=> { wnd.moveWindowTo(-200, -200).then(() => {
console.info(msgStr +'Succeeded in moving the window.'); console.info(msgStr + 'Succeeded in moving the window.');
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to move the window. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to move the window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done);
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
}).catch((err)=>{ ;
console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); }).catch((err) => {
console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_005 * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_005
...@@ -779,31 +867,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -779,31 +867,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let baseWndType = 1; let baseWndType = 1;
let windowId = 'moveWindowToTest5'; let windowId = 'moveWindowToTest5';
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: baseWndType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { ohosWindow.createWindow(winsowConfig, (create_err, create_data) => {
console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data));
if (create_err && create_err.code) { if (create_err && create_err.code) {
unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done);
return; return;
} }
try{ try {
create_data.moveWindowTo(300, 300, (err, data) => { create_data.moveWindowTo(300, 300, (err, data) => {
if (err.code) { if (err.code) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done);
return; return;
} }
console.info(msgStr +'Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data));
done(); done();
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
;
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_006 * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_006
...@@ -816,31 +908,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -816,31 +908,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let baseWndType = 1; let baseWndType = 1;
let windowId = 'moveWindowToTest6'; let windowId = 'moveWindowToTest6';
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: baseWndType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { ohosWindow.createWindow(winsowConfig, (create_err, create_data) => {
console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data));
if (create_err && create_err.code) { if (create_err && create_err.code) {
unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done);
return; return;
} }
try{ try {
create_data.moveWindowTo(100, 50, (err, data) => { create_data.moveWindowTo(100, 50, (err, data) => {
if (err.code) { if (err.code) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done);
return; return;
} }
console.info(msgStr +'Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data));
done(); done();
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
;
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_007 * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_007
...@@ -853,31 +949,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -853,31 +949,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let baseWndType = 1; let baseWndType = 1;
let windowId = 'moveWindowToTest7'; let windowId = 'moveWindowToTest7';
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: baseWndType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { ohosWindow.createWindow(winsowConfig, (create_err, create_data) => {
console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data));
if (create_err && create_err.code) { if (create_err && create_err.code) {
unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done);
return; return;
} }
try{ try {
create_data.moveWindowTo(20000, 20000, (err, data) => { create_data.moveWindowTo(20000, 20000, (err, data) => {
if (err.code) { if (err.code) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done);
return; return;
} }
console.info(msgStr +'Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data));
done(); done();
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
;
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_008 * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_008
...@@ -890,31 +990,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -890,31 +990,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let baseWndType = 1; let baseWndType = 1;
let windowId = 'moveWindowToTest8'; let windowId = 'moveWindowToTest8';
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: baseWndType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { ohosWindow.createWindow(winsowConfig, (create_err, create_data) => {
console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data));
if (create_err && create_err.code) { if (create_err && create_err.code) {
unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done);
return; return;
} }
try{ try {
create_data.moveWindowTo(-200, -200, (err, data) => { create_data.moveWindowTo(-200, -200, (err, data) => {
if (err.code) { if (err.code) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done);
return; return;
} }
console.info(msgStr +'Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data));
done(); done();
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
;
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_RESIZE_JSAPI_001 * @tc.number SUB_WINDOW_RESIZE_JSAPI_001
...@@ -927,28 +1031,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -927,28 +1031,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'resizeTest1'; let windowId = 'resizeTest1';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
let tempWnd=null; name: windowId, windowType: baseWndType, ctx: context
try{ };
let tempWnd = null;
try {
tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
}); });
console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
try{ try {
tempWnd.resize(200, 600).then((data)=> { tempWnd.resize(200, 600).then((data) => {
console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data));
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.resize', done); unexpectedError(err, caseName, 'tempWnd.resize', done);
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_RESIZE_JSAPI_002 * @tc.number SUB_WINDOW_RESIZE_JSAPI_002
...@@ -961,28 +1069,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -961,28 +1069,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'resizeTest2'; let windowId = 'resizeTest2';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
let tempWnd=null; name: windowId, windowType: baseWndType, ctx: context
try{ };
let tempWnd = null;
try {
tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
}); });
console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
try{ try {
tempWnd.resize(20000, 20000).then((data)=> { tempWnd.resize(20000, 20000).then((data) => {
console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data));
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.resize', done); unexpectedError(err, caseName, 'tempWnd.resize', done);
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_RESIZE_JSAPI_003 * @tc.number SUB_WINDOW_RESIZE_JSAPI_003
...@@ -995,31 +1107,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -995,31 +1107,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'resizeTest3'; let windowId = 'resizeTest3';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
let tempWnd=null; name: windowId, windowType: baseWndType, ctx: context
try{ };
let tempWnd = null;
try {
tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
}); });
console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
try{ try {
tempWnd.resize(0, 0).then((data)=> { tempWnd.resize(0, 0).then((data) => {
console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data));
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
done(); done();
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_RESIZE_JSAPI_004 * @tc.number SUB_WINDOW_RESIZE_JSAPI_004
...@@ -1032,31 +1148,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1032,31 +1148,35 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'resizeTest4'; let windowId = 'resizeTest4';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
let tempWnd=null; name: windowId, windowType: baseWndType, ctx: context
try{ };
let tempWnd = null;
try {
tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
}); });
console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
try{ try {
tempWnd.resize(-1, -1).then((data)=> { tempWnd.resize(-1, -1).then((data) => {
console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data));
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
done(); done();
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_RESIZE_JSAPI_005 * @tc.number SUB_WINDOW_RESIZE_JSAPI_005
...@@ -1069,32 +1189,36 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1069,32 +1189,36 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'resizeTest5'; let windowId = 'resizeTest5';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
let tempWnd=null; name: windowId, windowType: baseWndType, ctx: context
try{ };
let tempWnd = null;
try {
tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
}); });
console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
for (var i = 1; i <= 5; i++) { for (var i = 1; i <= 5; i++) {
try{ try {
tempWnd.resize(100, 100).then((data)=> { tempWnd.resize(100, 100).then((data) => {
console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data));
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(6); expect(err.code).assertEqual(6);
done(); done();
tempWnd.detroyWindow(); tempWnd.detroyWindow();
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception));
}; }
;
} }
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_RESIZE_JSAPI_006 * @tc.number SUB_WINDOW_RESIZE_JSAPI_006
...@@ -1107,8 +1231,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1107,8 +1231,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let baseWndType = 1; let baseWndType = 1;
let windowId = 'resizeTest6'; let windowId = 'resizeTest6';
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: baseWndType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { ohosWindow.createWindow(winsowConfig, (create_err, create_data) => {
console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data));
if (create_err && create_err.code) { if (create_err && create_err.code) {
...@@ -1118,20 +1244,22 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1118,20 +1244,22 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
try { try {
create_data.resize(200, 200, (err) => { create_data.resize(200, 200, (err) => {
if (err.code) { if (err.code) {
console.error(msgStr +'Failed to change the window size. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.resize', done); unexpectedError(err, caseName, 'ohosWindow.resize', done);
return; return;
} }
console.info(msgStr +'Succeeded in changing the window size.'); console.info(msgStr + 'Succeeded in changing the window size.');
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to change the window size. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(exception));
}; }
;
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_RESIZE_JSAPI_007 * @tc.number SUB_WINDOW_RESIZE_JSAPI_007
...@@ -1146,8 +1274,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1146,8 +1274,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let windowId = 'resizeTest7'; let windowId = 'resizeTest7';
let width = 100; let width = 100;
let height = 100; let height = 100;
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: baseWndType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { ohosWindow.createWindow(winsowConfig, (create_err, create_data) => {
console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data));
if (create_err && create_err.code) { if (create_err && create_err.code) {
...@@ -1160,22 +1290,24 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1160,22 +1290,24 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
try { try {
create_data.resize(width, height, (err) => { create_data.resize(width, height, (err) => {
if (err.code) { if (err.code) {
console.error(msgStr +'Failed to change the window size. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.resize', done); unexpectedError(err, caseName, 'ohosWindow.resize', done);
return; return;
} }
console.info(msgStr +'Succeeded in changing the window size.'); console.info(msgStr + 'Succeeded in changing the window size.');
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to change the window size. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(exception));
}; }
;
} }
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_001 * @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_001
...@@ -1188,32 +1320,36 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1188,32 +1320,36 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; let baseWndType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let windowId = 'destroyWindowTest1'; let windowId = 'destroyWindowTest1';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; let windowConfig = {
let tempWnd=null; name: windowId, windowType: baseWndType, ctx: context
try{ };
let tempWnd = null;
try {
tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.createWindow', done); unexpectedError(err, caseName, 'ohosWindow.createWindow', done);
}); });
console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + JSON.stringify(tempWnd)); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
tempWnd.destroyWindow().then(()=> { tempWnd.destroyWindow().then(() => {
console.info(msgStr +'Succeeded in destroying the window.'); console.info(msgStr + 'Succeeded in destroying the window.');
try { try {
let findWnd = ohosWindow.findWindow(windowId) let findWnd = ohosWindow.findWindow(windowId)
expect(!findWnd).assertTrue(); expect(!findWnd).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception));
expect(exception.code === 1300002).assertTrue(); expect(exception.code === 1300002).assertTrue();
done(); done();
}; }
}).catch((err)=>{ ;
console.error(msgStr +'try catch Failed to destroy the window. Cause: ' + JSON.stringify(err)); }).catch((err) => {
console.error(msgStr + 'try catch Failed to destroy the window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.destroyWindow', done); unexpectedError(err, caseName, 'tempWnd.destroyWindow', done);
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_002 * @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_002
...@@ -1226,35 +1362,43 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1226,35 +1362,43 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'destroyWindowTest2'; let windowId = 'destroyWindowTest2';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
try{ name: windowId, windowType: baseWndType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { ohosWindow.createWindow(winsowConfig, (create_err, create_data) => {
console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data));
if (create_err && create_err.code) { if (create_err && create_err.code) {
unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done);
return; return;
} }
expect(!!create_data).assertTrue(); try {
expect(!!create_data).assertTrue();
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
create_data.destroyWindow((err) => { create_data.destroyWindow((err) => {
if (err.code != 0) { if (err.code != 0) {
console.log('windowTest DestroyTest2 create callback fail' + JSON.stringify(err)); console.log('windowTest DestroyTest2 create callback fail' + JSON.stringify(err));
unexpectedError(create_err, caseName, 'ohosWindow.destroyWindow', done); unexpectedError(create_err, caseName, 'ohosWindow.destroyWindow', done);
} else { } else {
try { try {
let findWnd = ohosWindow.findWindow(windowId) let findWnd = ohosWindow.findWindow(windowId)
expect(!findWnd).assertTrue(); expect(!findWnd).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception));
expect(exception.code === 1300002).assertTrue(); expect(exception.code === 1300002).assertTrue();
done(); done();
}; }
;
} }
}) })
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_001 * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_001
...@@ -1264,29 +1408,31 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1264,29 +1408,31 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('setWindowSystemBarEnableTest1', 0, async function (done) { it('setWindowSystemBarEnableTest1', 0, async function (done) {
let caseName = 'setWindowSystemBarEnableTest1'; let caseName = 'setWindowSystemBarEnableTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let wnd=null; let wnd = null;
try{ try {
wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ wnd = await ohosWindow.getLastWindow(context).catch((err) => {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done);
}) })
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.setWindowSystemBarEnable([]).then(()=> { wnd.setWindowSystemBarEnable([]).then(() => {
console.info(msgStr +'Succeeded in setting the system bar to be invisible.'); console.info(msgStr + 'Succeeded in setting the system bar to be invisible.');
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_002 * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_002
...@@ -1296,29 +1442,31 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1296,29 +1442,31 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('setWindowSystemBarEnableTest2', 0, async function (done) { it('setWindowSystemBarEnableTest2', 0, async function (done) {
let caseName = 'setWindowSystemBarEnableTest2'; let caseName = 'setWindowSystemBarEnableTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let wnd=null; let wnd = null;
try{ try {
wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ wnd = await ohosWindow.getLastWindow(context).catch((err) => {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done);
}) })
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.setWindowSystemBarEnable(['status', 'navigation']).then(()=> { wnd.setWindowSystemBarEnable(['status', 'navigation']).then(() => {
console.info(msgStr +'Succeeded in setting the system bar to be invisible.'); console.info(msgStr + 'Succeeded in setting the system bar to be invisible.');
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_003 * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_003
...@@ -1328,29 +1476,31 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1328,29 +1476,31 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('setWindowSystemBarEnableTest3', 0, async function (done) { it('setWindowSystemBarEnableTest3', 0, async function (done) {
let caseName = 'setWindowSystemBarEnableTest3'; let caseName = 'setWindowSystemBarEnableTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let wnd=null; let wnd = null;
try{ try {
wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ wnd = await ohosWindow.getLastWindow(context).catch((err) => {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done);
}) })
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.setWindowSystemBarEnable(['status']).then(()=> { wnd.setWindowSystemBarEnable(['status']).then(() => {
console.info(msgStr +'Succeeded in setting the system bar to be invisible.'); console.info(msgStr + 'Succeeded in setting the system bar to be invisible.');
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_004 * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_004
...@@ -1360,29 +1510,31 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1360,29 +1510,31 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('setWindowSystemBarEnableTest4', 0, async function (done) { it('setWindowSystemBarEnableTest4', 0, async function (done) {
let caseName = 'setWindowSystemBarEnableTest4'; let caseName = 'setWindowSystemBarEnableTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let wnd=null; let wnd = null;
try{ try {
wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ wnd = await ohosWindow.getLastWindow(context).catch((err) => {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done);
}) })
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.setWindowSystemBarEnable(['navigation']).then(()=> { wnd.setWindowSystemBarEnable(['navigation']).then(() => {
console.info(msgStr +'Succeeded in setting the system bar to be invisible.'); console.info(msgStr + 'Succeeded in setting the system bar to be invisible.');
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_005 * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_005
...@@ -1395,19 +1547,21 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1395,19 +1547,21 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'setWindowSystemBarEnableTest5'; let windowId = 'setWindowSystemBarEnableTest5';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
let wnd=null; name: windowId, windowType: baseWndType, ctx: context
};
let wnd = null;
try { try {
wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ wnd = await ohosWindow.getLastWindow(context).catch((err) => {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done);
}) })
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try{ try {
wnd.setWindowSystemBarEnable(['status', 'navigation'], (err) => { wnd.setWindowSystemBarEnable(['status', 'navigation'], (err) => {
console.log(msgStr +'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin'); console.log(msgStr + 'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin');
if (err.code != 0) { if (err.code != 0) {
console.log(msgStr +'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail' + JSON.stringify(err)); console.log(msgStr + 'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
} else { } else {
...@@ -1416,11 +1570,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1416,11 +1570,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
} }
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +' try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error(msgStr + ' try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to get the last window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to get the last window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_006 * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_006
...@@ -1433,19 +1589,21 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1433,19 +1589,21 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let baseWndType = 1; let baseWndType = 1;
let windowId = 'setWindowSystemBarEnableTest6'; let windowId = 'setWindowSystemBarEnableTest6';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; let winsowConfig = {
let wnd=null; name: windowId, windowType: baseWndType, ctx: context
};
let wnd = null;
try { try {
wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ wnd = await ohosWindow.getLastWindow(context).catch((err) => {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done);
}) })
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try{ try {
wnd.setWindowSystemBarEnable([], (err) => { wnd.setWindowSystemBarEnable([], (err) => {
console.log(msgStr +'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin'); console.log(msgStr + 'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin');
if (err.code != 0) { if (err.code != 0) {
console.log(msgStr +'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail' + JSON.stringify(err)); console.log(msgStr + 'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
} else { } else {
...@@ -1454,11 +1612,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1454,11 +1612,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
} }
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +' try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error(msgStr + ' try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to get the last window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to get the last window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_003 * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_003
...@@ -1472,10 +1632,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1472,10 +1632,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let tempType = 5000; let tempType = 5000;
let windId = 'nonExistWindowType'; let windId = 'nonExistWindowType';
console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start');
let windowConfig = {name: windId, windowType: tempType, ctx: context}; let windowConfig = {
let nonExistWnd=null; name: windId, windowType: tempType, ctx: context
try{ };
nonExistWnd = await ohosWindow.createWindow(windowConfig).then((data)=> { let nonExistWnd = null;
try {
nonExistWnd = await ohosWindow.createWindow(windowConfig).then((data) => {
console.log(msgStr + 'ohosWindow.createWindow success: ' + JSON.stringify(nonExistWnd)); console.log(msgStr + 'ohosWindow.createWindow success: ' + JSON.stringify(nonExistWnd));
done(); done();
}).catch((err) => { }).catch((err) => {
...@@ -1483,11 +1645,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1483,11 +1645,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
expect(err.code === 401).assertTrue(); expect(err.code === 401).assertTrue();
done(); done();
}); });
}catch (exception) { } catch (exception) {
console.error(msgStr + 'try catch Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to create the window. Cause: ' + JSON.stringify(exception));
expect(exception.code === 401).assertTrue(); expect(exception.code === 401).assertTrue();
done(); done();
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_007 * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_007
...@@ -1501,20 +1664,27 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1501,20 +1664,27 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let tempType = 5000; let tempType = 5000;
let windId = 'createTest7'; let windId = 'createTest7';
console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start');
let winsowConfig = {name: windId, windowType:tempType, ctx: context}; let winsowConfig = {
try{ name: windId, windowType: tempType, ctx: context
};
try {
ohosWindow.createWindow(winsowConfig, (err, data) => { ohosWindow.createWindow(winsowConfig, (err, data) => {
if (err && err.code) { if (err && err.code) {
console.log(msgStr + 'ohosWindow.createWindow err' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.createWindow err' + JSON.stringify(err));
expect(err.code === 401).assertTrue(); try {
expect(err.code === 401).assertTrue();
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception));
expect(exception.code === 401).assertTrue(); expect(exception.code === 401).assertTrue();
done(); done();
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_001 * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_001
...@@ -1524,36 +1694,38 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1524,36 +1694,38 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('setWindowLayoutFullScreenTest1', 0, async function (done) { it('setWindowLayoutFullScreenTest1', 0, async function (done) {
let caseName = 'setWindowLayoutFullScreenTest1'; let caseName = 'setWindowLayoutFullScreenTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let wnd=null; let wnd = null;
try{ try {
wnd = windowStage.getMainWindowSync(); wnd = windowStage.getMainWindowSync();
console.log(msgStr +'ohosWindow.getLastWindow ' + JSON.stringify(wnd)); console.log(msgStr + 'ohosWindow.getLastWindow ' + JSON.stringify(wnd));
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
let isLayoutFullScreen= true; let isLayoutFullScreen = true;
wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(()=> { wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => {
console.info(msgStr +'Succeeded in setting the window layout to full-screen mode.'); console.info(msgStr + 'Succeeded in setting the window layout to full-screen mode.');
try { try {
let propData = wnd.getWindowProperties() let propData = wnd.getWindowProperties()
console.info(msgStr + 'wnd.getWindowProperties propData: ' + JSON.stringify(propData)); console.info(msgStr + 'wnd.getWindowProperties propData: ' + JSON.stringify(propData));
expect(propData.isLayoutFullScreen).assertTrue(); expect(propData.isLayoutFullScreen).assertTrue();
done(); done();
}catch (exception) { } catch (exception) {
console.error(msgStr + 'try catch Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
} }
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
}; }
}catch (exception) { ;
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); } catch (exception) {
}; console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_002 * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_002
...@@ -1563,35 +1735,37 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1563,35 +1735,37 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('setWindowLayoutFullScreenTest2', 0, async function (done) { it('setWindowLayoutFullScreenTest2', 0, async function (done) {
let caseName = 'setWindowLayoutFullScreenTest2'; let caseName = 'setWindowLayoutFullScreenTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let wnd=null; let wnd = null;
try{ try {
wnd = windowStage.getMainWindowSync(); wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
let isLayoutFullScreen= false; let isLayoutFullScreen = false;
wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(()=> { wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => {
console.info(msgStr +'Succeeded in setting the window layout to full-screen mode.'); console.info(msgStr + 'Succeeded in setting the window layout to full-screen mode.');
try { try {
let propData = wnd.getWindowProperties() let propData = wnd.getWindowProperties()
console.info(msgStr + 'wnd.getWindowProperties propData: ' + JSON.stringify(propData)); console.info(msgStr + 'wnd.getWindowProperties propData: ' + JSON.stringify(propData));
expect(!propData.isLayoutFullScreen).assertTrue(); expect(!propData.isLayoutFullScreen).assertTrue();
done(); done();
}catch (exception) { } catch (exception) {
console.error(msgStr + 'try catch Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
} }
}).catch((err)=>{ }).catch((err) => {
console.error(msgStr +'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
}; }
;
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_003 * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_003
...@@ -1601,39 +1775,46 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1601,39 +1775,46 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('setWindowLayoutFullScreenTest3', 0, async function (done) { it('setWindowLayoutFullScreenTest3', 0, async function (done) {
let caseName = 'setWindowLayoutFullScreenTest3'; let caseName = 'setWindowLayoutFullScreenTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let wnd=null; let wnd = null;
try { try {
wnd = windowStage.getMainWindowSync(); wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
let isLayoutFullScreen= true; let isLayoutFullScreen = true;
try { try {
wnd.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { wnd.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => {
if (err.code) { if (err.code) {
console.error(msgStr +'err Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); console.error(msgStr + 'err Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
done(); done();
return; return;
} }
console.info(msgStr +'Succeeded in setting the window layout to full-screen mode.'); console.info(msgStr + 'Succeeded in setting the window layout to full-screen mode.');
try{ try {
let propData = wnd.getWindowProperties() let propData = wnd.getWindowProperties()
console.log(msgStr + JSON.stringify(propData)); console.log(msgStr + JSON.stringify(propData));
expect(propData.isLayoutFullScreen).assertTrue(); expect(propData.isLayoutFullScreen).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
} catch (exception) { ;
console.error(msgStr +'Failed to get the main window. Cause: ' + JSON.stringify(exception)); } catch (exception) {
}; console.error(msgStr + 'Failed to get the main window. Cause: ' + JSON.stringify(exception));
}
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_004 * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_004
...@@ -1643,39 +1824,46 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1643,39 +1824,46 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
it('setWindowLayoutFullScreenTest4', 0, async function (done) { it('setWindowLayoutFullScreenTest4', 0, async function (done) {
let caseName = 'setWindowLayoutFullScreenTest4'; let caseName = 'setWindowLayoutFullScreenTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let wnd=null; let wnd = null;
try { try {
wnd = windowStage.getMainWindowSync(); wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
let isLayoutFullScreen= false; let isLayoutFullScreen = false;
try { try {
wnd.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { wnd.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => {
if (err.code) { if (err.code) {
console.error(msgStr +'err Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); console.error(msgStr + 'err Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
done(); done();
return; return;
} }
console.info(msgStr +'Succeeded in setting the window layout to full-screen mode.'); console.info(msgStr + 'Succeeded in setting the window layout to full-screen mode.');
try{ try {
let propData = wnd.getWindowProperties() let propData = wnd.getWindowProperties()
console.log(msgStr + JSON.stringify(propData)); console.log(msgStr + JSON.stringify(propData));
expect(!propData.isLayoutFullScreen).assertTrue(); expect(!propData.isLayoutFullScreen).assertTrue();
done(); done();
} catch (exception) { } catch (exception) {
console.error(msgStr +'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
} catch (exception) { ;
console.error(msgStr +'Failed to create the main window. Cause: ' + JSON.stringify(exception)); } catch (exception) {
}; console.error(msgStr + 'Failed to create the main window. Cause: ' + JSON.stringify(exception));
}
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_001 * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_001
...@@ -1684,10 +1872,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1684,10 +1872,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
*/ */
it('setWindowModeTest1', 0, function (done) { it('setWindowModeTest1', 0, function (done) {
//['UNDEFINED','FULLSCREEN','PRIMARY','SECONDARY','FLOATING'] //['UNDEFINED','FULLSCREEN','PRIMARY','SECONDARY','FLOATING']
let windowModeArr=['FULLSCREEN','PRIMARY','SECONDARY','FLOATING'] let windowModeArr = ['FULLSCREEN', 'PRIMARY', 'SECONDARY', 'FLOATING']
let caseName = 'setWindowModeTest1'; let caseName = 'setWindowModeTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let sumCount=0 let sumCount = 0
try { try {
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
...@@ -1698,23 +1886,25 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1698,23 +1886,25 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let tempType = ohosWindow.WindowMode[loopCount[i]]; let tempType = ohosWindow.WindowMode[loopCount[i]];
console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start');
try { try {
tempWnd.setWindowMode(tempType).then(()=> { tempWnd.setWindowMode(tempType).then(() => {
sumCount++ sumCount++
console.info(msgStr +'Succeeded in setting the window mode. count: '+sumCount); console.info(msgStr + 'Succeeded in setting the window mode. count: ' + sumCount);
console.info(msgStr +'Succeeded in setting the window mode. loopCount.length: '+loopCount.length); console.info(msgStr + 'Succeeded in setting the window mode. loopCount.length: ' + loopCount.length);
if(sumCount==loopCount.length) done(); if (sumCount == loopCount.length) done();
}).catch((err)=>{ }).catch((err) => {
console.log(msgStr +'currentType: '+tempType) console.log(msgStr + 'currentType: ' + tempType)
console.error(msgStr +'Failed to set the window mode. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.setWindowType', done); unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception));
}; }
;
} }
} catch (exception) { } catch (exception) {
console.error('try catch Failed to obtain the getMainWindowSync. Cause: ' + JSON.stringify(exception)); console.error('try catch Failed to obtain the getMainWindowSync. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_002 * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_002
...@@ -1722,11 +1912,11 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1722,11 +1912,11 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
* @tc.desc Verify the scenario where the normal window mode is set * @tc.desc Verify the scenario where the normal window mode is set
*/ */
it('setWindowModeTest2', 0, function (done) { it('setWindowModeTest2', 0, function (done) {
let windowModeArr=['FULLSCREEN','PRIMARY','SECONDARY','FLOATING'] let windowModeArr = ['FULLSCREEN', 'PRIMARY', 'SECONDARY', 'FLOATING']
let caseName = 'setWindowModeTest2'; let caseName = 'setWindowModeTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let sumCount=0 let sumCount = 0
try{ try {
let wnd = windowStage.getMainWindowSync(); let wnd = windowStage.getMainWindowSync();
expect(!!wnd).assertTrue(); expect(!!wnd).assertTrue();
let loopCount = windowModeArr; let loopCount = windowModeArr;
...@@ -1735,26 +1925,28 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1735,26 +1925,28 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
sleep(500) sleep(500)
let tempType = ohosWindow.WindowMode[loopCount[i]]; let tempType = ohosWindow.WindowMode[loopCount[i]];
console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start');
try{ try {
wnd.setWindowMode(tempType, (err, data) => { wnd.setWindowMode(tempType, (err, data) => {
if (err && err.code) { if (err && err.code) {
console.log(msgStr +'currentType: '+tempType) console.log(msgStr + 'currentType: ' + tempType)
console.error(msgStr +'Failed to set the window mode. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.setWindowType', done); unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
} else { } else {
sumCount++ sumCount++
console.info(msgStr +'Succeeded in setting the window mode. count: '+sumCount); console.info(msgStr + 'Succeeded in setting the window mode. count: ' + sumCount);
console.info(msgStr +'Succeeded in setting the window mode. loopCount.length: '+loopCount.length); console.info(msgStr + 'Succeeded in setting the window mode. loopCount.length: ' + loopCount.length);
if(sumCount==loopCount.length) done(); if (sumCount == loopCount.length) done();
} }
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception));
}; }
;
} }
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_003 * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_003
...@@ -1762,10 +1954,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1762,10 +1954,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
* @tc.desc Test window.setWindowMode API function test. * @tc.desc Test window.setWindowMode API function test.
*/ */
it('setWindowModeTest3', 0, function (done) { it('setWindowModeTest3', 0, function (done) {
let windowModeArr=['UNDEFINED'] let windowModeArr = ['UNDEFINED']
let caseName = 'setWindowModeTest3'; let caseName = 'setWindowModeTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let sumCount=0 let sumCount = 0
try { try {
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
...@@ -1776,23 +1968,25 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1776,23 +1968,25 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
let tempType = ohosWindow.WindowMode[loopCount[i]]; let tempType = ohosWindow.WindowMode[loopCount[i]];
console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start');
try { try {
tempWnd.setWindowMode(tempType).then(()=> { tempWnd.setWindowMode(tempType).then(() => {
sumCount++ sumCount++
console.info(msgStr +'Succeeded in setting the window mode. count: '+sumCount); console.info(msgStr + 'Succeeded in setting the window mode. count: ' + sumCount);
console.info(msgStr +'Succeeded in setting the window mode. loopCount.length: '+loopCount.length); console.info(msgStr + 'Succeeded in setting the window mode. loopCount.length: ' + loopCount.length);
}).catch((err)=>{ }).catch((err) => {
console.log(msgStr +'currentType: '+tempType) console.log(msgStr + 'currentType: ' + tempType)
console.error(msgStr +'Failed to set the window mode. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err));
expect(err.code==401).assertTrue(); expect(err.code == 401).assertTrue();
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception));
}; }
;
} }
} catch (exception) { } catch (exception) {
console.error('try catch Failed to obtain the getMainWindowSync. Cause: ' + JSON.stringify(exception)); console.error('try catch Failed to obtain the getMainWindowSync. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_004 * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_004
...@@ -1800,11 +1994,11 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1800,11 +1994,11 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
* @tc.desc Verify the scenario where the normal window mode is set * @tc.desc Verify the scenario where the normal window mode is set
*/ */
it('setWindowModeTest4', 0, function (done) { it('setWindowModeTest4', 0, function (done) {
let windowModeArr=['UNDEFINED'] let windowModeArr = ['UNDEFINED']
let caseName = 'setWindowModeTest4'; let caseName = 'setWindowModeTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let sumCount=0 let sumCount = 0
try{ try {
let wnd = windowStage.getMainWindowSync(); let wnd = windowStage.getMainWindowSync();
expect(!!wnd).assertTrue(); expect(!!wnd).assertTrue();
let loopCount = windowModeArr; let loopCount = windowModeArr;
...@@ -1813,26 +2007,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1813,26 +2007,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
sleep(500) sleep(500)
let tempType = ohosWindow.WindowMode[loopCount[i]]; let tempType = ohosWindow.WindowMode[loopCount[i]];
console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start');
try{ try {
wnd.setWindowMode(tempType, (err, data) => { wnd.setWindowMode(tempType, (err, data) => {
if (err && err.code) { if (err && err.code) {
console.log(msgStr +'currentType: '+tempType) console.log(msgStr + 'currentType: ' + tempType)
console.error(msgStr +'Failed to set the window mode. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err));
expect(err.code==401).assertTrue(); try {
expect(err.code == 401).assertTrue();
} catch (error) {
console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
sumCount++ sumCount++
console.info(msgStr +'Succeeded in setting the window mode. count: '+sumCount); console.info(msgStr + 'Succeeded in setting the window mode. count: ' + sumCount);
console.info(msgStr +'Succeeded in setting the window mode. loopCount.length: '+loopCount.length); console.info(msgStr + 'Succeeded in setting the window mode. loopCount.length: ' + loopCount.length);
} }
}) })
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception));
}; }
;
} }
} catch (exception) { } catch (exception) {
console.error(msgStr +'try catch Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error(msgStr + 'try catch Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
;
}) })
}) })
} }
...@@ -107,7 +107,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -107,7 +107,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
function unexpectedError(error, caseName, apiName, done) { function unexpectedError(error, caseName, apiName, done) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: '; let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error)); console.log(msgStr + JSON.stringify(error));
expect(TRUE_FLAG).assertFail(); try {
expect(TRUE_FLAG).assertFail();
;
} catch (error) {
console.info(`ohosWindow.on ${JSON.stringify(error)}`)
}
done(); done();
} }
...@@ -119,10 +124,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -119,10 +124,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
} }
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_006 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_006
* @tc.name Test setSystemBarEnableTest6 * @tc.name Test setSystemBarEnableTest6
* @tc.desc Test ohosWindow.setSystemBarEnable API function test1. * @tc.desc Test ohosWindow.setSystemBarEnable API function test1.
*/ */
it('setSystemBarEnableTest6', 0, function (done) { it('setSystemBarEnableTest6', 0, function (done) {
let caseName = 'setSystemBarEnableTest6'; let caseName = 'setSystemBarEnableTest6';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -133,8 +138,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -133,8 +138,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
ohosWindow.on('systemBarTintChange', systembartintstate => { ohosWindow.on('systemBarTintChange', systembartintstate => {
console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
if (flagStatus || flagNav) { if (flagStatus || flagNav) {
expect(!!systembartintstate).assertTrue(); try {
expect(!!systembartintstate.regionTint).assertTrue(); expect(!!systembartintstate).assertTrue();
expect(!!systembartintstate.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on ${JSON.stringify(error)}`)
}
console.log(msgStr + 'flagStatus || flagNav' + msgStr + 'ohosWindow.on systemBarTintChange regionTint:' + JSON.stringify(systembartintstate.regionTint)); console.log(msgStr + 'flagStatus || flagNav' + msgStr + 'ohosWindow.on systemBarTintChange regionTint:' + JSON.stringify(systembartintstate.regionTint));
done(); done();
} }
...@@ -147,7 +156,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -147,7 +156,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'windowStage.getMainWindow', done); unexpectedError(data, caseName, 'windowStage.getMainWindow', done);
} }
expect(!!data).assertTrue(); try {
expect(!!data).assertTrue();
} catch (error) {
console.info(`ohosWindow.on ${JSON.stringify(error)}`)
}
mainWnd = data; mainWnd = data;
console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd));
mainWnd.show((err, data) => { mainWnd.show((err, data) => {
...@@ -163,7 +176,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -163,7 +176,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done); unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`ohosWindow.on ${JSON.stringify(error)}`)
}
console.log(msgStr + 'mainWnd.setFullScreen success'); console.log(msgStr + 'mainWnd.setFullScreen success');
flagNav = true; flagNav = true;
mainWnd.setSystemBarEnable(['navigation'], (err, data) => { mainWnd.setSystemBarEnable(['navigation'], (err, data) => {
...@@ -171,7 +188,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -171,7 +188,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navigation]', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navigation]', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`ohosWindow.on ${JSON.stringify(error)}`)
}
console.log(msgStr + 'mainWnd.setSystemBarEnable success flagNav==' + flagNav); console.log(msgStr + 'mainWnd.setSystemBarEnable success flagNav==' + flagNav);
}) })
flagStatus = true; flagStatus = true;
...@@ -181,7 +202,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -181,7 +202,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(err)===' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(err)===' + JSON.stringify(err));
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`ohosWindow.on ${JSON.stringify(error)}`)
}
}) })
}) })
}) })
...@@ -189,10 +214,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -189,10 +214,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'finished!!'); console.log(msgStr + 'finished!!');
}); });
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007
* @tc.name Test setSystemBarEnableTest7 * @tc.name Test setSystemBarEnableTest7
* @tc.desc Verify that the scene hides the status bar and displays the navigation bar. * @tc.desc Verify that the scene hides the status bar and displays the navigation bar.
*/ */
it('setSystemBarEnableTest7', 0, function (done) { it('setSystemBarEnableTest7', 0, function (done) {
let caseName = 'setSystemBarEnableTest7'; let caseName = 'setSystemBarEnableTest7';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -205,7 +230,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -205,7 +230,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
if (flagStatus || flagNav) { if (flagStatus || flagNav) {
console.log(msgStr + 'ohosWindow.on flagStatus || flagNav:'); console.log(msgStr + 'ohosWindow.on flagStatus || flagNav:');
expect(!!systembartintstate).assertTrue(); try {
expect(!!systembartintstate).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
...@@ -215,7 +244,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -215,7 +244,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'windowStage.getMainWindow', done); unexpectedError(data, caseName, 'windowStage.getMainWindow', done);
} }
expect(!!data).assertTrue(); try {
expect(!!data).assertTrue();
} catch (error) {
console.info(`windowStage.getMainWindow catch err: ${JSON.stringify(error)}`)
}
mainWnd = data; mainWnd = data;
console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd));
mainWnd.show((err, data) => { mainWnd.show((err, data) => {
...@@ -223,38 +256,53 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -223,38 +256,53 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(data, caseName, 'mainWnd.show', done); unexpectedError(data, caseName, 'mainWnd.show', done);
} }
console.log(msgStr + 'mainWnd.show success'); console.log(msgStr + 'mainWnd.show success');
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.show catch error: ${JSON.stringify(error)}`)
}
mainWnd.setFullScreen(true, (err, data) => { mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done); unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setFullScreen catch err: ${JSON.stringify(error)}`)
}
mainWnd.setSystemBarEnable(['status'], (err, data) => { mainWnd.setSystemBarEnable(['status'], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(data)==' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(data)==' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done);
} }
flagStatus = true; flagStatus = true;
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`)
}
mainWnd.setSystemBarEnable(['navigation'], (err, data) => { mainWnd.setSystemBarEnable(['navigation'], (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navitgation]', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navitgation]', done);
} }
flagNav = true; flagNav = true;
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`)
}
}) })
}) })
}) })
}) })
}) })
console.log(msgStr + 'finished!!');
}); });
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_008 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_008
* @tc.name Test setSystemBarEnableTest8 * @tc.name Test setSystemBarEnableTest8
* @tc.desc Verify that the scene displays both the status bar and the navigation bar. * @tc.desc Verify that the scene displays both the status bar and the navigation bar.
*/ */
it('setSystemBarEnableTest8', 0, function (done) { it('setSystemBarEnableTest8', 0, function (done) {
let caseName = 'setSystemBarEnableTest8'; let caseName = 'setSystemBarEnableTest8';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -266,7 +314,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -266,7 +314,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'windowStage.getMainWindow', done); unexpectedError(data, caseName, 'windowStage.getMainWindow', done);
} }
expect(!!data).assertTrue(); try {
expect(!!data).assertTrue();
} catch (error) {
console.info(`mainWnd.getMainWindow catch err: ${JSON.stringify(error)}`)
}
mainWnd = data; mainWnd = data;
console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd));
mainWnd.show((err, data) => { mainWnd.show((err, data) => {
...@@ -274,19 +326,31 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -274,19 +326,31 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(data, caseName, 'mainWnd.show', done); unexpectedError(data, caseName, 'mainWnd.show', done);
} }
console.log(msgStr + 'mainWnd.show success'); console.log(msgStr + 'mainWnd.show success');
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.show catch err: ${JSON.stringify(error)}`)
}
mainWnd.setFullScreen(true, (err, data) => { mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done); unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setFullScreen catch err: ${JSON.stringify(error)}`)
}
mainWnd.setSystemBarEnable([], (err, data) => { mainWnd.setSystemBarEnable([], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`)
}
listenerData.on = true; listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange'; listenerData.typeStr = 'systemBarTintChange';
setTimeout(() => { setTimeout(() => {
...@@ -299,8 +363,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -299,8 +363,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let numType = systembartintstate.regionTint[0].type let numType = systembartintstate.regionTint[0].type
console.log(msgStr + 'ohosWindow.on isEnable : ' + JSON.stringify(enable)); console.log(msgStr + 'ohosWindow.on isEnable : ' + JSON.stringify(enable));
console.log(msgStr + 'ohosWindow.on numType : ' + JSON.stringify(numType)); console.log(msgStr + 'ohosWindow.on numType : ' + JSON.stringify(numType));
try {
expect(numType === ohosWindow.WindowType.TYPE_NAVIGATION_BAR || enable).assertTrue(); expect(numType === ohosWindow.WindowType.TYPE_NAVIGATION_BAR || enable).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`)
}
} }
done(); done();
}, 3000) }, 3000)
...@@ -312,7 +379,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -312,7 +379,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} }
flagStatus = true; flagStatus = true;
flagNav = true; flagNav = true;
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`)
}
}) })
}) })
}) })
...@@ -320,10 +391,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -320,10 +391,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}); });
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_009 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_009
* @tc.name Test setSystemBarEnableTest9 * @tc.name Test setSystemBarEnableTest9
* @tc.desc Verify that the scene hides both the status bar and the navigation bar. * @tc.desc Verify that the scene hides both the status bar and the navigation bar.
*/ */
it('setSystemBarEnableTest9', 0, function (done) { it('setSystemBarEnableTest9', 0, function (done) {
let caseName = 'setSystemBarEnableTest9'; let caseName = 'setSystemBarEnableTest9';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -335,7 +406,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -335,7 +406,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'windowStage.getMainWindow', done); unexpectedError(data, caseName, 'windowStage.getMainWindow', done);
} }
expect(!!data).assertTrue(); try {
expect(!!data).assertTrue();
} catch (error) {
console.info(`windowStage.getMainWindow catch err: ${JSON.stringify(error)}`)
}
mainWnd = data; mainWnd = data;
console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd));
mainWnd.show((err, data) => { mainWnd.show((err, data) => {
...@@ -343,13 +418,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -343,13 +418,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(data, caseName, 'mainWnd.show', done); unexpectedError(data, caseName, 'mainWnd.show', done);
} }
console.log(msgStr + 'mainWnd.show success'); console.log(msgStr + 'mainWnd.show success');
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.show catch err: ${JSON.stringify(error)}`)
}
mainWnd.setFullScreen(true, (err, data) => { mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen', done); unexpectedError(data, caseName, 'mainWnd.setFullScreen', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setFullScreen catch err: ${JSON.stringify(error)}`)
}
mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable status,navigation JSON.stringify(data)==' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setSystemBarEnable status,navigation JSON.stringify(data)==' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
...@@ -357,14 +440,22 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -357,14 +440,22 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} }
flagStatus = true; flagStatus = true;
flagNav = true; flagNav = true;
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`)
}
listenerData.on = true; listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange'; listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systembartintstate) => { ohosWindow.on('systemBarTintChange', (systembartintstate) => {
console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate)); console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate));
console.log(msgStr + 'ohosWindow.on systemBarTintChange systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); console.log(msgStr + 'ohosWindow.on systemBarTintChange systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
if (flagStatus || flagNav) { if (flagStatus || flagNav) {
expect(!!systembartintstate).assertTrue(); try {
expect(!!systembartintstate).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
...@@ -372,7 +463,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -372,7 +463,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`)
}
}) })
}) })
}) })
...@@ -394,7 +489,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -394,7 +489,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'windowStage.getMainWindow', done); unexpectedError(data, caseName, 'windowStage.getMainWindow', done);
} }
expect(!!data).assertTrue(); try {
console.log(msgStr + 'windowStage.getMainWindow JSON.stringify(!!data)===' + JSON.stringify(!!data));
expect(!!data).assertTrue();
} catch (error) {
console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`)
}
mainWnd = data; mainWnd = data;
console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd));
mainWnd.show((err, data) => { mainWnd.show((err, data) => {
...@@ -402,25 +502,44 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -402,25 +502,44 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(data, caseName, 'mainWnd.show', done); unexpectedError(data, caseName, 'mainWnd.show', done);
} }
console.log(msgStr + 'mainWnd.show success'); console.log(msgStr + 'mainWnd.show success');
expect(!data).assertTrue(); try {
console.log(msgStr + 'mainWnd.show JSON.stringify(!data)===' + JSON.stringify(!data));
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.show catch error: ${JSON.stringify(error)}`)
}
mainWnd.setFullScreen(true, (err, data) => { mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen: ' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setFullScreen: ' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done); unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done);
} }
expect(!data).assertTrue(); try {
console.log(msgStr + 'mainWnd.setFullScreen JSON.stringify(!data)===' + JSON.stringify(!data));
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setFullScreen catch error: ${JSON.stringify(error)}`)
}
mainWnd.setSystemBarEnable([], (err, data) => { mainWnd.setSystemBarEnable([], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done);
} }
try {
expect(!data).assertTrue(); console.log(msgStr + 'mainWnd.setSystemBarEnable JSON.stringify(!data)===' + JSON.stringify(!data));
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`)
}
mainWnd.setSystemBarEnable([null, '123'], (err, data) => { mainWnd.setSystemBarEnable([null, '123'], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(data)==' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(data)==' + JSON.stringify(data));
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(err)==' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(err)==' + JSON.stringify(err));
if (err && err.code) { if (err && err.code) {
expect(err.code === 1003).assertTrue(); try {
console.log(msgStr + 'mainWnd.setSystemBarEnable JSON.stringify(err.code)===' + JSON.stringify(err.code));
expect(err.code === 1003).assertTrue();
} catch (error) {
console.info(`mainWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [null,123]', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [null,123]', done);
...@@ -448,8 +567,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -448,8 +567,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
ohosWindow.on('systemBarTintChange', (systemBarData) => { ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) { if (listenerFlag === listenerStatus.pending) {
expect(!!systemBarData).assertTrue(); try {
expect(!!systemBarData.regionTint).assertTrue(); expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
...@@ -458,8 +581,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -458,8 +581,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor);
expect(backgroundIndex === -1).assertTrue(); try {
expect(contentColorIndex === -1).assertTrue(); expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
} }
} }
} }
...@@ -470,25 +597,41 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -470,25 +597,41 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.getMainWindow', done); unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
} }
let tempWnd = data let tempWnd = data
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
tempWnd.show((err, data) => { tempWnd.show((err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.show', done); unexpectedError(err, caseName, 'tempWnd.show', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.show success'); console.log(msgStr + 'tempWnd.show success');
tempWnd.setFullScreen(true, (err, data) => { tempWnd.setFullScreen(true, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.setFullScreen(true) success'); console.log(msgStr + 'tempWnd.setFullScreen(true) success');
tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
listenerFlag = listenerStatus.pending; listenerFlag = listenerStatus.pending;
let loopCount = commonRGBColorArr.length let loopCount = commonRGBColorArr.length
...@@ -544,8 +687,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -544,8 +687,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
ohosWindow.on('systemBarTintChange', (systemBarData) => { ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) { if (listenerFlag === listenerStatus.pending) {
expect(!!systemBarData).assertTrue(); try {
expect(!!systemBarData.regionTint).assertTrue(); expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
...@@ -585,7 +732,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -585,7 +732,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length
if (compareCount === 18 && !flag) { if (compareCount === 18 && !flag) {
console.log(msgStr + 'compareCount: ' + compareCount + ' ,true flag:' + flag); console.log(msgStr + 'compareCount: ' + compareCount + ' ,true flag:' + flag);
expect(true).assertTrue(); try {
expect(true).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag); console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag);
...@@ -603,25 +754,41 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -603,25 +754,41 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.getMainWindow', done); unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
} }
let tempWnd = data let tempWnd = data
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
tempWnd.show((err, data) => { tempWnd.show((err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.show', done); unexpectedError(err, caseName, 'tempWnd.show', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.show success'); console.log(msgStr + 'tempWnd.show success');
tempWnd.setFullScreen(true, (err, data) => { tempWnd.setFullScreen(true, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.setFullScreen(true) success'); console.log(msgStr + 'tempWnd.setFullScreen(true) success');
tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.setSystemBatEnable catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
listenerFlag = listenerStatus.pending; listenerFlag = listenerStatus.pending;
let loopCount = commonNUMBERColorArr.length let loopCount = commonNUMBERColorArr.length
...@@ -639,7 +806,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -639,7 +806,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
expect(TRUE_FLAG).assertFail(); try {
expect(TRUE_FLAG).assertFail();
} catch (error) {
console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
...@@ -666,8 +837,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -666,8 +837,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
ohosWindow.on('systemBarTintChange', (systemBarData) => { ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) { if (listenerFlag === listenerStatus.pending) {
expect(!!systemBarData).assertTrue(); try {
expect(!!systemBarData.regionTint).assertTrue(); expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
...@@ -676,8 +851,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -676,8 +851,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor);
expect(backgroundIndex === -1).assertTrue(); try {
expect(contentColorIndex === -1).assertTrue(); expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
} }
} }
} }
...@@ -688,25 +867,41 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -688,25 +867,41 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.getMainWindow', done); unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
} }
let tempWnd = data let tempWnd = data
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`winsowStage.getMainWindow catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
tempWnd.show((err, data) => { tempWnd.show((err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.show', done); unexpectedError(err, caseName, 'tempWnd.show', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.show success'); console.log(msgStr + 'tempWnd.show success');
tempWnd.setFullScreen(true, (err, data) => { tempWnd.setFullScreen(true, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.setFullScreen(true) success'); console.log(msgStr + 'tempWnd.setFullScreen(true) success');
tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
listenerFlag = listenerStatus.pending; listenerFlag = listenerStatus.pending;
let loopCount = commonRGBColorArr.length let loopCount = commonRGBColorArr.length
...@@ -724,7 +919,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -724,7 +919,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
expect(TRUE_FLAG).assertFail(); try {
expect(TRUE_FLAG).assertFail();
} catch (error) {
console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
...@@ -758,7 +957,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -758,7 +957,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err));
console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
expect(err.code === 1003).assertTrue(); try {
expect(err.code === 1003).assertTrue();
} catch (error) {
console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'ohosWindow.create err.code==' + JSON.stringify(err.code)) console.log(msgStr + 'ohosWindow.create err.code==' + JSON.stringify(err.code))
if (i === loopCount - 1) { if (i === loopCount - 1) {
done(); done();
...@@ -791,7 +994,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -791,7 +994,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done);
return; return;
} }
expect(!!data).assertTrue(); try {
expect(!!data).assertTrue();
} catch (error) {
console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`)
}
let tempWnd = data let tempWnd = data
console.log(msgStr + 'ohosWindow.create ' + tempType + ' wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.create ' + tempType + ' wnd: ' + tempWnd);
tempWnd.getProperties((err, data) => { tempWnd.getProperties((err, data) => {
...@@ -803,8 +1010,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -803,8 +1010,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
return; return;
} }
console.log(msgStr + 'tempWnd.getProperties success, !!data : ' + !!data); console.log(msgStr + 'tempWnd.getProperties success, !!data : ' + !!data);
expect(!!data).assertTrue(); try {
expect(data.type == tempType).assertTrue(); expect(!!data).assertTrue();
expect(data.type == tempType).assertTrue();
} catch (error) {
console.info(`tempWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
}) })
}) })
} }
...@@ -825,7 +1036,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -825,7 +1036,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
ohosWindow.create(context, windId, tempType, (err, data) => { ohosWindow.create(context, windId, tempType, (err, data) => {
console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
expect(err.code === 1003).assertTrue(); try {
expect(err.code === 1003).assertTrue();
} catch (error) {
console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`)
}
done(); done();
return; return;
} }
...@@ -853,7 +1068,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -853,7 +1068,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err));
if (err && err.code) { if (err && err.code) {
console.log(msgStr + 'ohosWindow.create 1 twice data: ' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.create 1 twice data: ' + JSON.stringify(data));
expect(err.code).assertEqual(1001) try {
expect(err.code).assertEqual(1001)
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
unexpectedError(err, caseName, 'ohosWindow.create', done); unexpectedError(err, caseName, 'ohosWindow.create', done);
...@@ -881,25 +1100,40 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -881,25 +1100,40 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} }
tempWnd = data tempWnd = data
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`)
}
tempWnd.show((err, data) => { tempWnd.show((err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.show', done); unexpectedError(err, caseName, 'tempWnd.show', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.show success'); console.log(msgStr + 'tempWnd.show success');
tempWnd.setFullScreen(true, (err, data) => { tempWnd.setFullScreen(true, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.setFullScreen(true) success'); console.log(msgStr + 'tempWnd.setFullScreen(true) success');
tempWnd.on('systemAvoidAreaChange', avoidAreaData => { tempWnd.on('systemAvoidAreaChange', avoidAreaData => {
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, avoidAreaData : ' + JSON.stringify(avoidAreaData)); console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, avoidAreaData : ' + JSON.stringify(avoidAreaData));
if (listenerOnFlag === listenerStatus.pending) { if (listenerOnFlag === listenerStatus.pending) {
listenerOnFlag = listenerStatus.finished; listenerOnFlag = listenerStatus.finished;
expect(!!avoidAreaData).assertTrue(); try {
expect(!!avoidAreaData).assertTrue();
} catch (error) {
console.info(`tempWnd.on catch error: ${JSON.stringify(error)}`)
}
} }
done(); done();
}) })
...@@ -907,7 +1141,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -907,7 +1141,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done);
} }
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success'); console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success');
listenerOnFlag = listenerStatus.pending; listenerOnFlag = listenerStatus.pending;
}) })
...@@ -923,10 +1161,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -923,10 +1161,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_003 * @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_003
* @tc.name Test setWindowTypeTest3 * @tc.name Test setWindowTypeTest3
* @tc.desc Verify the scenario where the normal window type is set * @tc.desc Verify the scenario where the normal window type is set
*/ */
it('setWindowTypeTest3', 0, function (done) { it('setWindowTypeTest3', 0, function (done) {
let caseName = 'setWindowTypeTest3'; let caseName = 'setWindowTypeTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -936,64 +1174,87 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -936,64 +1174,87 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let tempWnd = null let tempWnd = null
let tempTypeArr = []; let tempTypeArr = [];
ohosWindow.create(context, windowId, baseWndType, (err, data) => { ohosWindow.create(context, windowId, baseWndType, (err, data) => {
console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); try {
console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err));
console.log(msgStr + 'ohosWindow.create !!data' + !!data); console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data));
if (!!data) { console.log(msgStr + 'ohosWindow.create !!data' + !!data);
tempWnd = data if (!!data) {
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd); tempWnd = data
expect(!!tempWnd).assertTrue(); console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd);
let loopCount1 = systemWindowTypeArr; try {
console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount1)) expect(!!tempWnd).assertTrue();
for (let i = 0; i < loopCount1.length; i++) { } catch (error) {
let tempType = ohosWindow.WindowType[loopCount1[i]]; console.info(`ohosWindwo.create catch error: ${JSON.stringify(error)}`)
console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' start'); }
tempTypeArr.push(tempType); let loopCount1 = systemWindowTypeArr;
tempWnd.setWindowType(tempType, (err, data) => { console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount1))
console.log(msgStr + 'tempWnd.setWindowType i: ' + i); for (let i = 0; i < loopCount1.length; i++) {
console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err)); let tempType = ohosWindow.WindowType[loopCount1[i]];
console.log(msgStr + 'tempWnd.setWindowType data: ' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' start');
console.log(msgStr + 'tempWnd.setWindowType !data: ' + !data); tempTypeArr.push(tempType);
if (!data) { tempWnd.setWindowType(tempType, (err, data) => {
expect(!data).assertTrue(); try {
console.log(msgStr + 'tempWnd.getProperties start'); console.log(msgStr + 'tempWnd.setWindowType i: ' + i);
tempWnd.getProperties((err, dataProper) => { console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.getProperties err: ' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setWindowType data: ' + JSON.stringify(data));
console.log(msgStr + 'tempWnd.getProperties dataProper: ' + JSON.stringify(dataProper)); console.log(msgStr + 'tempWnd.setWindowType !data: ' + !data);
console.log(msgStr + 'tempWnd.getProperties !!dataProper: ' + !!dataProper); if (!data) {
expect(!!dataProper).assertTrue(); try {
if (!!dataProper) { expect(!data).assertTrue();
console.log(msgStr + 'tempWnd.getProperties true tempTypeArr: ' + JSON.stringify(tempTypeArr)); } catch (error) {
console.log(msgStr + 'tempWnd.getProperties true i: ' + i); console.info(`tempWnd.setWindowType catch error: ${JSON.stringify(error)}`)
tempTypeArr.splice(tempTypeArr.findIndex(item => item === dataProper.type), 1);
console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length: ' + tempTypeArr.length);
console.log(msgStr + 'tempWnd.getProperties true loopCount1.length: ' + loopCount1.length);
console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length + 1: ' + tempTypeArr.length + 1);
expect((loopCount1.length - i) == (tempTypeArr.length + 1)).assertTrue();
if (i == loopCount1.length - 1) {
console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length);
done();
} }
} else { console.log(msgStr + 'tempWnd.getProperties start');
unexpectedError(err, caseName, 'tempWnd.getProperties aa', done); tempWnd.getProperties((err, dataProper) => {
try {
console.log(msgStr + 'tempWnd.getProperties err: ' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.getProperties dataProper: ' + JSON.stringify(dataProper));
console.log(msgStr + 'tempWnd.getProperties !!dataProper: ' + !!dataProper);
try {
expect(!!dataProper).assertTrue();
} catch (error) {
console.info(`tempWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
if (!!dataProper) {
console.log(msgStr + 'tempWnd.getProperties true tempTypeArr: ' + JSON.stringify(tempTypeArr));
console.log(msgStr + 'tempWnd.getProperties true i: ' + i);
tempTypeArr.splice(tempTypeArr.findIndex(item => item === dataProper.type), 1);
console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length: ' + tempTypeArr.length);
console.log(msgStr + 'tempWnd.getProperties true loopCount1.length: ' + loopCount1.length);
console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length + 1: ' + Number(tempTypeArr.length + 1));
try {
expect((loopCount1.length - i) == (tempTypeArr.length + 1)).assertTrue();
} catch (error) {
console.info(`tempWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
if (i == loopCount1.length - 1) {
console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length);
done();
}
}
} catch (err) {
console.log(msgStr + 'tempWnd.getProperties catch err: ' + JSON.stringify(err));
}
})
} }
}) console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' end');
} else { } catch (err) {
unexpectedError(err, caseName, 'tempWnd.setWindowType', done); console.log(msgStr + 'tempWnd.setWindowType catch err: ' + JSON.stringify(err));
} }
console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' end'); })
}) }
} }
} else { } catch (err) {
unexpectedError(err, caseName, 'ohosWindow.create', done); console.log(msgStr + 'ohosWindow.create catch err: ' + JSON.stringify(err));
} }
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_004 * @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_004
* @tc.name Test setWindowTypeTest4 * @tc.name Test setWindowTypeTest4
* @tc.desc Verify the scene of setting illegal window type * @tc.desc Verify the scene of setting illegal window type
*/ */
it('setWindowTypeTest4', 0, function (done) { it('setWindowTypeTest4', 0, function (done) {
let caseName = 'setWindowTypeTest4'; let caseName = 'setWindowTypeTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1008,7 +1269,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1008,7 +1269,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create !!data' + !!data); console.log(msgStr + 'ohosWindow.create !!data' + !!data);
if (!!data) { if (!!data) {
tempWnd = data tempWnd = data
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`)
}
tempWnd.setWindowType(changedWndType, (err, data) => { tempWnd.setWindowType(changedWndType, (err, data) => {
console.log(msgStr + 'tempWnd.setWindowType err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setWindowType err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.setWindowType data' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.setWindowType data' + JSON.stringify(data));
...@@ -1016,7 +1281,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1016,7 +1281,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (!!data) { if (!!data) {
unexpectedError(err, caseName, 'tempWnd.setWindowType', done); unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
} else { } else {
expect(err.code == 1003).assertTrue(); try {
expect(err.code == 1003).assertTrue();
} catch (error) {
console.info(`tempWnd.setWindowType catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
...@@ -1026,10 +1295,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1026,10 +1295,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_DESTROY_JSAPI_002 * @tc.number SUB_WINDOW_DESTROY_JSAPI_002
* @tc.name Test destroyTest2 * @tc.name Test destroyTest2
* @tc.desc Verification window destruction scenario * @tc.desc Verification window destruction scenario
*/ */
it('destroyTest2', 0, function (done) { it('destroyTest2', 0, function (done) {
let caseName = 'destroyTest2'; let caseName = 'destroyTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1043,7 +1312,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1043,7 +1312,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create !!data' + !!data); console.log(msgStr + 'ohosWindow.create !!data' + !!data);
if (!!data) { if (!!data) {
tempWnd = data tempWnd = data
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
tempWnd.destroy((err, data) => { tempWnd.destroy((err, data) => {
console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data));
...@@ -1051,13 +1324,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1051,13 +1324,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'ohosWindow.destroy', done); unexpectedError(err, caseName, 'ohosWindow.destroy', done);
} else { } else {
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
ohosWindow.find(windowId, (err, data) => { ohosWindow.find(windowId, (err, data) => {
console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err));
console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data));
console.log(msgStr + 'ohosWindow.find !!data' + !!data); console.log(msgStr + 'ohosWindow.find !!data' + !!data);
if (err && err.code) { if (err && err.code) {
expect(err.code == 1001).assertTrue(); try {
expect(err.code == 1001).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
unexpectedError(err, caseName, 'tempWnd.setWindowType', done); unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
...@@ -1071,10 +1352,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1071,10 +1352,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_007 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_007
* @tc.name Test loadContentTest7 * @tc.name Test loadContentTest7
* @tc.desc Verify the scenario of loading an existing page * @tc.desc Verify the scenario of loading an existing page
*/ */
it('loadContentTest7', 0, function (done) { it('loadContentTest7', 0, function (done) {
let caseName = 'loadContentTest7'; let caseName = 'loadContentTest7';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1088,7 +1369,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1088,7 +1369,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create !!data' + !!data); console.log(msgStr + 'ohosWindow.create !!data' + !!data);
if (!!data) { if (!!data) {
tempWnd = data tempWnd = data
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
tempWnd.loadContent('pages/index', (err, data) => { tempWnd.loadContent('pages/index', (err, data) => {
console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data));
...@@ -1096,7 +1381,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1096,7 +1381,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.loadContent', done); unexpectedError(err, caseName, 'tempWnd.loadContent', done);
} else { } else {
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
...@@ -1106,10 +1395,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1106,10 +1395,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_008 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_008
* @tc.name Test loadContentTest8 * @tc.name Test loadContentTest8
* @tc.desc Verify the scenario of loading a page that does not exist * @tc.desc Verify the scenario of loading a page that does not exist
*/ */
it('loadContentTest8', 0, function (done) { it('loadContentTest8', 0, function (done) {
let caseName = 'loadContentTest8'; let caseName = 'loadContentTest8';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1123,13 +1412,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1123,13 +1412,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create !!data' + !!data); console.log(msgStr + 'ohosWindow.create !!data' + !!data);
if (!!data) { if (!!data) {
tempWnd = data tempWnd = data
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`)
}
tempWnd.loadContent(null, (err, data) => { tempWnd.loadContent(null, (err, data) => {
console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data));
console.log(msgStr + 'tempWnd.loadContent !!data' + !!data); console.log(msgStr + 'tempWnd.loadContent !!data' + !!data);
if (err && err.code) { if (err && err.code) {
expect(err.code === 1003).assertTrue(); try {
expect(err.code === 1003).assertTrue();
} catch (error) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
unexpectedError(err, caseName, 'tempWnd.loadContent', done); unexpectedError(err, caseName, 'tempWnd.loadContent', done);
...@@ -1141,10 +1438,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1141,10 +1438,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_009 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_009
* @tc.name Test loadContentTest9 * @tc.name Test loadContentTest9
* @tc.desc Verify the scenario of loading an existing page * @tc.desc Verify the scenario of loading an existing page
*/ */
it('loadContentTest9', 0, function (done) { it('loadContentTest9', 0, function (done) {
let caseName = 'loadContentTest9'; let caseName = 'loadContentTest9';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1154,17 +1451,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1154,17 +1451,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.loadContent', done); unexpectedError(err, caseName, 'windowStage.loadContent', done);
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
} else { } else {
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data)); console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data));
} }
done(); done();
}); });
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_010 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_010
* @tc.name Test loadContentTest10 * @tc.name Test loadContentTest10
* @tc.desc Verify the scenario of loading an existing page * @tc.desc Verify the scenario of loading an existing page
*/ */
it('loadContentTest10', 0, function (done) { it('loadContentTest10', 0, function (done) {
let caseName = 'loadContentTest10'; let caseName = 'loadContentTest10';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1172,20 +1473,28 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1172,20 +1473,28 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
try { try {
windowStage.loadContent(null, (err, data) => { windowStage.loadContent(null, (err, data) => {
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
expect(false).assertTrue(); try {
expect(false).assertTrue();
} catch (error) {
console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`)
}
}); });
} catch (err) { } catch (err) {
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err' + JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err' + JSON.stringify(err));
expect(err.code == 401).assertTrue(); try {
expect(err.code == 401).assertTrue();
} catch (error) {
console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`)
}
} }
console.log(msgStr + 'end'); console.log(msgStr + 'end');
done(); done();
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_011 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_011
* @tc.name Test loadContentTest11 * @tc.name Test loadContentTest11
* @tc.desc Verify the scenario of loading an existing page * @tc.desc Verify the scenario of loading an existing page
*/ */
it('loadContentTest11', 0, async function (done) { it('loadContentTest11', 0, async function (done) {
let caseName = 'loadContentTest11'; let caseName = 'loadContentTest11';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1195,17 +1504,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1195,17 +1504,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.loadContent', done); unexpectedError(err, caseName, 'windowStage.loadContent', done);
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
} else { } else {
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data)); console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data));
} }
done(); done();
}); });
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_012 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_012
* @tc.name Test loadContentTest12 * @tc.name Test loadContentTest12
* @tc.desc Verify the scenario of loading an existing page * @tc.desc Verify the scenario of loading an existing page
*/ */
it('loadContentTest12', 0, function (done) { it('loadContentTest12', 0, function (done) {
let caseName = 'loadContentTest12'; let caseName = 'loadContentTest12';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1213,20 +1526,27 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1213,20 +1526,27 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
try { try {
windowStage.loadContent(null, abilityStorage, (err, data) => { windowStage.loadContent(null, abilityStorage, (err, data) => {
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
expect(false).assertTrue(); try {
expect(false).assertTrue();
} catch (error) {
console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`)
}
}); });
} catch (err) { } catch (err) {
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err ' + JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err ' + JSON.stringify(err));
expect(err.code === 401).assertTrue(); try {
expect(err.code === 401).assertTrue();
} catch (error) {
console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`)
}
} }
done(); done();
}) })
/** /**
* @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_003 * @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_003
* @tc.name Test createSubWindowTest3 * @tc.name Test createSubWindowTest3
* @tc.desc Verify the scenario of creating an auxiliary window * @tc.desc Verify the scenario of creating an auxiliary window
*/ */
it('createSubWindowTest3', 0, function (done) { it('createSubWindowTest3', 0, function (done) {
let caseName = 'createSubWindowTest3'; let caseName = 'createSubWindowTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1236,17 +1556,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1236,17 +1556,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.createSubWindow', done); unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest3) err=' + JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest3) err=' + JSON.stringify(err));
} else { } else {
expect(!!data).assertTrue(); try {
expect(!!data).assertTrue();
} catch (error) {
console.info(`windowStage.createSubWindow catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.createSubWindow end data=' + JSON.stringify(data)); console.log(msgStr + 'windowStage.createSubWindow end data=' + JSON.stringify(data));
} }
done(); done();
}); });
}) })
/** /**
* @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_004 * @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_004
* @tc.name Test createSubWindowTest4 * @tc.name Test createSubWindowTest4
* @tc.desc Verify the scene of entering illegal values to create an auxiliary window * @tc.desc Verify the scene of entering illegal values to create an auxiliary window
*/ */
it('createSubWindowTest4', 0, function (done) { it('createSubWindowTest4', 0, function (done) {
let caseName = 'createSubWindowTest4'; let caseName = 'createSubWindowTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1254,19 +1578,27 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1254,19 +1578,27 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
try { try {
windowStage.createSubWindow(null, (err, data) => { windowStage.createSubWindow(null, (err, data) => {
console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
expect(false).assertTrue(); try {
expect(false).assertTrue();
} catch (error) {
console.info(`windowStage.createSubWindow catch error: ${JSON.stringify(error)}`)
}
}); });
} catch (err) { } catch (err) {
expect(err.code === 401).assertTrue(); try {
expect(err.code === 401).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.createSubWindow(null) catch err=' + JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(null) catch err=' + JSON.stringify(err));
} }
done(); done();
}) })
/** /**
* @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_002 * @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_002
* @tc.name Test getSubWindowTest2 * @tc.name Test getSubWindowTest2
* @tc.desc Verify the scene of obtaining all auxiliary sub windows * @tc.desc Verify the scene of obtaining all auxiliary sub windows
*/ */
it('getSubWindowTest2', 0, async function (done) { it('getSubWindowTest2', 0, async function (done) {
let caseName = 'getSubWindowTest2'; let caseName = 'getSubWindowTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1276,17 +1608,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1276,17 +1608,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.getSubWindow', done); unexpectedError(err, caseName, 'windowStage.getSubWindow', done);
console.log(msgStr + 'windowStage.getSubWindow(null) err=' + JSON.stringify(err)); console.log(msgStr + 'windowStage.getSubWindow(null) err=' + JSON.stringify(err));
} else { } else {
expect(!!data).assertTrue(); try {
expect(!!data).assertTrue();
} catch (error) {
console.info(`windowStage.getSubWindow catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.getSubWindow end data=' + JSON.stringify(data)); console.log(msgStr + 'windowStage.getSubWindow end data=' + JSON.stringify(data));
} }
done(); done();
}); });
}) })
/** /**
* @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_002 * @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_002
* @tc.name Test setPrivacyModeTest2 * @tc.name Test setPrivacyModeTest2
* @tc.desc Verify the scene where the application sub window is set as a security layer * @tc.desc Verify the scene where the application sub window is set as a security layer
*/ */
it('setPrivacyModeTest2', 0, async function (done) { it('setPrivacyModeTest2', 0, async function (done) {
let caseName = 'setPrivacyModeTest2'; let caseName = 'setPrivacyModeTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1295,50 +1631,90 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1295,50 +1631,90 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
ohosWindow.create(context, 'setPrivacyModeTest2', ohosWindow.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { ohosWindow.create(context, 'setPrivacyModeTest2', ohosWindow.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err && err.code) { if (err && err.code) {
console.log(msgStr + 'ohosWindow.create fail err:' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.create fail err:' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
expect(data != null).assertTrue(); try {
expect(data != null).assertTrue();
} catch (error) {
console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'ohosWindow.create success data' + data); console.log(msgStr + 'ohosWindow.create success data' + data);
mainWnd = data; mainWnd = data;
mainWnd.getProperties((err, data) => { mainWnd.getProperties((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data));
expect(!data.isPrivacyMode).assertTrue(); try {
expect(!data.isPrivacyMode).assertTrue();
} catch (error) {
console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
mainWnd.setPrivacyMode(true, (err, data) => { mainWnd.setPrivacyMode(true, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err));
} else { } else {
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setPrivacyMode catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data));
mainWnd.getProperties((err, data) => { mainWnd.getProperties((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data));
expect(data.isPrivacyMode).assertTrue(); try {
expect(data.isPrivacyMode).assertTrue();
} catch (error) {
console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
mainWnd.setPrivacyMode(false, (err, data) => { mainWnd.setPrivacyMode(false, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err));
} else { } else {
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`mainWnd.setPrivacyMode catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data));
mainWnd.getProperties((err, data) => { mainWnd.getProperties((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data));
expect(!data.isPrivacyMode).assertTrue(); try {
expect(!data.isPrivacyMode).assertTrue();
} catch (error) {
console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`)
}
} }
done(); done();
}) })
...@@ -1354,10 +1730,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1354,10 +1730,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_003 * @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_003
* @tc.name Test setPrivacyModeTest3 * @tc.name Test setPrivacyModeTest3
* @tc.desc Verify that the auxiliary window is set as the security layer * @tc.desc Verify that the auxiliary window is set as the security layer
*/ */
it('setPrivacyModeTest3', 0, async function (done) { it('setPrivacyModeTest3', 0, async function (done) {
let caseName = 'setPrivacyModeTest3'; let caseName = 'setPrivacyModeTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1366,50 +1742,90 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1366,50 +1742,90 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
windowStage.createSubWindow('setPrivacyModeTest3', (err, data) => { windowStage.createSubWindow('setPrivacyModeTest3', (err, data) => {
if (err && err.code) { if (err && err.code) {
console.log(msgStr + 'windowStage.createSubWindow fail err:' + JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow fail err:' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
expect(data != null).assertTrue(); try {
expect(data != null).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.createSubWindow success data' + data); console.log(msgStr + 'windowStage.createSubWindow success data' + data);
mainWnd = data; mainWnd = data;
mainWnd.getProperties((err, data) => { mainWnd.getProperties((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data));
expect(!data.isPrivacyMode).assertTrue(); try {
expect(!data.isPrivacyMode).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
mainWnd.setPrivacyMode(true, (err, data) => { mainWnd.setPrivacyMode(true, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err));
} else { } else {
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data));
mainWnd.getProperties((err, data) => { mainWnd.getProperties((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data));
expect(data.isPrivacyMode).assertTrue(); try {
expect(data.isPrivacyMode).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
mainWnd.setPrivacyMode(false, (err, data) => { mainWnd.setPrivacyMode(false, (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err));
} else { } else {
expect(!data).assertTrue(); try {
expect(!data).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data));
mainWnd.getProperties((err, data) => { mainWnd.getProperties((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err)); console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data));
expect(!data.isPrivacyMode).assertTrue(); try {
expect(!data.isPrivacyMode).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
} }
done(); done();
}) })
...@@ -1425,10 +1841,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1425,10 +1841,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_SETDENSITTYDPI_JSAPI_002 * @tc.number SUB_WINDOW_SETDENSITTYDPI_JSAPI_002
* @tc.name Test setDensityDpiTest2 * @tc.name Test setDensityDpiTest2
* @tc.desc Verify Sets the screen pixel * @tc.desc Verify Sets the screen pixel
*/ */
it('setDensityDpiTest2', 0, async function (done) { it('setDensityDpiTest2', 0, async function (done) {
let caseName = 'setDensityDpiTest2'; let caseName = 'setDensityDpiTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1437,8 +1853,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1437,8 +1853,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(errScreen, caseName, 'screenManager.getAllScreen', done); unexpectedError(errScreen, caseName, 'screenManager.getAllScreen', done);
}) })
console.log(msgStr + 'screenManager.getAllScreen' + JSON.stringify(screens)); console.log(msgStr + 'screenManager.getAllScreen' + JSON.stringify(screens));
expect(!!screens).assertTrue(); try {
expect(!!screens).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
let currentDeviceDefaultDpi; let currentDeviceDefaultDpi;
let currentDeviceDefault = null; let currentDeviceDefault = null;
display.getDefaultDisplay(async (err, data) => { display.getDefaultDisplay(async (err, data) => {
...@@ -1465,21 +1884,24 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1465,21 +1884,24 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay' + JSON.stringify(result)); console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay' + JSON.stringify(result));
let isEqual = Number(result.densityDPI) == parseInt(dpiItem[i]) let isEqual = Number(result.densityDPI) == parseInt(dpiItem[i])
console.log(msgStr + 'same ? ' + isEqual) console.log(msgStr + 'same ? ' + isEqual)
expect(isEqual).assertTrue() try {
expect(isEqual).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
} }
}) })
}) })
} }
}); });
console.log(msgStr + 'done '); console.log(msgStr + 'done ');
done(); done();
}) })
/** /**
* @tc.number SUB_WINDOW_SETPREFERREDORIENTATION_JSAPI_002 * @tc.number SUB_WINDOW_SETPREFERREDORIENTATION_JSAPI_002
* @tc.name Test setPreferredOrientationTest2 * @tc.name Test setPreferredOrientationTest2
* @tc.desc Sets the display direction property of the window * @tc.desc Sets the display direction property of the window
*/ */
it('setPreferredOrientationTest2', 0, async function (done) { it('setPreferredOrientationTest2', 0, async function (done) {
let caseName = 'setPreferredOrientationTest2'; let caseName = 'setPreferredOrientationTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1488,26 +1910,33 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1488,26 +1910,33 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.getMainWindow', done); 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(); try {
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE']; expect(!!mainWin).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
let num = 0
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', 'UNSPECIFIED'];
for (let i = 0;i < orientationItem.length; i++) { for (let i = 0;i < orientationItem.length; i++) {
await sleep(1000); await sleep(1000);
let orientation = ohosWindow.Orientation[orientationItem[i]] let orientation = ohosWindow.Orientation[orientationItem[i]]
await mainWin.setPreferredOrientation(orientation, (err, data) => { await mainWin.setPreferredOrientation(orientation, (err, data) => {
if (err.code) { if (err && err.code) {
console.log(msgStr + 'window.setPreferredOrientation failed set error' + orientation); console.log(msgStr + 'window.setPreferredOrientation failed set error' + orientation);
} }
num++
if (num == orientationItem.length) done();
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 ');
done();
}) })
/** /**
* @tc.number SUB_WINDOW_SETFORBIDSPLITMOVE_JSAPI_002 * @tc.number SUB_WINDOW_SETFORBIDSPLITMOVE_JSAPI_002
* @tc.name Test setForbidSplitMoveTest2 * @tc.name Test setForbidSplitMoveTest2
* @tc.desc Sets whether Windows are forbidden to move in split screen mode * @tc.desc Sets whether Windows are forbidden to move in split screen mode
*/ */
it('setForbidSplitMoveTest2', 0, async function (done) { it('setForbidSplitMoveTest2', 0, async function (done) {
let caseName = 'setForbidSplitMoveTest2'; let caseName = 'setForbidSplitMoveTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1516,7 +1945,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1516,7 +1945,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.getMainWindow', done); 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(); try {
expect(!!mainWin).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
await mainWin.setForbidSplitMove(true, (err, data) => { await mainWin.setForbidSplitMove(true, (err, data) => {
if (err.code) { if (err.code) {
console.log(msgStr + 'failed set window.setForbidSplitMove drag is prohibited'); console.log(msgStr + 'failed set window.setForbidSplitMove drag is prohibited');
...@@ -1535,10 +1968,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1535,10 +1968,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
done(); done();
}) })
/** /**
* @tc.number SUB_WINDOW_SNAPSHOT_JSAPI_002 * @tc.number SUB_WINDOW_SNAPSHOT_JSAPI_002
* @tc.name Test snapshotTest2 * @tc.name Test snapshotTest2
* @tc.desc Scenario of screenshot of verification window * @tc.desc Scenario of screenshot of verification window
*/ */
it('snapshotTest2', 0, async function (done) { it('snapshotTest2', 0, async function (done) {
let caseName = 'snapshotTest2'; let caseName = 'snapshotTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1547,7 +1980,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1547,7 +1980,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'windowStage.getMainWindow', done); 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(); try {
expect(!!mainWin).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
await mainWin.snapshot((err, data) => { await mainWin.snapshot((err, data) => {
if (err && err.code) { if (err && err.code) {
console.log(msgStr + 'snapshot err.code:' + JSON.stringify(err.code)); console.log(msgStr + 'snapshot err.code:' + JSON.stringify(err.code));
...@@ -1586,17 +2023,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1586,17 +2023,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'ohosWindow.create', done); unexpectedError(err, caseName, 'ohosWindow.create', done);
} else { } else {
let dialogTargetTouchTest2Win = data let dialogTargetTouchTest2Win = data
expect(!!dialogTargetTouchTest2Win).assertTrue(); try {
expect(!!dialogTargetTouchTest2Win).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
dialogTargetTouchTest2Win.destroy(); dialogTargetTouchTest2Win.destroy();
done(); done();
} }
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_ANIMATIONFORSHOWN_JSAPI_002 * @tc.number SUB_WINDOW_ANIMATIONFORSHOWN_JSAPI_002
* @tc.name Test animationForShownTest2 * @tc.name Test animationForShownTest2
* @tc.desc Verify window custom animation configuration of the scene * @tc.desc Verify window custom animation configuration of the scene
*/ */
it('animationForShownTest2', 0, async function (done) { it('animationForShownTest2', 0, async function (done) {
let caseName = 'animationForShownTest2'; let caseName = 'animationForShownTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1610,7 +2051,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1610,7 +2051,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
} else { } else {
tempWnd = data tempWnd = data
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd);
let controller = tempWnd.getTransitionController(); let controller = tempWnd.getTransitionController();
controller.animationForShown = (context: ohosWindow.TransitionContext) => { controller.animationForShown = (context: ohosWindow.TransitionContext) => {
...@@ -1640,16 +2085,20 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1640,16 +2085,20 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
/** /**
* @tc.number SUB_WINDOW_GETCUTOUTINFO_JSAPI_002 * @tc.number SUB_WINDOW_GETCUTOUTINFO_JSAPI_002
* @tc.name Test getCutoutInfoTest2 * @tc.name Test getCutoutInfoTest2
* @tc.desc Obtain information about unavailable screen areas such as the hole screen, fringe screen, and waterfall screen * @tc.desc Obtain information about unavailable screen areas such as the hole screen, fringe screen, and waterfall screen
*/ */
it('getCutoutInfoTest2', 0, async function (done) { it('getCutoutInfoTest2', 0, async function (done) {
let caseName = 'getCutoutInfoTest2'; let caseName = 'getCutoutInfoTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context)); console.log(msgStr + 'begin context==' + JSON.stringify(context));
let dpClass = display.getDefaultDisplaySync(); let dpClass = display.getDefaultDisplaySync();
expect(!!dpClass).assertTrue(); try {
expect(!!dpClass).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
dpClass.getCutoutInfo((err, data) => { dpClass.getCutoutInfo((err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'displayClass.getCutoutInfo', done); unexpectedError(err, caseName, 'displayClass.getCutoutInfo', done);
...@@ -1660,10 +2109,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1660,10 +2109,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_SHOWWITHANIMATION_JSAPI_002 * @tc.number SUB_WINDOW_SHOWWITHANIMATION_JSAPI_002
* @tc.name Test showWithAnimationTest2 * @tc.name Test showWithAnimationTest2
* @tc.desc Displays the current window, playing an animation in the process * @tc.desc Displays the current window, playing an animation in the process
*/ */
it('showWithAnimationTest2', 0, async function (done) { it('showWithAnimationTest2', 0, async function (done) {
let caseName = 'showWithAnimationTest2'; let caseName = 'showWithAnimationTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1676,7 +2125,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1676,7 +2125,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} else { } else {
let tempWnd = data; let tempWnd = data;
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd)); console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
tempWnd.showWithAnimation((error, animationData) => { tempWnd.showWithAnimation((error, animationData) => {
if (error && error.code) { if (error && error.code) {
unexpectedError(error, caseName, 'Failed to show the window with animation', done); unexpectedError(error, caseName, 'Failed to show the window with animation', done);
...@@ -1689,10 +2142,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1689,10 +2142,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_HIDEWITHANIMATION_JSAPI_002 * @tc.number SUB_WINDOW_HIDEWITHANIMATION_JSAPI_002
* @tc.name Test hideWithAnimationTest2 * @tc.name Test hideWithAnimationTest2
* @tc.desc Hide the current window and play an animation in the process * @tc.desc Hide the current window and play an animation in the process
*/ */
it('hideWithAnimationTest2', 0, async function (done) { it('hideWithAnimationTest2', 0, async function (done) {
let caseName = 'hideWithAnimationTest2'; let caseName = 'hideWithAnimationTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
...@@ -1703,7 +2156,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1703,7 +2156,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (creare_err && creare_err.code) { if (creare_err && creare_err.code) {
unexpectedError(creare_err, caseName, 'ohosWindow.create ' + baseType, done); unexpectedError(creare_err, caseName, 'ohosWindow.create ' + baseType, done);
} }
expect(!!tempWnd).assertTrue(); try {
expect(!!tempWnd).assertTrue();
} catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
}
ohosWindow.find(wndId, (findErr, findWnd) => { ohosWindow.find(wndId, (findErr, findWnd) => {
if (findErr && findErr.code) { if (findErr && findErr.code) {
unexpectedError(findErr, caseName, 'Failed to hide the window with animation', done); unexpectedError(findErr, caseName, 'Failed to hide the window with animation', done);
......
...@@ -36,7 +36,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -36,7 +36,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
'TYPE_VOLUME_OVERLAY': 6, 'TYPE_VOLUME_OVERLAY': 6,
'TYPE_NAVIGATION_BAR': 7, 'TYPE_NAVIGATION_BAR': 7,
'TYPE_FLOAT': 8, 'TYPE_FLOAT': 8,
'TYPE_FLOAT_CAMERA':9 'TYPE_FLOAT_CAMERA': 9
} }
var listenerStatus = { var listenerStatus = {
ready: 'ready', ready: 'ready',
...@@ -58,8 +58,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -58,8 +58,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
}) })
afterEach(async function (done) { afterEach(async function (done) {
if (listenerData.on) { if (listenerData.on) {
listenerData.on = false; listenerData.on = false;
console.info('jsunittest afterEach listener off, listenerData:' + JSON.stringify(listenerData)); console.info('jsunittest afterEach listener off, listenerData:' + JSON.stringify(listenerData));
if (listenerData.typeStr === 'systemBarTintChange') { if (listenerData.typeStr === 'systemBarTintChange') {
ohosWindow.off(listenerData.typeStr); ohosWindow.off(listenerData.typeStr);
} else if (newWindowObj) { } else if (newWindowObj) {
...@@ -92,60 +92,68 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -92,60 +92,68 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
listenerData.on = true; listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange'; listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => { ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest1 systemBatData : ' + JSON.stringify(systemBarData)); console.info('setWindowSystemBarPropertiesTest1 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) { if (listenerFlag === listenerStatus.pending) {
expect(!!systemBarData).assertTrue(); try {
expect(!!systemBarData.regionTint).assertTrue(); expect(!!systemBarData).assertTrue();
let arrLength = systemBarData.regionTint.length; expect(!!systemBarData.regionTint).assertTrue();
for (let i = 0; i < arrLength; i++) { } catch (error) {
// 单个导航栏或者系统状态信息 console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
let SystemBarRegionTint = systemBarData.regionTint[i]; }
if (SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR || SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { let arrLength = systemBarData.regionTint.length;
console.info('setWindowSystemBarPropertiesTest1 assert1 start!'); for (let i = 0; i < arrLength; i++) {
let backgroundIndex = cloneColorArr.indexOf(SystemBarRegionTint.backgroundColor); // 单个导航栏或者系统状态信息
let contentColorIndex = cloneColorArr.indexOf(SystemBarRegionTint.contentColor); let SystemBarRegionTint = systemBarData.regionTint[i];
expect(backgroundIndex === -1).assertTrue(); if (SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR || SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
expect(contentColorIndex === -1).assertTrue(); console.info('setWindowSystemBarPropertiesTest1 assert1 start!');
done(); let backgroundIndex = cloneColorArr.indexOf(SystemBarRegionTint.backgroundColor);
} let contentColorIndex = cloneColorArr.indexOf(SystemBarRegionTint.contentColor);
try {
expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
} }
done();
}
} }
}
}) })
console.info('setWindowSystemBarPropertiesTest1 on systemBarTintChange finished'); console.info('setWindowSystemBarPropertiesTest1 on systemBarTintChange finished');
let mainWsync = windowStage.getMainWindowSync(); let mainWsync = windowStage.getMainWindowSync();
expect(mainWsync != null).assertTrue(); expect(mainWsync != null).assertTrue();
await mainWsync.showWindow().catch(err => { await mainWsync.showWindow().catch(err => {
console.info('setWindowSystemBarPropertiesTest1 mainWsync.showWindow() error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest1 mainWsync.showWindow() error : ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
await mainWsync.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => { await mainWsync.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => {
console.info('setWindowSystemBarPropertiesTest1 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest1 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
await sleep(1000); await sleep(1000);
listenerFlag = listenerStatus.pending; listenerFlag = listenerStatus.pending;
let loopCount = commonRGBColorArr.length; let loopCount = commonRGBColorArr.length;
for (let i = 0; i < loopCount; i++) { for (let i = 0; i < loopCount; i++) {
let tempColor = commonRGBColorArr[i]; let tempColor = commonRGBColorArr[i];
let systemBarProperties = { let systemBarProperties = {
statusBarColor: tempColor, statusBarColor: tempColor,
isStatusBarLightIcon: true, isStatusBarLightIcon: true,
statusBarContentColor: tempColor, statusBarContentColor: tempColor,
navigationBarColor: tempColor, navigationBarColor: tempColor,
isNavigationBarLightIcon: false, isNavigationBarLightIcon: false,
navigationContentColor: tempColor, navigationContentColor: tempColor,
}; };
mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => { mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest1 success'); console.info('setWindowSystemBarPropertiesTest1 success');
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info('setWindowSystemBarPropertiesTest1 error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest1 error : ' + JSON.stringify(err));
expect().assertFail() expect().assertFail()
done(); done();
}) })
} }
}) })
...@@ -156,89 +164,101 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -156,89 +164,101 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
*/ */
it('setWindowSystemBarPropertiesTest2', 0, async function (done) { it('setWindowSystemBarPropertiesTest2', 0, async function (done) {
let cloneColorArr = { let cloneColorArr = {
SBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)), SBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
SCC: JSON.parse(JSON.stringify(commonNUMBERColorArr)), SCC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
NBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)), NBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
NCC: JSON.parse(JSON.stringify(commonNUMBERColorArr)) NCC: JSON.parse(JSON.stringify(commonNUMBERColorArr))
}; };
let listenerFlag = listenerStatus.ready; let listenerFlag = listenerStatus.ready;
listenerData.on = true; listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange'; listenerData.typeStr = 'systemBarTintChange';
console.info('setWindowSystemBarPropertiesTest2'); console.info('setWindowSystemBarPropertiesTest2');
ohosWindow.on('systemBarTintChange', (systemBarData) => { ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest2 systemBatData : ' + JSON.stringify(systemBarData)); console.info('setWindowSystemBarPropertiesTest2 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) { if (listenerFlag === listenerStatus.pending) {
// 单个导航栏或者系统状态信息 // 单个导航栏或者系统状态信息
try {
expect(!!systemBarData).assertTrue(); expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue(); expect(!!systemBarData.regionTint).assertTrue();
let arrLength = systemBarData.regionTint.length; } catch (error) {
for (let i = 0; i < arrLength; i++) { console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
let systemBarRegionTint = systemBarData.regionTint[i]; }
if (systemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR) { let arrLength = systemBarData.regionTint.length;
console.info('setWindowSystemBarPropertiesTest2 assert2 start!'); for (let i = 0; i < arrLength; i++) {
let backgroundIndex = cloneColorArr.SBC.indexOf(systemBarRegionTint.backgroundColor); let systemBarRegionTint = systemBarData.regionTint[i];
let contentColorIndex = cloneColorArr.SCC.indexOf(systemBarRegionTint.contentColor); if (systemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR) {
if (backgroundIndex >= 0) { console.info('setWindowSystemBarPropertiesTest2 assert2 start!');
cloneColorArr.SBC.splice(backgroundIndex, 1); let backgroundIndex = cloneColorArr.SBC.indexOf(systemBarRegionTint.backgroundColor);
} let contentColorIndex = cloneColorArr.SCC.indexOf(systemBarRegionTint.contentColor);
if (contentColorIndex >= 0) { if (backgroundIndex >= 0) {
cloneColorArr.SCC.splice(contentColorIndex, 1); cloneColorArr.SBC.splice(backgroundIndex, 1);
} }
expect(backgroundIndex !== -1).assertTrue(); if (contentColorIndex >= 0) {
expect(contentColorIndex !== -1).assertTrue(); cloneColorArr.SCC.splice(contentColorIndex, 1);
done(); }
} else if (systemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { try {
let backgroundIndex = cloneColorArr.NBC.indexOf(systemBarRegionTint.backgroundColor); expect(backgroundIndex !== -1).assertTrue();
let contentColorIndex = cloneColorArr.NCC.indexOf(systemBarRegionTint.contentColor); expect(contentColorIndex !== -1).assertTrue();
if (backgroundIndex >= 0) { } catch (error) {
cloneColorArr.NBC.splice(backgroundIndex, 1); console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
} }
if (contentColorIndex >= 0) { done();
cloneColorArr.NCC.splice(contentColorIndex, 1); } else if (systemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
} let backgroundIndex = cloneColorArr.NBC.indexOf(systemBarRegionTint.backgroundColor);
expect(backgroundIndex !== -1).assertTrue(); let contentColorIndex = cloneColorArr.NCC.indexOf(systemBarRegionTint.contentColor);
expect(contentColorIndex !== -1).assertTrue(); if (backgroundIndex >= 0) {
done(); cloneColorArr.NBC.splice(backgroundIndex, 1);
} }
if (contentColorIndex >= 0) {
cloneColorArr.NCC.splice(contentColorIndex, 1);
}
try {
expect(backgroundIndex !== -1).assertTrue();
expect(contentColorIndex !== -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
done();
} }
}
} }
}) })
console.info('setWindowSystemBarPropertiesTest2 on systemBarTintChange finished'); console.info('setWindowSystemBarPropertiesTest2 on systemBarTintChange finished');
let mainWsync = windowStage.getMainWindowSync(); let mainWsync = windowStage.getMainWindowSync();
expect(mainWsync != null).assertTrue(); expect(mainWsync != null).assertTrue();
await mainWsync.showWindow().catch((err) => { await mainWsync.showWindow().catch((err) => {
console.info('setWindowSystemBarPropertiesTest2 mainWsync.showWindow() error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest2 mainWsync.showWindow() error : ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
await mainWsync.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => { await mainWsync.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => {
console.info('setWindowSystemBarPropertiesTest2 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest2 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
await sleep(1000); await sleep(1000);
listenerFlag = listenerStatus.pending; listenerFlag = listenerStatus.pending;
let loopCount = commonNUMBERColorArr.length; let loopCount = commonNUMBERColorArr.length;
for (let i = 0; i < loopCount; i++) { for (let i = 0; i < loopCount; i++) {
let tempColor = commonNUMBERColorArr[i]; let tempColor = commonNUMBERColorArr[i];
let systemBarProperties = { let systemBarProperties = {
statusBarColor: tempColor, statusBarColor: tempColor,
isStatusBarLightIcon: true, isStatusBarLightIcon: true,
statusBarContentColor: tempColor, statusBarContentColor: tempColor,
navigationBarColor: tempColor, navigationBarColor: tempColor,
isNavigationBarLightIcon: true, isNavigationBarLightIcon: true,
navigationBarContentColor: tempColor, navigationBarContentColor: tempColor,
}; };
mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => { mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest2 success'); console.info('setWindowSystemBarPropertiesTest2 success');
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info('setWindowSystemBarPropertiesTest2 error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest2 error : ' + JSON.stringify(err));
expect().assertFail() expect().assertFail()
done(); done();
}) })
} }
}) })
...@@ -248,64 +268,72 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -248,64 +268,72 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
* @tc.desc Verify the scene where the status bar and navigation bar colors are set as keywords * @tc.desc Verify the scene where the status bar and navigation bar colors are set as keywords
*/ */
it('setWindowSystemBarPropertiesTest3', 0, async function (done) { it('setWindowSystemBarPropertiesTest3', 0, async function (done) {
let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr)); let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr));
let listenerFlag = listenerStatus.ready; let listenerFlag = listenerStatus.ready;
console.info('setWindowSystemBarPropertiesTest3 start'); console.info('setWindowSystemBarPropertiesTest3 start');
listenerData.on = true; listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange'; listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => { ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest3 systemBatData : ' + JSON.stringify(systemBarData)); console.info('setWindowSystemBarPropertiesTest3 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) { if (listenerFlag === listenerStatus.pending) {
expect(!!systemBarData).assertTrue(); try {
expect(!!systemBarData.regionTint).assertTrue(); expect(!!systemBarData).assertTrue();
let arrLength = systemBarData.regionTint.length; expect(!!systemBarData.regionTint).assertTrue();
// 单个导航栏或者系统状态信息 } catch (error) {
for (let i = 0; i < arrLength; i++) { console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
let tempData = systemBarData.regionTint[i]; }
if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { let arrLength = systemBarData.regionTint.length;
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); // 单个导航栏或者系统状态信息
let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); for (let i = 0; i < arrLength; i++) {
expect(backgroundIndex === -1).assertTrue(); let tempData = systemBarData.regionTint[i];
expect(contentColorIndex === -1).assertTrue(); if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
done(); let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
} let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor);
} try {
expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
done();
}
}
} }
}) })
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(tempWnd != null).assertTrue(); expect(tempWnd != null).assertTrue();
await tempWnd.showWindow().catch((err) => { await tempWnd.showWindow().catch((err) => {
console.info('setWindowSystemBarPropertiesTest3 mainWsync.showWindow() error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest3 mainWsync.showWindow() error : ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
await tempWnd.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => { await tempWnd.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => {
console.info('setWindowSystemBarPropertiesTest3 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest3 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
await sleep(1000); await sleep(1000);
listenerFlag = listenerStatus.pending; listenerFlag = listenerStatus.pending;
let loopCount = commonKEYColorArr.length; let loopCount = commonKEYColorArr.length;
for (let i = 0; i < loopCount; i++) { for (let i = 0; i < loopCount; i++) {
let tempColor = commonKEYColorArr[i]; let tempColor = commonKEYColorArr[i];
let systemBarProperties = { let systemBarProperties = {
statusBarColor: tempColor, statusBarColor: tempColor,
isStatusBarLightIcon: true, isStatusBarLightIcon: true,
statusBarContentColor: tempColor, statusBarContentColor: tempColor,
navigationBarColor: tempColor, navigationBarColor: tempColor,
isNavigationBarLightIcon: false, isNavigationBarLightIcon: false,
navigationContentColor: tempColor, navigationContentColor: tempColor,
}; };
tempWnd.setWindowSystemBarProperties(systemBarProperties).then(() => { tempWnd.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest3 success'); console.info('setWindowSystemBarPropertiesTest3 success');
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info('setWindowSystemBarPropertiesTest3 error : ' + JSON.stringify(err)); console.info('setWindowSystemBarPropertiesTest3 error : ' + JSON.stringify(err));
expect().assertFail() expect().assertFail()
done(); done();
}) })
} }
}) })
...@@ -319,9 +347,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -319,9 +347,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
statusBarColor: '#ff00ff', statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00', navigationBarColor: '#00ff00',
isStatusBarLightIcon: true, isStatusBarLightIcon: true,
isNavigationBarLightIcon:false, isNavigationBarLightIcon: false,
statusBarContentColor:'#ffffff', statusBarContentColor: '#ffffff',
navigationBarContentColor:'#00ffff' navigationBarContentColor: '#00ffff'
}; };
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(tempWnd != null).assertTrue(); expect(tempWnd != null).assertTrue();
...@@ -329,19 +357,28 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -329,19 +357,28 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
tempWnd.setWindowSystemBarProperties(SystemBarProperties, (err) => { tempWnd.setWindowSystemBarProperties(SystemBarProperties, (err) => {
console.info('Succeeded in setting the system bar properties.' + JSON.stringify(err)); console.info('Succeeded in setting the system bar properties.' + JSON.stringify(err));
if (err.code) { if (err.code) {
try {
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
done() } catch (error) {
console.info(`tempWnd.setWindowSystemBarProperties catch error: ${JSON.stringify(error)}`)
}
done()
} else { } else {
console.info('Succeeded in setting the system bar properties.'); console.info('Succeeded in setting the system bar properties.');
try {
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); } catch (error) {
} console.info(`tempWnd.setWindowSystemBarProperties catch error: ${JSON.stringify(error)}`)
}
done();
}
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
}) })
/** /**
...@@ -350,27 +387,29 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -350,27 +387,29 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
* @tc.desc To verify the widow isshowing * @tc.desc To verify the widow isshowing
*/ */
it('iswindowShowing_Test_001', 0, async function (done) { it('iswindowShowing_Test_001', 0, async function (done) {
console.info('windowTest isWindowShowing begin'); console.info('windowTest isWindowShowing begin');
let config = {name: "alertWindowshow", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context}; let config = {
ohosWindow.createWindow(config).then(wnd => { name: "alertWindowshow", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context
expect(wnd != null).assertTrue(); };
let isWindowShowing = wnd.isWindowShowing(); ohosWindow.createWindow(config).then(wnd => {
expect(!isWindowShowing).assertTrue(); expect(wnd != null).assertTrue();
wnd.showWindow().then(() => { let isWindowShowing = wnd.isWindowShowing();
let isWindowShowing2 = wnd.isWindowShowing(); expect(!isWindowShowing).assertTrue();
expect(isWindowShowing2).assertTrue(); wnd.showWindow().then(() => {
wnd.destroyWindow(); let isWindowShowing2 = wnd.isWindowShowing();
done(); expect(isWindowShowing2).assertTrue();
}).catch(err => { wnd.destroyWindow();
console.error('Failed to show window1. Cause:' + JSON.stringify(err)); done();
expect().assertFail(); }).catch(err => {
done(); console.error('Failed to show window1. Cause:' + JSON.stringify(err));
}) expect().assertFail();
}).catch(err => { done();
console.error('Failed to create the Windowshow1. Cause:' + JSON.stringify(err)); })
expect().assertFail(); }).catch(err => {
done(); console.error('Failed to create the Windowshow1. Cause:' + JSON.stringify(err));
}) expect().assertFail();
done();
})
}) })
/** /**
* @tc.number SUB_WINDOW_setUIContent_JSAPI_001 * @tc.number SUB_WINDOW_setUIContent_JSAPI_001
...@@ -378,31 +417,34 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -378,31 +417,34 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
* @tc.desc Verify the scenario of loading an existing page * @tc.desc Verify the scenario of loading an existing page
*/ */
it('setUIContentTest1', 0, async function (done) { it('setUIContentTest1', 0, async function (done) {
let config = {name: "alertWindow", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context}; let config = {
try { name: "alertWindow", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context
let promise = ohosWindow.createWindow(config); };
promise.then(win => { try {
console.info('Succeeded in creating the window1. Data:' + JSON.stringify(win)); let promise = ohosWindow.createWindow(config);
expect(win != null); promise.then(win => {
win.setUIContent('pages/second/second').then(() => { console.info('Succeeded in creating the window1. Data:' + JSON.stringify(win));
console.info('setUIContent1 . Cause: success'); expect(win != null);
expect(TRUE_FLAG).assertTrue(); win.setUIContent('pages/second/second').then(() => {
done(); console.info('setUIContent1 . Cause: success');
}).catch(err => { expect(TRUE_FLAG).assertTrue();
console.error('Failed to setUIContent . Cause:' + JSON.stringify(err)); done();
expect().assertFail(); }).catch(err => {
done(); console.error('Failed to setUIContent . Cause:' + JSON.stringify(err));
}); expect().assertFail();
}).catch((err) => { done();
console.error('Failed to create the Window1. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
}); });
} catch (exception) { }).catch((err) => {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the Window1. Cause:' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}; });
} catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
}
;
}) })
/** /**
...@@ -412,7 +454,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -412,7 +454,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
*/ */
it('setUIContentTestCallBack1', 0, async function (done) { it('setUIContentTestCallBack1', 0, async function (done) {
let windowClass = null; let windowClass = null;
let config = {name: "alertWindowcallBack", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context}; let config = {
name: "alertWindowcallBack", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context
};
try { try {
let promise = ohosWindow.createWindow(config); let promise = ohosWindow.createWindow(config);
promise.then(win => { promise.then(win => {
...@@ -436,7 +480,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -436,7 +480,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed callback to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed callback to load the content. Cause:' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}).catch((err) => { }).catch((err) => {
console.error('Failedcaa to create the inner Window2. Cause:' + JSON.stringify(err)); console.error('Failedcaa to create the inner Window2. Cause:' + JSON.stringify(err));
...@@ -447,7 +492,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -447,7 +492,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to create the window2. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the window2. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}) })
...@@ -458,7 +504,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -458,7 +504,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
*/ */
it('setUIContentTest2', 0, async function (done) { it('setUIContentTest2', 0, async function (done) {
let windowClass = null; let windowClass = null;
let config = {name: "alertWindow2", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context}; let config = {
name: "alertWindow2", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context
};
try { try {
let promise = ohosWindow.createWindow(config); let promise = ohosWindow.createWindow(config);
promise.then(win => { promise.then(win => {
...@@ -468,11 +516,11 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -468,11 +516,11 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
// 设置setUIContent // 设置setUIContent
try { try {
let promise = windowClass.setUIContent(null); let promise = windowClass.setUIContent(null);
promise.then(()=> { promise.then(() => {
console.info('Succeeded in loading the content.'); console.info('Succeeded in loading the content.');
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
done() done()
...@@ -481,18 +529,20 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -481,18 +529,20 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to load the content. exception: ' + JSON.stringify(exception)); console.error('Failed to load the content. exception: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
}).catch((err) => { }).catch((err) => {
console.error('Failed to create the inner Window2. Cause:' + JSON.stringify(err)); console.error('Failed to create the inner Window2. Cause:' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to create the window2. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the window2. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}) })
...@@ -502,7 +552,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -502,7 +552,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
* @tc.desc Verify the scene of loading the page with illegal values * @tc.desc Verify the scene of loading the page with illegal values
*/ */
it('setUIContentTest3', 0, async function (done) { it('setUIContentTest3', 0, async function (done) {
let config = {name: "alertWindow3", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context}; let config = {
name: "alertWindow3", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context
};
try { try {
let promise = ohosWindow.createWindow(config); let promise = ohosWindow.createWindow(config);
promise.then(win => { promise.then(win => {
...@@ -527,7 +579,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -527,7 +579,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to create the window3. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the window3. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}) })
/** /**
...@@ -566,25 +619,26 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -566,25 +619,26 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
* @tc.desc To verify that the color space of invaild values is set successfully * @tc.desc To verify that the color space of invaild values is set successfully
*/ */
it('setWindowColorSpace_Test_002', 0, async function (done) { it('setWindowColorSpace_Test_002', 0, async function (done) {
console.info('windowTest setWindowColorSpaceTest2 begin'); console.info('windowTest setWindowColorSpaceTest2 begin');
let wnd = windowStage.getMainWindowSync(); let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
let promise = wnd.setWindowColorSpace(-5); let promise = wnd.setWindowColorSpace(-5);
promise.then(()=> { promise.then(() => {
console.info('Succeeded in setting window2 colorspace.'); console.info('Succeeded in setting window2 colorspace.');
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to set window colorspacecatch2. Cause: ' + JSON.stringify(err)); console.error('Failed to set window colorspacecatch2. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
done(); done();
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window colorspaceexception2. Cause:' + JSON.stringify(exception)); console.error('Failed to set window colorspaceexception2. Cause:' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
}) })
...@@ -607,7 +661,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -607,7 +661,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
expect(windowColorSpace == ohosWindow.ColorSpace.WIDE_GAMUT).assertTrue(); expect(windowColorSpace == ohosWindow.ColorSpace.WIDE_GAMUT).assertTrue();
wnd.isWindowSupportWideGamut((err, data) => { wnd.isWindowSupportWideGamut((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log('windowTest SetWindowColorSpaceTest3 getColorSpace callback fail' + JSON.stringify(err)); console.log('windowTest SetWindowColorSpaceTest3 getColorSpace callback fail' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
} else { } else {
...@@ -625,27 +679,29 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -625,27 +679,29 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
* @tc.desc Set the window background color to red and Default opacity * @tc.desc Set the window background color to red and Default opacity
*/ */
it('setWindowBackgroundColor_Test_001', 0, async function (done) { it('setWindowBackgroundColor_Test_001', 0, async function (done) {
console.info('windowTest01 setWindowBackgroundColorTest1 begin'); console.info('windowTest01 setWindowBackgroundColorTest1 begin');
let wnd = windowStage.getMainWindowSync(); let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
let color = '#00ff33'; let color = '#00ff33';
try { try {
wnd.setWindowBackgroundColor(color); wnd.setWindowBackgroundColor(color);
done(); done();
try { try {
let properties = wnd.getWindowProperties(); let properties = wnd.getWindowProperties();
expect(!properties.isTransparent).assertTrue(); expect(!properties.isTransparent).assertTrue();
done() done()
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the window properties001. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the window properties001. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
} catch (exception) { ;
} catch (exception) {
console.error('Failed to set the background1 color. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the background1 color. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}) })
...@@ -656,27 +712,29 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -656,27 +712,29 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
* @tc.desc Set the window background color to red opaque * @tc.desc Set the window background color to red opaque
*/ */
it('setWindowBackgroundColor_Test_002', 0, async function (done) { it('setWindowBackgroundColor_Test_002', 0, async function (done) {
console.info('windowTest setWindowBackgroundColorTest2 begin'); console.info('windowTest setWindowBackgroundColorTest2 begin');
let wnd = windowStage.getMainWindowSync(); let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
let color = '#ffffff00'; let color = '#ffffff00';
try { try {
wnd.setWindowBackgroundColor(color); wnd.setWindowBackgroundColor(color);
done(); done();
try { try {
let properties = wnd.getWindowProperties(); let properties = wnd.getWindowProperties();
expect(!properties.isTransparent).assertTrue(); expect(!properties.isTransparent).assertTrue();
done() done()
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the window properties002. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the window properties002. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
} catch (exception) { } catch (exception) {
console.error('Failed to set the background2 color. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the background2 color. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}) })
...@@ -702,12 +760,14 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -702,12 +760,14 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to obtain the window properties003. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the window properties003. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
} catch (exception) { } catch (exception) {
console.error('Failed to set the background3 color. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the background3 color. Cause: ' + JSON.stringify(exception));
expect().assertFail(); expect().assertFail();
done(); done();
}; }
;
}) })
/** /**
...@@ -727,7 +787,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -727,7 +787,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to set the background4 color. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the background4 color. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
}) })
/** /**
...@@ -750,12 +811,14 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -750,12 +811,14 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to obtain the window properties005. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the window properties005. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
} catch (exception) { } catch (exception) {
console.error('Failed to set the background5 color. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the background5 color. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
}) })
...@@ -776,7 +839,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -776,7 +839,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to set the background6 color. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the background6 color. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
}) })
/** /**
...@@ -851,11 +915,11 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -851,11 +915,11 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
let brightness = Number.MAX_VALUE; let brightness = Number.MAX_VALUE;
try { try {
let promise = wnd.setWindowBrightness(brightness); let promise = wnd.setWindowBrightness(brightness);
promise.then(()=> { promise.then(() => {
console.info('Succeeded3 in setting the brightness.'); console.info('Succeeded3 in setting the brightness.');
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error('Failed3 to set the brightness. Cause: ' + JSON.stringify(err)); console.error('Failed3 to set the brightness. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
done(); done();
...@@ -864,7 +928,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -864,7 +928,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed3 to set the brightnessexception. Cause: ' + JSON.stringify(exception)); console.error('Failed3 to set the brightnessexception. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
}) })
...@@ -874,7 +939,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -874,7 +939,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
* @tc.desc Set the brightness bar input parameter to number min * @tc.desc Set the brightness bar input parameter to number min
*/ */
it('setWindowBrightness_Test_004', 0, async function (done) { it('setWindowBrightness_Test_004', 0, async function (done) {
console.info('windowTest setWindowBrightnessTest4 begin'); console.info('windowTest setWindowBrightnessTest4 begin');
let wnd = windowStage.getMainWindowSync(); let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
wnd.setWindowBrightness(Number.MIN_VALUE).then(() => { wnd.setWindowBrightness(Number.MIN_VALUE).then(() => {
...@@ -882,9 +947,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -882,9 +947,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}, (err) => { }, (err) => {
console.info('windowTest setWindowBrightnessTest4 setBrightness failed: err' + JSON.stringify(err)); console.info('windowTest setWindowBrightnessTest4 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}) })
}) })
...@@ -900,11 +965,11 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -900,11 +965,11 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
let brightness = 1.1; let brightness = 1.1;
try { try {
let promise = wnd.setWindowBrightness(brightness); let promise = wnd.setWindowBrightness(brightness);
promise.then(()=> { promise.then(() => {
console.info('Succeeded5 in setting the brightness.'); console.info('Succeeded5 in setting the brightness.');
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error('Failed5 to set the brightness. Cause: ' + JSON.stringify(err)); console.error('Failed5 to set the brightness. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
done(); done();
...@@ -913,15 +978,16 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -913,15 +978,16 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed5 to set the brightness. Cause: ' + JSON.stringify(exception)); console.error('Failed5 to set the brightness. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
try { try {
let promise = wnd.setWindowBrightness(-0.5); let promise = wnd.setWindowBrightness(-0.5);
promise.then(()=> { promise.then(() => {
console.info('Succeeded55 in setting the brightness.'); console.info('Succeeded55 in setting the brightness.');
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).catch((err) => {
console.error('Failed55 to set the brightness. Cause: ' + JSON.stringify(err)); console.error('Failed55 to set the brightness. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
done(); done();
...@@ -930,7 +996,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -930,7 +996,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed55 to set the brightness. Cause: ' + JSON.stringify(exception)); console.error('Failed55 to set the brightness. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
}) })
/** /**
...@@ -946,26 +1013,44 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -946,26 +1013,44 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
wnd.setWindowBrightness(1, (err) => { wnd.setWindowBrightness(1, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the brightnesscallback01. Cause: ' + JSON.stringify(err)); console.error('Failed to set the brightnesscallback01. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); try {
expect(err.code).assertEqual(401);
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
expect(TRUE_FLAG).assertTrue(); try {
expect(TRUE_FLAG).assertTrue();
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
try { try {
let properties = wnd.getWindowProperties(); let properties = wnd.getWindowProperties();
expect(properties.brightness).assertEqual(1); try {
expect(properties.brightness).assertEqual(1);
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} catch (exception) { } catch (exception) {
console.error('Failed04 to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error('Failed04 to obtain the window properties. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); try {
expect(exception.code).assertEqual(401);
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
}; }
;
} }
}); });
} catch (exception) { } catch (exception) {
console.error('Failedca02 to set the brightness. Cause: ' + JSON.stringify(exception)); console.error('Failedca02 to set the brightness. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done() done()
}; }
;
}) })
/** /**
...@@ -982,11 +1067,19 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -982,11 +1067,19 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
wnd.setWindowBrightness(brightness, (err) => { wnd.setWindowBrightness(brightness, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the brightnesscallback3. Cause: ' + JSON.stringify(err)); console.error('Failed to set the brightnesscallback3. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); try {
expect(err.code).assertEqual(401);
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.info('windowTest setBrightnessTest3CallBack setBrightness(Number.MAX_VALUE) success '); console.info('windowTest setBrightnessTest3CallBack setBrightness(Number.MAX_VALUE) success ');
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}); });
...@@ -994,7 +1087,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -994,7 +1087,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to set the brightnesscall3CallBack. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the brightnesscall3CallBack. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
}) })
/** /**
...@@ -1010,11 +1104,19 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1010,11 +1104,19 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
wnd.setWindowBrightness(Number.MIN_VALUE, (err) => { wnd.setWindowBrightness(Number.MIN_VALUE, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the brightnesscallback4. Cause: ' + JSON.stringify(err)); console.error('Failed to set the brightnesscallback4. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); try {
expect(err.code).assertEqual(401);
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.info('windowTest setBrightnessTest4CallBack setBrightness(Number.MAX_VALUE) success '); console.info('windowTest setBrightnessTest4CallBack setBrightness(Number.MAX_VALUE) success ');
expect(TRUE_FLAG).assertTrue(); try {
expect(TRUE_FLAG).assertTrue();
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}); });
...@@ -1022,7 +1124,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1022,7 +1124,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to set the brightnesscall4CallBack. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the brightnesscall4CallBack. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
}) })
/** /**
...@@ -1038,11 +1141,19 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1038,11 +1141,19 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
wnd.setWindowBrightness(1.1, (err) => { wnd.setWindowBrightness(1.1, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the brightnesscallback5. Cause: ' + JSON.stringify(err)); console.error('Failed to set the brightnesscallback5. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401); try {
expect(err.code).assertEqual(401);
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.info('windowTest setBrightnessTest5CallBack setBrightness(Number.MAX_VALUE) success '); console.info('windowTest setBrightnessTest5CallBack setBrightness(Number.MAX_VALUE) success ');
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}); });
...@@ -1050,7 +1161,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1050,7 +1161,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to set the brightnesscall5CallBack. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the brightnesscall5CallBack. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
}) })
/** /**
...@@ -1065,20 +1177,36 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1065,20 +1177,36 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
wnd.setWindowFocusable(false, (err, data) => { wnd.setWindowFocusable(false, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
let data = wnd.getWindowProperties(); let data = wnd.getWindowProperties();
expect(!data.focusable).assertTrue(); try {
expect(!data.focusable).assertTrue();
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
wnd.setWindowFocusable(true, (err, data) => { wnd.setWindowFocusable(true, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
let data2 = wnd.getWindowProperties(); let data2 = wnd.getWindowProperties();
expect(data2.focusable).assertTrue(); try {
done(); expect(data2.focusable).assertTrue();
} catch (error) {
console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`)
}
done();
} }
}) })
} }
...@@ -1103,14 +1231,14 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1103,14 +1231,14 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
done(); done();
}, err => { }, err => {
console.info('windowTest setFocusableTest1 setFocusable failed: err' + JSON.stringify(err)); console.info('windowTest setFocusableTest1 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}) })
}, (err) => { }, (err) => {
console.log('windowTest setWinFocusableTest1 setFocusable failed: err' + JSON.stringify(err)); console.log('windowTest setWinFocusableTest1 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}) })
}) })
...@@ -1165,11 +1293,19 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1165,11 +1293,19 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
wnd.setWindowTouchable(true, (err, data) => { wnd.setWindowTouchable(true, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`wnd.setWindowTouchable catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
let data2 = wnd.getWindowProperties(); let data2 = wnd.getWindowProperties();
expect(data2.touchable).assertTrue(); try {
expect(data2.touchable).assertTrue();
} catch (error) {
console.info(`wnd.setWindowTouchable catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
...@@ -1233,12 +1369,20 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1233,12 +1369,20 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
wnd.setWindowKeepScreenOn(true, (err, data) => { wnd.setWindowKeepScreenOn(true, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`wnd.setWindowKeepScreenOn catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.info('success set the screen to be always on. Cause: ' + JSON.stringify(data)); console.info('success set the screen to be always on. Cause: ' + JSON.stringify(data));
let data2 = wnd.getWindowProperties(); let data2 = wnd.getWindowProperties();
expect(data2.isKeepScreenOn).assertTrue(); try {
expect(data2.isKeepScreenOn).assertTrue();
} catch (error) {
console.info(`wnd.setWindowKeepScreenOn catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}) })
...@@ -1300,15 +1444,23 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1300,15 +1444,23 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
let wnd = windowStage.getMainWindowSync(); let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
try { try {
wnd.setWindowPrivacyMode(true, (err) => { wnd.setWindowPrivacyMode(true, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
expect().assertFail(); try {
expect().assertFail();
} catch (error) {
console.info(`wnd.setWindowPrivacyMode catch error: ${JSON.stringify(error)}`)
}
done(); done();
} else { } else {
console.info('Succeeded in setting the window to privacy mode.'); console.info('Succeeded in setting the window to privacy mode.');
let data2 = wnd.getWindowProperties(); let data2 = wnd.getWindowProperties();
expect(data2.isPrivacyMode).assertTrue(); try {
expect(data2.isPrivacyMode).assertTrue();
} catch (error) {
console.info(`wnd.setWindowPrivacyMode catch error: ${JSON.stringify(error)}`)
}
done(); done();
} }
}); });
...@@ -1316,7 +1468,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -1316,7 +1468,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
expect(exception.code).assertEqual(401); expect(exception.code).assertEqual(401);
done(); done();
}; }
;
}) })
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册