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 */ 15import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; 16import { 17 AllAppStartupRender, 18 AllAppStartupStruct 19} from '../../../../src/trace/database/ui-worker/ProcedureWorkerAllAppStartup'; 20 21jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 22 return {}; 23}); 24jest.mock('../../../../src/trace/component/SpSystemTrace', () => { 25 return {}; 26}); 27describe('ProcedureWorkerAllAppStartup Test',()=>{ 28 it('ProcedureWorkerAllAppStartup01 ', function () { 29 const data = { 30 frame: { 31 x: 20, 32 y: 19, 33 width: 10, 34 height: 3, 35 }, 36 dur: 1, 37 value: 'aa', 38 startTs: 12, 39 pid: 2, 40 process: 'null', 41 itid: 12, 42 endItid: 13, 43 tid: 3, 44 startName: '23', 45 stepName: 'st', 46 }; 47 const canvas = document.createElement('canvas'); 48 canvas.width = 1; 49 canvas.height = 1; 50 const ctx = canvas.getContext('2d'); 51 expect(AllAppStartupStruct.draw(ctx, data)).toBeUndefined(); 52 }); 53 it('ProcedureWorkerAllAppStartup02 ',()=>{ 54 let allAppStartupRender = new AllAppStartupRender() 55 let allAppStartupReq = { 56 lazyRefresh: true, 57 type: '', 58 startNS: 5, 59 endNS: 9, 60 totalNS: 4, 61 frame: { 62 x: 32, 63 y: 20, 64 width: 180, 65 height: 180, 66 }, 67 useCache: true, 68 range: { 69 refresh: '', 70 }, 71 canvas: 'a', 72 appStartupContext: { 73 font: '12px sans-serif', 74 fillStyle: '#a1697d', 75 globalAlpha: 0.3, 76 measureText: jest.fn(() => true), 77 clearRect: jest.fn(() => true), 78 stroke: jest.fn(() => true), 79 closePath: jest.fn(() => false), 80 beginPath: jest.fn(() => true), 81 fillRect: jest.fn(() => false), 82 fillText: jest.fn(() => true), 83 }, 84 lineColor: '', 85 isHover: 'true', 86 hoverX: 0, 87 params: '', 88 wakeupBean: undefined, 89 flagMoveInfo: '', 90 flagSelectedInfo: '', 91 slicesTime: 4, 92 id: 1, 93 x: 24, 94 y: 24, 95 width: 100, 96 height: 100, 97 }; 98 window.postMessage = jest.fn(() => true); 99 expect(allAppStartupRender.renderMainThread(allAppStartupReq,new TraceRow<AllAppStartupStruct>())).toBeUndefined() 100 }) 101})