1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { threadPool } from '../../../../src/trace/database/SqlLite';
17import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow';
18import { HiSysEventStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerHiSysEvent';
19import { hiSysEventDataSender } from '../../../../src/trace/database/data-trafic/HiSysEventDataSender';
20jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {});
21jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
22  return {};
23});
24jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => {
25  return {};
26});
27describe('hiSysEventDataSender Test', () => {
28  let hiSysEventData = {
29    id: 808,
30    ts: 78977,
31    pid: 491,
32    tid: 25,
33    uid: 66,
34    dur: 1,
35    depth: 0,
36    seq: 1,
37    domain: 'MULTIMODALINPUT',
38    eventName: 'TARGET_POINTER_EVENT_SUCCESS',
39    info: '',
40    level: 'MINOR',
41    contents: '{"AGENT_WINDOWID":16,"EVENTTYPE":131072,"FD":33,"MSG":"The window manager successfully update target pointer","PID":4192,"TARGET_WINDOWID":16}',
42    frame: {
43      y: 10,
44      height: 20,
45      x: 168,
46      width: 1
47    },
48    v: true
49  }
50  it('hiSysEventDataSenderTest01', () => {
51    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
52      callback(hiSysEventData, 1, true);
53    });
54    let hiSysEventTraceRow = TraceRow.skeleton<HiSysEventStruct>();
55    hiSysEventDataSender(hiSysEventTraceRow).then(result => {
56      expect(result).toHaveLength(1);
57    });
58  });
59});