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 { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; 17 18import { BinderRender, BinderStruct } from '../../../../src/trace/database/ui-worker/procedureWorkerBinder'; 19import { SpSegmentationChart } from '../../../../src/trace/component/chart/SpSegmentationChart'; 20 21jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 22 return {}; 23}); 24jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => { 25 return {}; 26}); 27jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 28 return {}; 29}); 30jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { 31 return {}; 32}); 33jest.mock('../../../../src/trace/component/SpSystemTrace', () => { 34 return {}; 35}); 36describe('Binder Test', () => { 37 const canvas = document.createElement('canvas'); 38 canvas.width = 10; 39 canvas.height = 10; 40 TraceRow.range = jest.fn(() => { 41 return { 42 startNS: 0 43 } 44 }); 45 SpSegmentationChart.trace = jest.fn(); 46 SpSegmentationChart.trace.traceSheetEL = jest.fn(); 47 const ctx = canvas.getContext('2d'); 48 it('BinderTest01 ', function () { 49 const data = { 50 frame: { 51 x: 210, 52 y: 209, 53 width: 111, 54 height: 100, 55 }, 56 name: 'binder transaction', 57 cycle: -1, 58 value: 0, 59 depth: 0, 60 startNS: 0 61 }; 62 expect(BinderStruct.draw(ctx, data)).toBeUndefined(); 63 }); 64 it('BinderTest02', () => { 65 const data = { 66 context: ctx!, 67 useCache: true, 68 type: '', 69 traceRange: [], 70 }; 71 let binderRender = new BinderRender(); 72 expect(binderRender.renderMainThread(data, new TraceRow<BinderStruct>())).toBeUndefined(); 73 }); 74}); 75