Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
0b51ca6d
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看板
未验证
提交
0b51ca6d
编写于
1月 05, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
!6983 add taskpool cancel xts
Merge pull request !6983 from bwx1148593/master
上级
cdb35b9f
a872b53d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
446 addition
and
0 deletion
+446
-0
commonlibrary/ets_utils/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
...s/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
+446
-0
未找到文件。
commonlibrary/ets_utils/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
浏览文件 @
0b51ca6d
...
...
@@ -634,5 +634,451 @@ describe('ActsAbilityTest', function () {
}
done
();
})
/**
* @tc.number : TaskPoolTestClass049
* @tc.name : Async Function Cancel task
* @tc.desc : Cancel tasks that have not been executed
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass049
'
,
0
,
async
function
()
{
function
addition
(
arg
)
{
return
arg
+
1
;
}
function
additionDelay
(
arg
)
{
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
3000
)
{
continue
;
}
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
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
""
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass050
* @tc.name : Sync Function Cancel task
* @tc.desc : Cancel tasks that have not been executed
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass050
'
,
0
,
function
()
{
function
addition
(
arg
)
{
return
arg
+
1
;
}
function
additionDelay
(
arg
)
{
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
3000
)
{
continue
;
}
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
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
var
result3
=
taskpool
.
execute
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
""
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass051
* @tc.name : Async Function Cancel task
* @tc.desc : Cancel the task in progress
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass051
'
,
0
,
async
function
()
{
function
addition
(
arg
)
{
return
arg
+
1
;
}
function
additionDelay
(
arg
)
{
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
3000
)
{
continue
;
}
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
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
;
}
taskpool
.
cancel
(
task1
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not cancel the running task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass052
* @tc.name : Sync Function Cancel task
* @tc.desc : Cancel the task in progress
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass052
'
,
0
,
function
()
{
function
addition
(
arg
)
{
return
arg
+
1
;
}
function
additionDelay
(
arg
)
{
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
3000
)
{
continue
;
}
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
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
;
}
taskpool
.
cancel
(
task1
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not cancel the running task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass053
* @tc.name : Async Function Cancel task
* @tc.desc : Cancel the executed task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass053
'
,
0
,
async
function
()
{
function
addition
(
arg
)
{
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
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
;
}
taskpool
.
cancel
(
task1
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass054
* @tc.name : Sync Function Cancel task
* @tc.desc : Cancel the executed task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass054
'
,
0
,
function
()
{
function
addition
(
arg
)
{
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
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass055
* @tc.name : Async Function Cancel task
* @tc.desc : Cancel nonexistent task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass055
'
,
0
,
async
function
()
{
function
addition
(
arg
)
{
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
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass056
* @tc.name : Sync Function Cancel task
* @tc.desc : Cancel nonexistent task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass056
'
,
0
,
function
()
{
function
addition
(
arg
)
{
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
result1
=
taskpool
.
execute
(
task1
);
var
result2
=
taskpool
.
execute
(
task2
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass057
* @tc.name : Async Function Cancel task
* @tc.desc : Canceling unexecuted tasks multiple times
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass057
'
,
0
,
async
function
()
{
function
addition
(
arg
)
{
return
arg
+
1
;
}
function
additionDelay
(
arg
)
{
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
3000
)
{
continue
;
}
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
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
;
}
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass058
* @tc.name : Sync Function Cancel task
* @tc.desc : Canceling unexecuted tasks multiple times
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass058
'
,
0
,
function
()
{
function
addition
(
arg
)
{
return
arg
+
1
;
}
function
additionDelay
(
arg
)
{
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
3000
)
{
continue
;
}
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
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
;
}
taskpool
.
cancel
(
task3
);
taskpool
.
cancel
(
task3
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass059
* @tc.name : Async Function Cancel task
* @tc.desc : Cancel all tasks in sequence
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass059
'
,
0
,
async
function
()
{
function
addition
(
arg
)
{
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
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
}
done
();
})
/**
* @tc.number : TaskPoolTestClass060
* @tc.name : Sync Function Cancel task
* @tc.desc : Cancel all tasks in sequence
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass060
'
,
0
,
function
()
{
function
addition
(
arg
)
{
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
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: taskpool:: can not find the task
"
);
}
done
();
})
})
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录