提交 39b80d2a 编写于 作者: B buzhuyu

modify xts for taskpool.cancel

description:
modify xts for taskpool.cancel

issue:https://gitee.com/openharmony/xts_acts/issues/I69V6KSigned-off-by: Nbuzhuyu <buzhuyu@huawei.com>
上级 32f2c89c
......@@ -865,7 +865,7 @@ describe('ActsAbilityTest', function () {
* @tc.type : Function
* @tc.level : Level 0
*/
it('TaskPoolTestClass049', 0, async function (done) {
it('TaskPoolTestClass049', 0, async function (done) {
function addition(arg) {
return arg + 1;
}
......@@ -877,18 +877,18 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
taskpool.cancel(task3);
taskpool.cancel(task3);
}
catch (e) {
expect(e.toString()).assertEqual("");
expect(e.toString()).assertEqual("");
}
done();
})
......@@ -913,18 +913,18 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
taskpool.cancel(task3);
taskpool.cancel(task3);
}
catch (e) {
expect(e.toString()).assertEqual("");
expect(e.toString()).assertEqual("");
}
done();
})
......@@ -949,23 +949,24 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task1);
taskpool.cancel(task1);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not cancel the running task");
expect(e.toString()).assertEqual(
"BusinessError: The task is executing when it is canceled, taskpool:: can not cancel the running task");
}
done();
})
......@@ -990,23 +991,24 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task1);
taskpool.cancel(task1);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not cancel the running task");
expect(e.toString()).assertEqual(
"BusinessError: The task is executing when it is canceled, taskpool:: can not cancel the running task");
}
done();
})
......@@ -1024,23 +1026,24 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task1);
taskpool.cancel(task1);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not find the task");
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done();
})
......@@ -1058,29 +1061,30 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6);
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6);
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task3);
taskpool.cancel(task3);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not find the task");
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done();
})
......@@ -1098,17 +1102,18 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
taskpool.cancel(task3);
taskpool.cancel(task3);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not find the task");
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done();
})
......@@ -1126,17 +1131,18 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
taskpool.cancel(task3);
taskpool.cancel(task3);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not find the task");
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done();
})
......@@ -1161,24 +1167,25 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task3);
taskpool.cancel(task3);
taskpool.cancel(task3);
taskpool.cancel(task3);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not find the task");
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done();
})
......@@ -1203,24 +1210,25 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
var start = new Date().getTime();
while (new Date().getTime() - start < 1000) {
continue;
}
taskpool.cancel(task3);
taskpool.cancel(task3);
taskpool.cancel(task3);
taskpool.cancel(task3);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not find the task");
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done();
})
......@@ -1238,28 +1246,34 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6);
taskpool.cancel(task6);
taskpool.cancel(task5);
taskpool.cancel(task4);
taskpool.cancel(task3);
taskpool.cancel(task2);
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6);
var start = new Date().getTime();
while (new Date().getTime() - start < 100) {
continue;
}
taskpool.cancel(task6);
taskpool.cancel(task5);
taskpool.cancel(task4);
taskpool.cancel(task3);
taskpool.cancel(task2);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not find the task");
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done();
})
......@@ -1277,28 +1291,34 @@ describe('ActsAbilityTest', function () {
return arg + 1;
}
try {
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6);
taskpool.cancel(task6);
taskpool.cancel(task5);
taskpool.cancel(task4);
taskpool.cancel(task3);
taskpool.cancel(task2);
var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6);
var start = new Date().getTime();
while (new Date().getTime() - start < 100) {
continue;
}
taskpool.cancel(task6);
taskpool.cancel(task5);
taskpool.cancel(task4);
taskpool.cancel(task3);
taskpool.cancel(task2);
}
catch (e) {
expect(e.toString()).assertEqual("BusinessError: taskpool:: can not find the task");
expect(e.toString()).assertEqual(
"BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task");
}
done();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册