Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
abcc6f72
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看板
提交
abcc6f72
编写于
11月 21, 2022
作者:
Z
zwx1016320
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimization time API 2
Signed-off-by:
N
zwx1016320
<
zhangyushuai1@huawei-partners.com
>
上级
63e674ec
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
736 addition
and
516 deletion
+736
-516
time/timeTest/entry/src/main/ets/test/systemTimeTest.ets
time/timeTest/entry/src/main/ets/test/systemTimeTest.ets
+486
-274
time/timeTest/entry/src/main/ets/test/systemTimer.test.ets
time/timeTest/entry/src/main/ets/test/systemTimer.test.ets
+250
-242
未找到文件。
time/timeTest/entry/src/main/ets/test/systemTimeTest.ets
浏览文件 @
abcc6f72
...
...
@@ -20,6 +20,38 @@ import systemTime from "@ohos.systemTime";
export default function systemTimeJsunit() {
describe('systemTimeTest', function () {
console.info('====>---------------systemTimeTest start-----------------------');
/**
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/
var dates;
var zone;
beforeEach(async function (done) {
let currentTime = new Date().getTime()
dates = currentTime
console.info("====>beforeEach data " + dates);
systemTime.getTimezone().then( data => {
console.info("====>beforeEach data " + data);
zone = data
done()
}).catch(error => {
console.info("====>beforeEach error " + error);
});
});
/**
* afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
*/
afterEach(async function (done) {
systemTime.setTimezone(zone).then( data => {
console.info("====>afterEach zone " + zone);
done()
}).catch(error => {
console.info("====>afterEach error " + error);
});
});
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
...
...
@@ -31,14 +63,20 @@ export default function systemTimeJsunit() {
it("SUB_systemTime_getCurrentTime_JS_API_0001", 0, async function (done) {
console.info("====>----------UB_systemTime_getCurrentTime_JS_API_0001 start----------------");
systemTime.getCurrentTime(true, (error, data) => {
try {
if (error) {
console.error('failed to systemTime.getCurrentTime because
' + JSON.stringify(error));
console.error('====>UB_systemTime_getCurrentTime_JS_API_0001 fail:
' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info('====>SystemTime.getCurrentTime success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
done();
} catch (error) {
console.error('====>UB_systemTime_getCurrentTime_JS_API_0001 catch error: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
});
});
...
...
@@ -52,16 +90,16 @@ export default function systemTimeJsunit() {
*/
it("SUB_systemTime_getCurrentTime_JS_API_0002", 0, async function (done) {
console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 start----------------");
systemTime.getCurrentTime(tru
e).then((data) => {
console.info('====>SUB_systemTime_getCurrentTime_JS_API_0002
data : ' + JSON.stringify(data));
await systemTime.getCurrentTime(fals
e).then((data) => {
console.info('====>SUB_systemTime_getCurrentTime_JS_API_0002 success
data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
done();
}).catch(err => {
console.error('SUB_systemTime_getCurrentTime_JS_API_0002 err: ' + JSON.stringify(erro
r));
console.error('====>SUB_systemTime_getCurrentTime_JS_API_0002 fail: ' + JSON.stringify(er
r));
expect().assertFail()
done();
});
console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
});
/**
...
...
@@ -75,14 +113,20 @@ export default function systemTimeJsunit() {
it("SUB_systemTime_getRealActiveTime_JS_API_0001", 0, async function (done) {
console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------");
systemTime.getRealActiveTime(true, (error, data) => {
try {
if (error) {
console.error('SUB_systemTime_getRealActiveTime_JS_API_0001 err
: ' + JSON.stringify(error));
console.error('====>SUB_systemTime_getRealActiveTime_JS_API_0001 fail
: ' + JSON.stringify(error));
expect().assertFail()
done();
};
console.info('====>SUB_systemTime_getRealActiveTime_JS_API_0001
data : ' + JSON.stringify(data));
console.info('====>SUB_systemTime_getRealActiveTime_JS_API_0001 success
data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
done();
} catch (error) {
console.error('====>SUB_systemTime_getRealActiveTime_JS_API_0001 catch err: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
});
});
...
...
@@ -96,16 +140,16 @@ export default function systemTimeJsunit() {
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0002", 0, async function (done) {
console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------");
systemTime.getRealActiveTime(tru
e).then((data) => {
console.log('SUB_systemTime_getRealActiveTime_JS_API_0002
data : ' + JSON.stringify(data));
await systemTime.getRealActiveTime(fals
e).then((data) => {
console.log('SUB_systemTime_getRealActiveTime_JS_API_0002 success
data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
done();
}).catch(err => {
console.error('SUB_systemTime_getRealActiveTime_JS_API_0002 err: ' + JSON.stringify(erro
r));
console.error('====>SUB_systemTime_getRealActiveTime_JS_API_0002 err: ' + JSON.stringify(er
r));
expect().assertFail()
done();
});
console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
});
/**
...
...
@@ -119,16 +163,21 @@ export default function systemTimeJsunit() {
it("SUB_systemTime_getRealTime_JS_API_0001", 0, async function (done) {
console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 start----------------");
systemTime.getRealTime(true, (error, data) => {
try {
if (error) {
console.error('SUB_systemTime_getRealTime_JS_API_0001 err: ' + JSON.stringify(error));
expect().assertFail()
console.error('SUB_systemTime_getRealTime_JS_API_0001 fail: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info('====>SUB_systemTime_getRealTime_JS_API_0001
data : ' + JSON.stringify(data));
console.info('====>SUB_systemTime_getRealTime_JS_API_0001 success
data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
done();
} catch (error) {
console.error('====>SUB_systemTime_getRealTime_JS_API_0001 catch err: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
});
});
/**
...
...
@@ -141,15 +190,16 @@ export default function systemTimeJsunit() {
*/
it("SUB_systemTime_getRealTime_JS_API_0002", 0, async function (done) {
console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 start----------------");
systemTime.getRealTime(tru
e).then((data) => {
console.info('====>SUB_systemTime_getRealTime_JS_API_0002
data : ' + JSON.stringify(data));
await systemTime.getRealTime(fals
e).then((data) => {
console.info('====>SUB_systemTime_getRealTime_JS_API_0002 success
data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error('SUB_systemTime_getRealTime_JS_API_0002 err: ' + JSON.stringify(error));
done();
}).catch(error => {
console.error('====>SUB_systemTime_getRealTime_JS_API_0002 err: ' + JSON.stringify(error));
expect().assertFail();
done();
});
console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 end------------");
done();
});
/**
...
...
@@ -163,16 +213,23 @@ export default function systemTimeJsunit() {
it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) {
console.info("====>SUB_systemTime_setTime_JS_API_0100 start");
let currentTime = new Date().getTime() + 2000
systemTime.setTime(currentTime, (err, data) => {
try{
await systemTime.setTime(currentTime)
if(err){
console.info("====>SUB_systemTime_setTime_JS_API_0100 setTime fail: " + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('====>SUB_systemTime_setTime_JS_API_0100 success: ' + data);
expect(true).assertTrue();
done();
}catch(err){
console.info("====>SUB_systemTime_setTime_JS_API_0100 error " + err);
expect().assertFail();
console.info("====>SUB_systemTime_setTime_JS_API_0100 catch error: " + JSON.stringify(err));
done();
}
});
console.info("====>SUB_systemTime_setTime_JS_API_0100 end");
});
/**
* @tc.number SUB_systemTime_setTime_JS_API_0200
...
...
@@ -213,17 +270,16 @@ export default function systemTimeJsunit() {
it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) {
console.info("====>SUB_systemTime_setTime_JS_API_0300 start");
let currentTime = new Date().getTime() + 2000
systemTime.setTime(currentTime, (err
) => {
try{
await systemTime.setTime(currentTime).then((
) => {
console.info('====>SUB_systemTime_setTime_JS_API_0300 success')
expect(true).assertTrue();
console.info('====>SUB_systemTime_setTime_JS_API_0300 end');
done();
}catch(err)
{
console.info("====>SUB_systemTime_setTime_JS_API_0300 error: " + err);
}).catch((err)=>
{
console.debug('====>SUB_systemTime_setTime_JS_API_0300 setTime fail:' + JSON.stringify(err))
expect().assertFail();
done();
}
}
);
})
console.info("====>SUB_systemTime_setTime_JS_API_0300 end"
);
});
/**
...
...
@@ -240,8 +296,8 @@ export default function systemTimeJsunit() {
systemTime.setTime(18, (err, data) => {
console.info("====>SUB_systemTime_setTime_JS_API_0400 data: " + data);
console.info("====>SUB_systemTime_setTime_JS_API_0400 error: " + err);
expect(true).assertTrue();
console.info('====>SUB_systemTime_setTime_JS_API_0400 end');
expect(true).assertTrue();
done();
})
}catch(err) {
...
...
@@ -260,8 +316,8 @@ export default function systemTimeJsunit() {
*/
it('SUB_systemTime_setDate_JS_API_0100', 0, async function (done) {
console.info("====>SUB_systemTime_setDate_JS_API_0100 start");
var
data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(1
).then(data => {
let
data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data
).then(data => {
console.info("====>SUB_systemTime_setDate_JS_API_0100 data " + data);
expect().assertFail();
done();
...
...
@@ -303,8 +359,9 @@ export default function systemTimeJsunit() {
*/
it('SUB_systemTime_setDate_JS_API_0300', 0, async function (done) {
console.info("====>SUB_systemTime_setDate_JS_API_0300 start");
var
data = new Date("October 13, 2020 11:13:00");
let
data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data, (error, data) => {
try {
if(error){
console.info("====>SUB_systemTime_setDate_JS_API_0300 error " + error);
expect(true).assertTrue();
...
...
@@ -313,7 +370,82 @@ export default function systemTimeJsunit() {
console.info("====>SUB_systemTime_setDate_JS_API_0300 data " + data);
expect().assertFail();
done();
};
}
} catch (error) {
console.info("====>SUB_systemTime_setDate_JS_API_0300 catch error " + error);
done();
}
});
});
/**
* @tc.number SUB_systemTime_setDate_JS_API_0400
* @tc.name Test systemTime.setDate true value
* @tc.desc Test systemTime_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0400', 0, async function (done) {
console.info("====>SUB_systemTime_setDate_JS_API_0400 start");
let data = new Date("Tue Oct 13 2020 11:13:00 GMT+0800");
systemTime.setDate(data, (error, data) => {
try {
if(error){
console.info("====>SUB_systemTime_setDate_JS_API_0400 setDate fail: " + JSON.stringify(error));
expect().assertFail();
done();
}
systemTime.getDate().then(async (data) => {
try {
console.info("====>SUB_systemTime_setDate_JS_API_0400 getDate: " + data);
console.info("====>SUB_systemTime_setDate_JS_API_0400 setTime: " + dates);
console.info("====>SUB_systemTime_setDate_JS_API_0400 getDate: " + JSON.stringify(data).slice(1,17));
expect(JSON.stringify(data).slice(1,17) == '2020-10-13T03:13').assertTrue();
await systemTime.setTime(dates + 1000)
done();
} catch (err) {
console.info("====>SUB_systemTime_setDate_JS_API_0400 catch err: " + err);
done();
}
})
} catch (err) {
console.info("====>SUB_systemTime_setDate_JS_API_0400 catch error " + JSON.stringify(err));
done();
}
});
});
/**
* @tc.number SUB_systemTime_setDate_JS_API_0500
* @tc.name Test systemTime.setDate true value
* @tc.desc Test systemTime_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0500', 0, async function (done) {
console.info("====>SUB_systemTime_setDate_JS_API_0500 start");
let data = new Date("Tue Oct 13 2020 11:13:00 GMT+0800");
await systemTime.setDate(data).then( () => {
console.info("====>SUB_systemTime_setDate_JS_API_0500 successful ");
systemTime.getDate().then(async data => {
try {
console.info("====>SUB_systemTime_setDate_JS_API_0500 getDate: " + data);
console.info("====>SUB_systemTime_setDate_JS_API_0500 setTime: " + dates);
console.info("====>SUB_systemTime_setDate_JS_API_0500 getDate: " + JSON.stringify(data).slice(1,17));
expect(JSON.stringify(data).slice(1,17) == '2020-10-13T03:13').assertTrue();
await systemTime.setTime(dates + 1000)
done();
} catch (err) {
console.info("====>SUB_systemTime_setDate_JS_API_0500 catch err: " + err);
done();
}
})
}).catch(error => {
console.info("====>SUB_systemTime_setDate_JS_API_0500 setDate fail: " + JSON.stringify(error));
expect().assertFail();
done();
});
});
...
...
@@ -330,6 +462,7 @@ export default function systemTimeJsunit() {
systemTime.setTimezone('Asia, Shanghai').then(data => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0100 data " + data);
expect().assertFail();
done();
}).catch(error => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0100 error " + error);
expect(true).assertTrue();
...
...
@@ -350,6 +483,7 @@ export default function systemTimeJsunit() {
systemTime.setTimezone('Beijing,China').then(data => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0200 data " + data);
expect().assertFail();
done();
}).catch(error => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0200 error " + error);
expect(true).assertTrue();
...
...
@@ -370,11 +504,89 @@ export default function systemTimeJsunit() {
systemTime.setTimezone('Baker Island, U.S.A.').then(data => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0300 data " + data);
expect().assertFail();
done();
}).catch(error => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0300 error " + error);
expect(true).assertTrue();
done();
});
});
/**
* @tc.number SUB_systemTime_setTimezone_JS_API_0400
* @tc.name Test systemTime.setTimezone true value
* @tc.desc Test systemTime_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0400', 0, function (done) {
console.info("====>SUB_systemTime_setTimezone_JS_API_0400 start");
systemTime.setTimezone('Asia/Jakarta',async (err) => {
try{
if(err){
console.info("====>SUB_systemTime_setTimezone_JS_API_0400 setTimezone fail: " + JSON.stringify(err));
expect().assertFail();
done();
}
console.info("====>SUB_systemTime_setTimezone_JS_API_0400 success ");
systemTime.getTimezone().then( data => {
try {
console.info("====>SUB_systemTime_setTimezone_JS_API_0400 getTimezone " + data);
expect(data == 'Asia/Jakarta').assertTrue();
done();
} catch (error) {
console.info("====>SUB_systemTime_setTimezone_JS_API_0400 getTimezone catch error " + error);
done();
}
}).catch(error => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0400 error " + error);
done();
});
}catch(err){
console.info("====>SUB_systemTime_setTimezone_JS_API_0400 error " + err);
done();
}
})
}
});
/**
* @tc.number SUB_systemTime_setTimezone_JS_API_0500
* @tc.name Test systemTime.setTimezone true value
* @tc.desc Test systemTime_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0500', 0, async function (done) {
console.info("====>SUB_systemTime_setTimezone_JS_API_0500 start");
try{
await systemTime.setTimezone('Europe/Moscow').then(() => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0500 promise successful " );
systemTime.getTimezone().then( data => {
try {
console.info("====>SUB_systemTime_setTimezone_JS_API_0500 getTimezone " + data);
expect(data == 'Europe/Moscow').assertTrue();
done();
} catch (error) {
console.info("====>SUB_systemTime_setTimezone_JS_API_0500 getTimezone catch error " + error);
done();
}
}).catch(error => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0500 error " + error);
expect().assertFail();
done();
});
}).catch(error => {
console.info("====>SUB_systemTime_setTimezone_JS_API_0500 error " + error.code);
expect().assertFail();
done();
});
}catch(err){
console.info("====>SUB_systemTime_setTimezone_JS_API_0500 catch error: " + err.code);
expect().assertFail();
done();
};
});
});
};
time/timeTest/entry/src/main/ets/test/systemTimer.test.ets
浏览文件 @
abcc6f72
此差异已折叠。
点击以展开。
鸿蒙社区
@harmonycommunity
mentioned in commit
8054e7e2
·
11月 23, 2022
mentioned in commit
8054e7e2
mentioned in commit 8054e7e20771d2fa307060bba793e0775ace6486
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录