提交 e92e27af 编写于 作者: Y yaocui

update

Signed-off-by: Nyaocui <yaocui2@h-partners.com>
上级 e24536ba
...@@ -17,6 +17,7 @@ import windowCallbackTest from './windowCallback.test' ...@@ -17,6 +17,7 @@ import windowCallbackTest from './windowCallback.test'
import windowRefactorInterfaceTest from './windowRefactorInterface.test' import windowRefactorInterfaceTest from './windowRefactorInterface.test'
import displayAndWindowRefactorInterfaceTest from './displayAndWindowRefactorInterface.test' import displayAndWindowRefactorInterfaceTest from './displayAndWindowRefactorInterface.test'
import parameterVerificationIsOptional from './parameterVerificationIsOptional.test' import parameterVerificationIsOptional from './parameterVerificationIsOptional.test'
import windowRichScene from './windowRichScene.test'
export default function testsuite() { export default function testsuite() {
windowCallbackTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) windowCallbackTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
...@@ -24,4 +25,5 @@ export default function testsuite() { ...@@ -24,4 +25,5 @@ export default function testsuite() {
windowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) windowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
displayAndWindowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) displayAndWindowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
parameterVerificationIsOptional(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) parameterVerificationIsOptional(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
windowRichScene(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
} }
\ No newline at end of file
...@@ -117,6 +117,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -117,6 +117,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'window_off_windowSizeChange_Test_001'; let caseName = 'window_off_windowSizeChange_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
let baseWndType = 1; let baseWndType = 1;
...@@ -132,10 +133,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -132,10 +133,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
tempWnd.on('windowSizeChange', () => { tempWnd.on('windowSizeChange', () => {
console.info(msgStr + "first listener trigger"); console.info(msgStr + "first listener trigger");
num++
firstListenFlag = true firstListenFlag = true
}); });
tempWnd.on('windowSizeChange', (data) => { tempWnd.on('windowSizeChange', (data) => {
console.info(msgStr + "second listener trigger"); console.info(msgStr + "second listener trigger");
num++
secondListenFlag = true secondListenFlag = true
}); });
await tempWnd.show().catch((err) => { await tempWnd.show().catch((err) => {
...@@ -161,8 +164,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -161,8 +164,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
await tempWnd.destroyWindow(); await tempWnd.destroyWindow();
done(); done();
}) })
console.error(msgStr + 'num : ' + num);
await sleep(500); await sleep(500);
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
await tempWnd.destroyWindow(); await tempWnd.destroyWindow();
done(); done();
} }
...@@ -245,6 +249,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -245,6 +249,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'window_off_avoidAreaChange_Test_001'; let caseName = 'window_off_avoidAreaChange_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
let tempWnd = null let tempWnd = null
...@@ -257,15 +262,20 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -257,15 +262,20 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
}); });
tempWnd.on('avoidAreaChange', () => { tempWnd.on('avoidAreaChange', () => {
console.info(msgStr + "first listener trigger"); console.info(msgStr + "first listener trigger");
num++
firstListenFlag = true firstListenFlag = true
}); });
tempWnd.on('avoidAreaChange', (data) => { tempWnd.on('avoidAreaChange', (data) => {
console.info(msgStr + 'second listener trigger'); console.info(msgStr + 'second listener trigger');
num++
secondListenFlag = true secondListenFlag = true
}); });
await tempWnd.setFullScreen(true).catch((err) => { await tempWnd.setFullScreen(true).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
}); });
await tempWnd.setSystemBarEnable(['status']).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status])', done);
});
await sleep(1000); await sleep(1000);
tempWnd.off('avoidAreaChange'); tempWnd.off('avoidAreaChange');
firstListenFlag = false firstListenFlag = false
...@@ -277,7 +287,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -277,7 +287,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
await tempWnd.setSystemBarEnable(['status', 'navigation']).catch((err) => { await tempWnd.setSystemBarEnable(['status', 'navigation']).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status])', done);
}); });
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
done(); done();
} }
}) })
...@@ -346,6 +356,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -346,6 +356,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'window_off_screenshot_Test_001'; let caseName = 'window_off_screenshot_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
let windowId = 'window_off_screenshot_Test_001'; let windowId = 'window_off_screenshot_Test_001';
...@@ -368,10 +379,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -368,10 +379,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
}); });
tempWnd.on('screenshot', (data) => { tempWnd.on('screenshot', (data) => {
console.info(msgStr + "first listener trigger"); console.info(msgStr + "first listener trigger");
num++
firstListenFlag = true firstListenFlag = true
}); });
tempWnd.on('screenshot', (data) => { tempWnd.on('screenshot', (data) => {
console.info(msgStr + "second listener trigger"); console.info(msgStr + "second listener trigger");
num++
secondListenFlag = true secondListenFlag = true
}); });
// 截屏代码 // 截屏代码
...@@ -397,7 +410,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -397,7 +410,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
done(); done();
}); });
await sleep(1000); await sleep(1000);
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
await tempWnd.destroyWindow(); await tempWnd.destroyWindow();
done(); done();
} else { } else {
...@@ -490,6 +503,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -490,6 +503,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'window_off_dialogTargetTouch_Test_001'; let caseName = 'window_off_dialogTargetTouch_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
let windowId = 'window_off_dialogTargetTouch_Test_001'; let windowId = 'window_off_dialogTargetTouch_Test_001';
...@@ -512,10 +526,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -512,10 +526,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
}); });
tempWnd.on('dialogTargetTouch', (data) => { tempWnd.on('dialogTargetTouch', (data) => {
console.info(msgStr + "first listener trigger"); console.info(msgStr + "first listener trigger");
num++
firstListenFlag = true firstListenFlag = true
}); });
tempWnd.on('dialogTargetTouch', (data) => { tempWnd.on('dialogTargetTouch', (data) => {
console.info(msgStr + "second listener trigger"); console.info(msgStr + "second listener trigger");
num++
secondListenFlag = true secondListenFlag = true
}); });
// 点击模态窗口 // 点击模态窗口
...@@ -536,7 +552,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -536,7 +552,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
done(); done();
}) })
await sleep(1000); await sleep(1000);
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
await tempWnd.destroyWindow(); await tempWnd.destroyWindow();
done(); done();
} }
...@@ -618,6 +634,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -618,6 +634,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'window_off_keyboardHeightChange_Test_001'; let caseName = 'window_off_keyboardHeightChange_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
let windowId = 'window_off_keyboardHeightChange_Test_001'; let windowId = 'window_off_keyboardHeightChange_Test_001';
...@@ -643,10 +660,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -643,10 +660,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
}); });
tempWnd.on('keyboardHeightChange', (data) => { tempWnd.on('keyboardHeightChange', (data) => {
console.info(msgStr + "first listener trigger"); console.info(msgStr + "first listener trigger");
num++
firstListenFlag = true firstListenFlag = true
}); });
tempWnd.on('keyboardHeightChange', (data) => { tempWnd.on('keyboardHeightChange', (data) => {
console.info(msgStr + "second listener trigger"); console.info(msgStr + "second listener trigger");
num++
secondListenFlag = true secondListenFlag = true
}); });
await inputClick('pageTwoinput', msgStr).catch(async err => { await inputClick('pageTwoinput', msgStr).catch(async err => {
...@@ -666,7 +685,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -666,7 +685,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
done(); done();
}) })
await sleep(2000); await sleep(2000);
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
await tempWnd.destroyWindow(); await tempWnd.destroyWindow();
done(); done();
} }
...@@ -754,16 +773,18 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -754,16 +773,18 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'windowStage_off_windowStageEvent_Test_001'; let caseName = 'windowStage_off_windowStageEvent_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
function firstCall() { function firstCall() {
console.log(msgStr + "first listener trigger") console.log(msgStr + "first listener trigger")
num++
firstListenFlag = true firstListenFlag = true
} }
function secondCall() { function secondCall() {
console.log(msgStr + "second listener trigger") console.log(msgStr + "second listener trigger")
num++
secondListenFlag = true secondListenFlag = true
} }
...@@ -783,7 +804,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -783,7 +804,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'tempWnd.show', done); unexpectedError(err, caseName, 'tempWnd.show', done);
}); });
await sleep(1000); await sleep(1000);
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
done(); done();
} }
}) })
...@@ -828,7 +849,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -828,7 +849,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
windowStage.off("windowStageEvent"); windowStage.off("windowStageEvent");
if (!firstListenFlag && secondListenFlag) { if (!firstListenFlag && secondListenFlag) {
done(); done();
}else{ } else {
expect(TRUE_FLAG).assertFail(); expect(TRUE_FLAG).assertFail();
done(); done();
} }
...@@ -843,6 +864,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -843,6 +864,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'display_off_add_Test_001'; let caseName = 'display_off_add_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
let screenClass = null; let screenClass = null;
...@@ -850,11 +872,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -850,11 +872,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
function firstCall() { function firstCall() {
console.log(msgStr + "first listener trigger") console.log(msgStr + "first listener trigger")
num++
firstListenFlag = true firstListenFlag = true
} }
function secondCall() { function secondCall() {
console.log(msgStr + "second listener trigger") console.log(msgStr + "second listener trigger")
num++
secondListenFlag = true secondListenFlag = true
} }
...@@ -900,7 +924,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -900,7 +924,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'screen.makeExpand', done); unexpectedError(err, caseName, 'screen.makeExpand', done);
}); });
await sleep(1000); await sleep(1000);
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
await screen.destroyVirtualScreen(screenClass_two.id) await screen.destroyVirtualScreen(screenClass_two.id)
done(); done();
} }
...@@ -975,7 +999,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -975,7 +999,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
display.off("add") display.off("add")
if (!firstListenFlag && secondListenFlag) { if (!firstListenFlag && secondListenFlag) {
done(); done();
}else{ } else {
expect(TRUE_FLAG).assertFail(); expect(TRUE_FLAG).assertFail();
done(); done();
} }
...@@ -989,6 +1013,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -989,6 +1013,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'display_off_remove_Test_001'; let caseName = 'display_off_remove_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
let screenClass = null; let screenClass = null;
...@@ -996,11 +1021,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -996,11 +1021,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
function firstCall() { function firstCall() {
console.log(msgStr + "first listener trigger") console.log(msgStr + "first listener trigger")
num++
firstListenFlag = true firstListenFlag = true
} }
function secondCall() { function secondCall() {
console.log(msgStr + "second listener trigger") console.log(msgStr + "second listener trigger")
num++
secondListenFlag = true secondListenFlag = true
} }
...@@ -1047,7 +1074,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1047,7 +1074,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
}); });
await screen.destroyVirtualScreen(screenClass_two.id) await screen.destroyVirtualScreen(screenClass_two.id)
await sleep(1000); await sleep(1000);
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
done(); done();
} }
}) })
...@@ -1121,7 +1148,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1121,7 +1148,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
display.off('remove') display.off('remove')
if (!firstListenFlag && secondListenFlag) { if (!firstListenFlag && secondListenFlag) {
done(); done();
}else{ } else {
expect(TRUE_FLAG).assertFail(); expect(TRUE_FLAG).assertFail();
done(); done();
} }
...@@ -1135,17 +1162,20 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1135,17 +1162,20 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'display_off_change_Test_001'; let caseName = 'display_off_change_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let num = 0
let firstListenFlag = false let firstListenFlag = false
let secondListenFlag = false let secondListenFlag = false
let screenClass = null; let screenClass = null;
function firstCall() { function firstCall() {
console.log(msgStr + "first listener trigger") console.log(msgStr + "first listener trigger")
num++
firstListenFlag = true firstListenFlag = true
} }
function secondCall() { function secondCall() {
console.log(msgStr + "second listener trigger") console.log(msgStr + "second listener trigger")
num++
secondListenFlag = true secondListenFlag = true
} }
...@@ -1179,7 +1209,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1179,7 +1209,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'screenClass.setOrientation', done); unexpectedError(err, caseName, 'screenClass.setOrientation', done);
}); });
await sleep(1000); await sleep(1000);
if (firstListenFlag === false && secondListenFlag === false) { if (num >= 2 && firstListenFlag === false && secondListenFlag === false) {
await screen.destroyVirtualScreen(screenClass.id) await screen.destroyVirtualScreen(screenClass.id)
done(); done();
} }
...@@ -1241,7 +1271,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1241,7 +1271,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
display.off('change') display.off('change')
if (!firstListenFlag && secondListenFlag) { if (!firstListenFlag && secondListenFlag) {
done(); done();
}else{ } else {
expect(TRUE_FLAG).assertFail(); expect(TRUE_FLAG).assertFail();
done(); done();
} }
...@@ -1254,7 +1284,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1254,7 +1284,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
it('getUIContext_Test_001', 0, async function (done) { it('getUIContext_Test_001', 0, async function (done) {
let caseName = 'getUIContext_Test_001'; let caseName = 'getUIContext_Test_001';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let uiContext=null; let uiContext = null;
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let mainWindow = null let mainWindow = null
mainWindow = await windowStage.getMainWindow().catch((err) => { mainWindow = await windowStage.getMainWindow().catch((err) => {
...@@ -1264,7 +1294,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1264,7 +1294,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
// 获取UIContext实例。 // 获取UIContext实例。
uiContext = mainWindow.getUIContext(); uiContext = mainWindow.getUIContext();
expect(!!uiContext).assertTrue(); expect(!!uiContext).assertTrue();
console.log(msgStr + 'after uiContext: '+JSON.stringify(uiContext)); console.log(msgStr + 'after uiContext: ' + JSON.stringify(uiContext));
done(); done();
}) })
......
...@@ -131,28 +131,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -131,28 +131,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
it('setSystemBarEnableTest6', 0, async function (done) { it('setSystemBarEnableTest6', 0, async function (done) {
let caseName = 'setSystemBarEnableTest6'; let caseName = 'setSystemBarEnableTest6';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let [flagStatus, flagNav] = [false, false];
console.log(msgStr + 'begin'); 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));
console.log(msgStr + 'ohosWindow.on flagNav : ' + JSON.stringify(flagNav));
console.log(msgStr + 'ohosWindow.on flagStatus : ' + JSON.stringify(flagStatus));
console.log(msgStr + 'ohosWindow.on flagStatus && flagNav : ' + (flagStatus && flagNav));
if (flagStatus || flagNav) {
try {
expect(!!systembartintstate).assertTrue();
expect(!!systembartintstate.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on ${JSON.stringify(error)}`)
}
console.log(msgStr + 'flagStatus || flagNav' + msgStr + 'ohosWindow.on systemBarTintChange regionTint:' + JSON.stringify(systembartintstate.regionTint));
ohosWindow.off('systemBarTintChange')
done();
}
})
function getMainWindow() { function getMainWindow() {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
windowStage.getMainWindow((err, data) => { windowStage.getMainWindow((err, data) => {
...@@ -191,7 +170,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -191,7 +170,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
reject(null) reject(null)
} else { } else {
console.log(msgStr + 'mainWnd.setFullScreen success'); console.log(msgStr + 'mainWnd.setFullScreen success');
flagNav = true;
resolve(true) resolve(true)
} }
}) })
...@@ -207,7 +185,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -207,7 +185,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
reject(null) reject(null)
} else { } else {
console.log(msgStr + 'mainWnd.setSystemBarEnable success'); console.log(msgStr + 'mainWnd.setSystemBarEnable success');
flagStatus = true;
resolve(true) resolve(true)
} }
}) })
...@@ -257,6 +234,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -257,6 +234,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
done(); done();
}); });
console.log(msgStr + 'finished!!'); console.log(msgStr + 'finished!!');
done();
}); });
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007
...@@ -266,24 +244,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -266,24 +244,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
it('setSystemBarEnableTest7', 0, async function (done) { it('setSystemBarEnableTest7', 0, async function (done) {
let caseName = 'setSystemBarEnableTest7'; let caseName = 'setSystemBarEnableTest7';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let [flagStatus, flagNav] = [false, false];
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
ohosWindow.on('systemBarTintChange', systembartintstate => {
console.log(msgStr + 'ohosWindow.on systembartintstate :' + JSON.stringify(systembartintstate));
console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
if (flagStatus || flagNav) {
console.log(msgStr + 'ohosWindow.on flagStatus || flagNav:');
try {
expect(!!systembartintstate).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`)
}
ohosWindow.off('systemBarTintChange')
done();
}
})
function getMainWindow() { function getMainWindow() {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
windowStage.getMainWindow((err, data) => { windowStage.getMainWindow((err, data) => {
...@@ -333,7 +294,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -333,7 +294,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
reject(null) reject(null)
} else { } else {
flagStatus = true;
resolve(true) resolve(true)
} }
}) })
...@@ -347,7 +307,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -347,7 +307,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
reject(null) reject(null)
} else { } else {
flagNav = true;
resolve(true) resolve(true)
} }
}) })
...@@ -381,6 +340,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -381,6 +340,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
expect().assertFail(); expect().assertFail();
done(); done();
}); });
done();
}); });
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_008 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_008
...@@ -390,30 +350,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -390,30 +350,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
it('setSystemBarEnableTest8', 0, async function (done) { it('setSystemBarEnableTest8', 0, async function (done) {
let caseName = 'setSystemBarEnableTest8'; let caseName = 'setSystemBarEnableTest8';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let [flagStatus, flagNav] = [false, false];
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
ohosWindow.on('systemBarTintChange', systembartintstate => {
if (flagStatus && flagNav) {
console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
let enable = systembartintstate.regionTint[0].isEnable
let numType = systembartintstate.regionTint[0].type
console.log(msgStr + 'ohosWindow.on isEnable : ' + JSON.stringify(enable));
console.log(msgStr + 'ohosWindow.on numType : ' + JSON.stringify(numType));
try {
expect(numType === ohosWindow.WindowType.TYPE_STATUS_BAR || numType === ohosWindow.WindowType.TYPE_NAVIGATION_BAR && enable)
.assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`)
}
ohosWindow.off('systemBarTintChange')
done();
} else {
console.log(msgStr + 'flagStatus :' + flagStatus + ' ,regionTint:' + JSON.stringify(systembartintstate.regionTint));
console.log(msgStr + 'flagNav :' + flagNav + ' ,regionTint:' + JSON.stringify(systembartintstate.regionTint));
}
})
function getMainWindow() { function getMainWindow() {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
windowStage.getMainWindow((err, data) => { windowStage.getMainWindow((err, data) => {
...@@ -460,8 +398,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -460,8 +398,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
reject(null) reject(null)
} else { } else {
flagStatus = true;
flagNav = true;
resolve(true) resolve(true)
console.log(msgStr + 'mainWnd.setSystemBarEnable [status, navigation] data==' + JSON.stringify(data)); console.log(msgStr + 'mainWnd.setSystemBarEnable [status, navigation] data==' + JSON.stringify(data));
} }
...@@ -492,6 +428,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -492,6 +428,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
expect().assertFail(); expect().assertFail();
done(); done();
}); });
done();
}); });
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_009 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_009
...@@ -501,22 +438,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -501,22 +438,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
it('setSystemBarEnableTest9', 0, async function (done) { it('setSystemBarEnableTest9', 0, async function (done) {
let caseName = 'setSystemBarEnableTest9'; let caseName = 'setSystemBarEnableTest9';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let [flagStatus, flagNav] = [false, false];
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
ohosWindow.on('systemBarTintChange', (systembartintstate) => {
console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate));
console.log(msgStr + 'ohosWindow.on systemBarTintChange systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
if (flagStatus || flagNav) {
try {
expect(!!systembartintstate).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`)
}
ohosWindow.off('systemBarTintChange')
done();
}
})
function getMainWindow() { function getMainWindow() {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
windowStage.getMainWindow((err, data) => { windowStage.getMainWindow((err, data) => {
...@@ -576,8 +498,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -576,8 +498,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
reject(null) reject(null)
} else { } else {
flagStatus = true;
flagNav = true;
resolve(true) resolve(true)
} }
}) })
...@@ -612,6 +532,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -612,6 +532,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
expect().assertFail(); expect().assertFail();
done(); done();
}); });
done();
}); });
/** /**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_010 * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_010
...@@ -786,88 +707,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -786,88 +707,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let endNum = 0; let endNum = 0;
let listenerFlag = false; let listenerFlag = false;
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag) {
try {
expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) {
console.log(msgStr + 'for arrLenght compareCount: ' + compareCount + ' ,i:' + i + ' ,arrLength:' + arrLength);
let tempData = systemBarData.regionTint[i];
if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR) {
console.log(msgStr + 'systemBarTintChange compare start! arrLength= ' + arrLength);
compareCount++;
let backgroundIndex = cloneColorArr.SBC.indexOf(tempData.backgroundColor);
let contentColorIndex = cloneColorArr.SCC.indexOf(tempData.contentColor);
if (backgroundIndex >= 0) {
cloneColorArr.SBC.splice(backgroundIndex, 1);
} else {
console.log(msgStr + 'SBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor));
}
if (contentColorIndex >= 0) {
cloneColorArr.SCC.splice(contentColorIndex, 1);
} else {
console.log(msgStr + 'SCC tempData.contentColor:' + JSON.stringify(tempData.contentColor));
}
let ca = cloneColorArr;
let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length
if (compareCount === 18 && !flag) {
console.log(msgStr + 'if compareCount: ' + compareCount + ' ,true flag:' + flag);
try {
expect(true).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
} else {
console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag);
}
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));
done();
} else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++;
let backgroundIndex = cloneColorArr.NBC.indexOf(tempData.backgroundColor);
let contentColorIndex = cloneColorArr.NCC.indexOf(tempData.contentColor);
if (backgroundIndex >= 0) {
cloneColorArr.NBC.splice(backgroundIndex, 1);
} else {
console.log(msgStr + 'NBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor));
}
if (contentColorIndex >= 0) {
cloneColorArr.NCC.splice(contentColorIndex, 1);
} else {
console.log(msgStr + 'NCC tempData.contentColor:' + JSON.stringify(tempData.contentColor));
}
let ca = cloneColorArr;
let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length
if (compareCount === 18 && !flag) {
console.log(msgStr + 'else compareCount: ' + compareCount + ' ,true flag:' + flag);
try {
expect(true).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
} else {
console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag);
}
console.log(msgStr + 'compareCount: ' + endNum + ' ,compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.NBC.length) + ' ,cloneColorArr.SBC:' + JSON.stringify(cloneColorArr.NBC));
console.log(msgStr + 'compareCount: ' + endNum + ' ,compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.NCC.length) + ' ,cloneColorArr.SCC' + JSON.stringify(cloneColorArr.NCC));
endNum = compareCount
done();
}
}
}
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
})
let tempWnd; let tempWnd;
tempWnd = await windowStage.getMainWindow().catch((err) => { tempWnd = await windowStage.getMainWindow().catch((err) => {
console.error(msgStr + 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
...@@ -891,7 +730,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -891,7 +730,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
done(); done();
}); });
await sleep(1000); await sleep(1000);
listenerFlag = true
let loopCount = commonNUMBERColorArr.length let loopCount = commonNUMBERColorArr.length
for (let i = 0; i < loopCount; i++) { for (let i = 0; i < loopCount; i++) {
console.log(msgStr + 'tempWnd.setSystemBarEnable i:' + i); console.log(msgStr + 'tempWnd.setSystemBarEnable i:' + i);
...@@ -906,7 +744,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -906,7 +744,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}; };
tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => {
console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
try { try {
expect(TRUE_FLAG).assertFail(); expect(TRUE_FLAG).assertFail();
...@@ -933,38 +770,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -933,38 +770,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr)); let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr));
let compareCount = 0; let compareCount = 0;
let listenerFlag = false;
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag) {
try {
expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i];
if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++;
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor);
try {
expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
}
}
}
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
})
let tempWnd; let tempWnd;
tempWnd = await windowStage.getMainWindow().catch((err) => { tempWnd = await windowStage.getMainWindow().catch((err) => {
console.error(msgStr + 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); console.error(msgStr + 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
...@@ -988,7 +794,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -988,7 +794,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
done(); done();
}); });
await sleep(1000); await sleep(1000);
listenerFlag = true
let loopCount = commonRGBColorArr.length let loopCount = commonRGBColorArr.length
for (let i = 0; i < loopCount; i++) { for (let i = 0; i < loopCount; i++) {
let tempColor = commonKEYColorArr[i]; let tempColor = commonKEYColorArr[i];
...@@ -1001,7 +806,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1001,7 +806,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
navigationBarContentColor: tempColor, navigationBarContentColor: tempColor,
}; };
tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => {
console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
try { try {
......
...@@ -92,42 +92,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -92,42 +92,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
let listenerFlag = listenerStatus.ready; let listenerFlag = listenerStatus.ready;
let caseName = 'setWindowSystemBarPropertiesTest1'; let caseName = 'setWindowSystemBarPropertiesTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.info('setWindowSystemBarPropertiesTest1');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest1 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) {
try {
expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length;
console.log('setWindowSystemBarPropertiesTest1 arrLength is: '+systemBarData.regionTint.length)
for(let i=0;i<arrLength;i++){
console.info('setWindowSystemBarPropertiesTest1 start step:'+i);
// 单个导航栏或者系统状态信息
let SystemBarRegionTint = systemBarData.regionTint[i];
if (SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR || SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.info('setWindowSystemBarPropertiesTest1 assert1 start!');
let backgroundIndex = cloneColorArr.indexOf(SystemBarRegionTint.backgroundColor);
let contentColorIndex = cloneColorArr.indexOf(SystemBarRegionTint.contentColor);
try {
expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
if(i==arrLength-1){
console.info('setWindowSystemBarPropertiesTest1 finished step:'+i);
}
}
}
}
})
console.info('setWindowSystemBarPropertiesTest1 on systemBarTintChange finished');
let mainWsync = windowStage.getMainWindowSync(); let mainWsync = windowStage.getMainWindowSync();
expect(mainWsync != null).assertTrue(); expect(mainWsync != null).assertTrue();
await mainWsync.showWindow().catch(err => { await mainWsync.showWindow().catch(err => {
...@@ -141,7 +105,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -141,7 +105,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
done(); done();
}); });
await sleep(1000); await sleep(1000);
listenerFlag = listenerStatus.pending;
for(let i=0;i<commonRGBColorArr.length;i++){ for(let i=0;i<commonRGBColorArr.length;i++){
console.info('setWindowSystemBarPropertiesTest1 begin step:'+i); console.info('setWindowSystemBarPropertiesTest1 begin step:'+i);
let tempColor = commonRGBColorArr[i]; let tempColor = commonRGBColorArr[i];
...@@ -184,63 +147,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -184,63 +147,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
NBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)), NBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
NCC: JSON.parse(JSON.stringify(commonNUMBERColorArr)) NCC: JSON.parse(JSON.stringify(commonNUMBERColorArr))
}; };
let listenerFlag = listenerStatus.ready;
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
let caseName = 'setWindowSystemBarPropertiesTest2'; let caseName = 'setWindowSystemBarPropertiesTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.info('setWindowSystemBarPropertiesTest2');
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest2 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) {
// 单个导航栏或者系统状态信息
try {
expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) {
let systemBarRegionTint = systemBarData.regionTint[i];
if (systemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR) {
console.info('setWindowSystemBarPropertiesTest2 assert2 start!');
let backgroundIndex = cloneColorArr.SBC.indexOf(systemBarRegionTint.backgroundColor);
let contentColorIndex = cloneColorArr.SCC.indexOf(systemBarRegionTint.contentColor);
if (backgroundIndex >= 0) {
cloneColorArr.SBC.splice(backgroundIndex, 1);
}
if (contentColorIndex >= 0) {
cloneColorArr.SCC.splice(contentColorIndex, 1);
}
try {
expect(backgroundIndex !== -1).assertTrue();
expect(contentColorIndex !== -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
done();
} else if (systemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
let backgroundIndex = cloneColorArr.NBC.indexOf(systemBarRegionTint.backgroundColor);
let contentColorIndex = cloneColorArr.NCC.indexOf(systemBarRegionTint.contentColor);
if (backgroundIndex >= 0) {
cloneColorArr.NBC.splice(backgroundIndex, 1);
}
if (contentColorIndex >= 0) {
cloneColorArr.NCC.splice(contentColorIndex, 1);
}
try {
expect(backgroundIndex !== -1).assertTrue();
expect(contentColorIndex !== -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
done();
}
}
}
})
console.info('setWindowSystemBarPropertiesTest2 on systemBarTintChange finished');
let mainWsync = windowStage.getMainWindowSync(); let mainWsync = windowStage.getMainWindowSync();
expect(mainWsync != null).assertTrue(); expect(mainWsync != null).assertTrue();
await mainWsync.showWindow().catch((err) => { await mainWsync.showWindow().catch((err) => {
...@@ -255,7 +163,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -255,7 +163,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
done(); done();
}); });
await sleep(1000); await sleep(1000);
listenerFlag = listenerStatus.pending;
for(let i =0;i<commonNUMBERColorArr.length;i++){ for(let i =0;i<commonNUMBERColorArr.length;i++){
console.info('setWindowSystemBarPropertiesTest2 begin step:'+i); console.info('setWindowSystemBarPropertiesTest2 begin step:'+i);
let tempColor = commonNUMBERColorArr[i]; let tempColor = commonNUMBERColorArr[i];
...@@ -293,39 +200,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -293,39 +200,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
*/ */
it('setWindowSystemBarPropertiesTest3', 0, async function (done) { it('setWindowSystemBarPropertiesTest3', 0, async function (done) {
let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr)); let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr));
let listenerFlag = listenerStatus.ready;
let caseName = 'setWindowSystemBarPropertiesTest3'; let caseName = 'setWindowSystemBarPropertiesTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.info('setWindowSystemBarPropertiesTest3 start');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest3 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) {
try {
expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
let arrLength = systemBarData.regionTint.length;
// 单个导航栏或者系统状态信息
for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i];
if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor);
try {
expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
} catch (error) {
console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`)
}
done();
}
}
}
})
let tempWnd = windowStage.getMainWindowSync(); let tempWnd = windowStage.getMainWindowSync();
expect(tempWnd != null).assertTrue(); expect(tempWnd != null).assertTrue();
await tempWnd.showWindow().catch((err) => { await tempWnd.showWindow().catch((err) => {
...@@ -339,7 +215,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit ...@@ -339,7 +215,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
done(); done();
}); });
await sleep(1000); await sleep(1000);
listenerFlag = listenerStatus.pending;
for(let i=0;i<commonKEYColorArr.length;i++){ for(let i=0;i<commonKEYColorArr.length;i++){
console.info('setWindowSystemBarPropertiesTest3 begin step:'+i); console.info('setWindowSystemBarPropertiesTest3 begin step:'+i);
let tempColor = commonKEYColorArr[i]; let tempColor = commonKEYColorArr[i];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册