Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
411bde32
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
411bde32
编写于
11月 04, 2022
作者:
华
华华小仙女
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
整理代码
Signed-off-by:
N
华华小仙女
<
zhurong18@h-partners.com
>
上级
4f57f955
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
112 addition
and
221 deletion
+112
-221
graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets
...indowStage/entry/src/main/ets/test/windowPromise.test.ets
+112
-221
未找到文件。
graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets
浏览文件 @
411bde32
...
...
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import ohosWindow from '@ohos.window';
import screenManager from '@ohos.screen';
...
...
@@ -27,6 +28,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
var commonNUMBERColorArr = ['#00FF0000', '#0000FF00', '#000000FF', '#00FFFFFF', '#00000000', '#00F900E6', '#00666666', '#00FFF700'];
var commonKEYColorArr = ['red', 'green', 'blue', 'white', 'black', 'pink', 'grey', 'yellow'];
var appWindowTypeArr = [];
var windowTypeArr = [];
var appWindowTypeDic = {
'TYPE_BASE': 0,
'TYPE_APP': 0,
...
...
@@ -70,6 +72,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log('jsunittest beforeall systemWindowTypeDicArr=' + JSON.stringify(systemWindowTypeDicArr) + ' ,length=' + systemWindowTypeDicArr.length);
systemWindowValueArr = Object.keys(systemWindowTypeDic);
systemWindowTypeArr = Object.keys(systemWindowTypeDic);
for (i in ohosWindow.WindowType) {
console.log('jsunittest beforeall i=' + i);
windowTypeArr.push(ohosWindow.WindowType[i])
}
})
beforeEach(function () {
})
...
...
@@ -175,22 +181,14 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let resizeValue = 200;
let listenerOnFlag = listenerStatus.ready;
console.log(msgStr + 'begin');
let tempWnd = null;
try {
await ohosWindow.create(context, wndId, baseType).then((data) => {
tempWnd = data
console.log(msgStr + 'ohosWindow.create data:' + JSON.stringify(data));
}).catch((err) => {
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';
} catch (err) {
console.log(msgStr + 'ohosWindow.create catch err:' + JSON.stringify(err));
}
await tempWnd.on('windowSizeChange', (sizeData) => {
tempWnd.on('windowSizeChange', (sizeData) => {
console.log(msgStr + 'tempWnd.on windowSizeChange, systemBatData : ' + JSON.stringify(sizeData));
if (listenerOnFlag === listenerStatus.pending) {
listenerOnFlag = listenerStatus.finished;
...
...
@@ -278,16 +276,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let changedModel = 102;
let listenerOffFlag = listenerStatus.ready;
console.log(msgStr + 'begin');
let createWindowObj = {
name: wndId, windowType: baseType, ctx: context
}
console.log(msgStr + 'ohosWindow.create createWindowObj:' + JSON.stringify(createWindowObj));
let tempWnd = null;
try {
// await ohosWindow.createWindow(createWindowObj).then((data) => {
await ohosWindow.create(context, wndId, baseType).then((data) => {
console.log(msgStr + 'ohosWindow.create data:' + JSON.stringify(data));
tempWnd = data
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;
...
...
@@ -302,12 +293,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
done();
}
})
}).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
} catch (err) {
}
await tempWnd.show().catch((err) => {
unexpectedError(err, caseName, 'tempWnd.show', done);
});
...
...
@@ -381,7 +366,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length);
done();
}
} else {
unexpectedError(err, caseName, 'tempWnd.getProperties', done);
}
} else {
unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
}
}
})
...
...
@@ -408,13 +397,17 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let windowTypeData = await tempWnd.setWindowType(changedWndType).catch((err) => {
console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err));
expectedError(err, caseName, 'tempWnd.setWindowType', done, 1003);
done();
})
console.log(msgStr + 'tempWnd.setWindowType windowTypeData' + JSON.stringify(windowTypeData));
console.log(msgStr + 'tempWnd.setWindowType !windowTypeData' + !windowTypeData);
if (!!windowTypeData) {
expect(false).assertFail();
unexpectedError(err, caseName, 'tempWnd.setWindowType', done);
} else {
expect(err.code == 1003).assertTrue();
done();
}
} else {
unexpectedError(err, caseName, 'ohosWindow.create', done);
}
})
/**
...
...
@@ -1007,26 +1000,19 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let windId = 'createTest2' + i;
console.log(msgStr + 'ohosWindow.create ' + tempType + ' start');
let createData = null;
try {
await ohosWindow.create(context, windId, tempType).then((data) => {
createData = data
expect(!!createData).assertTrue();
}).catch((err) => {
let createData = await ohosWindow.create(context, windId, tempType).catch((err) => {
console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done);
return;
})
}
catch (err) {
console.log(msgStr + 'ohosWindow.create catch err' + JSON.stringify(err));
}
expect(!!createData).assertTrue();
let tempWnd = createData
console.log(msgStr + 'ohosWindow.create ' + tempType + ' wnd: ' + tempWnd);
let proData = await tempWnd.getProperties().catch((err) => {
console.log(msgStr + 'tempWnd.getProperties err' + JSON.stringify(err));
unexpectedError(err, caseName, 'tempWnd.getProperties', done);
console.log(msgStr + 'tempWnd.getProperties err&&err.code' + JSON.stringify(err));
console.log(msgStr + 'tempWnd.getProperties success, !!data : ' + !!data);
})
expect(!!proData).assertTrue();
expect(proData.type == tempType).assertTrue();
...
...
@@ -1038,7 +1024,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
if (n === loopCount) {
expect(true).assertTrue();
} else {
expect(true).assertFail(
);
unexpectedError(err, caseName, 'tempWnd.getProperties', done
);
}
}
}
...
...
@@ -1095,21 +1081,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let baseWndType = 1;
let windowId = 'loadContentTest1';
console.log(msgStr + 'begin');
let createWindowObj = {
name: windowId, windowType: baseWndType, ctx: context
}
let tempWnd = null;
try {
await ohosWindow.createWindow(createWindowObj).then((data) => {
// await ohosWindow.create(context, wndId, baseType).then((data) => {
tempWnd = data
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' , wnd: ' + tempWnd);
}).catch((err) => {
let tempWnd = await ohosWindow.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
});
} catch (err) {
console.log(msgStr + 'ohosWindow.create catch err:' + JSON.stringify(err));
}
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' , wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let load = await tempWnd.loadContent('pages/second/second').catch((err) => {
...
...
@@ -1132,29 +1107,14 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let baseWndType = 1;
let windowId = 'loadContentTest2';
console.log(msgStr + 'begin');
let createWindowObj = {
name: windowId, windowType: baseWndType, ctx: context
}
let tempWnd = null;
try {
await ohosWindow.createWindow(createWindowObj).then((data) => {
tempWnd = data
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
}).catch((err) => {
let tempWnd = await ohosWindow.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
});
}
catch (err) {
console.log(msgStr + 'ohosWindow.createWindow catch err:' + JSON.stringify(err));
}
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let errFlag = false;
let loadContentData = null;
try {
await tempWnd.loadContent(null).then((data) => {
loadContentData = data;
}).catch((err) => {
let loadContentData = await tempWnd.loadContent(null).catch((err) => {
errFlag = true;
expectedError(err, caseName, 'tempWnd.loadContent', done, 1003);
console.log(msgStr + 'tempWnd.loadContent(null)' + JSON.stringify(err));
...
...
@@ -1165,9 +1125,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expect(TRUE_FLAG).assertFail();
done();
}
} catch (err) {
console.log(msgStr + 'tempWnd.loadContent(null) catch err:' + JSON.stringify(err));
}
})
/**
...
...
@@ -1245,6 +1202,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
});
expect(!load6).assertTrue();
console.log(msgStr + 'tempWnd.loadContent end load=' + JSON.stringify(load6));
done();
})
/**
...
...
@@ -1360,22 +1318,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let baseWndType = 1;
let windowId = 'destroyTest1';
console.log(msgStr + 'begin');
let createWindowObj = {
name: windowId, windowType: baseWndType, ctx: context
}
let tempWnd = null;
try {
await ohosWindow.createWindow(createWindowObj).then((data) => {
tempWnd = data
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');
}).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
});
} catch (err) {
console.log(msgStr + 'destroy catch err : ' + JSON.stringify(err));
}
await tempWnd.destroy().catch((err) => {
unexpectedError(err, caseName, 'tempWnd.destroy', done);
console.log(msgStr + 'destroy err : ' + JSON.stringify(err));
...
...
@@ -1397,23 +1345,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let caseName = 'setDensityDpiTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let screens = null;
try {
await screenManager.getAllScreens().then((data) => {
screens = data
console.log(msgStr + 'screenManager.getAllScreen' + JSON.stringify(screens));
expect(!!screens).assertTrue();
}).catch(err => {
let screens = await screenManager.getAllScreens().catch(err => {
unexpectedError(err, caseName, 'screenManager.getAllScreen', done);
})
}
catch (err) {
console.log(msgStr + 'screenManager.getAllScreen catch err:' + JSON.stringify(err));
}
let currentDeviceDefault = null;
await display.getDefaultDisplay().then((data) => {
currentDeviceDefault = data
}).catch(err => {
console.log(msgStr + 'screenManager.getAllScreen' + JSON.stringify(screens));
expect(!!screens).assertTrue();
let currentDeviceDefault = await display.getDefaultDisplay().catch(err => {
console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay failed current device');
});
console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay current device' + JSON.stringify(currentDeviceDefault));
...
...
@@ -1423,14 +1360,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
await sleep(1000);
await screens[0].setDensityDpi(dpiItem[i]).then(async () => {
console.log(msgStr + 'screen.setDensityDpi success set DPI ' + dpiItem[i]);
let defaultDpi = null;
display.getDefaultDisplay().then((data) => {
defaultDpi = data
}).catch(err => {
let defaultDpi = await display.getDefaultDisplay().catch(err => {
console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay failed');
});
console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay' + JSON.stringify(defaultDpi));
let isEqual =
Number(defaultDpi.densityDPI) == dpiItem[i]
let isEqual =
defaultDpi.densityDPI == parseInt(dpiItem[i])
console.log(msgStr + 'same ? ' + isEqual)
expect(isEqual).assertTrue()
}).catch(err => {
...
...
@@ -1454,7 +1388,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
console.log(msgStr + 'windowStage.getMainWindow :' + JSON.stringify(mainWin));
expect(!!mainWin).assertTrue();
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE'];
let num = 0
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED',
'LANDSCAPE_INVERTED', 'AUTO_ROTATION', 'AUTO_ROTATION_PORTRAIT', 'AUTO_ROTATION_LANDSCAPE',
'AUTO_ROTATION_RESTRICTED', 'AUTO_ROTATION_PORTRAIT_RESTRICTED', 'AUTO_ROTATION_LANDSCAPE_RESTRICTED', 'LOCKED', 'UNSPECIFIED'];
for (let i = 0;i < orientationItem.length; i++) {
await sleep(1000);
let orientation = ohosWindow.Orientation[orientationItem[i]]
...
...
@@ -1462,12 +1399,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'i : ' + i + ' ,ohosWindow.Orientation : ' + JSON.stringify(ohosWindow.Orientation));
await mainWin.setPreferredOrientation(orientation).then(() => {
console.log(msgStr + 'success set window.setPreferredOrientation : ' + orientation);
num++
if(num == orientationItem.length) done();
}).catch(err => {
console.log(msgStr + 'window.setPreferredOrientation failed set error:' + orientation);
});
}
console.log(msgStr + 'done ');
done();
})
/**
* @tc.number SUB_WINDOW_SETFORBIDSPLITMOVE_JSAPI_001
...
...
@@ -1527,21 +1464,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context));
let tempType = ohosWindow.WindowType.TYPE_DIALOG
let dialogTargetTouchTest1Win = null;
let createWindowObj = {
name: 'dialogTargetTouchTest1', windowType: tempType, ctx: context
}
try {
await ohosWindow.createWindow(createWindowObj).then((data) => {
dialogTargetTouchTest1Win = data
})
let dialogTargetTouchTest1Win = await ohosWindow.create(context, 'dialogTargetTouchTest1', tempType)
.catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
})
}
catch (err) {
console.log(msgStr + 'ohosWindow.createWindow catch err' + JSON.stringify(err));
}
expect(!!dialogTargetTouchTest1Win).assertTrue();
dialogTargetTouchTest1Win.destroy();
done();
...
...
@@ -1558,21 +1484,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin ohosWindow==' + JSON.stringify(ohosWindow));
let wndId = 'animationForShownTest1';
let baseType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let tempWnd = null;
let createWindowObj = {
name: wndId, windowType: baseType, ctx: context
}
try {
await ohosWindow.createWindow(createWindowObj).then((data) => {
tempWnd = data
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
}).catch((err) => {
let tempWnd = await ohosWindow.create(context, wndId, baseType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
} catch (err) {
console.log(msgStr + 'ohosWindow.createWindow catch err:' + JSON.stringify(err));
}
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
let controller = tempWnd.getTransitionController();
controller.animationForShown = (context: ohosWindow.TransitionContext) => {
let toWindow = context.toWindow
...
...
@@ -1626,24 +1542,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin context==' + JSON.stringify(context));
let wndId = 'showWithAnimationTest1';
let baseType = ohosWindow.WindowType.TYPE_FLOAT;
let createWindowObj = {
name: wndId, windowType: baseType, ctx: context
}
let tempWnd = null;
try {
await ohosWindow.createWindow(createWindowObj).then((data) => {
tempWnd = data
let tempWnd = await ohosWindow.create(context, wndId, baseType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue();
console.info('showWithAnimationTest1 ****' + Reflect.has(tempWnd, 'showWithAnimation'))
}).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
}
catch (err) {
console.log(msgStr + 'ohosWindow.create catch err:' + JSON.stringify(err));
}
await tempWnd.showWithAnimation().then((data) => {
console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
done();
...
...
@@ -1662,31 +1566,18 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'begin context==' + JSON.stringify(context));
let wndId = 'hideWithAnimationTest1';
let baseType = ohosWindow.WindowType.TYPE_FLOAT;
let createWindowObj = {
name: wndId, windowType: baseType, ctx: context
}
let tempWnd = null;
try {
await ohosWindow.createWindow(createWindowObj).then((data) => {
tempWnd = data
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue();
}).catch((err) => {
let tempWnd = await ohosWindow.create(context, wndId, baseType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
}
catch(err) {
console.log(msgStr + 'ohosWindow.create catch err:' + JSON.stringify(err));
}
let findWnd = null;
await ohosWindow.find(wndId).then((data) => {
findWnd = data
}).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.find', done);
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue();
let findWnd = await ohosWindow.find(wndId).catch((err) => {
expectedError(err, caseName, 'ohosWindow.find', done);
});
console.log(msgStr + 'find findWnd: ' + JSON.stringify(findWnd));
expect(!!findWnd).assertTrue();
console.info('hideWithAnimationTest1 ****' + Reflect.has(findWnd, 'hideWithAnimation'))
console.info('hideWithAnimationTest1 ****' + Reflect.has(findWnd, 'destroy'))
let promise = findWnd.hideWithAnimation();
promise.then((data) => {
console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录