提交 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 () { ...@@ -865,7 +865,7 @@ describe('ActsAbilityTest', function () {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TaskPoolTestClass049', 0, async function (done) { it('TaskPoolTestClass049', 0, async function (done) {
function addition(arg) { function addition(arg) {
return arg + 1; return arg + 1;
} }
...@@ -877,18 +877,18 @@ describe('ActsAbilityTest', function () { ...@@ -877,18 +877,18 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(additionDelay, 100); var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200); var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
taskpool.cancel(task3); taskpool.cancel(task3);
} }
catch (e) { catch (e) {
expect(e.toString()).assertEqual(""); expect(e.toString()).assertEqual("");
} }
done(); done();
}) })
...@@ -913,18 +913,18 @@ describe('ActsAbilityTest', function () { ...@@ -913,18 +913,18 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(additionDelay, 100); var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200); var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
taskpool.cancel(task3); taskpool.cancel(task3);
} }
catch (e) { catch (e) {
expect(e.toString()).assertEqual(""); expect(e.toString()).assertEqual("");
} }
done(); done();
}) })
...@@ -949,23 +949,24 @@ describe('ActsAbilityTest', function () { ...@@ -949,23 +949,24 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(additionDelay, 100); var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200); var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
var start = new Date().getTime(); var start = new Date().getTime();
while (new Date().getTime() - start < 1000) { while (new Date().getTime() - start < 1000) {
continue; continue;
} }
taskpool.cancel(task1); taskpool.cancel(task1);
} }
catch (e) { 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(); done();
}) })
...@@ -990,23 +991,24 @@ describe('ActsAbilityTest', function () { ...@@ -990,23 +991,24 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(additionDelay, 100); var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200); var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
var start = new Date().getTime(); var start = new Date().getTime();
while (new Date().getTime() - start < 1000) { while (new Date().getTime() - start < 1000) {
continue; continue;
} }
taskpool.cancel(task1); taskpool.cancel(task1);
} }
catch (e) { 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(); done();
}) })
...@@ -1024,23 +1026,24 @@ describe('ActsAbilityTest', function () { ...@@ -1024,23 +1026,24 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(addition, 100); var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200); var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
var start = new Date().getTime(); var start = new Date().getTime();
while (new Date().getTime() - start < 1000) { while (new Date().getTime() - start < 1000) {
continue; continue;
} }
taskpool.cancel(task1); taskpool.cancel(task1);
} }
catch (e) { 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(); done();
}) })
...@@ -1058,29 +1061,30 @@ describe('ActsAbilityTest', function () { ...@@ -1058,29 +1061,30 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(addition, 100); var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200); var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400); var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500); var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600); var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4); var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5); var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6); var result6 = taskpool.execute(task6);
var start = new Date().getTime(); var start = new Date().getTime();
while (new Date().getTime() - start < 1000) { while (new Date().getTime() - start < 1000) {
continue; continue;
} }
taskpool.cancel(task3); taskpool.cancel(task3);
} }
catch (e) { 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(); done();
}) })
...@@ -1098,17 +1102,18 @@ describe('ActsAbilityTest', function () { ...@@ -1098,17 +1102,18 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(addition, 100); var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200); var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
taskpool.cancel(task3); taskpool.cancel(task3);
} }
catch (e) { 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(); done();
}) })
...@@ -1126,17 +1131,18 @@ describe('ActsAbilityTest', function () { ...@@ -1126,17 +1131,18 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(addition, 100); var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200); var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
taskpool.cancel(task3); taskpool.cancel(task3);
} }
catch (e) { 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(); done();
}) })
...@@ -1161,24 +1167,25 @@ describe('ActsAbilityTest', function () { ...@@ -1161,24 +1167,25 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(additionDelay, 100); var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200); var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
var start = new Date().getTime(); var start = new Date().getTime();
while (new Date().getTime() - start < 1000) { while (new Date().getTime() - start < 1000) {
continue; continue;
} }
taskpool.cancel(task3); taskpool.cancel(task3);
taskpool.cancel(task3); taskpool.cancel(task3);
} }
catch (e) { 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(); done();
}) })
...@@ -1203,24 +1210,25 @@ describe('ActsAbilityTest', function () { ...@@ -1203,24 +1210,25 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(additionDelay, 100); var task1 = new taskpool.Task(additionDelay, 100);
var task2 = new taskpool.Task(additionDelay, 200); var task2 = new taskpool.Task(additionDelay, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
var start = new Date().getTime(); var start = new Date().getTime();
while (new Date().getTime() - start < 1000) { while (new Date().getTime() - start < 1000) {
continue; continue;
} }
taskpool.cancel(task3); taskpool.cancel(task3);
taskpool.cancel(task3); taskpool.cancel(task3);
} }
catch (e) { 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(); done();
}) })
...@@ -1238,28 +1246,34 @@ describe('ActsAbilityTest', function () { ...@@ -1238,28 +1246,34 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(addition, 100); var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200); var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400); var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500); var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600); var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4); var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5); var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6); var result6 = taskpool.execute(task6);
taskpool.cancel(task6); var start = new Date().getTime();
taskpool.cancel(task5); while (new Date().getTime() - start < 100) {
taskpool.cancel(task4); continue;
taskpool.cancel(task3); }
taskpool.cancel(task2);
taskpool.cancel(task6);
taskpool.cancel(task5);
taskpool.cancel(task4);
taskpool.cancel(task3);
taskpool.cancel(task2);
} }
catch (e) { 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(); done();
}) })
...@@ -1277,28 +1291,34 @@ describe('ActsAbilityTest', function () { ...@@ -1277,28 +1291,34 @@ describe('ActsAbilityTest', function () {
return arg + 1; return arg + 1;
} }
try { try {
var task1 = new taskpool.Task(addition, 100); var task1 = new taskpool.Task(addition, 100);
var task2 = new taskpool.Task(addition, 200); var task2 = new taskpool.Task(addition, 200);
var task3 = new taskpool.Task(addition, 300); var task3 = new taskpool.Task(addition, 300);
var task4 = new taskpool.Task(addition, 400); var task4 = new taskpool.Task(addition, 400);
var task5 = new taskpool.Task(addition, 500); var task5 = new taskpool.Task(addition, 500);
var task6 = new taskpool.Task(addition, 600); var task6 = new taskpool.Task(addition, 600);
var result1 = taskpool.execute(task1); var result1 = taskpool.execute(task1);
var result2 = taskpool.execute(task2); var result2 = taskpool.execute(task2);
var result3 = taskpool.execute(task3); var result3 = taskpool.execute(task3);
var result4 = taskpool.execute(task4); var result4 = taskpool.execute(task4);
var result5 = taskpool.execute(task5); var result5 = taskpool.execute(task5);
var result6 = taskpool.execute(task6); var result6 = taskpool.execute(task6);
taskpool.cancel(task6); var start = new Date().getTime();
taskpool.cancel(task5); while (new Date().getTime() - start < 100) {
taskpool.cancel(task4); continue;
taskpool.cancel(task3); }
taskpool.cancel(task2);
taskpool.cancel(task6);
taskpool.cancel(task5);
taskpool.cancel(task4);
taskpool.cancel(task3);
taskpool.cancel(task2);
} }
catch (e) { 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(); done();
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册