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 { ClockStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerClock';
19import { clockDataSender } from '../../../../src/trace/database/data-trafic/ClockDataSender';
20
21jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => ({}));
22jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => ({}));
23jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => ({}));
24describe('ClockDataSender Test', () => {
25  const clockData = {
26    filterId: 89,
27    value: 48000,
28    startNS: 19733,
29    dur: 230475,
30    type: 'measure',
31    delta: 0,
32    frame: {
33      y: 5,
34      height: 30,
35      x: 11,
36      width: 14
37    }
38  };
39  let clockTraceRow = TraceRow.skeleton<ClockStruct>();
40  it('ClockDataSenderTest01', async () => {
41    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
42      callback(clockData, 1, true);
43    });
44    let result = await clockDataSender('', 'screenState', clockTraceRow);
45    expect(result).toHaveLength(1);
46  });
47});