diff --git a/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets b/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets index d3f32eecfc6aa3b5d2c2edaa5694641ad64f91e4..a76a86e7276b0359540147fc5750d8a7e3800c14 100644 --- a/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets @@ -1964,14 +1964,14 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta 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); + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { console.log(msgStr + 'time wait finished. compareCount: ' + compareCount); listenerFlag = listenerStatus.finished; @@ -806,7 +823,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); listenerFlag = listenerStatus.pending; 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); let tempColor = commonNUMBERColorArr[i]; let systemBarProperties = { @@ -827,6 +846,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) 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++ { if (errDpi.code) { console.error('Failed to set DensityDpi. Cause: ' + JSON.stringify(err) + dpiItem[i]); @@ -1910,6 +1969,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (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++ { if (err && err.code) { console.log(msgStr + 'window.setPreferredOrientation failed set error' + orientation); } num++ + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { @@ -376,11 +378,18 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) tempTypeArr.splice(tempTypeArr.findIndex(item => item === prodata.type), 1); console.log(msgStr + '(loopCount1.length - i): ' + (loopCount1.length - i)); console.log(msgStr + '(tempTypeArr.length + 1): ' + (tempTypeArr.length + 1)); + console.log(msgStr + '(loopCount1.length - 1): ' + (loopCount1.length - 1)); if (i == loopCount1.length - 1) { expect((loopCount1.length - i) == (tempTypeArr.length + 1)).assertTrue(); console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length); - done(); } + if (++i <= length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { +// 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 { +// 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 + ' '; @@ -499,7 +593,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, navigationFlag : ' + JSON.stringify(navigationFlag)); console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending)); }) - /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_002 * @tc.name Test setSystemBarEnableTest2 @@ -520,7 +613,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - for (let i = 0; i < arrLength; i++) { + 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) { @@ -530,6 +625,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) navigationFlag = listenerStatus.finished; expect(tempData.isEnable).assertTrue(); } + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err)); expect(TRUE_FLAG).assertFail(); @@ -817,7 +950,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - for (let i = 0; i < arrLength; i++) { + getData(0, arrLength) + + function getData(i, length) { let tempData = systemBarData.regionTint[i]; if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR) { console.log(msgStr + 'systemBarTintChange compare start!'); @@ -846,6 +981,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(backgroundIndex !== -1).assertTrue(); expect(contentColorIndex !== -1).assertTrue(); } + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err)); expect(TRUE_FLAG).assertFail(); @@ -910,7 +1059,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - for (let i = 0; i < arrLength; i++) { + getData(0, loopCount) + + function getData(i, length) { let tempData = systemBarData.regionTint[i]; console.log(msgStr + 'i=' + i + ' , ohosWindow.on for=' + JSON.stringify(tempData)); if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { @@ -920,6 +1071,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); expect(backgroundIndex === -1).assertTrue(); expect(contentColorIndex === -1).assertTrue(); + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err)); expect(TRUE_FLAG).assertFail(); @@ -977,7 +1142,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'begin'); let loopCount = systemWindowTypeDicArr.length; console.log(msgStr + 'loopCount: ' + loopCount); - for (let i = 0; i < loopCount; i++) { + getData(0, loopCount) + + async function getData(i, length) { let tempType = systemWindowTypeDic[systemWindowTypeDicArr[i]]; let windId = 'createTest1' + i; console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); @@ -987,6 +1154,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }); console.log(msgStr + 'ohosWindow.create ' + tempType + 'finished, wnd: ' + tempWnd); expect(!!tempWnd).assertTrue(); + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { - // await ohosWindow.create(context, wndId, baseType).then((data) => { tempWnd = data console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' , wnd: ' + tempWnd); }).catch((err) => { @@ -1262,6 +1442,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }); expect(!!subWindow).assertTrue(); console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow)); + console.log(msgStr + 'windowStage.createSubWindow end !!subWindow=' + !!subWindow); done(); }) /** @@ -1419,7 +1600,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay current device' + JSON.stringify(currentDeviceDefault)); let currentDeviceDefaultDpi = parseInt(currentDeviceDefault.densityDPI) let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300, currentDeviceDefaultDpi]; - for (let i = 0;i < dpiItem.length; i++) { + getData(0, dpiItem.length) + + async function getData(i, length) { await sleep(1000); await screens[0].setDensityDpi(dpiItem[i]).then(async () => { console.log(msgStr + 'screen.setDensityDpi success set DPI ' + dpiItem[i]); @@ -1433,6 +1616,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let isEqual = Number(defaultDpi.densityDPI) == dpiItem[i] console.log(msgStr + 'same ? ' + isEqual) expect(isEqual).assertTrue() + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { console.log(msgStr + 'screen.setDensityDpi failed set DPI error' + dpiItem[i]); }); @@ -1458,13 +1647,21 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) 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++) { + getData(0, orientationItem.length) + + async function getData(i, length) { await sleep(1000); let orientation = ohosWindow.Orientation[orientationItem[i]] console.log(msgStr + 'i : ' + i + ' ,orientation : ' + orientation); console.log(msgStr + 'i : ' + i + ' ,ohosWindow.Orientation : ' + JSON.stringify(ohosWindow.Orientation)); await mainWin.setPreferredOrientation(orientation).then(() => { console.log(msgStr + 'success set window.setPreferredOrientation : ' + orientation); + if (++i < length) { + getData(i, length) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ {