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