提交 01c9be2e 编写于 作者: 1 15829070344

【时间时区】setTime异常值处理

Signed-off-by: N15829070344 <hehaitao5@huawei.com>
Change-Id: I7b10522b80691bd63cd117f8ef3ea1799c9c9423
上级 3bd23b21
......@@ -19,7 +19,7 @@ import systemTime from "@ohos.systemTime";
export default function systemTimeJsunit() {
describe('systemTimeTest', function () {
console.info('--------------------systemTimeTest start-----------------------');
console.info('====>---------------systemTimeTest start-----------------------');
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
......@@ -29,7 +29,7 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getCurrentTime_JS_API_0001", 0, async function (done) {
console.info("---------------UB_systemTime_getCurrentTime_JS_API_0001 start----------------");
console.info("====>----------UB_systemTime_getCurrentTime_JS_API_0001 start----------------");
systemTime.getCurrentTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
......@@ -39,7 +39,7 @@ export default function systemTimeJsunit() {
expect(data != null).assertEqual(true);
});
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
done();
});
......@@ -52,15 +52,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getCurrentTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 start----------------");
console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 start----------------");
systemTime.getCurrentTime(true).then((data) => {
console.info(`systemTime.getCurrentTime promise success data : ` + JSON.stringify(data));
console.info(`SUB_systemTime_getCurrentTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getCurrentTime promise because ` + JSON.stringify(error));
console.error(`SUB_systemTime_getCurrentTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail()
});
console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
done();
});
......@@ -73,17 +73,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0001", 0, async function (done) {
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------");
console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------");
systemTime.getRealActiveTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error));
console.error(`SUB_systemTime_getRealActiveTime_JS_API_0001 err: ` + JSON.stringify(error));
expect().assertFail()
};
console.info(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
console.info(`SUB_systemTime_getRealActiveTime_JS_API_0001 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
done();
});
......@@ -96,15 +96,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------");
console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------");
systemTime.getRealActiveTime(true).then((data) => {
onsole.log(`systemTime.getRealActiveTime promise success data : ` + JSON.stringify(data));
onsole.log(`SUB_systemTime_getRealActiveTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getRealActiveTime promise because ` + JSON.stringify(error));
console.error(`SUB_systemTime_getRealActiveTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail()
});
console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
done();
});
......@@ -117,17 +117,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealTime_JS_API_0001", 0, async function (done) {
console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 start----------------");
console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 start----------------");
systemTime.getRealTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
console.error(`SUB_systemTime_getRealTime_JS_API_0001 err: ` + JSON.stringify(error));
expect().assertFail()
};
console.info(`systemTime.getRealTime success data : ` + JSON.stringify(data));
console.info(`SUB_systemTime_getRealTime_JS_API_0001 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
done();
});
......@@ -140,15 +140,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getRealTime_JS_API_0002 start----------------");
console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 start----------------");
systemTime.getRealTime(true).then((data) => {
console.info(`systemTime.getRealTime promise success data : ` + JSON.stringify(data));
console.info(`SUB_systemTime_getRealTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getRealTime promise because ` + JSON.stringify(error));
console.error(`SUB_systemTime_getRealTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail();
});
console.info("----------SUB_systemTime_getRealTime_JS_API_0002 end------------");
console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 end------------");
done();
});
......@@ -161,17 +161,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0100 start");
systemTime.setTime(1526003846000)
.then(data =>{
console.info("setTime ===data " + data);
expect(data).assertEqual(true)
}).catch(error => {
console.info("setTime ===error " + error);
expect(0).assertLarger(1)
});
console.info('SUB_systemTime_setTime_JS_API_0100 end');
console.info("====>SUB_systemTime_setTime_JS_API_0100 start");
let currentTime = new Date().getTime() + 2000
try{
await systemTime.setTime(currentTime)
expect(true).assertTrue();
done();
}catch(err){
console.info("====>SUB_systemTime_setTime_JS_API_0100 error " + err);
expect().assertFail();
done();
}
});
/**
......@@ -183,17 +183,23 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0200 start");
systemTime.setTime(15222)
.then(data => {
console.info("setTime ===data " + data);
console.info("====>SUB_systemTime_setTime_JS_API_0200 start");
try{
systemTime.setTime(15222).then(() => {
console.debug('SUB_systemTime_setTime_JS_API_0200 setTime fail')
expect().assertFail();
done();
}).catch((err)=>{
console.debug('SUB_systemTime_setTime_JS_API_0200 setTime err:' + JSON.stringify(err))
expect(true).assertTrue();
}).catch(error => {
console.info("setTime ===error " + error);
expect(0).assertLarger(1)
});
console.info('SUB_systemTime_setTime_JS_API_0200 end');
console.debug('SUB_systemTime_setTime_JS_API_0200 end');
done();
})
}catch(err){
console.debug('SUB_systemTime_setTime_JS_API_0200 setTime throw_err' + JSON.stringify(err))
expect(err.code).assertEqual('401');
done();
}
});
/**
......@@ -205,18 +211,19 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0300 start");
systemTime.setTime(1597156246000, (err, data) => {
if (err) {
console.info("setTime ===error: " + err);
expect().assertFail()
}else{
console.info("setTime ===data: " + data);
console.info("====>SUB_systemTime_setTime_JS_API_0300 start");
let currentTime = new Date().getTime() + 2000
systemTime.setTime(currentTime, (err) => {
try{
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);
expect().assertFail();
done();
}
});
});
/**
......@@ -228,11 +235,11 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0400', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0400 start");
console.info("====>SUB_systemTime_setTime_JS_API_0400 start");
try{
systemTime.setTime(18, (err, data) => {
console.info("setTime ===data: " + data);
console.info("setTime ===error: " + err);
console.info("====>SUB_systemTime_setTime_JS_API_0400 data: " + data);
console.info("====>SUB_systemTime_setTime_JS_API_0400 error: " + err);
expect(true).assertTrue();
})}catch(error) {error => {
expect(1).assertLarger(0);
......@@ -251,13 +258,13 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0100 start");
console.info("====>SUB_systemTime_setDate_JS_API_0100 start");
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(1).then(data => {
console.info("setTime ===data " + data);
console.info("====>SUB_systemTime_setDate_JS_API_0100 data " + data);
expect(true).assertTrue();
}).catch(error => {
console.info("setTime ===error " + error);
console.info("====>SUB_systemTime_setDate_JS_API_0100 error " + error);
expect().assertFail();
});
done();
......@@ -272,12 +279,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0200 start");
console.info("====>SUB_systemTime_setDate_JS_API_0200 start");
systemTime.setDate(0).then(data => {
console.info("setTime ===data " + data);
console.info("====>SUB_systemTime_setDate_JS_API_0200 data " + data);
expect(true).assertTrue();
}).catch(error => {
console.info("setTime ===error " + error);
console.info("====>SUB_systemTime_setDate_JS_API_0200 error " + error);
expect().assertFail();
});
done();
......@@ -292,14 +299,14 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0300 start");
console.info("====>SUB_systemTime_setDate_JS_API_0300 start");
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data, (error, data) => {
if(error){
console.info("setTime ===error " + error);
console.info("====>SUB_systemTime_setDate_JS_API_0300 error " + error);
expect().assertFail();
}else{
console.info("setTime ===data " + data);
console.info("====>SUB_systemTime_setDate_JS_API_0300 data " + data);
expect(true).assertTrue();
};
});
......@@ -315,12 +322,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0100 start");
console.info("====>SUB_systemTime_setTimezone_JS_API_0100 start");
systemTime.setTimezone('Asia, Shanghai').then(data => {
console.info("setTime ===data " + data);
console.info("====>SUB_systemTime_setTimezone_JS_API_0100 data " + data);
expect().assertFail();
}).catch(error => {
console.info("setTime ===error " + error);
console.info("====>SUB_systemTime_setTimezone_JS_API_0100 error " + error);
expect(true).assertTrue();
});
done();
......@@ -335,12 +342,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0200 start");
console.info("====>SUB_systemTime_setTimezone_JS_API_0200 start");
systemTime.setTimezone('Beijing,China').then(data => {
console.info("setTime ===data " + data);
console.info("====>SUB_systemTime_setTimezone_JS_API_0200 data " + data);
expect().assertFail();
}).catch(error => {
console.info("setTime ===error " + error);
console.info("====>SUB_systemTime_setTimezone_JS_API_0200 error " + error);
expect(true).assertTrue();
});
done();
......@@ -355,12 +362,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0300 start");
console.info("====>SUB_systemTime_setTimezone_JS_API_0300 start");
systemTime.setTimezone('Baker Island, U.S.A.').then(data => {
console.info("setTime ===data " + data);
console.info("====>SUB_systemTime_setTimezone_JS_API_0300 data " + data);
expect().assertFail();
}).catch(error => {
console.info("setTime ===error " + error);
console.info("====>SUB_systemTime_setTimezone_JS_API_0300 error " + error);
expect(true).assertTrue();
});
done();
......
......@@ -19,7 +19,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export default function systemTimerTest() {
describe('systemTimerTest', function () {
console.info('systemTimer Test start');
console.info('====>systemTimer Test start');
//wantAgent对象
var wantAgent;
......@@ -43,11 +43,11 @@ export default function systemTimerTest() {
* beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.
*/
beforeAll(function () {
console.info('beforeAll: Prerequisites are executed.');
console.info('====>beforeAll: Prerequisites are executed.');
WantAgent.getWantAgent(wantAgentInfo)
.then((data) => {
if ( data != undefined || data != null) {
console.info('beforeAll: success to get wantAgent: ' + typeof(data));
console.info('====>beforeAll: success to get wantAgent: ' + typeof(data));
wantAgent = data;
}
})
......@@ -60,21 +60,21 @@ export default function systemTimerTest() {
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/
beforeEach(function () {
console.info('beforeEach: Prerequisites is executed.');
console.info('====>beforeEach: Prerequisites is executed.');
});
/**
* afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
*/
afterEach(function () {
console.info('afterEach: Test case-level clearance conditions is executed.');
console.info('====>afterEach: Test case-level clearance conditions is executed.');
});
/**
* afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed.
*/
afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition is executed.');
console.info('====>afterAll: Test suite-level cleanup condition is executed.');
});
/**
......@@ -86,27 +86,27 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0000', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0000 start.');
console.info('====>SUB_time_systemTimer_createTimer_0000 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
console.info('SUB_time_systemTimer_createTimer_0000 create timer.');
console.info('====>SUB_time_systemTimer_createTimer_0000 create timer.');
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
// 处理业务逻辑错误
expect().assertTrue();
done();
}
console.info('SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID);
console.info('====>SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID);
globalTimerID = timerID;
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_createTimer_0000 has failed for ' + err);
console.info('====>SUB_time_systemTimer_createTimer_0000 has failed for ' + err);
expect().assertTrue();
done();
};
......@@ -121,7 +121,7 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0001', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0001 start.');
console.info('====>SUB_time_systemTimer_createTimer_0001 start.');
let options = {
type: systemTimer.TIMER_TYPE_IDLE,
repeat: false
......@@ -129,16 +129,16 @@ export default function systemTimerTest() {
try {
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
console.info('SUB_time_systemTimer_createTimer_0001 wrong since ' + err.code);
console.info('====>SUB_time_systemTimer_createTimer_0001 wrong since ' + err.code);
expect().assertTrue();
done();
};
console.info('SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID);
console.info('====>SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0001 arv wrong since ' + e.code);
console.info('====>SUB_time_systemTimer_createTimer_0001 arv wrong since ' + e.code);
expect().assertTrue();
done();
};
......@@ -153,9 +153,9 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0002', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0002 start");
console.info("====>SUB_time_systemTimer_createTimer_0002 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info('SUB_time_systemTimer_createTimer_0002 BundleName: ' + data);
console.info('====>SUB_time_systemTimer_createTimer_0002 BundleName: ' + data);
})
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
......@@ -164,19 +164,19 @@ export default function systemTimerTest() {
interval: interval_time
};
try {
console.info("SUB_time_systemTimer_createTimer_0002 create timer")
console.info("====>SUB_time_systemTimer_createTimer_0002 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
console.info('SUB_time_systemTimer_createTimer_0002 wrong since ' + err.code);
console.info('====>SUB_time_systemTimer_createTimer_0002 wrong since ' + err.code);
expect().assertTrue();
done();
}
console.info('SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID);
console.info('====>SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
console.info('====>SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
expect().assertTrue();
done();
};
......@@ -191,16 +191,16 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0003', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0003 start");
console.info("====>SUB_time_systemTimer_createTimer_0003 start");
let options = {
type: systemTimer.TIMER_TYPE_EXACT,
repeat: false
};
try {
console.info("SUB_time_systemTimer_createTimer_0003 create timer")
console.info("====>SUB_time_systemTimer_createTimer_0003 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
console.info('SUB_time_systemTimer_createTimer_0003 wrong since ' + err.code);
console.info('====>SUB_time_systemTimer_createTimer_0003 wrong since ' + err.code);
expect().assertTrue();
done();
}
......@@ -208,7 +208,7 @@ export default function systemTimerTest() {
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
console.info('====>SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
expect().assertTrue();
done();
};
......@@ -223,9 +223,9 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0004', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0004 start");
console.info("====>SUB_time_systemTimer_createTimer_0004 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info("SUB_time_systemTimer_createTimer_0004 BundleName: " + data);
console.info("====>SUB_time_systemTimer_createTimer_0004 BundleName: " + data);
});
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
......@@ -234,7 +234,7 @@ export default function systemTimerTest() {
interval: interval_time
};
try {
console.info("SUB_time_systemTimer_createTimer_0004 create timer")
console.info("====>SUB_time_systemTimer_createTimer_0004 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
expect().assertTrue();
......@@ -244,7 +244,7 @@ export default function systemTimerTest() {
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0004 has failed for ' + e);
console.info('====>SUB_time_systemTimer_createTimer_0004 has failed for ' + e);
expect().assertTrue();
done();
};
......@@ -260,24 +260,24 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0005', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0005 start.');
console.info('====>SUB_time_systemTimer_createTimer_0005 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
console.info('SUB_time_systemTimer_createTimer_0005 create timer.');
console.info('====>SUB_time_systemTimer_createTimer_0005 create timer.');
systemTimer.createTimer(options).then((timerID) =>{
console.info('SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID);
console.info('====>SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0005 promise failed ' + err);
console.info('====>SUB_time_systemTimer_createTimer_0005 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (err) {
console.info('SUB_time_systemTimer_createTimer_0005 has failed for ' + err);
console.info('====>SUB_time_systemTimer_createTimer_0005 has failed for ' + err);
expect().assertTrue();
done();
};
......@@ -292,23 +292,23 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0006 start.');
console.info('====>SUB_time_systemTimer_createTimer_0006 start.');
let options = {
type: systemTimer.TIMER_TYPE_IDLE,
repeat: false
};
try {
systemTimer.createTimer(options).then((timerID) => {
console.info('SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID);
console.info('====>SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0006 promise failed ' + err);
console.info('====>SUB_time_systemTimer_createTimer_0006 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0006 arv wrong since ' + e.code);
console.info('====>SUB_time_systemTimer_createTimer_0006 arv wrong since ' + e.code);
expect().assertTrue();
done();
};
......@@ -323,9 +323,9 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0007', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0007 start");
console.info("====>SUB_time_systemTimer_createTimer_0007 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info('SUB_time_systemTimer_createTimer_0007 BundleName: ' + data);
console.info('====>SUB_time_systemTimer_createTimer_0007 BundleName: ' + data);
})
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
......@@ -334,18 +334,18 @@ export default function systemTimerTest() {
interval: interval_time
};
try {
console.info("SUB_time_systemTimer_createTimer_0007 create timer");
console.info("====>SUB_time_systemTimer_createTimer_0007 create timer");
systemTimer.createTimer(options).then((timerID) => {
console.info('SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID);
console.info('====>SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0007 promise failed ' + err);
console.info('====>SUB_time_systemTimer_createTimer_0007 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0007 arv wrong since ' + e);
console.info('====>SUB_time_systemTimer_createTimer_0007 arv wrong since ' + e);
expect().assertTrue();
done();
};
......@@ -360,23 +360,23 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0008', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0008 start");
console.info("====>SUB_time_systemTimer_createTimer_0008 start");
let options = {
type: systemTimer.TIMER_TYPE_EXACT,
repeat: false
};
try {
console.info("SUB_time_systemTimer_createTimer_0008 create timer")
console.info("====>SUB_time_systemTimer_createTimer_0008 create timer")
systemTimer.createTimer(options).then((timerID) => {
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0008 promise failed ' + err);
console.info('====>SUB_time_systemTimer_createTimer_0008 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0008 arv wrong since ' + e);
console.info('====>SUB_time_systemTimer_createTimer_0008 arv wrong since ' + e);
expect().assertTrue();
done();
};
......@@ -391,9 +391,9 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0009', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0009 start");
console.info("====>SUB_time_systemTimer_createTimer_0009 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info("SUB_time_systemTimer_createTimer_0009 BundleName: " + data);
console.info("====>SUB_time_systemTimer_createTimer_0009 BundleName: " + data);
});
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
......@@ -402,17 +402,17 @@ export default function systemTimerTest() {
interval: interval_time
};
try {
console.info("SUB_time_systemTimer_createTimer_0009 create timer")
console.info("====>SUB_time_systemTimer_createTimer_0009 create timer")
systemTimer.createTimer(options).then((timerID) => {
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0009 promise failed ' + err);
console.info('====>SUB_time_systemTimer_createTimer_0009 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0009 has failed for ' + e);
console.info('====>SUB_time_systemTimer_createTimer_0009 has failed for ' + e);
expect().assertTrue();
done();
};
......@@ -427,21 +427,21 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_startTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_startTimer_0001 start");
console.info("====>SUB_time_systemTimer_startTimer_0001 start");
try {
console.info("SUB_time_systemTimer_startTimer_0001 start timer, timerID: " + globalTimerID)
console.info("====>SUB_time_systemTimer_startTimer_0001 start timer, timerID: " + globalTimerID)
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(globalTimerID, triggerTime, function (err, data) {
if (err) {
console.info('SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code);
console.info('====>SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code);
expect().assertTrue();
done();
}
console.info("SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID);
console.info("====>SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID);
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_startTimer_0001 has failed for ' + e);
console.info('====>SUB_time_systemTimer_startTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
};
......@@ -456,19 +456,19 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_stopTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_stopTimer_0001 start");
console.info("====>SUB_time_systemTimer_stopTimer_0001 start");
try {
console.info("SUB_time_systemTimer_stopTimer_0001 stop timer, timerID: " + globalTimerID)
console.info("====>SUB_time_systemTimer_stopTimer_0001 stop timer, timerID: " + globalTimerID)
systemTimer.stopTimer(globalTimerID, function (err, data) {
if (err) {
expect().assertTrue();
done();
};
console.info("SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID);
console.info("====>SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID);
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_stopTimer_0001 has failed for ' + e);
console.info('====>SUB_time_systemTimer_stopTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
};
......@@ -483,19 +483,19 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_destroyTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_destroyTimer_0001 start");
console.info("====>SUB_time_systemTimer_destroyTimer_0001 start");
try {
console.info("SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID)
console.info("====>SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID)
systemTimer.destroyTimer(globalTimerID, function (err, data) {
if (err) {
expect().assertTrue();
done();
};
console.info("SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID);
console.info("====>SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID);
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e);
console.info('====>SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
};
......@@ -510,27 +510,27 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0002 start.');
console.info('====>SUB_time_systemTimer_createTimer_0002 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
console.info('SUB_time_systemTimer_createTimer_0002 create timer.');
console.info('====>SUB_time_systemTimer_createTimer_0002 create timer.');
systemTimer.createTimer(options).then((timerID)=>{
console.info('SUB_time_systemTimer_createTimer_0002 timerID:' + timerID);
console.info('====>SUB_time_systemTimer_createTimer_0002 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
globalTimerID = timerID;
done();
}).catch( error => {
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_createTimer_0002 failed to create timer.');
console.info('====>SUB_time_systemTimer_createTimer_0002 failed to create timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_createTimer_0002 has failed for ' + err);
console.info('====>SUB_time_systemTimer_createTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
};
......@@ -545,23 +545,23 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_startTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_startTimer_0002 start.');
console.info('====>SUB_time_systemTimer_startTimer_0002 start.');
try {
console.info('SUB_time_systemTimer_startTimer_0002 start timer, timerID: ' + globalTimerID);
console.info('====>SUB_time_systemTimer_startTimer_0002 start timer, timerID: ' + globalTimerID);
let triggerTime = new Date().getTime() + interval_time * 2;
systemTimer.startTimer(globalTimerID, triggerTime)
.then(()=>{
console.info('SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID);
console.info('====>SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID);
done();
}).catch(()=>{
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_startTimer_0002 failed to start timer.');
console.info('====>SUB_time_systemTimer_startTimer_0002 failed to start timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_startTimer_0002 has failed for ' + err);
console.info('====>SUB_time_systemTimer_startTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
}
......@@ -576,22 +576,22 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_stopTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_stopTimer_0002 start.');
console.info('====>SUB_time_systemTimer_stopTimer_0002 start.');
try {
console.info('SUB_time_systemTimer_stopTimer_0002 stop timer, timerID: ' + globalTimerID);
console.info('====>SUB_time_systemTimer_stopTimer_0002 stop timer, timerID: ' + globalTimerID);
systemTimer.stopTimer(globalTimerID)
.then(()=>{
console.info('SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID);
console.info('====>SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID);
done();
}).catch(()=>{
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_stopTimer_0002 failed to stop timer.');
console.info('====>SUB_time_systemTimer_stopTimer_0002 failed to stop timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
console.info('====>SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
};
......@@ -606,22 +606,22 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_destroyTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_destroyTimer_0002 start.');
console.info('====>SUB_time_systemTimer_destroyTimer_0002 start.');
try {
console.info('SUB_time_systemTimer_destroyTimer_0002 destroy timer, timerID: ' + globalTimerID);
console.info('====>SUB_time_systemTimer_destroyTimer_0002 destroy timer, timerID: ' + globalTimerID);
systemTimer.destroyTimer(globalTimerID)
.then(()=>{
console.info('SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID);
console.info('====>SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID);
done();
}).catch(()=>{
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer.');
console.info('====>SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
console.info('====>SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
};
......@@ -636,65 +636,65 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_ALL_Promise_0008', 0, async function (done) {
console.info('SUB_time_systemTimer_ALL_Promise_0008 start.');
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
console.info('SUB_time_systemTimer_ALL_Promise_0008 create timer.');
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 create timer.');
systemTimer.createTimer(options)
.then((timerID)=>{
console.info('SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID);
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
try {
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(timerID, triggerTime)
.then(()=>{
console.info('SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID);
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID);
try {
systemTimer.stopTimer(timerID)
.then(()=>{
systemTimer.destroyTimer(timerID, function (err, data) {
console.info('SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID);
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID);
done();
});
})
.catch(()=>{
// 捕获stopTimer业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
expect().assertTrue();
done();
})
} catch (err) {
// 捕获stopTimer参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err);
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
.catch(()=>{
// 捕获startTimer业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err);
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
.catch(()=>{
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.');
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err);
console.info('====>SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
......@@ -709,42 +709,42 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_ALL_Callback_0009', 0, async function (done) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 start.');
console.info('====>SUB_time_systemTimer_ALL_Callback_0009 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
console.info('SUB_time_systemTimer_ALL_Callback_0009 create timer.');
console.info('====>SUB_time_systemTimer_ALL_Callback_0009 create timer.');
systemTimer.createTimer(options)
.then((timerID)=>{
console.info('SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID);
console.info('====>SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
try {
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(timerID, triggerTime, ()=>{
console.info('SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID);
console.info('====>SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID);
try {
systemTimer.stopTimer(timerID, ()=>{
systemTimer.destroyTimer(timerID, function (err, data) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID);
console.info('====>SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID);
done();
});
})
} catch (err) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err);
console.info('====>SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
} catch (err) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err);
console.info('====>SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
} catch (err) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err);
console.info('====>SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册