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 {ThreadStruct} from "../../../dist/trace/bean/ThreadStruct.js" 18 19describe('ThreadStruct Test', () => { 20 const canvas = document.createElement('canvas'); 21 canvas.width = 1; 22 canvas.height = 1; 23 const ctx = canvas.getContext('2d'); 24 const dataSource = { 25 frame: { 26 x: 20, 27 y: 20, 28 width: 100, 29 height: 100 30 }, 31 startNS: 200, 32 state: '' 33 } 34 const equalsData = { 35 value: 50, 36 cpu: 1, 37 tid: 1, 38 state: 1, 39 startTime: 1, 40 dur: 1 41 } 42 43 it('ThreadStructTest01', function () { 44 expect(ThreadStruct.draw(ctx, dataSource)).toBeUndefined() 45 }); 46 47 it('ThreadStructTest02', function () { 48 dataSource.state = "S" 49 expect(ThreadStruct.draw(ctx, dataSource)).toBeUndefined() 50 }); 51 52 it('ThreadStructTest03', function () { 53 dataSource.state = "R" 54 expect(ThreadStruct.draw(ctx, dataSource)).toBeUndefined() 55 }); 56 57 it('ThreadStructTest04', function () { 58 dataSource.state = "D" 59 expect(ThreadStruct.draw(ctx, dataSource)).toBeUndefined() 60 }); 61 62 it('ThreadStructTest05', function () { 63 dataSource.state = "Running" 64 expect(ThreadStruct.draw(ctx, dataSource)).toBeUndefined() 65 }); 66 67 it('ThreadStructTest11', function () { 68 dataSource.state = "T"||"t" 69 expect(ThreadStruct.draw(ctx, dataSource)).toBeUndefined() 70 }); 71 72 it('ThreadStructTest06', function () { 73 expect(ThreadStruct.drawString(ctx, '', 2, dataSource.frame)).toBeUndefined() 74 }); 75 76 it('ThreadStructTest07', function () { 77 dataSource.frame.width = 10000000000000000; 78 expect(ThreadStruct.drawString(ctx, 'ThreadStructTest07', 1, dataSource.frame)).toBeUndefined() 79 }); 80 81 it('ThreadStructTest08', function () { 82 expect(ThreadStruct.equals(equalsData, equalsData)).toBeTruthy() 83 }); 84 85 it('ThreadStructTest09', function () { 86 expect(ThreadStruct.equals([], dataSource)).toBeFalsy() 87 }); 88 89 it('ThreadStructTest10', function () { 90 dataSource.state = 'ThreadStructTest10' 91 expect(ThreadStruct.getEndState(1)).toBe('') 92 }); 93}) 94