From 9b50f3e2b512027b0274a5be39995f12138b102d Mon Sep 17 00:00:00 2001 From: buzhuyu Date: Thu, 6 Jul 2023 14:44:20 +0800 Subject: [PATCH] modify taskpool xts throw error information description:modify taskpool xts throw error information issue:https://gitee.com/openharmony/commonlibrary_ets_utils/issues/I7IYGP Signed-off-by: buzhuyu --- .../entry/src/main/ets/test/TaskPool.test.js | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js b/commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js index 27c4349b3..222795d39 100644 --- a/commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js +++ b/commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js @@ -1173,12 +1173,25 @@ describe('ActsAbilityTest', function () { it('TaskPoolTestClass056', 0, async function (done) { function inspectStatus(arg) { "use concurrent" + let start = new Date().getTime(); + while (new Date().getTime() - start < 1000) { + continue; + } return arg; } - let task = new taskpool.Task(inspectStatus, 100); - taskpool.execute(task); - taskpool.cancel(task); + let task1 = new taskpool.Task(inspectStatus, 100); + let task2 = new taskpool.Task(inspectStatus, 200); + let task3 = new taskpool.Task(inspectStatus, 300); + let task4 = new taskpool.Task(inspectStatus, 400); + + taskpool.execute(task1); + taskpool.execute(task2); + taskpool.execute(task3); + taskpool.execute(task4); + setTimeout(()=>{ + taskpool.cancel(task4);}, 500); + expect(taskpool.Task.isCanceled() == false); done(); }) @@ -1214,8 +1227,7 @@ describe('ActsAbilityTest', function () { taskpool.execute(task1); taskpool.cancel(task1); } catch(e) { - expect(e.toString()).assertEqual( - "BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task"); + expect(e.toString()).assertEqual("BusinessError: The task does not exist when it is canceled"); } expect(taskpool.Task.isCanceled() == false); done(); @@ -1251,8 +1263,7 @@ describe('ActsAbilityTest', function () { taskpool.cancel(task1); } catch (e) { - expect(e.toString()).assertEqual( - "BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task"); + expect(e.toString()).assertEqual("BusinessError: The task does not exist when it is canceled"); } done(); }) @@ -1281,8 +1292,7 @@ describe('ActsAbilityTest', function () { taskpool.cancel(task3); } catch (e) { - expect(e.toString()).assertEqual( - "BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task"); + expect(e.toString()).assertEqual("BusinessError: The task does not exist when it is canceled"); } done(); }) @@ -1326,8 +1336,7 @@ describe('ActsAbilityTest', function () { taskpool.cancel(task3); } catch (e) { - expect(e.toString()).assertEqual( - "BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task"); + expect(e.toString()).assertEqual("BusinessError: The task does not exist when it is canceled"); } done(); }) @@ -1372,8 +1381,7 @@ describe('ActsAbilityTest', function () { taskpool.cancel(task2); } catch (e) { - expect(e.toString()).assertEqual( - "BusinessError: The task does not exist when it is canceled, taskpool:: can not find the task"); + expect(e.toString()).assertEqual("BusinessError: The task does not exist when it is canceled"); } done(); }) @@ -1472,8 +1480,7 @@ describe('ActsAbilityTest', function () { taskpool.cancel(taskGroup); } catch (e) { - expect(e.toString()).assertEqual( - "BusinessError: The task group does not exist when it is canceled, taskpool:: can not find the taskGroup"); + expect(e.toString()).assertEqual("BusinessError: The task group does not exist when it is canceled"); } done(); }) @@ -1513,8 +1520,7 @@ describe('ActsAbilityTest', function () { try { taskpool.cancel(taskGroup1); } catch (e) { - expect(e.toString()).assertEqual( - "BusinessError: The task group does not exist when it is canceled, taskpool:: can not find the taskGroup"); + expect(e.toString()).assertEqual("BusinessError: The task group does not exist when it is canceled"); } }, 3000); done(); -- GitLab