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 { processDataReceiver } from '../../../../../src/trace/database/data-trafic/process/ProcessDataReceiver'; 17 18jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 19 return {}; 20}); 21 22describe('ProcessDataReceiver Test', () => { 23 let data = { 24 action: "exec-proto", 25 id: "6", 26 name: 6, 27 params: 28 { 29 endNS: 8711323000, 30 pid: 431, 31 recordEndNS: 512261248000, 32 recordStartNS: 503549925000, 33 sharedArrayBuffers: undefined, 34 startNS: 0, 35 t: 1703560455293, 36 trafic: 0, 37 width: 1407 38 } 39 } 40 let processData = [ 41 { 42 cpu: 1, 43 dur: 1136000, 44 startTime: 3650382000, 45 v: true, 46 }, 47 { 48 cpu: 1, 49 dur: 104000, 50 startTime: 3665355000 51 } 52 ] 53 it('ProcessDataReceiverTest01', async () => { 54 (self as unknown as Worker).postMessage = jest.fn(() => true); 55 expect(processDataReceiver(data, () => { 56 return processData; 57 })).toBeUndefined(); 58 }); 59});