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 {FuncStruct} from "../../../dist/trace/bean/FuncStruct.js" 18 19describe('FuncStruct Test', ()=>{ 20 const canvas = document.createElement('canvas'); 21 canvas.width = 1; 22 canvas.height = 1; 23 const ctx = canvas.getContext('2d'); 24 25 const dataResource = { 26 frame: { 27 x: 20, 28 y: 20 29 } 30 } 31 32 const durData = { 33 frame: { 34 x: 20, 35 y: 20, 36 width: 100, 37 height: 100 38 }, 39 dur: 5 40 } 41 42 FuncStruct.isSelected = jest.fn(()=> true) 43 44 it('FuncStructTest01', function () { 45 expect(FuncStruct.draw(ctx, dataResource)).toBeUndefined() 46 }); 47 48 it('FuncStructTest02', function () { 49 expect(FuncStruct.draw(ctx, durData)).toBeUndefined() 50 }); 51 it('FuncStructTest03', function () { 52 expect(FuncStruct.drawString(ctx, 2, durData, durData.frame)).toBeUndefined() 53 }); 54 it('FuncStructTest06 ', function () { 55 expect(FuncStruct.drawString(ctx,3,durData,durData.frame)).toBeUndefined() 56 57 }); 58 59 it('FuncStructTest04', function () { 60 expect(FuncStruct.isSelected({ 61 startTs: 10, 62 dur: 10, 63 funName: '' 64 })).toBeTruthy(); 65 }); 66 67 68 it('FuncStructTest05', function () { 69 expect(FuncStruct.isBinder({ 70 startTs: 10, 71 dur: 10, 72 funName: null 73 })).toBeFalsy(); 74 }); 75 76 it('FuncStructTest07', function () { 77 expect(FuncStruct.drawString(ctx,300,durData,durData.frame)).toBeUndefined() 78 79 }); 80 81 it('FuncStructTest08', function () { 82 expect(FuncStruct.isBinderAsync({ 83 startTs: 10, 84 dur: 10, 85 funName: null 86 })).toBeFalsy(); 87 }); 88 89 it('FuncStructTest09', function () { 90 expect(FuncStruct.isBinderAsync({ 91 startTs: 20, 92 dur: 20, 93 funName: 'funName' 94 })).toBeFalsy(); 95 }); 96}) 97