Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6be2d99e
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看板
提交
6be2d99e
编写于
4月 19, 2023
作者:
U
unknown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add user
Signed-off-by:
N
unknown
<
sijunjie@huawei.com
>
上级
78d71136
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
146 deletion
+27
-146
ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts
...lehaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts
+0
-3
ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts
...lehaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts
+1
-1
ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets
...lesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets
+26
-142
未找到文件。
ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts
浏览文件 @
6be2d99e
...
...
@@ -53,9 +53,6 @@ export default class MainAbility1 extends Ability {
console
.
log
(
"
[Demo] AbilityLifecycleCallback1 onWindowStageDestroy ability:
"
+
JSON
.
stringify
(
ability
));
let
abilityname
=
ability
.
context
.
abilityInfo
.
name
;
console
.
log
(
"
[Demo] AbilityLifecycleCallback1 onWindowStageDestroy abilityname:
"
+
JSON
.
stringify
(
abilityname
));
console
.
log
(
"
[Demo]
"
+
abilityname
+
"
onWindowStageDestroy
"
);
listKey1
.
push
(
abilityname
+
"
onWindowStageDestroy
"
);
console
.
log
(
"
[Demo] 3listKey1:
"
+
JSON
.
stringify
(
listKey1
));
},
...
...
ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts
浏览文件 @
6be2d99e
...
...
@@ -104,10 +104,10 @@ export default class MainAbility4 extends Ability {
globalThis
.
applicationContext4
=
this
.
context
.
getApplicationContext
();
let
lifecycleid
=
globalThis
.
applicationContext4
.
registerAbilityLifecycleCallback
(
AbilityLifecycleCallback
);
console
.
log
(
"
[Demo] registerAbilityLifecycleCallback4 number:
"
+
JSON
.
stringify
(
lifecycleid
));
globalThis
.
callbackid4
=
lifecycleid
;
setTimeout
(
function
()
{
console
.
log
(
"
[Demo] registerAbilityLifecycleCallback4 listKey :
"
+
JSON
.
stringify
(
listKey4
));
globalThis
.
list4
=
listKey4
;
globalThis
.
callbackid4
=
lifecycleid
;
},
1500
);
}
...
...
ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets
浏览文件 @
6be2d99e
...
...
@@ -1455,11 +1455,8 @@ export default function lifecycleTest() {
it("Singlehap_LifeCycleTest_2100", 0, async function (done) {
console.log("------------Singlehap_LifeCycleTest_2100 START-------------");
TAG = "Singlehap_LifeCycleTest_2100";
var id1;
var id2;
var id3;
var id4;
var str = {
let id1;
let str = {
"bundleName": "com.example.lifecycle_xts",
"abilityName": "MainAbility1",
}
...
...
@@ -1467,181 +1464,68 @@ export default function lifecycleTest() {
.then((data) => {
console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => {
console.error(TAG + ' start failed. Cause: ' + JSON.stringify(error));
})
console.error(TAG + ' start failed. Cause: ' + JSON.stringify(error));
})
setTimeout(function () {
var str
1
= {
var str
2
= {
"bundleName": "com.example.lifecycle_xts",
"abilityName": "MainAbility
1
2",
"abilityName": "MainAbility2",
}
globalThis.abilityContext.startAbility(str
1
)
globalThis.abilityContext.startAbility(str
2
)
.then((data) => {
console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => {
console.error(TAG + ' start failed. Cause: ' + JSON.stringify(error));
})
setTimeout(function () {
var str2 = {
"bundleName": "com.example.lifecycle_xts",
"abilityName": "MainAbility2",
}
globalThis.abilityContext.startAbility(str2)
.then((data) => {
console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => {
console.error(TAG + ' start failed. Cause: ' + JSON.stringify(error));
})
}, 500);
}, 500);
})
}, 1000);
setTimeout(function () {
console.log(TAG + " firstCallback listKey1 : " + JSON.stringify(globalThis.list1));
console.log(TAG + " firstCallback callbackid1 : " + JSON.stringify(globalThis.callbackid1));
console.log(TAG + " firstCallback listKey12 : " + JSON.stringify(globalThis.list12));
console.log(TAG + " firstCallback callbackid12 : " + JSON.stringify(globalThis.callbackid12));
id1 = globalThis.callbackid1;
console.log(TAG + " firstCallback id1 : " + JSON.stringify(id1));
id2 = globalThis.callbackid12;
console.log(TAG + " firstCallback id12 : " + JSON.stringify(id2));
var para = {
resultCode: 2100,
want: {
"abilityName": "MainAbility1
2
",
"abilityName": "MainAbility1",
"bundleName": "com.example.lifecycle_xts"
}
}
console.log(TAG + " terminateSelfwithresult para: " + JSON.stringify(para));
globalThis.ability1
2
.terminateSelfWithResult(para)
globalThis.ability1
context
.terminateSelfWithResult(para)
.then((data) => {
console.log(TAG + " terminateSelfwithresult successful data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + " terminateSelfwithresult error: " + JSON.stringify(error));
});
setTimeout(function () {
var para = {
resultCode: 2100,
want: {
"abilityName": "MainAbility1",
"bundleName": "com.example.lifecycle_xts"
}
}
console.log(TAG + " terminateSelfwithresult para: " + JSON.stringify(para));
globalThis.ability1context.terminateSelfWithResult(para)
.then((data) => {
console.log(TAG + " terminateSelfwithresult successful data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + " terminateSelfwithresult error: " + JSON.stringify(error));
});
}, 500);
}, 3000);
setTimeout(function () {
var str = {
"bundleName": "com.example.lifecycle_xts",
"abilityName": "MainAbility1",
}
globalThis.abilityContext.startAbility(str)
.then((data) => {
console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => {
console.error(TAG + ' start failed. Cause: ' + JSON.stringify(error));
})
setTimeout(function () {
var str1 = {
"bundleName": "com.example.lifecycle_xts",
"abilityName": "MainAbility12",
}
globalThis.abilityContext.startAbility(str1)
.then((data) => {
console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => {
console.error(TAG + ' start failed. Cause: ' + JSON.stringify(error));
})
setTimeout(function () {
var str2 = {
"bundleName": "com.example.lifecycle_xts",
"abilityName": "MainAbility2",
}
globalThis.abilityContext.startAbility(str2)
.then((data) => {
console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => {
console.error(TAG + ' start failed. Cause: ' + JSON.stringify(error));
})
}, 500);
}, 500);
}, 4000);
}, 4500);
setTimeout(function () {
console.log(TAG + " secondCallback listKey1 : " + JSON.stringify(globalThis.list1));
let templist1 = globalThis.list1;
console.log(TAG + " secondCallback templist1 : " + JSON.stringify(templist1));
console.log(TAG + " secondCallback callbackid1 : " + JSON.stringify(globalThis.callbackid1));
console.log(TAG + " secondCallback listKey12 : " + JSON.stringify(globalThis.list12));
let templist2 = globalThis.list12;
console.log(TAG + " secondCallback templist2 : " + JSON.stringify(templist2));
console.log(TAG + " secondCallback callbackid12 : " + JSON.stringify(globalThis.callbackid12));
id3 = globalThis.callbackid1;
console.log(TAG + " secondCallback id1 : " + JSON.stringify(id3));
id4 = globalThis.callbackid12;
console.log(TAG + " secondCallback id12 : " + JSON.stringify(id4));
var strtemp = "";
var listtemp = [];
var listtemp12 = [];
for (var i = 0; i < templist1.length; i++) {
strtemp = templist1[i].substring(0, 13);
if (strtemp === "MainAbility2 ") {
listtemp.push(templist1[i]);
} else if (strtemp === "MainAbility12") {
listtemp12.push(templist1[i]);
}
}
console.log(TAG + " listtemp is :" + JSON.stringify(listtemp));
console.log(TAG + " listtemp12 is :" + JSON.stringify(listtemp12));
setTimeout(function () {
var strtemp1 = "";
var listtemp1 = [];
for (var j = 0; j < templist2.length; j++) {
strtemp1 = templist2[j].substring(0, 12);
if (strtemp1 === "MainAbility2") {
listtemp1.push(templist2[j]);
}
}
console.log(TAG + " listtemp1 is :" + JSON.stringify(listtemp1));
let exlist = listtemp;
let exlist12 = listtemp12;
let exlist1 = listtemp1;
expect(exlist[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[2]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[3]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[4]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[5]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist12[0]).assertEqual("MainAbility12 onAbilityCreate");
expect(exlist12[1]).assertEqual("MainAbility12 onWindowStageCreate");
expect(exlist12[2]).assertEqual("MainAbility12 onAbilityForeground");
expect(exlist12[3]).assertEqual("MainAbility12 onAbilityBackground");
expect(exlist12[4]).assertEqual("MainAbility12 onAbilityForeground");
expect(exlist1[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[2]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist1[3]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist1[4]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist1[5]).assertEqual("MainAbility2 onAbilityDestroy");
expect(id1 + 1).assertEqual(id2);
expect(id3 + 1).assertEqual(id4);
globalThis.applicationContext12
.unregisterAbilityLifecycleCallback(globalThis.callbackid12, (error, data) => {
console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) +
",data: " + JSON.stringify(data));
});
globalThis.applicationContext1
.unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => {
console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) +
",data: " + JSON.stringify(data));
console.log("------------Singlehap_LifeCycleTest_2100 END-------------");
done();
});
}, 100);
let exlist = listtemp;
expect(exlist[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[2]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[3]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[4]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[5]).assertEqual("MainAbility2 onAbilityDestroy");
globalThis.applicationContext1
.unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => {
console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) +
",data: " + JSON.stringify(data));
console.log("------------Singlehap_LifeCycleTest_2100 END-------------");
done();
});
}, 7000);
});
})
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录