Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
1d21e971
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看板
提交
1d21e971
编写于
3月 14, 2023
作者:
X
xinking129
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code
Signed-off-by:
N
xinking129
<
xinxin13@huawei.com
>
上级
7e230678
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
28 addition
and
26 deletion
+28
-26
ability/ability_runtime/registerjserror/ActsRegisterJsErrorRely/entry/src/main/ets/entryability/EntryAbility.ts
...ErrorRely/entry/src/main/ets/entryability/EntryAbility.ts
+1
-1
ability/ability_runtime/registerjserror/ActsRegisterJsErrorTest/entry/src/main/ets/test/Ability.test.ets
...isterJsErrorTest/entry/src/main/ets/test/Ability.test.ets
+27
-25
未找到文件。
ability/ability_runtime/registerjserror/ActsRegisterJsErrorRely/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
1d21e971
...
...
@@ -71,7 +71,7 @@ export default class EntryAbility extends Ability {
commonEventData
.
parameters
.
message
=
strMsg
;
console
.
info
(
"
====>Acts_RegisterJsErrorCallback_0100 onUnhandledException Message:
"
+
strMsg
);
commonEvent
.
publish
(
"
ACTS_RegisterEvent_First
"
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
"
====>Acts_RegisterJsErrorCallback_0100 publish err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
====>Acts_RegisterJsErrorCallback_0100 publish err:
"
+
JSON
.
stringify
(
err
));
setTimeout
(()
=>
{
globalThis
.
context
.
terminateSelf
().
then
(()
=>
{
console
.
info
(
"
====>Acts_RegisterJsErrorCallback_0100 rely terminateSelf end
"
);
...
...
ability/ability_runtime/registerjserror/ActsRegisterJsErrorTest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
1d21e971
...
...
@@ -26,16 +26,13 @@ export default function abilityTest() {
beforeAll(function () {
observer = {
onUnhandledException(strMsg){
console.info("====>Acts_RegisterJsErrorCallback onUnhandledException Message
:
" + strMsg);
console.info("====>Acts_RegisterJsErrorCallback onUnhandledException Message
:
" + strMsg);
},
onException(errObject){
console.info("====>Acts_RegisterJsErrorCallback onException Message
:
" + errObject);
console.info("====>Acts_RegisterJsErrorCallback onException Message
:
" + errObject);
}
}
})
beforeEach(function () {})
afterEach(function () {})
afterAll(function () {})
/*
* @tc.number: Acts_RegisterJsErrorCallback_0100
...
...
@@ -57,13 +54,13 @@ export default function abilityTest() {
abilityName: "EntryAbility",
action: "Acts_RegisterJsErrorCallback_0100"
},(err)=>{
console.debug("====>Acts_RegisterJsErrorCallback_0100 startAbility err:"+JSON.stringify(err));
console.debug("====>Acts_RegisterJsErrorCallback_0100 startAbility err:
"+JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
function subscribeCallBack(err, data) {
console.debug("====>Acts_RegisterJsErrorCallback_0100 subscribeCallBack data:" + JSON.stringify(data));
console.debug("====>Acts_RegisterJsErrorCallback_0100 subscribeCallBack data:
" + JSON.stringify(data));
if(data.event == "ACTS_RegisterEvent_First") {
flag = true;
expect(data.parameters.message).assertContain("Error message:Cannot read property terminateSelf");
...
...
@@ -73,7 +70,9 @@ export default function abilityTest() {
function unSubscribeCallback() {
console.debug("====>Acts_RegisterJsErrorCallback_0100 unSubscribeCallback");
setTimeout(() => {done();}, 800);
setTimeout(()=>{
done();
}, 800);
}
setTimeout(()=>{
...
...
@@ -104,7 +103,7 @@ export default function abilityTest() {
abilityName: "EntryAbility",
action: "Acts_RegisterJsErrorCallback_0200"
},(err)=>{
console.debug("====>Acts_RegisterJsErrorCallback_0200 startAbility err:"+JSON.stringify(err));
console.debug("====>Acts_RegisterJsErrorCallback_0200 startAbility err:
"+JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
...
...
@@ -112,11 +111,12 @@ export default function abilityTest() {
var msg = {"ACTS_RegisterEvent_First": false, "ACTS_RegisterEvent_Second": false}
function subscribeCallBack(err, data) {
if (data.event === 'ACTS_RegisterEvent_First') {
console.debug("====>Acts_RegisterJsErrorCallback_0200 subscribeCallBack First data:" + JSON.stringify(data));
console.debug("====>Acts_RegisterJsErrorCallback_0200 subscribeCallBack First data:
" + JSON.stringify(data));
expect(data.parameters.message).assertContain("Error message:Cannot read property terminateSelf");
msg["ACTS_RegisterEvent_First"] = true;
} else if (data.event === 'ACTS_RegisterEvent_Second') {
console.debug("====>Acts_RegisterJsErrorCallback_0200 subscribeCallBack Second data:" + JSON.stringify(data));
console.debug("====>Acts_RegisterJsErrorCallback_0200 subscribeCallBack Second data: " +
JSON.stringify(data));
expect(data.parameters.message.name).assertEqual("TypeError");
expect(data.parameters.message.message).assertEqual("Cannot read property terminateSelf of undefined");
expect(data.parameters.message.stack).assertContain("at anonymous");
...
...
@@ -130,7 +130,7 @@ export default function abilityTest() {
}
function unSubscribeCallback() {
setTimeout(()
=>
{
setTimeout(()
=>
{
console.debug("====>Acts_RegisterJsErrorCallback_0200 unSubscribeCallback");
done();
}, 800);
...
...
@@ -236,12 +236,12 @@ export default function abilityTest() {
expect().assertFail();
done();
}).catch((err)=>{
console.info("====>Acts_UnregisterJsErrorCallback_0100 err:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0100 err:
" + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
})
} catch (err) {
console.info("====>Acts_UnregisterJsErrorCallback_0100 catch:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0100 catch:
" + JSON.stringify(err));
expect(err.code).assertEqual(401);
console.info("====>Acts_UnregisterJsErrorCallback_0100 end");
done();
...
...
@@ -262,12 +262,12 @@ export default function abilityTest() {
expect().assertFail();
done();
}).catch((err)=>{
console.info("====>Acts_UnregisterJsErrorCallback_0200 err:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0200 err:
" + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
})
} catch (err) {
console.info("====>Acts_UnregisterJsErrorCallback_0200 catch:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0200 catch:
" + JSON.stringify(err));
expect(err.code).assertEqual(401);
console.info("====>Acts_UnregisterJsErrorCallback_0200 end");
done();
...
...
@@ -286,7 +286,7 @@ export default function abilityTest() {
expect().assertFail();
done();
}).catch((err)=>{
console.info("====>Acts_UnregisterJsErrorCallback_0300 err:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0300 err:
" + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
})
...
...
@@ -304,7 +304,7 @@ export default function abilityTest() {
expect().assertFail();
done();
}).catch((err)=>{
console.info("====>Acts_UnregisterJsErrorCallback_0400 err:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0400 err:
" + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
})
...
...
@@ -322,7 +322,7 @@ export default function abilityTest() {
expect().assertFail();
done();
}).catch((err)=>{
console.info("====>Acts_UnregisterJsErrorCallback_0500 err:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0500 err:
" + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
})
...
...
@@ -340,7 +340,7 @@ export default function abilityTest() {
expect().assertFail();
done();
}).catch((err)=>{
console.info("====>Acts_UnregisterJsErrorCallback_0600 err:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0600 err:
" + JSON.stringify(err));
expect(err.code).assertEqual(16000003);
done();
})
...
...
@@ -361,12 +361,12 @@ export default function abilityTest() {
expect(true).assertTrue();
done();
}).catch((err)=>{
console.info("====>Acts_UnregisterJsErrorCallback_0700 err:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0700 err:
" + JSON.stringify(err));
expect().assertFail();
done();
})
} catch (err) {
console.info("====>Acts_UnregisterJsErrorCallback_0700 catch:" + JSON.stringify(err));
console.info("====>Acts_UnregisterJsErrorCallback_0700 catch:
" + JSON.stringify(err));
expect().assertFail();
done();
}
...
...
@@ -392,7 +392,7 @@ export default function abilityTest() {
abilityName: "EntryAbility",
action: "Acts_UnregisterJsErrorCallback_0800"
},(err)=>{
console.debug("====>Acts_UnregisterJsErrorCallback_0800 startAbility err:"+JSON.stringify(err));
console.debug("====>Acts_UnregisterJsErrorCallback_0800 startAbility err:
"+JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
...
...
@@ -400,11 +400,13 @@ export default function abilityTest() {
var msg = {"ACTS_RegisterEvent_First": false, "ACTS_RegisterEvent_Second": false}
function subscribeCallBack(err, data) {
if (data.event === 'ACTS_RegisterEvent_First') {
console.debug("====>Acts_UnregisterJsErrorCallback_0800 subscribeCallBack First data:" + JSON.stringify(data));
console.debug("====>Acts_UnregisterJsErrorCallback_0800 subscribeCallBack First data: " +
JSON.stringify(data));
expect(data.parameters.message).assertContain("Error message:Cannot read property terminateSelf");
msg["ACTS_RegisterEvent_First"] = true;
} else if (data.event === 'ACTS_RegisterEvent_Second') {
console.debug("====>Acts_UnregisterJsErrorCallback_0800 subscribeCallBack Second data:" + JSON.stringify(data));
console.debug("====>Acts_UnregisterJsErrorCallback_0800 subscribeCallBack Second data: " +
JSON.stringify(data));
expect(data.parameters.message.name).assertEqual("TypeError");
expect(data.parameters.message.message).assertEqual("Cannot read property terminateSelf of undefined");
expect(data.parameters.message.stack).assertContain("at anonymous");
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录