提交 8d6b93ca 编写于 作者: O openharmony_ci 提交者: Gitee

!571 修改hiappevent的测试用例

Merge pull request !571 from 土行孙/master
...@@ -17,6 +17,9 @@ import device from '@system.device' ...@@ -17,6 +17,9 @@ import device from '@system.device'
import router from '@system.router' import router from '@system.router'
import {Core, ExpectExtend, Constant} from 'deccjsunit/index' import {Core, ExpectExtend, Constant} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default { export default {
data: { data: {
title: "" title: ""
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +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 HiAppEvent from '@ohos.hiappevent' import HiAppEvent from '@ohos.hiAppEvent'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import Constant from 'deccjsunit/src/Constant' import Constant from 'deccjsunit/src/Constant'
...@@ -22,50 +22,23 @@ describe('HiAppEventApiTest', function () { ...@@ -22,50 +22,23 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi01 * @tc.name testHiAppEventApi01
* @tc.desc HiAppEvent write interface test. * @tc.desc HiAppEvent write interface test.
*/ */
it('testHiAppEventApi01', 1, function () { it('testHiAppEventApi01', 1, async function (done) {
console.info('testHiAppEventApi01 start') console.info('testHiAppEventApi01 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_int": 100, "key_string": "demo",
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_int", 100, "key_float", 1.1, "key_string", "demo", "key_bool", true, "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3],
"key_array_int", [1, 2, 3], "key_array_float", [1.1, 2.2, 3.3], "key_array_str", ["a", "b", "c"], "key_array_bool", [true, false], "key_array_str": ["a", "b", "c"], "key_array_bool": [true, false],"key_array_int2": [1, 2, 3],
"key_array_int2", [1, 2, 3], "key_array_float2", [1.1, 2.2, 3.3], "key_array_str2", ["a", "b", "c"], "key_array_bool2", [true, false], "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]},
(err, value) => {
console.log(`HiAppEvent into callback`);
if (err) {
console.error(`HiAppEvent json-callback-error code=${err.code}`);
result = false;
} else {
console.log(`HiAppEvent json-callback-success value=${value}`);
result = true;
}
console.log(`HiAppEvent result=${result}`);
expect(result).assertTrue();
console.log(`HiAppEvent result123=${result}`);
});
})
/**
* @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0200
* @tc.name testHiAppEventApi02
* @tc.desc HiAppEvent write json interface test.
*/
it('testHiAppEventApi02', 1, function () {
console.info('testHiAppEventApi02 start')
var result = false;
HiAppEvent.writeJson("writeJson", HiAppEvent.EventType.FAULT, {"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_array_str": ["a", "b", "c"], "key_array_bool": [true, false]
,"key_array_int2": [1, 2, 3], "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]
},
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue()
}); });
}) })
...@@ -74,22 +47,23 @@ describe('HiAppEventApiTest', function () { ...@@ -74,22 +47,23 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi03 * @tc.name testHiAppEventApi03
* @tc.desc HiAppEvent write EventType of STATISTIC. * @tc.desc HiAppEvent write EventType of STATISTIC.
*/ */
it('testHiAppEventApi03', 2, function () { it('testHiAppEventApi03', 2, async function (done) {
console.info('testHiAppEventApi03 start') console.info('testHiAppEventApi03 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.STATISTIC, {"key_int": 100, "key_string": "demo",
HiAppEvent.write("write", HiAppEvent.EventType.STATISTIC, "key_int", 100, "key_float", 1.1, "key_string", "demo", "key_bool", true, "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3],
"key_array_int", [1, 2, 3], "key_array_float", [1.1, 2.2, 3.3], "key_array_str", ["a", "b", "c"], "key_array_bool", [true, false], "key_array_str": ["a", "b", "c"], "key_array_bool": [true, false],"key_array_int2": [1, 2, 3],
"key_array_int2", [1, 2, 3], "key_array_float2", [1.1, 2.2, 3.3], "key_array_str2", ["a", "b", "c"], "key_array_bool2", [true, false], "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]},
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi03 end') console.info('testHiAppEventApi03 end')
}) })
...@@ -99,22 +73,23 @@ describe('HiAppEventApiTest', function () { ...@@ -99,22 +73,23 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi04 * @tc.name testHiAppEventApi04
* @tc.desc HiAppEvent write EventType of SECURITY. * @tc.desc HiAppEvent write EventType of SECURITY.
*/ */
it('testHiAppEventApi04', 2, function () { it('testHiAppEventApi04', 2, async function (done) {
console.info('testHiAppEventApi04 start') console.info('testHiAppEventApi04 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.SECURITY, {"key_int": 100, "key_string": "demo",
HiAppEvent.write("write", HiAppEvent.EventType.SECURITY, "key_int", 100, "key_float", 1.1, "key_string", "demo", "key_bool", true, "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3],
"key_array_int", [1, 2, 3], "key_array_float", [1.1, 2.2, 3.3], "key_array_str", ["a", "b", "c"], "key_array_bool", [true, false], "key_array_str": ["a", "b", "c"], "key_array_bool": [true, false],"key_array_int2": [1, 2, 3],
"key_array_int2", [1, 2, 3], "key_array_float2", [1.1, 2.2, 3.3], "key_array_str2", ["a", "b", "c"], "key_array_bool2", [true, false], "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]},
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi04 end') console.info('testHiAppEventApi04 end')
}) })
...@@ -124,22 +99,23 @@ describe('HiAppEventApiTest', function () { ...@@ -124,22 +99,23 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi05 * @tc.name testHiAppEventApi05
* @tc.desc HiAppEvent write EventType of BEHAVIOR. * @tc.desc HiAppEvent write EventType of BEHAVIOR.
*/ */
it('testHiAppEventApi05', 2, function () { it('testHiAppEventApi05', 2, async function (done) {
console.info('testHiAppEventApi05 start') console.info('testHiAppEventApi05 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.BEHAVIOR, {"key_int": 100, "key_string": "demo",
HiAppEvent.write("write", HiAppEvent.EventType.BEHAVIOR, "key_int", 100, "key_float", 1.1, "key_string", "demo", "key_bool", true, "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3],
"key_array_int", [1, 2, 3], "key_array_float", [1.1, 2.2, 3.3], "key_array_str", ["a", "b", "c"], "key_array_bool", [true, false], "key_array_str": ["a", "b", "c"], "key_array_bool": [true, false],"key_array_int2": [1, 2, 3],
"key_array_int2", [1, 2, 3], "key_array_float2", [1.1, 2.2, 3.3], "key_array_str2", ["a", "b", "c"], "key_array_bool2", [true, false], "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]},
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi05 end') console.info('testHiAppEventApi05 end')
}) })
...@@ -150,20 +126,20 @@ describe('HiAppEventApiTest', function () { ...@@ -150,20 +126,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi06 * @tc.name testHiAppEventApi06
* @tc.desc HiAppEvent write datatype of int. * @tc.desc HiAppEvent write datatype of int.
*/ */
it('testHiAppEventApi06', 2, function () { it('testHiAppEventApi06', 2, async function (done) {
console.info('testHiAppEventApi06 start') console.info('testHiAppEventApi06 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_int":100},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_int", 100,
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi06 end') console.info('testHiAppEventApi06 end')
}) })
...@@ -173,20 +149,20 @@ describe('HiAppEventApiTest', function () { ...@@ -173,20 +149,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi07 * @tc.name testHiAppEventApi07
* @tc.desc HiAppEvent write datatype of int array. * @tc.desc HiAppEvent write datatype of int array.
*/ */
it('testHiAppEventApi07', 2, function () { it('testHiAppEventApi07', 2, async function (done) {
console.info('testHiAppEventApi07 start') console.info('testHiAppEventApi07 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_int_array":[100, 200]},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_int_array", [100, 200],
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi07 end') console.info('testHiAppEventApi07 end')
}) })
...@@ -196,20 +172,20 @@ describe('HiAppEventApiTest', function () { ...@@ -196,20 +172,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi08 * @tc.name testHiAppEventApi08
* @tc.desc HiAppEvent write datatype of float. * @tc.desc HiAppEvent write datatype of float.
*/ */
it('testHiAppEventApi08', 2, function () { it('testHiAppEventApi08', 2, async function (done) {
console.info('testHiAppEventApi08 start') console.info('testHiAppEventApi08 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_float":1.1},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_float", 1.1,
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi08 end') console.info('testHiAppEventApi08 end')
}) })
...@@ -219,20 +195,20 @@ describe('HiAppEventApiTest', function () { ...@@ -219,20 +195,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi09 * @tc.name testHiAppEventApi09
* @tc.desc HiAppEvent write datatype of float array. * @tc.desc HiAppEvent write datatype of float array.
*/ */
it('testHiAppEventApi09', 3, function () { it('testHiAppEventApi09', 3, async function (done) {
console.info('testHiAppEventApi09 start') console.info('testHiAppEventApi09 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_float_array":[1.1, 1.2]},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_float_array", [1.1, 1.2],
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi09 end') console.info('testHiAppEventApi09 end')
}) })
...@@ -242,20 +218,20 @@ describe('HiAppEventApiTest', function () { ...@@ -242,20 +218,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi10 * @tc.name testHiAppEventApi10
* @tc.desc HiAppEvent write datatype of string. * @tc.desc HiAppEvent write datatype of string.
*/ */
it('testHiAppEventApi10', 3, function () { it('testHiAppEventApi10', 3, async function (done) {
console.info('testHiAppEventApi10 start') console.info('testHiAppEventApi10 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_string":"hello world"},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_string", "hello world",
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi10 end') console.info('testHiAppEventApi10 end')
}) })
...@@ -265,20 +241,20 @@ describe('HiAppEventApiTest', function () { ...@@ -265,20 +241,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi11 * @tc.name testHiAppEventApi11
* @tc.desc HiAppEvent write datatype of string array. * @tc.desc HiAppEvent write datatype of string array.
*/ */
it('testHiAppEventApi11', 3, function () { it('testHiAppEventApi11', 3, async function (done) {
console.info('testHiAppEventApi11 start') console.info('testHiAppEventApi11 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_string_array":["hello world", "hello world2"]},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_string_array", ["hello world", "hello world2"],
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi11 end') console.info('testHiAppEventApi11 end')
}) })
...@@ -288,20 +264,20 @@ describe('HiAppEventApiTest', function () { ...@@ -288,20 +264,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi12 * @tc.name testHiAppEventApi12
* @tc.desc HiAppEvent write datatype of bool with true. * @tc.desc HiAppEvent write datatype of bool with true.
*/ */
it('testHiAppEventApi12', 3, function () { it('testHiAppEventApi12', 3, async function (done) {
console.info('testHiAppEventApi12 start') console.info('testHiAppEventApi12 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_bool":true},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_bool", true,
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi12 end') console.info('testHiAppEventApi12 end')
}) })
...@@ -311,20 +287,20 @@ describe('HiAppEventApiTest', function () { ...@@ -311,20 +287,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi13 * @tc.name testHiAppEventApi13
* @tc.desc HiAppEvent write datatype of bool with false. * @tc.desc HiAppEvent write datatype of bool with false.
*/ */
it('testHiAppEventApi13', 3, function () { it('testHiAppEventApi13', 3, async function (done) {
console.info('testHiAppEventApi13 start') console.info('testHiAppEventApi13 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_bool":false},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_bool", false,
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi13 end') console.info('testHiAppEventApi13 end')
}) })
...@@ -334,20 +310,20 @@ describe('HiAppEventApiTest', function () { ...@@ -334,20 +310,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi14 * @tc.name testHiAppEventApi14
* @tc.desc HiAppEvent write datatype of bool array. * @tc.desc HiAppEvent write datatype of bool array.
*/ */
it('testHiAppEventApi14', 3, function () { it('testHiAppEventApi14', 3, async function (done) {
console.info('testHiAppEventApi14 start') console.info('testHiAppEventApi14 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_bool_array":[false, true]},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_bool_array", [false, true],
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi14 end') console.info('testHiAppEventApi14 end')
}) })
...@@ -357,20 +333,20 @@ describe('HiAppEventApiTest', function () { ...@@ -357,20 +333,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi15 * @tc.name testHiAppEventApi15
* @tc.desc HiAppEvent write datatype of char. * @tc.desc HiAppEvent write datatype of char.
*/ */
it('testHiAppEventApi15', 3, function () { it('testHiAppEventApi15', 3, async function (done) {
console.info('testHiAppEventApi15 start') console.info('testHiAppEventApi15 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_char":'c'},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_char", 'c',
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi15 end') console.info('testHiAppEventApi15 end')
}) })
...@@ -380,20 +356,20 @@ describe('HiAppEventApiTest', function () { ...@@ -380,20 +356,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi16 * @tc.name testHiAppEventApi16
* @tc.desc HiAppEvent write datatype of long. * @tc.desc HiAppEvent write datatype of long.
*/ */
it('testHiAppEventApi16', 3, function () { it('testHiAppEventApi16', 3, async function (done) {
console.info('testHiAppEventApi16 start') console.info('testHiAppEventApi16 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_long":2147483647},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_long", 2147483647,
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi16 end') console.info('testHiAppEventApi16 end')
}) })
...@@ -403,20 +379,20 @@ describe('HiAppEventApiTest', function () { ...@@ -403,20 +379,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi17 * @tc.name testHiAppEventApi17
* @tc.desc HiAppEvent write datatype of double. * @tc.desc HiAppEvent write datatype of double.
*/ */
it('testHiAppEventApi17', 3, function () { it('testHiAppEventApi17', 3, async function (done) {
console.info('testHiAppEventApi17 start') console.info('testHiAppEventApi17 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_double":100.123},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_double", 100.123,
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi17 end') console.info('testHiAppEventApi17 end')
}) })
...@@ -426,21 +402,20 @@ describe('HiAppEventApiTest', function () { ...@@ -426,21 +402,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi18 * @tc.name testHiAppEventApi18
* @tc.desc HiAppEvent write datatype of long. * @tc.desc HiAppEvent write datatype of long.
*/ */
it('testHiAppEventApi18', 3, function () { it('testHiAppEventApi18', 3, async function (done) {
console.info('testHiAppEventApi18 start') console.info('testHiAppEventApi18 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_longlong":2147483647},
HiAppEvent.write("write", HiAppEvent.EventType.FAULT, "key_longlong", 2147483647,
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi18 end') console.info('testHiAppEventApi18 end')
}) })
...@@ -450,21 +425,20 @@ describe('HiAppEventApiTest', function () { ...@@ -450,21 +425,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi19 * @tc.name testHiAppEventApi19
* @tc.desc HiAppEvent write eventtype of none exists. * @tc.desc HiAppEvent write eventtype of none exists.
*/ */
it('testHiAppEventApi19', 3, function () { it('testHiAppEventApi19', 3, async function (done) {
console.info('testHiAppEventApi19 start') console.info('testHiAppEventApi19 start')
var result = false; HiAppEvent.write("write", HiAppEvent.EventType.BEHAVIOR + 1, {"key_longlong":2147483647},
HiAppEvent.write("write", HiAppEvent.EventType.BEHAVIOR + 1, "key_longlong", 2147483647,
(err, value) => { (err, value) => {
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}`);
result = false; expect().assertFail();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent json-callback-success value=${value}`);
result = true; expect(value == 0).assertTrue();
done();
} }
expect(result).assertFalse();
}); });
console.info('testHiAppEventApi19 end') console.info('testHiAppEventApi19 end')
}) })
...@@ -474,21 +448,20 @@ describe('HiAppEventApiTest', function () { ...@@ -474,21 +448,20 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi20 * @tc.name testHiAppEventApi20
* @tc.desc HiAppEvent write empty eventname . * @tc.desc HiAppEvent write empty eventname .
*/ */
it('testHiAppEventApi20', 3, function () { it('testHiAppEventApi20', 3, async function (done) {
console.info('testHiAppEventApi20 start') console.info('testHiAppEventApi20 start')
var result = false; HiAppEvent.write("", HiAppEvent.EventType.FAULT, {"key_longlong":2147483647},
HiAppEvent.write("", HiAppEvent.EventType.FAULT, "key_longlong", 2147483647,
(err, value) => { (err, value) => {
console.log(`HiAppEvent into json-callback`); console.log(`HiAppEvent20 into json-callback`);
if (err) { if (err) {
console.error(`HiAppEvent json-callback-error code=${err.code}`); console.error(`HiAppEvent20 json-callback-error code=${err.code}`);
result = false; expect(err.code == -1).assertTrue();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent20 json-callback-success value=${value}`);
result = true; expect().assertFail();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi20 end') console.info('testHiAppEventApi20 end')
}) })
...@@ -498,27 +471,26 @@ describe('HiAppEventApiTest', function () { ...@@ -498,27 +471,26 @@ describe('HiAppEventApiTest', function () {
* @tc.name testHiAppEventApi21 * @tc.name testHiAppEventApi21
* @tc.desc HiAppEvent write long eventname . * @tc.desc HiAppEvent write long eventname .
*/ */
it('testHiAppEventApi21', 3, function () { it('testHiAppEventApi21', 3, async function (done) {
console.info('testHiAppEventApi21 start') console.info('testHiAppEventApi21 start')
var result = false;
var i = 0; var i = 0;
var strlong = ""; var strlong = "";
while (i < 1000) { while (i < 1000) {
strlong = strlong + "eventnamelong"; strlong = strlong + "eventnamelong";
i = i + 1; i = i + 1;
} }
HiAppEvent.write(strlong, HiAppEvent.EventType.FAULT, "key_longlong", 2147483647, HiAppEvent.write(strlong, HiAppEvent.EventType.FAULT, {"key_longlong":2147483647},
(err, value) => { (err, value) => {
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(`HiAppEvent21 json-callback-error code=${err.code}`);
result = false; expect(err.code == -1).assertTrue();
done();
} else { } else {
console.log(`HiAppEvent json-callback-success value=${value}`); console.log(`HiAppEvent21 json-callback-success value=${value}`);
result = true; expect().assertFail();
done();
} }
expect(result).assertTrue();
}); });
console.info('testHiAppEventApi21 end') console.info('testHiAppEventApi21 end')
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册