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 { LogDataSender } from '../../../../src/trace/database/data-trafic/LogDataSender'; 17import { threadPool } from '../../../../src/trace/database/SqlLite'; 18import { LogStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerLog'; 19import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; 20jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); 21 22jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 23 return {}; 24}); 25jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 26 return {}; 27}); 28describe('LogDataSender Test', () => { 29 let logData = { 30 id: 4, 31 startTs: 16276, 32 pid: 2082, 33 tid: 2082, 34 dur: 1, 35 depth: 1, 36 tag: 'C02c01/Init', 37 context: '[param_request.c:53]Can not get log level from param, keep the original loglevel.', 38 originTime: '08-06 15:43:19.954', 39 processName: 'hilog', 40 level: 'Info', 41 frame: { 42 'x': 1, 43 'y': 7, 44 'width': 1, 45 'height': 7 46 } 47 } 48 it('LogDataSenderTest01', () => { 49 threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { 50 callback(logData, 1, true); 51 }); 52 let logTraceRow = TraceRow.skeleton<LogStruct>(); 53 LogDataSender(logTraceRow).then(res => { 54 expect(res).toHaveLength(1); 55 }); 56 }); 57});