未验证 提交 18497aef 编写于 作者: O openharmony_ci 提交者: Gitee

!5859 HiAppEvent新增异常处理后适配xts用例

Merge pull request !5859 from lyj/master
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import HiAppEventV9 from '@ohos.hiviewdfx.hiAppEvent'
import HiAppEvent from '@ohos.hiAppEvent' import HiAppEvent from '@ohos.hiAppEvent'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import Constant from 'deccjsunit/src/Constant' import Constant from 'deccjsunit/src/Constant'
...@@ -434,11 +435,11 @@ describe('HiAppEventApiTest', function () { ...@@ -434,11 +435,11 @@ describe('HiAppEventApiTest', function () {
console.log('HiAppEvent into json-callback'); console.log('HiAppEvent into json-callback');
if (err) { if (err) {
console.error(`HiAppEvent json-callback-error code=${err.code}`); console.error(`HiAppEvent json-callback-error code=${err.code}`);
expect().assertFail(); expect(err.code).assertEqual(-2);
done(); done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
expect(value == 0).assertTrue(); expect().assertFail();
done(); done();
} }
}); });
...@@ -586,10 +587,10 @@ describe('HiAppEventApiTest', function () { ...@@ -586,10 +587,10 @@ describe('HiAppEventApiTest', function () {
*/ */
it('testHiAppEventApi26', 2, async function (done) { it('testHiAppEventApi26', 2, async function (done) {
console.info('testHiAppEventApi26 start') console.info('testHiAppEventApi26 start')
HiAppEvent.write({ HiAppEventV9.write({
domain: "test_domain", domain: "test_domain",
name: "write", name: "write",
eventType: HiAppEvent.EventType.FAULT, eventType: HiAppEventV9.EventType.FAULT,
params: { params: {
"key_int": 100, "key_string": "demo", "key_int": 100, "key_string": "demo",
"key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3], "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3],
...@@ -612,10 +613,10 @@ describe('HiAppEventApiTest', function () { ...@@ -612,10 +613,10 @@ describe('HiAppEventApiTest', function () {
*/ */
it('testHiAppEventApi27', 2, async function (done) { it('testHiAppEventApi27', 2, async function (done) {
console.info('testHiAppEventApi27 start') console.info('testHiAppEventApi27 start')
HiAppEvent.write({ HiAppEventV9.write({
domain: "test_domain", domain: "test_domain",
name: "test_event", name: "test_event",
eventType: HiAppEvent.EventType.FAULT, eventType: HiAppEventV9.EventType.FAULT,
params: { params: {
"key_int": 100, "key_string": "demo", "key_int": 100, "key_string": "demo",
"key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3], "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3],
......
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import HiAppEventV9 from '@ohos.hiviewdfx.hiAppEvent'
import HiAppEvent from '@ohos.hiAppEvent' import HiAppEvent from '@ohos.hiAppEvent'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import Constant from 'deccjsunit/src/Constant' import Constant from 'deccjsunit/src/Constant'
...@@ -26,7 +27,7 @@ describe('HiAppEventSubTest', function () { ...@@ -26,7 +27,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub01', 3, async function (done) { it('HiAppEventSub01', 3, async function (done) {
console.info('testHiAppEventSub01 start') console.info('testHiAppEventSub01 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
triggerCondition: { triggerCondition: {
row: 1 row: 1
...@@ -107,7 +108,7 @@ describe('HiAppEventSubTest', function () { ...@@ -107,7 +108,7 @@ describe('HiAppEventSubTest', function () {
}, 2000) }, 2000)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub01 end') console.info('HiAppEventSub01 end')
}, 4000) }, 4000)
...@@ -129,7 +130,7 @@ describe('HiAppEventSubTest', function () { ...@@ -129,7 +130,7 @@ describe('HiAppEventSubTest', function () {
return; return;
} }
} }
let holder = HiAppEvent.addWatcher({ let holder = HiAppEventV9.addWatcher({
name: "watcher2", name: "watcher2",
}); });
HiAppEvent.write("test_event2", HiAppEvent.EventType.FAULT, {"key_int":100}, HiAppEvent.write("test_event2", HiAppEvent.EventType.FAULT, {"key_int":100},
...@@ -191,7 +192,7 @@ describe('HiAppEventSubTest', function () { ...@@ -191,7 +192,7 @@ describe('HiAppEventSubTest', function () {
expect(true).assertTrue() expect(true).assertTrue()
} }
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher2"}) HiAppEventV9.removeWatcher({"name":"watcher2"})
done() done()
console.info('HiAppEventSub02 end') console.info('HiAppEventSub02 end')
}, 5000) }, 5000)
...@@ -205,7 +206,8 @@ describe('HiAppEventSubTest', function () { ...@@ -205,7 +206,8 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub03', 3, async function (done) { it('HiAppEventSub03', 3, async function (done) {
console.info('testHiAppEventSub03 start') console.info('testHiAppEventSub03 start')
let result = HiAppEvent.addWatcher({ try {
let result = HiAppEventV9.addWatcher({
name: 123, name: 123,
appEventFilters: [ appEventFilters: [
{ {
...@@ -233,6 +235,10 @@ describe('HiAppEventSubTest', function () { ...@@ -233,6 +235,10 @@ describe('HiAppEventSubTest', function () {
}) })
console.info("HiAppEventSub_result" + result) console.info("HiAppEventSub_result" + result)
expect(result == null).assertTrue(); expect(result == null).assertTrue();
} catch (error) {
expect(error.code).assertEqual("401");
}
HiAppEvent.write("test_event3", HiAppEvent.EventType.FAULT, {"key_int":100}, HiAppEvent.write("test_event3", HiAppEvent.EventType.FAULT, {"key_int":100},
(err, value) => { (err, value) => {
console.log('HiAppEvent into json-callback'); console.log('HiAppEvent into json-callback');
...@@ -279,7 +285,7 @@ describe('HiAppEventSubTest', function () { ...@@ -279,7 +285,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub03 end') console.info('HiAppEventSub03 end')
}, 1000) }, 1000)
...@@ -292,7 +298,8 @@ describe('HiAppEventSubTest', function () { ...@@ -292,7 +298,8 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub04', 3, async function (done) { it('HiAppEventSub04', 3, async function (done) {
console.info('testHiAppEventSub04 start') console.info('testHiAppEventSub04 start')
let result = HiAppEvent.addWatcher({ try {
let result = HiAppEventV9.addWatcher({
name: true, name: true,
appEventFilters: [ appEventFilters: [
{ {
...@@ -318,7 +325,11 @@ describe('HiAppEventSubTest', function () { ...@@ -318,7 +325,11 @@ describe('HiAppEventSubTest', function () {
expect(true).assertTrue() expect(true).assertTrue()
} }
}) })
expect(result == null).assertTrue();; expect(result == null).assertTrue();
} catch (error) {
expect(error.code).assertEqual("401");
}
HiAppEvent.write("test_event4", HiAppEvent.EventType.FAULT, {"key_int":100}, HiAppEvent.write("test_event4", HiAppEvent.EventType.FAULT, {"key_int":100},
(err, value) => { (err, value) => {
console.log('HiAppEvent into json-callback'); console.log('HiAppEvent into json-callback');
...@@ -364,7 +375,7 @@ describe('HiAppEventSubTest', function () { ...@@ -364,7 +375,7 @@ describe('HiAppEventSubTest', function () {
} }
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub04 end') console.info('HiAppEventSub04 end')
}, 1000) }, 1000)
...@@ -377,7 +388,8 @@ describe('HiAppEventSubTest', function () { ...@@ -377,7 +388,8 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub05', 3, async function (done) { it('HiAppEventSub05', 3, async function (done) {
console.info('testHiAppEventSub05 start') console.info('testHiAppEventSub05 start')
let result = HiAppEvent.addWatcher({ try {
let result = HiAppEventV9.addWatcher({
appEventFilters: [ appEventFilters: [
{ {
domain: "default", domain: "default",
...@@ -402,6 +414,10 @@ describe('HiAppEventSubTest', function () { ...@@ -402,6 +414,10 @@ describe('HiAppEventSubTest', function () {
} }
}) })
expect(result == null).assertTrue(); expect(result == null).assertTrue();
} catch (error) {
expect(error.code).assertEqual("401");
}
HiAppEvent.write("test_event5", HiAppEvent.EventType.FAULT, {"key_int":100}, HiAppEvent.write("test_event5", HiAppEvent.EventType.FAULT, {"key_int":100},
(err, value) => { (err, value) => {
console.log('HiAppEvent into json-callback'); console.log('HiAppEvent into json-callback');
...@@ -448,7 +464,7 @@ describe('HiAppEventSubTest', function () { ...@@ -448,7 +464,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub05 end') console.info('HiAppEventSub05 end')
}, 1000) }, 1000)
...@@ -461,7 +477,7 @@ describe('HiAppEventSubTest', function () { ...@@ -461,7 +477,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub06', 3, async function (done) { it('HiAppEventSub06', 3, async function (done) {
console.info('testHiAppEventSub06 start') console.info('testHiAppEventSub06 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -475,8 +491,8 @@ describe('HiAppEventSubTest', function () { ...@@ -475,8 +491,8 @@ describe('HiAppEventSubTest', function () {
onTrigger: function (curRow, curSize, holder) { onTrigger: function (curRow, curSize, holder) {
let eventPkg = holder.takeNext(); let eventPkg = holder.takeNext();
if (eventPkg == null) { if (eventPkg == null) {
// expect().assertFail()
console.info("HiAppEventSub_result6:" + eventPkg) console.info("HiAppEventSub_result6:" + eventPkg)
return
} }
console.info("eventPkg.packageId=" + eventPkg.packageId); console.info("eventPkg.packageId=" + eventPkg.packageId);
console.info("eventPkg.row=" + eventPkg.row); console.info("eventPkg.row=" + eventPkg.row);
...@@ -534,7 +550,7 @@ describe('HiAppEventSubTest', function () { ...@@ -534,7 +550,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub06 end') console.info('HiAppEventSub06 end')
}, 1000) }, 1000)
...@@ -547,7 +563,8 @@ describe('HiAppEventSubTest', function () { ...@@ -547,7 +563,8 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub07', 3, async function (done) { it('HiAppEventSub07', 3, async function (done) {
console.info('testHiAppEventSub07 start') console.info('testHiAppEventSub07 start')
let result = HiAppEvent.addWatcher({ try {
let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -575,6 +592,10 @@ describe('HiAppEventSubTest', function () { ...@@ -575,6 +592,10 @@ describe('HiAppEventSubTest', function () {
} }
}) })
expect(result == null).assertTrue(); expect(result == null).assertTrue();
} catch (error) {
expect(error.code).assertEqual("11102002");
}
HiAppEvent.write("test_event7", HiAppEvent.EventType.FAULT, {"key_int":100}, HiAppEvent.write("test_event7", HiAppEvent.EventType.FAULT, {"key_int":100},
(err, value) => { (err, value) => {
console.log('HiAppEvent into json-callback'); console.log('HiAppEvent into json-callback');
...@@ -588,7 +609,7 @@ describe('HiAppEventSubTest', function () { ...@@ -588,7 +609,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub07 end') console.info('HiAppEventSub07 end')
}, 1000) }, 1000)
...@@ -601,7 +622,7 @@ describe('HiAppEventSubTest', function () { ...@@ -601,7 +622,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub08', 3, async function (done) { it('HiAppEventSub08', 3, async function (done) {
console.info('testHiAppEventSub08 start') console.info('testHiAppEventSub08 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -642,7 +663,7 @@ describe('HiAppEventSubTest', function () { ...@@ -642,7 +663,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub08 end') console.info('HiAppEventSub08 end')
}, 1000) }, 1000)
...@@ -655,7 +676,7 @@ describe('HiAppEventSubTest', function () { ...@@ -655,7 +676,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub09', 3, async function (done) { it('HiAppEventSub09', 3, async function (done) {
console.info('testHiAppEventSub09 start') console.info('testHiAppEventSub09 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -729,7 +750,7 @@ describe('HiAppEventSubTest', function () { ...@@ -729,7 +750,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub09 end') console.info('HiAppEventSub09 end')
}, 1000) }, 1000)
...@@ -742,7 +763,7 @@ describe('HiAppEventSubTest', function () { ...@@ -742,7 +763,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub10', 3, async function (done) { it('HiAppEventSub10', 3, async function (done) {
console.info('testHiAppEventSub10 start') console.info('testHiAppEventSub10 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -815,7 +836,7 @@ describe('HiAppEventSubTest', function () { ...@@ -815,7 +836,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub10 end') console.info('HiAppEventSub10 end')
}, 1000) }, 1000)
...@@ -828,7 +849,7 @@ describe('HiAppEventSubTest', function () { ...@@ -828,7 +849,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub11', 3, async function (done) { it('HiAppEventSub11', 3, async function (done) {
console.info('testHiAppEventSub11 start') console.info('testHiAppEventSub11 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -900,7 +921,7 @@ describe('HiAppEventSubTest', function () { ...@@ -900,7 +921,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub11 end') console.info('HiAppEventSub11 end')
}, 1000) }, 1000)
...@@ -913,7 +934,7 @@ describe('HiAppEventSubTest', function () { ...@@ -913,7 +934,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub12', 3, async function (done) { it('HiAppEventSub12', 3, async function (done) {
console.info('testHiAppEventSub12 start') console.info('testHiAppEventSub12 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -985,7 +1006,7 @@ describe('HiAppEventSubTest', function () { ...@@ -985,7 +1006,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub12 end') console.info('HiAppEventSub12 end')
}, 1000) }, 1000)
...@@ -998,7 +1019,7 @@ describe('HiAppEventSubTest', function () { ...@@ -998,7 +1019,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub13', 3, async function (done) { it('HiAppEventSub13', 3, async function (done) {
console.info('testHiAppEventSub13 start') console.info('testHiAppEventSub13 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1014,8 +1035,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1014,8 +1035,7 @@ describe('HiAppEventSubTest', function () {
onTrigger: function (curRow, curSize, holder) { onTrigger: function (curRow, curSize, holder) {
let eventPkg = holder.takeNext(); let eventPkg = holder.takeNext();
if (eventPkg == null) { if (eventPkg == null) {
// expect().assertFail() return
console.info("HiAppEventSub_result13:" + eventPkg)
} }
console.info("eventPkg.packageId=" + eventPkg.packageId); console.info("eventPkg.packageId=" + eventPkg.packageId);
console.info("eventPkg.row=" + eventPkg.row); console.info("eventPkg.row=" + eventPkg.row);
...@@ -1073,7 +1093,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1073,7 +1093,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub13 end') console.info('HiAppEventSub13 end')
}, 1000) }, 1000)
...@@ -1086,7 +1106,8 @@ describe('HiAppEventSubTest', function () { ...@@ -1086,7 +1106,8 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub14', 3, async function (done) { it('HiAppEventSub14', 3, async function (done) {
console.info('testHiAppEventSub14 start') console.info('testHiAppEventSub14 start')
let result = HiAppEvent.addWatcher({ try {
let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1113,6 +1134,10 @@ describe('HiAppEventSubTest', function () { ...@@ -1113,6 +1134,10 @@ describe('HiAppEventSubTest', function () {
} }
}) })
expect(result == null).assertTrue(); expect(result == null).assertTrue();
} catch (error) {
expect(error.code).assertEqual("401");
}
HiAppEvent.write("test_event14", HiAppEvent.EventType.FAULT, {"key_int":100}, HiAppEvent.write("test_event14", HiAppEvent.EventType.FAULT, {"key_int":100},
(err, value) => { (err, value) => {
console.log('HiAppEvent into json-callback'); console.log('HiAppEvent into json-callback');
...@@ -1159,7 +1184,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1159,7 +1184,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub14 end') console.info('HiAppEventSub14 end')
}, 1000) }, 1000)
...@@ -1167,12 +1192,13 @@ describe('HiAppEventSubTest', function () { ...@@ -1167,12 +1192,13 @@ describe('HiAppEventSubTest', function () {
/** /**
* @tc.number DFX_DFT_HiAppEvent_Sub_1500 * @tc.number DFX_DFT_HiAppEvent_Sub_1500
* @tc.name 验证调用hiAppEvent.addWatcher,eventType为非法,事件订阅成功 * @tc.name 验证调用hiAppEvent.addWatcher,eventType为非法,事件订阅失败
* @tc.desc HiAppEvent write interface test. * @tc.desc HiAppEvent write interface test.
*/ */
it('HiAppEventSub15', 3, async function (done) { it('HiAppEventSub15', 3, async function (done) {
console.info('testHiAppEventSub15 start') console.info('testHiAppEventSub15 start')
let result = HiAppEvent.addWatcher({ try {
let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1198,7 +1224,11 @@ describe('HiAppEventSubTest', function () { ...@@ -1198,7 +1224,11 @@ describe('HiAppEventSubTest', function () {
expect(true).assertTrue() expect(true).assertTrue()
} }
}) })
expect(result != null).assertTrue(); expect(result == null).assertTrue();
} catch (error) {
expect(error.code).assertEqual("401");
}
HiAppEvent.write("test_event15", HiAppEvent.EventType.FAULT, {"key_int":100}, HiAppEvent.write("test_event15", HiAppEvent.EventType.FAULT, {"key_int":100},
(err, value) => { (err, value) => {
console.log('HiAppEvent into json-callback'); console.log('HiAppEvent into json-callback');
...@@ -1245,7 +1275,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1245,7 +1275,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub15 end') console.info('HiAppEventSub15 end')
}, 1000) }, 1000)
...@@ -1267,7 +1297,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1267,7 +1297,7 @@ describe('HiAppEventSubTest', function () {
return; return;
} }
} }
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
triggerCondition: { triggerCondition: {
row: 3 row: 3
...@@ -1327,7 +1357,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1327,7 +1357,7 @@ describe('HiAppEventSubTest', function () {
sleep(3000) sleep(3000)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub16 end') console.info('HiAppEventSub16 end')
}, 1000) }, 1000)
...@@ -1350,7 +1380,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1350,7 +1380,7 @@ describe('HiAppEventSubTest', function () {
return; return;
} }
} }
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
triggerCondition: { triggerCondition: {
row: 4 row: 4
...@@ -1410,7 +1440,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1410,7 +1440,7 @@ describe('HiAppEventSubTest', function () {
sleep(3000) sleep(3000)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub17 end') console.info('HiAppEventSub17 end')
}, 1000) }, 1000)
...@@ -1423,7 +1453,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1423,7 +1453,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub18', 3, async function (done) { it('HiAppEventSub18', 3, async function (done) {
console.info('testHiAppEventSub18 start') console.info('testHiAppEventSub18 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1464,7 +1494,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1464,7 +1494,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub18 end') console.info('HiAppEventSub18 end')
}, 1000) }, 1000)
...@@ -1477,7 +1507,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1477,7 +1507,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub19', 3, async function (done) { it('HiAppEventSub19', 3, async function (done) {
console.info('testHiAppEventSub19 start') console.info('testHiAppEventSub19 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1516,7 +1546,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1516,7 +1546,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub19 end') console.info('HiAppEventSub19 end')
}, 1000) }, 1000)
...@@ -1529,7 +1559,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1529,7 +1559,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub20', 3, async function (done) { it('HiAppEventSub20', 3, async function (done) {
console.info('testHiAppEventSub20 start') console.info('testHiAppEventSub20 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1568,7 +1598,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1568,7 +1598,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub20 end') console.info('HiAppEventSub20 end')
}, 1000) }, 1000)
...@@ -1581,7 +1611,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1581,7 +1611,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub21', 3, async function (done) { it('HiAppEventSub21', 3, async function (done) {
console.info('testHiAppEventSub21 start') console.info('testHiAppEventSub21 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1622,7 +1652,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1622,7 +1652,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub21 end') console.info('HiAppEventSub21 end')
}, 1000) }, 1000)
...@@ -1644,7 +1674,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1644,7 +1674,7 @@ describe('HiAppEventSubTest', function () {
return; return;
} }
} }
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1683,7 +1713,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1683,7 +1713,7 @@ describe('HiAppEventSubTest', function () {
}); });
sleep(30000) sleep(30000)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub22 end') console.info('HiAppEventSub22 end')
}, 1000) }, 1000)
...@@ -1705,7 +1735,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1705,7 +1735,7 @@ describe('HiAppEventSubTest', function () {
return; return;
} }
} }
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1744,7 +1774,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1744,7 +1774,7 @@ describe('HiAppEventSubTest', function () {
}); });
sleep(1000) sleep(1000)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub23 end') console.info('HiAppEventSub23 end')
}, 1000) }, 1000)
...@@ -1766,7 +1796,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1766,7 +1796,7 @@ describe('HiAppEventSubTest', function () {
return; return;
} }
} }
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1802,7 +1832,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1802,7 +1832,7 @@ describe('HiAppEventSubTest', function () {
}); });
sleep(1000) sleep(1000)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub24 end') console.info('HiAppEventSub24 end')
}, 1000) }, 1000)
...@@ -1824,7 +1854,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1824,7 +1854,7 @@ describe('HiAppEventSubTest', function () {
return; return;
} }
} }
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1865,7 +1895,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1865,7 +1895,7 @@ describe('HiAppEventSubTest', function () {
}); });
sleep(30000) sleep(30000)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub28 end') console.info('HiAppEventSub28 end')
}, 1000) }, 1000)
...@@ -1878,7 +1908,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1878,7 +1908,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub29', 3, async function (done) { it('HiAppEventSub29', 3, async function (done) {
console.info('testHiAppEventSub29 start') console.info('testHiAppEventSub29 start')
let result = HiAppEvent.addWatcher({ let result = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [ appEventFilters: [
{ {
...@@ -1917,7 +1947,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1917,7 +1947,7 @@ describe('HiAppEventSubTest', function () {
}); });
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
console.info('HiAppEventSub29 end') console.info('HiAppEventSub29 end')
}, 1000) }, 1000)
...@@ -1930,7 +1960,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1930,7 +1960,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub25', 3, async function (done) { it('HiAppEventSub25', 3, async function (done) {
console.info('testHiAppEventSub25 start') console.info('testHiAppEventSub25 start')
let holder = HiAppEvent.addWatcher({ let holder = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
}); });
setTimeout(() => { setTimeout(() => {
...@@ -1949,7 +1979,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1949,7 +1979,7 @@ describe('HiAppEventSubTest', function () {
}, 500) }, 500)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher1"}) HiAppEventV9.removeWatcher({"name":"watcher1"})
done() done()
}, 1000) }, 1000)
...@@ -1968,7 +1998,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1968,7 +1998,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub26', 3, async function (done) { it('HiAppEventSub26', 3, async function (done) {
console.info('testHiAppEventSub26 start') console.info('testHiAppEventSub26 start')
let holder = HiAppEvent.addWatcher({ let holder = HiAppEventV9.addWatcher({
name: "watcher1", name: "watcher1",
}); });
setTimeout(() => { setTimeout(() => {
...@@ -1987,7 +2017,7 @@ describe('HiAppEventSubTest', function () { ...@@ -1987,7 +2017,7 @@ describe('HiAppEventSubTest', function () {
}, 500) }, 500)
setTimeout(() => { setTimeout(() => {
HiAppEvent.removeWatcher({"name":"watcher2"}) HiAppEventV9.removeWatcher({"name":"watcher2"})
done() done()
}, 1000) }, 1000)
...@@ -2005,7 +2035,7 @@ describe('HiAppEventSubTest', function () { ...@@ -2005,7 +2035,7 @@ describe('HiAppEventSubTest', function () {
*/ */
it('HiAppEventSub27', 3, function () { it('HiAppEventSub27', 3, function () {
console.info('testHiAppEventSub27 start') console.info('testHiAppEventSub27 start')
HiAppEvent.clearData() HiAppEventV9.clearData()
expect(true).assertTrue() expect(true).assertTrue()
console.info('HiAppEventSub27 end') console.info('HiAppEventSub27 end')
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册