提交 6e30a941 编写于 作者: X xwx1134060

xiayifan9@h-partners.com

Signed-off-by: Nxwx1134060 <xiayifan9@h-partners.com>
上级 9e4101ba
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "120000", "test-timeout": "600000",
"package": "com.test.window", "package": "com.test.window",
"shell-timeout": "60000" "shell-timeout": "60000"
}, },
......
...@@ -12,5 +12,7 @@ ...@@ -12,5 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./window.api.part1.js')
require('./window.test.js') require('./window.test.js')
require('./window.parameter.js') require('./window.parameter.js')
require('./display.screenshot.api.js')
/*
* * 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.
* */
import app from '@system.app'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import display from '@ohos.display'
import screenshot from '@ohos.screenshot'
import image from '@ohos.multimedia.image'
describe('screenshot_test', function () {
const TRUE_FLAG = true;
const FALSE_FLAG = false;
beforeAll(function () {
})
beforeEach(function () {
})
afterEach(function () {
})
afterAll(function () {
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_001
* @tc.name Test screenShotSaveTest1
* @tc.desc Set the screenshot area to be larger than the screen width and height
*/
it('screenShotSaveTest1', 0, function (done) {
console.log('jsunittest screenShotSaveTest1 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest1 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 10000,
height: 10000,
},
imageSize: {
width: 300,
height: 300
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest1 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail();
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest1 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue();
done();
})
}, (err) => {
console.log('jsunittest screenShotSaveTest1 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_002
* @tc.name Test screenShotSaveTest2
* @tc.desc Set the size of the screenshot area and the generated image to be larger than the screen width and height
*/
it('screenShotSaveTest2', 0, function (done) {
console.log('jsunittest screenShotSaveTest2 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest2 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 10000,
height: 10000,
},
imageSize: {
width: 3000,
height: 3000
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest2 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail();
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest2 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue();
done();
})
}, (err) => {
console.log('jsunittest screenShotSaveTest2 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done()
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_003
* @tc.name Test screenShotSaveTest3
* @tc.desc Set the screenshot area and the size of the generated image to be smaller than the screen width and height
*/
it('screenShotSaveTest3', 0, function (done) {
console.log('jsunittest screenShotSaveTest3 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest3 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 100,
height: 100,
},
imageSize: {
width: 300,
height: 300
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest3 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue();
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest3 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest screenShotSaveTest3 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_004
* @tc.name Test screenShotSaveTest4
* @tc.desc Set the size of the generated image to be smaller than the screen width and height
*/
it('screenShotSaveTest4', 0, function (done) {
console.log('jsunittest screenShotSaveTest4 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest4 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 100,
height: 100,
},
imageSize: {
width: 3000,
height: 3000
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest4 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue()
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest4 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest screenShotSaveTest4 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_005
* @tc.name Test screenShotSaveTest5
* @tc.desc Set the screenshot area to a negative value
*/
it('screenShotSaveTest5', 0, function (done) {
console.log('jsunittest screenShotSaveTest5 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest5 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: -50,
top: -50,
width: -100,
height: -100,
},
imageSize: {
width: 300,
height: 300
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest5 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail();
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest5 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue();
done();
})
}, (err) => {
console.log('jsunittest screenShotSaveTest5 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_006
* @tc.name Test screenShotSaveTest6
* @tc.desc Set the screenshot area to 0
*/
it('screenShotSaveTest6', 0, function (done) {
console.log('jsunittest screenShotSaveTest6 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest6 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 0,
height: 0,
},
imageSize: {
width: 300,
height: 300
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest6 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue()
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest6 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done()
})
}, (err) => {
console.log('jsunittest screenShotSaveTest6 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_007
* @tc.name Test screenShotSaveTest7
* @tc.desc Set the generated image size to a negative value
*/
it('screenShotSaveTest7', 0, function (done) {
console.log('jsunittest screenShotSaveTest7 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest7 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 100,
height: 100,
},
imageSize: {
width: -300,
height: -300
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest7 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail();
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest7 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue();
done();
})
}, (err) => {
console.log('jsunittest screenShotSaveTest7 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_008
* @tc.name Test screenShotSaveTest8
* @tc.desc Set the generated image size to 0
*/
it('screenShotSaveTest8', 0, function (done) {
console.log('jsunittest screenShotSaveTest8 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest8 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 100,
height: 100,
},
imageSize: {
width: 0,
height: 0
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest8 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue()
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest8 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest screenShotSaveTest8 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_009
* @tc.name Test screenShotSaveTest9
* @tc.desc Set the screenshot area and the size of the generated image to be equal to the screen width and height
*/
it('screenShotSaveTest9', 0, function (done) {
console.log('jsunittest screenShotSaveTest9 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest9 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: dsp.width,
height: dsp.height
},
imageSize: {
width: dsp.width,
height: dsp.height
},
displayId: dsp.id
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest9 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue()
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest9 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
})
}, (err) => {
console.log('jsunittest screenShotSaveTest9 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_010
* @tc.name Test screenShotSaveTest10
* @tc.desc Take a screenshot of a screen that doesn't exist
*/
it('screenShotSaveTest10', 0, function (done) {
console.log('jsunittest screenShotSaveTest10 begin');
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 100,
height: 100,
},
imageSize: {
width: 300,
height: 300
},
displayId: null
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest10 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue()
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest10 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_011
* @tc.name Test screenShotSaveTest11
* @tc.desc Test screenshot.save API function test11.
*/
it('screenShotSaveTest11', 0, function (done) {
console.log('jsunittest screenShotSaveTest11 begin');
var screenshotOptions = {
screenRect: {
left: 0,
top: 0,
width: 100,
height: 100,
},
imageSize: {
width: 300,
height: 300
},
displayId: 1000
};
screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest11 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail();
done();
}, (err) => {
console.log('jsunittest screenShotSaveTest11 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue();
done();
})
})
})
/*
* 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.
*/
import app from '@system.app'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import window from '@ohos.window'
describe('window_api_test', function () {
var windowTypeArr = [];
var windowTypeDic = {
'APP_WINDOW_BASE': 1,
'APP_MAIN_WINDOW_BASE': 1,
'WINDOW_TYPE_APP_MAIN_WINDOW': 1,
'APP_MAIN_WINDOW_END': 1,
'APP_SUB_WINDOW_BASE': 1000,
'WINDOW_TYPE_MEDIA': 1000,
'WINDOW_TYPE_APP_SUB_WINDOW': 1001,
'APP_SUB_WINDOW_END': 1001,
'APP_WINDOW_END': 1001,
'SYSTEM_WINDOW_BASE': 2000,
'BELOW_APP_SYSTEM_WINDOW_BASE': 2000,
'WINDOW_TYPE_WALLPAPER': 2000,
'WINDOW_TYPE_DESKTOP': 2001,
'BELOW_APP_SYSTEM_WINDOW_END': 2001,
'ABOVE_APP_SYSTEM_WINDOW_BASE': 2100,
'WINDOW_TYPE_APP_LAUNCHING': 2100,
'WINDOW_TYPE_DOCK_SLICE': 2101,
'WINDOW_TYPE_INCOMING_CALL': 2102,
'WINDOW_TYPE_SEARCHING_BAR': 2103,
'WINDOW_TYPE_SYSTEM_ALARM_WINDOW': 2104,
'WINDOW_TYPE_INPUT_METHOD_FLOAT': 2105,
'WINDOW_TYPE_FLOAT': 2106,
'WINDOW_TYPE_TOAST': 2107,
'WINDOW_TYPE_STATUS_BAR': 2108,
'WINDOW_TYPE_PANEL': 2109,
'WINDOW_TYPE_KEYGUARD': 2110,
'WINDOW_TYPE_VOLUME_OVERLAY': 2111,
'WINDOW_TYPE_NAVIGATION_BAR': 2112,
'WINDOW_TYPE_DRAGGING_EFFECT': 2113,
'WINDOW_TYPE_POINTER': 2114,
'WINDOW_TYPE_LAUNCHER_RECENT': 2115,
'WINDOW_TYPE_LAUNCHER_DOCK': 2116,
'ABOVE_APP_SYSTEM_WINDOW_END': 2116,
'SYSTEM_WINDOW_END': 2116
}
var windowCount = 2022;
var topWindow = null;
const DELAY_TIME = 3000;
const TRUE_FLAG = true;
beforeAll(function (done) {
windowTypeArr = Object.keys(windowTypeDic);
console.log('jsunittest beforeAll begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest beforeAll window.getTopWindow wnd: ' + wnd)
if (wnd) {
topWindow = wnd;
} else {
console.log('jsunittest beforeAll window.getTopWindow empty');
}
}, (err) => {
console.log('jsunittest beforeAll window.getTopWindow failed, err : ' + JSON.stringify(err));
})
setTimeout(() => {
done();
}, 5000);
})
beforeEach(function (done) {
if (topWindow) {
topWindow.show().then(() => {
console.log('jsunittest beforeEach wnd.show success');
}, (err) => {
console.log('jsunittest beforeEach wnd.show failed, err : ' + JSON.stringify(err));
})
topWindow.setFullScreen(false).then(() => {
console.log('jsunittest beforeEach wnd.setFullScreen(false) success');
}, (err) => {
console.log('jsunittest beforeEach wnd.setFullScreen(false) failed, err : ' + JSON.stringify(err));
})
setTimeout(() => {
done();
}, DELAY_TIME);
} else {
done();
}
})
afterEach(function () {
windowCount++;
})
afterAll(function () {
})
/**
* @tc.number SUB_WINDOW_HIDE_SHOW_JSAPI_001
* @tc.name Test hideOrShowTest1
* @tc.desc set window hidden
*/
it('hideOrShowTest1', 0, async function (done) {
console.log('jsunittest hideOrShowTest1 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest hideOrShowTest1 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
wnd.hide().then(() => {
console.log('jsunittest hideOrShowTest1 wnd.hide success');
expect(TRUE_FLAG).assertTrue();
done();
}, (err) => {
console.log('jsunittest hideOrShowTest1 wnd.hide failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest hideOrShowTest1 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_HIDE_SHOW_JSAPI_001
* @tc.name Test hideOrShowTest1
* @tc.desc Set the window to hide and then show
*/
it('hideOrShowTest2', 0, async function (done) {
console.log('jsunittest hideOrShowTest2 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest hideOrShowTest2 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
wnd.hide().then(() => {
console.log('jsunittest hideOrShowTest2 wnd.hide success');
wnd.show().then(() => {
console.log('jsunittest hideOrShowTest2 wnd.show success');
expect(TRUE_FLAG).assertTrue()
done()
}, (err) => {
console.log('jsunittest hideOrShowTest2 wnd.show failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest hideOrShowTest2 wnd.hide failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest hideOrShowTest2 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_GETPROPERTIES_JSAPI_001
* @tc.name Test getPropertiesTest1
* @tc.desc Get the current application main window properties
*/
it('getPropertiesTest1', 0, async function (done) {
console.log('jsunittest getPropertiesTest1 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest getPropertiesTest1 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
wnd.getProperties().then((data) => {
console.log('jsunittest getPropertiesTest1 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!!data.type).assertTrue();
expect(!!data.windowRect).assertTrue();
done()
}, (err) => {
console.log('jsunittest getPropertiesTest1 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest getPropertiesTest1 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_001
* @tc.name Test getAvoidAreaTest1
* @tc.desc Get SystemUI type avoidance area
*/
it('getAvoidAreaTest1', 0, async function (done) {
console.log('jsunittest getAvoidAreaTest1 this.context begin');
window.getTopWindow().then(wnd => {
console.log('jsunittest getAvoidAreaTest1 window.getTopWindow wnd: ' + wnd);
expect(!!wnd).assertTrue();
wnd.getAvoidArea(0).then((data) => {
console.log('jsunittest getAvoidAreaTest1 wnd.getAvoidArea success, data :' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!!data.topRect).assertTrue();
expect(!!data.rightRect).assertTrue();
expect(!!data.bottomRect).assertTrue();
expect(!!data.leftRect).assertTrue();
done()
}, (err) => {
console.log('jsunittest getAvoidAreaTest1 wnd.getAvoidArea failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest getAvoidAreaTest1 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_002
* @tc.name Test getAvoidAreaTest2
* @tc.desc Get Notch type avoidance area
*/
it('getAvoidAreaTest2', 0, async function (done) {
console.log('jsunittest getAvoidAreaTest2 pages/index/index begin');
window.getTopWindow().then(wnd => {
console.log('jsunittest getAvoidAreaTest2 window.getTopWindow wnd: ' + wnd);
expect(!!wnd).assertTrue();
wnd.getAvoidArea(1).then((data) => {
console.log('jsunittest getAvoidAreaTest2 wnd.getAvoidArea success, data :' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!!data.topRect).assertTrue();
expect(!!data.rightRect).assertTrue();
expect(!!data.bottomRect).assertTrue();
expect(!!data.leftRect).assertTrue();
done()
}, (err) => {
console.log('jsunittest getAvoidAreaTest2 wnd.getAvoidArea failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest getAvoidAreaTest2 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_003
* @tc.name Test getAvoidAreaTest3
* @tc.desc Get system gesture type avoidance area
*/
it('getAvoidAreaTest3', 0, async function (done) {
console.log('jsunittest getAvoidAreaTest3 pages/index/ begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest getAvoidAreaTest3 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
wnd.getAvoidArea(3).then((data) => {
console.log('jsunittest getAvoidAreaTest3 wnd.getAvoidArea success, data :' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!!data.topRect).assertTrue();
expect(!!data.rightRect).assertTrue();
expect(!!data.bottomRect).assertTrue();
expect(!!data.leftRect).assertTrue();
done()
}, (err) => {
console.log('jsunittest getAvoidAreaTest3 wnd.getAvoidArea failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest getAvoidAreaTest3 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_SETFULLSCREEN_JSAPI_001
* @tc.name Test setFullScreenTest1
* @tc.desc Set the window to be non-fullscreen first and then fullscreen
*/
it('setFullScreenTest1', 0, async function (done) {
console.log('jsunittest setFullScreenTest1 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setFullScreenTest1 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
console.log('jsunittest setFullScreenTest1 setFullScreen begin')
wnd.setFullScreen(false).then(() => {
console.log('jsunittest setFullScreenTest1 wnd.setFullScreen(false) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setFullScreenTest1 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!data.isFullScreen).assertTrue();
wnd.setFullScreen(true).then(() => {
console.log('jsunittest setFullScreenTest1 wnd.setFullScreen(true) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setFullScreenTest1 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(data.isFullScreen).assertTrue();
done();
}, (err) => {
console.log('jsunittest setFullScreenTest1 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setFullScreenTest1 wnd.setFullScreen(true) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setFullScreenTest1 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setFullScreenTest1 wnd.setFullScreen(false) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
console.log('jsunittest setFullScreenTest1 setFullScreen end')
}, (err) => {
console.log('jsunittest setFullScreenTest1 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_001
* @tc.name Test setLayoutFullScreenTest1
* @tc.desc Set window and layout to full screen
*/
it('setLayoutFullScreenTest1', 0, async function (done) {
console.log('jsunittest setLayoutFullScreenTest1 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setLayoutFullScreenTest1 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
wnd.setFullScreen(true).then(() => {
console.log('jsunittest setLayoutFullScreenTest1 wnd.setFullScreen(true) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setLayoutFullScreenTest1 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(data.isFullScreen).assertTrue();
wnd.setLayoutFullScreen(true).then(() => {
console.log('jsunittest setLayoutFullScreenTest1 wnd.setLayoutFullScreen(true) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setLayoutFullScreenTest1 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(data.isLayoutFullScreen).assertTrue();
done()
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest1 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest1 wnd.setLayoutFullScreen(true) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest1 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest1 wnd.setFullScreen(true) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest1 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_002
* @tc.name Test setLayoutFullScreenTest2
* @tc.desc Set the window to full screen, the layout is not full screen
*/
it('setLayoutFullScreenTest2', 0, async function (done) {
console.log('jsunittest setLayoutFullScreenTest2 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setLayoutFullScreenTest2 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
wnd.setFullScreen(true).then(() => {
console.log('jsunittest setLayoutFullScreenTest2 wnd.setFullScreen(true) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setLayoutFullScreenTest2 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(data.isFullScreen).assertTrue();
wnd.setLayoutFullScreen(false).then(() => {
console.log('jsunittest setLayoutFullScreenTest2 wnd.setLayoutFullScreen(false) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setLayoutFullScreenTest2 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!data.isLayoutFullScreen).assertTrue();
done()
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest2 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest2 wnd.setLayoutFullScreen(false) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest2 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest2 wnd.setFullScreen(true) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest1 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_003
* @tc.name Test setLayoutFullScreenTest3
* @tc.desc Set the window to be non-full-screen and the layout to be full-screen
*/
it('setLayoutFullScreenTest3', 0, async function (done) {
console.log('jsunittest setLayoutFullScreenTest3 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setLayoutFullScreenTest3 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
wnd.setFullScreen(false).then(() => {
console.log('jsunittest setLayoutFullScreenTest3 wnd.setFullScreen(false) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setLayoutFullScreenTest3 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!data.isFullScreen).assertTrue();
wnd.setLayoutFullScreen(true).then(() => {
console.log('jsunittest setLayoutFullScreenTest3 wnd.setLayoutFullScreen(true) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setLayoutFullScreenTest3 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(data.isLayoutFullScreen).assertTrue();
done()
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest3 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest3 wnd.setLayoutFullScreen(true) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest3 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest3 wnd.setFullScreen(false) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest3 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_004
* @tc.name Test setLayoutFullScreenTest4
* @tc.desc Setting windows and layouts to be non-fullscreen
*/
it('setLayoutFullScreenTest4', 0, async function (done) {
console.log('jsunittest setLayoutFullScreenTest4 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setLayoutFullScreenTest4 window.getTopWindow wnd: ' + wnd)
expect(!!wnd).assertTrue();
wnd.setFullScreen(false).then(() => {
console.log('jsunittest setLayoutFullScreenTest4 wnd.setFullScreen(false) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setLayoutFullScreenTest4 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!data.isFullScreen).assertTrue();
wnd.setLayoutFullScreen(false).then(() => {
console.log('jsunittest setLayoutFullScreenTest4 wnd.setLayoutFullScreen(false) success');
wnd.getProperties().then((data) => {
console.log('jsunittest setLayoutFullScreenTest4 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
expect(!data.isLayoutFullScreen).assertTrue();
done()
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest4 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest4 wnd.setLayoutFullScreen(false) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest4 wnd.getProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest4 wnd.setFullScreen(false) failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}, (err) => {
console.log('jsunittest setLayoutFullScreenTest4 window.getTopWindow failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_FIND_JSAPI_001
* @tc.name Test findTest1
* @tc.desc Query main window
*/
it('findTest1', 0, async function (done) {
console.log('jsunittest findTest1 begin')
window.find('main window0').then((data) => {
console.log('jsunittest findTest1 wnd.find success, data : ' + JSON.stringify(data));
expect(!!data).assertTrue();
done()
}, (err) => {
console.log('jsunittest findTest1 wnd.find failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue();
done();
})
})
/**
* @tc.number SUB_WINDOW_FIND_JSAPI_002
* @tc.name Test findTest2
* @tc.desc Query for non-existing windows
*/
it('findTest2', 0, async function (done) {
console.log('jsunittest findTest2 begin')
window.find('nonexist').then((window) => {
console.log('jsunittest findTest2 wnd.find success, window : ' + JSON.stringify(window));
expect(!!data).assertTrue();
done()
}, (err) => {
console.log('jsunittest findTest2 wnd.find failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue();
done();
})
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册