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 { funcDataSender } from '../../../../../src/trace/database/data-trafic/process/FuncDataSender';
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('FuncDataSender Test',()=>{
28  let FuncData = {
29    startTs: 1115,
30    dur: 0,
31    argsetid: 1462,
32    depth: 0,
33    id: 633,
34    itid: 120,
35    ipid: 52,
36    funName: "binder transaction async",
37    frame: {
38      x: 6,
39      y: 0,
40      width: 1,
41      height: 20
42    }
43  }
44  it('FuncDataSenderTest01 ', function () {
45    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
46      callback(FuncData, 1, true);
47    });
48    let tid = 1;
49    let ipid = 52;
50    let FuncDataTraceRow =  TraceRow.skeleton<FuncStruct>();
51    funcDataSender(tid,ipid,FuncDataTraceRow).then(res=>{
52      expect(res).toHaveLength(1);
53    })
54  });
55})