diff --git a/graphic/windowStage/entry/src/main/ets/test/List.test.ets b/graphic/windowStage/entry/src/main/ets/test/List.test.ets index 3fbeaf339cac940ddff84f46ac6d881ec8a9491a..a548c635d4584e7ecd7d79f3d4ee38d32e07c4c8 100644 --- a/graphic/windowStage/entry/src/main/ets/test/List.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/List.test.ets @@ -15,9 +15,11 @@ import windowPromiseTest from './windowPromise.test' import windowCallbackTest from './windowCallback.test' import windowRefactorInterfaceTest from './windowRefactorInterface.test' +import displayAndWindowRefactorInterfaceTest from './displayAndWindowRefactorInterface.test' export default function testsuite() { windowCallbackTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) windowPromiseTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) windowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) + displayAndWindowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) } \ No newline at end of file diff --git a/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets b/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3cfd3fddfeefca803db2623593f2abf5ca318825 --- /dev/null +++ b/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets @@ -0,0 +1,1737 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// @ts-nocheck +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import ohosWindow from '@ohos.window'; +import screenManager from '@ohos.screen'; +import display from '@ohos.display'; + +export default function displayAndWindowRefactorInterfaceTest(context, windowStage, abilityStorage) { + console.log('windowTest context: ' + JSON.stringify(context)) + console.log('windowTest abilityStorage: ' + JSON.stringify(abilityStorage)) + describe('displayAndWindowRefactorInterface_test', function () { + console.log('describe window_api_test start!!!') + const TRUE_FLAG = true; + var appWindowTypeArr = []; + var windowTypeArr = []; + var appWindowTypeDic = { + 'TYPE_BASE': 0, + 'TYPE_APP': 0, + 'TYPE_APP_SUB_WINDOW': 1, + }; + var systemWindowValueArr = []; + var systemWindowTypeArr = []; + var systemWindowTypeDicArr = []; + var windowModeArr=['UNDEFINED','FULLSCREEN','PRIMARY','SECONDARY','FLOATING'] + var systemWindowTypeDic = { + 'TYPE_SYSTEM_ALERT': 1, + 'TYPE_INPUT_METHOD': 2, + 'TYPE_STATUS_BAR': 3, + 'TYPE_PANEL': 4, + 'TYPE_KEYGUARD': 5, + 'TYPE_VOLUME_OVERLAY': 6, + 'TYPE_NAVIGATION_BAR': 7, + 'TYPE_FLOAT': 8, +// 'TYPE_FLOAT_CAMERA': 9 + } + var windowLayoutModeArr = []; + var windowLayoutModeDic = { + 'WINDOW_LAYOUT_MODE_TILE': 1, + 'WINDOW_LAYOUT_MODE_CASCADE': 0 + }; + var windowCount = 2022; + var listenerStatus = { + ready: 'ready', + pending: 'pending', + finished: 'finished' + }; + var listenerData = { + on: false, + typeStr: '', + }; + var newWindowObj = null; + const WINDOW_NAME = 'windowName'; + + beforeAll(function () { + console.log('jsunittest beforeall ohosWindow.WindowType=' + JSON.stringify(ohosWindow.WindowType)); + systemWindowTypeDicArr = Object.keys(systemWindowTypeDic); + console.log('jsunittest beforeall systemWindowTypeDicArr=' + JSON.stringify(systemWindowTypeDicArr) + ' ,length=' + systemWindowTypeDicArr.length); + systemWindowValueArr = Object.keys(systemWindowTypeDic); + systemWindowTypeArr = Object.keys(systemWindowTypeDic); + for (var i in ohosWindow.WindowType) { + console.log('jsunittest beforeall i=' + i); + windowTypeArr.push(ohosWindow.WindowType[i]) + } + }) + beforeEach(function () { + }) + afterEach(async function (done) { + windowCount++; + if (listenerData.on) { + listenerData.on = false; + console.log('jsunittest afterEach listener off, listenerData:' + JSON.stringify(listenerData)); + if (listenerData.typeStr === 'systemBarTintChange') { + ohosWindow.off(listenerData.typeStr); + } else if (newWindowObj) { + newWindowObj.off(listenerData.typeStr); + } + await sleep(3000); + } + done(); + }) + afterAll(function () { + }) + + function expectedError(error, caseName, apiName, done, code) { + let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: '; + console.log(msgStr + JSON.stringify(error)); + if (error.code === code) { + expect(TRUE_FLAG).assertTrue(); + } + done(); + } + + function unexpectedError(error, caseName, apiName, done) { + let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: '; + console.log(msgStr + JSON.stringify(error)); + expect(TRUE_FLAG).assertFail(); + done(); + } + + function sleep(time) { + return new Promise(resolve => { + setTimeout(() => { + resolve('sleep finished'); + }, time); + }) + } + /** + * @tc.number SUB_WINDOW_GETALLDISPLAYS_JSAPI_001 + * @tc.name Test getAllDisplaysTest1 + * @tc.desc Gets all current display objects + */ + it('getAllDisplaysTest1', 0, async function (done) { + let caseName = 'getAllDisplaysTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + display.getAllDisplays().then((data) => { + console.info(msgStr+'Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); + expect(data[0].id != null).assertTrue(); + expect(data[0].refreshRate != null).assertTrue(); + expect(data[0].width != null).assertTrue(); + expect(data[0].height != null).assertTrue(); + expect(data[0].rotation != null).assertTrue(); + expect(data[0].densityDPI != null).assertTrue(); + expect(data[0].name != null).assertTrue(); + expect(data[0].alive).assertTrue(); + expect(data[0].state != null).assertTrue(); + expect(data[0].densityPixels != null).assertTrue(); + expect(data[0].scaledDensity !=null).assertTrue(); + expect(data[0].xDPI != null).assertTrue(); + expect(data[0].yDPI != null).assertTrue(); + done(); + }).catch((err) => { + console.error(msgStr+'Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }) + /** + * @tc.number SUB_WINDOW_GETALLDISPLAYS_JSAPI_002 + * @tc.name Test getAllDisplaysTest2 + * @tc.desc Gets all current display objects + */ + it('getAllDisplaysTest2', 0, async function (done) { + let caseName = 'getAllDisplaysTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + display.getAllDisplays((err, data) => { + if (err.code) { + console.error(msgStr+'Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + return; + } + console.info(msgStr+'Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); + expect(data[0].refreshRate != null).assertTrue(); + expect(data[0].width != null).assertTrue(); + expect(data[0].height != null).assertTrue(); + expect(data[0].rotation != null).assertTrue(); + expect(data[0].densityDPI != null).assertTrue(); + expect(data[0].name != null).assertTrue(); + expect(data[0].alive).assertTrue(); + expect(data[0].state != null).assertTrue(); + expect(data[0].densityPixels != null).assertTrue(); + expect(data[0].scaledDensity !=null).assertTrue(); + expect(data[0].xDPI != null).assertTrue(); + expect(data[0].yDPI != null).assertTrue(); + done(); + console.log(msgStr + 'done '); + }); + }) + /** + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_001 + * @tc.name Test createWindowTest1 + * @tc.desc Verify the scenario of creating the application type window + */ + it('createWindowTest1', 0, async function (done) { + let caseName = 'createWindowTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let loopCount = systemWindowTypeDicArr.length; + console.log(msgStr + 'loopCount: ' + loopCount); + for (let i = 0; i < loopCount; i++) { + sleep(500) + let tempType = Number(ohosWindow.WindowType[systemWindowTypeDicArr[i]]) + let windId = 'createWindowTest1' + i; + console.log(msgStr + 'ohosWindow.createWindow: ' + tempType + ' start'); + let windowConfig = {name: windId, windowType: tempType, ctx: context}; + try{ + let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'catched, err: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'finished, wnd: ' + JSON.stringify(tempWnd)); + expect(!!tempWnd).assertTrue(); + } catch (exception) { + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + } + console.log(msgStr + 'done '); + done(); + }) + + /** + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_004 + * @tc.name Test createWindowTest4 + * @tc.desc Verify the scenario of creating a window with duplicate IDs + */ + it('createWindowTest4', 0, async function (done) { + let caseName = 'createWindowTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let windowId = 'createWindowSameidsTest4' + let windowConfig = {name: windowId, windowType: 1, ctx: context}; + try{ + let ohosData = await ohosWindow.createWindow(windowConfig).catch((err) => { + console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }) + expect(!!ohosData).assertTrue(); + try{ + let ohosDataError = await ohosWindow.createWindow(windowConfig).catch((errSencond) => { + console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(errSencond)); + expect(errSencond.code).assertEqual(1300002) + done(); + }) + console.log(msgStr + 'ohosWindow.createWindow 1 twice ohosDataError: ' + JSON.stringify(ohosDataError)); + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + + }) + /** + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_005 + * @tc.name Test createWindowTest5 + * @tc.desc Verify the scenario of creating the application type window + */ + it('createWindowTest5', 0, done => { + let caseName = 'createWindowTest5'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin context==' + JSON.stringify(context)); + let loopCount = appWindowTypeArr.length; + console.log(msgStr + 'loopCount: ' + loopCount); + for (let i = 0; i < loopCount; i++) { + sleep(500) + let tempType = ohosWindow.WindowType.TYPE_APP; + let windId = 'createWindowTest5' + i; + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start'); + let windowConfig = {name: windId, windowType: tempType, ctx: context}; + try{ + ohosWindow.createWindow(windowConfig, (err, data) => { + if (err && err.code) { + console.log(msgStr + 'ohosWindow.createWindow err.code==' + JSON.stringify(err.code)) + expect(err.code === 1300002).assertTrue(); + return; + } + console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); + expect(!!data).assertTrue(); + data.resetSize(500, 1000); + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + } + done(); + }) + /** + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_006 + * @tc.name Test createWindowTest6 + * @tc.desc Verify the scenario of creating the system type window + */ + it('createWindowTest6', 0, done => { + let caseName = 'createWindowTest6'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let loopCount = systemWindowTypeArr.length; + console.log('jsunittest loopCount: ' + loopCount); + let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; + let windId = 'createWindowTest6'; + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start'); + let windowConfig = {name: windId, windowType: tempType, ctx: context}; + try{ + ohosWindow.createWindow(windowConfig, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); + return; + } + expect(!!data).assertTrue(); + let tempWnd = data + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' wnd: ' + tempWnd); + try { + let proData = tempWnd.getWindowProperties(); + console.log(msgStr + 'proData.type:' + proData.type); + expect(proData.type == tempType).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); + }; + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_008 + * @tc.name Test createWindowTest8 + * @tc.desc Verify the scenario of creating a window with duplicate IDs + */ + it('createWindowTest8', 0, done => { + let caseName = 'createWindowTest8'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let windowId = 'createWindowSameidTest8' + let winsowConfig = {name: windowId, windowType:1, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (err, data) => { + console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err)); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + return + } + expect(!!data).assertTrue(); + try{ + ohosWindow.createWindow(winsowConfig, (err, dataTwo) => { + console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(err)); + if (err && err.code) { + console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo)); + expect(err.code).assertEqual(1300002) + done(); + } else { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo)); + } + }) + }catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + + }) + /** + * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_001 + * @tc.name Test getWindowAvoidAreaTest1 + * @tc.desc Obtain the area that the window content avoids + */ + it('getWindowAvoidAreaTest1', 0, async function (done) { + let caseName = 'getWindowAvoidAreaTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let tempWnd = windowStage.getMainWindowSync(); + expect(!!tempWnd).assertTrue(); + try { + let type = ohosWindow.AvoidAreaType.TYPE_SYSTEM; + let avoidArea = tempWnd.getWindowAvoidArea(type); + console.log(msgStr + 'avoidArea: ' + JSON.stringify(avoidArea)); + expect(avoidArea.visible).assertTrue(); + expect(avoidArea.topRect != null).assertTrue(); + expect(avoidArea.rightRect != null).assertTrue(); + expect(avoidArea.bottomRect != null).assertTrue(); + expect(avoidArea.leftRect != null).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the area. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + + /** + * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_002 + * @tc.name Test getWindowAvoidAreaTest2 + * @tc.desc Obtain the area that the window content avoids + */ + it('getWindowAvoidAreaTest2', 0, async function (done) { + let caseName = 'getWindowAvoidAreaTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ +// let tempWnd = await ohosWindow.getLastWindow(context).catch((err)=>{ +// console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); +// unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); +// }) + let tempWnd = windowStage.getMainWindowSync(); + expect(tempWnd != null).assertTrue(); + try { + let type = ohosWindow.AvoidAreaType.TYPE_CUTOUT; + let avoidArea = tempWnd.getWindowAvoidArea(type); + console.log(msgStr + 'avoidArea: ' + JSON.stringify(avoidArea)); + expect(!avoidArea.visible).assertTrue(); + expect(avoidArea.topRect != null).assertTrue(); + expect(avoidArea.rightRect != null).assertTrue(); + expect(avoidArea.bottomRect != null).assertTrue(); + expect(avoidArea.leftRect != null).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the area. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); + }; + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_003 + * @tc.name Test getWindowAvoidAreaTest3 + * @tc.desc Obtain the area that the window content avoids + */ + it('getWindowAvoidAreaTest3', 0, async function (done) { + let caseName = 'getWindowAvoidAreaTest3'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let tempWnd = windowStage.getMainWindowSync(); + expect(!!tempWnd).assertTrue(); + try { + let type = ohosWindow.AvoidAreaType.TYPE_SYSTEM_GESTURE; + let avoidArea = tempWnd.getWindowAvoidArea(type); + console.log(msgStr + 'avoidArea: ' + JSON.stringify(avoidArea)); + expect(avoidArea.visible).assertTrue(); + expect(avoidArea.topRect != null).assertTrue(); + expect(avoidArea.rightRect != null).assertTrue(); + expect(avoidArea.bottomRect != null).assertTrue(); + expect(avoidArea.leftRect != null).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the area. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_004 + * @tc.name Test getWindowAvoidAreaTest4 + * @tc.desc Obtain the area that the window content avoids + */ + it('getWindowAvoidAreaTest4', 0, async function (done) { + let caseName = 'getWindowAvoidAreaTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let tempWnd = windowStage.getMainWindowSync(); + expect(!!tempWnd).assertTrue(); + try { + let type = ohosWindow.AvoidAreaType.TYPE_KEYBOARD; + let avoidArea = tempWnd.getWindowAvoidArea(type); + console.log(msgStr + 'avoidArea: ' + JSON.stringify(avoidArea)); + expect(avoidArea.visible).assertTrue(); + expect(avoidArea.topRect != null).assertTrue(); + expect(avoidArea.rightRect != null).assertTrue(); + expect(avoidArea.bottomRect != null).assertTrue(); + expect(avoidArea.leftRect != null).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the area. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_GETWINDOWPROPERTIES_JSAPI_001 + * @tc.name Test getWindowPropertiesTest1 + * @tc.desc Gets the properties of the current window + */ + it('getWindowPropertiesTest1', 0, async function (done) { + let caseName = 'getWindowPropertiesTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let tempWnd = windowStage.getMainWindowSync(); + expect(!!tempWnd).assertTrue(); + try { + let data = tempWnd.getWindowProperties(); + console.log(msgStr + 'ohosWindow.getWindowProperties ' + JSON.stringify(data)); + expect(data.type != null).assertTrue(); + expect(data.windowRect.height != null).assertTrue(); + expect(data.windowRect.left != null).assertTrue(); + expect(data.windowRect.top != null).assertTrue(); + expect(data.windowRect.width != null).assertTrue(); + expect(data.isFullScreen!= null).assertTrue(); + expect(data.isLayoutFullScreen!= null).assertTrue(); + expect(data.focusable!= null).assertTrue(); + expect(data.touchable!= null).assertTrue(); + expect(data.isKeepScreenOn!= null).assertTrue(); + expect(data.isTransparent != null).assertTrue(); + expect(data.brightness != null).assertTrue(); + expect(data.dimBehindValue).assertEqual(0); + expect(data.isRoundCorner!= null).assertTrue(); + expect(data.isPrivacyMode != null).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the main window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_FINDWINDOW_JSAPI_001 + * @tc.name Test getLastWindowTest1 + * @tc.desc Get the final show window + */ + it('getLastWindowTest1', 0, async function (done) { + let caseName = 'getLastWindowTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let proData=null + try{ + let lastWindow = await ohosWindow.getLastWindow(context).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + }) + expect(lastWindow != null).assertTrue(); + done(); + }catch (exception) { + console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_002 + * @tc.name Test getLastWindowTest2 + * @tc.desc Get the final show window + */ + it('getLastWindowTest2', 0, async function (done) { + let caseName = 'getLastWindowTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + try { + ohosWindow.getLastWindow(context, (err, data) => { + if (err.code) { + console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + return; + } + console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + done(); + }) + } catch (exception) { + console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_001 + * @tc.name Test showWindowTest1 + * @tc.desc show window + */ + it('showWindowTest1', 0, async function (done) { + let caseName = 'showWindowTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let baseWndType = 1; + let windowId = 'showWindowTest1'; + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try{ + let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + JSON.stringify(tempWnd)); + expect(!!tempWnd).assertTrue(); + tempWnd.showWindow().then((data)=> { + console.info(msgStr +'Succeeded in showing the window. Data: ' + JSON.stringify(data)); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to show the window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.showWindow', done); + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_002 + * @tc.name Test showWindowTest2 + * @tc.desc show window + */ + it('showWindowTest2', 0, async function (done) { + let caseName = 'showWindowTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let baseWndType = 1; + let windowId = 'showWindowTest2'; + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); + return; + } + expect(!!create_data).assertTrue(); + create_data.showWindow((err, data) => { + if (err.code) { + console.error(msgStr +'Failed to show the window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + return; + } + console.info(msgStr +'Succeeded in showing the window. Data: ' + JSON.stringify(data)); + done(); + }) + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_001 + * @tc.name Test moveWindowToTest1 + * @tc.desc Set the position of a window. + */ + it('moveWindowToTest1', 0, async function (done) { + let caseName = 'moveWindowToTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'moveWindowToTest1'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try { + ohosWindow.createWindow(windowConfig).then((wnd)=> { + console.info(msgStr +'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); + expect(wnd != null).assertTrue(); + try { + wnd.moveWindowTo(300, 300).then(()=> { + console.info(msgStr +'Succeeded in moving the window.'); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to move the window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); + }); + } catch (exception) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; + }).catch((err)=>{ + console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_002 + * @tc.name Test moveWindowToTest2 + * @tc.desc Set the position of a window. + */ + it('moveWindowToTest2', 0, async function (done) { + let caseName = 'moveWindowToTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'moveWindowToTest2'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try { + ohosWindow.createWindow(windowConfig).then((wnd)=> { + console.info(msgStr +'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); + expect(wnd != null).assertTrue(); + try { + wnd.moveWindowTo(100, 50).then(()=> { + console.info(msgStr +'Succeeded in moving the window.'); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to move the window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); + }); + } catch (exception) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; + }).catch((err)=>{ + console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_003 + * @tc.name Test moveWindowToTest3 + * @tc.desc Set the position of a window. + */ + it('moveWindowToTest3', 0, async function (done) { + let caseName = 'moveWindowToTest3'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'moveWindowToTest3'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try { + ohosWindow.createWindow(windowConfig).then((wnd)=> { + console.info(msgStr +'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); + expect(wnd != null).assertTrue(); + try { + wnd.moveWindowTo(20000, 20000).then(()=> { + console.info(msgStr +'Succeeded in moving the window.'); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to move the window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); + }); + } catch (exception) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; + }).catch((err)=>{ + console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_004 + * @tc.name Test moveWindowToTest4 + * @tc.desc Set the position of a window. + */ + it('moveWindowToTest4', 0, async function (done) { + let caseName = 'moveWindowToTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'moveWindowToTest4'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try { + ohosWindow.createWindow(windowConfig).then((wnd)=> { + console.info(msgStr +'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); + expect(wnd != null).assertTrue(); + try { + wnd.moveWindowTo(-200, -200).then(()=> { + console.info(msgStr +'Succeeded in moving the window.'); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to move the window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); + }); + } catch (exception) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; + }).catch((err)=>{ + console.error(msgStr +'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_005 + * @tc.name Test moveWindowToTest5 + * @tc.desc Set the position of a window. + */ + it('moveWindowToTest5', 0, async function (done) { + let caseName = 'moveWindowToTest5'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let baseWndType = 1; + let windowId = 'moveWindowToTest5'; + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); + return; + } + try{ + create_data.moveWindowTo(300, 300, (err, data) => { + if (err.code) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); + return; + } + console.info(msgStr +'Succeeded in moving the window. Data: ' + JSON.stringify(data)); + done(); + }) + } catch (exception) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_006 + * @tc.name Test moveWindowToTest6 + * @tc.desc Set the position of a window. + */ + it('moveWindowToTest6', 0, async function (done) { + let caseName = 'moveWindowToTest6'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let baseWndType = 1; + let windowId = 'moveWindowToTest6'; + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); + return; + } + try{ + create_data.moveWindowTo(100, 50, (err, data) => { + if (err.code) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); + return; + } + console.info(msgStr +'Succeeded in moving the window. Data: ' + JSON.stringify(data)); + done(); + }) + } catch (exception) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_007 + * @tc.name Test moveWindowToTest7 + * @tc.desc Set the position of a window. + */ + it('moveWindowToTest7', 0, async function (done) { + let caseName = 'moveWindowToTest7'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let baseWndType = 1; + let windowId = 'moveWindowToTest7'; + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); + return; + } + try{ + create_data.moveWindowTo(20000, 20000, (err, data) => { + if (err.code) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); + return; + } + console.info(msgStr +'Succeeded in moving the window. Data: ' + JSON.stringify(data)); + done(); + }) + } catch (exception) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_008 + * @tc.name Test moveWindowToTest8 + * @tc.desc Set the position of a window. + */ + it('moveWindowToTest8', 0, async function (done) { + let caseName = 'moveWindowToTest8'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let baseWndType = 1; + let windowId = 'moveWindowToTest8'; + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); + return; + } + try{ + create_data.moveWindowTo(-200, -200, (err, data) => { + if (err.code) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); + return; + } + console.info(msgStr +'Succeeded in moving the window. Data: ' + JSON.stringify(data)); + done(); + }) + } catch (exception) { + console.error(msgStr +'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_RESIZE_JSAPI_001 + * @tc.name Test resizeTest1 + * @tc.desc Set the size of a window + */ + it('resizeTest1', 0, async function (done) { + let caseName = 'resizeTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'resizeTest1'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try{ + let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); + expect(!!tempWnd).assertTrue(); + try{ + tempWnd.resize(200, 600).then((data)=> { + console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'tempWnd.resize', done); + }) + } catch (exception) { + console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_RESIZE_JSAPI_002 + * @tc.name Test resizeTest2 + * @tc.desc Set the size of a window + */ + it('resizeTest2', 0, async function (done) { + let caseName = 'resizeTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'resizeTest2'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try{ + let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); + expect(!!tempWnd).assertTrue(); + try{ + tempWnd.resize(20000, 20000).then((data)=> { + console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'tempWnd.resize', done); + }) + } catch (exception) { + console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_RESIZE_JSAPI_003 + * @tc.name Test resizeTest3 + * @tc.desc Set the size of a window + */ + it('resizeTest3', 0, async function (done) { + let caseName = 'resizeTest3'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'resizeTest3'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try{ + let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); + expect(!!tempWnd).assertTrue(); + try{ + tempWnd.resize(0, 0).then((data)=> { + console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(401); + done(); + }) + } catch (exception) { + console.error(msgStr +'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception)); + expect(exception.code).assertEqual(401); + done(); + }; + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_RESIZE_JSAPI_004 + * @tc.name Test resizeTest4 + * @tc.desc Set the size of a window + */ + it('resizeTest4', 0, async function (done) { + let caseName = 'resizeTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'resizeTest4'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try{ + let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); + expect(!!tempWnd).assertTrue(); + try{ + tempWnd.resize(-1, -1).then((data)=> { + console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(401); + done(); + }) + } catch (exception) { + console.error(msgStr +'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception)); + expect(exception.code).assertEqual(401); + done(); + }; + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_RESIZE_JSAPI_005 + * @tc.name Test resizeTest5 + * @tc.desc Set the size of a window + */ + it('resizeTest5', 0, async function (done) { + let caseName = 'resizeTest5'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'resizeTest5'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try{ + let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); + expect(!!tempWnd).assertTrue(); + for (var i = 1; i <= 5; i++) { + try{ + tempWnd.resize(100, 100).then((data)=> { + console.info(msgStr +'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to change the window size. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(6); + done(); + tempWnd.detroyWindow(); + }) + } catch (exception) { + console.error(msgStr +'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception)); + }; + } + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_RESIZE_JSAPI_006 + * @tc.name Test resizeTest6 + * @tc.desc Set the size of a window + */ + it('resizeTest6', 0, async function (done) { + let caseName = 'resizeTest6'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let baseWndType = 1; + let windowId = 'resizeTest6'; + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); + return; + } + try { + create_data.resize(200, 200, (err) => { + if (err.code) { + console.error(msgStr +'Failed to change the window size. Cause:' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.resize', done); + return; + } + console.info(msgStr +'Succeeded in changing the window size.'); + done(); + }); + } catch (exception) { + console.error(msgStr +'Failed to change the window size. Cause:' + JSON.stringify(exception)); + }; + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_RESIZE_JSAPI_007 + * @tc.name Test resizeTest7 + * @tc.desc Set the size of a window + */ + it('resizeTest7', 0, async function (done) { + let caseName = 'resizeTest6'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let baseWndType = 1; + let windowId = 'resizeTest7'; + let width = 100; + let height = 100; + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); + return; + } + for (let i = 1; i <= 5; i++) { + width = width * i; + height = height * i; + try { + create_data.resize(width, height, (err) => { + if (err.code) { + console.error(msgStr +'Failed to change the window size. Cause:' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.resize', done); + return; + } + console.info(msgStr +'Succeeded in changing the window size.'); + done(); + }); + } catch (exception) { + console.error(msgStr +'Failed to change the window size. Cause:' + JSON.stringify(exception)); + }; + } + + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_001 + * @tc.name Test destroyWindowTest1 + * @tc.desc Verification window destruction scenario. + */ + it('destroyWindowTest1', 0, async function (done) { + let caseName = 'destroyWindowTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; + let windowId = 'destroyWindowTest1'; + console.log(msgStr + 'begin'); + let windowConfig = {name: windowId, windowType: baseWndType, ctx: context}; + try{ + let tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + }); + console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + JSON.stringify(tempWnd)); + expect(!!tempWnd).assertTrue(); + tempWnd.destroyWindow().then(()=> { + console.info(msgStr +'Succeeded in destroying the window.'); + try { + let findWnd = ohosWindow.findWindow(windowId) + expect(!findWnd).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception)); + expect(exception.code === 1300002).assertTrue(); + done(); + }; + }).catch((err)=>{ + console.error(msgStr +'try catch Failed to destroy the window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'tempWnd.destroyWindow', done); + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_002 + * @tc.name Test destroyWindowTest2 + * @tc.desc Verification window destruction scenario + */ + it('destroyWindowTest2', 0, function (done) { + let caseName = 'destroyWindowTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'destroyWindowTest2'; + console.log(msgStr + 'begin'); + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); + return; + } + expect(!!create_data).assertTrue(); + create_data.destroyWindow((err) => { + if (err.code != 0) { + console.log('windowTest DestroyTest2 create callback fail' + JSON.stringify(err)); + unexpectedError(create_err, caseName, 'ohosWindow.destroyWindow', done); + } else { + try { + let findWnd = ohosWindow.findWindow(windowId) + expect(!findWnd).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception)); + expect(exception.code === 1300002).assertTrue(); + done(); + }; + } + }) + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_001 + * @tc.name Test setWindowSystemBarEnableTest1 + * @tc.desc Set the visible mode of navigation bar and status bar + */ + it('setWindowSystemBarEnableTest1', 0, async function (done) { + let caseName = 'setWindowSystemBarEnableTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + }) + expect(wnd != null).assertTrue(); + try { + wnd.setWindowSystemBarEnable([]).then(()=> { + console.info(msgStr +'Succeeded in setting the system bar to be invisible.'); + expect(TRUE_FLAG).assertTrue(); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_002 + * @tc.name Test setWindowSystemBarEnableTest2 + * @tc.desc Set the visible mode of navigation bar and status bar + */ + it('setWindowSystemBarEnableTest2', 0, async function (done) { + let caseName = 'setWindowSystemBarEnableTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + }) + expect(wnd != null).assertTrue(); + try { + wnd.setWindowSystemBarEnable(['status', 'navigation']).then(()=> { + console.info(msgStr +'Succeeded in setting the system bar to be invisible.'); + expect(TRUE_FLAG).assertTrue(); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_003 + * @tc.name Test setWindowSystemBarEnableTest3 + * @tc.desc Set the visible mode of navigation bar and status bar + */ + it('setWindowSystemBarEnableTest3', 0, async function (done) { + let caseName = 'setWindowSystemBarEnableTest3'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + }) + expect(wnd != null).assertTrue(); + try { + wnd.setWindowSystemBarEnable(['status']).then(()=> { + console.info(msgStr +'Succeeded in setting the system bar to be invisible.'); + expect(TRUE_FLAG).assertTrue(); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_004 + * @tc.name Test setWindowSystemBarEnableTest4 + * @tc.desc Set the visible mode of navigation bar and status bar + */ + it('setWindowSystemBarEnableTest4', 0, async function (done) { + let caseName = 'setWindowSystemBarEnableTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + }) + expect(wnd != null).assertTrue(); + try { + wnd.setWindowSystemBarEnable(['navigation']).then(()=> { + console.info(msgStr +'Succeeded in setting the system bar to be invisible.'); + expect(TRUE_FLAG).assertTrue(); + done(); + }).catch((err)=>{ + console.error(msgStr +'Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_005 + * @tc.name Test setWindowSystemBarEnableTest5 + * @tc.desc Set the visible mode of navigation bar and status bar + */ + it('setWindowSystemBarEnableTest5', 0, async function (done) { + let caseName = 'setWindowSystemBarEnableTest5'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'setWindowSystemBarEnableTest5'; + console.log(msgStr + 'begin'); + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try { + let wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + }) + expect(wnd != null).assertTrue(); + try{ + wnd.setWindowSystemBarEnable(['status', 'navigation'], (err) => { + console.log(msgStr +'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin'); + if (err.code != 0) { + console.log(msgStr +'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail' + JSON.stringify(err)); + expect().assertFail(); + done(); + } else { + expect(TRUE_FLAG).assertTrue(); + done(); + } + }) + } catch (exception) { + console.error(msgStr +' try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to get the last window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_006 + * @tc.name Test setWindowSystemBarEnableTest6 + * @tc.desc Set the visible mode of navigation bar and status bar + */ + it('setWindowSystemBarEnableTest6', 0, async function (done) { + let caseName = 'setWindowSystemBarEnableTest6'; + let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'setWindowSystemBarEnableTest6'; + console.log(msgStr + 'begin'); + let winsowConfig = {name: windowId, windowType:baseWndType, ctx: context}; + try { + let wnd = await ohosWindow.getLastWindow(context).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + }) + expect(wnd != null).assertTrue(); + try{ + wnd.setWindowSystemBarEnable([], (err) => { + console.log(msgStr +'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin'); + if (err.code != 0) { + console.log(msgStr +'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail' + JSON.stringify(err)); + expect().assertFail(); + done(); + } else { + expect(TRUE_FLAG).assertTrue(); + done(); + } + }) + } catch (exception) { + console.error(msgStr +' try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to get the last window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_003 + * @tc.name Test createWindowTest3 + * @tc.desc Verify the scenario of creating a window of a type that does not exist + */ + it('createWindowTest3', 0, async function (done) { + let caseName = 'createWindowTest3'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let tempType = 5000; + let windId = 'nonExistWindowType'; + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start'); + let windowConfig = {name: windId, windowType: tempType, ctx: context}; + try{ + let nonExistWnd = await ohosWindow.createWindow(windowConfig).then((data)=> { + console.log(msgStr + 'ohosWindow.createWindow success: ' + JSON.stringify(nonExistWnd)); + done(); + }).catch((err) => { + console.log(msgStr + 'ohosWindow.createWindow err: ' + JSON.stringify(err)); + expect(err.code === 401).assertTrue(); + done(); + }); + }catch (exception) { + console.error(msgStr + 'try catch Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect(exception.code === 401).assertTrue(); + done(); + }; + }) + /** + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_007 + * @tc.name Test createWindowTest7 + * @tc.desc Verify the scenario of creating a window of a type that does not exist + */ + it('createWindowTest7', 0, done => { + let caseName = 'createWindowTest7'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + let tempType = 5000; + let windId = 'createTest7'; + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' start'); + let winsowConfig = {name: windId, windowType:tempType, ctx: context}; + try{ + ohosWindow.createWindow(winsowConfig, (err, data) => { + if (err && err.code) { + console.log(msgStr + 'ohosWindow.createWindow err' + JSON.stringify(err)); + expect(err.code === 401).assertTrue(); + done(); + } + }) + } catch (exception) { + console.error(msgStr +'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect(exception.code === 401).assertTrue(); + done(); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_001 + * @tc.name Test setWindowLayoutFullScreenTest1 + * @tc.desc set the property of the window can layout in full screen + */ + it('setWindowLayoutFullScreenTest1', 0, async function (done) { + let caseName = 'setWindowLayoutFullScreenTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let wnd = windowStage.getMainWindowSync(); + console.log(msgStr +'ohosWindow.getLastWindow ' + JSON.stringify(wnd)); + expect(wnd != null).assertTrue(); + try { + let isLayoutFullScreen= true; + wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(()=> { + console.info(msgStr +'Succeeded in setting the window layout to full-screen mode.'); + try { + let propData = wnd.getWindowProperties() + console.info(msgStr + 'wnd.getWindowProperties propData: ' + JSON.stringify(propData)); + expect(propData.isLayoutFullScreen).assertTrue(); + done(); + }catch (exception) { + console.error(msgStr + 'try catch Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); + } + }).catch((err)=>{ + console.error(msgStr +'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); + }; + }catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_002 + * @tc.name Test setWindowLayoutFullScreenTest2 + * @tc.desc set the property of the window can layout in full screen + */ + it('setWindowLayoutFullScreenTest2', 0, async function (done) { + let caseName = 'setWindowLayoutFullScreenTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + try{ + let wnd = windowStage.getMainWindowSync(); + expect(wnd != null).assertTrue(); + try { + let isLayoutFullScreen= false; + wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(()=> { + console.info(msgStr +'Succeeded in setting the window layout to full-screen mode.'); + try { + let propData = wnd.getWindowProperties() + console.info(msgStr + 'wnd.getWindowProperties propData: ' + JSON.stringify(propData)); + expect(!propData.isLayoutFullScreen).assertTrue(); + done(); + }catch (exception) { + console.error(msgStr + 'try catch Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); + } + }).catch((err)=>{ + console.error(msgStr +'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); + }; + } catch (exception) { + console.error(msgStr +'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_003 + * @tc.name Test setWindowLayoutFullScreenTest3 + * @tc.desc set the property of the window can layout in full screen + */ + it('setWindowLayoutFullScreenTest3', 0, async function (done) { + let caseName = 'setWindowLayoutFullScreenTest3'; + let msgStr = 'jsunittest ' + caseName + ' '; + try { + let wnd = windowStage.getMainWindowSync(); + expect(wnd != null).assertTrue(); + let isLayoutFullScreen= true; + try { + wnd.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { + if (err.code) { + console.error(msgStr +'err Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + expect().assertFail(); + done(); + return; + } + console.info(msgStr +'Succeeded in setting the window layout to full-screen mode.'); + try{ + let propData = wnd.getWindowProperties() + console.log(msgStr + JSON.stringify(propData)); + expect(propData.isLayoutFullScreen).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); + }; + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); + }; + } catch (exception) { + console.error(msgStr +'Failed to get the main window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_004 + * @tc.name Test setWindowLayoutFullScreenTest4 + * @tc.desc set the property of the window can layout in full screen + */ + it('setWindowLayoutFullScreenTest4', 0, async function (done) { + let caseName = 'setWindowLayoutFullScreenTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + try { + let wnd = windowStage.getMainWindowSync(); + expect(wnd != null).assertTrue(); + let isLayoutFullScreen= false; + try { + wnd.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { + if (err.code) { + console.error(msgStr +'err Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + expect().assertFail(); + done(); + return; + } + console.info(msgStr +'Succeeded in setting the window layout to full-screen mode.'); + try{ + let propData = wnd.getWindowProperties() + console.log(msgStr + JSON.stringify(propData)); + expect(!propData.isLayoutFullScreen).assertTrue(); + done(); + } catch (exception) { + console.error(msgStr +'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); + }; + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); + }; + } catch (exception) { + console.error(msgStr +'Failed to create the main window. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_001 + * @tc.name Test setWindowModeTest1 + * @tc.desc Test window.setWindowMode API function test. + */ + it('setWindowModeTest1', 0, function (done) { + let caseName = 'setWindowModeTest1'; + let msgStr = 'jsunittest ' + caseName + ' '; + let sumCount=0 + try { + let tempWnd = windowStage.getMainWindowSync(); + expect(!!tempWnd).assertTrue(); + let loopCount = windowModeArr; + console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount)) + for (let i = 0; i < loopCount.length; i++) { + sleep(500) + let tempType = ohosWindow.WindowMode[loopCount[i]]; + console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); + try { + tempWnd.setWindowMode(tempType).then(()=> { + sumCount++ + console.info(msgStr +'Succeeded in setting the window mode. count: '+sumCount); + console.info(msgStr +'Succeeded in setting the window mode. loopCount.length: '+loopCount.length); + if(sumCount==loopCount.length-1) done(); + }).catch((err)=>{ + console.log(msgStr +'currentType: '+tempType) + console.error(msgStr +'Failed to set the window mode. Cause: ' + JSON.stringify(err)); + if(tempType == 1) return; + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + }); + } catch (exception) { + console.error(msgStr +'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); + }; + } + } catch (exception) { + console.error('try catch Failed to obtain the getMainWindowSync. Cause: ' + JSON.stringify(exception)); + }; + }) + /** + * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_002 + * @tc.name Test setWindowModeTest2 + * @tc.desc Verify the scenario where the normal window mode is set + */ + it('setWindowModeTest2', 0, function (done) { + let caseName = 'setWindowModeTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + let sumCount=0 + try{ + let wnd = windowStage.getMainWindowSync(); + expect(!!wnd).assertTrue(); + let loopCount = windowModeArr; + console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount)) + for (let i = 0; i < loopCount.length; i++) { + sleep(500) + let tempType = ohosWindow.WindowMode[loopCount[i]]; + console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); + try{ + wnd.setWindowMode(tempType, (err, data) => { + if (err && err.code) { + console.log(msgStr +'currentType: '+tempType) + console.error(msgStr +'Failed to set the window mode. Cause: ' + JSON.stringify(err)); + if(tempType == 1) return; + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } else { + sumCount++ + console.info(msgStr +'Succeeded in setting the window mode. count: '+sumCount); + console.info(msgStr +'Succeeded in setting the window mode. loopCount.length: '+loopCount.length); + if(sumCount==loopCount.length-1) done(); + } + }) + } catch (exception) { + console.error(msgStr +'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); + }; + } + } catch (exception) { + console.error(msgStr +'try catch Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + }) +}