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 { 17 processDeliverInputEventDataReceiver 18} from '../../../../../src/trace/database/data-trafic/process/ProcessDeliverInputEventDataReceiver'; 19 20jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 21 return {}; 22}); 23 24describe('DeliverInputEventDataReceiver Test', () => { 25 let data = { 26 action: "exec-proto", 27 id: "52", 28 name: 28, 29 params: 30 { 31 endNS: 20000305000, 32 recordEndNS: 168778663166000, 33 recordStartNS: 168758662861000, 34 sharedArrayBuffers: undefined, 35 startNS: 0, 36 t: 1703561897634, 37 tid: "1298", 38 trafic: 3, 39 width: 1407 40 } 41 } 42 let res = [ 43 { 44 processInputEventData: { 45 argsetid: -1, 46 cookie: 10350, 47 dur: 83000, 48 id: 41459, 49 isMainThread: 1, 50 parentId: -1, 51 pid: 1298, 52 startTs: 7379559000, 53 tid: 1298, 54 trackId: 14 55 } 56 }] 57 it('DeliverInputEventDataReceiverTest01', async () => { 58 let mockCallback = jest.fn(() => res); 59 (self as unknown as Worker).postMessage = jest.fn(); 60 processDeliverInputEventDataReceiver(data, mockCallback); 61 expect(mockCallback).toHaveBeenCalled(); 62 }); 63});