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

!3603 补充窗口xts接口

Merge pull request !3603 from 华华小仙女/master
...@@ -116,6 +116,76 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -116,6 +116,76 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
} }
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_006
* @tc.name Test setSystemBarEnableTest6
* @tc.desc Test ohosWindow.setSystemBarEnable API function test1.
*/
it('setSystemBarEnableTest6', 0, function (done) {
let caseName = 'setSystemBarEnableTest6';
let msgStr = 'jsunittest ' + caseName + ' ';
let [flagStatus, flagNav] = [false, false];
console.log(msgStr + 'begin');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', systembartintstate => {
console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
if (flagStatus || flagNav) {
expect(!!systembartintstate).assertTrue();
expect(!!systembartintstate.regionTint).assertTrue();
console.log(msgStr + 'flagStatus || flagNav' + msgStr + 'ohosWindow.on systemBarTintChange regionTint:' + JSON.stringify(systembartintstate.regionTint));
done();
}
})
let mainWnd = null;
console.log(msgStr + 'mainWnd = null');
console.log(msgStr + 'windowStage = ' + JSON.stringify(windowStage));
windowStage.getMainWindow((err, data) => {
console.log(msgStr + 'getMainWindow data2' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'windowStage.getMainWindow', done);
}
expect(!!data).assertTrue();
mainWnd = data;
console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd));
mainWnd.show((err, data) => {
console.log(msgStr + 'mainWnd.show err' + JSON.stringify(err));
console.log(msgStr + 'mainWnd.show data' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.show', done);
}
expect(!data).assertTrue();
console.log(msgStr + 'mainWnd.show success');
mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen data:' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done);
}
expect(!data).assertTrue();
console.log(msgStr + 'mainWnd.setFullScreen success');
flagNav = true;
mainWnd.setSystemBarEnable(['navigation'], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable navigation JSON.stringify(data)==' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navigation]', done);
}
expect(!data).assertTrue();
console.log(msgStr + 'mainWnd.setSystemBarEnable success flagNav==' + flagNav);
})
flagStatus = true;
mainWnd.setSystemBarEnable(['status'], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(data)===' + JSON.stringify(data));
if (err && err.code) {
console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(err)===' + JSON.stringify(err));
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done);
}
expect(!data).assertTrue();
})
})
})
})
console.log(msgStr + 'finished!!');
});
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007
* @tc.name Test setSystemBarEnableTest7 * @tc.name Test setSystemBarEnableTest7
* @tc.desc Verify that the scene hides the status bar and displays the navigation bar. * @tc.desc Verify that the scene hides the status bar and displays the navigation bar.
...@@ -203,7 +273,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -203,7 +273,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'mainWnd.show success'); console.log(msgStr + 'mainWnd.show success');
expect(!data).assertTrue(); expect(!data).assertTrue();
mainWnd.setFullScreen(true, (err, data) => { mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen: ' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done); unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done);
} }
...@@ -227,7 +297,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -227,7 +297,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.on isEnable : ' + JSON.stringify(enable)); console.log(msgStr + 'ohosWindow.on isEnable : ' + JSON.stringify(enable));
console.log(msgStr + 'ohosWindow.on numType : ' + JSON.stringify(numType)); console.log(msgStr + 'ohosWindow.on numType : ' + JSON.stringify(numType));
expect(numType === 2112 || enable).assertTrue(); expect(numType === ohosWindow.WindowType.TYPE_NAVIGATION_BAR || enable).assertTrue();
} }
done(); done();
}, 3000) }, 3000)
...@@ -272,7 +342,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -272,7 +342,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'mainWnd.show success'); console.log(msgStr + 'mainWnd.show success');
expect(!data).assertTrue(); expect(!data).assertTrue();
mainWnd.setFullScreen(true, (err, data) => { mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen: ' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen', done); unexpectedError(data, caseName, 'mainWnd.setFullScreen', done);
} }
...@@ -300,7 +370,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -300,7 +370,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done);
} }
expect(!data).assertTrue(); expect(!data).assertTrue();
// done();
}) })
}) })
}) })
...@@ -381,7 +450,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -381,7 +450,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
if (tempData.type === 2108 || tempData.type === 2112) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
...@@ -476,8 +545,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -476,8 +545,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
if (tempData.type === 2108) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start! arrLength= '+ arrLength);
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.SBC.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.SBC.indexOf(tempData.backgroundColor);
let contentColorIndex = cloneColorArr.SCC.indexOf(tempData.contentColor); let contentColorIndex = cloneColorArr.SCC.indexOf(tempData.contentColor);
...@@ -487,7 +556,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -487,7 +556,9 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (contentColorIndex >= 0) { if (contentColorIndex >= 0) {
cloneColorArr.SCC.splice(contentColorIndex, 1); cloneColorArr.SCC.splice(contentColorIndex, 1);
} }
} else if (tempData.type === 2112) { console.log(msgStr+'compareCount: '+compareCount +' ,length: '+JSON.stringify(cloneColorArr.SCC.length)+ ' ,cloneColorArr.SBC:'+JSON.stringify(cloneColorArr.SBC));
console.log(msgStr+'compareCount: '+compareCount +' ,length: '+JSON.stringify(cloneColorArr.SCC.length)+' ,cloneColorArr.SCC'+JSON.stringify(cloneColorArr.SCC));
} else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.NBC.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.NBC.indexOf(tempData.backgroundColor);
...@@ -498,6 +569,17 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -498,6 +569,17 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (contentColorIndex >= 0) { if (contentColorIndex >= 0) {
cloneColorArr.NCC.splice(contentColorIndex, 1); cloneColorArr.NCC.splice(contentColorIndex, 1);
} }
let ca = cloneColorArr;
let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length
if(compareCount===18&&!flag){
console.log(msgStr + 'compareCount: '+compareCount +' ,true flag:'+flag);
expect(true).assertTrue();
done();
}else{
console.log(msgStr + 'compareCount: '+compareCount +' ,flag:'+flag);
}
console.log(msgStr+'compareCount: '+compareCount +' ,length: '+JSON.stringify(cloneColorArr.NBC.length)+ ' ,cloneColorArr.SBC:'+JSON.stringify(cloneColorArr.NBC));
console.log(msgStr+'compareCount: '+compareCount +' ,length: '+JSON.stringify(cloneColorArr.NCC.length)+' ,cloneColorArr.SCC'+JSON.stringify(cloneColorArr.NCC));
} }
} }
} }
...@@ -549,16 +631,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -549,16 +631,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} }
}) })
} }
setTimeout(() => {
console.log(msgStr + 'time wait finished. compareCount: ' + compareCount);
listenerFlag = listenerStatus.finished;
let ca = cloneColorArr;
if (ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length) {
unexpectedError(null, caseName, ' something compaer failed', done);
} else {
done();
}
}, 10000)
}) })
}) })
}) })
...@@ -586,7 +658,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -586,7 +658,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
if (tempData.type === 2108 || tempData.type === 2112) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
...@@ -882,7 +954,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -882,7 +954,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'tempWnd.getProperties true i: ' + i); console.log(msgStr + 'tempWnd.getProperties true i: ' + i);
tempTypeArr.splice(tempTypeArr.findIndex(item => item === dataProper.type), 1); tempTypeArr.splice(tempTypeArr.findIndex(item => item === dataProper.type), 1);
console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length: ' + tempTypeArr.length); console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length: ' + tempTypeArr.length);
console.log(msgStr + 'tempWnd.getProperties true loopCount1.length - i: ' + loopCount1.length - i); console.log(msgStr + 'tempWnd.getProperties true loopCount1.length: ' + loopCount1.length);
console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length + 1: ' + tempTypeArr.length + 1);
expect((loopCount1.length - i) == (tempTypeArr.length + 1)).assertTrue(); expect((loopCount1.length - i) == (tempTypeArr.length + 1)).assertTrue();
if (i == loopCount1.length - 1) { if (i == loopCount1.length - 1) {
console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length); console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length);
...@@ -902,7 +975,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -902,7 +975,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'ohosWindow.create', done); unexpectedError(err, caseName, 'ohosWindow.create', done);
} }
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_004 * @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_004
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
// @ts-nocheck // @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import ohosWindow from '@ohos.window'; import ohosWindow from '@ohos.window';
import screenManager from '@ohos.screen';
import display from '@ohos.display';
export default function windowPromiseTest(context, windowStage, abilityStorage) { export default function windowPromiseTest(context, windowStage, abilityStorage) {
console.log('windowTest context: ' + JSON.stringify(context)) console.log('windowTest context: ' + JSON.stringify(context))
...@@ -95,7 +97,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -95,7 +97,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
function expectedError(error, caseName, apiName, done, code) { function expectedError(error, caseName, apiName, done, code) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: '; let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error)); console.log(msgStr + JSON.stringify(error));
console.log(msgStr + 'code:' + code);
if (error.code === code) { if (error.code === code) {
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
} }
...@@ -224,7 +225,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -224,7 +225,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'listenerTest3'; let caseName = 'listenerTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let listenerOffFlag = listenerStatus.ready; let listenerOffFlag = listenerStatus.ready;
console.log(msgStr + 'begin'); console.log(msgStr + 'begin 1');
let tempWnd = await windowStage.getMainWindow().catch((err) => { let tempWnd = await windowStage.getMainWindow().catch((err) => {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done); unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
}); });
...@@ -234,9 +235,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -234,9 +235,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
listenerData.typeStr = 'systemAvoidAreaChange'; listenerData.typeStr = 'systemAvoidAreaChange';
tempWnd.on('systemAvoidAreaChange', (avoidAreaData) => { tempWnd.on('systemAvoidAreaChange', (avoidAreaData) => {
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, systemBatData : ' + JSON.stringify(avoidAreaData)); console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, systemBatData : ' + JSON.stringify(avoidAreaData));
setTimeout(() => { console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, systemBatData 1100 : ' + JSON.stringify(avoidAreaData));
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, systemBatData 1100 : ' + JSON.stringify(avoidAreaData));
}, 1100)
done(); done();
}) })
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange finished'); console.log(msgStr + 'tempWnd.on systemAvoidAreaChange finished');
...@@ -262,6 +261,153 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -262,6 +261,153 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
}); });
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
}) })
/**
* @tc.number SUB_WINDOW_ON_OFF_JSAPI_004
* @tc.name Test listenerTest4
* @tc.desc Verify whether the window size change monitoring can be closed normally.
*/
it('listenerTest4', 0, async function (done) {
let caseName = 'listenerTest4';
let msgStr = 'jsunittest ' + caseName + ' ';
let wndId = 'listenerTest4';
let baseType = 2;
let changedModel = 102;
let listenerOffFlag = listenerStatus.ready;
console.log(msgStr + 'begin');
let tempWnd = await ohosWindow.create(context, wndId, baseType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
listenerData.on = true;
listenerData.typeStr = 'windowSizeChange';
tempWnd.on('windowSizeChange', (sizeData) => {
console.log(msgStr + 'tempWnd.on windowSizeChange, sizeData : ' + JSON.stringify(sizeData));
if (listenerOffFlag === listenerStatus.pending) {
listenerOffFlag = listenerStatus.finished;
console.log(msgStr + 'tempWnd.on windowSizeChange, listenerOffFlag === listenerStatus.pending : ' + JSON.stringify(sizeData));
expect(sizeData.width === 100).assertTrue();
expect(sizeData.height === 100).assertTrue();
done();
}
})
await tempWnd.show().catch((err) => {
unexpectedError(err, caseName, 'tempWnd.show', done);
});
console.log(msgStr + 'tempWnd.show success');
await tempWnd.setWindowMode(changedModel).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setWindowMode ' + changedModel, done);
});
console.log(msgStr + 'tempWnd.setWindowMode ' + changedModel + ' success');
await tempWnd.resetSize(100, 100).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.resetSize(100, 100)', done);
});
console.log(msgStr + 'tempWnd.resetSize(100, 100) success');
console.log(msgStr + 'tempWnd.on windowSizeChange finished');
listenerOffFlag = listenerStatus.pending;
await sleep(1000);
tempWnd.off('windowSizeChange');
console.log(msgStr + 'tempWnd.off windowSizeChange finished');
sleep(1000);
await tempWnd.resetSize(200, 200).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.resetSize(200, 200)', done);
console.log(msgStr + 'tempWnd.resetSize(200, 200) err: ' + JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.resetSize(200, 200) success');
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_001
* @tc.name Test setWindowTypeTest1
* @tc.desc Test window.setWindowType API function test.
*/
it('setWindowTypeTest1', 0, async function (done) {
let caseName = 'setWindowTypeTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
let windowId = 'setWindowTypeTest1';
console.log(msgStr + 'begin');
let tempWnd = null
let tempTypeArr = [];
tempWnd = await ohosWindow.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
})
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' ,tempWnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
let loopCount1 = systemWindowTypeArr;
console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount1))
for (let i = 1; i < loopCount1.length; i++) {
let tempType = ohosWindow.WindowType[loopCount1[i]];
console.log(msgStr + 'tempWnd.setWindowType: ' + tempType + ' ,start');
tempTypeArr.push(tempType);
console.log(msgStr + 'tempTypeArr: ' + JSON.stringify(tempTypeArr));
let windowTypeData = await tempWnd.setWindowType(tempType).catch((err) => {
console.log(msgStr + 'tempWnd.setWindowType err' + JSON.stringify(err));
})
console.log(msgStr + 'tempWnd.setWindowType windowTypeData' + JSON.stringify(windowTypeData));
console.log(msgStr + 'tempWnd.setWindowType !windowTypeData' + !windowTypeData);
console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' end');
if (!windowTypeData) {
expect(!windowTypeData).assertTrue();
let prodata = await tempWnd.getProperties().catch((err) => {
console.log(msgStr + 'tempWnd.getProperties err' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.getProperties', done);
})
console.log(msgStr + 'tempWnd.getProperties prodata' + JSON.stringify(prodata));
console.log(msgStr + 'tempWnd.getProperties !!prodata' + !!prodata);
expect(!!prodata).assertTrue();
if (!!prodata) {
tempTypeArr.splice(tempTypeArr.findIndex(item => item === prodata.type), 1);
console.log(msgStr + '(loopCount1.length - i): ' + (loopCount1.length - i));
console.log(msgStr + '(tempTypeArr.length + 1): ' + (tempTypeArr.length + 1));
if (i == loopCount1.length - 1) {
expect((loopCount1.length - i) == (tempTypeArr.length + 1)).assertTrue();
console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length);
done();
}
} else {
unexpectedError(err, caseName, 'tempWnd.getProperties', done);
}
} else {
unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
}
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_002
* @tc.name Test setWindowTypeTest2
* @tc.desc Test window.setWindowType API function test.
*/
it('setWindowTypeTest2', 0, async function (done) {
let caseName = 'setWindowTypeTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
let changedWndType = null;
let windowId = 'setWindowTypeTest2';
console.log(msgStr + 'begin');
let tempWnd = null
tempWnd = await ohosWindow.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
})
console.log(msgStr + 'ohosWindow.create tempWnd' + JSON.stringify(tempWnd));
console.log(msgStr + 'ohosWindow.create !!tempWnd' + !!tempWnd);
if (!!tempWnd) {
expect(!!tempWnd).assertTrue();
let windowTypeData = await tempWnd.setWindowType(changedWndType).catch((err) => {
console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err));
expectedError(err, caseName, 'tempWnd.setWindowType', done, 130);
})
console.log(msgStr + 'tempWnd.setWindowType windowTypeData' + JSON.stringify(windowTypeData));
console.log(msgStr + 'tempWnd.setWindowType !windowTypeData' + !windowTypeData);
if (!!windowTypeData) {
unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
} else {
expect(err.code == 130).assertTrue();
done();
}
} else {
unexpectedError(err, caseName, 'ohosWindow.create', done);
}
})
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_001 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_001
* @tc.name Test setSystemBarEnableTest1 * @tc.name Test setSystemBarEnableTest1
...@@ -319,10 +465,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -319,10 +465,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable);
if (tempData.type === 2108 && statusFlag === listenerStatus.pending) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) {
statusFlag = listenerStatus.finished; statusFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue(); expect(!tempData.isEnable).assertTrue();
} else if (tempData.type === 2112 && navigationFlag === listenerStatus.pending) { } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR && navigationFlag === listenerStatus.pending) {
navigationFlag = listenerStatus.finished; navigationFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue(); expect(tempData.isEnable).assertTrue();
} }
...@@ -368,10 +514,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -368,10 +514,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable);
if (tempData.type === 2108 && statusFlag === listenerStatus.pending) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) {
statusFlag = listenerStatus.finished; statusFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue(); expect(!tempData.isEnable).assertTrue();
} else if (tempData.type === 2112 && navigationFlag === listenerStatus.pending) { } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR && navigationFlag === listenerStatus.pending) {
navigationFlag = listenerStatus.finished; navigationFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue(); expect(tempData.isEnable).assertTrue();
} }
...@@ -429,10 +575,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -429,10 +575,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable);
if (tempData.type === 2108 && statusFlag === listenerStatus.pending) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) {
statusFlag = listenerStatus.finished; statusFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue(); expect(tempData.isEnable).assertTrue();
} else if (tempData.type === 2112 && navigationFlag === listenerStatus.pending) { } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR && navigationFlag === listenerStatus.pending) {
navigationFlag = listenerStatus.finished; navigationFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue(); expect(tempData.isEnable).assertTrue();
} }
...@@ -490,10 +636,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -490,10 +636,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable);
if (tempData.type === 2108 && statusFlag === listenerStatus.pending) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) {
statusFlag = listenerStatus.finished; statusFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue(); expect(!tempData.isEnable).assertTrue();
} else if (tempData.type === 2112 && navigationFlag === listenerStatus.pending) { } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR && navigationFlag === listenerStatus.pending) {
navigationFlag = listenerStatus.finished; navigationFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue(); expect(!tempData.isEnable).assertTrue();
} }
...@@ -585,7 +731,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -585,7 +731,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
if (tempData.type === 2108 || tempData.type === 2112) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
...@@ -664,7 +810,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -664,7 +810,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
if (tempData.type === 2108) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.SBC.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.SBC.indexOf(tempData.backgroundColor);
...@@ -677,7 +823,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -677,7 +823,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
} }
expect(backgroundIndex !== -1).assertTrue(); expect(backgroundIndex !== -1).assertTrue();
expect(contentColorIndex !== -1).assertTrue(); expect(contentColorIndex !== -1).assertTrue();
} else if (tempData.type === 2112) { } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.NBC.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.NBC.indexOf(tempData.backgroundColor);
...@@ -758,7 +904,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -758,7 +904,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
console.log(msgStr + 'i=' + i + ' , ohosWindow.on for=' + JSON.stringify(tempData)); console.log(msgStr + 'i=' + i + ' , ohosWindow.on for=' + JSON.stringify(tempData));
if (tempData.type === 2108 || tempData.type === 2112) { if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++; compareCount++;
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
...@@ -809,11 +955,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -809,11 +955,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
done(); done();
}) })
} }
setTimeout(() => {
console.log(msgStr + 'time wait finished. compareCount: ' + compareCount);
listenerFlag = listenerStatus.finished;
done();
}, 10000)
}) })
/** /**
...@@ -854,7 +995,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -854,7 +995,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + ' loopCount: ' + loopCount); console.log(msgStr + ' loopCount: ' + loopCount);
let n = 0 let n = 0
for (let i = 0; i < loopCount; i++) { for (let i = 0; i < loopCount; i++) {
// for (let i = 0; i < 5; i++) {
let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let windId = 'createTest2' + i; let windId = 'createTest2' + i;
console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.create ' + tempType + ' start');
...@@ -1082,6 +1222,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1082,6 +1222,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
}); });
console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow)); console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
}) })
/** /**
* @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_001 * @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_001
...@@ -1175,5 +1316,38 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1175,5 +1316,38 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expect(!findWnd).assertTrue(); expect(!findWnd).assertTrue();
done(); done();
}) })
/**
* @tc.number SUB_WINDOW_SETDENSITTYDPI_JSAPI_001
* @tc.name Test setDensityDpiTest1
* @tc.desc Verify Sets the screen pixel
*/
it('setDensityDpiTest1', 0, async function (done) {
let caseName = 'setDensityDpiTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let screens = await screenManager.getAllScreens().catch(err => {
unexpectedError(err, caseName, 'screenManager.getAllScreen', done);
})
console.log(msgStr + 'screenManager.getAllScreen' + JSON.stringify(screens));
expect(!!screens).assertTrue();
let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300];
for (let i = 0;i < dpiItem.length; i++) {
await sleep(1000);
await screens[0].setDensityDpi(dpiItem[i]).then(async () => {
console.log(msgStr + 'screen.setDensityDpi success set DPI ' + dpiItem[i]);
let defaultDpi = await display.getDefaultDisplay().catch(err => {
console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay failed');
});
console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay' + JSON.stringify(defaultDpi));
let isEqual = defaultDpi.densityDPI == parseInt(dpiItem[i])
console.log(msgStr + 'same ? ' + isEqual)
expect(isEqual).assertTrue()
}).catch(err => {
console.log(msgStr + 'screen.setDensityDpi failed set DPI error' + dpiItem[i]);
});
}
console.log(msgStr + 'done ');
done();
})
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册