未验证 提交 f6c5c3cc 编写于 作者: O openharmony_ci 提交者: Gitee

!2851 [【窗口子系统】修改测试用例设计和代码冗余

Merge pull request !2851 from hk_js/cherry-pick-1648196707
...@@ -16,60 +16,27 @@ import app from '@system.app' ...@@ -16,60 +16,27 @@ import app from '@system.app'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
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'
const TRUE_WINDOW = true; const TRUE_WINDOW = true;
const avoidAreaType = 3; const avoidAreaType = 3;
describe('window_test', function () { describe('window_test', function () {
var wnd; var wnd;
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 topWindow; var topWindow;
const DELAY_TIME = 3000; const DELAY_TIME = 3000;
var listenerStatus; var height;
function callback(data) { function windowSizeChangeCallback(data) {
listenerStatus = 1; console.log('windowTest OnOffTest1 callback ' + JSON.stringify(data));
console.log('windowTest OnOffTest callback ' + JSON.stringify(data) + height = data.height;
'listenerStatus :' + listenerStatus); }
function systemAvoidAreaChangeCallback(data) {
console.log('windowTest OnOffTest2 callback ' + JSON.stringify(data));
height = data.bottomRect.height;
} }
beforeAll(function (done) { beforeAll(function (done) {
windowTypeArr = Object.keys(windowTypeDic);
console.log('windowTest beforeAll begin'); console.log('windowTest beforeAll begin');
window.getTopWindow().then(wnd => { window.getTopWindow().then(wnd => {
console.log('windowTest beforeAll window.getTopWindow wnd: ' + wnd); console.log('windowTest beforeAll window.getTopWindow wnd: ' + wnd);
...@@ -874,7 +841,7 @@ describe('window_test', function () { ...@@ -874,7 +841,7 @@ describe('window_test', function () {
*/ */
it('find_Test_002', 0, async function (done) { it('find_Test_002', 0, async function (done) {
console.log('windowTest findTest2 begin'); console.log('windowTest findTest2 begin');
window.find('nonexist').then((window) => { window.find('window').then((window) => {
console.log('windowTest findTest2 wnd.find success, window : ' + JSON.stringify(window)); console.log('windowTest findTest2 wnd.find success, window : ' + JSON.stringify(window));
expect().assertFail(); expect().assertFail();
done(); done();
...@@ -912,7 +879,7 @@ describe('window_test', function () { ...@@ -912,7 +879,7 @@ describe('window_test', function () {
*/ */
it('find_Test_004', 0, async function (done) { it('find_Test_004', 0, async function (done) {
console.log('windowTest findTest4 begin'); console.log('windowTest findTest4 begin');
window.find('nonexist', (err, data) => { window.find('window', (err, data) => {
if (err.code) { if (err.code) {
console.log('windowTest findTest4 wnd.find fail, err : ' + JSON.stringify(err)); console.log('windowTest findTest4 wnd.find fail, err : ' + JSON.stringify(err));
expect(TRUE_WINDOW).assertTrue(); expect(TRUE_WINDOW).assertTrue();
...@@ -933,40 +900,43 @@ describe('window_test', function () { ...@@ -933,40 +900,43 @@ describe('window_test', function () {
*/ */
it('onOff_Test_001', 0, async function (done) { it('onOff_Test_001', 0, async function (done) {
console.log('windowTest OnOffTest1 begin'); console.log('windowTest OnOffTest1 begin');
window.getTopWindow((err, data) => { display.getDefaultDisplay().then(dsp => {
if (err.code != 0) { window.getTopWindow((err, data) => {
console.log('windowTest OnOffTest1 getTopWindow fail ' + JSON.stringify(err.code)); if (err.code != 0) {
expect().assertFail(); console.log('windowTest OnOffTest1 getTopWindow fail ' + JSON.stringify(err.code));
done(); expect().assertFail();
} else { done();
expect(data != null).assertTrue(); } else {
data.on('windowSizeChange', callback); expect(data != null).assertTrue();
data.setLayoutFullScreen(true, (err) => { data.on('windowSizeChange', windowSizeChangeCallback);
if (err.code != 0) { data.setLayoutFullScreen(true, (err) => {
console.log('windowTest OnOffTest1 setLayoutFullScreen fail ' + JSON.stringify(err.code)); if (err.code != 0) {
expect().assertFail(); console.log('windowTest OnOffTest1 setLayoutFullScreen fail ' + JSON.stringify(err.code));
done(); expect().assertFail();
} else { done();
setTimeout((async function () { } else {
expect(listenerStatus).assertEqual(1); setTimeout((async function () {
data.off('windowSizeChange') expect(dsp.height == height).assertTrue();
listenerStatus = 0; data.off('windowSizeChange');
data.setLayoutFullScreen(false, (err) => { data.setLayoutFullScreen(false, (err) => {
if (err.code != 0 || listenerStatus == 1) { if (err.code != 0) {
console.log('windowTest OnOffTest1 setLayoutFullScreen callback fail ' + JSON.stringify(err)); console.log('windowTest OnOffTest1 setLayoutFullScreen callback fail ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
} else { } else {
console.log('windowTest OnOffTest1 listenerStatus 3: ' + listenerStatus); expect(dsp.height == height).assertTrue();
expect(TRUE_WINDOW).assertTrue(); done();
done(); }
} })
}) }), 3000)
}), 3000) }
} })
}) }
} })
}, (err) => {
console.log('displayTest OnOffTest1 getDefaultDisplay failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
}) })
}) })
...@@ -976,7 +946,7 @@ describe('window_test', function () { ...@@ -976,7 +946,7 @@ describe('window_test', function () {
* @tc.desc To verify the function of enabling and disabling lawful interception in the system and window * @tc.desc To verify the function of enabling and disabling lawful interception in the system and window
*/ */
it('onOff_Test_002', 0, async function (done) { it('onOff_Test_002', 0, async function (done) {
console.log('windowTest OnOffTest2 begin') console.log('windowTest OnOffTest2 begin');
window.getTopWindow((err, data) => { window.getTopWindow((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log('windowTest OnOffTest2 getTopWindow callback fail ' + JSON.stringify(err.code)); console.log('windowTest OnOffTest2 getTopWindow callback fail ' + JSON.stringify(err.code));
...@@ -984,7 +954,7 @@ describe('window_test', function () { ...@@ -984,7 +954,7 @@ describe('window_test', function () {
done(); done();
} else { } else {
expect(data != null).assertTrue(); expect(data != null).assertTrue();
data.on('systemAvoidAreaChange', callback); data.on('systemAvoidAreaChange', systemAvoidAreaChangeCallback);
data.setFullScreen(true, (err) => { data.setFullScreen(true, (err) => {
if (err.code != 0) { if (err.code != 0) {
console.log('windowTest OnOffTest2 setLayoutFullScreen callback fail ' + JSON.stringify(err)); console.log('windowTest OnOffTest2 setLayoutFullScreen callback fail ' + JSON.stringify(err));
...@@ -992,18 +962,16 @@ describe('window_test', function () { ...@@ -992,18 +962,16 @@ describe('window_test', function () {
done(); done();
} else { } else {
setTimeout((async function () { setTimeout((async function () {
console.log('windowTest OnOffTest2 listenerStatus 111: ' + listenerStatus); expect(height == 0).assertTrue();
expect(listenerStatus).assertEqual(1); data.off('systemAvoidAreaChange');
data.off('systemAvoidAreaChange')
listenerStatus = 0;
data.setFullScreen(false, (err) => { data.setFullScreen(false, (err) => {
if (err.code != 0 || listenerStatus == 1) { if (err.code != 0) {
console.log('windowTest OnOffTest2 setLayoutFullScreen callback fail ' + JSON.stringify(err)); console.log('windowTest OnOffTest2 setLayoutFullScreen callback fail ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
} else { } else {
console.log('windowTest OnOffTest2 off callback success'); console.log('windowTest OnOffTest2 off callback success');
expect(TRUE_WINDOW).assertTrue(); expect(height == 0).assertTrue();
done(); done();
} }
}) })
...@@ -1021,7 +989,7 @@ describe('window_test', function () { ...@@ -1021,7 +989,7 @@ describe('window_test', function () {
*/ */
it('isShowing_Test_001', 0, async function (done) { it('isShowing_Test_001', 0, async function (done) {
console.log('windowTest IsShowingTest1 begin'); console.log('windowTest IsShowingTest1 begin');
window.create('isShow1', window.WindowType.TYPE_APP).then(wnd => { window.create('subWindow1', window.WindowType.TYPE_APP).then(wnd => {
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
wnd.isShowing().then(res => { wnd.isShowing().then(res => {
console.log('windowTest IsShowingTest1 wnd.isShowing data:' + res); console.log('windowTest IsShowingTest1 wnd.isShowing data:' + res);
...@@ -1055,7 +1023,7 @@ describe('window_test', function () { ...@@ -1055,7 +1023,7 @@ describe('window_test', function () {
*/ */
it('isShowing_Test_002', 0, async function (done) { it('isShowing_Test_002', 0, async function (done) {
console.log('windowTest IsShowingTest2 begin'); console.log('windowTest IsShowingTest2 begin');
window.create('isShow2', window.WindowType.TYPE_APP, (err, data) => { window.create('subWindow2', window.WindowType.TYPE_APP, (err, data) => {
if (err.code) { if (err.code) {
console.log('windowTest IsShowingTest2 window.create fail err ' + JSON.stringify(err)); console.log('windowTest IsShowingTest2 window.create fail err ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
...@@ -1106,7 +1074,7 @@ describe('window_test', function () { ...@@ -1106,7 +1074,7 @@ describe('window_test', function () {
wnd.setColorSpace(window.ColorSpace.WIDE_GAMUT).then(() => { wnd.setColorSpace(window.ColorSpace.WIDE_GAMUT).then(() => {
console.log('windowTest SetColorSpaceTest1 setColorSpace WIDE_GAMUT'); console.log('windowTest SetColorSpaceTest1 setColorSpace WIDE_GAMUT');
wnd.getColorSpace().then(res => { wnd.getColorSpace().then(res => {
expect(res == 1).assertTrue(); expect(res == window.ColorSpace.WIDE_GAMUT).assertTrue();
console.log('windowTest SetColorSpaceTest1 setColorSpace WIDE_GAMUT success'); console.log('windowTest SetColorSpaceTest1 setColorSpace WIDE_GAMUT success');
wnd.isSupportWideGamut().then(data => { wnd.isSupportWideGamut().then(data => {
expect(data).assertTrue(); expect(data).assertTrue();
...@@ -1181,7 +1149,7 @@ describe('window_test', function () { ...@@ -1181,7 +1149,7 @@ describe('window_test', function () {
expect().assertFail(); expect().assertFail();
done(); done();
} else { } else {
expect(data == 1).assertTrue(); expect(data == window.ColorSpace.WIDE_GAMUT).assertTrue();
wnd.isSupportWideGamut((err, data) => { wnd.isSupportWideGamut((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log('windowTest SetColorSpaceTest3 getColorSpace callback fail' + JSON.stringify(err)); console.log('windowTest SetColorSpaceTest3 getColorSpace callback fail' + JSON.stringify(err));
...@@ -1238,7 +1206,7 @@ describe('window_test', function () { ...@@ -1238,7 +1206,7 @@ describe('window_test', function () {
*/ */
it('create_Test_001', 0, async function (done) { it('create_Test_001', 0, async function (done) {
console.log('windowTest CreateTest1 begin'); console.log('windowTest CreateTest1 begin');
window.create('subWindow', window.WindowType.TYPE_APP).then(wnd => { window.create('subWindow3', window.WindowType.TYPE_APP).then(wnd => {
console.log('windowTest CreateTest1 create success wnd' + wnd); console.log('windowTest CreateTest1 create success wnd' + wnd);
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
done(); done();
...@@ -1256,7 +1224,7 @@ describe('window_test', function () { ...@@ -1256,7 +1224,7 @@ describe('window_test', function () {
*/ */
it('create_Test_002', 0, async function (done) { it('create_Test_002', 0, async function (done) {
console.log('windowTest CreateTest2 begin'); console.log('windowTest CreateTest2 begin');
window.create('subWindow1', window.WindowType.TYPE_APP, (err, data) => { window.create('subWindow4', window.WindowType.TYPE_APP, (err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log('windowTest CreateTest2 create callback fail' + JSON.stringify(err.code)); console.log('windowTest CreateTest2 create callback fail' + JSON.stringify(err.code));
expect().assertFail(); expect().assertFail();
...@@ -1276,11 +1244,11 @@ describe('window_test', function () { ...@@ -1276,11 +1244,11 @@ describe('window_test', function () {
*/ */
it('destroy_Test_001', 0, async function (done) { it('destroy_Test_001', 0, async function (done) {
console.log('windowTest DestroyTest1 begin'); console.log('windowTest DestroyTest1 begin');
window.create('subWindow2', window.WindowType.TYPE_APP).then(wnd => { window.create('subWindow5', window.WindowType.TYPE_APP).then(wnd => {
console.log('windowTest DestroyTest1 create success wnd' + wnd); console.log('windowTest DestroyTest1 create success wnd' + wnd);
expect(wnd != null).assertTrue(); expect(wnd != null).assertTrue();
wnd.destroy().then(() => { wnd.destroy().then(() => {
window.find('subWindow2').then((data) => { window.find('subWindow5').then((data) => {
console.log('windowTest DestroyTest1 window.find success, window :' + JSON.stringify(data)); console.log('windowTest DestroyTest1 window.find success, window :' + JSON.stringify(data));
expect().assertFail(); expect().assertFail();
done(); done();
...@@ -1309,7 +1277,7 @@ describe('window_test', function () { ...@@ -1309,7 +1277,7 @@ describe('window_test', function () {
*/ */
it('destroy_Test_002', 0, async function (done) { it('destroy_Test_002', 0, async function (done) {
console.log('windowTest DestroyTest2 begin'); console.log('windowTest DestroyTest2 begin');
window.create('subWindow2', window.WindowType.TYPE_APP, (err, data) => { window.create('subWindow6', window.WindowType.TYPE_APP, (err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log('windowTest DestroyTest2 create callback fail' + JSON.stringify(err.code)); console.log('windowTest DestroyTest2 create callback fail' + JSON.stringify(err.code));
expect().assertFail(); expect().assertFail();
...@@ -1322,7 +1290,7 @@ describe('window_test', function () { ...@@ -1322,7 +1290,7 @@ describe('window_test', function () {
expect().assertFail(); expect().assertFail();
done(); done();
} else { } else {
window.find('subWindow2', (err, data) => { window.find('subWindow6', (err, data) => {
console.log('windowTest DestroyTest2 find callback begin' + JSON.stringify(data)); console.log('windowTest DestroyTest2 find callback begin' + JSON.stringify(data));
if (err.code != 0) { if (err.code != 0) {
console.log('windowTest DestroyTest2 find callback fail' + JSON.stringify(err.code)); console.log('windowTest DestroyTest2 find callback fail' + JSON.stringify(err.code));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册