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 frameActualReceiver, 18 frameExpectedReceiver 19} from "../../../../src/trace/database/data-trafic/FrameJanksReceiver"; 20 21describe('FrameJanksReceiver Test', () => { 22 let data = { 23 action: "exec-proto", 24 id: "5", 25 name: 16, 26 params: { 27 endNS: 8711323000, 28 queryEnum: 16, 29 recordEndNS: 512261248000, 30 recordStartNS: 503549925000, 31 sharedArrayBuffers: undefined, 32 startNS: 0, 33 t: 1703484466189, 34 trafic: 3, 35 width: 1407 36 } 37 } 38 39 let expectData = { 40 frameData: { 41 appDur: 16634548, 42 cmdline: "com.huawei.wx", 43 depth: 2, 44 dur: 33269438, 45 frameType: "frameTime", 46 id: 1007, 47 ipid: 135, 48 jankTag: -1, 49 name: 2299, 50 pid: 3104, 51 rsDur: 16634548, 52 rsIpid: 15, 53 rsPid: 994, 54 rsTs: 4996898311, 55 rsVsync: 1279, 56 ts: 4980263421, 57 type: "1" 58 } 59 } 60 61 let actualData = { 62 frameData: { 63 appDur: 1697000, 64 cmdline: "com.ohos.launch", 65 depth: 0, 66 dur: 24662000, 67 frameType: "frameTime", 68 id: 918, 69 ipid: 19, 70 name: 2280, 71 pid: 2128, 72 rsDur: 11082000, 73 rsIpid: 15, 74 rsPid: 994, 75 rsTs: 4681218000, 76 rsVsync: 1260, 77 ts: 4667638000, 78 type: "0" 79 } 80 } 81 it('FrameJanksReceiverTest01', function () { 82 (self as unknown as Worker).postMessage = jest.fn(() => true); 83 expect(frameExpectedReceiver(data, () => { 84 return expectData; 85 })).toBeUndefined(); 86 }); 87 88 it('FrameJanksReceiverTest02', function () { 89 (self as unknown as Worker).postMessage = jest.fn(() => true); 90 expect(frameActualReceiver(data, () => { 91 return actualData; 92 })).toBeUndefined(); 93 }); 94});