Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
3c21cc5a
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看板
未验证
提交
3c21cc5a
编写于
7月 31, 2023
作者:
O
openharmony_ci
提交者:
Gitee
7月 31, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9614 [4.0Beta2]add getTaskpoolInfo xts test case
Merge pull request !9614 from buzhuyu/OpenHarmony-4.0-Beta2
上级
05d55c25
fd1ab404
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
154 addition
and
0 deletion
+154
-0
commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js
...ool_lib_standard/entry/src/main/ets/test/TaskPool.test.js
+154
-0
未找到文件。
commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js
浏览文件 @
3c21cc5a
...
@@ -1525,5 +1525,159 @@ describe('ActsAbilityTest', function () {
...
@@ -1525,5 +1525,159 @@ describe('ActsAbilityTest', function () {
},
3000
);
},
3000
);
done
();
done
();
})
})
/**
* @tc.number : TaskPoolTestClass066
* @tc.name : Async Function GetTaskPoolInfo
* @tc.desc : Get the taskPoolInfo
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass066
'
,
0
,
async
function
(
done
)
{
async
function
currentFun
()
{
"
use concurrent
"
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(
resolve
,
500
,
"
async operation 1
"
)
});
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(
resolve
,
500
,
"
async operation 2
"
)
});
}
let
highCount
=
0
;
let
mediumCount
=
0
;
let
lowCount
=
0
;
let
allCount
=
100
;
for
(
let
i
=
0
;
i
<
allCount
;
i
++
)
{
let
task1
=
new
taskpool
.
Task
(
currentFun
);
let
task2
=
new
taskpool
.
Task
(
currentFun
);
let
task3
=
new
taskpool
.
Task
(
currentFun
);
taskpool
.
execute
(
task1
,
taskpool
.
Priority
.
LOW
).
then
(()
=>
{
lowCount
++
;
}).
catch
((
e
)
=>
{
console
.
error
(
"
low task error:
"
+
e
);
})
taskpool
.
execute
(
task2
,
taskpool
.
Priority
.
MEDIUM
).
then
(()
=>
{
mediumCount
++
;
}).
catch
((
e
)
=>
{
console
.
error
(
"
medium task error:
"
+
e
);
})
taskpool
.
execute
(
task3
,
taskpool
.
Priority
.
HIGH
).
then
(()
=>
{
highCount
++
;
}).
catch
((
e
)
=>
{
console
.
error
(
"
high task error:
"
+
e
);
})
}
let
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
let
taskpoolInfo
=
taskpool
.
getTaskPoolInfo
();
let
tid
=
0
;
let
taskIds
=
[];
let
priority
=
0
;
let
taskId
=
0
;
let
state
=
0
;
let
duration
=
0
;
for
(
let
threadInfo
of
taskpoolInfo
.
threadInfos
)
{
tid
+=
threadInfo
.
tid
;
taskIds
.
length
+=
threadInfo
.
taskIds
.
length
;
priority
+=
threadInfo
.
priority
;
}
for
(
let
taskInfo
of
taskpoolInfo
.
taskInfos
)
{
taskId
+=
taskInfo
.
taskId
;
state
+=
taskInfo
.
state
;
duration
+=
taskInfo
.
duration
;
}
console
.
info
(
"
task duration is:
"
+
duration
);
expect
(
tid
!=
0
);
expect
(
taskId
.
length
!=
0
);
expect
(
priority
!=
-
1
);
expect
(
taskId
!=
0
);
expect
(
state
!=
0
);
done
();
})
/**
* @tc.number : TaskPoolTestClass067
* @tc.name : sync Function GetTaskPoolInfo
* @tc.desc : Get the taskPoolInfo
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass067
'
,
0
,
async
function
(
done
)
{
function
delay
()
{
"
use concurrent
"
let
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
500
)
{
continue
;
}
}
let
highCount
=
0
;
let
mediumCount
=
0
;
let
lowCount
=
0
;
let
allCount
=
100
;
for
(
let
i
=
0
;
i
<
allCount
;
i
++
)
{
let
task1
=
new
taskpool
.
Task
(
delay
);
let
task2
=
new
taskpool
.
Task
(
delay
);
let
task3
=
new
taskpool
.
Task
(
delay
);
taskpool
.
execute
(
task1
,
taskpool
.
Priority
.
LOW
).
then
(()
=>
{
lowCount
++
;
}).
catch
((
e
)
=>
{
console
.
error
(
"
low task error:
"
+
e
);
})
taskpool
.
execute
(
task2
,
taskpool
.
Priority
.
MEDIUM
).
then
(()
=>
{
mediumCount
++
;
}).
catch
((
e
)
=>
{
console
.
error
(
"
medium task error:
"
+
e
);
})
taskpool
.
execute
(
task3
,
taskpool
.
Priority
.
HIGH
).
then
(()
=>
{
highCount
++
;
}).
catch
((
e
)
=>
{
console
.
error
(
"
high task error:
"
+
e
);
})
}
let
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
1000
)
{
continue
;
}
let
taskpoolInfo
=
taskpool
.
getTaskPoolInfo
();
let
tid
=
0
;
let
taskIds
=
[];
let
priority
=
0
;
let
taskId
=
0
;
let
state
=
0
;
let
duration
=
0
;
for
(
let
threadInfo
of
taskpoolInfo
.
threadInfos
)
{
tid
+=
threadInfo
.
tid
;
taskIds
.
length
+=
threadInfo
.
taskIds
.
length
;
priority
+=
threadInfo
.
priority
;
}
for
(
let
taskInfo
of
taskpoolInfo
.
taskInfos
)
{
taskId
+=
taskInfo
.
taskId
;
state
+=
taskInfo
.
state
;
duration
+=
taskInfo
.
duration
;
}
console
.
info
(
"
task duration is:
"
+
duration
);
expect
(
tid
!=
0
);
expect
(
taskId
.
length
!=
0
);
expect
(
priority
!=
-
1
);
expect
(
taskId
!=
0
);
expect
(
state
!=
0
);
done
();
})
})
})
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录