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 { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow';
17import { JankStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerJank';
18import { threadPool } from '../../../../../src/trace/database/SqlLite';
19import {
20  processExpectedDataSender
21} from '../../../../../src/trace/database/data-trafic/process/ProcessExpectedDataSender';
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('ProcessExpectedDataSender Test', () => {
30  let expectedData = {
31    cmdline: "render_service",
32    depth: 0,
33    dur: 166,
34    frame: {x: 336, y: 0, width: 3, height: 20},
35    frame_type: "render_service",
36    id: 415,
37    name: 1143,
38    pid: 994,
39    ts: 20862,
40    type: 1143
41  }
42  it('ExpectedDataSenderTest01', () => {
43    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
44      callback(expectedData, 1, true);
45    });
46    let expectedTraceRow = TraceRow.skeleton<JankStruct>();
47    processExpectedDataSender(994, expectedTraceRow).then(result => {
48      expect(result).toHaveLength(1);
49    });
50  });
51});