提交 e375fabf 编写于 作者: L liziqiang
上级 00344986
......@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"test-timeout": "800000",
"package": "com.test.window",
"shell-timeout": "60000"
},
......
......@@ -12,10 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./window.api.part1.js')
require('./window.api.part2.js')
require('./window.test.js')
require('./window.parameter.js')
require('./window.promise.js')
require('./display.test.js')
require('./screenshot.test.js')
/*
* Copyright (C) 2021 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'
import display from '@ohos.display'
describe('display_test', function () {
beforeAll(function () {
})
beforeEach(function () {
})
afterEach(function () {
})
afterAll(function () {
})
/**
* @tc.number SUB_WMS_GETDEFALUTDISPLAY_JSAPI_001
* @tc.name Test getDefaultDisplay_Test_001
* @tc.desc To test the function of obtaining the default screen
*/
it('getDefaultDisplay_Test_001', 0, async function (done) {
console.log('displayTest getDefaultDisplayTest1 begin')
display.getDefaultDisplay().then(dsp => {
console.log('displayTest getDefaultDisplayTest1 getDefaultDisplay id :' + JSON.stringify(dsp))
expect(dsp.id != null).assertTrue();
expect(dsp.refreshRate != null).assertTrue();
expect(dsp.width != null).assertTrue();
expect(dsp.height != null).assertTrue();
done();
}, (err) => {
console.log('displayTest getDefaultDisplayTest1 getDefaultDisplay failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_GETDEFALUTDISPLAY_JSAPI_001
* @tc.name Test getDefaultDisplay_Test_002.
* @tc.desc To test the function if obtaining the default screen.
*/
it('getDefaultDisplay_Test_002', 0, async function (done) {
console.log('displayTest getDefaultDisplayTest2 begin');
display.getDefaultDisplay((err, data) => {
if (err.code != 0) {
console.log('displayTest getDefaultDisplayTest2 getDefaultDisplay callback fail' + JSON.stringify(err.code));
expect().assertFail();
done();
} else {
console.log('displayTest getDefaultDisplayTest2 getDefaultDisplay id :' + JSON.stringify(data));
expect(data.id != null).assertTrue();
expect(data.refreshRate != null).assertTrue();
expect(data.width != null).assertTrue();
expect(data.height != null).assertTrue();
done();
}
})
})
/**
* @tc.number SUB_WMS_GETALLDISPLAY_JSAPI_001
* @tc.name Test getAllDisplay_Test_001.
* @tc.desc To verify the function of obtaining all screens.
*/
it('getAllDisplay_Test_001', 0, async function (done) {
console.log('displayTest getAllDisplayTest1 begin')
display.getAllDisplay().then(dsp => {
console.log('displayTest getAllDisplayTest1 getAllDisplay id :' + JSON.stringify(dsp))
expect(dsp[0].id != null).assertTrue();
expect(dsp[0].refreshRate != null).assertTrue();
expect(dsp[0].width != null).assertTrue();
expect(dsp[0].height != null).assertTrue();
done();
}, (err) => {
console.log('displayTest getAllDisplayTest1 getAllDisplay failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_GETALLDISPLAY_JSAPI_002
* @tc.name Test getAllDisplay_Test_002
* @tc.desc To test the function if obtaining the default screen
*/
it('getAllDisplay_Test_002', 0, async function (done) {
console.log('displayTest getAllDisplayTest2 begin');
display.getAllDisplay((err, data) => {
if (err.code != 0) {
console.log('displayTest getAllDisplayTest2 getAllDisplay callback fail');
expect().assertFail();
done();
} else {
console.log('displayTest getAllDisplayTest2 getDefaultDisplay id :' + JSON.stringify(data));
expect(data[0].refreshRate != null).assertTrue();
expect(data[0].width != null).assertTrue();
expect(data[0].height != null).assertTrue();
done();
}
})
})
})
......@@ -405,7 +405,7 @@ describe('screenshot_test', function () {
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest10 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
expect().assertFail();
done();
})
})
......
/*
* Copyright (C) 2021 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_test', function(){
var wnd;
beforeAll(function(){
})
beforeEach(function(){
})
afterEach(function(){
})
afterAll(function(){
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_007
* @tc.name Test moveTestNegative.
* @tc.desc Test window.moveTo API function test7.
*/
it('moveTestNegative', 0,function(){
console.log('jsunittest moveTestNegative begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest moveTestNegative getTopWindow wnd: ' + wnd)
wnd.moveTo(-200,-200).then(()=>{
console.log('moveTo(-200,-200) success')
})
wnd.moveTo(0,0).then(()=>{
console.log('moveTo(0,0) success')
})
})
})
/**
* @tc.number SUB_WINDOW_RESETSIZE_JSAPI_006
* @tc.name Test resetSizeTestLoop.
* @tc.desc Test window.resetSize API function test6.
*/
it('resetSizeLoop', 0, function(){
var width = 100;
var height = 100;
console.log('jsunittest resetSizeLoop begin')
window.getTopWindow().then(wnd =>{
console.log('jsunittest resetSizeLoop getTopWindow wnd: ' + wnd)
for (let i = 1; i <= 5; i++){
width = width * i;
height = height * i;
wnd.resetSize(width, height).then(()=>{
console.log('jsunittest resetSizeTestLoop success')
})
}
wnd.resetSize(0,0).then(()=>{
console.log('jsunittest resetSizeTsetLoop wnd.resetSize(0,0) success')
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_008
* @tc.name Test setWindowTypeTestZero.
* @tc.desc Test window.setWindowType API function test8.
*/
it('setWindowTypeTestZero', 0, function(){
console.log('jsunittest setWindowTypeTestZero begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setWindowTypeTestZero getTopWindow wnd: ' + wnd)
wnd.setWindowType(window.WindowType.TYPE_APP).then(()=>{
console.log('jsunittest setWindowTypeTestZero wnd.setWindowType(0) success')
})
wnd.moveTo(200,200).then(()=>{
console.log('jsunittest setWindowTypeTestZero wnd.moveTo(200,200) success')
})
wnd.resetSize(200,200).then(()=>{
console.log('jsunittest setWindowTypeTestZero wnd.resetSize(200,200) success')
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_009
* @tc.name Test setWindowTypeTestThirty.
* @tc.desc Test window.setWindowType API function test9.
*/
it('setWindowTypeTestThirty', 0, function(){
console.log('jsunittest setWindowTypeTestThirty begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setWindowTypeTestThirty getTopWindow wnd: ' + wnd)
wnd.setWindowType(window.WindowType.TYPE_SYSTEM_ALTER).then(()=>{
console.log('jsunittest setWindowTypeTestThirty wnd.setWindowType(30) success')
})
wnd.moveTo(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTestThirty wnd.moveTo(200, 200) success')
})
wnd.resetSize(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTestThirty wnd.resetSize(200, 200) success')
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_010
* @tc.name Test setWindowTypeTestSeventy.
* @tc.desc Test window.setWindowType API function test10.
*/
it('setWindowTypeTestSeventy', 0, function(){
console.log('jsunittest setWindowTypeTestSeventy begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setWindowTypeTestSeventy getTopWindow wnd: ' + wnd)
wnd.setWindowType(window.WindowType.TYPE_SYSTEM_VOLUME).then(()=>{
console.log('jsunittest setWindowTypeTestSeventy wnd.setWindowType(70) success')
})
wnd.moveTo(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTestSeventy wnd.moveTo(200, 200) success')
})
wnd.resetSize(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTestSeventy wnd.resetSize(200, 200) success')
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_012
* @tc.name Test setWindowTypeTestNinety.
* @tc.desc Test window.setWindowType API function test12.
*/
it('setWindowTypeTestNinety', 0, function(){
console.log('jsunittest setWindowTypeTestNinety begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setWindowTypeTestNinety getTopWindow wnd: ' + wnd)
wnd.setWindowType(window.WindowType.TYPE_SYSTEM_PANEL).then(()=>{
console.log('jsunittest setWindowTypeTestNinety wnd.setWindowType(90) success')
})
wnd.moveTo(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTestNinety wnd.moveTo(200, 200) success')
})
wnd.resetSize(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTestNinety wnd.resetSize(200, 200) success')
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_011
* @tc.name Test setWindowTypeTestOrderChange.
* @tc.desc Test window.setWindowType API function test11.
*/
it('setWindowTypeTestOrderChange', 0, function(){
console.log('jsunittest setWindowTypeTestOrderChange begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setWindowTypeTestOrderChange getTopWindow wnd: ' + wnd)
wnd.setWindowType(window.WindowType.TYPE_APP).then(()=>{
console.log('jsunittest setWindowTypeTestOrderChange wnd.setWindowType(0) success')
})
wnd.resetSize(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTestOrderChange wnd.resetSize(200, 200) success')
})
wnd.moveTo(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTestOrderChange wnd.moveTo(200, 200) success')
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_013
* @tc.name Test setWindowTypeTest15.
* @tc.desc Test window.setWindowType API function test13.
*/
it('setWindowTypeTest15', 0, function(){
console.log('jsunittest setWindowTypeTest15 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setWindowTypeTest15 getTopWindow wnd: ' + wnd)
wnd.setWindowType(window.WindowType.TYPE_SYSTEM_ALTER).then(()=>{
console.log('jsunittest setWindowTypeTest15 wnd.setWindowType(30) success')
})
wnd.resetSize(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTest15 wnd.resetSize(200, 200) success')
})
wnd.moveTo(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTest15 wnd.moveTo(200, 200) success')
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_014
* @tc.name Test setWindowTypeTest16.
* @tc.desc Test window.setWindowType API function test14.
*/
it('setWindowTypeTest16', 0, function(){
console.log('jsunittest setWindowTypeTest16 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setWindowTypeTest16 getTopWindow wnd: ' + wnd)
wnd.setWindowType(window.WindowType.TYPE_SYSTEM_VOLUME).then(()=>{
console.log('jsunittest setWindowTypeTest16 wnd.setWindowType(70) success')
})
wnd.resetSize(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTest16 wnd.resetSize(200, 200) success')
})
wnd.moveTo(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTest16 wnd.moveTo(200, 200) success')
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_015
* @tc.name Test setWindowTypeTest17.
* @tc.desc Test window.setWindowType API function test15.
*/
it('setWindowTypeTest17', 0, function(){
console.log('jsunittest setWindowTypeTest17 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest setWindowTypeTest17 getTopWindow wnd: ' + wnd)
wnd.setWindowType(window.WindowType.TYPE_SYSTEM_PANEL).then(()=>{
console.log('jsunittest setWindowTypeTest17 wnd.setWindowType(90) success')
})
wnd.resetSize(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTest17 wnd.resetSize(200, 200) success')
})
wnd.moveTo(200, 200).then(()=>{
console.log('jsunittest setWindowTypeTest17 wnd.moveTo(200, 200) success')
})
})
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_006
* @tc.name Test moveTest6.
* @tc.desc Test window.moveTo API function test6.
*/
it('moveTest6', 0, function(){
console.log('jsunittest moveTest6 begin')
window.getTopWindow().then(wnd => {
console.log('jsunittest moveTest6 getTopWindow wnd: ' + wnd)
wnd.moveTo(-200, 200).then(()=>{
console.log('jsunittest moveTest6 wnd.moveTo(-200, 300) success')
})
wnd.moveTo(200, -300).then(()=>{
console.log('jsunittest moveTest6 wnd.moveTo(200, -300) success')
})
})
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册