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 b6e3279a11ba47fc26a961485471ec6a921d54ac..f17fd6b169e368757d947bd3e0f76eb99950abda 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets @@ -115,6 +115,198 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) }, time); }) } + /** + * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007 + * @tc.name Test setSystemBarEnableTest7 + * @tc.desc Verify that the scene hides the status bar and displays the navigation bar. + */ + it('setSystemBarEnableTest7', 0, function (done) { + let caseName = 'setSystemBarEnableTest7'; + let msgStr = 'jsunittest ' + caseName + ' '; + let [flagStatus, flagNav] = [false, false]; + console.log(msgStr + 'begin'); + listenerData.on = true; + listenerData.typeStr = 'systemBarTintChange'; + ohosWindow.on('systemBarTintChange', systembartintstate => { + console.log(msgStr + 'ohosWindow.on systembartintstate :' + JSON.stringify(systembartintstate)); + console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); + if (flagStatus || flagNav) { + console.log(msgStr + 'ohosWindow.on flagStatus || flagNav:'); + expect(!!systembartintstate).assertTrue(); + done(); + } + }) + let mainWnd = null; + console.log(msgStr + 'mainWnd = null') + windowStage.getMainWindow((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + expect(!!data).assertTrue(); + mainWnd = data; + console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); + mainWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.show', done); + } + console.log(msgStr + 'mainWnd.show success'); + expect(!data).assertTrue(); + mainWnd.setFullScreen(true, (err, data) => { + console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done); + } + expect(!data).assertTrue(); + mainWnd.setSystemBarEnable(['status'], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(data)==' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done); + } + flagStatus = true; + expect(!data).assertTrue(); + mainWnd.setSystemBarEnable(['navigation'], (err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navitgation]', done); + } + flagNav = true; + expect(!data).assertTrue(); + }) + }) + }) + }) + }) + console.log(msgStr + 'finished!!'); + }); + /** + * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_008 + * @tc.name Test setSystemBarEnableTest8 + * @tc.desc Verify that the scene displays both the status bar and the navigation bar. + */ + it('setSystemBarEnableTest8', 0, function (done) { + let caseName = 'setSystemBarEnableTest8'; + let msgStr = 'jsunittest ' + caseName + ' '; + let [flagStatus, flagNav] = [false, false]; + console.log(msgStr + 'begin'); + let mainWnd = null; + console.log(msgStr + 'mainWnd = null'); + windowStage.getMainWindow((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + expect(!!data).assertTrue(); + mainWnd = data; + console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); + mainWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.show', done); + } + console.log(msgStr + 'mainWnd.show success'); + expect(!data).assertTrue(); + mainWnd.setFullScreen(true, (err, data) => { + console.log(msgStr + 'mainWnd.setFullScreen: ' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done); + } + expect(!data).assertTrue(); + mainWnd.setSystemBarEnable([], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); + } + expect(!data).assertTrue(); + listenerData.on = true; + listenerData.typeStr = 'systemBarTintChange'; + setTimeout(() => { + ohosWindow.on('systemBarTintChange', systembartintstate => { + console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate)); + console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); + setTimeout(() => { + if (flagStatus || flagNav) { + let enable = systembartintstate.regionTint[0].isEnable + let numType = systembartintstate.regionTint[0].type + console.log(msgStr + 'ohosWindow.on isEnable : ' + JSON.stringify(enable)); + console.log(msgStr + 'ohosWindow.on numType : ' + JSON.stringify(numType)); + + expect(numType === 2112 || enable).assertTrue(); + } + done(); + }, 3000) + }) + }, 2300) + mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status,navigation]', done); + } + flagStatus = true; + flagNav = true; + expect(!data).assertTrue(); + }) + }) + }) + }) + }) + }); + /** + * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_009 + * @tc.name Test setSystemBarEnableTest9 + * @tc.desc Verify that the scene hides both the status bar and the navigation bar. + */ + it('setSystemBarEnableTest9', 0, function (done) { + let caseName = 'setSystemBarEnableTest9'; + let msgStr = 'jsunittest ' + caseName + ' '; + let [flagStatus, flagNav] = [false, false]; + console.log(msgStr + 'begin'); + let mainWnd = null; + console.log(msgStr + 'mainWnd = null'); + windowStage.getMainWindow((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + expect(!!data).assertTrue(); + mainWnd = data; + console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); + mainWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.show', done); + } + console.log(msgStr + 'mainWnd.show success'); + expect(!data).assertTrue(); + mainWnd.setFullScreen(true, (err, data) => { + console.log(msgStr + 'mainWnd.setFullScreen: ' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setFullScreen', done); + } + expect(!data).assertTrue(); + mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable status,navigation JSON.stringify(data)==' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status,navigation]', done); + } + flagStatus = true; + flagNav = true; + expect(!data).assertTrue(); + listenerData.on = true; + listenerData.typeStr = 'systemBarTintChange'; + ohosWindow.on('systemBarTintChange', (systembartintstate) => { + console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate)); + console.log(msgStr + 'ohosWindow.on systemBarTintChange systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); + if (flagStatus || flagNav) { + expect(!!systembartintstate).assertTrue(); + done(); + } + }) + mainWnd.setSystemBarEnable([], (err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); + } + expect(!data).assertTrue(); + // done(); + }) + }) + }) + }) + }) + }); /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_010 * @tc.name Test setSystemBarEnableTest10 @@ -140,7 +332,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.log(msgStr + 'mainWnd.show success'); expect(!data).assertTrue(); mainWnd.setFullScreen(true, (err, data) => { - console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); + console.log(msgStr + 'mainWnd.setFullScreen: ' + JSON.stringify(data)); if (err && err.code) { unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done); } @@ -668,30 +860,36 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) expect(!!tempWnd).assertTrue(); let loopCount1 = systemWindowTypeArr; console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount1)) - for (let i = 1; i < loopCount1.length; i++) { + for (let i = 0; i < loopCount1.length; i++) { let tempType = ohosWindow.WindowType[loopCount1[i]]; console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' start'); tempTypeArr.push(tempType); tempWnd.setWindowType(tempType, (err, data) => { - console.log(msgStr + 'tempWnd.setWindowType err' + JSON.stringify(err)); - console.log(msgStr + 'tempWnd.setWindowType data' + JSON.stringify(data)); - console.log(msgStr + 'tempWnd.setWindowType !!data' + !!data); + console.log(msgStr + 'tempWnd.setWindowType i: ' + i); + console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.setWindowType data: ' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.setWindowType !data: ' + !data); if (!data) { expect(!data).assertTrue(); - tempWnd.getProperties((err, data) => { - console.log(msgStr + 'tempWnd.getProperties err' + JSON.stringify(err)); - console.log(msgStr + 'tempWnd.getProperties data' + JSON.stringify(data)); - console.log(msgStr + 'tempWnd.getProperties !!data' + !!data); - expect(!!data).assertTrue(); - if (!!data) { - tempTypeArr.splice(tempTypeArr.findIndex(item => item === data.type), 1); + console.log(msgStr + 'tempWnd.getProperties start'); + tempWnd.getProperties((err, dataProper) => { + console.log(msgStr + 'tempWnd.getProperties err: ' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.getProperties dataProper: ' + JSON.stringify(dataProper)); + console.log(msgStr + 'tempWnd.getProperties !!dataProper: ' + !!dataProper); + expect(!!dataProper).assertTrue(); + if (!!dataProper) { + console.log(msgStr + 'tempWnd.getProperties true tempTypeArr: ' + JSON.stringify(tempTypeArr)); + console.log(msgStr + 'tempWnd.getProperties true i: ' + i); + tempTypeArr.splice(tempTypeArr.findIndex(item => item === dataProper.type), 1); + console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length: ' + tempTypeArr.length); + console.log(msgStr + 'tempWnd.getProperties true loopCount1.length - i: ' + loopCount1.length - i); expect((loopCount1.length - i) == (tempTypeArr.length + 1)).assertTrue(); if (i == loopCount1.length - 1) { console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length); done(); } } else { - unexpectedError(err, caseName, 'tempWnd.getProperties', done); + unexpectedError(err, caseName, 'tempWnd.getProperties aa', done); } }) } else { @@ -707,10 +905,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) }) /** -* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_004 -* @tc.name Test setWindowTypeTest4 -* @tc.desc Verify the scene of setting illegal window type -*/ + * @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_004 + * @tc.name Test setWindowTypeTest4 + * @tc.desc Verify the scene of setting illegal window type + */ it('setWindowTypeTest4', 0, function (done) { let caseName = 'setWindowTypeTest4'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -809,7 +1007,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) tempWnd.loadContent('pages/index', (err, data) => { console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data)); - console.log(msgStr + 'tempWnd.loadContent !!data' + !!data); + console.log(msgStr + 'tempWnd.loadContent !data' + !data); if (err && err.code) { expectedError(err, caseName, 'tempWnd.loadContent', done); } else { @@ -878,6 +1076,24 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) }); }) /** + * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_010 + * @tc.name Test loadContentTest10 + * @tc.desc Verify the scenario of loading an existing page + */ + it('loadContentTest10', 0, function (done) { + let caseName = 'loadContentTest10'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + windowStage.loadContent(null, (err, data) => { + if (err && err.code) { + expectedError(err, caseName, 'windowStage.loadContent', done, 130); + console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); + } + done(); + }); + console.log(msgStr + 'end'); + }) + /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_011 * @tc.name Test loadContentTest11 * @tc.desc Verify the scenario of loading an existing page @@ -908,7 +1124,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.log(msgStr + 'begin'); windowStage.loadContent(null, abilityStorage, (err, data) => { if (err && err.code) { - expectedError(err, caseName, 'windowStage.loadContent', done,130); + expectedError(err, caseName, 'windowStage.loadContent', done, 130); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); } 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 bd65a049b75e21e88b0251c1224abadc19ff8b4c..07ddaf6e7ae88f75984ad3be61c682b60d721e1a 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets @@ -262,65 +262,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }); console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); }) - /** - * @tc.number SUB_WINDOW_ON_OFF_JSAPI_004 - * @tc.name Test listenerTest4 - * @tc.desc Verify whether the window size change monitoring can be closed normally. - */ - it('listenerTest4', 0, async function (done) { - let caseName = 'listenerTest4'; - let msgStr = 'jsunittest ' + caseName + ' '; - let wndId = 'listenerTest4'; - let baseType = 2; - let changedModel = 102; - let listenerOffFlag = listenerStatus.ready; - console.log(msgStr + 'begin'); - let tempWnd = await ohosWindow.create(context, wndId, baseType).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); - }); - console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd); - expect(!!tempWnd).assertTrue(); - listenerData.on = true; - listenerData.typeStr = 'windowSizeChange'; - tempWnd.on('windowSizeChange', (sizeData) => { - console.log(msgStr + 'tempWnd.on windowSizeChange, sizeData : ' + JSON.stringify(sizeData)); - if (listenerOffFlag === listenerStatus.pending) { - listenerOffFlag = listenerStatus.finished; - unexpectedError(null, caseName, 'off windowSizeChange', done) - } - }) - await tempWnd.show().catch((err) => { - unexpectedError(err, caseName, 'tempWnd.show', done); - }); - console.log(msgStr + 'tempWnd.show success'); - await tempWnd.setWindowMode(changedModel).catch((err) => { - unexpectedError(err, caseName, 'tempWnd.setWindowMode ' + changedModel, done); - }); - console.log(msgStr + 'tempWnd.setWindowMode ' + changedModel + ' success'); - await tempWnd.resetSize(100, 100).catch((err) => { - unexpectedError(err, caseName, 'tempWnd.resetSize(100, 100)', done); - }); - console.log(msgStr + 'tempWnd.resetSize(100, 100) success'); - console.log(msgStr + 'tempWnd.on windowSizeChange finished'); - await sleep(1000); - tempWnd.off('windowSizeChange'); - console.log(msgStr + 'tempWnd.off windowSizeChange finished'); - sleep(1000); - listenerOffFlag = listenerStatus.pending; - await tempWnd.resetSize(200, 200).catch((err) => { - unexpectedError(err, caseName, 'tempWnd.resetSize(200, 200)', done); - }); - console.log(msgStr + 'tempWnd.resetSize(200, 200) success'); - setTimeout(() => { - if (listenerOffFlag === listenerStatus.finished) { - let apiStr = 'tempWnd.off windowSizeChange time wait'; - unexpectedError(null, caseName, apiStr, done); - } else { - console.log(msgStr + 'tempWnd.off windowSizeChange time wait'); - done(); - } - }, 5000) - }) /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_001 * @tc.name Test setSystemBarEnableTest1 @@ -463,12 +404,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([navigation])', done); }); console.log(msgStr + 'tempWnd.setSystemBarEnable([navigation]) success'); - setTimeout(() => { - if (statusFlag !== listenerStatus.finished || navigationFlag !== listenerStatus.finished) { - let apiStr = 'tempWnd.on systemBarTintChange time wait'; - unexpectedError(null, caseName, apiStr, done); - } - }, 5000) }) /** @@ -591,12 +526,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done); }); console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success'); - setTimeout(() => { - if (statusFlag !== listenerStatus.finished || navigationFlag !== listenerStatus.finished) { - let apiStr = 'tempWnd.on systemBarTintChange time wait'; - unexpectedError(null, caseName, apiStr, done); - } - }, 5000) }) /** @@ -706,11 +635,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(TRUE_FLAG).assertFail(); }) } - setTimeout(() => { - console.log(msgStr + 'time wait finished. compareCount: ' + compareCount); - listenerFlag = listenerStatus.finished; - done(); - }, 10000) }) /** @@ -809,16 +733,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(TRUE_FLAG).assertFail(); }) } - setTimeout(() => { - console.log(msgStr + 'time wait finished. compareCount: ' + compareCount); - listenerFlag = listenerStatus.finished; - let ca = cloneColorArr; - if (ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length) { - unexpectedError(null, caseName, ' something compaer failed', done); - } else { - done(); - } - }, 10000) }) /** @@ -927,6 +841,53 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'done '); done(); }) + /** + * @tc.number SUB_WINDOW_CREATE_JSAPI_002 + * @tc.name Test createTest2 + * @tc.desc Verify the scenario of creating the system type window + */ + it('createTest2', 0, async function (done) { + let caseName = 'createTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let loopCount = systemWindowTypeArr.length; + console.log(msgStr + ' loopCount: ' + loopCount); + let n = 0 + for (let i = 0; i < loopCount; i++) { + // for (let i = 0; i < 5; i++) { + let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; + let windId = 'createTest2' + i; + console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); + let createData = await ohosWindow.create(context, windId, tempType).catch((err) => { + console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); + return; + }) + expect(!!createData).assertTrue(); + let tempWnd = createData + console.log(msgStr + 'ohosWindow.create ' + tempType + ' wnd: ' + tempWnd); + let proData = await tempWnd.getProperties().catch((err) => { + console.log(msgStr + 'tempWnd.getProperties err' + JSON.stringify(err)); + unexpectedError(err, caseName, 'tempWnd.getProperties', done); + console.log(msgStr + 'tempWnd.getProperties err&&err.code' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.getProperties success, !!data : ' + !!data); + }) + expect(!!proData).assertTrue(); + expect(proData.type == tempType).assertTrue(); + console.log(msgStr + 'n:' + n); + if (proData.type == tempType) n++ + console.log(msgStr + 'n++:' + n); + console.log(msgStr + 'i:' + i); + if (i + 1 == loopCount) { + if (n === loopCount) { + expect(true).assertTrue(); + } else { + unexpectedError(err, caseName, 'tempWnd.getProperties', done); + } + } + } + done(); + }) /** * @tc.number SUB_WINDOW_CREATE_JSAPI_003 * @tc.name Test createTest3 @@ -946,6 +907,28 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }); }) /** + * @tc.number SUB_WINDOW_CREATE_JSAPI_004 + * @tc.name Test createTest4 + * @tc.desc Verify the scenario of creating a window with duplicate IDs + */ + it('createTest4', 0, async function (done) { + let caseName = 'createTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let windowId = 'sameids' + let ohosData = await ohosWindow.create(context, windowId, 1).catch((err) => { + console.log(msgStr + 'ohosWindow.create 1 once err: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.create', done); + }) + expect(!!ohosData).assertTrue(); + let ohosDataError = await ohosWindow.create(context, windowId, 1).catch((err) => { + console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err)); + expect(err.code).assertEqual(120) + done(); + }) + console.log(msgStr + 'ohosWindow.create 1 twice ohosDataError: ' + JSON.stringify(ohosDataError)); + }) + /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_001 * @tc.name Test loadContentTest1 * @tc.desc Verify the scenario of loading an existing page @@ -1020,6 +1003,22 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) done(); }) /** + * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_004 + * @tc.name Test loadContentTest4 + * @tc.desc Verify the scenario of loading an existing page + */ + it('loadContentTest4', 0, async function (done) { + let caseName = 'loadContentTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let load4 = await windowStage.loadContent(null).catch((err) => { + expectedError(err, caseName, 'tempWnd.loadContent', done, 130); + console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err)); + }); + console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load4)); + done(); + }) + /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_005 * @tc.name Test loadContentTest5 * @tc.desc Verify the scenario of loading an existing page @@ -1083,7 +1082,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err)); }); console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow)); - done(); }) /** * @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_001 @@ -1148,5 +1146,34 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(!lastPro.isPrivacyMode).assertTrue(); done(); }) + /** + * @tc.number SUB_WINDOW_DESTROY_JSAPI_001 + * @tc.name Test destroyTest1 + * @tc.desc Verification window destruction scenario. + */ + it('destroyTest1', 0, async function (done) { + let caseName = 'destroyTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'destroyTest1'; + console.log(msgStr + 'begin'); + let tempWnd = await ohosWindow.create(context, windowId, baseWndType).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.create', done); + }); + console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd); + expect(!!tempWnd).assertTrue(); + console.log(msgStr + 'tempWnd.destroy start'); + await tempWnd.destroy().catch((err) => { + unexpectedError(err, caseName, 'tempWnd.destroy', done); + console.log(msgStr + 'destroy err : ' + JSON.stringify(err)); + }); + console.log(msgStr + 'tempWnd.destroy end'); + let findWnd = await ohosWindow.find(windowId).catch((err) => { + expectedError(err, caseName, 'ohosWindow.find', done, 120); + }); + console.log(msgStr + 'find findWnd: ' + JSON.stringify(findWnd)); + expect(!findWnd).assertTrue(); + done(); + }) }) }