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 */ 15import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; 16import { irqDataSender } from '../../../../src/trace/database/data-trafic/IrqDataSender'; 17import { threadPool } from '../../../../src/trace/database/SqlLite'; 18import { IrqStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerIrq'; 19jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); 20jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 21 return {}; 22}); 23jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 24 return {}; 25}); 26describe('irqDataSender Test', () => { 27 let IrqData = 28 { 29 argSetId: 74, 30 depth: 0, 31 dur: 364, 32 frame: { x: 0, y: 5, width: 1, height: 30 }, 33 id: 74, 34 name: 'IPI', 35 startNS: 4255, 36 } 37 it('IrqDataSenderTest01', () => { 38 threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { 39 callback(IrqData, 1, true); 40 }); 41 let traceRow = TraceRow.skeleton<IrqStruct>(); 42 irqDataSender(0, 'irq', traceRow).then((res) => { 43 expect(res).toHaveLength(1); 44 }); 45 }); 46}); 47