From c514e0aa7d9019b74c0a9bd704b6f3bbb018324d Mon Sep 17 00:00:00 2001 From: yaocui Date: Fri, 4 Nov 2022 11:05:36 +0800 Subject: [PATCH] fixed e199890 from https://gitee.com/yaocui_moring/xts_acts/pulls/6365 restore orientation test Signed-off-by: yaocui --- .../entry/src/main/ets/test/windowCallback.test.ets | 11 +++++++---- .../entry/src/main/ets/test/windowPromise.test.ets | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) 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 cd4a0d2fb..cbd39619b 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets @@ -1489,19 +1489,22 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) }); console.log(msgStr + 'windowStage.getMainWindow' + JSON.stringify(mainWin)); expect(!!mainWin).assertTrue(); - let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE']; + let num = 0 + 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++) { await sleep(1000); let orientation = ohosWindow.Orientation[orientationItem[i]] await mainWin.setPreferredOrientation(orientation, (err, data) => { - if (err.code) { + if (err && err.code) { console.log(msgStr + 'window.setPreferredOrientation failed set error' + orientation); } + num++ + if(num == orientationItem.length) done(); console.log(msgStr + 'success set window.setPreferredOrientation ' + orientation + JSON.stringify(data)); }) } - console.log(msgStr + 'done '); - done(); }) /** * @tc.number SUB_WINDOW_SETFORBIDSPLITMOVE_JSAPI_002 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 520dba843..8b6ab078c 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets @@ -1388,7 +1388,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }); console.log(msgStr + 'windowStage.getMainWindow :' + JSON.stringify(mainWin)); expect(!!mainWin).assertTrue(); - let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE']; + let num = 0 + 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++) { await sleep(1000); let orientation = ohosWindow.Orientation[orientationItem[i]] @@ -1396,12 +1399,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'i : ' + i + ' ,ohosWindow.Orientation : ' + JSON.stringify(ohosWindow.Orientation)); await mainWin.setPreferredOrientation(orientation).then(() => { console.log(msgStr + 'success set window.setPreferredOrientation : ' + orientation); + num++ + if(num == orientationItem.length) done(); }).catch(err => { console.log(msgStr + 'window.setPreferredOrientation failed set error:' + orientation); }); } - console.log(msgStr + 'done '); - done(); }) /** * @tc.number SUB_WINDOW_SETFORBIDSPLITMOVE_JSAPI_001 -- GitLab