11401458bSopenharmony_ci/*
21401458bSopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
31401458bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41401458bSopenharmony_ci * you may not use this file except in compliance with the License.
51401458bSopenharmony_ci * You may obtain a copy of the License at
61401458bSopenharmony_ci *
71401458bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81401458bSopenharmony_ci *
91401458bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101401458bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111401458bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121401458bSopenharmony_ci * See the License for the specific language governing permissions and
131401458bSopenharmony_ci * limitations under the License.
141401458bSopenharmony_ci */
151401458bSopenharmony_ci
161401458bSopenharmony_ciimport hiSysEvent from "@ohos.hiSysEvent"
171401458bSopenharmony_ci
181401458bSopenharmony_ciimport {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
191401458bSopenharmony_ci
201401458bSopenharmony_cidescribe('hiSysEventJsUnitTest', function () {
211401458bSopenharmony_ci  beforeAll(function() {
221401458bSopenharmony_ci
231401458bSopenharmony_ci    /**
241401458bSopenharmony_ci     * @tc.setup: setup invoked before all test cases
251401458bSopenharmony_ci     */
261401458bSopenharmony_ci    console.info('hiSysEventJsUnitTest beforeAll called')
271401458bSopenharmony_ci  })
281401458bSopenharmony_ci
291401458bSopenharmony_ci  afterAll(function() {
301401458bSopenharmony_ci
311401458bSopenharmony_ci    /**
321401458bSopenharmony_ci     * @tc.teardown: teardown invoked after all test cases
331401458bSopenharmony_ci     */
341401458bSopenharmony_ci    console.info('hiSysEventJsUnitTest afterAll called')
351401458bSopenharmony_ci  })
361401458bSopenharmony_ci
371401458bSopenharmony_ci  beforeEach(function() {
381401458bSopenharmony_ci
391401458bSopenharmony_ci    /**
401401458bSopenharmony_ci     * @tc.setup: setup invoked before each test case
411401458bSopenharmony_ci     */
421401458bSopenharmony_ci    console.info('hiSysEventJsUnitTest beforeEach called')
431401458bSopenharmony_ci  })
441401458bSopenharmony_ci
451401458bSopenharmony_ci  afterEach(function() {
461401458bSopenharmony_ci
471401458bSopenharmony_ci    /**
481401458bSopenharmony_ci     * @tc.teardown: teardown invoked after each test case
491401458bSopenharmony_ci     */
501401458bSopenharmony_ci    console.info('hiSysEventJsUnitTest afterEach called')
511401458bSopenharmony_ci  })
521401458bSopenharmony_ci
531401458bSopenharmony_ci  const DEFAULT_QUERY_TIME = -1
541401458bSopenharmony_ci
551401458bSopenharmony_ci  const DEFAULT_ID = 1
561401458bSopenharmony_ci
571401458bSopenharmony_ci  const PERMISSION_ERR = 201
581401458bSopenharmony_ci
591401458bSopenharmony_ci  const PARAM_CHECK_ERR = 401
601401458bSopenharmony_ci
611401458bSopenharmony_ci  const INVALID_QUERY_RULE_ERR = 11200302
621401458bSopenharmony_ci
631401458bSopenharmony_ci  const QUERY_TOO_FREQUENTLY_ERR = 11200304
641401458bSopenharmony_ci
651401458bSopenharmony_ci  const DELAY_1500_MS = 1500
661401458bSopenharmony_ci
671401458bSopenharmony_ci  const DELAY_2000_MS = 2000
681401458bSopenharmony_ci
691401458bSopenharmony_ci  const QUERY_1_ITEM = 1
701401458bSopenharmony_ci
711401458bSopenharmony_ci  const QUERY_2_ITEMS = 2
721401458bSopenharmony_ci
731401458bSopenharmony_ci  const defaultEventInfo = {
741401458bSopenharmony_ci    PID: DEFAULT_ID,
751401458bSopenharmony_ci    UID: DEFAULT_ID,
761401458bSopenharmony_ci    PACKAGE_NAME: "com.ohos.testHiSysEvent",
771401458bSopenharmony_ci    PROCESS_NAME: "hiview js test suite",
781401458bSopenharmony_ci    MSG: "no msg."
791401458bSopenharmony_ci  }
801401458bSopenharmony_ci
811401458bSopenharmony_ci  const defaultQueryArg = {
821401458bSopenharmony_ci    beginTime: DEFAULT_QUERY_TIME,
831401458bSopenharmony_ci    endTime: DEFAULT_QUERY_TIME,
841401458bSopenharmony_ci    maxEvents: -1, // -1 means query cnt with no limit
851401458bSopenharmony_ci  }
861401458bSopenharmony_ci
871401458bSopenharmony_ci  const queryArgWithOneCnt = {
881401458bSopenharmony_ci    beginTime: DEFAULT_QUERY_TIME,
891401458bSopenharmony_ci    endTime: DEFAULT_QUERY_TIME,
901401458bSopenharmony_ci    maxEvents: QUERY_1_ITEM, // 1 is query count
911401458bSopenharmony_ci  }
921401458bSopenharmony_ci
931401458bSopenharmony_ci  const queryArgWithTwoCnt = {
941401458bSopenharmony_ci    beginTime: DEFAULT_QUERY_TIME,
951401458bSopenharmony_ci    endTime: DEFAULT_QUERY_TIME,
961401458bSopenharmony_ci    maxEvents: QUERY_2_ITEMS,
971401458bSopenharmony_ci  }
981401458bSopenharmony_ci
991401458bSopenharmony_ci  const queryArgWithFiveCnt = {
1001401458bSopenharmony_ci    beginTime: DEFAULT_QUERY_TIME,
1011401458bSopenharmony_ci    endTime: DEFAULT_QUERY_TIME,
1021401458bSopenharmony_ci    maxEvents: 5, // 5 is query count
1031401458bSopenharmony_ci  }
1041401458bSopenharmony_ci
1051401458bSopenharmony_ci  function GetParam(src, key) {
1061401458bSopenharmony_ci    return src["params"][key]
1071401458bSopenharmony_ci  }
1081401458bSopenharmony_ci
1091401458bSopenharmony_ci  function GetArrayIemParamByIndex(src, key, index) {
1101401458bSopenharmony_ci    let arrayInSrc = src["params"][key]
1111401458bSopenharmony_ci    if (index > arrayInSrc.length) {
1121401458bSopenharmony_ci      return undefined
1131401458bSopenharmony_ci    }
1141401458bSopenharmony_ci    return arrayInSrc[index]
1151401458bSopenharmony_ci  }
1161401458bSopenharmony_ci
1171401458bSopenharmony_ci  function writeEventWithAsyncWork(domain, name, eventType, params, errCallback, normalCallback, done) {
1181401458bSopenharmony_ci    try {
1191401458bSopenharmony_ci      hiSysEvent.write({
1201401458bSopenharmony_ci        domain: domain,
1211401458bSopenharmony_ci        name: name,
1221401458bSopenharmony_ci        eventType: eventType,
1231401458bSopenharmony_ci        params: params
1241401458bSopenharmony_ci      }, (err, val) => {
1251401458bSopenharmony_ci        if (err) {
1261401458bSopenharmony_ci          errCallback(err)
1271401458bSopenharmony_ci        } else {
1281401458bSopenharmony_ci          normalCallback(val)
1291401458bSopenharmony_ci        }
1301401458bSopenharmony_ci        done()
1311401458bSopenharmony_ci      })
1321401458bSopenharmony_ci    } catch (err) {
1331401458bSopenharmony_ci      expect(false).assertTrue()
1341401458bSopenharmony_ci      done()
1351401458bSopenharmony_ci    }
1361401458bSopenharmony_ci  }
1371401458bSopenharmony_ci
1381401458bSopenharmony_ci  function writeEventWithPromise(domain, name, eventType, params, errCallback, normalCallback, done) {
1391401458bSopenharmony_ci    try {
1401401458bSopenharmony_ci      hiSysEvent.write({
1411401458bSopenharmony_ci        domain: domain,
1421401458bSopenharmony_ci        name: name,
1431401458bSopenharmony_ci        eventType: eventType,
1441401458bSopenharmony_ci        params: params
1451401458bSopenharmony_ci      }).then((val) => {
1461401458bSopenharmony_ci        normalCallback(val)
1471401458bSopenharmony_ci        done()
1481401458bSopenharmony_ci      }).catch((err) => {
1491401458bSopenharmony_ci        errCallback(err)
1501401458bSopenharmony_ci        done()
1511401458bSopenharmony_ci      })
1521401458bSopenharmony_ci    } catch (err) {
1531401458bSopenharmony_ci      expect(false).assertTrue()
1541401458bSopenharmony_ci      done()
1551401458bSopenharmony_ci    }
1561401458bSopenharmony_ci  }
1571401458bSopenharmony_ci
1581401458bSopenharmony_ci  function writeCustomizedSysEvent(customized) {
1591401458bSopenharmony_ci    try {
1601401458bSopenharmony_ci      hiSysEvent.write({
1611401458bSopenharmony_ci        domain: "RELIABILITY",
1621401458bSopenharmony_ci        name: "STACK",
1631401458bSopenharmony_ci        eventType: hiSysEvent.EventType.FAULT,
1641401458bSopenharmony_ci        params: customized
1651401458bSopenharmony_ci      }, (err, val) => {
1661401458bSopenharmony_ci        if (err) {
1671401458bSopenharmony_ci          console.error(`callback: err.code = ${err.code}, error msg is ${err.message}`)
1681401458bSopenharmony_ci          expect(false).assertTrue()
1691401458bSopenharmony_ci          done()
1701401458bSopenharmony_ci        }
1711401458bSopenharmony_ci      })
1721401458bSopenharmony_ci    } catch (err) {
1731401458bSopenharmony_ci      expect(false).assertTrue()
1741401458bSopenharmony_ci      done()
1751401458bSopenharmony_ci    }
1761401458bSopenharmony_ci  }
1771401458bSopenharmony_ci
1781401458bSopenharmony_ci  function writeDefaultSysEvent() {
1791401458bSopenharmony_ci    writeCustomizedSysEvent(defaultEventInfo)
1801401458bSopenharmony_ci  }
1811401458bSopenharmony_ci
1821401458bSopenharmony_ci  function querySysEvent(queryArgs, querRules, onQueryCallback, onCompleteCallback,
1831401458bSopenharmony_ci    errCallback, done) {
1841401458bSopenharmony_ci    try {
1851401458bSopenharmony_ci      hiSysEvent.query(queryArgs, querRules, {
1861401458bSopenharmony_ci        onQuery: function (infos) {
1871401458bSopenharmony_ci          onQueryCallback(infos)
1881401458bSopenharmony_ci        },
1891401458bSopenharmony_ci        onComplete: function(reason, total) {
1901401458bSopenharmony_ci          onCompleteCallback(reason, total)
1911401458bSopenharmony_ci          done()
1921401458bSopenharmony_ci        }
1931401458bSopenharmony_ci      })
1941401458bSopenharmony_ci    } catch (err) {
1951401458bSopenharmony_ci      errCallback(err)
1961401458bSopenharmony_ci      done()
1971401458bSopenharmony_ci    }
1981401458bSopenharmony_ci  }
1991401458bSopenharmony_ci
2001401458bSopenharmony_ci  /**
2011401458bSopenharmony_ci   * @tc.desc: Test hisysevent writing with calling AsyncCallback.
2021401458bSopenharmony_ci   * @tc.level: Level 0
2031401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest001
2041401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest001
2051401458bSopenharmony_ci   * @tc.type: Function
2061401458bSopenharmony_ci   * @tc.size: MediumTest
2071401458bSopenharmony_ci   */
2081401458bSopenharmony_ci  it('hiSysEventJsUnitTest001', 0, async function (done) {
2091401458bSopenharmony_ci    writeEventWithAsyncWork("RELIABILITY", "STACK", hiSysEvent.EventType.FAULT, defaultEventInfo,
2101401458bSopenharmony_ci      (err) => {
2111401458bSopenharmony_ci        expect(false).assertTrue()
2121401458bSopenharmony_ci      },
2131401458bSopenharmony_ci      (val) => {
2141401458bSopenharmony_ci        expect(val).assertEqual(0)
2151401458bSopenharmony_ci      }, done)
2161401458bSopenharmony_ci  })
2171401458bSopenharmony_ci
2181401458bSopenharmony_ci  /**
2191401458bSopenharmony_ci   * @tc.desc: Test hisysevent writing with returning Promise.
2201401458bSopenharmony_ci   * @tc.level: Level 0
2211401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest002
2221401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest002
2231401458bSopenharmony_ci   * @tc.type: Function
2241401458bSopenharmony_ci   * @tc.size: MediumTest
2251401458bSopenharmony_ci   */
2261401458bSopenharmony_ci  it('hiSysEventJsUnitTest002', 0, async function (done) {
2271401458bSopenharmony_ci    writeEventWithPromise("RELIABILITY", "STACK", hiSysEvent.EventType.FAULT, defaultEventInfo,
2281401458bSopenharmony_ci      (err) => {
2291401458bSopenharmony_ci        expect(false).assertTrue()
2301401458bSopenharmony_ci      },
2311401458bSopenharmony_ci      (val) => {
2321401458bSopenharmony_ci        expect(val).assertEqual(0)
2331401458bSopenharmony_ci      }, done)
2341401458bSopenharmony_ci  })
2351401458bSopenharmony_ci
2361401458bSopenharmony_ci  /**
2371401458bSopenharmony_ci   * @tc.desc: Test function return of adding/remove hisysevent watcher result.
2381401458bSopenharmony_ci   * @tc.level: Level 0
2391401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest003
2401401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest003
2411401458bSopenharmony_ci   * @tc.type: Function
2421401458bSopenharmony_ci   * @tc.size: MediumTest
2431401458bSopenharmony_ci   */
2441401458bSopenharmony_ci  it('hiSysEventJsUnitTest003', 0, async function (done) {
2451401458bSopenharmony_ci    let watcher = {
2461401458bSopenharmony_ci      rules: [{
2471401458bSopenharmony_ci        domain: "RELIABILITY",
2481401458bSopenharmony_ci        name: "STACK",
2491401458bSopenharmony_ci        ruleType: hiSysEvent.RuleType.WHOLE_WORD,
2501401458bSopenharmony_ci      }],
2511401458bSopenharmony_ci      onEvent: (info) => {
2521401458bSopenharmony_ci      },
2531401458bSopenharmony_ci      onServiceDied: () => {
2541401458bSopenharmony_ci      }
2551401458bSopenharmony_ci    }
2561401458bSopenharmony_ci    try {
2571401458bSopenharmony_ci      hiSysEvent.addWatcher(watcher)
2581401458bSopenharmony_ci      hiSysEvent.removeWatcher(watcher)
2591401458bSopenharmony_ci      expect(true).assertTrue()
2601401458bSopenharmony_ci      done();
2611401458bSopenharmony_ci    } catch (err) {
2621401458bSopenharmony_ci      expect(err.code == PERMISSION_ERR).assertTrue()
2631401458bSopenharmony_ci      done()
2641401458bSopenharmony_ci    }
2651401458bSopenharmony_ci  })
2661401458bSopenharmony_ci
2671401458bSopenharmony_ci  /**
2681401458bSopenharmony_ci   * @tc.desc: Test watcher callback.
2691401458bSopenharmony_ci   * @tc.level: Level 0
2701401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest004
2711401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest004
2721401458bSopenharmony_ci   * @tc.type: Function
2731401458bSopenharmony_ci   * @tc.size: MediumTest
2741401458bSopenharmony_ci   */
2751401458bSopenharmony_ci  it('hiSysEventJsUnitTest004', 0, async function (done) {
2761401458bSopenharmony_ci    let watcher = {
2771401458bSopenharmony_ci      rules: [{
2781401458bSopenharmony_ci        domain: "RELIABILITY",
2791401458bSopenharmony_ci        name: "STACK",
2801401458bSopenharmony_ci        tag: "STABILITY",
2811401458bSopenharmony_ci        ruleType: hiSysEvent.RuleType.WHOLE_WORD,
2821401458bSopenharmony_ci      }],
2831401458bSopenharmony_ci      onEvent: (info) => {
2841401458bSopenharmony_ci        expect(Object.keys(info).length > 0).assertTrue()
2851401458bSopenharmony_ci      },
2861401458bSopenharmony_ci      onServiceDied: () => {
2871401458bSopenharmony_ci      }
2881401458bSopenharmony_ci    }
2891401458bSopenharmony_ci    try {
2901401458bSopenharmony_ci      hiSysEvent.addWatcher(watcher)
2911401458bSopenharmony_ci      writeDefaultSysEvent()
2921401458bSopenharmony_ci      setTimeout(() => {
2931401458bSopenharmony_ci        try {
2941401458bSopenharmony_ci          hiSysEvent.removeWatcher(watcher)
2951401458bSopenharmony_ci          expect(true).assertTrue()
2961401458bSopenharmony_ci          done()
2971401458bSopenharmony_ci        } catch (err) {
2981401458bSopenharmony_ci          expect(err.code == PERMISSION_ERR).assertTrue()
2991401458bSopenharmony_ci          done()
3001401458bSopenharmony_ci        }
3011401458bSopenharmony_ci      }, 1000)
3021401458bSopenharmony_ci    } catch (err) {
3031401458bSopenharmony_ci      expect(err.code == PERMISSION_ERR).assertTrue()
3041401458bSopenharmony_ci      done()
3051401458bSopenharmony_ci    }
3061401458bSopenharmony_ci  })
3071401458bSopenharmony_ci
3081401458bSopenharmony_ci  /**
3091401458bSopenharmony_ci   * @tc.desc: Test query callback.
3101401458bSopenharmony_ci   * @tc.level: Level 0
3111401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest005
3121401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest005
3131401458bSopenharmony_ci   * @tc.type: Function
3141401458bSopenharmony_ci   * @tc.size: MediumTest
3151401458bSopenharmony_ci   */
3161401458bSopenharmony_ci  it('hiSysEventJsUnitTest005', 0, async function (done) {
3171401458bSopenharmony_ci    try {
3181401458bSopenharmony_ci      writeDefaultSysEvent()
3191401458bSopenharmony_ci      setTimeout(() => {
3201401458bSopenharmony_ci        querySysEvent(queryArgWithTwoCnt,
3211401458bSopenharmony_ci          [{
3221401458bSopenharmony_ci            domain: "RELIABILITY",
3231401458bSopenharmony_ci            names: ["STACK"],
3241401458bSopenharmony_ci          }], (infos) => {
3251401458bSopenharmony_ci            expect(infos.length >= 0).assertTrue()
3261401458bSopenharmony_ci          }, (reason, total) => {
3271401458bSopenharmony_ci            expect(true).assertTrue()
3281401458bSopenharmony_ci          }, (err) => {
3291401458bSopenharmony_ci            expect(err.code == PERMISSION_ERR).assertTrue()
3301401458bSopenharmony_ci          }, done)
3311401458bSopenharmony_ci      }, 1000);
3321401458bSopenharmony_ci    } catch (err) {
3331401458bSopenharmony_ci      expect(err.code == PERMISSION_ERR).assertTrue()
3341401458bSopenharmony_ci      done()
3351401458bSopenharmony_ci    }
3361401458bSopenharmony_ci  })
3371401458bSopenharmony_ci
3381401458bSopenharmony_ci  /**
3391401458bSopenharmony_ci   * @tc.desc: Test query callback with domain which length is over 16.
3401401458bSopenharmony_ci   * @tc.level: Level 0
3411401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest006
3421401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest006
3431401458bSopenharmony_ci   * @tc.type: Function
3441401458bSopenharmony_ci   * @tc.size: MediumTest
3451401458bSopenharmony_ci   */
3461401458bSopenharmony_ci  it('hiSysEventJsUnitTest006', 0, async function (done) {
3471401458bSopenharmony_ci    console.info('hiSysEventJsUnitTest006 start')
3481401458bSopenharmony_ci    try {
3491401458bSopenharmony_ci      writeDefaultSysEvent()
3501401458bSopenharmony_ci      setTimeout(() => {
3511401458bSopenharmony_ci        querySysEvent(queryArgWithTwoCnt,
3521401458bSopenharmony_ci          [{
3531401458bSopenharmony_ci            domain: "RELIABILITY_RELIABILITY",
3541401458bSopenharmony_ci            names: ["STACK"],
3551401458bSopenharmony_ci          }], (infos) => {
3561401458bSopenharmony_ci            expect(infos.length >= 0).assertTrue()
3571401458bSopenharmony_ci          }, (reason, total) => {
3581401458bSopenharmony_ci            expect(true).assertTrue()
3591401458bSopenharmony_ci          }, (err) => {
3601401458bSopenharmony_ci            expect(err.code == INVALID_QUERY_RULE_ERR || err.code == QUERY_TOO_FREQUENTLY_ERR).assertTrue()
3611401458bSopenharmony_ci          }, done)
3621401458bSopenharmony_ci      }, 1000);
3631401458bSopenharmony_ci    } catch (err) {
3641401458bSopenharmony_ci      expect(false).assertTrue()
3651401458bSopenharmony_ci      done()
3661401458bSopenharmony_ci    }
3671401458bSopenharmony_ci  })
3681401458bSopenharmony_ci
3691401458bSopenharmony_ci  /**
3701401458bSopenharmony_ci   * @tc.desc: Test query callback with domain which length is over 32.
3711401458bSopenharmony_ci   * @tc.level: Level 0
3721401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest007
3731401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest007
3741401458bSopenharmony_ci   * @tc.type: Function
3751401458bSopenharmony_ci   * @tc.size: MediumTest
3761401458bSopenharmony_ci   */
3771401458bSopenharmony_ci   it('hiSysEventJsUnitTest007', 0, async function (done) {
3781401458bSopenharmony_ci    try {
3791401458bSopenharmony_ci      writeDefaultSysEvent()
3801401458bSopenharmony_ci      setTimeout(() => {
3811401458bSopenharmony_ci        querySysEvent(queryArgWithTwoCnt,
3821401458bSopenharmony_ci          [{
3831401458bSopenharmony_ci            domain: "RELIABILITY",
3841401458bSopenharmony_ci            names: ["STACK_STACK_STACK_STACK_STACK_STACK"],
3851401458bSopenharmony_ci          }], (infos) => {
3861401458bSopenharmony_ci            expect(infos.length >= 0).assertTrue()
3871401458bSopenharmony_ci          }, (reason, total) => {
3881401458bSopenharmony_ci            expect(true).assertTrue()
3891401458bSopenharmony_ci          }, (err) => {
3901401458bSopenharmony_ci            expect(err.code == INVALID_QUERY_RULE_ERR || err.code == QUERY_TOO_FREQUENTLY_ERR).assertTrue()
3911401458bSopenharmony_ci          }, done)
3921401458bSopenharmony_ci      }, 1000);
3931401458bSopenharmony_ci    } catch (err) {
3941401458bSopenharmony_ci      expect(false).assertTrue()
3951401458bSopenharmony_ci      done()
3961401458bSopenharmony_ci    }
3971401458bSopenharmony_ci  })
3981401458bSopenharmony_ci
3991401458bSopenharmony_ci  /**
4001401458bSopenharmony_ci   * @tc.desc: Test hisysevent of invalid domain writing with calling AsyncCallback.
4011401458bSopenharmony_ci   * @tc.level: Level 0
4021401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest008
4031401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest008
4041401458bSopenharmony_ci   * @tc.type: Function
4051401458bSopenharmony_ci   * @tc.size: MediumTest
4061401458bSopenharmony_ci   */
4071401458bSopenharmony_ci  it('hiSysEventJsUnitTest008', 0, async function (done) {
4081401458bSopenharmony_ci    writeEventWithAsyncWork("RELIABILITY_RELIABILITY", "STACK", hiSysEvent.EventType.FAULT, defaultEventInfo,
4091401458bSopenharmony_ci      (err) => {
4101401458bSopenharmony_ci        expect(err.code == 11200001).assertTrue() // 11200001: error code for invalid domain
4111401458bSopenharmony_ci      }, (val) => {
4121401458bSopenharmony_ci        expect(false).assertTrue()
4131401458bSopenharmony_ci      }, done)
4141401458bSopenharmony_ci  })
4151401458bSopenharmony_ci
4161401458bSopenharmony_ci  /**
4171401458bSopenharmony_ci   * @tc.desc: Test hisysevent of invalid event name writing with calling AsyncCallback.
4181401458bSopenharmony_ci   * @tc.level: Level 0
4191401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest009
4201401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest009
4211401458bSopenharmony_ci   * @tc.type: Function
4221401458bSopenharmony_ci   * @tc.size: MediumTest
4231401458bSopenharmony_ci   */
4241401458bSopenharmony_ci  it('hiSysEventJsUnitTest009', 0, async function (done) {
4251401458bSopenharmony_ci    writeEventWithAsyncWork("RELIABILITY", "STACK_STACK_STACK_STACK_STACK_STACK", hiSysEvent.EventType.FAULT,
4261401458bSopenharmony_ci      defaultEventInfo,
4271401458bSopenharmony_ci      (err) => {
4281401458bSopenharmony_ci        expect(err.code == 11200002).assertTrue() // 11200002: error code for invalid event name
4291401458bSopenharmony_ci      }, (val) => {
4301401458bSopenharmony_ci        expect(false).assertTrue()
4311401458bSopenharmony_ci      }, done)
4321401458bSopenharmony_ci  })
4331401458bSopenharmony_ci
4341401458bSopenharmony_ci  /**
4351401458bSopenharmony_ci   * @tc.desc: Test hisysevent which is over size writing with calling AsyncCallback.
4361401458bSopenharmony_ci   * @tc.level: Level 0
4371401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest010
4381401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest010
4391401458bSopenharmony_ci   * @tc.type: Function
4401401458bSopenharmony_ci   * @tc.size: MediumTest
4411401458bSopenharmony_ci   */
4421401458bSopenharmony_ci   it('hiSysEventJsUnitTest010', 0, async function (done) {
4431401458bSopenharmony_ci    for (let i = 0; i < 40; i++) {  // 40 is a test limiting value
4441401458bSopenharmony_ci      defaultEventInfo[`bundle${i}`] = Array.from({length: 10 * 1024}).join("ohos")
4451401458bSopenharmony_ci    }
4461401458bSopenharmony_ci    writeEventWithAsyncWork("RELIABILITY", "STACK", hiSysEvent.EventType.FAULT,
4471401458bSopenharmony_ci      defaultEventInfo,
4481401458bSopenharmony_ci      (err) => {
4491401458bSopenharmony_ci        expect(err.code == 11200004).assertTrue() // 11200004: error code for content over limit
4501401458bSopenharmony_ci      }, (val) => {
4511401458bSopenharmony_ci        expect(false).assertTrue()
4521401458bSopenharmony_ci      }, done)
4531401458bSopenharmony_ci  })
4541401458bSopenharmony_ci
4551401458bSopenharmony_ci  /**
4561401458bSopenharmony_ci   * @tc.desc: Test hisysevent of invalid param name writing with calling AsyncCallback.
4571401458bSopenharmony_ci   * @tc.level: Level 0
4581401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest011
4591401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest011
4601401458bSopenharmony_ci   * @tc.type: Function
4611401458bSopenharmony_ci   * @tc.size: MediumTest
4621401458bSopenharmony_ci   */
4631401458bSopenharmony_ci  it('hiSysEventJsUnitTest011', 0, async function (done) {
4641401458bSopenharmony_ci    writeEventWithAsyncWork("RELIABILITY", "STACK", hiSysEvent.EventType.FAULT,
4651401458bSopenharmony_ci      {
4661401458bSopenharmony_ci        PID: DEFAULT_ID,
4671401458bSopenharmony_ci        UID: DEFAULT_ID,
4681401458bSopenharmony_ci        STACK_STACK_STACK_STACK_STACK_STACK_STACK_STACK_STACK_STACK_STACK_STACK: "com.ohos.testHiSysEvent",
4691401458bSopenharmony_ci        PROCESS_NAME: "hiview js test suite",
4701401458bSopenharmony_ci        MSG: "no msg."
4711401458bSopenharmony_ci      }, (err) => {
4721401458bSopenharmony_ci        expect(err.code == 11200051).assertTrue() // 11200051: error code for invalid parameter name
4731401458bSopenharmony_ci      }, (val) => {
4741401458bSopenharmony_ci        expect(false).assertTrue()
4751401458bSopenharmony_ci      }, done)
4761401458bSopenharmony_ci  })
4771401458bSopenharmony_ci
4781401458bSopenharmony_ci  /**
4791401458bSopenharmony_ci   * @tc.desc: Test hisysevent with string over limit writing with calling AsyncCallback.
4801401458bSopenharmony_ci   * @tc.level: Level 0
4811401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest012
4821401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest012
4831401458bSopenharmony_ci   * @tc.type: Function
4841401458bSopenharmony_ci   * @tc.size: MediumTest
4851401458bSopenharmony_ci   */
4861401458bSopenharmony_ci   it('hiSysEventJsUnitTest012', 0, async function (done) {
4871401458bSopenharmony_ci    writeEventWithAsyncWork("RELIABILITY", "STACK", hiSysEvent.EventType.FAULT,
4881401458bSopenharmony_ci      {
4891401458bSopenharmony_ci        PID: DEFAULT_ID,
4901401458bSopenharmony_ci        UID: DEFAULT_ID,
4911401458bSopenharmony_ci        PACKAGE_NAME: "com.ohos.testHiSysEvent",
4921401458bSopenharmony_ci        PROCESS_NAME: Array.from({length: 10 * 1024 + 10}).join("ohos"), // 10 * 1024 + 10 is a threshold value
4931401458bSopenharmony_ci        MSG: "no msg."
4941401458bSopenharmony_ci      }, (err) => {
4951401458bSopenharmony_ci        expect(err.code == 11200052).assertTrue() // 11200052: error code for length of string over limit
4961401458bSopenharmony_ci      }, (val) => {
4971401458bSopenharmony_ci        expect(false).assertTrue()
4981401458bSopenharmony_ci      }, done)
4991401458bSopenharmony_ci  })
5001401458bSopenharmony_ci
5011401458bSopenharmony_ci  /**
5021401458bSopenharmony_ci   * @tc.desc: Test hisysevent with param count over limit writing with calling AsyncCallback.
5031401458bSopenharmony_ci   * @tc.level: Level 0
5041401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest013
5051401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest013
5061401458bSopenharmony_ci   * @tc.type: Function
5071401458bSopenharmony_ci   * @tc.size: MediumTest
5081401458bSopenharmony_ci   */
5091401458bSopenharmony_ci   it('hiSysEventJsUnitTest013', 0, async function (done) {
5101401458bSopenharmony_ci    let largeParams = {}
5111401458bSopenharmony_ci    for (let i = 0; i < 200; i++) { // 200 is a test limiting value
5121401458bSopenharmony_ci      largeParams["name" + i] = i
5131401458bSopenharmony_ci    }
5141401458bSopenharmony_ci    writeEventWithAsyncWork("RELIABILITY", "STACK", hiSysEvent.EventType.FAULT,
5151401458bSopenharmony_ci      largeParams, (err) => {
5161401458bSopenharmony_ci        expect(err.code == 11200053).assertTrue() // 11200053: error code for parameter count over limit
5171401458bSopenharmony_ci      }, (val) => {
5181401458bSopenharmony_ci        expect(false).assertTrue()
5191401458bSopenharmony_ci      }, done)
5201401458bSopenharmony_ci  })
5211401458bSopenharmony_ci
5221401458bSopenharmony_ci  /**
5231401458bSopenharmony_ci   * @tc.desc: Test hisysevent with array size over limit writing with calling AsyncCallback.
5241401458bSopenharmony_ci   * @tc.level: Level 0
5251401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest014
5261401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest014
5271401458bSopenharmony_ci   * @tc.type: Function
5281401458bSopenharmony_ci   * @tc.size: MediumTest
5291401458bSopenharmony_ci   */
5301401458bSopenharmony_ci   it('hiSysEventJsUnitTest014', 0, async function (done) {
5311401458bSopenharmony_ci    let msgArray = []
5321401458bSopenharmony_ci    for (let i = 0; i < 200; i++) { // 200 is a test limiting value
5331401458bSopenharmony_ci      msgArray[i] = i
5341401458bSopenharmony_ci    }
5351401458bSopenharmony_ci    writeEventWithAsyncWork("RELIABILITY", "STACK", hiSysEvent.EventType.FAULT,
5361401458bSopenharmony_ci      {
5371401458bSopenharmony_ci        PID: DEFAULT_ID,
5381401458bSopenharmony_ci        UID: DEFAULT_ID,
5391401458bSopenharmony_ci        PACKAGE_NAME: "com.ohos.testHiSysEvent",
5401401458bSopenharmony_ci        PROCESS_NAME: "hiview js test suite",
5411401458bSopenharmony_ci        MSG: msgArray
5421401458bSopenharmony_ci      }, (err) => {
5431401458bSopenharmony_ci        expect(err.code == 11200054).assertTrue() // 11200054: error code for array size over limit
5441401458bSopenharmony_ci      }, (val) => {
5451401458bSopenharmony_ci        expect(false).assertTrue()
5461401458bSopenharmony_ci      }, done)
5471401458bSopenharmony_ci  })
5481401458bSopenharmony_ci
5491401458bSopenharmony_ci  /**
5501401458bSopenharmony_ci   * @tc.desc: Test hisysevent query with sequence.
5511401458bSopenharmony_ci   * @tc.level: Level 0
5521401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest015
5531401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest015
5541401458bSopenharmony_ci   * @tc.type: Function
5551401458bSopenharmony_ci   * @tc.size: MediumTest
5561401458bSopenharmony_ci   */
5571401458bSopenharmony_ci  it('hiSysEventJsUnitTest015', 0, async function (done) {
5581401458bSopenharmony_ci    querySysEvent({
5591401458bSopenharmony_ci      maxEvents: 10000, // 10000 is a test value
5601401458bSopenharmony_ci      fromSeq: 100, // 100 is a test value
5611401458bSopenharmony_ci      toSeq: 1000, // 1000 is a test value
5621401458bSopenharmony_ci    }, [{
5631401458bSopenharmony_ci      domain: "AAFWK",
5641401458bSopenharmony_ci      names: ["CONNECT_SERVICE"],
5651401458bSopenharmony_ci    }], (infos) => {
5661401458bSopenharmony_ci      expect(infos.length >= 0).assertTrue()
5671401458bSopenharmony_ci    }, (reason, total) => {
5681401458bSopenharmony_ci      expect(true).assertTrue()
5691401458bSopenharmony_ci    }, (err) => {
5701401458bSopenharmony_ci      expect(err.code == PERMISSION_ERR).assertTrue()
5711401458bSopenharmony_ci    }, done)
5721401458bSopenharmony_ci  })
5731401458bSopenharmony_ci
5741401458bSopenharmony_ci  /**
5751401458bSopenharmony_ci   * @tc.desc: Test hisysevent get max sequence.
5761401458bSopenharmony_ci   * @tc.level: Level 0
5771401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest016
5781401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest016
5791401458bSopenharmony_ci   * @tc.type: Function
5801401458bSopenharmony_ci   * @tc.size: MediumTest
5811401458bSopenharmony_ci   */
5821401458bSopenharmony_ci  it('hiSysEventJsUnitTest016', 0, async function (done) {
5831401458bSopenharmony_ci    querySysEvent({
5841401458bSopenharmony_ci      maxEvents: 0, // 0 is a test value
5851401458bSopenharmony_ci      fromSeq: 0, // 0 is a test value
5861401458bSopenharmony_ci      toSeq: 1000, // 1000 is a test value
5871401458bSopenharmony_ci    }, [{
5881401458bSopenharmony_ci      domain: "AAFWK",
5891401458bSopenharmony_ci      names: ["CONNECT_SERVICE"],
5901401458bSopenharmony_ci    }], (infos) => {
5911401458bSopenharmony_ci      expect(infos.length >= 0).assertTrue()
5921401458bSopenharmony_ci    }, (reason, total) => {
5931401458bSopenharmony_ci      expect(true).assertTrue()
5941401458bSopenharmony_ci    }, (err) => {
5951401458bSopenharmony_ci      expect(err.code == PERMISSION_ERR).assertTrue()
5961401458bSopenharmony_ci    }, done)
5971401458bSopenharmony_ci  })
5981401458bSopenharmony_ci
5991401458bSopenharmony_ci  /**
6001401458bSopenharmony_ci   * @tc.desc: Test writing sysevents more than 100 times in 5 seconds.
6011401458bSopenharmony_ci   * @tc.level: Level 0
6021401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest017
6031401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest017
6041401458bSopenharmony_ci   * @tc.type: Function
6051401458bSopenharmony_ci   * @tc.size: MediumTest
6061401458bSopenharmony_ci   */
6071401458bSopenharmony_ci  it('hiSysEventJsUnitTest017', 0, async function (done) {
6081401458bSopenharmony_ci    try {
6091401458bSopenharmony_ci      for (let index = 0; index < 102; index++) { // 102 is a test limiting value
6101401458bSopenharmony_ci        writeEventWithAsyncWork("USERIAM_PIN", "USERIAM_TEMPLATE_CHANGE",
6111401458bSopenharmony_ci          hiSysEvent.EventType.SECURITY,
6121401458bSopenharmony_ci          {
6131401458bSopenharmony_ci            PID: DEFAULT_ID,
6141401458bSopenharmony_ci            UID: DEFAULT_ID,
6151401458bSopenharmony_ci            PACKAGE_NAME: "com.ohos.testHiSysEvent",
6161401458bSopenharmony_ci            PROCESS_NAME: "hiview js test suite",
6171401458bSopenharmony_ci          }, (err) => {
6181401458bSopenharmony_ci            expect(err.code == 11200003).assertTrue() // 11200003: error code for abnormnal environment
6191401458bSopenharmony_ci          }, (val) => {}, done)
6201401458bSopenharmony_ci      }
6211401458bSopenharmony_ci    } catch (err) {
6221401458bSopenharmony_ci      expect(false).assertTrue()
6231401458bSopenharmony_ci      done()
6241401458bSopenharmony_ci    }
6251401458bSopenharmony_ci  })
6261401458bSopenharmony_ci
6271401458bSopenharmony_ci  /**
6281401458bSopenharmony_ci   * @tc.desc: Test query sysevent with 2 conditions: == & ==.
6291401458bSopenharmony_ci   * @tc.level: Level 0
6301401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest018
6311401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest018
6321401458bSopenharmony_ci   * @tc.type: Function
6331401458bSopenharmony_ci   * @tc.size: MediumTest
6341401458bSopenharmony_ci   */
6351401458bSopenharmony_ci  it('hiSysEventJsUnitTest018', 0, async function (done) {
6361401458bSopenharmony_ci    writeCustomizedSysEvent({
6371401458bSopenharmony_ci      PID: 323232388,  // 323232388 is a test pid
6381401458bSopenharmony_ci      UID: DEFAULT_ID,
6391401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest018",
6401401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
6411401458bSopenharmony_ci    })
6421401458bSopenharmony_ci    writeCustomizedSysEvent({
6431401458bSopenharmony_ci      PID: 1000,      // 1000 is a test pid
6441401458bSopenharmony_ci      UID: DEFAULT_ID,
6451401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest018",
6461401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
6471401458bSopenharmony_ci    })
6481401458bSopenharmony_ci    writeCustomizedSysEvent({
6491401458bSopenharmony_ci      PID: 1000,     // 1000 is a test pid
6501401458bSopenharmony_ci      UID: DEFAULT_ID,
6511401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.testHiSysEvent2",
6521401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
6531401458bSopenharmony_ci    })
6541401458bSopenharmony_ci    setTimeout(() => {
6551401458bSopenharmony_ci      querySysEvent(queryArgWithFiveCnt,
6561401458bSopenharmony_ci        [{
6571401458bSopenharmony_ci          domain: "RELIABILITY",
6581401458bSopenharmony_ci          names: ["STACK"],
6591401458bSopenharmony_ci          condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":"=","value":1000},' +
6601401458bSopenharmony_ci            '{"param":"PACKAGE_NAME","op":"=","value":"com.ohos.testHiSysEvent2"}]}}'
6611401458bSopenharmony_ci        }], (infos) => {
6621401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
6631401458bSopenharmony_ci        }, (reason, total) => {
6641401458bSopenharmony_ci          expect(total >= QUERY_1_ITEM).assertTrue()
6651401458bSopenharmony_ci        }, (err) => {
6661401458bSopenharmony_ci          expect(false).assertTrue()
6671401458bSopenharmony_ci        }, done)
6681401458bSopenharmony_ci    }, 1000)
6691401458bSopenharmony_ci  })
6701401458bSopenharmony_ci
6711401458bSopenharmony_ci  /**
6721401458bSopenharmony_ci   * @tc.desc: Test query sysevent with conditions: <= & >=.
6731401458bSopenharmony_ci   * @tc.level: Level 0
6741401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest019
6751401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest019
6761401458bSopenharmony_ci   * @tc.type: Function
6771401458bSopenharmony_ci   * @tc.size: MediumTest
6781401458bSopenharmony_ci   */
6791401458bSopenharmony_ci  it('hiSysEventJsUnitTest019', 0, async function (done) {
6801401458bSopenharmony_ci    const PID = 222
6811401458bSopenharmony_ci    writeCustomizedSysEvent({
6821401458bSopenharmony_ci      PID,
6831401458bSopenharmony_ci      UID: 10,  // 10 is a test value
6841401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest019",
6851401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
6861401458bSopenharmony_ci    })
6871401458bSopenharmony_ci    writeCustomizedSysEvent({
6881401458bSopenharmony_ci      PID,
6891401458bSopenharmony_ci      UID: 20,  // 20 is a test value
6901401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest019",
6911401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
6921401458bSopenharmony_ci    })
6931401458bSopenharmony_ci    writeCustomizedSysEvent({
6941401458bSopenharmony_ci      PID,
6951401458bSopenharmony_ci      UID: 23,  // 23 is a test value
6961401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest019",
6971401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
6981401458bSopenharmony_ci    })
6991401458bSopenharmony_ci    setTimeout(() => {
7001401458bSopenharmony_ci      querySysEvent(queryArgWithFiveCnt,
7011401458bSopenharmony_ci        [{
7021401458bSopenharmony_ci          domain: "RELIABILITY",
7031401458bSopenharmony_ci          names: ["STACK"],
7041401458bSopenharmony_ci          condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":"<=","value":222},' +
7051401458bSopenharmony_ci            '{"param":"UID","op":">=","value":19.0}]}}'
7061401458bSopenharmony_ci        }], (infos) => {
7071401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
7081401458bSopenharmony_ci        }, (reason, total) => {
7091401458bSopenharmony_ci          expect(total >= QUERY_2_ITEMS).assertTrue() // 2 is a check value
7101401458bSopenharmony_ci        }, (err) => {
7111401458bSopenharmony_ci          expect(false).assertTrue()
7121401458bSopenharmony_ci        }, done)
7131401458bSopenharmony_ci    }, DELAY_1500_MS)
7141401458bSopenharmony_ci  })
7151401458bSopenharmony_ci
7161401458bSopenharmony_ci  /**
7171401458bSopenharmony_ci   * @tc.desc: Test query sysevent with conditions: > & <.
7181401458bSopenharmony_ci   * @tc.level: Level 0
7191401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest020
7201401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest020
7211401458bSopenharmony_ci   * @tc.type: Function
7221401458bSopenharmony_ci   * @tc.size: MediumTest
7231401458bSopenharmony_ci   */
7241401458bSopenharmony_ci  it('hiSysEventJsUnitTest020', 0, async function (done) {
7251401458bSopenharmony_ci    writeCustomizedSysEvent({
7261401458bSopenharmony_ci      PID: 2009,  // 2009 is a test value
7271401458bSopenharmony_ci      UID: 20001, // 20001 is a test value
7281401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest020",
7291401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
7301401458bSopenharmony_ci    })
7311401458bSopenharmony_ci    writeCustomizedSysEvent({
7321401458bSopenharmony_ci      PID: 2010,  // 2010 is a test value
7331401458bSopenharmony_ci      UID: 20002, // 20002 is a test value
7341401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest020",
7351401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
7361401458bSopenharmony_ci    })
7371401458bSopenharmony_ci    writeCustomizedSysEvent({
7381401458bSopenharmony_ci      PID: 2020,  // 2020 is a test value
7391401458bSopenharmony_ci      UID: 20003, // 20003 is a test value
7401401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest020",
7411401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
7421401458bSopenharmony_ci    })
7431401458bSopenharmony_ci    setTimeout(() => {
7441401458bSopenharmony_ci      querySysEvent(queryArgWithFiveCnt,
7451401458bSopenharmony_ci        [{
7461401458bSopenharmony_ci          domain: "RELIABILITY",
7471401458bSopenharmony_ci          names: ["STACK"],
7481401458bSopenharmony_ci          condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":">","value":2000},' +
7491401458bSopenharmony_ci            '{"param":"UID","op":"<","value":20003}]}}'
7501401458bSopenharmony_ci        }], (infos) => {
7511401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
7521401458bSopenharmony_ci        }, (reason, total) => {
7531401458bSopenharmony_ci          expect(total >= QUERY_2_ITEMS).assertTrue() // 2 is a test limit
7541401458bSopenharmony_ci        }, (err) => {
7551401458bSopenharmony_ci          expect(false).assertTrue()
7561401458bSopenharmony_ci        }, done)
7571401458bSopenharmony_ci    }, DELAY_2000_MS)
7581401458bSopenharmony_ci  })
7591401458bSopenharmony_ci
7601401458bSopenharmony_ci  /**
7611401458bSopenharmony_ci   * @tc.desc: Test query sysevent with 2 conditions: != & ==.
7621401458bSopenharmony_ci   * @tc.level: Level 0
7631401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest021
7641401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest021
7651401458bSopenharmony_ci   * @tc.type: Function
7661401458bSopenharmony_ci   * @tc.size: MediumTest
7671401458bSopenharmony_ci   */
7681401458bSopenharmony_ci  it('hiSysEventJsUnitTest021', 0, async function (done) {
7691401458bSopenharmony_ci    const UID = 88888
7701401458bSopenharmony_ci    writeCustomizedSysEvent({
7711401458bSopenharmony_ci      PID: 22,    // 22 is a test value
7721401458bSopenharmony_ci      UID,
7731401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest021",
7741401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
7751401458bSopenharmony_ci    })
7761401458bSopenharmony_ci    writeCustomizedSysEvent({
7771401458bSopenharmony_ci      PID: 23,    // 23 is a test value
7781401458bSopenharmony_ci      UID,
7791401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest021",
7801401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
7811401458bSopenharmony_ci    })
7821401458bSopenharmony_ci    writeCustomizedSysEvent({
7831401458bSopenharmony_ci      PID: 24,    // 24 is a test value
7841401458bSopenharmony_ci      UID,
7851401458bSopenharmony_ci      PACKAGE_NAME: "com.ohos.hiSysEventJsUnitTest021",
7861401458bSopenharmony_ci      PROCESS_NAME: "hiview js test suite"
7871401458bSopenharmony_ci    })
7881401458bSopenharmony_ci    setTimeout(() => {
7891401458bSopenharmony_ci      querySysEvent(queryArgWithFiveCnt,
7901401458bSopenharmony_ci        [{
7911401458bSopenharmony_ci          domain: "RELIABILITY",
7921401458bSopenharmony_ci          names: ["STACK"],
7931401458bSopenharmony_ci          condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":"!=","value":22}, ' +
7941401458bSopenharmony_ci            '{"param":"UID","op":"=","value":88888}]}}'
7951401458bSopenharmony_ci        }], (infos) => {
7961401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
7971401458bSopenharmony_ci        }, (reason, total) => {
7981401458bSopenharmony_ci          expect(total >= 2).assertTrue()
7991401458bSopenharmony_ci        }, (err) => {
8001401458bSopenharmony_ci          expect(false).assertTrue()
8011401458bSopenharmony_ci        }, done)
8021401458bSopenharmony_ci    }, 2500)
8031401458bSopenharmony_ci  })
8041401458bSopenharmony_ci
8051401458bSopenharmony_ci  /**
8061401458bSopenharmony_ci   * @tc.desc: Test query sysevent with null condition.
8071401458bSopenharmony_ci   * @tc.level: Level 0
8081401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest022
8091401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest022
8101401458bSopenharmony_ci   * @tc.type: Function
8111401458bSopenharmony_ci   * @tc.size: MediumTest
8121401458bSopenharmony_ci   */
8131401458bSopenharmony_ci  it('hiSysEventJsUnitTest022', 0, async function (done) {
8141401458bSopenharmony_ci    setTimeout(() => {
8151401458bSopenharmony_ci      querySysEvent(queryArgWithFiveCnt,
8161401458bSopenharmony_ci        [{
8171401458bSopenharmony_ci          domain: "RELIABILITY",
8181401458bSopenharmony_ci          names: ["STACK"],
8191401458bSopenharmony_ci          condition: null
8201401458bSopenharmony_ci        }], (infos) => {
8211401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
8221401458bSopenharmony_ci        }, (reason, total) => {
8231401458bSopenharmony_ci          expect(total > 0).assertTrue()
8241401458bSopenharmony_ci        }, (err) => {
8251401458bSopenharmony_ci          expect(false).assertTrue()
8261401458bSopenharmony_ci        }, done)
8271401458bSopenharmony_ci    }, 2500)
8281401458bSopenharmony_ci  })
8291401458bSopenharmony_ci
8301401458bSopenharmony_ci  /**
8311401458bSopenharmony_ci   * @tc.desc: Test query sysevent with default query argument.
8321401458bSopenharmony_ci   * @tc.level: Level 0
8331401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest023
8341401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest023
8351401458bSopenharmony_ci   * @tc.type: Function
8361401458bSopenharmony_ci   * @tc.size: MediumTest
8371401458bSopenharmony_ci   */
8381401458bSopenharmony_ci  it('hiSysEventJsUnitTest023', 0, async function (done) {
8391401458bSopenharmony_ci    setTimeout(() => {
8401401458bSopenharmony_ci      querySysEvent(defaultQueryArg,
8411401458bSopenharmony_ci        [{
8421401458bSopenharmony_ci          domain: "RELIABILITY",
8431401458bSopenharmony_ci          names: ["STACK"],
8441401458bSopenharmony_ci          condition: null
8451401458bSopenharmony_ci        }], (infos) => {
8461401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
8471401458bSopenharmony_ci        }, (reason, total) => {
8481401458bSopenharmony_ci          expect(total > 0).assertTrue()
8491401458bSopenharmony_ci        }, (err) => {
8501401458bSopenharmony_ci          expect(false).assertTrue()
8511401458bSopenharmony_ci        }, done)
8521401458bSopenharmony_ci    }, 2500)
8531401458bSopenharmony_ci  })
8541401458bSopenharmony_ci
8551401458bSopenharmony_ci  /**
8561401458bSopenharmony_ci   * @tc.desc: Test write with integer number
8571401458bSopenharmony_ci   * @tc.level: Level 0
8581401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest024
8591401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest024
8601401458bSopenharmony_ci   * @tc.type: Function
8611401458bSopenharmony_ci   * @tc.size: MediumTest
8621401458bSopenharmony_ci   */
8631401458bSopenharmony_ci  it('hiSysEventJsUnitTest024', 0, async function (done) {
8641401458bSopenharmony_ci    const FIRST_INT_VAL = 1
8651401458bSopenharmony_ci    const SECOND_INT_VAL = -1
8661401458bSopenharmony_ci    const THIRD_INT_VAL = 123456789
8671401458bSopenharmony_ci    const FORTH_INT_VAL = -123456789
8681401458bSopenharmony_ci    const TEST_PID_UID = 2222222
8691401458bSopenharmony_ci    writeCustomizedSysEvent({
8701401458bSopenharmony_ci      PID: TEST_PID_UID,
8711401458bSopenharmony_ci      UID: TEST_PID_UID,
8721401458bSopenharmony_ci      FIRST_INT_VAL, SECOND_INT_VAL, THIRD_INT_VAL, FORTH_INT_VAL,
8731401458bSopenharmony_ci    })
8741401458bSopenharmony_ci    setTimeout(() => {
8751401458bSopenharmony_ci      querySysEvent(queryArgWithOneCnt,
8761401458bSopenharmony_ci        [{
8771401458bSopenharmony_ci          domain: "RELIABILITY",
8781401458bSopenharmony_ci          names: ["STACK"],
8791401458bSopenharmony_ci          condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":"=","value":2222222},' +
8801401458bSopenharmony_ci            '{"param":"UID","op":"=","value":2222222}]}}'
8811401458bSopenharmony_ci        }], (infos) => {
8821401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
8831401458bSopenharmony_ci          expect(GetParam(infos[0], "FIRST_INT_VAL")).assertEqual(FIRST_INT_VAL)
8841401458bSopenharmony_ci          expect(GetParam(infos[0], "SECOND_INT_VAL")).assertEqual(SECOND_INT_VAL)
8851401458bSopenharmony_ci          expect(GetParam(infos[0], "THIRD_INT_VAL")).assertEqual(THIRD_INT_VAL)
8861401458bSopenharmony_ci          expect(GetParam(infos[0], "FORTH_INT_VAL")).assertEqual(FORTH_INT_VAL)
8871401458bSopenharmony_ci        }, (reason, total) => {
8881401458bSopenharmony_ci          expect(total == QUERY_1_ITEM).assertTrue()
8891401458bSopenharmony_ci        }, (err) => {
8901401458bSopenharmony_ci          expect(false).assertTrue()
8911401458bSopenharmony_ci        }, done)
8921401458bSopenharmony_ci    }, DELAY_1500_MS)
8931401458bSopenharmony_ci  })
8941401458bSopenharmony_ci
8951401458bSopenharmony_ci  /**
8961401458bSopenharmony_ci   * @tc.desc: Test write with big integer number
8971401458bSopenharmony_ci   * @tc.level: Level 0
8981401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest025
8991401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest025
9001401458bSopenharmony_ci   * @tc.type: Function
9011401458bSopenharmony_ci   * @tc.size: MediumTest
9021401458bSopenharmony_ci   */
9031401458bSopenharmony_ci  it('hiSysEventJsUnitTest025', 0, async function (done) {
9041401458bSopenharmony_ci    const FIRST_BIG_INT_VAL = 1n
9051401458bSopenharmony_ci    const SECOND_BIG_INT_VAL = -1n
9061401458bSopenharmony_ci    const THIRD_BIG_INT_VAL = 123456789n
9071401458bSopenharmony_ci    const FORTH_BIG_INT_VAL = -123456789n
9081401458bSopenharmony_ci    const TEST_PID_UID = 3333333
9091401458bSopenharmony_ci    writeCustomizedSysEvent({
9101401458bSopenharmony_ci      PID: TEST_PID_UID,
9111401458bSopenharmony_ci      UID: TEST_PID_UID,
9121401458bSopenharmony_ci      FIRST_BIG_INT_VAL, SECOND_BIG_INT_VAL, THIRD_BIG_INT_VAL, FORTH_BIG_INT_VAL,
9131401458bSopenharmony_ci    })
9141401458bSopenharmony_ci    setTimeout(() => {
9151401458bSopenharmony_ci      querySysEvent(queryArgWithOneCnt,
9161401458bSopenharmony_ci        [{
9171401458bSopenharmony_ci          domain: "RELIABILITY",
9181401458bSopenharmony_ci          names: ["STACK"],
9191401458bSopenharmony_ci          condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":"=","value":3333333},' +
9201401458bSopenharmony_ci            '{"param":"UID","op":"=","value":3333333}]}}'
9211401458bSopenharmony_ci        }], (infos) => {
9221401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
9231401458bSopenharmony_ci          expect(BigInt(GetParam(infos[0], "FIRST_BIG_INT_VAL"))).assertEqual(FIRST_BIG_INT_VAL)
9241401458bSopenharmony_ci          expect(BigInt(GetParam(infos[0], "SECOND_BIG_INT_VAL"))).assertEqual(SECOND_BIG_INT_VAL)
9251401458bSopenharmony_ci          expect(BigInt(GetParam(infos[0], "THIRD_BIG_INT_VAL"))).assertEqual(THIRD_BIG_INT_VAL)
9261401458bSopenharmony_ci          expect(BigInt(GetParam(infos[0], "FORTH_BIG_INT_VAL"))).assertEqual(FORTH_BIG_INT_VAL)
9271401458bSopenharmony_ci        }, (reason, total) => {
9281401458bSopenharmony_ci          expect(total == QUERY_1_ITEM).assertTrue()
9291401458bSopenharmony_ci        }, (err) => {
9301401458bSopenharmony_ci          expect(false).assertTrue()
9311401458bSopenharmony_ci        }, done)
9321401458bSopenharmony_ci    }, DELAY_1500_MS)
9331401458bSopenharmony_ci  })
9341401458bSopenharmony_ci
9351401458bSopenharmony_ci  /**
9361401458bSopenharmony_ci   * @tc.desc: Test write with max or min big integer number
9371401458bSopenharmony_ci   * @tc.level: Level 0
9381401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest026
9391401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest026
9401401458bSopenharmony_ci   * @tc.type: Function
9411401458bSopenharmony_ci   * @tc.size: MediumTest
9421401458bSopenharmony_ci   */
9431401458bSopenharmony_ci  it('hiSysEventJsUnitTest026', 0, async function (done) {
9441401458bSopenharmony_ci    const UINT64_MAX = 18446744073709551615n
9451401458bSopenharmony_ci    const INT64_MAX = 9223372036854775807n
9461401458bSopenharmony_ci    const INT64_MIN = -9223372036854775808n
9471401458bSopenharmony_ci    const TEST_PID_UID = 4444444
9481401458bSopenharmony_ci    writeCustomizedSysEvent({
9491401458bSopenharmony_ci      PID: TEST_PID_UID,
9501401458bSopenharmony_ci      UID: TEST_PID_UID,
9511401458bSopenharmony_ci      UINT64_MAX, INT64_MAX, INT64_MIN,
9521401458bSopenharmony_ci    })
9531401458bSopenharmony_ci    setTimeout(() => {
9541401458bSopenharmony_ci      querySysEvent(queryArgWithOneCnt,
9551401458bSopenharmony_ci        [{
9561401458bSopenharmony_ci          domain: "RELIABILITY",
9571401458bSopenharmony_ci          names: ["STACK"],
9581401458bSopenharmony_ci          condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":"=","value":4444444},' +
9591401458bSopenharmony_ci            '{"param":"UID","op":"=","value":4444444}]}}'
9601401458bSopenharmony_ci        }], (infos) => {
9611401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
9621401458bSopenharmony_ci          expect(GetParam(infos[0], "UINT64_MAX")).assertEqual(UINT64_MAX)
9631401458bSopenharmony_ci          expect(GetParam(infos[0], "INT64_MAX")).assertEqual(INT64_MAX)
9641401458bSopenharmony_ci          expect(GetParam(infos[0], "INT64_MIN")).assertEqual(INT64_MIN)
9651401458bSopenharmony_ci        }, (reason, total) => {
9661401458bSopenharmony_ci          expect(total == QUERY_1_ITEM).assertTrue()
9671401458bSopenharmony_ci        }, (err) => {
9681401458bSopenharmony_ci          expect(false).assertTrue()
9691401458bSopenharmony_ci        }, done)
9701401458bSopenharmony_ci    }, DELAY_1500_MS)
9711401458bSopenharmony_ci  })
9721401458bSopenharmony_ci
9731401458bSopenharmony_ci  /**
9741401458bSopenharmony_ci   * @tc.desc: Test write with big integer number array
9751401458bSopenharmony_ci   * @tc.level: Level 0
9761401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest027
9771401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest027
9781401458bSopenharmony_ci   * @tc.type: Function
9791401458bSopenharmony_ci   * @tc.size: MediumTest
9801401458bSopenharmony_ci   */
9811401458bSopenharmony_ci  it('hiSysEventJsUnitTest027', 0, async function (done) {
9821401458bSopenharmony_ci    const FIRST_BIG_INT_ARR = [4n, 5n, 6n]
9831401458bSopenharmony_ci    const SECOND_BIG_INT_ARR = [-4n, -5n, -6n]
9841401458bSopenharmony_ci    const THIRD_BIG_INT_ARR = [123456789n, -2232333n, 2222223344n]
9851401458bSopenharmony_ci    const FORTH_BIG_INT_ARR = [-123456789n, -2232333n, -2222223344n]
9861401458bSopenharmony_ci    const TEST_PID_UID = 55555555
9871401458bSopenharmony_ci    writeCustomizedSysEvent({
9881401458bSopenharmony_ci      PID: TEST_PID_UID,
9891401458bSopenharmony_ci      UID: TEST_PID_UID,
9901401458bSopenharmony_ci      FIRST_BIG_INT_ARR, SECOND_BIG_INT_ARR, THIRD_BIG_INT_ARR, FORTH_BIG_INT_ARR,
9911401458bSopenharmony_ci    })
9921401458bSopenharmony_ci    setTimeout(() => {
9931401458bSopenharmony_ci      querySysEvent(queryArgWithOneCnt,
9941401458bSopenharmony_ci        [{
9951401458bSopenharmony_ci          domain: "RELIABILITY",
9961401458bSopenharmony_ci          names: ["STACK"],
9971401458bSopenharmony_ci          condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":"=","value":55555555},' +
9981401458bSopenharmony_ci            '{"param":"UID","op":"=","value":55555555}]}}'
9991401458bSopenharmony_ci        }], (infos) => {
10001401458bSopenharmony_ci          expect(infos.length >= 0).assertTrue()
10011401458bSopenharmony_ci          const SEC_INDEX = 1
10021401458bSopenharmony_ci          const THIRD_INDEX = 2
10031401458bSopenharmony_ci          expect(BigInt(GetArrayIemParamByIndex(
10041401458bSopenharmony_ci            infos[0], "FIRST_BIG_INT_ARR", SEC_INDEX))).assertEqual(FIRST_BIG_INT_ARR[SEC_INDEX])
10051401458bSopenharmony_ci          expect(BigInt(GetArrayIemParamByIndex(
10061401458bSopenharmony_ci            infos[0], "SECOND_BIG_INT_ARR", THIRD_INDEX))).assertEqual(SECOND_BIG_INT_ARR[THIRD_INDEX])
10071401458bSopenharmony_ci          expect(BigInt(GetArrayIemParamByIndex(
10081401458bSopenharmony_ci            infos[0], "THIRD_BIG_INT_ARR", SEC_INDEX))).assertEqual(THIRD_BIG_INT_ARR[SEC_INDEX])
10091401458bSopenharmony_ci          expect(BigInt(GetArrayIemParamByIndex(
10101401458bSopenharmony_ci            infos[0], "FORTH_BIG_INT_ARR", THIRD_INDEX))).assertEqual(FORTH_BIG_INT_ARR[THIRD_INDEX])
10111401458bSopenharmony_ci        }, (reason, total) => {
10121401458bSopenharmony_ci          expect(total == QUERY_1_ITEM).assertTrue()
10131401458bSopenharmony_ci        }, (err) => {
10141401458bSopenharmony_ci          expect(false).assertTrue()
10151401458bSopenharmony_ci        }, done)
10161401458bSopenharmony_ci    }, DELAY_1500_MS)
10171401458bSopenharmony_ci  })
10181401458bSopenharmony_ci
10191401458bSopenharmony_ci  /**
10201401458bSopenharmony_ci   * @tc.desc: Test write with integer number array
10211401458bSopenharmony_ci   * @tc.level: Level 0
10221401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest028
10231401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest028
10241401458bSopenharmony_ci   * @tc.type: Function
10251401458bSopenharmony_ci   * @tc.size: MediumTest
10261401458bSopenharmony_ci   */
10271401458bSopenharmony_ci    it('hiSysEventJsUnitTest028', 0, async function (done) {
10281401458bSopenharmony_ci      const FIRST_INT_ARR = [1, 2, 3]
10291401458bSopenharmony_ci      const SECOND_INT_ARR = [-1, -2, -3]
10301401458bSopenharmony_ci      const THIRD_INT_ARR = [123456789, -2232333, 2222223344]
10311401458bSopenharmony_ci      const FORTH_INT_ARR = [-123456, 222333, -222222]
10321401458bSopenharmony_ci      const TEST_PID_UID = 66666666
10331401458bSopenharmony_ci      writeCustomizedSysEvent({
10341401458bSopenharmony_ci        PID: TEST_PID_UID,
10351401458bSopenharmony_ci        UID: TEST_PID_UID,
10361401458bSopenharmony_ci        FIRST_INT_ARR, SECOND_INT_ARR, THIRD_INT_ARR, FORTH_INT_ARR,
10371401458bSopenharmony_ci      })
10381401458bSopenharmony_ci      setTimeout(() => {
10391401458bSopenharmony_ci        querySysEvent(queryArgWithOneCnt,
10401401458bSopenharmony_ci          [{
10411401458bSopenharmony_ci            domain: "RELIABILITY",
10421401458bSopenharmony_ci            names: ["STACK"],
10431401458bSopenharmony_ci            condition: '{"version":"V1","condition":{"and":[{"param":"PID","op":"=","value":66666666},' +
10441401458bSopenharmony_ci              '{"param":"UID","op":"=","value":66666666}]}}'
10451401458bSopenharmony_ci          }], (infos) => {
10461401458bSopenharmony_ci            expect(infos.length >= 0).assertTrue()
10471401458bSopenharmony_ci            const SEC_INDEX = 1
10481401458bSopenharmony_ci            const THIRD_INDEX = 2
10491401458bSopenharmony_ci            expect(GetArrayIemParamByIndex(
10501401458bSopenharmony_ci              infos[0], "FIRST_INT_ARR", SEC_INDEX)).assertEqual(FIRST_INT_ARR[SEC_INDEX])
10511401458bSopenharmony_ci            expect(GetArrayIemParamByIndex(
10521401458bSopenharmony_ci              infos[0], "SECOND_INT_ARR", THIRD_INDEX)).assertEqual(SECOND_INT_ARR[THIRD_INDEX])
10531401458bSopenharmony_ci            expect(GetArrayIemParamByIndex(
10541401458bSopenharmony_ci              infos[0], "THIRD_INT_ARR", SEC_INDEX)).assertEqual(THIRD_INT_ARR[SEC_INDEX])
10551401458bSopenharmony_ci            expect(GetArrayIemParamByIndex(
10561401458bSopenharmony_ci              infos[0], "FORTH_INT_ARR", THIRD_INDEX)).assertEqual(FORTH_INT_ARR[THIRD_INDEX])
10571401458bSopenharmony_ci          }, (reason, total) => {
10581401458bSopenharmony_ci            expect(total == QUERY_1_ITEM).assertTrue()
10591401458bSopenharmony_ci          }, (err) => {
10601401458bSopenharmony_ci            expect(false).assertTrue()
10611401458bSopenharmony_ci          }, done)
10621401458bSopenharmony_ci      }, DELAY_1500_MS)
10631401458bSopenharmony_ci    })
10641401458bSopenharmony_ci
10651401458bSopenharmony_ci  /**
10661401458bSopenharmony_ci   * @tc.desc: Test query with undefined as beginTime
10671401458bSopenharmony_ci   * @tc.level: Level 0
10681401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest029
10691401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest029
10701401458bSopenharmony_ci   * @tc.type: Function
10711401458bSopenharmony_ci   * @tc.size: MediumTest
10721401458bSopenharmony_ci   */
10731401458bSopenharmony_ci  it('hiSysEventJsUnitTest029', 0, async function (done) {
10741401458bSopenharmony_ci    querySysEvent({
10751401458bSopenharmony_ci      beginTime: undefined,
10761401458bSopenharmony_ci      endTime: DEFAULT_QUERY_TIME,
10771401458bSopenharmony_ci      maxEvents: QUERY_2_ITEMS
10781401458bSopenharmony_ci    }, [{
10791401458bSopenharmony_ci      domain: "KERNEL_VENDOR",
10801401458bSopenharmony_ci      names: ["POWER_KEY"],
10811401458bSopenharmony_ci    }], (infos) => {
10821401458bSopenharmony_ci      expect(false).assertTrue()
10831401458bSopenharmony_ci    }, (reason, total) => {
10841401458bSopenharmony_ci      expect(false).assertTrue()
10851401458bSopenharmony_ci    }, (err) => {
10861401458bSopenharmony_ci      expect(err.code == PARAM_CHECK_ERR).assertTrue()
10871401458bSopenharmony_ci    }, done)
10881401458bSopenharmony_ci  })
10891401458bSopenharmony_ci
10901401458bSopenharmony_ci  /**
10911401458bSopenharmony_ci   * @tc.desc: Test query with null as endTime
10921401458bSopenharmony_ci   * @tc.level: Level 0
10931401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest030
10941401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest030
10951401458bSopenharmony_ci   * @tc.type: Function
10961401458bSopenharmony_ci   * @tc.size: MediumTest
10971401458bSopenharmony_ci   */
10981401458bSopenharmony_ci  it('hiSysEventJsUnitTest030', 0, async function (done) {
10991401458bSopenharmony_ci    querySysEvent({
11001401458bSopenharmony_ci      beginTime: DEFAULT_QUERY_TIME,
11011401458bSopenharmony_ci      endTime: null,
11021401458bSopenharmony_ci      maxEvents: QUERY_2_ITEMS
11031401458bSopenharmony_ci    }, [{
11041401458bSopenharmony_ci      domain: "AAFWK",
11051401458bSopenharmony_ci      names: ["PROCESS_EXIT"],
11061401458bSopenharmony_ci    }], (infos) => {
11071401458bSopenharmony_ci      expect(infos.length >= 0).assertTrue()
11081401458bSopenharmony_ci    }, (reason, total) => {
11091401458bSopenharmony_ci      expect(true).assertTrue()
11101401458bSopenharmony_ci    }, (err) => {
11111401458bSopenharmony_ci      expect(err.code == PARAM_CHECK_ERR).assertTrue()
11121401458bSopenharmony_ci    }, done)
11131401458bSopenharmony_ci  })
11141401458bSopenharmony_ci
11151401458bSopenharmony_ci  /**
11161401458bSopenharmony_ci   * @tc.desc: Test query with undefined as querier
11171401458bSopenharmony_ci   * @tc.level: Level 0
11181401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest031
11191401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest031
11201401458bSopenharmony_ci   * @tc.type: Function
11211401458bSopenharmony_ci   * @tc.size: MediumTest
11221401458bSopenharmony_ci   */
11231401458bSopenharmony_ci  it('hiSysEventJsUnitTest031', 0, async function (done) {
11241401458bSopenharmony_ci    try {
11251401458bSopenharmony_ci      hiSysEvent.query(queryArgWithOneCnt, [{
11261401458bSopenharmony_ci        domain: "HUKS",
11271401458bSopenharmony_ci        names: ["FAULT"],
11281401458bSopenharmony_ci      }], undefined)
11291401458bSopenharmony_ci    } catch (err) {
11301401458bSopenharmony_ci      expect(err.code == PARAM_CHECK_ERR).assertTrue()
11311401458bSopenharmony_ci      done()
11321401458bSopenharmony_ci    }
11331401458bSopenharmony_ci  })
11341401458bSopenharmony_ci
11351401458bSopenharmony_ci  /**
11361401458bSopenharmony_ci   * @tc.desc: Test query with null as querier
11371401458bSopenharmony_ci   * @tc.level: Level 0
11381401458bSopenharmony_ci   * @tc.name: hiSysEventJsUnitTest032
11391401458bSopenharmony_ci   * @tc.number: hiSysEventJsUnitTest032
11401401458bSopenharmony_ci   * @tc.type: Function
11411401458bSopenharmony_ci   * @tc.size: MediumTest
11421401458bSopenharmony_ci   */
11431401458bSopenharmony_ci  it('hiSysEventJsUnitTest032', 0, async function (done) {
11441401458bSopenharmony_ci    try {
11451401458bSopenharmony_ci      hiSysEvent.query(queryArgWithOneCnt, [{
11461401458bSopenharmony_ci        domain: "SAMGR",
11471401458bSopenharmony_ci        names: ["ONDEMAND_SA_LOAD"],
11481401458bSopenharmony_ci      }], null)
11491401458bSopenharmony_ci    } catch (err) {
11501401458bSopenharmony_ci      expect(err.code == PARAM_CHECK_ERR).assertTrue()
11511401458bSopenharmony_ci      done()
11521401458bSopenharmony_ci    }
11531401458bSopenharmony_ci  })
11541401458bSopenharmony_ci});