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 16 17import { cpuProfilerDataSender } from '../../../../src/trace/database/data-trafic/ArkTsSender'; 18import { threadPool } from '../../../../src/trace/database/SqlLite'; 19import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; 20import { JsCpuProfilerStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCpuProfiler'; 21jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); 22jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 23 return {}; 24}); 25jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 26 return {}; 27}); 28 29describe('cpuProfilerDataSender Test', () => { 30 let cpuProfilerData = { 31 column: [25, 30], 32 depth: [0, 1], 33 samplesIds: [[1, 2], [3, 4]], 34 childrenIds: [[5, 6], [7, 8]], 35 maxDepth: 5, 36 }; 37 it('cpuProfilerDataSenderTest01', () => { 38 threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { 39 callback(cpuProfilerData, 1, true); 40 }); 41 let cpuProfilerDataTraceRow = TraceRow.skeleton<JsCpuProfilerStruct>(); 42 cpuProfilerDataSender(cpuProfilerDataTraceRow).then(result => { 43 expect(result).toBeTruthy(); 44 }); 45 }); 46}); 47