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 { threadDataReceiver } from '../../../../../src/trace/database/data-trafic/process/ThreadDataReceiver'; 17 18jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 19 return {}; 20}); 21 22describe('ThreadDataReceiver Test', () => { 23 let data = { 24 action: "exec-proto", 25 id: "258", 26 name: 30, 27 params: 28 { 29 endNS: 29372913537, 30 pid: 1668, 31 recordEndNS: 262379203084, 32 recordStartNS: 233006289547, 33 sharedArrayBuffers: undefined, 34 startNS: 0, 35 t: 1703581047560, 36 trafic: 2, 37 width: 1407 38 } 39 } 40 41 let threadData = [ 42 { 43 argSetId: -1, 44 cpu: null, 45 dur: 2327000, 46 id: 16, 47 pid: 590, 48 px: 285, 49 startTime: 2029133000, 50 state: "D", 51 tid: 590 52 }, 53 { 54 argSetId: -1, 55 cpu: 3, 56 dur: 14494000, 57 id: 6, 58 pid: 1668, 59 px: 1331, 60 startTime: 9464658000, 61 state: "Running", 62 tid: 1699 63 } 64 ] 65 it('ThreadDataReceiverTest01', async () => { 66 (self as unknown as Worker).postMessage = jest.fn(() => true); 67 expect(threadDataReceiver(data, () => { 68 return threadData; 69 })).toBeUndefined(); 70 }); 71});