diff --git a/graphic/windowStage/entry/src/main/ets/MainAbility/pages/second/pageTwo.ets b/graphic/windowStage/entry/src/main/ets/MainAbility/pages/second/pageTwo.ets index 6e9b5db3506869218dfb214411685455042f803a..b276339f21bfd8381bffada8f8a7ad88afabf8e2 100644 --- a/graphic/windowStage/entry/src/main/ets/MainAbility/pages/second/pageTwo.ets +++ b/graphic/windowStage/entry/src/main/ets/MainAbility/pages/second/pageTwo.ets @@ -19,7 +19,7 @@ struct PageTwo { build() { Row(){ - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { Text(`${this.content}`) .fontSize(50) .fontWeight(FontWeight.Bold) diff --git a/graphic/windowStage/entry/src/main/ets/test/parameterVerificationIsOptional.test.ets b/graphic/windowStage/entry/src/main/ets/test/parameterVerificationIsOptional.test.ets index c9ffea22b80ab1d6f57ec93cf08a451889e6239b..941a5b06fb61c343b6f8f1ab2304973464ae107d 100644 --- a/graphic/windowStage/entry/src/main/ets/test/parameterVerificationIsOptional.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/parameterVerificationIsOptional.test.ets @@ -336,142 +336,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) done(); } }) - /** - * @tc.number SUB_WINDOW_WINDOWOFFKEYBOARDHEIGHTCHANGE_JSAPI_001 - * @tc.name Test window_off_keyboardHeightChange_Test_001 - * @tc.desc Turn off listening for keyboard height changes - */ - it('window_off_keyboardHeightChange_Test_001', 0, async function (done) { - let caseName = 'window_off_keyboardHeightChange_Test_001'; - let msgStr = 'jsunittest ' + caseName + ' '; - console.log(msgStr + 'begin'); - let firstListenFlag = false - let secondListenFlag = false - let windowId = 'window_off_keyboardHeightChange_Test_001'; - let windowConfig = { - name: windowId, windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context - }; - let tempWnd = null; - tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); - }); - expect(!!tempWnd).assertTrue(); - await tempWnd.loadContent('MainAbility/pages/second/pageTwo').catch((err) => { - unexpectedError(err, caseName, 'tempWnd.loadContent', done); - }); - await tempWnd.resize(800, 800).catch((err) => { - unexpectedError(err, caseName, 'tempWnd.resetSize', done); - }); - await tempWnd.moveWindowTo(100, 100).catch((err) => { - unexpectedError(err, caseName, 'tempWnd.moveWindowTo ', done); - }); - await tempWnd.showWindow().catch((err) => { - unexpectedError(err, caseName, 'tempWnd.showWindow', done); - }); - tempWnd.on('keyboardHeightChange', (data) => { - console.info(msgStr + "first listener trigger"); - firstListenFlag = true - }); - tempWnd.on('keyboardHeightChange', (data) => { - console.info(msgStr + "second listener trigger"); - secondListenFlag = true - }); - await inputClick('pageTwoinput', msgStr).catch(async err => { - console.info(msgStr + err); - await tempWnd.destroyWindow(); - expect(TRUE_FLAG).assertFail(); - done(); - }) - await sleep(1000); - tempWnd.off('keyboardHeightChange'); - firstListenFlag = false - secondListenFlag = false - await inputClick('pageTwoinputSecond', msgStr).catch(async err => { - console.info(msgStr + err); - await tempWnd.destroyWindow(); - expect(TRUE_FLAG).assertFail(); - done(); - }) - await sleep(2000); - if (firstListenFlag === false && secondListenFlag === false) { - await tempWnd.destroyWindow(); - done(); - } - }) - /** - * @tc.number SUB_WINDOW_WINDOWOFFKEYBOARDHEIGHTCHANGE_JSAPI_002 - * @tc.name Test window_off_keyboardHeightChange_Test_002 - * @tc.desc Turn off listening for keyboard height changes - */ - it('window_off_keyboardHeightChange_Test_002', 0, async function (done) { - let caseName = 'window_off_keyboardHeightChange_Test_002'; - let msgStr = 'jsunittest ' + caseName + ' '; - console.log(msgStr + 'begin'); - let firstListenFlag = false - let secondListenFlag = false - - function firstCall() { - console.log(msgStr + "first listener trigger") - firstListenFlag = true - } - - function secondCall() { - console.log(msgStr + "second listener trigger") - secondListenFlag = true - } - - let windowId = 'window_off_keyboardHeightChange_Test_002'; - let windowConfig = { - name: windowId, windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context - }; - let tempWnd = null; - tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); - }); - expect(!!tempWnd).assertTrue(); - await tempWnd.loadContent('MainAbility/pages/second/pageTwo').catch((err) => { - unexpectedError(err, caseName, 'tempWnd.loadContent', done); - }); - await tempWnd.resize(800, 800).catch((err) => { - unexpectedError(err, caseName, 'tempWnd.resetSize', done); - }); - await tempWnd.moveWindowTo(100, 100).catch((err) => { - unexpectedError(err, caseName, 'tempWnd.moveWindowTo ', done); - }); - await tempWnd.showWindow().catch((err) => { - unexpectedError(err, caseName, 'tempWnd.showWindow', done); - }); - tempWnd.on('keyboardHeightChange', firstCall); - tempWnd.on('keyboardHeightChange', secondCall); - await inputClick('pageTwoinput', msgStr).catch(async err => { - console.info(msgStr + err); - await tempWnd.destroyWindow(); - expect(TRUE_FLAG).assertFail(); - done(); - }) - await sleep(1000); - tempWnd.off('keyboardHeightChange', firstCall); - firstListenFlag = false - secondListenFlag = false - await inputClick('pageTwoinputSecond', msgStr).catch(async err => { - console.info(msgStr + err); - await tempWnd.destroyWindow(); - expect(TRUE_FLAG).assertFail(); - done(); - }) - await sleep(2000); - if (!firstListenFlag && secondListenFlag) { - tempWnd.off('keyboardHeightChange'); - await tempWnd.destroyWindow(); - done(); - } else { - tempWnd.off('keyboardHeightChange'); - await tempWnd.destroyWindow(); - expect(TRUE_FLAG).assertFail(); - done(); - } - }) - /** * @tc.number SUB_WINDOW_WINDOWOFFSCREENSHOT_JSAPI_001 * @tc.name Test window_off_screenshot_Test_001 @@ -744,6 +608,141 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) done(); } }) + /** + * @tc.number SUB_WINDOW_WINDOWOFFKEYBOARDHEIGHTCHANGE_JSAPI_001 + * @tc.name Test window_off_keyboardHeightChange_Test_001 + * @tc.desc Turn off listening for keyboard height changes + */ + it('window_off_keyboardHeightChange_Test_001', 0, async function (done) { + let caseName = 'window_off_keyboardHeightChange_Test_001'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let firstListenFlag = false + let secondListenFlag = false + let windowId = 'window_off_keyboardHeightChange_Test_001'; + let windowConfig = { + name: windowId, windowType: ohosWindow.WindowType.TYPE_DIALOG, ctx: context + }; + let tempWnd = null; + tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + expect(!!tempWnd).assertTrue(); + await tempWnd.loadContent('MainAbility/pages/second/pageTwo').catch((err) => { + unexpectedError(err, caseName, 'tempWnd.loadContent', done); + }); + await tempWnd.resize(800, 1000).catch((err) => { + unexpectedError(err, caseName, 'tempWnd.resetSize', done); + }); + await tempWnd.moveWindowTo(0, 0).catch((err) => { + unexpectedError(err, caseName, 'tempWnd.moveWindowTo ', done); + }); + await tempWnd.showWindow().catch((err) => { + unexpectedError(err, caseName, 'tempWnd.showWindow', done); + }); + tempWnd.on('keyboardHeightChange', (data) => { + console.info(msgStr + "first listener trigger"); + firstListenFlag = true + }); + tempWnd.on('keyboardHeightChange', (data) => { + console.info(msgStr + "second listener trigger"); + secondListenFlag = true + }); + await inputClick('pageTwoinput', msgStr).catch(async err => { + console.info(msgStr + err); + await tempWnd.destroyWindow(); + expect(TRUE_FLAG).assertFail(); + done(); + }) + await sleep(1000); + tempWnd.off('keyboardHeightChange'); + firstListenFlag = false + secondListenFlag = false + await inputClick('pageTwoinputSecond', msgStr).catch(async err => { + console.info(msgStr + err); + await tempWnd.destroyWindow(); + expect(TRUE_FLAG).assertFail(); + done(); + }) + await sleep(2000); + if (firstListenFlag === false && secondListenFlag === false) { + await tempWnd.destroyWindow(); + done(); + } + }) + /** + * @tc.number SUB_WINDOW_WINDOWOFFKEYBOARDHEIGHTCHANGE_JSAPI_002 + * @tc.name Test window_off_keyboardHeightChange_Test_002 + * @tc.desc Turn off listening for keyboard height changes + */ + it('window_off_keyboardHeightChange_Test_002', 0, async function (done) { + let caseName = 'window_off_keyboardHeightChange_Test_002'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let firstListenFlag = false + let secondListenFlag = false + + function firstCall() { + console.log(msgStr + "first listener trigger") + firstListenFlag = true + } + + function secondCall() { + console.log(msgStr + "second listener trigger") + secondListenFlag = true + } + + let windowId = 'window_off_keyboardHeightChange_Test_002'; + let windowConfig = { + name: windowId, windowType: ohosWindow.WindowType.TYPE_DIALOG, ctx: context + }; + let tempWnd = null; + tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + expect(!!tempWnd).assertTrue(); + await tempWnd.loadContent('MainAbility/pages/second/pageTwo').catch((err) => { + unexpectedError(err, caseName, 'tempWnd.loadContent', done); + }); + await tempWnd.resize(800, 1000).catch((err) => { + unexpectedError(err, caseName, 'tempWnd.resetSize', done); + }); + await tempWnd.moveWindowTo(0, 0).catch((err) => { + unexpectedError(err, caseName, 'tempWnd.moveWindowTo ', done); + }); + await tempWnd.showWindow().catch((err) => { + unexpectedError(err, caseName, 'tempWnd.showWindow', done); + }); + tempWnd.on('keyboardHeightChange', firstCall); + tempWnd.on('keyboardHeightChange', secondCall); + await inputClick('pageTwoinput', msgStr).catch(async err => { + console.info(msgStr + err); + await tempWnd.destroyWindow(); + expect(TRUE_FLAG).assertFail(); + done(); + }) + await sleep(1000); + tempWnd.off('keyboardHeightChange', firstCall); + firstListenFlag = false + secondListenFlag = false + await inputClick('pageTwoinputSecond', msgStr).catch(async err => { + console.info(msgStr + err); + await tempWnd.destroyWindow(); + expect(TRUE_FLAG).assertFail(); + done(); + }) + await sleep(2000); + if (!firstListenFlag && secondListenFlag) { + tempWnd.off('keyboardHeightChange'); + await tempWnd.destroyWindow(); + done(); + } else { + tempWnd.off('keyboardHeightChange'); + await tempWnd.destroyWindow(); + expect(TRUE_FLAG).assertFail(); + done(); + } + }) /** * @tc.number SUB_WINDOW_WINDOWSTAGEOFFWINDOWSTAGEVENT_JSAPI_001 * @tc.name Test windowStage_off_windowStageEvent_Test_001