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 { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; 18 19jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { 20 return {}; 21}); 22// @ts-ignore 23import { CpuFreqStruct, FreqRender, freq } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerFreq.js'; 24// @ts-ignore 25import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js'; 26 27describe('freqTest', () => { 28 it('freqTest01', () => { 29 const canvas = document.createElement('canvas'); 30 canvas.width = 10; 31 canvas.height = 10; 32 const ctx = canvas.getContext('2d'); 33 34 const data = { 35 frame: { 36 x: 210, 37 y: 210, 38 width: 100, 39 height: 100, 40 }, 41 startNS: 200, 42 value: 50, 43 }; 44 45 expect(CpuFreqStruct.draw(ctx, data)).toBeUndefined(); 46 }); 47 it('freqTest02', () => { 48 const canvas = document.createElement('canvas'); 49 canvas.width = 1; 50 canvas.height = 1; 51 const ctx = canvas.getContext('2d'); 52 const Sourcedata = { 53 frame: { 54 x: 20, 55 y: 20, 56 width: 100, 57 height: 100, 58 }, 59 maxFreq: 200, 60 value: 50, 61 }; 62 expect(CpuFreqStruct.draw(ctx, Sourcedata)).toBeUndefined(); 63 }); 64 it('freqTest03', () => { 65 let canvas = document.createElement('canvas') as HTMLCanvasElement; 66 let context = canvas.getContext('2d'); 67 const data = { 68 context: context!, 69 useCache: true, 70 type: '', 71 traceRange: [], 72 }; 73 let freqRender = new FreqRender(); 74 expect(freqRender.renderMainThread(data, new TraceRow())).toBeUndefined(); 75 }); 76}); 77