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

优化异步接口用例

Signed-off-by: N华华小仙女 <zhurong18@h-partners.com>
上级 a9821726
......@@ -284,7 +284,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create createWindowObj:' + JSON.stringify(createWindowObj));
let tempWnd = null;
try {
// await ohosWindow.createWindow(createWindowObj).then((data) => {
await ohosWindow.create(context, wndId, baseType).then((data) => {
console.log(msgStr + 'ohosWindow.create data:' + JSON.stringify(data));
tempWnd = data
......@@ -431,91 +430,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
* @tc.name Test setSystemBarEnableTest1
* @tc.desc Verify that the scene shows the status bar and hides the navigation bar
*/
// it('setSystemBarEnableTest1', 0, async function (done) {
// let caseName = 'setSystemBarEnableTest1';
// let msgStr = 'jsunittest ' + caseName + ' ';
// let statusFlag = listenerStatus.ready;
// let navigationFlag = listenerStatus.ready;
// console.log(msgStr + 'begin');
// console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
// let tempWnd = await windowStage.getMainWindow().catch((err) => {
// unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
// });
// console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
// expect(!!tempWnd).assertTrue();
// await tempWnd.show().catch((err) => {
// unexpectedError(err, caseName, 'tempWnd.show', done);
// });
// console.log(msgStr + 'tempWnd.show success');
// await tempWnd.setFullScreen(true).catch((err) => {
// unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
// });
// console.log(msgStr + 'tempWnd.setFullScreen(true) success');
// await tempWnd.setSystemBarEnable(['navigation']).catch((err) => {
// unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([navigation])', done);
// });
// console.log(msgStr + 'tempWnd.setSystemBarEnable([navigation]) success');
// await sleep(1000);
// statusFlag = listenerStatus.pending;
// navigationFlag = listenerStatus.pending;
// if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) {
// console.log(msgStr + 'start on !!!!');
// listenerData.on = true;
// listenerData.typeStr = 'systemBarTintChange';
// ohosWindow.on('systemBarTintChange', (systemBarData) => {
// console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData));
// console.log(msgStr + 'tempWnd.on , statusFlag : ' + JSON.stringify(statusFlag));
// console.log(msgStr + 'tempWnd.on , listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
// console.log(msgStr + 'tempWnd.on , navigationFlag : ' + JSON.stringify(navigationFlag));
// console.log(msgStr + 'tempWnd.on , listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
//
// setTimeout(() => {
// console.log(msgStr + 'tempWnd.on , 3 statusFlag : ' + JSON.stringify(statusFlag));
// console.log(msgStr + 'tempWnd.on , 3 listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
// console.log(msgStr + 'tempWnd.on , 3 navigationFlag : ' + JSON.stringify(navigationFlag));
// console.log(msgStr + 'tempWnd.on , 3 listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
//
// if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) {
// console.log(msgStr + 'systemBarTintChange compare start!');
// expect(!!systemBarData).assertTrue();
// expect(!!systemBarData.regionTint).assertTrue();
// let arrLength = systemBarData.regionTint.length;
// getData(0, arrLength)
//
// function getData(i, length) {
// let tempData = systemBarData.regionTint[i];
// console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable);
// if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) {
// statusFlag = listenerStatus.finished;
// expect(!tempData.isEnable).assertTrue();
// } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR && navigationFlag === listenerStatus.pending) {
// navigationFlag = listenerStatus.finished;
// expect(tempData.isEnable).assertTrue();
// }
// if (++i <setWindowTypeTest1 length) {
// getData(i, length)
// console.log(msgStr + 'jixuzhixing i: ' + i);
// } else {
// console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
// }
// }
// ohosWindow.off('systemBarTintChange');
// }
// done();
// }, 3000)
// })
// }
//
//
// await tempWnd.setSystemBarEnable(['status']).catch((err) => {
// unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status])', done);
// });
// console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success');
// console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, statusFlag : ' + JSON.stringify(statusFlag));
// console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
// console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, navigationFlag : ' + JSON.stringify(navigationFlag));
// console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
// })
it('setSystemBarEnableTest1', 0, async function (done) {
let caseName = 'setSystemBarEnableTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
......
......@@ -16,7 +16,6 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import ohosWindow from '@ohos.window';
export default function windowRefactorInterfaceTest(context, windowStage, abilityStorage) {
console.info('windowTest context: ' + JSON.stringify(context))
console.info('windowTest abilityStorage: ' + JSON.stringify(abilityStorage))
......@@ -88,6 +87,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
it('setWindowSystemBarPropertiesTest1', 0, async function (done) {
let cloneColorArr = JSON.parse(JSON.stringify(commonRGBColorArr));
let listenerFlag = listenerStatus.ready;
let caseName = 'setWindowSystemBarPropertiesTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.info('setWindowSystemBarPropertiesTest1');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
......@@ -101,7 +102,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) {
getData(0, arrLength)
function getData(i, length) {
// 单个导航栏或者系统状态信息
let SystemBarRegionTint = systemBarData.regionTint[i];
if (SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR || SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
......@@ -114,6 +117,12 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
} catch (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);
}
done();
}
}
......@@ -135,7 +144,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
await sleep(1000);
listenerFlag = listenerStatus.pending;
let loopCount = commonRGBColorArr.length;
for (let i = 0; i < loopCount; i++) {
getData(0, loopCount)
function getData(i, length) {
let tempColor = commonRGBColorArr[i];
let systemBarProperties = {
statusBarColor: tempColor,
......@@ -148,6 +159,12 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest1 success');
expect(TRUE_FLAG).assertTrue();
if (++i < length) {
getData(i, length)
console.log(msgStr+'jixuzhixing i: ' + i);
} else {
console.log(msgStr+'i++<length i: ' + i + ' ,length:' + length);
}
done();
}).catch(err => {
console.info('setWindowSystemBarPropertiesTest1 error : ' + JSON.stringify(err));
......@@ -172,6 +189,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
let listenerFlag = listenerStatus.ready;
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
let caseName = 'setWindowSystemBarPropertiesTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
console.info('setWindowSystemBarPropertiesTest2');
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest2 systemBatData : ' + JSON.stringify(systemBarData));
......@@ -240,7 +259,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
await sleep(1000);
listenerFlag = listenerStatus.pending;
let loopCount = commonNUMBERColorArr.length;
for (let i = 0; i < loopCount; i++) {
getData(0, loopCount)
function getData(i, length) {
let tempColor = commonNUMBERColorArr[i];
let systemBarProperties = {
statusBarColor: tempColor,
......@@ -252,6 +273,12 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
};
mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest2 success');
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
expect(TRUE_FLAG).assertTrue();
done();
}).catch(err => {
......@@ -270,6 +297,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
it('setWindowSystemBarPropertiesTest3', 0, async function (done) {
let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr));
let listenerFlag = listenerStatus.ready;
let caseName = 'setWindowSystemBarPropertiesTest3';
let msgStr = 'jsunittest ' + caseName + ' ';
console.info('setWindowSystemBarPropertiesTest3 start');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
......@@ -315,7 +344,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
await sleep(1000);
listenerFlag = listenerStatus.pending;
let loopCount = commonKEYColorArr.length;
for (let i = 0; i < loopCount; i++) {
getData(0, loopCount)
function getData(i, length) {
let tempColor = commonKEYColorArr[i];
let systemBarProperties = {
statusBarColor: tempColor,
......@@ -327,6 +358,12 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
};
tempWnd.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest3 success');
if (++i < length) {
getData(i, length)
console.log(msgStr + 'jixuzhixing i: ' + i);
} else {
console.log(msgStr + 'i++<length i: ' + i + ' ,length:' + length);
}
expect(TRUE_FLAG).assertTrue();
done();
}).catch(err => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册