未验证 提交 8634a31c 编写于 作者: O openharmony_ci 提交者: Gitee

!6124 【挑单monthly】【元能力】新增errorManager接口XTS

Merge pull request !6124 from donglin/monthly
......@@ -14,6 +14,7 @@
*/
import apiCoverAbility from './ApiCoverAbility.test'
import newApiCoverAbility from './NewApiCoverAbility.test'
import verificationTest from './VerificationTest'
import wantAgentCover from './WantAgentCover.test'
import contextEnvironmentTest from './ContextEnvironmentTest.test';
......@@ -21,6 +22,7 @@ import contextEnvironmentTest from './ContextEnvironmentTest.test';
export default function List() {
apiCoverAbility()
newApiCoverAbility()
verificationTest()
wantAgentCover()
contextEnvironmentTest(globalThis.applicationContext)
......
/*
* 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 '@ohos/hypium'
import errorManager from '@ohos.app.ability.errorManager';
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
export default function ApiCoverTest() {
describe('NewApiCoverTestTest', function () {
afterEach(async (done) => {
setTimeout(function () {
done();
}, 2500);
})
/*
* @tc.number SUB_AA_ReisterErrorObserver_New_0100
* @tc.name Test ReisterErrorObserver.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ReisterErrorObserver_New_0100', 0, async function (done) {
let errorObserver:errorManager.ErrorObserver;
errorObserver = {
onUnhandledException:(errMessage) => {
console.info("SUB_AA_ReisterErrorObserver_0100" + JSON.stringify(errMessage));
}
}
try {
let errCodeId = errorManager.on("error", errorObserver)
expect(errCodeId).assertEqual(0)
errorManager.off("error", errCodeId).then((data)=>{
expect(data).assertEqual(undefined)
done();
}).catch((err)=>{
expect().assertFail()
done();
})
} catch (error) {
expect().assertFail()
done();
}
});
/*
* @tc.number SUB_AA_ReisterErrorObserver_0200
* @tc.name Test unregisterErrorObserver with error number.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ReisterErrorObserver_New_0200', 0, async function (done) {
try {
errorManager.off("error", -1).then((data)=>{
expect().assertFail()
done();
}).catch((err)=>{
expect(err.code).assertEqual(401)
done();
})
} catch (error) {
expect().assertFail()
done();
}
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册