From 156f18f6fbf5311c53721a1af0aa2d9ba2517905 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: Wed, 24 Aug 2022 17:53:16 +0800 Subject: [PATCH] add new testCases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 华华小仙女 --- .../src/main/ets/test/windowCallback.test.ets | 81 +++++++++++++++++++ .../src/main/ets/test/windowPromise.test.ets | 73 +++++++++++++++++ 2 files changed, 154 insertions(+) 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 076dce5c9..30b76cdf5 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets @@ -1580,5 +1580,86 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) }); }) + /** + * @tc.number SUB_WINDOW_GETCUTOUTINFO_JSAPI_002 + * @tc.name Test getCutoutInfoTest2 + * @tc.desc Obtain information about unavailable screen areas such as the hole screen, fringe screen, and waterfall screen + */ + it('getCutoutInfoTest2', 0, async function (done) { + let caseName = 'getCutoutInfoTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin context==' + JSON.stringify(context)); + let dpClass = display.getDefaultDisplaySync(); + expect(!!dpClass).assertTrue(); + dpClass.getCutoutInfo((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'displayClass.getCutoutInfo', done); + }else{ + console.info(msgStr+'Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); + done(); + } + }) + }) + /** + * @tc.number SUB_WINDOW_SHOWWITHANIMATION_JSAPI_002 + * @tc.name Test showWithAnimationTest2 + * @tc.desc Displays the current window, playing an animation in the process + */ + it('showWithAnimationTest2', 0, async function (done) { + let caseName = 'showWithAnimationTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin context==' + JSON.stringify(context)); + let wndId = 'showWithAnimationTest2'; + let baseType = ohosWindow.WindowType.TYPE_FLOAT; + ohosWindow.create(context, wndId, baseType, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); + } else { + let tempWnd=data; + console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd)); + expect(!!tempWnd).assertTrue(); + tempWnd.showWithAnimation((error, animationData) => { + if (error && error.code) { + unexpectedError(error, caseName, 'Failed to show the window with animation', done); + }else { + console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(animationData)); + done(); + } + }) + } + }) + }) + /** + * @tc.number SUB_WINDOW_HIDEWITHANIMATION_JSAPI_002 + * @tc.name Test hideWithAnimationTest2 + * @tc.desc Hide the current window and play an animation in the process + */ + it('hideWithAnimationTest2', 0, async function (done) { + let caseName = 'hideWithAnimationTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin context==' + JSON.stringify(context)); + let wndId = 'hideWithAnimationTest2'; + let baseType = ohosWindow.WindowType.TYPE_FLOAT; + ohosWindow.create(context, wndId, baseType, (creare_err, tempWnd) => { + if (creare_err && creare_err.code) { + unexpectedError(creare_err, caseName, 'ohosWindow.create ' + baseType, done); + } + expect(!!tempWnd).assertTrue(); + ohosWindow.find(wndId, (findErr, findWnd) => { + if (findErr && findErr.code) { + unexpectedError(findErr, caseName, 'Failed to hide the window with animation', done); + }else { + findWnd.hideWithAnimation((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'Failed to hide the window with animation', done); + }else { + console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); + done(); + } + }) + } + }) + }) + }) }) } 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 c53a7905e..80d873a95 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets @@ -1483,5 +1483,78 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) } done(); }) + /** + * @tc.number SUB_WINDOW_GETCUTOUTINFO_JSAPI_001 + * @tc.name Test getCutoutInfoTest1 + * @tc.desc Obtain information about unavailable screen areas such as the hole screen, fringe screen, and waterfall screen + */ + it('getCutoutInfoTest1', 0, async function (done) { + let caseName = 'getCutoutInfoTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin context==' + JSON.stringify(context)); + let dpClass = display.getDefaultDisplaySync(); + expect(!!dpClass).assertTrue(); + dpClass.getCutoutInfo().then((data) => { + console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); + done(); + }).catch(err=>{ + unexpectedError(err, caseName, 'displayClass.getCutoutInfo', done); + }); + }) + /** + * @tc.number SUB_WINDOW_SHOWWITHANIMATION_JSAPI_001 + * @tc.name Test showWithAnimationTest1 + * @tc.desc Displays the current window, playing an animation in the process + */ + it('showWithAnimationTest1', 0, async function (done) { + let caseName = 'showWithAnimationTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin context==' + JSON.stringify(context)); + let wndId = 'showWithAnimationTest1'; + let baseType = ohosWindow.WindowType.TYPE_FLOAT; + let tempWnd = await ohosWindow.create(context,wndId, baseType).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); + }); + console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd)); + expect(!!tempWnd).assertTrue(); + console.info('showWithAnimationTest1 ****' + Reflect.has(tempWnd,'showWithAnimation')) + await tempWnd.showWithAnimation().then((data)=> { + console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); + done(); + }).catch((err)=>{ + unexpectedError(err, caseName, 'Failed to show the window with animation', done); + }) + }) + /** + * @tc.number SUB_WINDOW_HIDEWITHANIMATION_JSAPI_001 + * @tc.name Test hideWithAnimationTest1 + * @tc.desc Hide the current window and play an animation in the process + */ + it('hideWithAnimationTest1', 0, async function (done) { + let caseName = 'hideWithAnimationTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin context==' + JSON.stringify(context)); + let wndId = 'hideWithAnimationTest1'; + let baseType = ohosWindow.WindowType.TYPE_FLOAT; + let tempWnd = await ohosWindow.create(context,wndId, baseType).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); + }); + console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd)); + expect(!!tempWnd).assertTrue(); + let findWnd = await ohosWindow.find(wndId).catch((err) => { + expectedError(err, caseName, 'ohosWindow.find', done); + }); + console.log(msgStr + 'find findWnd: ' + JSON.stringify(findWnd)); + expect(!!findWnd).assertTrue(); + console.info('hideWithAnimationTest1 ****' + Reflect.has(findWnd,'hideWithAnimation')) + console.info('hideWithAnimationTest1 ****' + Reflect.has(findWnd,'destroy')) + let promise = findWnd.hideWithAnimation(); + promise.then((data)=> { + console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); + done(); + }).catch((err)=>{ + console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); + }) + }) }) } -- GitLab