Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
83c0b058
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看板
未验证
提交
83c0b058
编写于
8月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9908 为UIExtensionContentSession中的StartAbility和StartAbilityForResult接口增加XTS测试用例
Merge pull request !9908 from 夏良伟/UISession
上级
7699d90d
54214ec8
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
1162 addition
and
2 deletion
+1162
-2
ability/ability_runtime/actsuiextensiontest/BUILD.gn
ability/ability_runtime/actsuiextensiontest/BUILD.gn
+1
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/AppScope/app.json
...actsuiextensiontest/actsabilityusertest/AppScope/app.json
+21
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/AppScope/resources/base/element/string.json
...ilityusertest/AppScope/resources/base/element/string.json
+8
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/AppScope/resources/base/media/app_icon.png
...bilityusertest/AppScope/resources/base/media/app_icon.png
+0
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/BUILD.gn
..._runtime/actsuiextensiontest/actsabilityusertest/BUILD.gn
+44
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/Test.json
...runtime/actsuiextensiontest/actsabilityusertest/Test.json
+20
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/Application/AbilityStage.ts
...tyusertest/entry/src/main/ets/Application/AbilityStage.ts
+7
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility/MainAbility.ts
...ityusertest/entry/src/main/ets/MainAbility/MainAbility.ts
+43
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility2/MainAbility2.ts
...yusertest/entry/src/main/ets/MainAbility2/MainAbility2.ts
+73
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility3/MainAbility3.ts
...yusertest/entry/src/main/ets/MainAbility3/MainAbility3.ts
+72
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/pages/index.ets
...st/actsabilityusertest/entry/src/main/ets/pages/index.ets
+32
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/pages/index2.ets
...t/actsabilityusertest/entry/src/main/ets/pages/index2.ets
+32
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/pages/index3.ets
...t/actsabilityusertest/entry/src/main/ets/pages/index3.ets
+32
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/module.json
...ensiontest/actsabilityusertest/entry/src/main/module.json
+53
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/resources/base/element/string.json
...sertest/entry/src/main/resources/base/element/string.json
+40
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/resources/base/media/icon.png
...lityusertest/entry/src/main/resources/base/media/icon.png
+0
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+5
-0
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/signature/openharmony_sx.p7b
...siontest/actsabilityusertest/signature/openharmony_sx.p7b
+0
-0
ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets
...st/uiextensionprovider/entry/src/main/ets/pages/index.ets
+163
-1
ability/ability_runtime/actsuiextensiontest/uiextensiontest/Test.json
...ity_runtime/actsuiextensiontest/uiextensiontest/Test.json
+9
-1
ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/TestAbility.ets
...ensiontest/entry/src/main/ets/TestAbility/TestAbility.ets
+5
-0
ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/Ability.test.ets
.../uiextensiontest/entry/src/main/ets/test/Ability.test.ets
+502
-0
未找到文件。
ability/ability_runtime/actsuiextensiontest/BUILD.gn
浏览文件 @
83c0b058
...
@@ -17,6 +17,7 @@ group("actsuiextensiontest") {
...
@@ -17,6 +17,7 @@ group("actsuiextensiontest") {
testonly = true
testonly = true
if (is_standard_system) {
if (is_standard_system) {
deps = [
deps = [
"actsabilityusertest:StartAbilityByUIContentSession",
"uiextensionprovider:UIExtensionProvider",
"uiextensionprovider:UIExtensionProvider",
"uiextensiontest:UIExtensionTest",
"uiextensiontest:UIExtensionTest",
]
]
...
...
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/AppScope/app.json
0 → 100644
浏览文件 @
83c0b058
{
"app"
:
{
"bundleName"
:
"com.example.actsabilityusertest"
,
"vendor"
:
"huawei"
,
"versionCode"
:
1000000
,
"versionName"
:
"1.0.0"
,
"debug"
:
false
,
"icon"
:
"$media:icon"
,
"label"
:
"$string:app_name"
,
"description"
:
"$string:description_application"
,
"distributedNotificationEnabled"
:
true
,
"keepAlive"
:
true
,
"singleUser"
:
true
,
"minAPIVersion"
:
9
,
"targetAPIVersion"
:
9
,
"car"
:
{
"apiCompatibleVersion"
:
9
,
"singleUser"
:
false
}
}
}
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/AppScope/resources/base/element/string.json
0 → 100644
浏览文件 @
83c0b058
{
"string"
:
[
{
"name"
:
"app_name"
,
"value"
:
"actsabilityusertest"
}
]
}
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/AppScope/resources/base/media/app_icon.png
0 → 100644
浏览文件 @
83c0b058
6.6 KB
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/BUILD.gn
0 → 100644
浏览文件 @
83c0b058
# Copyright (c) 2023 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("StartAbilityByUIContentSession") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":startabilitybyuicontentsession_js_assets",
":startabilitybyuicontentsession_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "StartAbilityByUIContentSession"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("startabilitybyuicontentsession_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("startabilitybyuicontentsession_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("startabilitybyuicontentsession_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":startabilitybyuicontentsession_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/Test.json
0 → 100644
浏览文件 @
83c0b058
{
"description"
:
"Configuration for aceceshi Tests"
,
"driver"
:
{
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"600000"
,
"bundle-name"
:
"com.example.actsabilityusertest"
,
"module-name"
:
"entry"
,
"shell-timeout"
:
"600000"
},
"kits"
:
[
{
"test-file-name"
:
[
"StartAbilityByUIContentSession.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}
]
}
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/Application/AbilityStage.ts
0 → 100644
浏览文件 @
83c0b058
import
AbilityStage
from
"
@ohos.app.ability.AbilityStage
"
export
default
class
MyAbilityStage
extends
AbilityStage
{
onCreate
()
{
console
.
log
(
"
[Demo] MyAbilityStage onCreate
"
)
}
}
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility/MainAbility.ts
0 → 100644
浏览文件 @
83c0b058
/*
* Copyright (c) 2023 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
Ability
from
'
@ohos.app.ability.UIAbility
'
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
MainAbility onCreate
'
);
}
onDestroy
()
{
console
.
log
(
'
MainAbility onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
MainAbility onWindowStageCreate
'
);
windowStage
.
setUIContent
(
this
.
context
,
'
pages/index
'
,
null
);
}
onWindowStageDestroy
()
{
console
.
log
(
'
MainAbility onWindowStageDestroy
'
);
}
onForeground
()
{
console
.
log
(
'
MainAbility onForeground
'
);
}
onBackground
()
{
console
.
log
(
'
MainAbility onBackground
'
);
}
};
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility2/MainAbility2.ts
0 → 100644
浏览文件 @
83c0b058
/*
* Copyright (c) 2023 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
Ability
from
'
@ohos.app.ability.UIAbility
'
;
import
commonEventManager
from
'
@ohos.commonEventManager
'
;
const
sleepTimeOne
=
1000
;
function
publishCallBack
()
{
console
.
log
(
'
====>Publish CallBack ACTS_StartAbilityEvent====>
'
);
globalThis
.
ability2Context
.
terminateSelf
().
then
(()
=>
{
console
.
log
(
'
====>terminateSelf success====>
'
);
});
}
function
timeout
()
{
globalThis
.
ability2Context
.
startAbility
(
{
bundleName
:
'
com.example.uiextensiontest
'
,
abilityName
:
'
TestAbility
'
,
}
).
then
(()
=>
{
console
.
log
(
'
====>start com.example.uiextensiontest.TestAbility finish====>
'
);
});
}
export
default
class
MainAbility2
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
MainAbility2 onCreate
'
);
}
onDestroy
()
{
// Ability is destroying, release resources for this ability
console
.
log
(
'
MainAbility2 onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
'
MainAbility2 onWindowStageCreate
'
);
windowStage
.
setUIContent
(
this
.
context
,
'
pages/index2
'
,
null
);
}
onWindowStageDestroy
()
{
// Main window is destroyed, release UI related resources
console
.
log
(
'
MainAbility2 onWindowStageDestroy
'
);
}
onForeground
()
{
// Ability has brought to foreground
console
.
log
(
'
MainAbility2 onForeground
'
);
globalThis
.
ability2Context
=
this
.
context
;
setTimeout
(
timeout
,
sleepTimeOne
);
}
onBackground
()
{
// Ability has back to background
console
.
log
(
'
MainAbility2 onBackground
'
);
let
onResultEvent
=
'
ACTS_UIExtension_StartAbility_OnResult
'
;
commonEventManager
.
publish
(
onResultEvent
,
publishCallBack
);
}
};
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility3/MainAbility3.ts
0 → 100644
浏览文件 @
83c0b058
/*
* Copyright (c) 2023 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
Ability
from
'
@ohos.app.ability.UIAbility
'
;
const
sleepTimeOne
=
1000
;
function
timeout
()
{
globalThis
.
ability3Context
.
startAbility
(
{
bundleName
:
'
com.example.uiextensiontest
'
,
abilityName
:
'
TestAbility
'
}
).
then
(()
=>
{
console
.
log
(
'
====>start com.example.uiextensiontest.TestAbility finish====>
'
);
});
}
export
default
class
MainAbility3
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
MainAbility3 onCreate
'
);
}
onDestroy
()
{
// Ability is destroying, release resources for this ability
console
.
log
(
'
MainAbility3 onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
'
MainAbility3 onWindowStageCreate
'
);
windowStage
.
setUIContent
(
this
.
context
,
'
pages/index3
'
,
null
);
}
onWindowStageDestroy
()
{
// Main window is destroyed, release UI related resources
console
.
log
(
'
MainAbility3 onWindowStageDestroy
'
);
}
onForeground
()
{
// Ability has brought to foreground
console
.
log
(
'
MainAbility3 onForeground
'
);
globalThis
.
ability3Context
=
this
.
context
;
setTimeout
(
timeout
,
sleepTimeOne
);
}
onBackground
()
{
// Ability has back to background
console
.
log
(
'
MainAbility3 onBackground
'
);
globalThis
.
ability3Context
.
terminateSelfWithResult
(
{
resultCode
:
1
,
want
:{
action
:
'
ACTION
'
}
},
()
=>
{
console
.
debug
(
'
====>terminateSelfWithResult success====>
'
);
});
}
};
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/pages/index.ets
0 → 100644
浏览文件 @
83c0b058
/*
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/pages/index2.ets
0 → 100644
浏览文件 @
83c0b058
/*
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World2'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/pages/index3.ets
0 → 100644
浏览文件 @
83c0b058
/*
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World3'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/module.json
0 → 100644
浏览文件 @
83c0b058
{
"module"
:
{
"name"
:
"entry"
,
"type"
:
"entry"
,
"srcEntrance"
:
"./ets/Application/AbilityStage.ts"
,
"description"
:
"$string:entry_desc"
,
"mainElement"
:
"MainAbility"
,
"deviceTypes"
:
[
"default"
,
"tablet"
],
"deliveryWithInstall"
:
true
,
"installationFree"
:
false
,
"pages"
:
"$profile:main_pages"
,
"uiSyntax"
:
"ets"
,
"abilities"
:
[
{
"name"
:
"MainAbility"
,
"srcEntrance"
:
"./ets/MainAbility/MainAbility.ts"
,
"description"
:
"$string:MainAbility_desc"
,
"icon"
:
"$media:icon"
,
"label"
:
"$string:MainAbility_label"
,
"visible"
:
true
,
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
]
},
{
"name"
:
"MainAbility2"
,
"srcEntrance"
:
"./ets/MainAbility2/MainAbility2.ts"
,
"description"
:
"$string:MainAbility2_desc"
,
"icon"
:
"$media:icon"
,
"label"
:
"$string:MainAbility2_label"
,
"visible"
:
true
},
{
"name"
:
"MainAbility3"
,
"srcEntrance"
:
"./ets/MainAbility3/MainAbility3.ts"
,
"description"
:
"$string:MainAbility3_desc"
,
"icon"
:
"$media:icon"
,
"label"
:
"$string:MainAbility3_label"
,
"visible"
:
true
}
]
}
}
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
83c0b058
{
"string"
:
[
{
"name"
:
"entry_desc"
,
"value"
:
"description"
},
{
"name"
:
"MainAbility_desc"
,
"value"
:
"description"
},
{
"name"
:
"MainAbility_label"
,
"value"
:
"label"
},
{
"name"
:
"MainAbility2_desc"
,
"value"
:
"description"
},
{
"name"
:
"MainAbility2_label"
,
"value"
:
"label"
},
{
"name"
:
"MainAbility3_desc"
,
"value"
:
"description"
},
{
"name"
:
"MainAbility3_label"
,
"value"
:
"label"
},
{
"name"
:
"app_name"
,
"value"
:
"actsabilityusertest"
},
{
"name"
:
"description_application"
,
"value"
:
"demo for test"
}
]
}
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
83c0b058
6.6 KB
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/resources/base/profile/main_pages.json
0 → 100644
浏览文件 @
83c0b058
{
"src"
:
[
"pages/index"
]
}
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/actsabilityusertest/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
83c0b058
文件已添加
ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets
浏览文件 @
83c0b058
...
@@ -18,6 +18,7 @@ import commonEventManager from '@ohos.commonEventManager'
...
@@ -18,6 +18,7 @@ import commonEventManager from '@ohos.commonEventManager'
import Logger from '../model/Logger'
import Logger from '../model/Logger'
import common from '@ohos.app.ability.common';
import common from '@ohos.app.ability.common';
let context= getContext(this) as common.UIExtensionContext;
let context= getContext(this) as common.UIExtensionContext;
const TAG: string = '[UIExtAbility]'
const TAG: string = '[UIExtAbility]'
const sleepTimeOne = 1000;
const sleepTimeOne = 1000;
...
@@ -50,10 +51,24 @@ struct Index {
...
@@ -50,10 +51,24 @@ struct Index {
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let terminateSelfWithResultEvent = 'ACTS_UIExtension_TerminateSelfWithResult';
let terminateSelfWithResultEvent = 'ACTS_UIExtension_TerminateSelfWithResult';
let sendDataEvent = 'ACTS_UIExtension_SendData';
let sendDataEvent = 'ACTS_UIExtension_SendData';
let startAbilityEvent1 = 'ACTS_UIExtension_StartAbility_001';
let startAbilityEvent2 = 'ACTS_UIExtension_StartAbility_002';
let startAbilityEvent3 = 'ACTS_UIExtension_StartAbility_003';
let startAbilityEvent4 = 'ACTS_UIExtension_StartAbility_004';
let startAbilityForResultEvent1 = 'ACTS_UIExtension_StartAbilityForResult_001';
let startAbilityForResultEvent2 = 'ACTS_UIExtension_StartAbilityForResult_002';
let startAbilityForResultEvent3 = 'ACTS_UIExtension_StartAbilityForResult_003';
let startAbilityForResultEvent4 = 'ACTS_UIExtension_StartAbilityForResult_004';
var subscriber;
var subscriber;
var startresult = false;
var subscribeInfo = {
var subscribeInfo = {
events: [terminateSelfWithResultEvent, sendDataEvent]
events: [startAbilityEvent1, startAbilityEvent2, startAbilityEvent3,
startAbilityEvent4, startAbilityForResultEvent1,
startAbilityForResultEvent2, startAbilityForResultEvent3,
startAbilityForResultEvent4,
terminateSelfWithResultEvent, sendDataEvent]
}
}
commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
...
@@ -100,7 +115,154 @@ struct Index {
...
@@ -100,7 +115,154 @@ struct Index {
}).catch((err)=>{
}).catch((err)=>{
console.log(TAG + "setWindowPrivacyModeFalsePromise : " + JSON.stringify(err));
console.log(TAG + "setWindowPrivacyModeFalsePromise : " + JSON.stringify(err));
})
})
} else if(data.event == startAbilityEvent1) {
this.session.startAbility(
{
bundleName: 'com.example.actsabilityusertest',
abilityName: 'MainAbility2',
}, () => {
console.log(TAG + "====>startAbilityEvent1 end====>" );
});
commonEventManager.unsubscribe(subscriber, async (err, data) => {
console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data));
});
} else if(data.event == startAbilityEvent2) {
this.session.startAbility(
{
bundleName: 'com.example.actsabilityusertest',
abilityName: 'MainAbility2',
},
{
windowMode: 0
}, () => {
console.log(TAG + "====>startAbilityEvent2 end====>" );
});
commonEventManager.unsubscribe(subscriber, async (err, data) => {
console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data));
});
} else if(data.event == startAbilityEvent3) {
this.session.startAbility(
{
bundleName: 'com.example.actsabilityusertest',
abilityName: 'MainAbility2',
}).then((data)=>{
console.log(TAG + "====>startAbilityEvent3 end====>");
console.log(TAG + "====>data is====>" + JSON.stringify(data));
});
commonEventManager.unsubscribe(subscriber, async (err, data) => {
console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data));
});
} else if(data.event == startAbilityEvent4) {
this.session.startAbility(
{
bundleName: 'com.example.actsabilityusertest',
abilityName: 'MainAbility2',
},
{
windowMode: 0
}).then((data)=>{
console.log(TAG + "====>startAbilityEvent4 end====>");
console.log(TAG + "====>data is====>" + JSON.stringify(data));
});
commonEventManager.unsubscribe(subscriber, async (err, data) => {
console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data));
});
} else if(data.event == startAbilityForResultEvent1) {
var flag = true
this.session.startAbilityForResult(
{
bundleName: 'com.example.actsabilityusertest',
abilityName: 'MainAbility3'
}, (err,data) => {
console.log(TAG + "====>startAbilityForResultEvent1 end====>" + JSON.stringify(data));
if(data.resultCode == 1 && data.want.action=='ACTION') {
commonEventManager.publish('ACTS_UIExtension_StartAbilityForResult_001_OnResult', (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbilityForResult_001_OnResult failed,
code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'ACTS_UIExtension_StartAbilityForResult_001_OnResult success');
}
});
}
})
commonEventManager.unsubscribe(subscriber, async (err, data) => {
console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data));
});
} else if(data.event == startAbilityForResultEvent2) {
var flag = true
this.session.startAbilityForResult(
{
bundleName: 'com.example.actsabilityusertest',
abilityName: 'MainAbility3'
},
{
windowMode: 0
}, (err,data) => {
console.log(TAG + "====>startAbilityForResultEvent2 end====>" + JSON.stringify(data));
if(data.resultCode == 1 && data.want.action=='ACTION') {
commonEventManager.publish('ACTS_UIExtension_StartAbilityForResult_002_OnResult', (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbilityForResult_002_OnResult failed,
code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'ACTS_UIExtension_StartAbilityForResult_002_OnResult success');
}
});
}
})
commonEventManager.unsubscribe(subscriber, async (err, data) => {
console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data));
});
} else if(data.event == startAbilityForResultEvent3) {
var flag = true
this.session.startAbilityForResult(
{
bundleName: 'com.example.actsabilityusertest',
abilityName: 'MainAbility3'
}).then((data) => {
console.log(TAG + "====>startAbilityForResultEvent3 end====>" + JSON.stringify(data));
if(data.resultCode == 1 && data.want.action=='ACTION') {
commonEventManager.publish('ACTS_UIExtension_StartAbilityForResult_003_OnResult', (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbilityForResult_003_OnResult failed,
code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'ACTS_UIExtension_StartAbilityForResult_003_OnResult success');
}
});
}
})
commonEventManager.unsubscribe(subscriber, async (err, data) => {
console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data));
});
} else if(data.event == startAbilityForResultEvent4) {
var flag = true
this.session.startAbilityForResult(
{
bundleName: 'com.example.actsabilityusertest',
abilityName: 'MainAbility3'
},
{
windowMode: 0
}).then((data) => {
console.log(TAG + "====>startAbilityForResultEvent4 end====>" + JSON.stringify(data));
if(data.resultCode == 1 && data.want.action=='ACTION') {
commonEventManager.publish('ACTS_UIExtension_StartAbilityForResult_004_OnResult', (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbilityForResult_004_OnResult failed,
code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'ACTS_UIExtension_StartAbilityForResult_004_OnResult success');
}
});
}
})
commonEventManager.unsubscribe(subscriber, async (err, data) => {
console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data));
});
}
}
});
});
}).catch((error) => {
}).catch((error) => {
console.log(TAG + "createSubscriber error : " + JSON.stringify(error));
console.log(TAG + "createSubscriber error : " + JSON.stringify(error));
...
...
ability/ability_runtime/actsuiextensiontest/uiextensiontest/Test.json
浏览文件 @
83c0b058
...
@@ -12,10 +12,18 @@
...
@@ -12,10 +12,18 @@
{
{
"test-file-name"
:
[
"test-file-name"
:
[
"UIExtensionTest.hap"
,
"UIExtensionTest.hap"
,
"UIextensionProvider.hap"
"UIExtensionProvider.hap"
,
"StartAbilityByUIContentSession.hap"
],
],
"type"
:
"AppInstallKit"
,
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
"cleanup-apps"
:
true
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"power-shell wakeup"
,
"power-shell setmode 602"
]
}
}
]
]
}
}
...
...
ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/TestAbility.ets
浏览文件 @
83c0b058
...
@@ -61,4 +61,9 @@ export default class TestAbility extends Ability {
...
@@ -61,4 +61,9 @@ export default class TestAbility extends Ability {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
onNewWant(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onNewWant');
}
}
}
\ No newline at end of file
ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
83c0b058
...
@@ -144,5 +144,507 @@ export default function abilityTest() {
...
@@ -144,5 +144,507 @@ export default function abilityTest() {
done();
done();
})
})
})
})
/*
* @tc.number : ACTS_UIExtension_StartAbility_001
* @tc.name : start new ability by UIContentSession
* @tc.desc : Starting mainability2 by UIContentSession with startability succeeded.(callback)
*/
it('ACTS_UIExtension_StartAbility_001',0, async function (done) {
TAG = 'ACTS_UIExtension_StartAbility_001 == ';
console.log(TAG + "begin");
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let onResultEvent = 'ACTS_UIExtension_StartAbility_OnResult';
let startAbilityEvent = 'ACTS_UIExtension_StartAbility_001';
var flag = true
function UnSubscribeCallback() {
console.log(TAG + "UnSubscribeInfoCallback");
flag = false;
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'StartAbility_001 - timeout');
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback)
}
}
var subscriber;
var subscribeInfo = {
events: [appearEvent, onResultEvent]
}
await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
subscriber = data;
commonEventManager.subscribe(subscriber, async (err, data) => {
console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data));
if (data.event == appearEvent) {
commonEventManager.publish(startAbilityEvent, (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbility_001 failed, code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'publish ACTS_UIExtension_StartAbility_001 success');
}
});
} else if (data.event == onResultEvent) {
setTimeout(async () => {
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback);
}, sleepTimeOne);
}
});
}).catch((error) => {
console.log(TAG + "createSubscriber err : " + JSON.stringify(error));
expect().assertFail();
done();
})
setTimeout(timeout, 5000);
})
/*
* @tc.number : ACTS_UIExtension_StartAbility_002
* @tc.name : start new ability by UIContentSession
* @tc.desc : Starting mainability2 by UIContentSession with the parameter startability with options succeeded.(callback)
*/
it('ACTS_UIExtension_StartAbility_002',0, async function (done) {
TAG = 'ACTS_UIExtension_StartAbility_002 == ';
console.log(TAG + "begin");
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let onResultEvent = 'ACTS_UIExtension_StartAbility_OnResult';
let startAbilityOpsEvent = 'ACTS_UIExtension_StartAbility_002';
var flag = true
function UnSubscribeCallback() {
console.log(TAG + "UnSubscribeInfoCallback");
flag = false;
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'StartAbility_002 - timeout');
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback)
}
}
var subscriber;
var subscribeInfo = {
events: [appearEvent, onResultEvent]
}
await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
subscriber = data;
commonEventManager.subscribe(subscriber, async (err, data) => {
console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data));
if (data.event == appearEvent) {
commonEventManager.publish(startAbilityOpsEvent, (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbility_002 failed, code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'publish ACTS_UIExtension_StartAbility_002 success');
}
});
} else if (data.event == onResultEvent) {
setTimeout(async () => {
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback);
}, sleepTimeOne);
}
});
}).catch((error) => {
console.log(TAG + "createSubscriber err : " + JSON.stringify(error));
expect().assertFail();
done();
})
setTimeout(timeout, 5000);
})
/*
* @tc.number : ACTS_UIExtension_StartAbility_003
* @tc.name : start new ability by UIContentSession
* @tc.desc : Starting mainability2 by UIContentSession with startability succeeded.(promise)
*/
it('ACTS_UIExtension_StartAbility_003',0, async function (done) {
TAG = 'ACTS_UIExtension_StartAbility_003 == ';
console.log(TAG + "begin");
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let onResultEvent = 'ACTS_UIExtension_StartAbility_OnResult';
let startAbilityEventPromise = 'ACTS_UIExtension_StartAbility_003';
var flag = true
function UnSubscribeCallback() {
console.log(TAG + "UnSubscribeInfoCallback");
flag = false;
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'StartAbility_003 - timeout');
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback)
}
}
var subscriber;
var subscribeInfo = {
events: [appearEvent, onResultEvent]
}
await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
subscriber = data;
commonEventManager.subscribe(subscriber, async (err, data) => {
console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data));
if (data.event == appearEvent) {
commonEventManager.publish(startAbilityEventPromise, (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbility_003 failed, code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'publish ACTS_UIExtension_StartAbility_003 success');
}
});
} else if (data.event == onResultEvent) {
setTimeout(async () => {
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback);
}, sleepTimeOne);
}
});
}).catch((error) => {
console.log(TAG + "createSubscriber err : " + JSON.stringify(error));
expect().assertFail();
done();
})
setTimeout(timeout, 5000);
})
/*
* @tc.number : ACTS_UIExtension_StartAbility_004
* @tc.name : start new ability by UIContentSession
* @tc.desc : Starting mainability2 by UIContentSession with the parameter startability with options succeeded.(promise)
*/
it('ACTS_UIExtension_StartAbility_004',0, async function (done) {
TAG = 'ACTS_UIExtension_StartAbility_004 == ';
console.log(TAG + "begin");
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let onResultEvent = 'ACTS_UIExtension_StartAbility_OnResult';
let startAbilityOpsEventPromise = 'ACTS_UIExtension_StartAbility_004';
var flag = true
function UnSubscribeCallback() {
console.log(TAG + "UnSubscribeInfoCallback");
flag = false;
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'StartAbility_004 - timeout');
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback)
}
}
var subscriber;
var subscribeInfo = {
events: [appearEvent, onResultEvent]
}
await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
subscriber = data;
commonEventManager.subscribe(subscriber, async (err, data) => {
console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data));
if (data.event == appearEvent) {
commonEventManager.publish(startAbilityOpsEventPromise, (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbility_004 failed, code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'publish ACTS_UIExtension_StartAbility_004 success');
}
});
} else if (data.event == onResultEvent) {
setTimeout(async () => {
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback);
}, sleepTimeOne);
}
});
}).catch((error) => {
console.log(TAG + "createSubscriber err : " + JSON.stringify(error));
expect().assertFail();
done();
})
setTimeout(timeout, 5000);
})
/*
* @tc.number : ACTS_UIExtension_StartAbilityForResult_001
* @tc.name : start new ability for result by UIContentSession
* @tc.desc : Starting mainability3 by UIContentSession with startAbilityforresult succeeded.(callback)
*/
it('ACTS_UIExtension_StartAbilityForResult_001',0, async function (done) {
TAG = 'ACTS_UIExtension_StartAbilityForResult_001 == ';
console.log(TAG + "begin");
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let onResultEvent = 'ACTS_UIExtension_StartAbilityForResult_001_OnResult';
let startAbilityForResultEvent = 'ACTS_UIExtension_StartAbilityForResult_001';
var flag = true
function UnSubscribeCallback() {
console.log(TAG + "UnSubscribeInfoCallback");
flag = false;
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'StartAbilityForResult_001 - timeout');
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback)
}
}
var subscriber;
var subscribeInfo = {
events: [appearEvent, onResultEvent]
}
await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
subscriber = data;
commonEventManager.subscribe(subscriber, async (err, data) => {
console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data));
if (data.event == appearEvent) {
commonEventManager.publish(startAbilityForResultEvent, (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbilityForResult_001 failed, code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'publish ACTS_UIExtension_StartAbilityForResult_001 success');
}
});
}
else if (data.event == onResultEvent) {
setTimeout(async () => {
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback);
}, sleepTimeOne);
}
});
}).catch((error) => {
console.log(TAG + "createSubscriber err : " + JSON.stringify(error));
expect().assertFail();
done();
})
setTimeout(timeout, 5000);
})
/*
* @tc.number : ACTS_UIExtension_StartAbilityForResult_002
* @tc.name : start new ability for result by UIContentSession
* @tc.desc : Starting mainability3 by UIContentSession with the parameter startabilityforresult with options succeeded.(callback)
*/
it('ACTS_UIExtension_StartAbilityForResult_002',0, async function (done) {
TAG = 'ACTS_UIExtension_StartAbilityForResult_002 == ';
console.log(TAG + "begin");
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let onResultEvent = 'ACTS_UIExtension_StartAbilityForResult_002_OnResult';
let startAbilityForResultOpsEvent = 'ACTS_UIExtension_StartAbilityForResult_002';
var flag = true
function UnSubscribeCallback() {
console.log(TAG + "UnSubscribeInfoCallback");
flag = false;
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'StartAbilityForResult_002 - timeout');
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback)
}
}
var subscriber;
var subscribeInfo = {
events: [appearEvent, onResultEvent]
}
await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
subscriber = data;
commonEventManager.subscribe(subscriber, async (err, data) => {
console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data));
if (data.event == appearEvent) {
commonEventManager.publish(startAbilityForResultOpsEvent, (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbilityForResult_002 failed, code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'publish ACTS_UIExtension_StartAbilityForResult_002 success');
}
});
}
else if (data.event == onResultEvent) {
setTimeout(async () => {
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback);
}, sleepTimeOne);
}
});
}).catch((error) => {
console.log(TAG + "createSubscriber err : " + JSON.stringify(error));
expect().assertFail();
done();
})
setTimeout(timeout, 5000);
})
/*
* @tc.number : ACTS_UIExtension_StartAbilityForResult_003
* @tc.name : start new ability for result by UIContentSession
* @tc.desc : Starting mainability3 by UIContentSession with startabilityforresult succeeded.(promise)
*/
it('ACTS_UIExtension_StartAbilityForResult_003',0, async function (done) {
TAG = 'ACTS_UIExtension_StartAbilityForResult_003 == ';
console.log(TAG + "begin");
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let onResultEvent = 'ACTS_UIExtension_StartAbilityForResult_003_OnResult';
let startAbilityForResultEventPromise = 'ACTS_UIExtension_StartAbilityForResult_003';
var flag = true
function UnSubscribeCallback() {
console.log(TAG + "UnSubscribeInfoCallback");
flag = false;
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'StartAbilityForResult_003 - timeout');
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback)
}
}
var subscriber;
var subscribeInfo = {
events: [appearEvent, onResultEvent]
}
await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
subscriber = data;
commonEventManager.subscribe(subscriber, async (err, data) => {
console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data));
if (data.event == appearEvent) {
commonEventManager.publish(startAbilityForResultEventPromise, (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbilityForResult_003 failed, code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'publish ACTS_UIExtension_StartAbilityForResult_003 success');
}
});
}
else if (data.event == onResultEvent) {
setTimeout(async () => {
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback);
}, sleepTimeOne);
}
});
}).catch((error) => {
console.log(TAG + "createSubscriber err : " + JSON.stringify(error));
expect().assertFail();
done();
})
setTimeout(timeout, 5000);
})
/*
* @tc.number : ACTS_UIExtension_StartAbilityForResult_004
* @tc.name : start new ability for result by UIContentSession
* @tc.desc : Starting mainability2 by UIContentSession with the parameter startabilityforresult with options succeeded.(promise)
*/
it('ACTS_UIExtension_StartAbilityForResult_004',0, async function (done) {
TAG = 'ACTS_UIExtension_StartAbilityForResult_004 == ';
console.log(TAG + "begin");
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let onResultEvent = 'ACTS_UIExtension_StartAbilityForResult_004_OnResult';
let startAbilityForResultOpsEventPromise = 'ACTS_UIExtension_StartAbilityForResult_004';
var flag = true
function UnSubscribeCallback() {
console.log(TAG + "UnSubscribeInfoCallback");
flag = false;
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'StartAbilityForResult_004 - timeout');
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback)
}
}
var subscriber;
var subscribeInfo = {
events: [appearEvent, onResultEvent]
}
await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => {
console.log(TAG + "createSubscriber data : " + JSON.stringify(data));
subscriber = data;
commonEventManager.subscribe(subscriber, async (err, data) => {
console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data));
if (data.event == appearEvent) {
commonEventManager.publish(startAbilityForResultOpsEventPromise, (err) => {
if (err) {
console.log(TAG + `publish ACTS_UIExtension_StartAbilityForResult_004 failed, code is ${err.code}, message is ${err.message}`);
} else {
console.log(TAG + 'publish ACTS_UIExtension_StartAbilityForResult_004 success');
}
});
}
else if (data.event == onResultEvent) {
setTimeout(async () => {
commonEventManager.unsubscribe(subscriber, UnSubscribeCallback);
}, sleepTimeOne);
}
});
}).catch((error) => {
console.log(TAG + "createSubscriber err : " + JSON.stringify(error));
expect().assertFail();
done();
})
setTimeout(timeout, 5000);
})
})
})
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录