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

优化用例

Signed-off-by: N华华小仙女 <zhurong18@h-partners.com>
上级 7a05eaec
...@@ -1964,14 +1964,14 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ...@@ -1964,14 +1964,14 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta
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 (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length + ' ,tempType:' + tempType);
}
if (sumCount == loopCount.length) done(); if (sumCount == loopCount.length) done();
} }
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length + ' ,tempType:' + tempType);
}
}) })
} 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));
......
...@@ -574,7 +574,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -574,7 +574,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.info(`ohosWindow.on catch error: ${JSON.stringify(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++) { getData(0, arrLength)
function getData(i, length) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
...@@ -587,6 +589,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -587,6 +589,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} catch (error) { } catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
} }
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
} }
} }
} }
...@@ -635,7 +643,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -635,7 +643,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
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
for (let i = 0; i < loopCount; i++) { getData(0, loopCount)
function getData(i, length) {
let tempColor = commonRGBColorArr[i]; let tempColor = commonRGBColorArr[i];
let systemBarProperties = { let systemBarProperties = {
statusBarColor: tempColor, statusBarColor: tempColor,
...@@ -652,8 +662,15 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -652,8 +662,15 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'tempWnd.setSystemBarProperties' + tempColor + ' ', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarProperties' + tempColor + ' ', done);
} }
console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success');
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
}) })
} }
setTimeout(() => { setTimeout(() => {
console.log(msgStr + 'time wait finished. compareCount: ' + compareCount); console.log(msgStr + 'time wait finished. compareCount: ' + compareCount);
listenerFlag = listenerStatus.finished; listenerFlag = listenerStatus.finished;
...@@ -806,7 +823,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -806,7 +823,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
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
for (let i = 0; i < loopCount; i++) { getData(0, loopCount)
function getData(i, length) {
console.log(msgStr+'tempWnd.setSystemBarEnable i:'+i); console.log(msgStr+'tempWnd.setSystemBarEnable i:'+i);
let tempColor = commonNUMBERColorArr[i]; let tempColor = commonNUMBERColorArr[i];
let systemBarProperties = { let systemBarProperties = {
...@@ -827,6 +846,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -827,6 +846,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`) console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`)
} }
} }
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
}) })
} }
}) })
...@@ -858,7 +883,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -858,7 +883,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.info(`ohosWindow.on catch error: ${JSON.stringify(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++) { getData(0, arrLength)
function getData(i, length) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
...@@ -871,6 +898,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -871,6 +898,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} catch (error) { } catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
} }
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
} }
} }
} }
...@@ -919,7 +952,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -919,7 +952,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
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
for (let i = 0; i < loopCount; i++) { getData(0, loopCount)
function getData(i, length) {
let tempColor = commonKEYColorArr[i]; let tempColor = commonKEYColorArr[i];
let systemBarProperties = { let systemBarProperties = {
statusBarColor: tempColor, statusBarColor: tempColor,
...@@ -938,6 +973,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -938,6 +973,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} catch (error) { } catch (error) {
console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`) console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`)
} }
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
done(); done();
} }
}) })
...@@ -963,7 +1004,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -963,7 +1004,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin context==' + JSON.stringify(context)); console.log(msgStr + 'begin context==' + JSON.stringify(context));
let loopCount = appWindowTypeArr.length; let loopCount = appWindowTypeArr.length;
console.log(msgStr + 'loopCount: ' + loopCount); console.log(msgStr + 'loopCount: ' + loopCount);
for (let i = 0; i < loopCount; i++) { getData(0, loopCount)
function getData(i, length) {
let tempType = ohosWindow.WindowType.TYPE_APP; let tempType = ohosWindow.WindowType.TYPE_APP;
let windId = 'createTest5' + i; let windId = 'createTest5' + i;
console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.create ' + tempType + ' start');
...@@ -973,10 +1016,17 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -973,10 +1016,17 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
try { try {
expect(err.code === 1003).assertTrue(); expect(err.code === 1003).assertTrue();
} catch (error) { } catch (error) {
console.info(`ohosWindow.create catch error: ${JSON.stringify(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 < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
if (i === loopCount - 1) { if (i === loopCount - 1) {
done(); done();
} }
...@@ -997,7 +1047,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -997,7 +1047,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let loopCount = systemWindowTypeArr.length; let loopCount = systemWindowTypeArr.length;
console.log('jsunittest loopCount: ' + loopCount); console.log('jsunittest loopCount: ' + loopCount);
for (let i = 0; i < loopCount; i++) { getData(0, loopCount)
function getData(i, length) {
let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let windId = 'createTest6' + i; let windId = 'createTest6' + i;
console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.create ' + tempType + ' start');
...@@ -1030,6 +1082,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1030,6 +1082,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} catch (error) { } catch (error) {
console.info(`tempWnd.getProperties catch error: ${JSON.stringify(error)}`) console.info(`tempWnd.getProperties catch error: ${JSON.stringify(error)}`)
} }
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
}) })
}) })
} }
...@@ -1890,8 +1948,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1890,8 +1948,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
currentDeviceDefault = data; currentDeviceDefault = data;
currentDeviceDefaultDpi = parseInt(currentDeviceDefault.densityDPI) currentDeviceDefaultDpi = parseInt(currentDeviceDefault.densityDPI)
let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300, currentDeviceDefaultDpi]; let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300, currentDeviceDefaultDpi];
for (let i = 0;i < dpiItem.length; i++) { getData(0, dpiItem.length)
await sleep(1000);
function getData(i, length) {
screens[0].setDensityDpi(dpiItem[i], (errDpi, dataDpi) => { screens[0].setDensityDpi(dpiItem[i], (errDpi, dataDpi) => {
if (errDpi.code) { if (errDpi.code) {
console.error('Failed to set DensityDpi. Cause: ' + JSON.stringify(err) + dpiItem[i]); console.error('Failed to set DensityDpi. Cause: ' + JSON.stringify(err) + dpiItem[i]);
...@@ -1910,6 +1969,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1910,6 +1969,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} catch (error) { } catch (error) {
console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`)
} }
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
} }
}) })
}) })
...@@ -1940,14 +2005,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1940,14 +2005,21 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED', let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED',
'LANDSCAPE_INVERTED', 'AUTO_ROTATION', 'AUTO_ROTATION_PORTRAIT', 'AUTO_ROTATION_LANDSCAPE', 'LANDSCAPE_INVERTED', 'AUTO_ROTATION', 'AUTO_ROTATION_PORTRAIT', 'AUTO_ROTATION_LANDSCAPE',
'AUTO_ROTATION_RESTRICTED', 'AUTO_ROTATION_PORTRAIT_RESTRICTED', 'AUTO_ROTATION_LANDSCAPE_RESTRICTED', 'LOCKED', 'UNSPECIFIED']; 'AUTO_ROTATION_RESTRICTED', 'AUTO_ROTATION_PORTRAIT_RESTRICTED', 'AUTO_ROTATION_LANDSCAPE_RESTRICTED', 'LOCKED', 'UNSPECIFIED'];
for (let i = 0;i < orientationItem.length; i++) { getData(0, orientationItem.length)
await sleep(1000);
async function getData(i, length) {
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 && 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++ num++
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
if (num == orientationItem.length) done(); 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));
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册