Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
3a81f84f
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看板
未验证
提交
3a81f84f
编写于
6月 27, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3837 XTS元能力un测试套整改
Merge pull request !3837 from chengxingzhen/master
上级
a45d7265
de840c1d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
492 addition
and
399 deletion
+492
-399
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets
...ultiinstancetest/entry/src/main/ets/test/Ability.test.ets
+0
-30
ability/ability_runtime/actscalltest/thirdcalltest/entry/src/main/ets/test/Ability.test.ets
...st/thirdcalltest/entry/src/main/ets/test/Ability.test.ets
+0
-17
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/entry/src/main/js/test/DataAbilityHelperJsSt.test.js
...test/entry/src/main/js/test/DataAbilityHelperJsSt.test.js
+1
-1
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets
...startabilitytest/entry/src/main/ets/test/Ability.test.ets
+0
-30
ability/ability_runtime/amsgetabilityprocessinfo/actsgetabilityprocessinfotest/entry/src/main/js/test/ActsProcessManageJsTest.test.js
...st/entry/src/main/js/test/ActsProcessManageJsTest.test.js
+1
-1
ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets
...try/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets
+46
-7
ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets
.../main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets
+6
-231
ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets
.../actsnewwanttest/entry/src/main/ets/test/Ability.test.ets
+438
-82
未找到文件。
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
3a81f84f
...
@@ -98,23 +98,6 @@ async function startAbilityProcess(abilityContext, parameters) {
...
@@ -98,23 +98,6 @@ async function startAbilityProcess(abilityContext, parameters) {
})
})
}
}
function
getMissionId
()
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
var
missionId
=
-
1
;
var
missionInfos
=
await
missionManager
.
getMissionInfos
(
''
,
MAX_MISSION_NUM
);
for
(
let
i
=
0
;
i
<
missionInfos
.
length
;
i
++
)
{
console
.
log
(
'getMissionId result: '
+
i
+
'= '
+
JSON
.
stringify
(
missionInfos
[
i
]))
if
((
missionInfos
[
i
]
.
want
.
abilityName
==
"com.example.amsabilitymultiinstancetest.MainAbility"
)
&&
(
missionInfos
[
i
]
.
runningState
==
0
))
{
missionId
=
missionInfos
[
i
]
.
missionId
;
break
;
}
}
console
.
log
(
'======>getMissionId resolve missionId<======='
+
missionId
);
resolve
(
missionId
);
})
}
export
default
function
abilityTest
(
abilityContext
)
{
export
default
function
abilityTest
(
abilityContext
)
{
describe
(
'ActsAbilityTest'
,
function
()
{
describe
(
'ActsAbilityTest'
,
function
()
{
...
@@ -126,19 +109,6 @@ export default function abilityTest(abilityContext) {
...
@@ -126,19 +109,6 @@ export default function abilityTest(abilityContext) {
afterEach
(
async
(
done
)
=>
{
afterEach
(
async
(
done
)
=>
{
let
installer
=
await
bundle
.
getBundleInstaller
();
let
installer
=
await
bundle
.
getBundleInstaller
();
var
count
=
0
;
var
count
=
0
;
var
testMissionId
;
testMissionId
=
await
getMissionId
();
console
.
log
(
'======>afterEach test missionId<======='
+
testMissionId
);
if
(
testMissionId
!=
-
1
)
{
await
missionManager
.
moveMissionToFront
(
testMissionId
);
}
await
appManager
.
killProcessesByBundleName
(
"com.example.amsabilitymultiinstanceappa"
);
await
appManager
.
killProcessesByBundleName
(
"com.example.amsabilitymultiinstanceappb"
);
await
appManager
.
killProcessesByBundleName
(
"com.example.amsabilitymultiinstanceappc"
);
await
appManager
.
killProcessesByBundleName
(
"com.example.amsabilitymultiinstanceappd"
);
await
appManager
.
killProcessesByBundleName
(
"com.example.amsabilitymultiinstanceappe"
);
done
();
done
();
})
})
...
...
ability/ability_runtime/actscalltest/thirdcalltest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
3a81f84f
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
*/
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import commonEvent from '@ohos.commonEvent'
import commonEvent from '@ohos.commonEvent'
import missionManager from '@ohos.application.missionManager'
const MAX_MISSION_NUM = 1024;
const MAX_MISSION_NUM = 1024;
...
@@ -64,22 +63,6 @@ class MySequenceable {
...
@@ -64,22 +63,6 @@ class MySequenceable {
}
}
}
}
function getMissionId(abilityName, state) {
return new Promise(async (resolve, reject) => {
let missionId = -1;
let missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM);
for (let i = 0; i < missionInfos.length; i++) {
if ((missionInfos[i].want.abilityName == abilityName)
&& (missionInfos[i].runningState == state)) {
missionId = missionInfos[i].missionId;
break;
}
}
console.log('======>getMissionId resolve missionId<=======' + missionId);
resolve(missionId);
})
}
function delay(time) {
function delay(time) {
let delta;
let delta;
if (typeof time != 'number' || time <= 0) {
if (typeof time != 'number' || time <= 0) {
...
...
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/entry/src/main/js/test/DataAbilityHelperJsSt.test.js
浏览文件 @
3a81f84f
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohosDataAbility
from
'
@ohos.data.data
a
bility
'
import
ohosDataAbility
from
'
@ohos.data.data
A
bility
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
ActsDataAbilityHelperTest
'
,
function
()
{
describe
(
'
ActsDataAbilityHelperTest
'
,
function
()
{
...
...
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
3a81f84f
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"deccjsunit/index"
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"deccjsunit/index"
import
commonEvent
from
'@ohos.commonEvent'
import
commonEvent
from
'@ohos.commonEvent'
import
bundle
from
'@ohos.bundle'
import
bundle
from
'@ohos.bundle'
import
missionManager
from
'@ohos.application.missionManager'
import
appManager
from
'@ohos.application.appManager'
var
subscriberInfoMultiInstance
=
{
var
subscriberInfoMultiInstance
=
{
...
@@ -53,37 +51,9 @@ async function startAbilityProcess(abilityContext, options, parameters) {
...
@@ -53,37 +51,9 @@ async function startAbilityProcess(abilityContext, options, parameters) {
}
}
}
}
function
getMissionId
()
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
var
missionId
=
-
1
;
var
missionInfos
=
await
missionManager
.
getMissionInfos
(
''
,
MAX_MISSION_NUM
);
for
(
let
i
=
0
;
i
<
missionInfos
.
length
;
i
++
)
{
console
.
log
(
'getMissionId result: '
+
i
+
'= '
+
JSON
.
stringify
(
missionInfos
[
i
]))
if
((
missionInfos
[
i
]
.
want
.
abilityName
==
"com.example.actsgetdisplayidtest.MainAbility"
)
&&
(
missionInfos
[
i
]
.
runningState
==
0
))
{
missionId
=
missionInfos
[
i
]
.
missionId
;
break
;
}
}
console
.
log
(
'======>getMissionId resolve missionId<======='
+
missionId
);
resolve
(
missionId
);
})
}
export
default
function
abilityTest
(
abilityContext
)
{
export
default
function
abilityTest
(
abilityContext
)
{
describe
(
'ActsGetDisplayIdStartAbilityTest'
,
function
()
{
describe
(
'ActsGetDisplayIdStartAbilityTest'
,
function
()
{
afterEach
(
async
(
done
)
=>
{
var
testMissionId
;
testMissionId
=
await
getMissionId
();
console
.
log
(
'======>afterEach test missionId<======='
+
testMissionId
);
await
missionManager
.
moveMissionToFront
(
testMissionId
);
await
appManager
.
killProcessesByBundleName
(
"com.example.actsspecifytesthap"
);
done
();
})
/*
/*
* @tc.number: ACTS_StartAbility_0100
* @tc.number: ACTS_StartAbility_0100
* @tc.name: Get the specified displayId to start Ability
* @tc.name: Get the specified displayId to start Ability
...
...
ability/ability_runtime/amsgetabilityprocessinfo/actsgetabilityprocessinfotest/entry/src/main/js/test/ActsProcessManageJsTest.test.js
浏览文件 @
3a81f84f
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"
deccjsunit/index
"
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"
deccjsunit/index
"
import
appManager
from
'
@ohos.application.
A
ppManager
'
import
appManager
from
'
@ohos.application.
a
ppManager
'
describe
(
'
ActsAbilityRunningInfosTest
'
,
function
()
{
describe
(
'
ActsAbilityRunningInfosTest
'
,
function
()
{
...
...
ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets
浏览文件 @
3a81f84f
...
@@ -83,8 +83,10 @@ export default function test() {
...
@@ -83,8 +83,10 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_0200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_0200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_0200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_0200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_0200 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_0200 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
});
});
/**
/**
* @tc.number: FMS_acquireForm_0300
* @tc.number: FMS_acquireForm_0300
...
@@ -121,8 +123,10 @@ export default function test() {
...
@@ -121,8 +123,10 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_0300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_0300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_0300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_0300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_0300 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_0300 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
});
});
/**
/**
* @tc.number: FMS_acquireForm_0400
* @tc.number: FMS_acquireForm_0400
...
@@ -159,8 +163,10 @@ export default function test() {
...
@@ -159,8 +163,10 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_0400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_0400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_0400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_0400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_0400 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_0400 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
});
});
/**
/**
* @tc.number: FMS_acquireForm_0500
* @tc.number: FMS_acquireForm_0500
...
@@ -197,8 +203,10 @@ export default function test() {
...
@@ -197,8 +203,10 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_0500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_0500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_0500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_0500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_0500 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_0500 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
});
});
/**
/**
* @tc.number: FMS_acquireForm_0600
* @tc.number: FMS_acquireForm_0600
...
@@ -235,8 +243,10 @@ export default function test() {
...
@@ -235,8 +243,10 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_0600 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_0600 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
});
});
/**
/**
* @tc.number: FMS_acquireForm_0700
* @tc.number: FMS_acquireForm_0700
...
@@ -273,8 +283,10 @@ export default function test() {
...
@@ -273,8 +283,10 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_0700 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_0700 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
});
});
/**
/**
* @tc.number: FMS_acquireForm_1000
* @tc.number: FMS_acquireForm_1000
...
@@ -312,8 +324,10 @@ export default function test() {
...
@@ -312,8 +324,10 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_1000 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_1000 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
});
});
/**
/**
...
@@ -396,8 +410,11 @@ export default function test() {
...
@@ -396,8 +410,11 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_1100 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_1100 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_1100 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_1100 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_1100 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_1100 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
done
()
});
});
/**
/**
...
@@ -481,6 +498,8 @@ export default function test() {
...
@@ -481,6 +498,8 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_1200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_1200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
});
});
console
.
info
(
`FMS_acquireForm_1200 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_1200 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
done
()
});
});
/**
/**
* @tc.number: FMS_acquireForm_1400
* @tc.number: FMS_acquireForm_1400
...
@@ -502,6 +521,7 @@ export default function test() {
...
@@ -502,6 +521,7 @@ export default function test() {
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
console
.
info
(
'FMS_acquireForm_1400 publish'
+
JSON
.
stringify
(
err
));
console
.
info
(
'FMS_acquireForm_1400 publish'
+
JSON
.
stringify
(
err
));
});
});
done
()
}
}
async
function
onAcquiredCallBack
(
_
,
data
)
{
async
function
onAcquiredCallBack
(
_
,
data
)
{
console
.
info
(
"!!!====>FMS_acquireForm_1400 onAcquiredCallBack data:====>"
+
JSON
.
stringify
(
data
));
console
.
info
(
"!!!====>FMS_acquireForm_1400 onAcquiredCallBack data:====>"
+
JSON
.
stringify
(
data
));
...
@@ -531,6 +551,8 @@ export default function test() {
...
@@ -531,6 +551,8 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_1400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_1400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
});
});
console
.
info
(
`FMS_acquireForm_1400 featureAbility.startAbility again end`
);
console
.
info
(
`FMS_acquireForm_1400 featureAbility.startAbility again end`
);
await
sleepTime
(
3000
)
}
}
commonEvent
.
subscribe
(
subscriberOnAcquired
,
onAcquiredCallBack
);
commonEvent
.
subscribe
(
subscriberOnAcquired
,
onAcquiredCallBack
);
...
@@ -581,6 +603,7 @@ export default function test() {
...
@@ -581,6 +603,7 @@ export default function test() {
console
.
info
(
'FMS_acquireForm_1500 publish'
+
JSON
.
stringify
(
err
));
console
.
info
(
'FMS_acquireForm_1500 publish'
+
JSON
.
stringify
(
err
));
});
});
}
}
done
()
}
}
async
function
onAcquiredCallBack
(
_
,
data
)
{
async
function
onAcquiredCallBack
(
_
,
data
)
{
console
.
info
(
"!!!====>FMS_acquireForm_1500 onAcquiredCallBack data:====>"
+
JSON
.
stringify
(
data
));
console
.
info
(
"!!!====>FMS_acquireForm_1500 onAcquiredCallBack data:====>"
+
JSON
.
stringify
(
data
));
...
@@ -653,8 +676,10 @@ export default function test() {
...
@@ -653,8 +676,10 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_1500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_1500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_1500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_1500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_1500 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_1500 featureAbility.startAbility end`
);
await
sleepTime
(
3000
)
});
});
/**
/**
...
@@ -1075,12 +1100,11 @@ export default function test() {
...
@@ -1075,12 +1100,11 @@ export default function test() {
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_1800_Temp2 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_1800_Temp2 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
});
});
console
.
info
(
`FMS_acquireForm_1800_Temp2 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_1800_Temp2 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_1800_Temp2 end`
);
console
.
info
(
`FMS_acquireForm_1800_Temp2 end`
);
}
}
await
FMS_acquireForm_1800_normal1
();
FMS_acquireForm_1800_normal1
();
await
sleepTime
(
5000
)
});
});
/**
/**
* @tc.number: FMS_acquireForm_1900
* @tc.number: FMS_acquireForm_1900
...
@@ -1107,6 +1131,7 @@ export default function test() {
...
@@ -1107,6 +1131,7 @@ export default function test() {
console
.
info
(
'FMS_acquireForm_1900 publish'
+
JSON
.
stringify
(
err
));
console
.
info
(
'FMS_acquireForm_1900 publish'
+
JSON
.
stringify
(
err
));
});
});
}
}
done
()
}
}
commonEvent
.
subscribe
(
subscriberOnAcquired
,
onAcquiredCallBack
);
commonEvent
.
subscribe
(
subscriberOnAcquired
,
onAcquiredCallBack
);
...
@@ -1188,6 +1213,7 @@ export default function test() {
...
@@ -1188,6 +1213,7 @@ export default function test() {
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
console
.
info
(
'FMS_acquireForm_2100 publish'
+
JSON
.
stringify
(
err
));
console
.
info
(
'FMS_acquireForm_2100 publish'
+
JSON
.
stringify
(
err
));
});
});
done
()
}
}
async
function
onAcquiredCallBack
(
_
,
data
)
{
async
function
onAcquiredCallBack
(
_
,
data
)
{
console
.
info
(
"!!!====>FMS_acquireForm_2100 onAcquiredCallBack data:====>"
+
JSON
.
stringify
(
data
));
console
.
info
(
"!!!====>FMS_acquireForm_2100 onAcquiredCallBack data:====>"
+
JSON
.
stringify
(
data
));
...
@@ -1261,6 +1287,7 @@ export default function test() {
...
@@ -1261,6 +1287,7 @@ export default function test() {
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
console
.
info
(
'FMS_acquireForm_2200 publish'
+
JSON
.
stringify
(
err
));
console
.
info
(
'FMS_acquireForm_2200 publish'
+
JSON
.
stringify
(
err
));
});
});
done
()
}
}
commonEvent
.
subscribe
(
subscriberCast
,
onCastCallBack
);
commonEvent
.
subscribe
(
subscriberCast
,
onCastCallBack
);
...
@@ -1290,7 +1317,7 @@ export default function test() {
...
@@ -1290,7 +1317,7 @@ export default function test() {
});
});
/**
/**
* @tc.number: FMS_acquireForm_2300
* @tc.number: FMS_acquireForm_2300
* @tc.name: Cast to normal form when the temporary formIdis set to 0.
* @tc.name: Cast to normal form when the temporary formId
is set to 0.
* @tc.desc: Failed to convert to normal form when verifying that the temporary formIdis set to 0
* @tc.desc: Failed to convert to normal form when verifying that the temporary formIdis set to 0
*/
*/
it
(
`FMS_acquireForm_2300`
,
0
,
async
(
done
)
=>
{
it
(
`FMS_acquireForm_2300`
,
0
,
async
(
done
)
=>
{
...
@@ -1306,6 +1333,7 @@ export default function test() {
...
@@ -1306,6 +1333,7 @@ export default function test() {
};
};
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
console
.
info
(
'FMS_acquireForm_2300 publish'
+
JSON
.
stringify
(
err
));
console
.
info
(
'FMS_acquireForm_2300 publish'
+
JSON
.
stringify
(
err
));
done
()
});
});
}
}
commonEvent
.
subscribe
(
subscriberCast
,
onCastCallBack
);
commonEvent
.
subscribe
(
subscriberCast
,
onCastCallBack
);
...
@@ -1330,6 +1358,7 @@ export default function test() {
...
@@ -1330,6 +1358,7 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_2300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_2300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_2300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_2300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_2300 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_2300 featureAbility.startAbility end`
);
});
});
...
@@ -1351,6 +1380,7 @@ export default function test() {
...
@@ -1351,6 +1380,7 @@ export default function test() {
};
};
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
console
.
info
(
'FMS_acquireForm_2400 publish'
+
JSON
.
stringify
(
err
));
console
.
info
(
'FMS_acquireForm_2400 publish'
+
JSON
.
stringify
(
err
));
done
()
});
});
}
}
async
function
onAcquiredCallBack
(
_
,
data
)
{
async
function
onAcquiredCallBack
(
_
,
data
)
{
...
@@ -1379,6 +1409,7 @@ export default function test() {
...
@@ -1379,6 +1409,7 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_2400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_2400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_2400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_2400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_2400 featureAbility.startAbility again end`
);
console
.
info
(
`FMS_acquireForm_2400 featureAbility.startAbility again end`
);
}
}
...
@@ -1424,6 +1455,7 @@ export default function test() {
...
@@ -1424,6 +1455,7 @@ export default function test() {
};
};
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
(
err
)
=>
{
console
.
info
(
'FMS_acquireForm_2500 publish'
+
JSON
.
stringify
(
err
));
console
.
info
(
'FMS_acquireForm_2500 publish'
+
JSON
.
stringify
(
err
));
done
()
});
});
}
}
commonEvent
.
subscribe
(
subscriberCast
,
onCastCallBack
);
commonEvent
.
subscribe
(
subscriberCast
,
onCastCallBack
);
...
@@ -1448,10 +1480,12 @@ export default function test() {
...
@@ -1448,10 +1480,12 @@ export default function test() {
console
.
info
(
`FMS_acquireForm_2500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
console
.
info
(
`FMS_acquireForm_2500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`
);
})
.
catch
((
err
:
any
)
=>
{
})
.
catch
((
err
:
any
)
=>
{
console
.
info
(
`FMS_acquireForm_2500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
console
.
info
(
`FMS_acquireForm_2500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`
);
done
()
});
});
console
.
info
(
`FMS_acquireForm_2500 featureAbility.startAbility end`
);
console
.
info
(
`FMS_acquireForm_2500 featureAbility.startAbility end`
);
await
sleep
(
3000
)
});
});
/**
/**
* @tc.number: FMS_acquireForm_2600
* @tc.number: FMS_acquireForm_2600
* @tc.name: When the normal form does not reach the maximum value created by the form, the temporary form changes to the normal form.
* @tc.name: When the normal form does not reach the maximum value created by the form, the temporary form changes to the normal form.
* @tc.desc: Verify that when the normal form does not reach the maximum value created by the form.
* @tc.desc: Verify that when the normal form does not reach the maximum value created by the form.
...
@@ -1465,7 +1499,7 @@ export default function test() {
...
@@ -1465,7 +1499,7 @@ export default function test() {
function
onCastCallBack
(
_
,
data
)
{
function
onCastCallBack
(
_
,
data
)
{
console
.
info
(
"!!!====>FMS_acquireForm_2600 onCastCallBack data:====>"
+
JSON
.
stringify
(
data
));
console
.
info
(
"!!!====>FMS_acquireForm_2600 onCastCallBack data:====>"
+
JSON
.
stringify
(
data
));
expect
(
data
.
event
)
.
assertEqual
(
"FMS_FormCast_commonEvent"
);
expect
(
data
.
event
)
.
assertEqual
(
"FMS_FormCast_commonEvent"
);
expect
(
data
.
data
)
.
assertEqual
(
"
0
"
);
expect
(
data
.
data
)
.
assertEqual
(
"
undefined
"
);
commonEvent
.
unsubscribe
(
subscriberCast
,
()
=>
unsubscribeOnCastCallback
(
"FMS_acquireForm_2600"
))
commonEvent
.
unsubscribe
(
subscriberCast
,
()
=>
unsubscribeOnCastCallback
(
"FMS_acquireForm_2600"
))
formId1
=
data
.
parameters
.
formId
;
formId1
=
data
.
parameters
.
formId
;
if
(
formId1
&&
formId2
)
{
if
(
formId1
&&
formId2
)
{
...
@@ -1473,8 +1507,8 @@ export default function test() {
...
@@ -1473,8 +1507,8 @@ export default function test() {
let
commonEventPublishData
=
{
let
commonEventPublishData
=
{
data
:
formId1
data
:
formId1
};
};
}
commonEvent
.
publish
(
deleteForm_Event
,
()
=>
delPublishCallBack
(
"FMS_acquireForm_2600"
,
done
));
commonEvent
.
publish
(
deleteForm_Event
,
()
=>
delPublishCallBack
(
"FMS_acquireForm_2600"
,
done
));
}
}
}
async
function
onAcquiredCallBack
(
_
,
data
)
{
async
function
onAcquiredCallBack
(
_
,
data
)
{
...
@@ -1520,6 +1554,7 @@ export default function test() {
...
@@ -1520,6 +1554,7 @@ export default function test() {
};
};
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
()
=>
commonEvent
.
publish
(
deleteForm_Event
,
commonEventPublishData
,
()
=>
publishCallback1
(
"FMS_acquireForm_2600"
));
publishCallback1
(
"FMS_acquireForm_2600"
));
done
()
}
}
}
}
}
}
...
@@ -1569,6 +1604,10 @@ const delPublishCallBack = async (tcNumber, done) => {
...
@@ -1569,6 +1604,10 @@ const delPublishCallBack = async (tcNumber, done) => {
},
1000
);
},
1000
);
}
}
function
sleepTime
(
time
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
time
));
}
const
unsubscribeOnErrorCallback
=
(
tcNumber
)
=>
{
const
unsubscribeOnErrorCallback
=
(
tcNumber
)
=>
{
console
.
debug
(
`====>${tcNumber} unsubscribeOnErrorCallback====>`
);
console
.
debug
(
`====>${tcNumber} unsubscribeOnErrorCallback====>`
);
}
}
...
...
ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets
浏览文件 @
3a81f84f
...
@@ -47,52 +47,6 @@ export default function test() {
...
@@ -47,52 +47,6 @@ export default function test() {
onRequestEventSubscriber = await commonEvent.createSubscriber(onRequestEvent);
onRequestEventSubscriber = await commonEvent.createSubscriber(onRequestEvent);
});
});
/**
* @tc.number: FMS_hostDeathRecipient_0100
* @tc.name: Reset host ability.
* @tc.desc: The provider's onDestroy event will be triggered.
*/
it(`FMS_hostDeathRecipient_0100`, 0, async (done) => {
tcNumber = `FMS_hostDeathRecipient_0100`;
let tempFormId;
commonEvent.subscribe(onAcquiredEventSubscriber, async (err, data) => {
const hostFormId = data.data;
console.info(`${tcNumber} onAcquiredCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
console.info(`${tcNumber} onAcquiredCallBack formId: ${hostFormId}`);
if (data.parameters?.cast) {
tempFormId = hostFormId;
}
if (++hostCounter == 2) {
// onAcquired * 2
commonEvent.unsubscribe(onAcquiredEventSubscriber, unsubscribeOnAcquiredCallback);
// terminate host
commonEvent.publish(formOnTerminateEvent, publishOnTerminateCallback);
console.info(`${tcNumber} onAcquiredCallBack end`);
}
});
commonEvent.subscribe(onSupplyEventSubscriber, async (err, data) => {
const kind = data.parameters.kind;
const supplyFormId = getSupplyFormId(data);
console.info(`${tcNumber} onSupplyCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
console.info(`${tcNumber} onSupplyCallBack formId: ${supplyFormId} kind: ${kind}`);
if (`onDestroy` == kind) {
expect(tempFormId).assertEqual(supplyFormId);
commonEvent.unsubscribe(onSupplyEventSubscriber, unsubscribeOnSupplyCallback);
await sleep(1000);
done();
}
});
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
isCreate: true,
createTempAndNormal: true,
subscribeTerminate: true
});
});
/**
/**
* @tc.number: FMS_hostDeathRecipient_0200
* @tc.number: FMS_hostDeathRecipient_0200
* @tc.name: Reset host ability and requestForm.
* @tc.name: Reset host ability and requestForm.
...
@@ -138,205 +92,26 @@ export default function test() {
...
@@ -138,205 +92,26 @@ export default function test() {
if (`onDestroy` == kind) {
if (`onDestroy` == kind) {
expect(tempFormId).assertEqual(supplyFormId);
expect(tempFormId).assertEqual(supplyFormId);
done()
} else if (`onUpdate` == kind) {
} else if (`onUpdate` == kind) {
expect(normalFormId).assertEqual(supplyFormId);
expect(normalFormId).assertEqual(supplyFormId);
done()
}
}
if (++providerCounter == 4) {
if (++providerCounter == 4) {
console.info(`${tcNumber} onSupplyCallBack 123`);
// onCreate * 2 onDestroy * 1 onUpdate * 1
// onCreate * 2 onDestroy * 1 onUpdate * 1
commonEvent.unsubscribe(onSupplyEventSubscriber, unsubscribeOnSupplyCallback);
commonEvent.unsubscribe(onSupplyEventSubscriber, unsubscribeOnSupplyCallback);
console.info(`${tcNumber} onSupplyCallBack end`);
console.info(`${tcNumber} onSupplyCallBack end`);
await sleep(1000);
//await sleep(1000);
done();
}
}
});
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
isCreate: true,
createTempAndNormal: true,
subscribeTerminate: true
});
});
/**
* @tc.number: FMS_hostDeathRecipient_0300
* @tc.name: Reset host ability.
* @tc.desc: The provider's onDestroy event will be triggered but requestForm will be failed.
*/
it(`FMS_hostDeathRecipient_0300`, 0, async (done) => {
tcNumber = `FMS_hostDeathRecipient_0300`;
let tempFormId;
commonEvent.subscribe(onAcquiredEventSubscriber, async (err, data) => {
const hostFormId = data.data;
console.info(`${tcNumber} onAcquiredCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
console.info(`${tcNumber} onAcquiredCallBack formId: ${hostFormId}`);
if (data.parameters) {
tempFormId = hostFormId;
commonEvent.unsubscribe(onAcquiredEventSubscriber, unsubscribeOnAcquiredCallback);
// terminate host
commonEvent.publish(formOnTerminateEvent, publishOnTerminateCallback);
console.info(`${tcNumber} onAcquiredCallBack end`);
}
});
commonEvent.subscribe(onSupplyEventSubscriber, async (err, data) => {
const kind = data.parameters.kind;
const supplyFormId = getSupplyFormId(data);
console.info(`${tcNumber} onSupplyCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
console.info(`${tcNumber} onSupplyCallBack formId: ${supplyFormId} kind: ${kind}`);
if (`onDestroy` == kind) {
expect(tempFormId).assertEqual(supplyFormId);
}
if (++providerCounter == 2) {
// onCreate * 1
// onDestroy * 1
commonEvent.unsubscribe(onSupplyEventSubscriber, unsubscribeOnSupplyCallback);
await sleep(1000);
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
requestForm: true,
requestId: tempFormId
});
console.info(`${tcNumber} onSupplyCallBack end`);
}
});
commonEvent.subscribe(onRequestEventSubscriber, async (err, data) => {
console.info(`${tcNumber} onRequestCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
commonEvent.unsubscribe(onRequestEventSubscriber, unsubscribeOnRequestCallback);
const error = data.parameters.error;
expect(error.code).assertEqual(9);
expect(error.message).assertEqual(`the ID of the form to be operated does not exist`);
console.info(`${tcNumber} onRequestCallBack end`);
await sleep(1000);
done();
done();
});
});
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
isCreate: true,
isCreate: true,
temporary: true,
createTempAndNormal: true,
subscribeTerminate: true
});
});
/**
* @tc.number: FMS_hostDeathRecipient_0500
* @tc.name: Reset host ability and requestForm.
* @tc.desc: The provider's onUpdate event will be triggered.
*/
it(`FMS_hostDeathRecipient_0500`, 0, async (done) => {
tcNumber = `FMS_hostDeathRecipient_0500`;
let hostFormId;
commonEvent.subscribe(onAcquiredEventSubscriber, async (err, data) => {
hostFormId = data.data;
console.info(`${tcNumber} onAcquiredCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
console.info(`${tcNumber} onAcquiredCallBack formId: ${hostFormId}`);
commonEvent.unsubscribe(onAcquiredEventSubscriber, unsubscribeOnAcquiredCallback);
// start abilityb
await startAbility(`com.ohos.st.formsystemhostl`, `com.ohos.st.formsystemhostl.MainAbility`, {
formId: hostFormId,
isCreate: true
});
// terminate host
commonEvent.publish(formOnTerminateEvent, publishOnTerminateCallback);
await sleep(2000);
// reset host a
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
formId: hostFormId,
requestForm: true,
requestId: hostFormId,
});
console.info(`${tcNumber} onAcquiredCallBack end`);
});
commonEvent.subscribe(onSupplyEventSubscriber, async (err, data) => {
const kind = data.parameters.kind;
const supplyFormId = getSupplyFormId(data);
console.info(`${tcNumber} onSupplyCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
console.info(`${tcNumber} onSupplyCallBack formId: ${supplyFormId} kind: ${kind}`);
if (`onUpdate` == kind) {
expect(hostFormId).assertEqual(supplyFormId);
}
if (++providerCounter == 2) {
// onCreate * 1 host A
// onUpdate * 1
commonEvent.unsubscribe(onSupplyEventSubscriber, unsubscribeOnSupplyCallback);
console.info(`${tcNumber} onSupplyCallBack end`);
await sleep(1000);
done();
}
});
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
isCreate: true,
subscribeTerminate: true
});
});
/**
* @tc.number: FMS_hostDeathRecipient_0600
* @tc.name: Reset host ability and requestForm.
* @tc.desc: The provider's onUpdate event will be triggered.
*/
it(`FMS_hostDeathRecipient_0600`, 0, async (done) => {
tcNumber = `FMS_hostDeathRecipient_0600`;
let hostFormId;
commonEvent.subscribe(onAcquiredEventSubscriber, async (err, data) => {
hostFormId = data.data;
console.info(`${tcNumber} onAcquiredCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
console.info(`${tcNumber} onAcquiredCallBack formId: ${hostFormId}`);
commonEvent.unsubscribe(onAcquiredEventSubscriber, unsubscribeOnAcquiredCallback);
// start abilityb
await startAbility(`com.ohos.st.formsystemhostl`, `com.ohos.st.formsystemhostl.MainAbility`, {
formId: hostFormId,
isCreate: true
});
// terminate host
commonEvent.publish(formOnTerminateEvent, publishOnTerminateCallback);
await sleep(2000);
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
formId: hostFormId,
isCreate: true,
requestForm: true,
requestId: hostFormId,
subscribeTerminate: true
});
await sleep(2000);
await startAbility(`com.ohos.st.formsystemhostl`, `com.ohos.st.formsystemhostl.MainAbility`, {
formId: hostFormId,
requestForm: true,
requestId: hostFormId,
});
console.info(`${tcNumber} onAcquiredCallBack end`);
});
commonEvent.subscribe(onSupplyEventSubscriber, async (err, data) => {
const kind = data.parameters.kind;
const supplyFormId = getSupplyFormId(data);
console.info(`${tcNumber} onSupplyCallBack data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`);
console.info(`${tcNumber} onSupplyCallBack formId: ${supplyFormId} kind: ${kind}`);
if (`onUpdate` == kind) {
expect(hostFormId).assertEqual(supplyFormId);
}
if (++providerCounter == 3) {
// onCreate * 1 host A
// onUpdate * 2
commonEvent.unsubscribe(onSupplyEventSubscriber, unsubscribeOnSupplyCallback);
console.info(`${tcNumber} onSupplyCallBack end`);
await sleep(1000);
done();
}
});
await startAbility(`com.ohos.st.formsystemhostk`, `com.ohos.st.formsystemhostk.MainAbility`, {
isCreate: true,
subscribeTerminate: true
subscribeTerminate: true
});
});
});
});
});
});
}
}
...
...
ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
3a81f84f
...
@@ -18,6 +18,18 @@ import commonEvent from '@ohos.commonEvent'
...
@@ -18,6 +18,18 @@ import commonEvent from '@ohos.commonEvent'
import missionManager from '@ohos.application.missionManager'
import missionManager from '@ohos.application.missionManager'
import appManager from '@ohos.application.appManager'
import appManager from '@ohos.application.appManager'
import formProvider from '@ohos.application.formProvider';
import FormInfo from '@ohos.application.formInfo';
import formError from '@ohos.application.formError';
var EXTENSION_INFO_ERR = 2097152
var USERID_ERR = 2097177
var trueInfo;
var array = new Array();
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
const MAX_MISSION_NUM = 1024;
const MAX_MISSION_NUM = 1024;
var subscriberInfo = {
var subscriberInfo = {
events: ['onCreateMain_To_Test_CommonEvent',
events: ['onCreateMain_To_Test_CommonEvent',
...
@@ -31,42 +43,9 @@ var subscriberInfo = {
...
@@ -31,42 +43,9 @@ var subscriberInfo = {
],
],
};
};
function getMissionId() {
return new Promise(async (resolve, reject) => {
var missionId = -1;
var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM);
console.log('======>ACTS_NewWant_Test getMissionId missionInfos<=======' + missionInfos);
for (let i = 0; i < missionInfos.length; i++) {
console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i]))
if ((missionInfos[i].want.abilityName == "com.example.newwanttest.MainAbility") &&
(missionInfos[i].runningState == 0)) {
missionId = missionInfos[i].missionId;
break;
}
}
console.log('======>ACTS_NewWant_Test getMissionId resolve missionId<=======' + missionId);
resolve(missionId);
})
}
export default function abilityTest(abilityContext) {
export default function abilityTest(abilityContext) {
describe('ActsNewWantTest', function () {
describe('ActsNewWantTest', function () {
afterEach(async (done) => {
var testMissionId;
testMissionId = await getMissionId();
console.log('======>ACTS_NewWant_Test afterEach test missionId<=======' + testMissionId);
await missionManager.moveMissionToFront(testMissionId);
console.log('======>ACTS_NewWant_Test afterEach test move<=======');
await appManager.killProcessesByBundleName("com.example.newwanthapapi7");
await appManager.killProcessesByBundleName("com.example.newwanthapa");
await appManager.killProcessesByBundleName("com.example.newwanthap");
done();
})
/**
/**
* @tc.number: ACTS_NewWant_Test_0100
* @tc.number: ACTS_NewWant_Test_0100
* @tc.name: Starting standard Ability for the first time does not trigger onNewWant.
* @tc.name: Starting standard Ability for the first time does not trigger onNewWant.
...
@@ -80,6 +59,12 @@ export default function abilityTest(abilityContext) {
...
@@ -80,6 +59,12 @@ export default function abilityTest(abilityContext) {
var flagOnForeground = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
var flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0100====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
abilityContext.startAbility({
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapa.MainAbility"
abilityName: "com.example.newwanthapa.MainAbility"
...
@@ -88,12 +73,7 @@ export default function abilityTest(abilityContext) {
...
@@ -88,12 +73,7 @@ export default function abilityTest(abilityContext) {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
})
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0100====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function SubscribeCallBack(err, data) {
function SubscribeCallBack(err, data) {
console.debug("ACTS_NewWant_Test_0100====>Subscribe CallBack data:====>"
console.debug("ACTS_NewWant_Test_0100====>Subscribe CallBack data:====>"
...
@@ -130,6 +110,7 @@ export default function abilityTest(abilityContext) {
...
@@ -130,6 +110,7 @@ export default function abilityTest(abilityContext) {
expect(flagOnNewWant).assertEqual(0);
expect(flagOnNewWant).assertEqual(0);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
done()
}
}
function UnSubscribeCallback() {
function UnSubscribeCallback() {
...
@@ -150,6 +131,12 @@ export default function abilityTest(abilityContext) {
...
@@ -150,6 +131,12 @@ export default function abilityTest(abilityContext) {
var flagOnWindowStageCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
var flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0200====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
abilityContext.startAbility({
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
bundleName: "com.example.newwanthap",
...
@@ -159,12 +146,6 @@ export default function abilityTest(abilityContext) {
...
@@ -159,12 +146,6 @@ export default function abilityTest(abilityContext) {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
})
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0200====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function SubscribeCallBack(err, data) {
function SubscribeCallBack(err, data) {
console.debug("ACTS_NewWant_Test_0200====>Subscribe CallBack data:====>"
console.debug("ACTS_NewWant_Test_0200====>Subscribe CallBack data:====>"
...
@@ -201,6 +182,7 @@ export default function abilityTest(abilityContext) {
...
@@ -201,6 +182,7 @@ export default function abilityTest(abilityContext) {
expect(flagOnNewWant).assertEqual(0);
expect(flagOnNewWant).assertEqual(0);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
done()
}
}
function UnSubscribeCallback() {
function UnSubscribeCallback() {
...
@@ -222,6 +204,12 @@ export default function abilityTest(abilityContext) {
...
@@ -222,6 +204,12 @@ export default function abilityTest(abilityContext) {
var flagOnForeground = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
var flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0300====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
abilityContext.startAbility({
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapa.MainAbility",
abilityName: "com.example.newwanthapa.MainAbility",
...
@@ -231,12 +219,6 @@ export default function abilityTest(abilityContext) {
...
@@ -231,12 +219,6 @@ export default function abilityTest(abilityContext) {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
})
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0300====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function SubscribeCallBack(err, data) {
function SubscribeCallBack(err, data) {
console.debug("ACTS_NewWant_Test_0300====>Subscribe CallBack data:====>"
console.debug("ACTS_NewWant_Test_0300====>Subscribe CallBack data:====>"
...
@@ -294,6 +276,12 @@ export default function abilityTest(abilityContext) {
...
@@ -294,6 +276,12 @@ export default function abilityTest(abilityContext) {
var flagOnForeground = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
var flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0400====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
abilityContext.startAbility({
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapa.SecondAbility",
abilityName: "com.example.newwanthapa.SecondAbility",
...
@@ -303,13 +291,6 @@ export default function abilityTest(abilityContext) {
...
@@ -303,13 +291,6 @@ export default function abilityTest(abilityContext) {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
})
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0400====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function SubscribeCallBack(err, data) {
function SubscribeCallBack(err, data) {
console.debug("ACTS_NewWant_Test_0400====>Subscribe CallBack data:====>"
console.debug("ACTS_NewWant_Test_0400====>Subscribe CallBack data:====>"
...
@@ -348,6 +329,7 @@ export default function abilityTest(abilityContext) {
...
@@ -348,6 +329,7 @@ export default function abilityTest(abilityContext) {
expect(flagOnNewWant).assertEqual(1);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
done()
}
}
function UnSubscribeCallback() {
function UnSubscribeCallback() {
...
@@ -369,6 +351,12 @@ export default function abilityTest(abilityContext) {
...
@@ -369,6 +351,12 @@ export default function abilityTest(abilityContext) {
var flagOnForeground = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
var flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0500====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
abilityContext.startAbility({
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapb.MainAbility",
abilityName: "com.example.newwanthapb.MainAbility",
...
@@ -378,12 +366,6 @@ export default function abilityTest(abilityContext) {
...
@@ -378,12 +366,6 @@ export default function abilityTest(abilityContext) {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
})
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0500====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function SubscribeCallBack(err, data) {
function SubscribeCallBack(err, data) {
console.debug("ACTS_NewWant_Test_0500====>Subscribe CallBack data:====>"
console.debug("ACTS_NewWant_Test_0500====>Subscribe CallBack data:====>"
...
@@ -422,6 +404,7 @@ export default function abilityTest(abilityContext) {
...
@@ -422,6 +404,7 @@ export default function abilityTest(abilityContext) {
expect(flagOnNewWant).assertEqual(1);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
done()
}
}
function UnSubscribeCallback() {
function UnSubscribeCallback() {
...
@@ -443,6 +426,12 @@ export default function abilityTest(abilityContext) {
...
@@ -443,6 +426,12 @@ export default function abilityTest(abilityContext) {
var flagOnForeground = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
var flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0600====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
abilityContext.startAbility({
abilityContext.startAbility({
bundleName: "com.example.newwanthapa",
bundleName: "com.example.newwanthapa",
abilityName: "com.example.newwanthapc.MainAbility",
abilityName: "com.example.newwanthapc.MainAbility",
...
@@ -452,12 +441,6 @@ export default function abilityTest(abilityContext) {
...
@@ -452,12 +441,6 @@ export default function abilityTest(abilityContext) {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
})
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0600====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function SubscribeCallBack(err, data) {
function SubscribeCallBack(err, data) {
console.debug("ACTS_NewWant_Test_0600====>Subscribe CallBack data:====>"
console.debug("ACTS_NewWant_Test_0600====>Subscribe CallBack data:====>"
...
@@ -496,6 +479,7 @@ export default function abilityTest(abilityContext) {
...
@@ -496,6 +479,7 @@ export default function abilityTest(abilityContext) {
expect(flagOnNewWant).assertEqual(1);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
done()
}
}
function UnSubscribeCallback() {
function UnSubscribeCallback() {
...
@@ -517,6 +501,12 @@ export default function abilityTest(abilityContext) {
...
@@ -517,6 +501,12 @@ export default function abilityTest(abilityContext) {
var flagOnForeground = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
var flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0700====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
abilityContext.startAbility({
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapa.SecondAbility",
abilityName: "com.example.newwanthapa.SecondAbility",
...
@@ -526,12 +516,6 @@ export default function abilityTest(abilityContext) {
...
@@ -526,12 +516,6 @@ export default function abilityTest(abilityContext) {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
})
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0700====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function SubscribeCallBack(err, data) {
function SubscribeCallBack(err, data) {
console.debug("ACTS_NewWant_Test_0700====>Subscribe CallBack data:====>"
console.debug("ACTS_NewWant_Test_0700====>Subscribe CallBack data:====>"
...
@@ -570,6 +554,7 @@ export default function abilityTest(abilityContext) {
...
@@ -570,6 +554,7 @@ export default function abilityTest(abilityContext) {
expect(flagOnNewWant).assertEqual(1);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
done()
}
}
function UnSubscribeCallback() {
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0700====>UnSubscribe CallBack====>");
console.debug("ACTS_NewWant_Test_0700====>UnSubscribe CallBack====>");
...
@@ -590,6 +575,12 @@ export default function abilityTest(abilityContext) {
...
@@ -590,6 +575,12 @@ export default function abilityTest(abilityContext) {
var flagOnForeground = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
var flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0800====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
abilityContext.startAbility({
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapa.SecondAbility",
abilityName: "com.example.newwanthapa.SecondAbility",
...
@@ -599,12 +590,7 @@ export default function abilityTest(abilityContext) {
...
@@ -599,12 +590,7 @@ export default function abilityTest(abilityContext) {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
})
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0800====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function SubscribeCallBack(err, data) {
function SubscribeCallBack(err, data) {
console.debug("ACTS_NewWant_Test_0800====>Subscribe CallBack data:====>"
console.debug("ACTS_NewWant_Test_0800====>Subscribe CallBack data:====>"
...
@@ -643,11 +629,381 @@ export default function abilityTest(abilityContext) {
...
@@ -643,11 +629,381 @@ export default function abilityTest(abilityContext) {
expect(flagOnNewWant).assertEqual(1);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
done()
}
}
function UnSubscribeCallback() {
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0800====>UnSubscribe CallBack====>");
console.debug("ACTS_NewWant_Test_0800====>UnSubscribe CallBack====>");
done();
done();
}
}
})
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_001
* @tc.name StartServiceExtensionAbility with incorrect abilityName.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_001', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension1"
};
await globalThis.AbilityContext.startServiceExtensionAbility(want).then((data) => {
console.log('Ability: startServiceExtensionAbility success:' + JSON.stringify(data));
expect("case execute failed").assertEqual(data);
}).catch((error) => {
console.error(`Ability: startServiceExtensionAbility failed: ${JSON.stringify(error)}`);
expect(EXTENSION_INFO_ERR).assertEqual(error.code);
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_002
* @tc.name StopServiceExtensionAbility with incorrect bundleName.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_002', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest1",
abilityName: "FirstExtension"
};
await globalThis.AbilityContext.stopServiceExtensionAbility(want).then((data) => {
console.log(`Ability: stopServiceExtensionAbility success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}).catch((error) => {
console.error(`Ability: stopServiceExtensionAbility failed: ${JSON.stringify(error)}`);
expect(EXTENSION_INFO_ERR).assertEqual(error.code);
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_003
* @tc.name startServiceExtensionAbilityWithAccount with incorrect userId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_003', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
};
await globalThis.AbilityContext.startServiceExtensionAbilityWithAccount(want, 999).then((data) => {
console.log(`Ability: startServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual("data");
}).catch((error) => {
console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`);
expect(USERID_ERR).assertEqual(error.code);
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_004
* @tc.name stopServiceExtensionAbilityWithAccount with incorrect userId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_004', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
};
await globalThis.AbilityContext.stopServiceExtensionAbilityWithAccount(want, 999).then((data) => {
console.log(`Ability: stopServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}).catch((error) => {
console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`);
expect(USERID_ERR).assertEqual(error.code);
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_005
* @tc.name StartServiceExtensionAbility with incorrect abilityName.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_005', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension1"
}
await globalThis.AbilityContext.startServiceExtensionAbility(want, (err, data) => {
if (err.code) {
console.error(`Ability: startServiceExtensionAbility failed: ${JSON.stringify(err)}`);
expect(EXTENSION_INFO_ERR).assertEqual(err.code);
} else {
console.log(`Ability: startServiceExtensionAbility success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}
done()
})
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_006
* @tc.name StopServiceExtensionAbility with incorrect bundleName.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_006', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest1",
abilityName: "FirstExtension"
};
await globalThis.AbilityContext.stopServiceExtensionAbility(want, (err, data) => {
if (err.code) {
console.error(`Ability: stopServiceExtensionAbility failed: ${JSON.stringify(err)}`);
expect(EXTENSION_INFO_ERR).assertEqual(err.code);
} else {
console.log(`Ability: stopServiceExtensionAbility success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}
done()
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_007
* @tc.name startServiceExtensionAbilityWithAccount with incorrect userId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_007', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
};
await globalThis.AbilityContext.startServiceExtensionAbilityWithAccount(want, 999, (err, data) => {
if (err.code) {
console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
} else {
console.log(`Ability: startServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}
done()
})
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_008
* @tc.name stopServiceExtensionAbilityWithAccount with incorrect userId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_008', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
};
globalThis.AbilityContext.stopServiceExtensionAbilityWithAccount(want, 999, (err, data) => {
if (err.code) {
console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
} else {
console.log(`Ability: stopServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}
done()
})
})
/*
* @tc.number SUB_AA_AMS_Context_0100
* @tc.name Get the resource and path of the context.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_0100', 0, async function (done) {
expect("/data/storage/el2/base/haps/entry_test/cache").assertEqual(globalThis.AbilityContext.cacheDir)
expect("/data/storage/el2/base/haps/entry_test/temp").assertEqual(globalThis.AbilityContext.tempDir)
expect("/data/storage/el2/base/haps/entry_test/files").assertEqual(globalThis.AbilityContext.filesDir)
expect("/data/storage/el2/database/entry_test").assertEqual(globalThis.AbilityContext.databaseDir)
expect("/data/storage/el2/base/haps/entry_test/preferences").assertEqual(globalThis.AbilityContext.preferencesDir)
expect("/data/storage/el1/bundle").assertEqual(globalThis.AbilityContext.bundleCodeDir)
expect("/data/storage/el2/distributedfiles").assertEqual(globalThis.AbilityContext.distributedFilesDir)
expect(1).assertEqual(globalThis.AbilityContext.area)
globalThis.AbilityContext.resourceManager.getConfiguration((err, data) => {
if (err.code != 0 ) {
console.error(`Ability: getConfiguration failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
done()
} else {
console.log(`Ability: getConfiguration success: ${JSON.stringify(data)}`);
expect(1).assertEqual(data.direction)
done()
}
})
let moduleContext = globalThis.AbilityContext.createModuleContext("module1")
expect("/data/storage/el2/base/cache").assertEqual(moduleContext.cacheDir)
done()
})
/*
* @tc.number SUB_AA_Form_provider_getFormsInfo_0100
* @tc.name The provider calls the getFormsInfo interface to obtain form information.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_getFormsInfo_0100', 0, async function (done) {
console.info("SUB_AA_Form_provider_getFormsInfo_0100");
formProvider.getFormsInfo((err, value) => {
console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err));
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value));
if (err.code != 0) {
expect(0).assertEqual(2)
} else {
for(let i = 0; i < value.length; i++){
if(value[i].bundleName == "com.example.extensionapitest" && value[i].name == "widget"){
trueInfo = value[i]
console.info("formProvider::GetFormsInfoTest trueInfo: " + JSON.stringify(trueInfo));
}
}
}
checkFormInfo(trueInfo)
done()
})
done()
})
/*
* @tc.number SUB_AA_Form_provider_getFormsInfo_0200
* @tc.name The provider calls the getFormsInfo interface to obtain form information in the module1.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_getFormsInfo_0200', 0, async function (done) {
console.info("SUB_AA_Form_provider_getFormsInfo_0200");
const filter: formInfo.FormInfoFilter = {
moduleName: "module1"
};
formProvider.getFormsInfo(filter, (err, value) => {
console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err));
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value));
if (err.code != 0) {
expect(0).assertEqual(2)
} else {
if(value.length == 0){
expect(1).assertEqual(0)
}else{
for(let i = 0; i < value.length; i++){
if(value[i].bundleName == "com.example.extensionapitest" && value[i].name == "widget1"){
trueInfo = value[i]
console.info("formProvider::GetFormsInfoTest trueInfo: " + JSON.stringify(trueInfo));
}
}
}
}
checkFormInfoModule1(trueInfo)
done();
})
done()
})
/*
* @tc.number SUB_AA_Form_provider_TestFormErr_0100
* @tc.name Get all FormError types.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_TestFormErr_0100', 0, async function (done) {
console.info("SUB_AA_Form_provider_TestFormErr_0100");
expect(7).assertEqual(formError.FormError.ERR_ADD_INVALID_PARAM)
expect(10).assertEqual(formError.FormError.ERR_BIND_PROVIDER_FAILED)
expect(8).assertEqual(formError.FormError.ERR_CFG_NOT_MATCH_ID)
expect(1).assertEqual(formError.FormError.ERR_COMMON)
expect(31).assertEqual(formError.FormError.ERR_FORM_DUPLICATE_ADDED)
expect(20).assertEqual(formError.FormError.ERR_FORM_FA_NOT_INSTALLED)
expect(18).assertEqual(formError.FormError.ERR_FORM_NO_SUCH_ABILITY)
expect(19).assertEqual(formError.FormError.ERR_FORM_NO_SUCH_DIMENSION)
expect(17).assertEqual(formError.FormError.ERR_FORM_NO_SUCH_MODULE)
expect(5).assertEqual(formError.FormError.ERR_GET_BUNDLE_FAILED)
expect(4).assertEqual(formError.FormError.ERR_GET_INFO_FAILED)
expect(6).assertEqual(formError.FormError.ERR_GET_LAYOUT_FAILED)
expect(36).assertEqual(formError.FormError.ERR_IN_RECOVERY)
expect(15).assertEqual(formError.FormError.ERR_MAX_FORMS_PER_CLIENT)
expect(12).assertEqual(formError.FormError.ERR_MAX_INSTANCES_PER_FORM)
expect(11).assertEqual(formError.FormError.ERR_MAX_SYSTEM_FORMS)
expect(16).assertEqual(formError.FormError.ERR_MAX_SYSTEM_TEMP_FORMS)
expect(9).assertEqual(formError.FormError.ERR_NOT_EXIST_ID)
expect(13).assertEqual(formError.FormError.ERR_OPERATION_FORM_NOT_SELF)
expect(2).assertEqual(formError.FormError.ERR_PERMISSION_DENY)
expect(14).assertEqual(formError.FormError.ERR_PROVIDER_DEL_FAIL)
expect(30).assertEqual(formError.FormError.ERR_SYSTEM_RESPONSES_FAILED)
done()
})
/*
* @tc.number SUB_AA_Form_provider_TestFormInfo_0100
* @tc.name Get all FormInfo types
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_TestFormInfo_0100', 0, async function (done) {
console.info("SUB_AA_Form_provider_TestFormInfo_0100");
expect("ohos.extra.param.key.form_dimension").assertEqual(FormInfo.FormParam.DIMENSION_KEY)
expect("ohos.extra.param.key.form_height").assertEqual(FormInfo.FormParam.HEIGHT_KEY)
expect("ohos.extra.param.key.module_name").assertEqual(FormInfo.FormParam.MODULE_NAME_KEY)
expect("ohos.extra.param.key.form_name").assertEqual(FormInfo.FormParam.NAME_KEY)
expect("ohos.extra.param.key.form_temporary").assertEqual(FormInfo.FormParam.TEMPORARY_KEY)
expect("ohos.extra.param.key.form_width").assertEqual(FormInfo.FormParam.WIDTH_KEY)
expect(0).assertEqual(FormInfo.FormState.DEFAULT)
expect(1).assertEqual(FormInfo.FormState.READY)
expect(-1).assertEqual(FormInfo.FormState.UNKNOWN)
expect(0).assertEqual(FormInfo.ColorMode.MODE_DARK)
expect(1).assertEqual(FormInfo.ColorMode.MODE_LIGHT)
done();
});
})
})
}
function checkFormInfoModule1(formInfo){
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(formInfo));
expect("com.example.extensionapitest").assertEqual(formInfo.bundleName)
expect("module1").assertEqual(formInfo.moduleName)
expect("FormAbility").assertEqual(formInfo.abilityName)
expect("widget1").assertEqual(formInfo.name)
expect("This is a service widget.").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect(FormInfo.ColorMode.MODE_DARK).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(0).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("ability://xxxxx").assertEqual(formInfo.formConfigAbility)
expect(1).assertEqual(formInfo.updateDuration)
expect(2).assertEqual(formInfo.defaultDimension)
expect(2).assertEqual(formInfo.supportDimensions[0])
}
function checkFormInfo(formInfo){
console.info("formProvider::GetFormsInfoTest formInfo: " + JSON.stringify(formInfo));
expect("com.example.extensionapitest").assertEqual(formInfo.bundleName)
expect("entry").assertEqual(formInfo.moduleName)
expect("FormAbility").assertEqual(formInfo.abilityName)
expect("widget").assertEqual(formInfo.name)
expect("This is a service widget.").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(0).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("ability://xxxxx").assertEqual(formInfo.formConfigAbility)
expect(1).assertEqual(formInfo.updateDuration)
expect(2).assertEqual(formInfo.defaultDimension)
expect(2).assertEqual(formInfo.supportDimensions[0])
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录