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 { FuncStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerFunc';
19import {
20  processDeliverInputEventDataSender
21} from '../../../../../src/trace/database/data-trafic/process/ProcessDeliverInputEventDataSender';
22jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {});
23jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
24  return {};
25});
26jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => {
27  return {};
28});
29describe('ProcessDataSender Test', () => {
30  let inputEventData = {
31    argsetid: 12,
32    cookie: 684,
33    depth: 0,
34    dur: 7810,
35    frame: {x: 516, y: 0, width: 1, height: 20},
36    funName: "deliverInputEvent",
37    id: 408,
38    is_main_thread: 1,
39    parent_id: 725,
40    pid: 756,
41    startTs: 740,
42    threadName: "ndroid.settings",
43    tid: 725,
44    track_id: 136
45  }
46  it('ProcessDataSenderTest01',  () => {
47    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
48      callback(inputEventData, 1, true);
49    });
50    let inputEventTraceRow = TraceRow.skeleton<FuncStruct>();
51    processDeliverInputEventDataSender(7256, inputEventTraceRow).then(result => {
52      expect(result).toHaveLength(1);
53    });
54  });
55});