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 { SampleRender, SampleStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerBpftrace'; 17import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; 18 19jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 20 return {}; 21}); 22 23jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { 24 return {}; 25}); 26jest.mock('../../../../src/trace/component/SpSystemTrace', () => { 27 return {}; 28}); 29describe('ProcedureWorkerSample Test', () => { 30 const canvas = document.createElement('canvas'); 31 canvas.width = 10; 32 canvas.height = 10; 33 const ctx = canvas.getContext('2d'); 34 it('ProcedureWorkerSampleTest01 ', function () { 35 const data = { 36 frame: { 37 x: 210, 38 y: 209, 39 width: 111, 40 height: 100, 41 }, 42 name: 'Sample', 43 cycle: -1, 44 value: 0, 45 depth: 0, 46 detail: 1 47 }; 48 expect(SampleStruct.draw(ctx, data)).toBeUndefined(); 49 }); 50 it('ProcedureWorkerSampleTest02 ', function () { 51 const data = { 52 context: ctx!, 53 useCache: true, 54 type: '', 55 traceRange: [], 56 }; 57 let sampleRender = new SampleRender(); 58 TraceRow.range = jest.fn(() => true); 59 TraceRow.range!.startNS = jest.fn(() => 0); 60 expect(sampleRender.renderMainThread(data, new TraceRow<SampleStruct>())).toBeUndefined(); 61 }); 62});