Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
b8bc27e5
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看板
提交
b8bc27e5
编写于
8月 19, 2023
作者:
W
wangyulie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化用例
Signed-off-by:
N
wangyulie
<
wanglieyu@126.com
>
上级
63c5763c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
80 addition
and
10 deletion
+80
-10
resourceschedule/resourceschedule_standard/ffrt/entry/src/main/cpp/ffrtndk.cpp
...urceschedule_standard/ffrt/entry/src/main/cpp/ffrtndk.cpp
+51
-3
resourceschedule/resourceschedule_standard/ffrt/entry/src/main/cpp/types/libffrtndk/index.d.ts
...ndard/ffrt/entry/src/main/cpp/types/libffrtndk/index.d.ts
+3
-1
resourceschedule/resourceschedule_standard/ffrt/entry/src/ohosTest/ets/test/Ffrt.test.ets
...e_standard/ffrt/entry/src/ohosTest/ets/test/Ffrt.test.ets
+26
-6
未找到文件。
resourceschedule/resourceschedule_standard/ffrt/entry/src/main/cpp/ffrtndk.cpp
浏览文件 @
b8bc27e5
...
...
@@ -252,8 +252,6 @@ static napi_value SubmitQueueFfrtTask(napi_env env, napi_callback_info info)
ffrt_queue_t
queue_handle
=
ffrt_queue_create
(
ffrt_queue_serial
,
"test_queue"
,
&
queue_attr
);
ffrt_task_handle_t
task1
=
ffrt_queue_submit_h
(
queue_handle
,
ffrt_create_function_wrapper
(
OnePlusForTest
,
NULL
,
&
a
,
ffrt_function_kind_queue
),
nullptr
);
ffrt_queue_cancel
(
task1
);
ffrt_queue_wait
(
task1
);
ffrt_queue_submit
(
queue_handle
,
ffrt_create_function_wrapper
(
MulipleForTest
,
nullptr
,
&
a
,
ffrt_function_kind_queue
),
nullptr
);
ffrt_queue_submit
(
queue_handle
,
...
...
@@ -269,13 +267,63 @@ static napi_value SubmitQueueFfrtTask(napi_env env, napi_callback_info info)
return
flag
;
}
static
napi_value
CancelQueueFfrtTask
(
napi_env
env
,
napi_callback_info
info
)
{
int
a
=
0
;
int
b
=
0
;
ffrt_queue_attr_t
queue_attr
;
(
void
)
ffrt_queue_attr_init
(
&
queue_attr
);
ffrt_queue_attr_set_qos
(
&
queue_attr
,
ffrt_qos_default
);
ffrt_queue_attr_set_callback
(
&
queue_attr
,
ffrt_create_function_wrapper
(
OnePlusForTest
,
NULL
,
&
b
,
ffrt_function_kind_queue
));
ffrt_queue_t
queue_handle
=
ffrt_queue_create
(
ffrt_queue_serial
,
"test_queue"
,
&
queue_attr
);
ffrt_task_handle_t
task1
=
ffrt_queue_submit_h
(
queue_handle
,
ffrt_create_function_wrapper
(
OnePlusForTest
,
NULL
,
&
a
,
ffrt_function_kind_queue
),
nullptr
);
ffrt_queue_cancel
(
task1
);
sleep
(
2
);
OH_LOG_Print
(
LOG_APP
,
LOG_INFO
,
1
,
"testFFRT"
,
"cancel queue task a is %{public}d"
,
a
);
OH_LOG_Print
(
LOG_APP
,
LOG_INFO
,
1
,
"testFFRT"
,
"cancel queue task b is %{public}d"
,
b
);
napi_value
flag
=
nullptr
;
napi_create_double
(
env
,
a
,
&
flag
);
ffrt_task_handle_destroy
(
task1
);
ffrt_queue_attr_destroy
(
&
queue_attr
);
ffrt_queue_destroy
(
queue_handle
);
return
flag
;
}
static
napi_value
WaitQueueFfrtTask
(
napi_env
env
,
napi_callback_info
info
)
{
int
a
=
0
;
int
b
=
0
;
ffrt_queue_attr_t
queue_attr
;
(
void
)
ffrt_queue_attr_init
(
&
queue_attr
);
ffrt_queue_attr_set_qos
(
&
queue_attr
,
ffrt_qos_default
);
ffrt_queue_attr_set_callback
(
&
queue_attr
,
ffrt_create_function_wrapper
(
OnePlusForTest
,
NULL
,
&
b
,
ffrt_function_kind_queue
));
ffrt_queue_t
queue_handle
=
ffrt_queue_create
(
ffrt_queue_serial
,
"test_queue"
,
&
queue_attr
);
ffrt_task_handle_t
task1
=
ffrt_queue_submit_h
(
queue_handle
,
ffrt_create_function_wrapper
(
OnePlusForTest
,
NULL
,
&
a
,
ffrt_function_kind_queue
),
nullptr
);
ffrt_queue_wait
(
task1
);
sleep
(
2
);
OH_LOG_Print
(
LOG_APP
,
LOG_INFO
,
1
,
"testFFRT"
,
"wait queue task a is %{public}d"
,
a
);
OH_LOG_Print
(
LOG_APP
,
LOG_INFO
,
1
,
"testFFRT"
,
"wait queue task b is %{public}d"
,
b
);
napi_value
flag
=
nullptr
;
napi_create_double
(
env
,
a
,
&
flag
);
ffrt_task_handle_destroy
(
task1
);
ffrt_queue_attr_destroy
(
&
queue_attr
);
ffrt_queue_destroy
(
queue_handle
);
return
flag
;
}
EXTERN_C_START
static
napi_value
Init
(
napi_env
env
,
napi_value
exports
)
{
napi_property_descriptor
desc
[]
=
{
{
"submitSimpleFfrtTask"
,
nullptr
,
SubmitSimpleFfrtTask
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"submitCondFfrtTask"
,
nullptr
,
SubmitCondFfrtTask
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"submitQueueFfrtTask"
,
nullptr
,
SubmitQueueFfrtTask
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
}
{
"submitQueueFfrtTask"
,
nullptr
,
SubmitQueueFfrtTask
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"cancelQueueFfrtTask"
,
nullptr
,
CancelQueueFfrtTask
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"waitQueueFfrtTask"
,
nullptr
,
WaitQueueFfrtTask
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
}
};
napi_define_properties
(
env
,
exports
,
sizeof
(
desc
)
/
sizeof
(
desc
[
0
]),
desc
);
return
exports
;
...
...
resourceschedule/resourceschedule_standard/ffrt/entry/src/main/cpp/types/libffrtndk/index.d.ts
浏览文件 @
b8bc27e5
export
const
submitSimpleFfrtTask
:
()
=>
number
;
export
const
submitCondFfrtTask
:
()
=>
number
;
export
const
submitQueueFfrtTask
:
()
=>
number
;
export
const
cancelQueueFfrtTask
:
()
=>
number
;
export
const
waitQueueFfrtTask
:
()
=>
number
;
\ No newline at end of file
resourceschedule/resourceschedule_standard/ffrt/entry/src/ohosTest/ets/test/Ffrt.test.ets
浏览文件 @
b8bc27e5
...
...
@@ -16,7 +16,7 @@ import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import ffrtndk from 'libffrtndk.so';
export default function ffrtTest() {
describe('Acts
Ability
Test', function () {
describe('Acts
Ffrt
Test', function () {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(function () {
// Presets an action, which is performed only once before all test cases of the test suite start.
...
...
@@ -36,15 +36,35 @@ export default function ffrtTest() {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
it('
assertContain
',0, function () {
it('
submitSimpleFfrtTask
',0, function () {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
var flag = ffrtndk.submitSimpleFfrtTask();
var flag2 = ffrtndk.submitCondFfrtTask();
var flag3 = ffrtndk.submitQueueFfrtTask();
expect(flag).assertEqual(1);
expect(flag2).assertEqual(3);
expect(flag3).assertEqual(-1);
})
it('submitCondFfrtTask',0, function () {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
var flag = ffrtndk.submitCondFfrtTask();
expect(flag).assertEqual(3);
})
it('submitQueueFfrtTask',0, function () {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
var flag = ffrtndk.submitQueueFfrtTask();
expect(flag).assertEqual(9);
})
it('cancelQueueFfrtTask',0, function () {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
var flag = ffrtndk.cancelQueueFfrtTask();
expect(flag).assertEqual(0);
})
it('waitQueueFfrtTask',0, function () {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
var flag = ffrtndk.waitQueueFfrtTask();
expect(flag).assertEqual(1);
})
})
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录