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 { FpsStruct } from '../../../src/trace/bean/FpsStruct'; 17 18jest.mock('../../../src/js-heap/model/DatabaseStruct', () => { 19}); 20jest.mock('../../../src/trace/database/ui-worker/ProcedureWorker', () => { 21 return {}; 22}); 23 24describe('FpsStruct Test', () => { 25 const canvas = document.createElement('canvas'); 26 canvas.width = 4; 27 canvas.height = 2; 28 const ctx = canvas.getContext('2d'); 29 30 const data = { 31 frame: { 32 x: 201, 33 y: 202, 34 width: 100, 35 height: 100, 36 }, 37 startNS: 200, 38 value: 50, 39 }; 40 const node = { 41 startNS: 200, 42 frame: 2, 43 dur: 3, 44 }; 45 const padding = 1; 46 const startNs = 1; 47 const endNS = 1; 48 const totalNS = 1; 49 const frame = { 50 x: 20, 51 y: 20, 52 width: 100, 53 height: 100, 54 }; 55 const dataSource = { 56 frame: { 57 x: 20, 58 y: 20, 59 width: 100, 60 height: 100, 61 }, 62 value: 50, 63 maxFps: 50, 64 }; 65 66 it('FpsStructTest01', function () { 67 expect(FpsStruct.draw(ctx, data)).toBeUndefined(); 68 }); 69 70 it('FpsStructTest04 ', function () { 71 expect(FpsStruct.draw(ctx, dataSource)).toBeUndefined(); 72 }); 73 74 it('FpsStructTest02', function () { 75 let fpsStruct = new FpsStruct(); 76 expect(fpsStruct).not.toBeUndefined(); 77 }); 78 79 it('FpsStructTest03', function () { 80 expect(FpsStruct.setFrame(node, padding, startNs, endNS, totalNS, frame)).toBeUndefined(); 81 }); 82}); 83