提交 c5efcd72 编写于 作者: Z zhurong

Supplement the codes with previous problems

Signed-off-by: Nzhurong <zhurong18@h-partners.com>
上级 b2226ed9
......@@ -18,7 +18,6 @@ import ohosWindow from '@ohos.window';
import display from '@ohos.display';
export default function windowCallbackTest(context, windowStage, abilityStorage) {
console.log('testets context: ' + JSON.stringify(context))
console.log('testets context windowStage: ' + JSON.stringify(windowStage));
console.log('testets context abilityStorage: ' + JSON.stringify(abilityStorage));
......@@ -116,6 +115,270 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}, time);
})
}
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_006
* @tc.name Test setSystemBarEnableTest6
* @tc.desc Test ohosWindow.setSystemBarEnable API function test1.
*/
it('setSystemBarEnableTest6', 0, 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.name Test setSystemBarEnableTest7
* @tc.desc Verify that the scene hides the status bar and displays the navigation bar.
*/
it('setSystemBarEnableTest7', 0, function (done) {
let caseName = 'setSystemBarEnableTest7';
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 :' + JSON.stringify(systembartintstate));
console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
if (flagStatus || flagNav) {
console.log(msgStr + 'ohosWindow.on flagStatus || flagNav:');
expect(!!systembartintstate).assertTrue();
done();
}
})
let mainWnd = null;
console.log(msgStr + 'mainWnd = null')
windowStage.getMainWindow((err, 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) => {
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.show', done);
}
console.log(msgStr + 'mainWnd.show success');
expect(!data).assertTrue();
mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done);
}
expect(!data).assertTrue();
mainWnd.setSystemBarEnable(['status'], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(data)==' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done);
}
flagStatus = true;
expect(!data).assertTrue();
mainWnd.setSystemBarEnable(['navigation'], (err, data) => {
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navitgation]', done);
}
flagNav = true;
expect(!data).assertTrue();
})
})
})
})
})
console.log(msgStr + 'finished!!');
});
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_008
* @tc.name Test setSystemBarEnableTest8
* @tc.desc Verify that the scene displays both the status bar and the navigation bar.
*/
it('setSystemBarEnableTest8', 0, function (done) {
let caseName = 'setSystemBarEnableTest8';
let msgStr = 'jsunittest ' + caseName + ' ';
let [flagStatus, flagNav] = [false, false];
console.log(msgStr + 'begin');
let mainWnd = null;
console.log(msgStr + 'mainWnd = null');
windowStage.getMainWindow((err, 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) => {
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.show', done);
}
console.log(msgStr + 'mainWnd.show success');
expect(!data).assertTrue();
mainWnd.setFullScreen(true, (err, data) => {
console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setFullScreen true', done);
}
expect(!data).assertTrue();
mainWnd.setSystemBarEnable([], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done);
}
expect(!data).assertTrue();
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
setTimeout(() => {
ohosWindow.on('systemBarTintChange', systembartintstate => {
console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate));
console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint));
setTimeout(() => {
if (flagStatus || flagNav) {
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));
expect(numType === 2112 || enable).assertTrue();
}
done();
}, 3000)
})
}, 2300)
mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status,navigation]', done);
}
flagStatus = true;
flagNav = true;
expect(!data).assertTrue();
})
})
})
})
})
});
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_009
* @tc.name Test setSystemBarEnableTest9
* @tc.desc Verify that the scene hides both the status bar and the navigation bar.
*/
// it('setSystemBarEnableTest9', 0, function (done) {
// let caseName = 'setSystemBarEnableTest9';
// let msgStr = 'jsunittest ' + caseName + ' ';
// let [flagStatus, flagNav] = [false, false];
// console.log(msgStr + 'begin');
// let mainWnd = null;
// console.log(msgStr + 'mainWnd = null');
// windowStage.getMainWindow((err, 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) => {
// if (err && err.code) {
// unexpectedError(data, caseName, 'mainWnd.show', done);
// }
// console.log(msgStr + 'mainWnd.show success');
// expect(!data).assertTrue();
// mainWnd.setFullScreen(true, (err, data) => {
// console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data));
// if (err && err.code) {
// unexpectedError(data, caseName, 'mainWnd.setFullScreen', done);
// }
// expect(!data).assertTrue();
// mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
// console.log(msgStr + 'mainWnd.setSystemBarEnable status,navigation JSON.stringify(data)==' + JSON.stringify(data));
// if (err && err.code) {
// unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status,navigation]', done);
// }
// flagStatus = true;
// flagNav = true;
// expect(!data).assertTrue();
// listenerData.on = true;
// listenerData.typeStr = 'systemBarTintChange';
// 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) {
// expect(!!systembartintstate).assertTrue();
// done();
// }
// })
// mainWnd.setSystemBarEnable([], (err, data) => {
// if (err && err.code) {
// unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done);
// }
// expect(!data).assertTrue();
// done();
// })
// })
// })
// })
// })
// });
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_010
* @tc.name Test setSystemBarEnableTest10
......@@ -147,15 +410,15 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}
expect(!data).assertTrue();
mainWnd.setSystemBarEnable([], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringfy(data)==' + JSON.stringify(data));
console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done);
}
expect(!data).assertTrue();
mainWnd.setSystemBarEnable([null, '123'], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringfy(data)==' + JSON.stringify(data));
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringfy(err)==' + JSON.stringify(err));
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(data)==' + JSON.stringify(data));
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(err)==' + JSON.stringify(err));
if (err && err.code) {
expect(err.code === 130).assertTrue();
done();
......@@ -744,10 +1007,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
})
})
/**
* @tc.number SUB_WINDOW_DESTROY_JSAPI_002
* @tc.name Test destroyTest2
* @tc.desc Verification window destruction scenario
*/
* @tc.number SUB_WINDOW_DESTROY_JSAPI_002
* @tc.name Test destroyTest2
* @tc.desc Verification window destruction scenario
*/
it('destroyTest2', 0, function (done) {
let caseName = 'destroyTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
......@@ -824,10 +1087,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
})
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_008
* @tc.name Test loadContentTest8
* @tc.desc Verify the scenario of loading a page that does not exist
*/
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_008
* @tc.name Test loadContentTest8
* @tc.desc Verify the scenario of loading a page that does not exist
*/
it('loadContentTest8', 0, function (done) {
let caseName = 'loadContentTest8';
let msgStr = 'jsunittest ' + caseName + ' ';
......@@ -968,8 +1231,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin ohosWindow =' + JSON.stringify(ohosWindow));
let mainWnd = null;
ohosWindow.create(context,'setPrivacyModeTest2', ohosWindow.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err&&err.code) {
ohosWindow.create(context, 'setPrivacyModeTest2', ohosWindow.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err && err.code) {
console.log(msgStr + 'ohosWindow.create fail err:' + JSON.stringify(err));
expect().assertFail();
done();
......@@ -1040,7 +1303,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin ohosWindow =' + JSON.stringify(ohosWindow));
let mainWnd = null;
windowStage.createSubWindow('setPrivacyModeTest3', (err, data) => {
if (err&&err.code) {
if (err && err.code) {
console.log(msgStr + 'windowStage.createSubWindow fail err:' + JSON.stringify(err));
expect().assertFail();
done();
......
......@@ -95,6 +95,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
function expectedError(error, caseName, apiName, done, code) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error));
console.log(msgStr + 'code:'+code);
if (error.code === code) {
expect(TRUE_FLAG).assertTrue();
}
......@@ -115,7 +116,211 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
}, time);
})
}
/**
* @tc.number SUB_WINDOW_ON_OFF_JSAPI_001
* @tc.name Test listenerTest1
* @tc.desc Verify whether the change monitoring of avoidance area can be started normally.
*/
it('listenerTest1', 0, async function (done) {
let caseName = 'listenerTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
let listenerOnFlag = listenerStatus.ready;
console.log(msgStr + 'begin');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
});
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
listenerData.on = true;
listenerData.typeStr = 'systemAvoidAreaChange';
tempWnd.on('systemAvoidAreaChange', (avoidAreaData) => {
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, systemBatData : ' + JSON.stringify(avoidAreaData));
if (listenerOnFlag === listenerStatus.pending) {
listenerOnFlag = listenerStatus.finished;
expect(!!avoidAreaData).assertTrue();
done();
}
})
expect(!!tempWnd).assertTrue();
await tempWnd.show().catch((err) => {
unexpectedError(err, caseName, 'tempWnd.show', done);
});
console.log(msgStr + 'tempWnd.show success');
await tempWnd.setFullScreen(true).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
});
console.log(msgStr + 'tempWnd.setFullScreen(true) success');
await tempWnd.setSystemBarEnable([]).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done);
});
console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success');
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange finished');
await sleep(1000);
listenerOnFlag = listenerStatus.pending;
await tempWnd.setSystemBarEnable(['status', 'navigation']).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
});
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
})
/**
* @tc.number SUB_WINDOW_ON_OFF_JSAPI_002
* @tc.name Test listenerTest2
* @tc.desc Verify that the window size avoidance area changes and monitor whether it can be opened normally.
*/
it('listenerTest2', 0, async function (done) {
let caseName = 'listenerTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
let wndId = 'listenerTest2';
let baseType = 2;
let changedModel = 102;
let baseValue = 100;
let resizeValue = 200;
let listenerOnFlag = 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, systemBatData : ' + JSON.stringify(sizeData));
if (listenerOnFlag === listenerStatus.pending) {
listenerOnFlag = listenerStatus.finished;
expect(!!sizeData).assertTrue();
expect(sizeData.width === resizeValue).assertTrue();
expect(sizeData.height === resizeValue).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(baseValue, baseValue).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.resetSize(' + baseValue + ', ' + baseValue + ')', done);
});
console.log(msgStr + 'tempWnd.resetSize(' + baseValue + ', ' + baseValue + ') success');
console.log(msgStr + 'tempWnd.on windowSizeChange finished');
await sleep(1000);
listenerOnFlag = listenerStatus.pending;
await tempWnd.resetSize(resizeValue, resizeValue).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.resetSize(' + resizeValue + ', ' + resizeValue + ')', done);
});
console.log(msgStr + 'tempWnd.resetSize(' + resizeValue + ', ' + resizeValue + ') success');
})
/**
* @tc.number SUB_WINDOW_ON_OFF_JSAPI_003
* @tc.name Test listenerTest3
* @tc.desc Verify whether the change monitoring of avoidance area can be started normally.
*/
it('listenerTest3', 0, async function (done) {
let caseName = 'listenerTest3';
let msgStr = 'jsunittest ' + caseName + ' ';
let listenerOffFlag = listenerStatus.ready;
console.log(msgStr + 'begin');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
});
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
listenerData.on = true;
listenerData.typeStr = 'systemAvoidAreaChange';
tempWnd.on('systemAvoidAreaChange', (avoidAreaData) => {
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, systemBatData : ' + JSON.stringify(avoidAreaData));
setTimeout(()=>{
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, systemBatData 1100 : ' + JSON.stringify(avoidAreaData));
},1100)
done();
})
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange finished');
await tempWnd.show().catch((err) => {
unexpectedError(err, caseName, 'tempWnd.show', done);
});
console.log(msgStr + 'tempWnd.show success');
await tempWnd.setFullScreen(true).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
});
console.log(msgStr + 'tempWnd.setFullScreen(true) success');
await tempWnd.setSystemBarEnable([]).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done);
});
console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success');
await sleep(1000);
tempWnd.off('systemAvoidAreaChange');
console.log(msgStr + 'tempWnd.off systemAvoidAreaChange finished');
await sleep(1200);
listenerOffFlag = listenerStatus.pending;
await tempWnd.setSystemBarEnable(['status', 'navigation']).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
});
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;
unexpectedError(null, caseName, 'off windowSizeChange', 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');
await sleep(1000);
tempWnd.off('windowSizeChange');
console.log(msgStr + 'tempWnd.off windowSizeChange finished');
sleep(1000);
listenerOffFlag = listenerStatus.pending;
await tempWnd.resetSize(200, 200).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.resetSize(200, 200)', done);
});
console.log(msgStr + 'tempWnd.resetSize(200, 200) success');
setTimeout(() => {
if (listenerOffFlag === listenerStatus.finished) {
let apiStr = 'tempWnd.off windowSizeChange time wait';
unexpectedError(null, caseName, apiStr, done);
} else {
console.log(msgStr + 'tempWnd.off windowSizeChange time wait');
done();
}
}, 5000)
})
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_001
* @tc.name Test setSystemBarEnableTest1
......@@ -784,12 +989,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let errFlag = false;
await tempWnd.loadContent(null).catch((err) => {
let loadContentData = await tempWnd.loadContent(null).catch((err) => {
errFlag = true;
expectedError(err, caseName, 'tempWnd.loadContent', done, 130);
console.log(msgStr + 'tempWnd.loadContent(null)' + JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent end');
console.log(msgStr + 'tempWnd.loadContent loadContentData:'+JSON.stringify(loadContentData));
if (!errFlag) {
console.log(msgStr + 'should report err');
expect(TRUE_FLAG).assertFail();
......@@ -823,12 +1028,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'loadContentTest5';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let load5 = await windowStage.loadContent('pages/index/index.ets', abilityStorage).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
let load5 = await windowStage.loadContent(null, abilityStorage).catch((err) => {
expectedError(err, caseName, 'tempWnd.loadContent', done,130);
console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
});
expect(!load5).assertTrue();
console.log(msgStr + 'tempWnd.loadContent end load=' + JSON.stringify(load5));
// expect(!load5).assertTrue();
console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load5));
done();
})
/**
......@@ -947,5 +1152,33 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expect(!lastPro.isPrivacyMode).assertTrue();
done();
})
/**
* @tc.number SUB_WINDOW_DESTROY_JSAPI_001
* @tc.name Test destroyTest1
* @tc.desc Verification window destruction scenario.
*/
it('destroyTest1', 0, async function (done) {
let caseName = 'destroyTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
let windowId = 'destroyTest1';
console.log(msgStr + 'begin');
let tempWnd = await ohosWindow.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
});
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.destroy start');
await tempWnd.destroy().catch((err) => {
unexpectedError(err, caseName, 'tempWnd.destroy', done);
});
console.log(msgStr + 'tempWnd.destroy end');
let findWnd = await ohosWindow.find(windowId).catch((err) => {
expectedError(err, caseName, 'ohosWindow.find', done);
});
console.log(msgStr + 'find findWnd:'+JSON.stringify(findWnd));
expect(!findWnd).assertTrue();
done();
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册