提交 e18319e6 编写于 作者: L liziqiang

window release add xts test

Signed-off-by: Nliziqiang <liziqiang8@huawei.com>
上级 8c829e6e
...@@ -14,5 +14,4 @@ ...@@ -14,5 +14,4 @@
*/ */
require('./window.test.js') require('./window.test.js')
require('./display.test.js') require('./display.test.js')
require('./screenshot.test.js')
...@@ -41,6 +41,15 @@ describe('display_test', function () { ...@@ -41,6 +41,15 @@ describe('display_test', function () {
expect(dsp.refreshRate != null).assertTrue(); expect(dsp.refreshRate != null).assertTrue();
expect(dsp.width != null).assertTrue(); expect(dsp.width != null).assertTrue();
expect(dsp.height != null).assertTrue(); expect(dsp.height != null).assertTrue();
expect(dsp.rotation).assertEqual(undefined);
expect(dsp.densityDPI).assertEqual(undefined);
expect(dsp.name).assertEqual(undefined);
expect(dsp.alive).assertEqual(undefined);
expect(dsp.state).assertEqual(undefined);
expect(dsp.densityPixels).assertEqual(undefined);
expect(dsp.scaledDensity).assertEqual(undefined);
expect(dsp.xDPI).assertEqual(undefined);
expect(dsp.yDPI).assertEqual(undefined);
done(); done();
}, (err) => { }, (err) => {
console.log('displayTest getDefaultDisplayTest1 getDefaultDisplay failed, err :' + JSON.stringify(err)); console.log('displayTest getDefaultDisplayTest1 getDefaultDisplay failed, err :' + JSON.stringify(err));
...@@ -67,6 +76,15 @@ describe('display_test', function () { ...@@ -67,6 +76,15 @@ describe('display_test', function () {
expect(data.refreshRate != null).assertTrue(); expect(data.refreshRate != null).assertTrue();
expect(data.width != null).assertTrue(); expect(data.width != null).assertTrue();
expect(data.height != null).assertTrue(); expect(data.height != null).assertTrue();
expect(data.rotation).assertEqual(undefined);
expect(data.densityDPI).assertEqual(undefined);
expect(data.name).assertEqual(undefined);
expect(data.alive).assertEqual(undefined);
expect(data.state).assertEqual(undefined);
expect(data.densityPixels).assertEqual(undefined);
expect(data.scaledDensity).assertEqual(undefined);
expect(data.xDPI).assertEqual(undefined);
expect(data.yDPI).assertEqual(undefined);
done(); done();
} }
}) })
...@@ -85,6 +103,15 @@ describe('display_test', function () { ...@@ -85,6 +103,15 @@ describe('display_test', function () {
expect(dsp[0].refreshRate != null).assertTrue(); expect(dsp[0].refreshRate != null).assertTrue();
expect(dsp[0].width != null).assertTrue(); expect(dsp[0].width != null).assertTrue();
expect(dsp[0].height != null).assertTrue(); expect(dsp[0].height != null).assertTrue();
expect(dsp[0].rotation).assertEqual(undefined);
expect(dsp[0].densityDPI).assertEqual(undefined);
expect(dsp[0].name).assertEqual(undefined);
expect(dsp[0].alive).assertEqual(undefined);
expect(dsp[0].state).assertEqual(undefined);
expect(dsp[0].densityPixels).assertEqual(undefined);
expect(dsp[0].scaledDensity).assertEqual(undefined);
expect(dsp[0].xDPI).assertEqual(undefined);
expect(dsp[0].yDPI).assertEqual(undefined);
done(); done();
}, (err) => { }, (err) => {
console.log('displayTest getAllDisplayTest1 getAllDisplay failed, err :' + JSON.stringify(err)); console.log('displayTest getAllDisplayTest1 getAllDisplay failed, err :' + JSON.stringify(err));
...@@ -110,6 +137,15 @@ describe('display_test', function () { ...@@ -110,6 +137,15 @@ describe('display_test', function () {
expect(data[0].refreshRate != null).assertTrue(); expect(data[0].refreshRate != null).assertTrue();
expect(data[0].width != null).assertTrue(); expect(data[0].width != null).assertTrue();
expect(data[0].height != null).assertTrue(); expect(data[0].height != null).assertTrue();
expect(data[0].rotation).assertEqual(undefined);
expect(data[0].densityDPI).assertEqual(undefined);
expect(data[0].name).assertEqual(undefined);
expect(data[0].alive).assertEqual(undefined);
expect(data[0].state).assertEqual(undefined);
expect(data[0].densityPixels).assertEqual(undefined);
expect(data[0].scaledDensity).assertEqual(undefined);
expect(data[0].xDPI).assertEqual(undefined);
expect(data[0].yDPI).assertEqual(undefined);
done(); 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 { 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'
import screen from '@ohos.screen'
describe('screenshot_test', function () {
beforeAll(function () {
})
beforeEach(function () {
})
afterEach(function () {
})
afterAll(function () {
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_001
* @tc.name Test screenShotSave_Test_001
* @tc.desc Set the screenshot area to be larger than the screen width and height
*/
it('screenShotSave_Test_001', 0, function (done) {
console.log('screenshotTest screenShotSaveTest1 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest1 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest1 screenshot.save success, data :' + JSON.stringify(data));
expect().assertFail();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest1 screenshot.save failed, err : ' + JSON.stringify(err));
expect(err.code == 120).assertTrue();
done();
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest1 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_002
* @tc.name Test screenShotSave_Test_002
* @tc.desc Set the size of the screenshot area and the generated image to be larger than the screen width and height
*/
it('screenShotSave_Test_002', 0, function (done) {
console.log('screenshotTest screenShotSaveTest2 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest2 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest2 screenshot.save success, data :' + JSON.stringify(data));
expect().assertFail();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest2 screenshot.save failed, err : ' + JSON.stringify(err));
expect(err.code == 120).assertTrue();
done();
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest2 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done()
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_003
* @tc.name Test screenShotSave_Test_003
* @tc.desc Set the screenshot area and the size of the generated image to be smaller than the screen width and height
*/
it('screenShotSave_Test_003', 0, function (done) {
console.log('screenshotTest screenShotSaveTest3 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest3 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest3 screenshot.save success, data :' + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest3 screenshot.save failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest3 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_004
* @tc.name Test screenShotSave_Test_004
* @tc.desc Set the size of the generated image to be smaller than the screen width and height
*/
it('screenShotSave_Test_004', 0, function (done) {
console.log('screenshotTest screenShotSaveTest4 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest4 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest4 screenshot.save success, data :' + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest4 screenshot.save failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest4 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_005
* @tc.name Test screenShotSave_Test_005
* @tc.desc Set the screenshot area to a negative value
*/
it('screenShotSave_Test_005', 0, function (done) {
console.log('screenshotTest screenShotSaveTest5 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest5 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest5 screenshot.save success, data :' + JSON.stringify(data));
expect().assertFail();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest5 screenshot.save failed, err : ' + JSON.stringify(err));
expect(err.code == 120).assertTrue();
done();
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest5 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_006
* @tc.name Test screenShotSave_Test_006
* @tc.desc Set the screenshot area to 0
*/
it('screenShotSave_Test_006', 0, function (done) {
console.log('screenshotTest screenShotSaveTest6 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest6 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest6 screenshot.save success, data :' + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest6 screenshot.save failed, err : ' + JSON.stringify(err));
expect().assertFail();
done()
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest6 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_007
* @tc.name Test screenShotSave_Test_007
* @tc.desc Set the generated image size to a negative value
*/
it('screenShotSave_Test_007', 0, function (done) {
console.log('screenshotTest screenShotSaveTest7 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest7 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest7 screenshot.save success, data :' + JSON.stringify(data));
expect().assertFail();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest7 screenshot.save failed, err : ' + JSON.stringify(err));
expect(err.code == 120).assertTrue();
done();
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest7 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_008
* @tc.name Test screenShotSave_Test_008
* @tc.desc Set the generated image size to 0
*/
it('screenShotSave_Test_008', 0, function (done) {
console.log('screenshotTest screenShotSaveTest8 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest8 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest8 screenshot.save success, data :' + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest8 screenshot.save failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest8 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_009
* @tc.name Test screenShotSave_Test_009
* @tc.desc Set the screenshot area and the size of the generated image to be equal to the screen width and height
*/
it('screenShotSave_Test_009', 0, function (done) {
console.log('screenshotTest screenShotSaveTest9 begin');
display.getDefaultDisplay().then((dsp) => {
console.log('screenshotTest screenShotSaveTest9 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
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('screenshotTest screenShotSaveTest9 screenshot.save success, data :' + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest9 screenshot.save failed, err : ' + JSON.stringify(err));
expect().assertFail();
})
}, (err) => {
console.log('screenshotTest screenShotSaveTest9 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_010
* @tc.name Test screenShotSave_Test_010
* @tc.desc Take a screenshot of a screen that doesn't exist
*/
it('screenShotSave_Test_010', 0, function (done) {
console.log('screenshotTest 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('screenshotTest screenShotSaveTest10 screenshot.save success, data :' + JSON.stringify(data));
expect(data != null).assertTrue()
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest10 screenshot.save failed, err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_011
* @tc.name Test screenShotSave_Test_011
* @tc.desc Test screenshot.save API function test11
*/
it('screenShotSave_Test_011', 0, function (done) {
console.log('screenshotTest 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('screenshotTest screenShotSaveTest11 screenshot.save success, data :' + JSON.stringify(data));
expect().assertFail();
done();
}, (err) => {
console.log('screenshotTest screenShotSaveTest11 screenshot.save failed, err : ' + JSON.stringify(err));
expect(err.code == 120).assertTrue();
done();
})
})
})
\ No newline at end of file
...@@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
import window from '@ohos.window' import window from '@ohos.window'
import screen from '@ohos.screen' import screen from '@ohos.screen'
import display from '@ohos.display' import display from '@ohos.display'
import featureAbility from '@ohos.ability.featureAbility'
const TRUE_WINDOW = true; const TRUE_WINDOW = true;
const avoidAreaType = 3; const avoidAreaType = 3;
...@@ -25,7 +26,7 @@ describe('window_test', function () { ...@@ -25,7 +26,7 @@ describe('window_test', function () {
var topWindow; var topWindow;
const DELAY_TIME = 3000; const DELAY_TIME = 3000;
var height; var height;
var context = featureAbility.getContext();
function windowSizeChangeCallback(data) { function windowSizeChangeCallback(data) {
console.log('windowTest OnOffTest1 callback ' + JSON.stringify(data)); console.log('windowTest OnOffTest1 callback ' + JSON.stringify(data));
height = data.height; height = data.height;
...@@ -36,6 +37,21 @@ describe('window_test', function () { ...@@ -36,6 +37,21 @@ describe('window_test', function () {
height = data.bottomRect.height; height = data.bottomRect.height;
} }
function expectedError(error, caseName, apiName, done, code) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error));
expect(TRUE_WINDOW).assertTrue();
expect(error.code === code).assertTrue();
done();
}
function unexpectedError(error, caseName, apiName, done) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error));
expect(TRUE_WINDOW).assertFail();
done();
}
beforeAll(function (done) { beforeAll(function (done) {
console.log('windowTest beforeAll begin'); console.log('windowTest beforeAll begin');
window.getTopWindow().then(wnd => { window.getTopWindow().then(wnd => {
...@@ -95,11 +111,20 @@ describe('window_test', function () { ...@@ -95,11 +111,20 @@ describe('window_test', function () {
wnd.getProperties().then((data) => { wnd.getProperties().then((data) => {
console.log('windowTest getPropertiesTest1 wnd.getProperties success, data : ' + JSON.stringify(data)); console.log('windowTest getPropertiesTest1 wnd.getProperties success, data : ' + JSON.stringify(data));
expect(data.type != null).assertTrue(); expect(data.type != null).assertTrue();
expect(data.windowRect != 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).assertTrue(); expect(!data.isFullScreen).assertTrue();
expect(!data.isLayoutFullScreen).assertTrue(); expect(!data.isLayoutFullScreen).assertTrue();
expect(data.focusable).assertTrue(); expect(data.focusable).assertTrue();
expect(data.touchable).assertTrue(); expect(data.touchable).assertTrue();
expect(!data.isKeepScreenOn).assertTrue();
expect(!data.isTransparent).assertTrue();
expect(data.brightness != null).assertTrue();
expect(data.dimBehindValue).assertEqual(undefined);
expect(!data.isRoundCorner).assertTrue();
expect(!data.isPrivacyMode).assertTrue();
done(); done();
}, (err) => { }, (err) => {
console.log('windowTest getPropertiesTest1 wnd.getProperties failed, err : ' + JSON.stringify(err)); console.log('windowTest getPropertiesTest1 wnd.getProperties failed, err : ' + JSON.stringify(err));
...@@ -130,11 +155,20 @@ describe('window_test', function () { ...@@ -130,11 +155,20 @@ describe('window_test', function () {
done(); done();
} else { } else {
expect(data.type != null).assertTrue(); expect(data.type != null).assertTrue();
expect(data.windowRect != 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).assertTrue(); expect(!data.isFullScreen).assertTrue();
expect(!data.isLayoutFullScreen).assertTrue(); expect(!data.isLayoutFullScreen).assertTrue();
expect(data.focusable).assertTrue(); expect(data.focusable).assertTrue();
expect(data.touchable).assertTrue(); expect(data.touchable).assertTrue();
expect(!data.isKeepScreenOn).assertTrue();
expect(!data.isTransparent).assertTrue();
expect(data.brightness != null).assertTrue();
expect(data.dimBehindValue).assertEqual(undefined);
expect(!data.isRoundCorner).assertTrue();
expect(!data.isPrivacyMode).assertTrue();
done(); done();
} }
}) })
...@@ -997,6 +1031,7 @@ describe('window_test', function () { ...@@ -997,6 +1031,7 @@ describe('window_test', function () {
wnd.show().then(() => { wnd.show().then(() => {
wnd.isShowing().then(res => { wnd.isShowing().then(res => {
expect(res).assertTrue(); expect(res).assertTrue();
wnd.destroy();
done(); done();
}, (err) => { }, (err) => {
console.log('windowTest IsShowingTest1 wnd.isShowing failed, err :' + JSON.stringify(err)); console.log('windowTest IsShowingTest1 wnd.isShowing failed, err :' + JSON.stringify(err));
...@@ -1050,6 +1085,7 @@ describe('window_test', function () { ...@@ -1050,6 +1085,7 @@ describe('window_test', function () {
done(); done();
} else { } else {
expect(res2).assertTrue(); expect(res2).assertTrue();
data.destroy();
done(); done();
} }
}) })
...@@ -1443,11 +1479,11 @@ describe('window_test', function () { ...@@ -1443,11 +1479,11 @@ describe('window_test', function () {
/** /**
* @tc.number SUB_WMS_MOVETO_JSAPI_007 * @tc.number SUB_WMS_MOVETO_JSAPI_001
* @tc.name Test move_Test_001 * @tc.name Test move_Test_001
* @tc.desc Verify the scene where the window moves * @tc.desc Verify the scene where the window moves
*/ */
it('move_Test_001', 0, function () { it('move_Test_001', 0, function (done) {
console.log('windowTest moveTest1 begin'); console.log('windowTest moveTest1 begin');
window.getTopWindow().then(wnd => { window.getTopWindow().then(wnd => {
console.log('windowTest moveTest1 getTopWindow wnd' + wnd); console.log('windowTest moveTest1 getTopWindow wnd' + wnd);
...@@ -1556,7 +1592,7 @@ describe('window_test', function () { ...@@ -1556,7 +1592,7 @@ describe('window_test', function () {
for (var i = 1; i <= 5; i++) { for (var i = 1; i <= 5; i++) {
wnd.moveTo(100, 100).then(() => { wnd.moveTo(100, 100).then(() => {
expect(TRUE_WINDOW).assertTrue(); expect(TRUE_WINDOW).assertTrue();
},(err) => { }, (err) => {
console.log('windowTest moveTest5 wnd.moveTo failed, err :' + JSON.stringify(err)); console.log('windowTest moveTest5 wnd.moveTo failed, err :' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
...@@ -1572,23 +1608,24 @@ describe('window_test', function () { ...@@ -1572,23 +1608,24 @@ describe('window_test', function () {
}) })
/** /**
* @tc.number SUB_WMS_MOVETO_JSAPI_001 * @tc.number SUB_WMS_MOVETO_JSAPI_006
* @tc.name Test move_Test_006 * @tc.name Test move_Test_006
* @tc.desc Verify that the window is moved into the normal scene * @tc.desc Verify the scene where the window moves
*/ */
it('move_Test_006', 0, async function (done) { it('move_Test_006', 0, async function (done) {
console.log('windowTest moveTest6 begin'); console.log('windowTest moveTest6 begin');
window.getTopWindow().then(wnd => { window.getTopWindow().then(wnd => {
console.log('windowTest moveTest6 getTopWindow wnd: ' + wnd); console.log('windowTest moveTest6 getTopWindow wnd: ' + wnd);
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
wnd.moveTo(200, 200).then(() => { wnd.moveTo(-200, -200, (err) => {
if (err) {
console.log('windowTest moveTest6 wnd.moveTo failed, err :' + JSON.stringify(err));
done();
} else {
console.log('windowTest moveTest6 wnd.moveTo success'); console.log('windowTest moveTest6 wnd.moveTo success');
expect(TRUE_WINDOW).assertTrue(); expect(TRUE_WINDOW).assertTrue();
done(); done();
}, (err) => { }
console.log('windowTest moveTest6 wnd.moveTo failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
}) })
}, (err) => { }, (err) => {
console.log('windowTest moveTest6 getTopWindow failed, err :' + JSON.stringify(err)); console.log('windowTest moveTest6 getTopWindow failed, err :' + JSON.stringify(err));
...@@ -1791,7 +1828,7 @@ describe('window_test', function () { ...@@ -1791,7 +1828,7 @@ describe('window_test', function () {
* @tc.name Test resetSize_Test_006 * @tc.name Test resetSize_Test_006
* @tc.desc Verify the scene where the window resets size * @tc.desc Verify the scene where the window resets size
*/ */
it('resetSize_Test_006', 0, function () { it('resetSize_Test_006', 0, function (done) {
console.log('windowTest ResetSizeTest6 begin'); console.log('windowTest ResetSizeTest6 begin');
window.getTopWindow().then(wnd => { window.getTopWindow().then(wnd => {
console.log('windowTest ResetSizeTest6 getTopWindow wnd: ' + wnd); console.log('windowTest ResetSizeTest6 getTopWindow wnd: ' + wnd);
...@@ -1910,4 +1947,912 @@ describe('window_test', function () { ...@@ -1910,4 +1947,912 @@ describe('window_test', function () {
}) })
}) })
/**
* @tc.number SUB_WMS_ENUM_WINDOWSTAGEEVENTTYPE_JSAPI_001
* @tc.name Test enumWindowStageEventType_Test_001.
* @tc.desc To test the enum value of WindowStageEventType.
*/
it('enumWindowStageEventType_Test_001', 0, async function (done) {
console.log('test the enum value of WindowStageEventType begin');
try {
expect(1).assertEqual(window.WindowStageEventType.FOREGROUND);
expect(2).assertEqual(window.WindowStageEventType.ACTIVE);
expect(3).assertEqual(window.WindowStageEventType.INACTIVE);
expect(4).assertEqual(window.WindowStageEventType.BACKGROUND);
done();
} catch (err) {
console.log('test enum value of windowStageEventType error ' + JSON.stringify(err));
}
})
/**
* @tc.number SUB_WMS_ENUM_WINDOWTYPE_JSAPI_001
* @tc.name Test enumWindowType_Test_001.
* @tc.desc To test the enum value of WindowType.
*/
it('enumWindowType_Test_001', 0, async function (done) {
console.log('windowTest the enum value of Window begin');
try {
expect(0).assertEqual(window.WindowType.TYPE_APP);
expect(1).assertEqual(window.WindowType.TYPE_SYSTEM_ALERT);
done();
} catch (err) {
console.log('windowTest enum value of WindowType error ' + JSON.stringify(err));
}
})
/**
* @tc.number SUB_WMS_SETFOCUSABLE_JSAPI_001
* @tc.name Test setFocusable_Test_001
* @tc.desc Setting window focus acquisition and defocus
*/
it('setFocusable_Test_001', 0, function (done) {
console.log('windowTest setFocusableTest1 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setFocusableTest1 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.getProperties().then(data => {
expect(data.focusable).assertTrue();
wnd.setFocusable(false).then(() => {
console.log('windowTest setFocusableTest1 setFocusable(false) success ');
wnd.getProperties().then(data => {
expect(!data.focusable).assertTrue();
wnd.setFocusable(true).then(() => {
console.log('windowTest setFocusableTest1 setFocusable(true) success ');
expect(TRUE_WINDOW).assertTrue();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest1 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest1 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETFOCUSABLE_JSAPI_002
* @tc.name Test setFocusable_Test_002
* @tc.desc The setting window loses focus and cannot be touched
*/
it('setFocusable_Test_002', 0, function (done) {
console.log('windowTest setFocusableTest2 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setFocusableTest2 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setFocusable(false).then(() => {
console.log('windowTest setFocusableTest2 setFocusable(false) success ');
wnd.getProperties().then(data => {
expect(!data.focusable).assertTrue();
wnd.setTouchable(false).then(() => {
console.log('windowTest setFocusableTest2 setTouchable(false) success ');
wnd.getProperties().then(data => {
expect(!data.touchable).assertTrue();
done();
}, (err) => {
console.log('windowTest setFocusableTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest2 setTouchable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest2 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest2 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETFOCUSABLE_JSAPI_003
* @tc.name Test setFocusable_Test_003
* @tc.desc Set the window to lose focus and be touchable
*/
it('setFocusable_Test_003', 0, function (done) {
console.log('windowTest setFocusableTest3 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setFocusableTest3 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setFocusable(false).then(() => {
console.log('windowTest setFocusableTest3 setFocusable(false) success ');
wnd.getProperties().then(data => {
expect(!data.focusable).assertTrue();
wnd.setTouchable(true).then(() => {
console.log('windowTest setFocusableTest3 setTouchable(true) success ');
wnd.getProperties().then(data => {
expect(data.touchable).assertTrue();
done();
}, (err) => {
console.log('windowTest setFocusableTest3 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest3 setTouchable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest3 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest3 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest3 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETFOCUSABLE_JSAPI_004
* @tc.name Test setFocusable_Test_004
* @tc.desc Setting the window to get focus is not touchable
*/
it('setFocusable_Test_004', 0, function (done) {
console.log('windowTest setFocusableTest4 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setFocusableTest4 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setFocusable(true).then(() => {
console.log('windowTest setFocusableTest4 setFocusable(true) success ');
wnd.getProperties().then(data => {
expect(data.focusable).assertTrue();
wnd.setTouchable(false).then(() => {
console.log('windowTest setFocusableTest4 setTouchable(false) success ');
wnd.getProperties().then(data => {
expect(!data.touchable).assertTrue();
done();
}, (err) => {
console.log('windowTest setFocusableTest4 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest4 setTouchable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest4 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest4 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest4 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETFOCUSABLE_JSAPI_005
* @tc.name Test setFocusable_Test_005
* @tc.desc Set the window to get focus and touch
*/
it('setFocusable_Test_005', 0, function (done) {
console.log('windowTest setFocusableTest5 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setFocusableTest5 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setFocusable(true).then(() => {
console.log('windowTest setFocusableTest5 setFocusable(true) success ');
wnd.getProperties().then(data => {
expect(data.focusable).assertTrue();
wnd.setTouchable(true).then(() => {
console.log('windowTest setFocusableTest5 setTouchable(true) success ');
wnd.getProperties().then(data => {
expect(data.touchable).assertTrue();
done();
}, (err) => {
console.log('windowTest setFocusableTest5 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest5 setTouchable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest5 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest5 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setFocusableTest5 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETTOUCHABLE_JSAPI_001
* @tc.name Test setTouchable_Test_001
* @tc.desc Set whether the window can be touched or not
*/
it('setTouchable_Test_001', 0, function (done) {
console.log('windowTest setTouchableTest1 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setTouchableTest1 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.getProperties().then(data => {
expect(data.touchable).assertTrue();
wnd.setTouchable(false).then(() => {
console.log('windowTest setTouchableTest1 setTouchable(false) success ');
wnd.getProperties().then(data => {
expect(!data.touchable).assertTrue();
wnd.setTouchable(true).then(() => {
console.log('windowTest setTouchableTest1 setTouchable(true) success ');
wnd.getProperties().then(data => {
expect(data.touchable).assertTrue();
done();
}, (err) => {
console.log('windowTest setTouchableTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setTouchableTest1 setTouchable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setTouchableTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setTouchableTest1 setTouchable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setTouchableTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setTouchableTest1 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETKEEPSCREENON_JSAPI_001
* @tc.name Test setKeepScreenOn_Test_001
* @tc.desc Set whether the window can be touched or not
*/
it('setKeepScreenOn_Test_001', 0, function (done) {
console.log('windowTest setKeepScreenOnTest1 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setKeepScreenOnTest1 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.getProperties().then(data => {
expect(!data.isKeepScreenOn).assertTrue();
wnd.setKeepScreenOn(true).then(() => {
console.log('windowTest setKeepScreenOnTest1 setKeepScreenOn(true) success ');
wnd.getProperties().then(data => {
expect(data.isKeepScreenOn).assertTrue();
wnd.setKeepScreenOn(false).then(() => {
console.log('windowTest setKeepScreenOnTest1 setKeepScreenOn(false) success ');
wnd.getProperties().then(data => {
expect(!data.isKeepScreenOn).assertTrue();
done();
}, (err) => {
console.log('windowTest setKeepScreenOnTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest1 setKeepScreenOn failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest1 setKeepScreenOn failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest1 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETKEEPSCREENON_JSAPI_002
* @tc.name Test setKeepScreenOn_Test_002
* @tc.desc Set whether the window can be touched or not
*/
it('setKeepScreenOn_Test_002', 0, function (done) {
console.log('windowTest setKeepScreenOnTest2 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setKeepScreenOnTest2 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
for (let i = 0; i < 5; i++) {
wnd.getProperties().then(data => {
expect(!data.isKeepScreenOn).assertTrue();
wnd.setKeepScreenOn(true).then(() => {
console.log('windowTest setKeepScreenOnTest2 setKeepScreenOn(true) success ');
wnd.getProperties().then(data => {
expect(data.isKeepScreenOn).assertTrue();
wnd.setKeepScreenOn(false).then(() => {
console.log('windowTest setKeepScreenOnTest2 setKeepScreenOn(false) success ');
wnd.getProperties().then(data => {
expect(!data.isKeepScreenOn).assertTrue();
}, (err) => {
console.log('windowTest setKeepScreenOnTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest2 setKeepScreenOn failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest2 setKeepScreenOn failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setKeepScreenOnTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
done();
}, (err) => {
console.log('windowTest setKeepScreenOnTest2 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLOR_JSAPI_001
* @tc.name Test setBackgroundColor_Test_001
* @tc.desc Set the window background color to red and Default opacity
*/
it('setBackgroundColor_Test_001', 0, function (done) {
console.log('windowTest setBackgroundColorTest1 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorTest1 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#ffff00").then(() => {
console.log('windowTest setBackgroundColorTest1 setBrightness(#ffff00) success ');
wnd.getProperties().then(data => {
expect(!data.isTransparent).assertTrue();
done();
}, (err) => {
console.log('windowTest setBackgroundColorTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest1 setBackgroundColor failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest1 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLOR_JSAPI_002
* @tc.name Test setBackgroundColor_Test_002
* @tc.desc Set the window background color to red opaque
*/
it('setBackgroundColor_Test_002', 0, function (done) {
console.log('windowTest setBackgroundColorTest2 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorTest2 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#ffffff00").then(() => {
console.log('windowTest setBackgroundColorTest2 setBrightness(#ffffff00) success ');
wnd.getProperties().then(data => {
expect(!data.isTransparent).assertTrue();
done();
}, (err) => {
console.log('windowTest setBackgroundColorTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest2 setBackgroundColor failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest2 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLOR_JSAPI_003
* @tc.name Test setBackgroundColor_Test_003
* @tc.desc Set the window background color to red transparent
*/
it('setBackgroundColor_Test_003', 0, function (done) {
console.log('windowTest setBackgroundColorTest3 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorTest3 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#00ffff00").then(() => {
console.log('windowTest setBackgroundColorTest3 setBrightness(#00ffff00) success ');
wnd.getProperties().then(data => {
expect(data.isTransparent).assertTrue();
done();
}, (err) => {
console.log('windowTest setBackgroundColorTest3 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest3 setBackgroundColor failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest3 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLOR_JSAPI_004
* @tc.name Test setBackgroundColor_Test_004
* @tc.desc Set the background color input parameter as an outlier
*/
it('setBackgroundColor_Test_004', 0, function (done) {
console.log('windowTest setBackgroundColorTest4 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorTest4 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("ff00").then(() => {
console.log('windowTest setBackgroundColorTest4 setBrightness(#ff00) success ');
expect().assertFail();
done();
}, (err) => {
console.log('windowTest setBackgroundColorTest4 setBackgroundColor failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(130);
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest4 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLOR_JSAPI_005
* @tc.name Test setBackgroundColor_Test_005
* @tc.desc Setting window background color input exception ARGB
*/
it('setBackgroundColor_Test_005', 0, function (done) {
console.log('windowTest setBackgroundColorTest5 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorTest5 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#hhgghhgg").then(() => {
console.log('windowTest setBackgroundColorTest5 setBrightness(#hhgghhgg) success ');
expect().assertFail();
done();
}, (err) => {
console.log('windowTest setBackgroundColorTest5 setBackgroundColor failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(130);
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest5 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLOR_JSAPI_006
* @tc.name Test setBackgroundColor_Test_006
* @tc.desc Setting window background color input exception RGB
*/
it('setBackgroundColor_Test_006', 0, function (done) {
console.log('windowTest setBackgroundColorTest6 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorTest6 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#gghhkk").then(() => {
console.log('windowTest setBackgroundColorTest6 setBrightness(#gghhkk) success ');
expect().assertFail();
done();
}, (err) => {
console.log('windowTest setBackgroundColorTest6 setBackgroundColor failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(130);
done();
})
}, (err) => {
console.log('windowTest setBackgroundColorTest6 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESS_JSAPI_001
* @tc.name Test setBrightness_Test_001
* @tc.desc Setting the brightness bar input parameter is normal
*/
it('setBrightness_Test_001', 0, function (done) {
console.log('windowTest setBrightnessTest1 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTest1 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(0).then(() => {
console.log('windowTest setBrightnessTest1 setBrightness(0) success ');
wnd.getProperties().then(data => {
console.log('windowTest setBrightnessTest1 getProperties data ' + data);
expect(data.brightness).assertEqual(0);
wnd.setBrightness(0.5).then(() => {
console.log('windowTest setBrightnessTest1 setBrightness(0.5) success ');
wnd.getProperties().then(data => {
console.log('windowTest setBrightnessTest1 getProperties data ' + data);
expect(data.brightness).assertEqual(0.5);
wnd.setBrightness(1).then(() => {
console.log('windowTest setBrightnessTest1 setBrightness(1) success ');
wnd.getProperties().then(data => {
console.log('windowTest setBrightnessTest1 getProperties data ' + data);
expect(data.brightness).assertEqual(1);
done();
}, (err) => {
console.log('windowTest setBrightnessTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest1 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest1 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest1 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest1 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESS_JSAPI_002
* @tc.name Test setBrightness_Test_002
* @tc.desc Set the brightness bar input parameter to decimal
*/
it('setBrightness_Test_002', 0, function (done) {
console.log('windowTest setBrightnessTest2 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTest2 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(0.564789).then(() => {
console.log('windowTest setBrightnessTest2 setBrightness(0.564789) success ');
wnd.getProperties().then(data => {
console.log('windowTest setBrightnessTest2 getProperties data ' + data);
expect(TRUE_WINDOW).assertTrue();
done();
}, (err) => {
console.log('windowTest setBrightnessTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest2 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest2 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESS_JSAPI_003
* @tc.name Test setBrightness_Test_003
* @tc.desc Set the brightness bar input parameter to number max
*/
it('setBrightness_Test_003', 0, function (done) {
console.log('windowTest setBrightnessTest3 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTest3 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(Number.MAX_VALUE).then(() => {
console.log('windowTest setBrightnessTest3 setBrightness(Number.MAX_VALUE) success ');
expect().assertFail();
done();
}, (err) => {
console.log('windowTest setBrightnessTest3 setBrightness failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(130);
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest3 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESS_JSAPI_004
* @tc.name Test setBrightness_Test_004
* @tc.desc Set the brightness bar input parameter to number min
*/
it('setBrightness_Test_004', 0, function (done) {
console.log('windowTest setBrightnessTest4 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTest4 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(Number.MIN_VALUE).then(() => {
console.log('windowTest setBrightnessTest4 setBrightness(Number.MIN_VALUE) success ');
expect(TRUE_WINDOW).assertTrue();
done();
}, (err) => {
console.log('windowTest setBrightnessTest4 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest4 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESS_JSAPI_005
* @tc.name Test setBrightness_Test_005
* @tc.desc Setting brightness bar input parameter exception
*/
it('setBrightness_Test_005', 0, function (done) {
console.log('windowTest setBrightnessTest5 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTest5 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(1.1).then(() => {
console.log('windowTest setBrightnessTest5 setBrightness(1.1) success ');
expect().assertFail();
done();
}, (err) => {
console.log('windowTest setBrightnessTest5 setBrightness failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(130);
wnd.setBrightness(-0.1).then(() => {
console.log('windowTest setBrightnessTest5 setBrightness(-0.1) success ');
expect().assertFail();
done();
}, (err) => {
console.log('windowTest setBrightnessTest5 setBrightness failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(130);
done();
})
})
}, (err) => {
console.log('windowTest setBrightnessTest5 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_007
* @tc.name Test loadContentTest7
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest7', 0, function (done) {
let caseName = 'loadContentTest7';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 0;
let windowId = 'loadContentTest7';
console.log(msgStr + 'begin');
let tempWnd = null
window.create(context, windowId, baseWndType, (err, data) => {
console.log(msgStr + 'window.create err' + JSON.stringify(err));
console.log(msgStr + 'window.create data' + JSON.stringify(data));
console.log(msgStr + 'window.create !!data' + !!data);
if (!!data) {
tempWnd = data
expect(!!tempWnd).assertTrue();
tempWnd.loadContent('pages/index', (err, data) => {
console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data));
console.log(msgStr + 'tempWnd.loadContent !!data' + !!data);
if (err && err.code) {
expectedError(err, caseName, 'tempWnd.loadContent', done);
} else {
expect(!data).assertTrue();
done();
}
})
} else {
unexpectedError(err, caseName, 'window.create', done);
}
})
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_008
* @tc.name Test loadContentTest8
* @tc.desc Verify the scenario of loading a page that does not exist
*/
it('loadContentTest8', 0, function (done) {
let caseName = 'loadContentTest8';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 0;
let windowId = 'loadContentTest8';
console.log(msgStr + 'begin');
let tempWnd = null
window.create(context, windowId, baseWndType, (err, data) => {
console.log(msgStr + 'window.create err' + JSON.stringify(err));
console.log(msgStr + 'window.create data' + JSON.stringify(data));
console.log(msgStr + 'window.create !!data' + !!data);
if (!!data) {
tempWnd = data
expect(!!tempWnd).assertTrue();
tempWnd.loadContent(null, (err, data) => {
console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data));
console.log(msgStr + 'tempWnd.loadContent !!data' + !!data);
if (err && err.code) {
expect(err.code === 130).assertTrue();
done();
} else {
expectedError(err, caseName, 'tempWnd.loadContent', done);
}
})
} else {
unexpectedError(err, caseName, 'window.create', done);
}
})
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_001
* @tc.name Test loadContentTest1
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest1', 0, async function (done) {
let caseName = 'loadContentTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 0;
let windowId = 'loadContentTest1';
console.log(msgStr + 'begin');
let tempWnd = await window.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'window.create', done);
});
console.log(msgStr + 'window.create ' + baseWndType + ' , wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let load = await tempWnd.loadContent('pages/index/index').catch((err) => {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
console.log(msgStr+'tempWnd.loadContent(pages/index/index) err='+JSON.stringify(err));
});
console.log(msgStr+'tempWnd.loadContent(pages/index/index) load='+JSON.stringify(load));
expect(!load).assertTrue();
done();
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_002
* @tc.name Test loadContentTest2
* @tc.desc Verify the scene of loading the page with illegal values
*/
it('loadContentTest2', 0, async function (done) {
let caseName = 'loadContentTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 0;
let windowId = 'loadContentTest2';
console.log(msgStr + 'begin');
let tempWnd = await window.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'window.create', done);
});
console.log(msgStr + 'window.create ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let errFlag = false;
await tempWnd.loadContent(null).catch((err) => {
errFlag = true;
expectedError(err, caseName, 'tempWnd.loadContent', done, 130);
console.log(msgStr+'tempWnd.loadContent(null)'+JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent end');
if (!errFlag) {
console.log(msgStr + 'should report err');
expect(TRUE_WINDOW).assertFail();
done();
}
})
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册