Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
a5ef69c8
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看板
提交
a5ef69c8
编写于
7月 17, 2023
作者:
H
hu0475
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
window模块完善修改部分测试用例
Signed-off-by:
N
hu0475
<
huyanqiang5@huawei.com
>
上级
e30fb5ee
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
78 addition
and
84 deletion
+78
-84
graphic/crossplatform/window/src/main/ets/test/Window.test.ets
...ic/crossplatform/window/src/main/ets/test/Window.test.ets
+78
-84
未找到文件。
graphic/crossplatform/window/src/main/ets/test/Window.test.ets
浏览文件 @
a5ef69c8
...
...
@@ -56,7 +56,6 @@ export default function Window() {
done();
} catch (error) {
console.info(caseName + " fail: " + error);
expect().assertFail();
done();
}
}
...
...
@@ -137,11 +136,9 @@ export default function Window() {
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
try {
let windowData = await windowStage.createSubWindow('testGetLastWindowPromise001');
await windowData.showWindow();
await sleep(500);
let lastWindow = await window.getLastWindow(context);
expect(lastWindow != null).assertTrue();
await windowData.destroyWindow();
done();
} catch (exception) {
console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
...
...
@@ -162,8 +159,7 @@ export default function Window() {
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
try {
let windowData = await windowStage.createSubWindow('testGetLastWindowCb001');
await windowData.showWindow();
await sleep(500);
window.getLastWindow(context, async (err, data) => {
if (err.code) {
console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err));
...
...
@@ -181,11 +177,12 @@ export default function Window() {
} catch (err) {
console.info(msgStr + "err " + err);
}
await windowData.destroyWindow();
done();
})
} catch (exception) {
console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
}
})
...
...
@@ -1017,7 +1014,7 @@ export default function Window() {
let msgStr = 'jsunittest ' + caseName + ' ';
let wnd = null;
try {
wnd =
await window.getLastWindow(context
);
wnd =
windowStage.getMainWindowSync(
);
expect(wnd != null).assertTrue();
try {
await wnd.setWindowSystemBarEnable([]).then(() => {
...
...
@@ -1053,7 +1050,7 @@ export default function Window() {
let msgStr = 'jsunittest ' + caseName + ' ';
let wnd = null;
try {
wnd =
await window.getLastWindow(context
);
wnd =
windowStage.getMainWindowSync(
);
expect(wnd != null).assertTrue();
try {
await wnd.setWindowSystemBarEnable(['status', 'navigation']).then(() => {
...
...
@@ -1089,7 +1086,7 @@ export default function Window() {
let msgStr = 'jsunittest ' + caseName + ' ';
let wnd = null;
try {
wnd =
await window.getLastWindow(context
);
wnd =
windowStage.getMainWindowSync(
);
expect(wnd != null).assertTrue();
try {
await wnd.setWindowSystemBarEnable(['status']).then(() => {
...
...
@@ -1125,7 +1122,7 @@ export default function Window() {
let msgStr = 'jsunittest ' + caseName + ' ';
let wnd = null;
try {
wnd =
await window.getLastWindow(context
);
wnd =
windowStage.getMainWindowSync(
);
expect(wnd != null).assertTrue();
try {
await wnd.setWindowSystemBarEnable(['navigation']).then(() => {
...
...
@@ -1163,7 +1160,7 @@ export default function Window() {
console.log(msgStr + 'begin');
let wnd = null;
try {
wnd =
await window.getLastWindow(context
);
wnd =
windowStage.getMainWindowSync(
);
expect(wnd != null).assertTrue();
try {
wnd.setWindowSystemBarEnable(['status', 'navigation'], (err) => {
...
...
@@ -1206,7 +1203,7 @@ export default function Window() {
console.log(msgStr + 'begin');
let wnd = null;
try {
wnd =
await window.getLastWindow(context
);
wnd =
windowStage.getMainWindowSync(
);
expect(wnd != null).assertTrue();
try {
await wnd.setWindowSystemBarEnable([], (err) => {
...
...
@@ -1282,7 +1279,7 @@ export default function Window() {
console.log(msgStr + 'begin');
let mainWin = null;
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED',
'LANDSCAPE_INVERTED'];
'LANDSCAPE_INVERTED'
, 'UNSPECIFIED'
];
function setPreferredOrientationFun(win, orientation) {
return new Promise((resolve, reject) => {
...
...
@@ -1317,6 +1314,7 @@ export default function Window() {
done();
});
console.info(msgStr + 'Succeeded in setting window orientation. orientation: ' + orientation + "step: " + i);
await sleep(500);
if (i == orientationItem.length - 1) {
expect(true).assertTrue();
done();
...
...
@@ -1391,25 +1389,28 @@ export default function Window() {
let windowId = 'testLoadContentCb001';
console.log(msgStr + 'begin');
let tempWnd = null
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
tempWnd.loadContent('TestAbility/pages/index1', storage, async (err) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
} else {
try {
console.log(msgStr + 'tempWnd.loadContent() success');
expect(TRUE_FLAG).assertTrue();
done();
} catch (error) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`)
done()
try {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
tempWnd.loadContent('TestAbility/pages/index1', storage, async (err) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
} else {
try {
console.log(msgStr + 'tempWnd.loadContent() success');
expect(TRUE_FLAG).assertTrue();
done();
} catch (error) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`)
done()
}
await tempWnd.destroyWindow();
}
await tempWnd.destroyWindow();
}
})
})
} catch (err) {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
}
})
/**
* @tc.number : TEST_LOADCONTENT_CB_002
...
...
@@ -1430,8 +1431,9 @@ export default function Window() {
try {
tempWnd.loadContent(null, storage, async (err) => {
if (err && err.code) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(err)}`)
try {
expect(err.code
=== 401).assertTrue(
);
expect(err.code
).assertEqual(401
);
} catch (error) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`)
}
...
...
@@ -1443,8 +1445,9 @@ export default function Window() {
}
})
} catch (err) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(err)}`);
try {
expect(err.code
=== 401).assertTrue(
);
expect(err.code
).assertEqual(401
);
} catch (error) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`)
}
...
...
@@ -1461,12 +1464,18 @@ export default function Window() {
* @tc.level : Level 2
*/
it('testGetUIContext001', 0, async function (done) {
let tempWnd = await windowStage.getMainWindow();
expect(!!tempWnd).assertTrue();
let UIContext = tempWnd.getUIContext();
expect(UIContext != undefined).assertTrue();
console.info('testGetUIContext001 Succeeded');
done();
try {
let tempWnd = await windowStage.getMainWindow();
expect(!!tempWnd).assertTrue();
let UIContext = tempWnd.getUIContext();
expect(UIContext != undefined).assertTrue();
console.info('testGetUIContext001 Succeeded');
done();
} catch (err) {
console.info('testGetUIContext001 fail ' + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : TEST_SETUICONTENT_PROMISE_001
...
...
@@ -1518,14 +1527,22 @@ export default function Window() {
await win.destroyWindow();
done();
}).catch(async (err) => {
console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
console.error('Failed to load the content. Cause1: ' + JSON.stringify(err));
try {
expect(err.code).assertEqual(401);
} catch (err) {
console.error('Failed to load the content. Cause2: ' + JSON.stringify(err));
}
await win.destroyWindow();
done()
});
} catch (exception) {
console.error('Failed to load the content. exception: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
try {
expect(exception.code).assertEqual(401);
} catch (err) {
console.error('Failed to load the content. Cause2: ' + JSON.stringify(err));
}
await win.destroyWindow();
done()
}
...
...
@@ -1648,18 +1665,11 @@ export default function Window() {
let color = '#00ff33';
try {
wnd.setWindowBackgroundColor(color);
console.log('testSetWindowBackgroundColor001 success');
await sleep(2000);
done();
try {
let properties = wnd.getWindowProperties();
expect(!properties.isTransparent).assertTrue();
done()
} catch (exception) {
console.error('Failed to obtain the window properties001. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
}
} catch (exception) {
console.error('Failed to set the background1 color. Cause: ' + JSON.stringify(exception));
} catch (err) {
console.error('Failed to set the background1 color. Cause: ' + JSON.stringify(err));
expect().assertFail();
done();
}
...
...
@@ -1679,16 +1689,9 @@ export default function Window() {
let color = '#ffffff00';
try {
wnd.setWindowBackgroundColor(color);
console.log('testSetWindowBackgroundColor002 success');
await sleep(2000);
done();
try {
let properties = wnd.getWindowProperties();
expect(!properties.isTransparent).assertTrue();
done()
} catch (exception) {
console.error('Failed to obtain the window properties002. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
}
} catch (exception) {
console.error('Failed to set the background2 color. Cause: ' + JSON.stringify(exception));
expect().assertFail();
...
...
@@ -1710,16 +1713,11 @@ export default function Window() {
let color = '#00ffff00';
try {
wnd.setWindowBackgroundColor(color);
console.log('testSetWindowBackgroundColor003 success');
await sleep(2000);
wnd.setWindowBackgroundColor('#ffffff');
await sleep(2000);
done();
try {
let properties = wnd.getWindowProperties();
expect(properties.isTransparent).assertTrue();
done()
} catch (exception) {
console.error('Failed to obtain the window properties003. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
}
} catch (exception) {
console.error('Failed to set the background3 color. Cause: ' + JSON.stringify(exception));
expect().assertFail();
...
...
@@ -1741,6 +1739,8 @@ export default function Window() {
let color = '#ff00';
try {
wnd.setWindowBackgroundColor(color);
console.log('testSetWindowBackgroundColor004 fail');
expect().assertFail();
done();
} catch (exception) {
console.error('Failed to set the background4 color. Cause: ' + JSON.stringify(exception));
...
...
@@ -1763,18 +1763,12 @@ export default function Window() {
let color = '#hhgghhgg';
try {
wnd.setWindowBackgroundColor(color);
try {
let properties = wnd.getWindowProperties();
expect(!properties.isTransparent).assertTrue();
done()
} catch (exception) {
console.error('Failed to obtain the window properties005. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
}
} catch (exception) {
console.error('Failed to set the background5 color. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
console.log('testSetWindowBackgroundColor005 fail');
expect().assertFail();
done();
} catch (err) {
console.error('Failed to set the background5 color. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done()
}
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录