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 16// @ts-ignore 17import {func, FuncStruct} from "../../../dist/trace/database/ProcedureWorkerFunc.js"; 18// @ts-ignore 19import {Rect} from "../../../dist/trace/component/trace/timer-shaft/Rect.js"; 20import {markAsUntransferable} from "worker_threads"; 21 22describe(' FPSTest', () => { 23 24 it('FuncTest01', () => { 25 let dataList = new Array(); 26 dataList.push({startTime: 0, dur: 10, frame: {x:0, y:9, width:10, height:10}}) 27 dataList.push({startTime: 1, dur: 111}) 28 let rect = new Rect(0, 10, 10, 10); 29 func(dataList, new Set(), 1, 100254, 100254, rect) 30 }) 31 32 it('FuncTest02', () => { 33 let dataList = new Array(); 34 dataList.push({startTime: 0, dur: 10, frame: {x:0, y:9, width:10, height:10}}) 35 dataList.push({startTime: 1, dur: 111, frame: {x:0, y:9, width:10, height:10}}) 36 let rect = new Rect(0, 10, 10, 10); 37 func(dataList, new Set(), 1, 100254, 100254, rect) 38 }) 39 40 it('FuncTest03', () => { 41 const canvas = document.createElement('canvas'); 42 canvas.width = 1; 43 canvas.height = 1; 44 const ctx = canvas.getContext('2d'); 45 46 const data = { 47 frame: { 48 x: 20, 49 y: 20, 50 width: 100, 51 height: 100 52 }, 53 startNS: 200, 54 value: 50, 55 dur:undefined || null || 0 56 } 57 expect(FuncStruct.draw(ctx, data)).toBeUndefined() 58 }) 59 60 61 it('FuncTest04', () => { 62 const canvas = document.createElement('canvas'); 63 canvas.width = 1; 64 canvas.height = 1; 65 const ctx = canvas.getContext('2d'); 66 FuncStruct.drawString(ctx, "1", 1,new Rect(0,0,100,100)); 67 }) 68 69 it('FuncTest05', () => { 70 const canvas = document.createElement('canvas'); 71 canvas.width = 1; 72 canvas.height = 1; 73 const ctx = canvas.getContext('2d'); 74 FuncStruct.drawString(ctx, "1", 2,new Rect(1,1,150,150)); 75 }); 76 77 it('FuncTest06 ', function () { 78 let str = "" 79 expect(FuncStruct.getInt(str)).toBe(0); 80 }); 81});