Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6e0c37ee
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
接近 2 年 前同步成功
通知
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看板
提交
6e0c37ee
编写于
7月 12, 2022
作者:
C
chengxingzhen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
元能力新增api覆盖
Signed-off-by:
N
chengxingzhen
<
chengxingzhen@huawei.com
>
上级
662db2c3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
169 addition
and
0 deletion
+169
-0
ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/MainAbility/MainAbility.ts
...overhaptest/entry/src/main/ets/MainAbility/MainAbility.ts
+1
-0
ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ContextEnvironmentTest.test.ets
...t/entry/src/main/ets/test/ContextEnvironmentTest.test.ets
+166
-0
ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ListTest.ets
...over/apicoverhaptest/entry/src/main/ets/test/ListTest.ets
+2
-0
未找到文件。
ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
6e0c37ee
...
...
@@ -19,6 +19,7 @@ export default class MainAbility extends Ability {
onCreate
(
want
,
launchParam
)
{
console
.
log
(
"
[Demo] MainAbility onCreate
"
)
globalThis
.
abilityWant
=
want
;
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
}
onDestroy
()
{
...
...
ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ContextEnvironmentTest.test.ets
0 → 100644
浏览文件 @
6e0c37ee
/*
* Copyright (c) 2022 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
var TAG: string = ''
export default function ContextEnvironmentTest(applicationContext) {
describe('ContextEnvironmentTest', function () {
var isUpdated = false;
var update_language = "";
var callbackid_NA = 100
var callbackid_errorNum = -1
var callbackid_errorType = "test"
var callNum = 0;
let envCallback = {
onConfigurationUpdated(config) {
console.info(TAG, `envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
update_language = config.language;
isUpdated = true;
}
}
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
let gSetTimeout = 1000
beforeEach(async (done) => {
isUpdated = false;
setTimeout(function () {
done();
}, gSetTimeout);
})
afterEach(async (done) => {
isUpdated = false;
setTimeout(function () {
done();
}, gSetTimeout);
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0400
* @tc.name Multiple registrations and deregistration.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0400', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0400 ==== '
console.info(TAG, `begin`)
for (let i = 0;i < 10;i++) {
// registerEnvironmentCallback
var callbackId = applicationContext.registerEnvironmentCallback(envCallback);
var code = undefined
console.info(TAG + "callbackId = " + callbackId + " callNum = " + callNum)
await sleep(1000)
// unregisterEnvironmentCallback
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback first err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
code = error.code
})
await sleep(1000)
expect(callbackId).assertEqual(callNum)
expect(code).assertEqual(0)
callNum++;
}
done()
console.info(TAG, `end`)
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0500
* @tc.name unregisterEnvironmentCallback interface input parameter is a nonexistent ID.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0500', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0500 ==== '
console.info(TAG, `begin`)
applicationContext.unregisterEnvironmentCallback(callbackid_NA, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
expect(error.code).assertEqual(1)
console.info(TAG, `end`)
done();
})
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0600
* @tc.name unregisterEnvironmentCallback interface input parameter is negative.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0600', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0600 ==== '
console.info(TAG, `begin`)
applicationContext.unregisterEnvironmentCallback(callbackid_errorNum, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
expect(error.code).assertEqual(1)
console.info(TAG, `end`)
done();
})
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0700
* @tc.name unregisterEnvironmentCallback interface input parameter is of wrong type.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0700', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0700 ==== '
console.info(TAG, `begin`)
applicationContext.unregisterEnvironmentCallback(callbackid_errorType, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
expect(error.code).assertEqual(1)
console.info(TAG, `end`)
done();
})
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0800
* @tc.name unregisterEnvironmentCallback interface input parameter is undefined.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0800', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0800 ==== '
console.info(TAG, `begin`)
applicationContext.unregisterEnvironmentCallback(undefined).then((data) => {
console.info(TAG + "unregisterEnvironmentCallback data is : " + JSON.stringify(data))
expect().assertFail();
}).catch((error) => {
console.info(TAG + "unregisterEnvironmentCallback err is : " + JSON.stringify(error))
expect(error.code).assertEqual(1)
});
console.info(TAG, `end`)
done();
})
})
}
\ No newline at end of file
ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ListTest.ets
浏览文件 @
6e0c37ee
...
...
@@ -16,10 +16,12 @@
import apiCoverAbility from './ApiCoverAbility.test'
import verificationTest from './VerificationTest'
import wantAgentCover from './WantAgentCover.test'
import contextEnvironmentTest from './ContextEnvironmentTest.test';
export default function List(context) {
apiCoverAbility(context)
verificationTest(context)
wantAgentCover(context)
contextEnvironmentTest(globalThis.applicationContext)
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录