Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7699d90d
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看板
未验证
提交
7699d90d
编写于
8月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9772 Worker的基于listener机制添加测试用例
Merge pull request !9772 from yuqing_han/master
上级
875076df
61e6c439
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
655 addition
and
0 deletion
+655
-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
+55
-0
commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/ets/test/ThreadWorker.test.js
...lib_standard/entry/src/main/ets/test/ThreadWorker.test.js
+219
-0
commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/ets/workers/newworker_028.js
..._lib_standard/entry/src/main/ets/workers/newworker_028.js
+26
-0
commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/ets/workers/newworker_029.js
..._lib_standard/entry/src/main/ets/workers/newworker_029.js
+21
-0
commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/ets/workers/newworker_030.js
..._lib_standard/entry/src/main/ets/workers/newworker_030.js
+34
-0
commonlibrary/ets_utils/worker_lib_standard/entry/src/main/ets/test/WorkerTest.test.js
...r_lib_standard/entry/src/main/ets/test/WorkerTest.test.js
+219
-0
commonlibrary/ets_utils/worker_lib_standard/entry/src/main/ets/workers/worker_024.js
...ker_lib_standard/entry/src/main/ets/workers/worker_024.js
+26
-0
commonlibrary/ets_utils/worker_lib_standard/entry/src/main/ets/workers/worker_025.js
...ker_lib_standard/entry/src/main/ets/workers/worker_025.js
+21
-0
commonlibrary/ets_utils/worker_lib_standard/entry/src/main/ets/workers/worker_026.js
...ker_lib_standard/entry/src/main/ets/workers/worker_026.js
+34
-0
未找到文件。
commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js
浏览文件 @
7699d90d
...
@@ -1671,5 +1671,60 @@ describe('ActsAbilityTest', function () {
...
@@ -1671,5 +1671,60 @@ describe('ActsAbilityTest', function () {
expect
(
state
!=
0
).
assertTrue
();
expect
(
state
!=
0
).
assertTrue
();
done
();
done
();
})
})
/**
* @tc.number : TaskPoolTestClass068
* @tc.name : SharedArrayBuffer with taskpool
* @tc.desc : transfer SharedArrayBuffer with taskpool
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass068
'
,
0
,
async
function
(
done
)
{
let
sab
=
new
SharedArrayBuffer
(
20
);
let
int32
=
new
Uint32Array
(
sab
);
function
testTransfer
(
arg1
)
{
"
use concurrent
"
arg1
[
0
]
=
100
;
arg1
[
1
]
=
200
;
arg1
[
2
]
=
300
;
arg1
[
3
]
=
400
;
return
"
success
"
;
}
let
task
=
new
taskpool
.
Task
(
testTransfer
,
int32
);
taskpool
.
execute
(
task
).
then
((
res
)
=>
{
let
val
=
int32
[
0
]
+
int32
[
1
]
+
int32
[
2
]
+
int32
[
3
];
expect
(
val
).
assertEqual
(
1000
);
});
done
();
})
/**
* @tc.number : TaskPoolTestClass069
* @tc.name : SharedArrayBuffer and Atomics with taskpool
* @tc.desc : transfer SharedArrayBuffer and Atomics with taskpool
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass069
'
,
0
,
async
function
(
done
)
{
let
sab
=
new
SharedArrayBuffer
(
20
);
let
int32
=
new
Int32Array
(
sab
);
function
testTransfer
(
arg1
)
{
"
use concurrent
"
console
.
info
(
"
wait begin::
"
);
let
res
=
Atomics
.
wait
(
arg1
,
0
,
0
,
3000
);
return
res
;
}
let
task
=
new
taskpool
.
Task
(
testTransfer
,
int32
);
taskpool
.
execute
(
task
).
then
((
res
)
=>
{
expect
(
res
).
assertEqual
(
"
ok
"
);
});
setTimeout
(()
=>
{
Atomics
.
notify
(
int32
,
0
,
1
);
},
1000
);
done
();
})
})
})
}
}
\ No newline at end of file
commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/ets/test/ThreadWorker.test.js
浏览文件 @
7699d90d
...
@@ -2546,5 +2546,224 @@ describe('threadWorkerTest', function () {
...
@@ -2546,5 +2546,224 @@ describe('threadWorkerTest', function () {
expect
(
res
==
1
).
assertTrue
();
expect
(
res
==
1
).
assertTrue
();
done
();
done
();
})
})
// Check the SharedArrayBuffer with worker.
/**
* @tc.name: threadWorker_worker_SharedArrayBuffer_test_001
* @tc.desc: Check the SharedArrayBuffer with worker is ok.
*/
it
(
'
threadWorker_worker_SharedArrayBuffer_test_001
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
ThreadWorker
(
"
entry/ets/workers/newworker_028.js
"
);
let
sab
=
new
SharedArrayBuffer
(
20
);
let
int32
=
new
Uint32Array
(
sab
);
let
res
=
0
;
let
isTerminate
=
false
;
ss
.
onmessage
=
function
(
d
)
{
if
(
d
.
data
==
"
success
"
)
{
res
=
int32
[
0
]
+
int32
[
1
]
+
int32
[
2
]
+
int32
[
3
];
}
ss
.
terminate
();
}
ss
.
onexit
=
function
()
{
isTerminate
=
true
;
}
ss
.
postMessage
(
int32
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
==
1000
).
assertTrue
();
done
();
})
// Check the listener of worker.
/**
* @tc.name: threadWorker_worker_listener_test_001
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
threadWorker_worker_listener_test_001
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
ThreadWorker
(
"
entry/ets/workers/newworker_029.js
"
);
let
res
=
undefined
;
let
flag
=
false
;
let
isTerminate
=
false
;
ss
.
on
(
'
message
'
,
(
event
)
=>
{
flag
=
true
;
let
jsonData
=
JSON
.
parse
(
JSON
.
stringify
(
event
));
res
=
jsonData
.
data
;
ss
.
terminate
();
});
ss
.
on
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
"
hello worker
"
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: threadWorker_worker_listener_test_002
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
threadWorker_worker_listener_test_002
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
ThreadWorker
(
"
entry/ets/workers/newworker_029.js
"
);
let
res
=
0
;
let
flag
=
false
;
let
isTerminate
=
false
;
ss
.
addEventListener
(
'
messageerror
'
,
(
event
)
=>
{
flag
=
true
;
res
+=
1
;
});
ss
.
addEventListener
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
try
{
const
data
=
Symbol
();
ss
.
postMessage
(
data
);
}
catch
(
error
)
{
while
(
!
flag
)
{
await
promiseCase
();
}
ss
.
terminate
();
while
(
!
isTerminate
)
{
await
promiseCase
();
}
}
expect
(
res
).
assertEqual
(
1
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: threadWorker_worker_listener_test_003
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
threadWorker_worker_listener_test_003
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
ThreadWorker
(
"
entry/ets/workers/newworker_007.js
"
);
let
res
=
undefined
;
let
isTerminate
=
false
;
ss
.
addEventListener
(
'
error
'
,
(
event
)
=>
{
let
jsonData
=
JSON
.
parse
(
JSON
.
stringify
(
event
));
res
=
jsonData
.
message
;
ss
.
terminate
();
});
ss
.
addEventListener
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
"
Error: 123
"
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: threadWorker_worker_listener_test_004
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
threadWorker_worker_listener_test_004
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
ThreadWorker
(
"
entry/ets/workers/newworker_007.js
"
);
let
res
=
undefined
;
let
isTerminate
=
false
;
ss
.
on
(
'
error
'
,
(
event
)
=>
{
let
jsonData
=
JSON
.
parse
(
JSON
.
stringify
(
event
));
res
=
jsonData
.
message
;
ss
.
terminate
();
});
ss
.
on
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
"
Error: 123
"
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: threadWorker_worker_listener_test_005
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
threadWorker_worker_listener_test_005
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
ThreadWorker
(
"
entry/ets/workers/newworker_029.js
"
);
let
res1
=
""
;
let
res2
=
""
;
let
flag1
=
false
;
let
flag2
=
false
;
let
isTerminate
=
false
;
ss
.
on
(
'
message
'
,
(
event
)
=>
{
flag1
=
true
;
let
jsonData
=
JSON
.
parse
(
JSON
.
stringify
(
event
));
res1
=
jsonData
.
data
;
});
ss
.
onmessage
=
function
(
d
)
{
flag2
=
true
;
let
data
=
d
.
data
;
res2
=
data
;
}
ss
.
on
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
flag1
||
!
flag2
)
{
await
promiseCase
();
}
ss
.
terminate
();
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res1
).
assertEqual
(
"
hello worker
"
)
expect
(
res2
).
assertEqual
(
"
hello worker
"
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: threadWorker_worker_listener_test_006
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
threadWorker_worker_listener_test_006
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
ThreadWorker
(
"
entry/ets/workers/newworker_030.js
"
);
let
res
=
0
;
let
isTerminate
=
false
;
ss
.
on
(
'
message
'
,
(
event
)
=>
{
res
+=
1
;
if
(
res
==
3
)
{
ss
.
terminate
();
}
});
ss
.
on
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
3
)
done
();
})
})
})
}
}
\ No newline at end of file
commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/ets/workers/newworker_028.js
0 → 100644
浏览文件 @
7699d90d
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
'
@ohos.worker
'
;
const
workerPort
=
worker
.
workerPort
;
workerPort
.
onmessage
=
function
(
d
)
{
let
int32
=
d
.
data
;
int32
[
0
]
=
100
;
int32
[
1
]
=
200
;
int32
[
2
]
=
300
;
int32
[
3
]
=
400
;
workerPort
.
postMessage
(
"
success
"
);
}
\ No newline at end of file
commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/ets/workers/newworker_029.js
0 → 100644
浏览文件 @
7699d90d
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
'
@ohos.worker
'
;
const
workerPort
=
worker
.
workerPort
;
workerPort
.
addEventListener
(
"
message
"
,
(
event
)
=>
{
workerPort
.
postMessage
(
"
hello worker
"
)
})
\ No newline at end of file
commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/ets/workers/newworker_030.js
0 → 100644
浏览文件 @
7699d90d
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
'
@ohos.worker
'
;
const
workerPort
=
worker
.
workerPort
;
workerPort
.
addEventListener
(
"
addEventTest
"
,
(
event
)
=>
{
workerPort
.
postMessage
(
"
123
"
)
})
workerPort
.
addEventListener
(
"
onceTest
"
,
(
event
)
=>
{
workerPort
.
postMessage
(
"
456
"
)
})
workerPort
.
addEventListener
(
"
message
"
,
(
event
)
=>
{
workerPort
.
dispatchEvent
({
type
:
"
addEventTest
"
,
timeStamp
:
0
})
workerPort
.
dispatchEvent
({
type
:
"
addEventTest
"
,
timeStamp
:
0
})
workerPort
.
removeEventListener
(
"
addEventTest
"
);
workerPort
.
dispatchEvent
({
type
:
"
addEventTest
"
,
timeStamp
:
0
})
workerPort
.
dispatchEvent
({
type
:
"
onceTest
"
,
timeStamp
:
0
})
workerPort
.
removeEventListener
(
"
onceTest
"
)
})
\ No newline at end of file
commonlibrary/ets_utils/worker_lib_standard/entry/src/main/ets/test/WorkerTest.test.js
浏览文件 @
7699d90d
...
@@ -1734,5 +1734,224 @@ describe('WorkerTest', function () {
...
@@ -1734,5 +1734,224 @@ describe('WorkerTest', function () {
expect
(
result
).
assertEqual
(
"
unInit
"
);
expect
(
result
).
assertEqual
(
"
unInit
"
);
done
();
done
();
})
})
// Check the SharedArrayBuffer with worker.
/**
* @tc.name: worker_SharedArrayBuffer_test_001
* @tc.desc: Check the SharedArrayBuffer with worker is ok.
*/
it
(
'
worker_SharedArrayBuffer_test_001
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
Worker
(
"
entry/ets/workers/worker_024.js
"
);
let
sab
=
new
SharedArrayBuffer
(
20
);
let
int32
=
new
Uint32Array
(
sab
);
let
res
=
0
;
let
isTerminate
=
false
;
ss
.
onmessage
=
function
(
d
)
{
if
(
d
.
data
==
"
success
"
)
{
res
=
int32
[
0
]
+
int32
[
1
]
+
int32
[
2
]
+
int32
[
3
];
}
ss
.
terminate
();
}
ss
.
onexit
=
function
()
{
isTerminate
=
true
;
}
ss
.
postMessage
(
int32
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
==
1000
).
assertTrue
();
done
();
})
// Check the listener of worker.
/**
* @tc.name: worker_listener_test_001
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
worker_listener_test_001
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
Worker
(
"
entry/ets/workers/worker_025.js
"
);
let
res
=
undefined
;
let
flag
=
false
;
let
isTerminate
=
false
;
ss
.
on
(
'
message
'
,
(
event
)
=>
{
flag
=
true
;
let
jsonData
=
JSON
.
parse
(
JSON
.
stringify
(
event
));
res
=
jsonData
.
data
;
ss
.
terminate
();
});
ss
.
on
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
"
hello worker
"
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: worker_listener_test_002
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
worker_listener_test_002
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
Worker
(
"
entry/ets/workers/worker_025.js
"
);
let
res
=
0
;
let
flag
=
false
;
let
isTerminate
=
false
;
ss
.
addEventListener
(
'
messageerror
'
,
(
event
)
=>
{
flag
=
true
;
res
+=
1
;
});
ss
.
addEventListener
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
try
{
const
data
=
Symbol
();
ss
.
postMessage
(
data
);
}
catch
(
error
)
{
while
(
!
flag
)
{
await
promiseCase
();
}
ss
.
terminate
();
while
(
!
isTerminate
)
{
await
promiseCase
();
}
}
expect
(
res
).
assertEqual
(
1
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: worker_listener_test_003
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
worker_listener_test_003
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
Worker
(
"
entry/ets/workers/worker_007.js
"
);
let
res
=
undefined
;
let
isTerminate
=
false
;
ss
.
addEventListener
(
'
error
'
,
(
event
)
=>
{
let
jsonData
=
JSON
.
parse
(
JSON
.
stringify
(
event
));
res
=
jsonData
.
message
;
ss
.
terminate
();
});
ss
.
addEventListener
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
"
Error: 123
"
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: worker_listener_test_004
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
worker_listener_test_004
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
Worker
(
"
entry/ets/workers/worker_007.js
"
);
let
res
=
undefined
;
let
isTerminate
=
false
;
ss
.
on
(
'
error
'
,
(
event
)
=>
{
let
jsonData
=
JSON
.
parse
(
JSON
.
stringify
(
event
));
res
=
jsonData
.
message
;
ss
.
terminate
();
});
ss
.
on
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
"
Error: 123
"
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: worker_listener_test_005
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
worker_listener_test_005
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
Worker
(
"
entry/ets/workers/worker_025.js
"
);
let
res1
=
""
;
let
res2
=
""
;
let
flag1
=
false
;
let
flag2
=
false
;
let
isTerminate
=
false
;
ss
.
on
(
'
message
'
,
(
event
)
=>
{
flag1
=
true
;
let
jsonData
=
JSON
.
parse
(
JSON
.
stringify
(
event
));
res1
=
jsonData
.
data
;
});
ss
.
onmessage
=
function
(
d
)
{
flag2
=
true
;
let
data
=
d
.
data
;
res2
=
data
;
}
ss
.
on
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
flag1
||
!
flag2
)
{
await
promiseCase
();
}
ss
.
terminate
();
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res1
).
assertEqual
(
"
hello worker
"
)
expect
(
res2
).
assertEqual
(
"
hello worker
"
)
done
();
})
// Check the listener of worker.
/**
* @tc.name: worker_listener_test_006
* @tc.desc: Check the listener of worker is ok.
*/
it
(
'
worker_listener_test_006
'
,
0
,
async
function
(
done
)
{
let
ss
=
new
worker
.
Worker
(
"
entry/ets/workers/worker_026.js
"
);
let
res
=
0
;
let
isTerminate
=
false
;
ss
.
on
(
'
message
'
,
(
event
)
=>
{
res
+=
1
;
if
(
res
==
3
)
{
ss
.
terminate
();
}
});
ss
.
on
(
'
exit
'
,
(
code
)
=>
{
isTerminate
=
true
;
})
ss
.
postMessage
(
"
123
"
);
while
(
!
isTerminate
)
{
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
3
)
done
();
})
})
})
}
}
\ No newline at end of file
commonlibrary/ets_utils/worker_lib_standard/entry/src/main/ets/workers/worker_024.js
0 → 100644
浏览文件 @
7699d90d
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
d
)
{
let
int32
=
d
.
data
;
int32
[
0
]
=
100
;
int32
[
1
]
=
200
;
int32
[
2
]
=
300
;
int32
[
3
]
=
400
;
parentPort
.
postMessage
(
"
success
"
);
}
\ No newline at end of file
commonlibrary/ets_utils/worker_lib_standard/entry/src/main/ets/workers/worker_025.js
0 → 100644
浏览文件 @
7699d90d
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
addEventListener
(
"
message
"
,
(
event
)
=>
{
parentPort
.
postMessage
(
"
hello worker
"
)
})
\ No newline at end of file
commonlibrary/ets_utils/worker_lib_standard/entry/src/main/ets/workers/worker_026.js
0 → 100644
浏览文件 @
7699d90d
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
addEventListener
(
"
addEventTest
"
,
(
event
)
=>
{
parentPort
.
postMessage
(
"
123
"
)
})
parentPort
.
addEventListener
(
"
onceTest
"
,
(
event
)
=>
{
parentPort
.
postMessage
(
"
456
"
)
})
parentPort
.
addEventListener
(
"
message
"
,
(
event
)
=>
{
parentPort
.
dispatchEvent
({
type
:
"
addEventTest
"
,
timeStamp
:
0
})
parentPort
.
dispatchEvent
({
type
:
"
addEventTest
"
,
timeStamp
:
0
})
parentPort
.
removeEventListener
(
"
addEventTest
"
);
parentPort
.
dispatchEvent
({
type
:
"
addEventTest
"
,
timeStamp
:
0
})
parentPort
.
dispatchEvent
({
type
:
"
onceTest
"
,
timeStamp
:
0
})
parentPort
.
removeEventListener
(
"
onceTest
"
)
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录