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

!3731 补充窗口xts接口

Merge pull request !3731 from 华华小仙女/master
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "hypium/index"
import ohosWindow from '@ohos.window'; import ohosWindow from '@ohos.window';
import display from '@ohos.display'; import display from '@ohos.display';
...@@ -417,7 +418,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -417,7 +418,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(data)==' + JSON.stringify(data)); 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)); console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(err)==' + JSON.stringify(err));
if (err && err.code) { if (err && err.code) {
expect(err.code === 130).assertTrue(); expect(err.code === 1003).assertTrue();
done(); done();
} else { } else {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [null,123]', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [null,123]', done);
...@@ -745,7 +746,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -745,7 +746,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err));
console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
expect(err.code === 130).assertTrue(); expect(err.code === 1003).assertTrue();
console.log(msgStr + 'ohosWindow.create err.code==' + JSON.stringify(err.code)) console.log(msgStr + 'ohosWindow.create err.code==' + JSON.stringify(err.code))
if (i === loopCount - 1) { if (i === loopCount - 1) {
done(); done();
...@@ -812,7 +813,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -812,7 +813,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
ohosWindow.create(context, windId, tempType, (err, data) => { ohosWindow.create(context, windId, tempType, (err, data) => {
console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data));
if (err && err.code) { if (err && err.code) {
expect(err.code === 130).assertTrue(); expect(err.code === 1003).assertTrue();
done(); done();
return; return;
} }
...@@ -840,7 +841,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -840,7 +841,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err));
if (err && err.code) { if (err && err.code) {
console.log(msgStr + 'ohosWindow.create 1 twice data: ' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.create 1 twice data: ' + JSON.stringify(data));
expect(err.code).assertEqual(120) expect(err.code).assertEqual(1001)
done(); done();
} else { } else {
unexpectedError(err, caseName, 'ohosWindow.create', done); unexpectedError(err, caseName, 'ohosWindow.create', done);
...@@ -1003,7 +1004,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1003,7 +1004,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (!!data) { if (!!data) {
expectedError(err, caseName, 'tempWnd.setWindowType', done); expectedError(err, caseName, 'tempWnd.setWindowType', done);
} else { } else {
expect(err.code == 130).assertTrue(); expect(err.code == 1003).assertTrue();
done(); done();
} }
}) })
...@@ -1044,7 +1045,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1044,7 +1045,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data));
console.log(msgStr + 'ohosWindow.find !!data' + !!data); console.log(msgStr + 'ohosWindow.find !!data' + !!data);
if (err && err.code) { if (err && err.code) {
expect(err.code == 120).assertTrue(); expect(err.code == 1001).assertTrue();
done(); done();
} else { } else {
expectedError(err, caseName, 'tempWnd.setWindowType', done); expectedError(err, caseName, 'tempWnd.setWindowType', done);
...@@ -1116,7 +1117,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1116,7 +1117,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data)); console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data));
console.log(msgStr + 'tempWnd.loadContent !!data' + !!data); console.log(msgStr + 'tempWnd.loadContent !!data' + !!data);
if (err && err.code) { if (err && err.code) {
expect(err.code === 130).assertTrue(); expect(err.code === 1003).assertTrue();
done(); done();
} else { } else {
expectedError(err, caseName, 'tempWnd.loadContent', done); expectedError(err, caseName, 'tempWnd.loadContent', done);
...@@ -1158,7 +1159,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1158,7 +1159,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
windowStage.loadContent(null, (err, data) => { windowStage.loadContent(null, (err, data) => {
if (err && err.code) { if (err && err.code) {
expectedError(err, caseName, 'windowStage.loadContent', done, 130); expectedError(err, caseName, 'windowStage.loadContent', done, 1003);
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
} }
done(); done();
...@@ -1196,7 +1197,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1196,7 +1197,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
windowStage.loadContent(null, abilityStorage, (err, data) => { windowStage.loadContent(null, abilityStorage, (err, data) => {
if (err && err.code) { if (err && err.code) {
expectedError(err, caseName, 'windowStage.loadContent', done, 130); expectedError(err, caseName, 'windowStage.loadContent', done, 1003);
console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
} }
done(); done();
...@@ -1233,7 +1234,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -1233,7 +1234,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
windowStage.createSubWindow(null, (err, data) => { windowStage.createSubWindow(null, (err, data) => {
if (err && err.code) { if (err && err.code) {
expectedError(err, caseName, 'windowStage.createSubWindow', done, 130); expectedError(err, caseName, 'windowStage.createSubWindow', done, 1003);
console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
} else { } else {
expect(false).assertTrue(); expect(false).assertTrue();
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
// @ts-nocheck // @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "hypium/index"
import ohosWindow from '@ohos.window'; import ohosWindow from '@ohos.window';
import screenManager from '@ohos.screen'; import screenManager from '@ohos.screen';
import display from '@ohos.display'; import display from '@ohos.display';
...@@ -69,9 +68,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -69,9 +68,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
beforeAll(function () { beforeAll(function () {
console.log('jsunittest beforeall ohosWindow.WindowType=' + JSON.stringify(ohosWindow.WindowType)); console.log('jsunittest beforeall ohosWindow.WindowType=' + JSON.stringify(ohosWindow.WindowType));
systemWindowTypeDicArr = Object.keys(systemWindowTypeDic); systemWindowTypeDicArr = Object.keys(systemWindowTypeDic);
console.log('jsunittest beforeall systemWindowTypeDicArr=' + JSON.stringify(systemWindowTypeDicArr)+' ,length='+systemWindowTypeDicArr.length);
systemWindowValueArr = Object.keys(systemWindowTypeDic); systemWindowValueArr = Object.keys(systemWindowTypeDic);
systemWindowTypeArr = Object.keys(systemWindowTypeDic); systemWindowTypeArr = Object.keys(systemWindowTypeDic);
for (i in ohosWindow.WindowType) { for (i in ohosWindow.WindowType) {
console.log('jsunittest beforeall i=' + i);
windowTypeArr.push(ohosWindow.WindowType[i]) windowTypeArr.push(ohosWindow.WindowType[i])
} }
}) })
...@@ -254,7 +255,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -254,7 +255,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
await sleep(1000); await sleep(1000);
tempWnd.off('systemAvoidAreaChange'); tempWnd.off('systemAvoidAreaChange');
console.log(msgStr + 'tempWnd.off systemAvoidAreaChange finished'); console.log(msgStr + 'tempWnd.off systemAvoidAreaChange finished');
await sleep(1200); await sleep(10010);
listenerOffFlag = listenerStatus.pending; listenerOffFlag = listenerStatus.pending;
await tempWnd.setSystemBarEnable(['status', 'navigation']).catch((err) => { await tempWnd.setSystemBarEnable(['status', 'navigation']).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
...@@ -394,14 +395,14 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -394,14 +395,14 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
let windowTypeData = await tempWnd.setWindowType(changedWndType).catch((err) => { let windowTypeData = await tempWnd.setWindowType(changedWndType).catch((err) => {
console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err));
expectedError(err, caseName, 'tempWnd.setWindowType', done, 130); expectedError(err, caseName, 'tempWnd.setWindowType', done, 1003);
}) })
console.log(msgStr + 'tempWnd.setWindowType windowTypeData' + JSON.stringify(windowTypeData)); console.log(msgStr + 'tempWnd.setWindowType windowTypeData' + JSON.stringify(windowTypeData));
console.log(msgStr + 'tempWnd.setWindowType !windowTypeData' + !windowTypeData); console.log(msgStr + 'tempWnd.setWindowType !windowTypeData' + !windowTypeData);
if (!!windowTypeData) { if (!!windowTypeData) {
unexpectedError(err, caseName, 'tempWnd.setWindowType', done); unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
} else { } else {
expect(err.code == 130).assertTrue(); expect(err.code == 1003).assertTrue();
done(); done();
} }
} else { } else {
...@@ -703,7 +704,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -703,7 +704,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success'); console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success');
await tempWnd.setSystemBarEnable([null, '123']).catch((err) => { await tempWnd.setSystemBarEnable([null, '123']).catch((err) => {
console.log(msgStr + 'tempWnd.setSystemBarEnable([null, 123]) err=' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setSystemBarEnable([null, 123]) err=' + JSON.stringify(err));
expect(err.code === 130).assertTrue(); expect(err.code === 1003).assertTrue();
done(); done();
}); });
console.log(msgStr + 'tempWnd.setSystemBarEnable([null, 123]) finished'); console.log(msgStr + 'tempWnd.setSystemBarEnable([null, 123]) finished');
...@@ -966,8 +967,8 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -966,8 +967,8 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'createTest1'; let caseName = 'createTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let loopCount = appWindowTypeArr.length; let loopCount = systemWindowTypeDicArr.length;
console.log('jsunittest loopCount: ' + loopCount); console.log(msgStr + 'loopCount: ' + loopCount);
for (let i = 0; i < loopCount; i++) { for (let i = 0; i < loopCount; i++) {
let tempType = systemWindowTypeDic[systemWindowTypeDicArr[i]]; let tempType = systemWindowTypeDic[systemWindowTypeDicArr[i]];
let windId = 'createTest1' + i; let windId = 'createTest1' + i;
...@@ -977,7 +978,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -977,7 +978,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done);
}); });
console.log(msgStr + 'ohosWindow.create ' + tempType + 'finished, wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.create ' + tempType + 'finished, wnd: ' + tempWnd);
expect(!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
} }
console.log(msgStr + 'done '); console.log(msgStr + 'done ');
done(); done();
...@@ -1042,7 +1043,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1042,7 +1043,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.create ' + tempType + ' start');
let nonExistWnd = await ohosWindow.create(context, windId, tempType).catch((err) => { let nonExistWnd = await ohosWindow.create(context, windId, tempType).catch((err) => {
console.log(msgStr + 'ohosWindow.create err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.create err: ' + JSON.stringify(err));
expect(err.code === 130).assertTrue(); expect(err.code === 1003).assertTrue();
done(); done();
}); });
}) })
...@@ -1063,7 +1064,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1063,7 +1064,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expect(!!ohosData).assertTrue(); expect(!!ohosData).assertTrue();
let ohosDataError = await ohosWindow.create(context, windowId, 1).catch((err) => { let ohosDataError = await ohosWindow.create(context, windowId, 1).catch((err) => {
console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err));
expect(err.code).assertEqual(120) expect(err.code).assertEqual(1001)
done(); done();
}) })
console.log(msgStr + 'ohosWindow.create 1 twice ohosDataError: ' + JSON.stringify(ohosDataError)); console.log(msgStr + 'ohosWindow.create 1 twice ohosDataError: ' + JSON.stringify(ohosDataError));
...@@ -1114,7 +1115,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1114,7 +1115,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let errFlag = false; let errFlag = false;
let loadContentData = await tempWnd.loadContent(null).catch((err) => { let loadContentData = await tempWnd.loadContent(null).catch((err) => {
errFlag = true; errFlag = true;
expectedError(err, caseName, 'tempWnd.loadContent', done, 130); expectedError(err, caseName, 'tempWnd.loadContent', done, 1003);
console.log(msgStr + 'tempWnd.loadContent(null)' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent(null)' + JSON.stringify(err));
}); });
console.log(msgStr + 'tempWnd.loadContent loadContentData:' + JSON.stringify(loadContentData)); console.log(msgStr + 'tempWnd.loadContent loadContentData:' + JSON.stringify(loadContentData));
...@@ -1152,7 +1153,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1152,7 +1153,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let load4 = await windowStage.loadContent(null).catch((err) => { let load4 = await windowStage.loadContent(null).catch((err) => {
expectedError(err, caseName, 'tempWnd.loadContent', done, 130); expectedError(err, caseName, 'tempWnd.loadContent', done, 1003);
console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
}); });
console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load4)); console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load4));
...@@ -1168,7 +1169,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1168,7 +1169,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let load5 = await windowStage.loadContent(null, abilityStorage).catch((err) => { let load5 = await windowStage.loadContent(null, abilityStorage).catch((err) => {
expectedError(err, caseName, 'tempWnd.loadContent', done, 130); expectedError(err, caseName, 'tempWnd.loadContent', done, 1003);
console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
}); });
console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load5)); console.log(msgStr + 'tempWnd.loadContent end load5=' + JSON.stringify(load5));
...@@ -1218,7 +1219,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1218,7 +1219,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let subWindow = await windowStage.createSubWindow(null).catch((err) => { let subWindow = await windowStage.createSubWindow(null).catch((err) => {
expectedError(err, caseName, 'windowStage.createSubWindow', done, 130); expectedError(err, caseName, 'windowStage.createSubWindow', done, 1003);
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));
...@@ -1310,7 +1311,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) ...@@ -1310,7 +1311,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
}); });
console.log(msgStr + 'tempWnd.destroy end'); console.log(msgStr + 'tempWnd.destroy end');
let findWnd = await ohosWindow.find(windowId).catch((err) => { let findWnd = await ohosWindow.find(windowId).catch((err) => {
expectedError(err, caseName, 'ohosWindow.find', done, 120); expectedError(err, caseName, 'ohosWindow.find', done, 1001);
}); });
console.log(msgStr + 'find findWnd: ' + JSON.stringify(findWnd)); console.log(msgStr + 'find findWnd: ' + JSON.stringify(findWnd));
expect(!findWnd).assertTrue(); expect(!findWnd).assertTrue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册