From 31715d36d7c08f1e6ba78c87df4013622675c15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E=E5=8D=8E=E5=B0=8F=E4=BB=99=E5=A5=B3?= Date: Fri, 9 Dec 2022 15:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E6=AD=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 华华小仙女 --- .../src/main/ets/test/windowPromise.test.ets | 86 ------------------- .../ets/test/windowRefactorInterface.test.ets | 47 ++++++++-- 2 files changed, 42 insertions(+), 91 deletions(-) diff --git a/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets b/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets index d03d3e67e..ca987f959 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets @@ -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 { -// 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 + ' '; diff --git a/graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets b/graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets index 006e9d89a..6c8d6bf10 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets @@ -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++ { 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++ { 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++ { @@ -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++ { -- GitLab