From 5259bed579c6d92d8aedefb1b764063077ce231f Mon Sep 17 00:00:00 2001 From: hk_js Date: Fri, 5 Aug 2022 18:07:00 +0800 Subject: [PATCH] fix the compile error about window system Signed-off-by: hk_js --- graphic/windowStage/BUILD.gn | 2 + .../src/main/ets/MainAbility/MainAbility.ts | 1 - .../src/main/ets/test/windowCallback.test.ets | 129 +----------------- .../src/main/ets/test/windowPromise.test.ets | 7 +- 4 files changed, 7 insertions(+), 132 deletions(-) diff --git a/graphic/windowStage/BUILD.gn b/graphic/windowStage/BUILD.gn index 2b4e17dfc..bd608133e 100644 --- a/graphic/windowStage/BUILD.gn +++ b/graphic/windowStage/BUILD.gn @@ -23,6 +23,8 @@ ohos_js_hap_suite("ActsWindowStageTest") { ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" hap_name = "ActsWindowStageTest" + subsystem_name = "window" + part_name = "window_manager" } ohos_app_scope("windowStage_app_profile") { diff --git a/graphic/windowStage/entry/src/main/ets/MainAbility/MainAbility.ts b/graphic/windowStage/entry/src/main/ets/MainAbility/MainAbility.ts index a0946c604..c3b2b245c 100644 --- a/graphic/windowStage/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/graphic/windowStage/entry/src/main/ets/MainAbility/MainAbility.ts @@ -16,7 +16,6 @@ export default class MainAbility extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage) globalThis.windowStage = windowStage - globalThis.abilityStorage = this.storage globalThis.abilityContext = this.context windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } diff --git a/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets b/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets index 3e6c161ac..d8db238c5 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets @@ -520,134 +520,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) }) }) }) - /** - * @tc.number SUB_WINDOW_SETSYSTEMBARPROPERTIES_JSAPI_005 - * @tc.name Test setSystemBarPropertiesTest5 - * @tc.desc Verify the scene where the status bar and navigation bar colors are set in hexadecimal form - */ - it('setSystemBarPropertiesTest5', 0, done => { - let caseName = 'setSystemBarPropertiesTest5'; - let msgStr = 'jsunittest ' + caseName + ' '; - let cloneColorArr = { - SBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)), - SCC: JSON.parse(JSON.stringify(commonNUMBERColorArr)), - NBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)), - NCC: JSON.parse(JSON.stringify(commonNUMBERColorArr)) - }; - let compareCount = 0; - let endNum = 0; - let listenerFlag = listenerStatus.ready; - console.log(msgStr + 'begin'); - listenerData.on = true; - listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systemBarData) => { - console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); - if (listenerFlag === listenerStatus.pending) { - expect(!!systemBarData).assertTrue(); - expect(!!systemBarData.regionTint).assertTrue(); - let arrLength = systemBarData.regionTint.length; - for (let i = 0; i < arrLength; i++) { - let tempData = systemBarData.regionTint[i]; - if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR) { - console.log(msgStr + 'systemBarTintChange compare start! arrLength= ' + arrLength); - compareCount++; - let backgroundIndex = cloneColorArr.SBC.indexOf(tempData.backgroundColor); - let contentColorIndex = cloneColorArr.SCC.indexOf(tempData.contentColor); - if (backgroundIndex >= 0) { - cloneColorArr.SBC.splice(backgroundIndex, 1); - }else{ - console.log(msgStr + 'SBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor)); - } - if (contentColorIndex >= 0) { - cloneColorArr.SCC.splice(contentColorIndex, 1); - }else{ - console.log(msgStr + 'SCC tempData.contentColor:' + JSON.stringify(tempData.contentColor)); - } - console.log(msgStr + 'compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.SCC.length) + ' ,cloneColorArr.SBC:' + JSON.stringify(cloneColorArr.SBC)); - console.log(msgStr + 'compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.SCC.length) + ' ,cloneColorArr.SCC' + JSON.stringify(cloneColorArr.SCC)); - } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { - console.log(msgStr + 'systemBarTintChange compare start!'); - compareCount++; - let backgroundIndex = cloneColorArr.NBC.indexOf(tempData.backgroundColor); - let contentColorIndex = cloneColorArr.NCC.indexOf(tempData.contentColor); - if (backgroundIndex >= 0) { - cloneColorArr.NBC.splice(backgroundIndex, 1); - } else { - console.log(msgStr + 'NBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor)); - } - if (contentColorIndex >= 0) { - cloneColorArr.NCC.splice(contentColorIndex, 1); - } else { - console.log(msgStr + 'NCC tempData.contentColor:' + JSON.stringify(tempData.contentColor)); - } - let ca = cloneColorArr; - let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length - if (compareCount === 18 && !flag) { - console.log(msgStr + 'compareCount: ' + compareCount + ' ,true flag:' + flag); - expect(true).assertTrue(); - done(); - } else { - console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag); - } - console.log(msgStr + 'compareCount: ' + endNum + ' ,compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.NBC.length) + ' ,cloneColorArr.SBC:' + JSON.stringify(cloneColorArr.NBC)); - console.log(msgStr + 'compareCount: ' + endNum + ' ,compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.NCC.length) + ' ,cloneColorArr.SCC' + JSON.stringify(cloneColorArr.NCC)); - endNum = compareCount - } - } - } - }) - console.log(msgStr + 'tempWnd.on systemBarTintChange finished'); - windowStage.getMainWindow((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'windowStage.getMainWindow', done); - } - let tempWnd = data - expect(!!tempWnd).assertTrue(); - console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); - tempWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.show', done); - } - expect(!data).assertTrue(); - console.log(msgStr + 'tempWnd.show success'); - tempWnd.setFullScreen(true, (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); - } - expect(!data).assertTrue(); - console.log(msgStr + 'tempWnd.setFullScreen(true) success'); - tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); - } - expect(!data).assertTrue(); - console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); - listenerFlag = listenerStatus.pending; - let loopCount = commonNUMBERColorArr.length - for (let i = 0; i < loopCount; i++) { - let tempColor = commonNUMBERColorArr[i]; - let systemBarProperties = { - statusBarColor: tempColor, - isStatusBarLightIcon: true, - statusBarContentColor: tempColor, - navigationBarColor: tempColor, - isNavigationBarLightIcon: true, - navigationBarContentColor: tempColor, - }; - tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { - console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); - console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); - if (err && err.code) { - expect(TRUE_FLAG).assertFail(); - done(); - } - }) - } - }) - }) - }) - }) - }) + /** * @tc.number SUB_WINDOW_SETSYSTEMBARPROPERTIES_JSAPI_006 * @tc.name Test setSystemBarPropertiesTest6 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 179dbfafc..bd388319c 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets @@ -1349,7 +1349,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) } console.log(msgStr + 'done '); done(); - }) + }) /** * @tc.number SUB_WINDOW_SETPREFERREDORIENTATION_JSAPI_001 * @tc.name Test setPreferredOrientation @@ -1364,10 +1364,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }); console.log(msgStr + 'windowStage.getMainWindow' + JSON.stringify(mainWin)); expect(!!mainWin).assertTrue(); - let orientationItem = ['UNSPECIFIED','LOCKED','PORTRAIT_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']; + let orientationItem = ['UNSPECIFIED', 'LOCKED', 'PORTRAIT_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']; for (let i = 0;i < orientationItem.length; i++) { await sleep(1000); - let orientation=ohosWindow.Orientation[orientationItem[i]] + let orientation = ohosWindow.Orientation[orientationItem[i]] await mainWin.setPreferredOrientation(orientation).then(() => { console.log(msgStr + 'success set window.setPreferredOrientation ' + orientation); }).catch(err => { @@ -1404,4 +1404,5 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'done '); done(); }) + }) } -- GitLab