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//@ts-ignore 16import {hiPerfCpu,HiPerfCpuStruct} from "../../../dist/trace/database/ProcedureWorkerHiPerfCPU.js"; 17 18describe('ProcedureWorkerHiPerfCPU Test', ()=>{ 19 20 it('ProcedureWorkerHiPerfCPUTest01',()=>{ 21 const data = { 22 frame:undefined, 23 cpu:1, 24 startNs:1, 25 value:1, 26 } 27 const canvas = document.createElement('canvas'); 28 canvas.width = 1; 29 canvas.height = 1; 30 const ctx = canvas.getContext('2d'); 31 expect(HiPerfCpuStruct.draw(ctx,'',data,true)).toBeUndefined(); 32 }); 33 34 it('ProcedureWorkerHiPerfCPUTest02', function () { 35 let dataList = new Array(); 36 dataList.push({startNS: 0, dur: 10,length:1, frame: {x:0, y:9, width:10, height:10}}) 37 dataList.push({startNS: 1, dur: 2,length:1}) 38 hiPerfCpu(dataList, new Set(), 1, 8, 3, "",true) 39 }); 40 41 it('ProcedureWorkerHiPerfCPUTest03', function () { 42 let dataList = new Array(); 43 dataList.push({startNS: 0, dur: 10,length:1, frame: {x:0, y:9, width:10, height:10}}) 44 dataList.push({startNS: 1, dur: 2,length:1}) 45 hiPerfCpu(dataList, new Set(), 1, 8, 3, "",false) 46 }); 47 48 it('ProcedureWorkerHiPerfCPUTest04',()=>{ 49 const canvas = document.createElement('canvas'); 50 canvas.width = 1; 51 canvas.height = 1; 52 const ctx = canvas.getContext('2d'); 53 expect(HiPerfCpuStruct.drawRoundRectPath(ctx,1,1,1,1,1)).toBeUndefined(); 54 }); 55})