提交 1d21e971 编写于 作者: X xinking129

fix code

Signed-off-by: Nxinking129 <xinxin13@huawei.com>
上级 7e230678
...@@ -71,7 +71,7 @@ export default class EntryAbility extends Ability { ...@@ -71,7 +71,7 @@ export default class EntryAbility extends Ability {
commonEventData.parameters.message = strMsg; commonEventData.parameters.message = strMsg;
console.info("====>Acts_RegisterJsErrorCallback_0100 onUnhandledException Message: " + strMsg); console.info("====>Acts_RegisterJsErrorCallback_0100 onUnhandledException Message: " + strMsg);
commonEvent.publish("ACTS_RegisterEvent_First", commonEventData, (err) => { 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(()=>{ setTimeout(()=>{
globalThis.context.terminateSelf().then(()=>{ globalThis.context.terminateSelf().then(()=>{
console.info("====>Acts_RegisterJsErrorCallback_0100 rely terminateSelf end"); console.info("====>Acts_RegisterJsErrorCallback_0100 rely terminateSelf end");
......
...@@ -26,16 +26,13 @@ export default function abilityTest() { ...@@ -26,16 +26,13 @@ export default function abilityTest() {
beforeAll(function () { beforeAll(function () {
observer = { observer = {
onUnhandledException(strMsg){ onUnhandledException(strMsg){
console.info("====>Acts_RegisterJsErrorCallback onUnhandledException Message" + strMsg); console.info("====>Acts_RegisterJsErrorCallback onUnhandledException Message: " + strMsg);
}, },
onException(errObject){ 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 * @tc.number: Acts_RegisterJsErrorCallback_0100
...@@ -57,13 +54,13 @@ export default function abilityTest() { ...@@ -57,13 +54,13 @@ export default function abilityTest() {
abilityName: "EntryAbility", abilityName: "EntryAbility",
action: "Acts_RegisterJsErrorCallback_0100" action: "Acts_RegisterJsErrorCallback_0100"
},(err)=>{ },(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); expect(err.code).assertEqual(0);
}) })
}) })
function subscribeCallBack(err, data) { 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") { if(data.event == "ACTS_RegisterEvent_First") {
flag = true; flag = true;
expect(data.parameters.message).assertContain("Error message:Cannot read property terminateSelf"); expect(data.parameters.message).assertContain("Error message:Cannot read property terminateSelf");
...@@ -73,7 +70,9 @@ export default function abilityTest() { ...@@ -73,7 +70,9 @@ export default function abilityTest() {
function unSubscribeCallback() { function unSubscribeCallback() {
console.debug("====>Acts_RegisterJsErrorCallback_0100 unSubscribeCallback"); console.debug("====>Acts_RegisterJsErrorCallback_0100 unSubscribeCallback");
setTimeout(() => {done();}, 800); setTimeout(()=>{
done();
}, 800);
} }
setTimeout(()=>{ setTimeout(()=>{
...@@ -104,7 +103,7 @@ export default function abilityTest() { ...@@ -104,7 +103,7 @@ export default function abilityTest() {
abilityName: "EntryAbility", abilityName: "EntryAbility",
action: "Acts_RegisterJsErrorCallback_0200" action: "Acts_RegisterJsErrorCallback_0200"
},(err)=>{ },(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); expect(err.code).assertEqual(0);
}) })
}) })
...@@ -112,11 +111,12 @@ export default function abilityTest() { ...@@ -112,11 +111,12 @@ export default function abilityTest() {
var msg = {"ACTS_RegisterEvent_First": false, "ACTS_RegisterEvent_Second": false} var msg = {"ACTS_RegisterEvent_First": false, "ACTS_RegisterEvent_Second": false}
function subscribeCallBack(err, data) { function subscribeCallBack(err, data) {
if (data.event === 'ACTS_RegisterEvent_First') { 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"); expect(data.parameters.message).assertContain("Error message:Cannot read property terminateSelf");
msg["ACTS_RegisterEvent_First"] = true; msg["ACTS_RegisterEvent_First"] = true;
} else if (data.event === 'ACTS_RegisterEvent_Second') { } 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.name).assertEqual("TypeError");
expect(data.parameters.message.message).assertEqual("Cannot read property terminateSelf of undefined"); expect(data.parameters.message.message).assertEqual("Cannot read property terminateSelf of undefined");
expect(data.parameters.message.stack).assertContain("at anonymous"); expect(data.parameters.message.stack).assertContain("at anonymous");
...@@ -130,7 +130,7 @@ export default function abilityTest() { ...@@ -130,7 +130,7 @@ export default function abilityTest() {
} }
function unSubscribeCallback() { function unSubscribeCallback() {
setTimeout(() => { setTimeout(()=>{
console.debug("====>Acts_RegisterJsErrorCallback_0200 unSubscribeCallback"); console.debug("====>Acts_RegisterJsErrorCallback_0200 unSubscribeCallback");
done(); done();
}, 800); }, 800);
...@@ -236,12 +236,12 @@ export default function abilityTest() { ...@@ -236,12 +236,12 @@ export default function abilityTest() {
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).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); expect(err.code).assertEqual(401);
done(); done();
}) })
} catch (err) { } 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); expect(err.code).assertEqual(401);
console.info("====>Acts_UnregisterJsErrorCallback_0100 end"); console.info("====>Acts_UnregisterJsErrorCallback_0100 end");
done(); done();
...@@ -262,12 +262,12 @@ export default function abilityTest() { ...@@ -262,12 +262,12 @@ export default function abilityTest() {
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).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); expect(err.code).assertEqual(401);
done(); done();
}) })
} catch (err) { } 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); expect(err.code).assertEqual(401);
console.info("====>Acts_UnregisterJsErrorCallback_0200 end"); console.info("====>Acts_UnregisterJsErrorCallback_0200 end");
done(); done();
...@@ -286,7 +286,7 @@ export default function abilityTest() { ...@@ -286,7 +286,7 @@ export default function abilityTest() {
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).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); expect(err.code).assertEqual(401);
done(); done();
}) })
...@@ -304,7 +304,7 @@ export default function abilityTest() { ...@@ -304,7 +304,7 @@ export default function abilityTest() {
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).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); expect(err.code).assertEqual(401);
done(); done();
}) })
...@@ -322,7 +322,7 @@ export default function abilityTest() { ...@@ -322,7 +322,7 @@ export default function abilityTest() {
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).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); expect(err.code).assertEqual(401);
done(); done();
}) })
...@@ -340,7 +340,7 @@ export default function abilityTest() { ...@@ -340,7 +340,7 @@ export default function abilityTest() {
expect().assertFail(); expect().assertFail();
done(); done();
}).catch((err)=>{ }).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); expect(err.code).assertEqual(16000003);
done(); done();
}) })
...@@ -361,12 +361,12 @@ export default function abilityTest() { ...@@ -361,12 +361,12 @@ export default function abilityTest() {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}).catch((err)=>{ }).catch((err)=>{
console.info("====>Acts_UnregisterJsErrorCallback_0700 err:" + JSON.stringify(err)); console.info("====>Acts_UnregisterJsErrorCallback_0700 err: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}) })
} catch (err) { } catch (err) {
console.info("====>Acts_UnregisterJsErrorCallback_0700 catch:" + JSON.stringify(err)); console.info("====>Acts_UnregisterJsErrorCallback_0700 catch: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
} }
...@@ -392,7 +392,7 @@ export default function abilityTest() { ...@@ -392,7 +392,7 @@ export default function abilityTest() {
abilityName: "EntryAbility", abilityName: "EntryAbility",
action: "Acts_UnregisterJsErrorCallback_0800" action: "Acts_UnregisterJsErrorCallback_0800"
},(err)=>{ },(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); expect(err.code).assertEqual(0);
}) })
}) })
...@@ -400,11 +400,13 @@ export default function abilityTest() { ...@@ -400,11 +400,13 @@ export default function abilityTest() {
var msg = {"ACTS_RegisterEvent_First": false, "ACTS_RegisterEvent_Second": false} var msg = {"ACTS_RegisterEvent_First": false, "ACTS_RegisterEvent_Second": false}
function subscribeCallBack(err, data) { function subscribeCallBack(err, data) {
if (data.event === 'ACTS_RegisterEvent_First') { 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"); expect(data.parameters.message).assertContain("Error message:Cannot read property terminateSelf");
msg["ACTS_RegisterEvent_First"] = true; msg["ACTS_RegisterEvent_First"] = true;
} else if (data.event === 'ACTS_RegisterEvent_Second') { } 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.name).assertEqual("TypeError");
expect(data.parameters.message.message).assertEqual("Cannot read property terminateSelf of undefined"); expect(data.parameters.message.message).assertEqual("Cannot read property terminateSelf of undefined");
expect(data.parameters.message.stack).assertContain("at anonymous"); 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.
先完成此消息的编辑!
想要评论请 注册